diff options
Diffstat (limited to 'clang/unittests/Tooling/Syntax/TreeTest.cpp')
-rw-r--r-- | clang/unittests/Tooling/Syntax/TreeTest.cpp | 209 |
1 files changed, 208 insertions, 1 deletions
diff --git a/clang/unittests/Tooling/Syntax/TreeTest.cpp b/clang/unittests/Tooling/Syntax/TreeTest.cpp index 6e914b6..cfed1ee 100644 --- a/clang/unittests/Tooling/Syntax/TreeTest.cpp +++ b/clang/unittests/Tooling/Syntax/TreeTest.cpp @@ -99,6 +99,7 @@ protected: Diags->setClient(new IgnoringDiagConsumer); // Prepare to run a compiler. std::vector<const char *> Args = {"syntax-test", "-std=c++11", + "-fno-delayed-template-parsing", "-fsyntax-only", FileName}; Invocation = createInvocationFromCommandLine(Args, Diags, FS); assert(Invocation); @@ -678,6 +679,212 @@ struct {} *a1; `-; )txt"}, {R"cpp( +template <class T> struct cls {}; +template <class T> int var = 10; +template <class T> int fun() {} + )cpp", + R"txt( +*: TranslationUnit +|-TemplateDeclaration +| |-template +| |-< +| |-UnknownDeclaration +| | |-class +| | `-T +| |-> +| `-SimpleDeclaration +| |-struct +| |-cls +| |-{ +| |-} +| `-; +|-TemplateDeclaration +| |-template +| |-< +| |-UnknownDeclaration +| | |-class +| | `-T +| |-> +| `-SimpleDeclaration +| |-int +| |-SimpleDeclarator +| | |-var +| | |-= +| | `-UnknownExpression +| | `-10 +| `-; +`-TemplateDeclaration + |-template + |-< + |-UnknownDeclaration + | |-class + | `-T + |-> + `-SimpleDeclaration + |-int + |-SimpleDeclarator + | |-fun + | `-ParametersAndQualifiers + | |-( + | `-) + `-CompoundStatement + |-{ + `-} +)txt"}, + {R"cpp( +template <class T> +struct X { + template <class U> + U foo(); +}; + )cpp", + R"txt( +*: TranslationUnit +`-TemplateDeclaration + |-template + |-< + |-UnknownDeclaration + | |-class + | `-T + |-> + `-SimpleDeclaration + |-struct + |-X + |-{ + |-TemplateDeclaration + | |-template + | |-< + | |-UnknownDeclaration + | | |-class + | | `-U + | |-> + | `-SimpleDeclaration + | |-U + | |-SimpleDeclarator + | | |-foo + | | `-ParametersAndQualifiers + | | |-( + | | `-) + | `-; + |-} + `-; +)txt"}, + {R"cpp( +template <class T> struct X {}; +template <class T> struct X<T*> {}; +template <> struct X<int> {}; + +template struct X<double>; +extern template struct X<float>; +)cpp", + R"txt( +*: TranslationUnit +|-TemplateDeclaration +| |-template +| |-< +| |-UnknownDeclaration +| | |-class +| | `-T +| |-> +| `-SimpleDeclaration +| |-struct +| |-X +| |-{ +| |-} +| `-; +|-TemplateDeclaration +| |-template +| |-< +| |-UnknownDeclaration +| | |-class +| | `-T +| |-> +| `-SimpleDeclaration +| |-struct +| |-X +| |-< +| |-T +| |-* +| |-> +| |-{ +| |-} +| `-; +|-TemplateDeclaration +| |-template +| |-< +| |-> +| `-SimpleDeclaration +| |-struct +| |-X +| |-< +| |-int +| |-> +| |-{ +| |-} +| `-; +|-ExplicitTemplateInstantiation +| |-template +| `-SimpleDeclaration +| |-struct +| |-X +| |-< +| |-double +| |-> +| `-; +`-ExplicitTemplateInstantiation + |-extern + |-template + `-SimpleDeclaration + |-struct + |-X + |-< + |-float + |-> + `-; +)txt"}, + {R"cpp( +template <class T> struct X { struct Y; }; +template <class T> struct X<T>::Y {}; + )cpp", + R"txt( +*: TranslationUnit +|-TemplateDeclaration +| |-template +| |-< +| |-UnknownDeclaration +| | |-class +| | `-T +| |-> +| `-SimpleDeclaration +| |-struct +| |-X +| |-{ +| |-SimpleDeclaration +| | |-struct +| | |-Y +| | `-; +| |-} +| `-; +`-TemplateDeclaration + |-template + |-< + |-UnknownDeclaration + | |-class + | `-T + |-> + `-SimpleDeclaration + |-struct + |-X + |-< + |-T + |-> + |-:: + |-Y + |-{ + |-} + `-; + )txt"}, + {R"cpp( namespace ns {} using namespace ::ns; )cpp", @@ -726,7 +933,7 @@ template <class T> struct X { )cpp", R"txt( *: TranslationUnit -`-UnknownDeclaration +`-TemplateDeclaration |-template |-< |-UnknownDeclaration |