forked from OSchip/llvm-project
[ASTImporter] Import the default argument of TemplateTypeParmDecl
The test case isn't using the AST matchers for all checks as there doesn't seem to be support for matching TemplateTypeParmDecl default arguments. Otherwise this is simply importing the default arguments. Also updates several LLDB tests that now as intended omit the default template arguments of several std templates. Reviewed By: martong Differential Revision: https://reviews.llvm.org/D92103
This commit is contained in:
parent
3d7f19ff18
commit
3f6c856bb5
|
@ -5158,8 +5158,6 @@ ASTNodeImporter::VisitTemplateTypeParmDecl(TemplateTypeParmDecl *D) {
|
|||
// context. This context will be fixed when the actual template declaration
|
||||
// is created.
|
||||
|
||||
// FIXME: Import default argument and constraint expression.
|
||||
|
||||
ExpectedSLoc BeginLocOrErr = import(D->getBeginLoc());
|
||||
if (!BeginLocOrErr)
|
||||
return BeginLocOrErr.takeError();
|
||||
|
@ -5206,6 +5204,14 @@ ASTNodeImporter::VisitTemplateTypeParmDecl(TemplateTypeParmDecl *D) {
|
|||
ToIDC);
|
||||
}
|
||||
|
||||
if (D->hasDefaultArgument()) {
|
||||
Expected<TypeSourceInfo *> ToDefaultArgOrErr =
|
||||
import(D->getDefaultArgumentInfo());
|
||||
if (!ToDefaultArgOrErr)
|
||||
return ToDefaultArgOrErr.takeError();
|
||||
ToD->setDefaultArgument(*ToDefaultArgOrErr);
|
||||
}
|
||||
|
||||
return ToD;
|
||||
}
|
||||
|
||||
|
|
|
@ -880,6 +880,25 @@ TEST_P(ImportExpr, DependentSizedArrayType) {
|
|||
has(fieldDecl(hasType(dependentSizedArrayType())))))));
|
||||
}
|
||||
|
||||
TEST_P(ASTImporterOptionSpecificTestBase, TemplateTypeParmDeclNoDefaultArg) {
|
||||
Decl *FromTU = getTuDecl("template<typename T> struct X {};", Lang_CXX03);
|
||||
auto From = FirstDeclMatcher<TemplateTypeParmDecl>().match(
|
||||
FromTU, templateTypeParmDecl(hasName("T")));
|
||||
TemplateTypeParmDecl *To = Import(From, Lang_CXX03);
|
||||
ASSERT_FALSE(To->hasDefaultArgument());
|
||||
}
|
||||
|
||||
TEST_P(ASTImporterOptionSpecificTestBase, TemplateTypeParmDeclDefaultArg) {
|
||||
Decl *FromTU =
|
||||
getTuDecl("template<typename T = int> struct X {};", Lang_CXX03);
|
||||
auto From = FirstDeclMatcher<TemplateTypeParmDecl>().match(
|
||||
FromTU, templateTypeParmDecl(hasName("T")));
|
||||
TemplateTypeParmDecl *To = Import(From, Lang_CXX03);
|
||||
ASSERT_TRUE(To->hasDefaultArgument());
|
||||
QualType ToArg = To->getDefaultArgument();
|
||||
ASSERT_EQ(ToArg, QualType(To->getASTContext().IntTy));
|
||||
}
|
||||
|
||||
TEST_P(ASTImporterOptionSpecificTestBase, ImportBeginLocOfDeclRefExpr) {
|
||||
Decl *FromTU =
|
||||
getTuDecl("class A { public: static int X; }; void f() { (void)A::X; }",
|
||||
|
|
|
@ -22,7 +22,7 @@ class TestBasicDeque(TestBase):
|
|||
|
||||
self.runCmd("settings set target.import-std-module true")
|
||||
|
||||
deque_type = "std::deque<int, std::allocator<int> >"
|
||||
deque_type = "std::deque<int>"
|
||||
size_type = deque_type + "::size_type"
|
||||
value_type = "std::__deque_base<int, std::allocator<int> >::value_type"
|
||||
iterator = deque_type + "::iterator"
|
||||
|
|
|
@ -22,7 +22,7 @@ class TestDbgInfoContentDeque(TestBase):
|
|||
|
||||
self.runCmd("settings set target.import-std-module true")
|
||||
|
||||
deque_type = "std::deque<Foo, std::allocator<Foo> >"
|
||||
deque_type = "std::deque<Foo>"
|
||||
size_type = deque_type + "::size_type"
|
||||
value_type = "std::__deque_base<Foo, std::allocator<Foo> >::value_type"
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ class TestDbgInfoContentForwardList(TestBase):
|
|||
|
||||
self.runCmd("settings set target.import-std-module true")
|
||||
|
||||
list_type = "std::forward_list<Foo, std::allocator<Foo> >"
|
||||
list_type = "std::forward_list<Foo>"
|
||||
value_type = list_type + "::value_type"
|
||||
|
||||
# FIXME: This has three elements in it but the formatter seems to
|
||||
|
|
|
@ -22,7 +22,7 @@ class TestBasicForwardList(TestBase):
|
|||
|
||||
self.runCmd("settings set target.import-std-module true")
|
||||
|
||||
list_type = "std::forward_list<int, std::allocator<int> >"
|
||||
list_type = "std::forward_list<int>"
|
||||
value_type = list_type + "::value_type"
|
||||
|
||||
# FIXME: This has three elements in it but the formatter seems to
|
||||
|
|
|
@ -23,7 +23,7 @@ class TestDbgInfoContentList(TestBase):
|
|||
|
||||
self.runCmd("settings set target.import-std-module true")
|
||||
|
||||
list_type = "std::list<Foo, std::allocator<Foo> >"
|
||||
list_type = "std::list<Foo>"
|
||||
size_type = list_type + "::size_type"
|
||||
value_type = list_type + "::value_type"
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ class TestBasicList(TestBase):
|
|||
|
||||
self.runCmd("settings set target.import-std-module true")
|
||||
|
||||
list_type = "std::list<int, std::allocator<int> >"
|
||||
list_type = "std::list<int>"
|
||||
size_type = list_type + "::size_type"
|
||||
value_type = list_type + "::value_type"
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ class TestQueue(TestBase):
|
|||
|
||||
self.runCmd("settings set target.import-std-module true")
|
||||
|
||||
queue_type = "std::queue<C, std::deque<C, std::allocator<C> > >"
|
||||
queue_type = "std::queue<C>"
|
||||
size_type = queue_type + "::size_type"
|
||||
value_type = "std::__deque_base<C, std::allocator<C> >::value_type"
|
||||
|
||||
|
@ -54,9 +54,9 @@ class TestQueue(TestBase):
|
|||
result_value="5")
|
||||
|
||||
# Test std::queue functionality with a std::list.
|
||||
queue_type = "std::queue<C, std::list<C, std::allocator<C> > >"
|
||||
queue_type = "std::queue<C, std::list<C> >"
|
||||
size_type = queue_type + "::size_type"
|
||||
value_type = "std::list<C, std::allocator<C> >::value_type"
|
||||
value_type = "std::list<C>::value_type"
|
||||
self.expect_expr(
|
||||
"q_list",
|
||||
result_type=queue_type,
|
||||
|
|
|
@ -22,7 +22,7 @@ class TestStack(TestBase):
|
|||
self.runCmd("settings set target.import-std-module true")
|
||||
|
||||
# Test std::stack functionality with a std::deque.
|
||||
stack_type = "std::stack<C, std::deque<C, std::allocator<C> > >"
|
||||
stack_type = "std::stack<C>"
|
||||
size_type = stack_type + "::size_type"
|
||||
|
||||
self.expect_expr("s_deque", result_type=stack_type)
|
||||
|
@ -40,7 +40,7 @@ class TestStack(TestBase):
|
|||
result_value="5")
|
||||
|
||||
# Test std::stack functionality with a std::vector.
|
||||
stack_type = "std::stack<C, std::vector<C, std::allocator<C> > >"
|
||||
stack_type = "std::stack<C, std::vector<C> >"
|
||||
size_type = stack_type + "::size_type"
|
||||
|
||||
self.expect_expr("s_vector", result_type=stack_type)
|
||||
|
@ -58,7 +58,7 @@ class TestStack(TestBase):
|
|||
result_value="5")
|
||||
|
||||
# Test std::stack functionality with a std::list.
|
||||
stack_type = "std::stack<C, std::list<C, std::allocator<C> > >"
|
||||
stack_type = "std::stack<C, std::list<C> >"
|
||||
size_type = stack_type + "::size_type"
|
||||
self.expect_expr("s_list", result_type=stack_type)
|
||||
self.expect("expr s_list.pop()")
|
||||
|
|
|
@ -25,7 +25,7 @@ class TestUniquePtrDbgInfoContent(TestBase):
|
|||
|
||||
self.expect_expr(
|
||||
"s",
|
||||
result_type="std::unique_ptr<Foo, std::default_delete<Foo> >",
|
||||
result_type="std::unique_ptr<Foo>",
|
||||
result_children=[ValueCheck(children=[ValueCheck(value="3")])])
|
||||
self.expect_expr("s->a", result_type="int", result_value="3")
|
||||
self.expect_expr("s->a = 5", result_type="int", result_value="5")
|
||||
|
|
|
@ -25,7 +25,7 @@ class TestUniquePtr(TestBase):
|
|||
|
||||
self.expect_expr(
|
||||
"s",
|
||||
result_type="std::unique_ptr<int, std::default_delete<int> >",
|
||||
result_type="std::unique_ptr<int>",
|
||||
result_summary="3",
|
||||
result_children=[ValueCheck(name="__value_")])
|
||||
self.expect_expr("*s", result_type="int", result_value="3")
|
||||
|
|
|
@ -20,7 +20,7 @@ class TestBoolVector(TestBase):
|
|||
"// Set break point at this line.",
|
||||
lldb.SBFileSpec("main.cpp"))
|
||||
|
||||
vector_type = "std::vector<bool, std::allocator<bool> >"
|
||||
vector_type = "std::vector<bool>"
|
||||
size_type = vector_type + "::size_type"
|
||||
|
||||
self.runCmd("settings set target.import-std-module true")
|
||||
|
|
|
@ -23,7 +23,7 @@ class TestDbgInfoContentVector(TestBase):
|
|||
|
||||
self.runCmd("settings set target.import-std-module true")
|
||||
|
||||
vector_type = "std::vector<Foo, std::allocator<Foo> >"
|
||||
vector_type = "std::vector<Foo>"
|
||||
size_type = vector_type + "::size_type"
|
||||
value_type = vector_type + "::value_type"
|
||||
iterator = vector_type + "::iterator"
|
||||
|
|
|
@ -20,13 +20,9 @@ class TestVectorOfVectors(TestBase):
|
|||
"// Set break point at this line.",
|
||||
lldb.SBFileSpec("main.cpp"))
|
||||
|
||||
vector_type = "std::vector<int, std::allocator<int> >"
|
||||
vector_of_vector_type = "std::vector<" + vector_type + \
|
||||
", std::allocator<std::vector<int, std::allocator<int> > > >"
|
||||
size_type = (
|
||||
"std::vector<std::vector<int, std::allocator<int> >, " +
|
||||
"std::allocator<std::vector<int, std::allocator<int> > >" +
|
||||
" >::size_type")
|
||||
vector_type = "std::vector<int>"
|
||||
vector_of_vector_type = "std::vector<" + vector_type + " >"
|
||||
size_type = vector_of_vector_type + "::size_type"
|
||||
value_type = "std::__vector_base<int, std::allocator<int> >::value_type"
|
||||
|
||||
self.runCmd("settings set target.import-std-module true")
|
||||
|
@ -35,13 +31,13 @@ class TestVectorOfVectors(TestBase):
|
|||
"a",
|
||||
result_type=vector_of_vector_type,
|
||||
result_children=[
|
||||
ValueCheck(type="std::vector<int, std::allocator<int> >",
|
||||
ValueCheck(type="std::vector<int>",
|
||||
children=[
|
||||
ValueCheck(value='1'),
|
||||
ValueCheck(value='2'),
|
||||
ValueCheck(value='3'),
|
||||
]),
|
||||
ValueCheck(type="std::vector<int, std::allocator<int> >",
|
||||
ValueCheck(type="std::vector<int>",
|
||||
children=[
|
||||
ValueCheck(value='3'),
|
||||
ValueCheck(value='2'),
|
||||
|
|
|
@ -22,7 +22,7 @@ class TestBasicVector(TestBase):
|
|||
|
||||
self.runCmd("settings set target.import-std-module true")
|
||||
|
||||
vector_type = "std::vector<int, std::allocator<int> >"
|
||||
vector_type = "std::vector<int>"
|
||||
size_type = vector_type + "::size_type"
|
||||
value_type = "std::__vector_base<int, std::allocator<int> >::value_type"
|
||||
iterator = vector_type + "::iterator"
|
||||
|
|
Loading…
Reference in New Issue