diff --git a/clang/test/AST/ast-dump-attr.cpp b/clang/test/AST/ast-dump-attr.cpp index c2bd768dc2adfc..25cfa6820b3724 100644 --- a/clang/test/AST/ast-dump-attr.cpp +++ b/clang/test/AST/ast-dump-attr.cpp @@ -1,261 +1,261 @@ -// Test without serialization: -// RUN: %clang_cc1 -triple x86_64-pc-linux -std=c++11 -Wno-deprecated-declarations -ast-dump -ast-dump-filter Test %s \ -// RUN: | FileCheck --strict-whitespace %s -// -// Test with serialization: -// RUN: %clang_cc1 -triple x86_64-pc-linux -std=c++11 -Wno-deprecated-declarations -emit-pch -o %t %s -// RUN: %clang_cc1 -x c++ -triple x86_64-pc-linux -std=c++11 -Wno-deprecated-declarations \ -// RUN: -include-pch %t -ast-dump-all -ast-dump-filter Test /dev/null \ -// RUN: | sed -e "s/ //" -e "s/ imported//" \ -// RUN: | FileCheck --strict-whitespace %s - -int TestLocation -__attribute__((unused)); -// CHECK: VarDecl{{.*}}TestLocation -// CHECK-NEXT: UnusedAttr 0x{{[^ ]*}} - -int TestIndent -__attribute__((unused)); -// CHECK: {{^}}VarDecl{{.*TestIndent[^()]*$}} -// CHECK-NEXT: {{^}}`-UnusedAttr{{[^()]*$}} - -void TestAttributedStmt() { - switch (1) { - case 1: - [[clang::fallthrough]]; - case 2: - ; - } -} -// CHECK: FunctionDecl{{.*}}TestAttributedStmt -// CHECK: AttributedStmt -// CHECK-NEXT: FallThroughAttr -// CHECK-NEXT: NullStmt - -[[clang::warn_unused_result]] int TestCXX11DeclAttr(); -// CHECK: FunctionDecl{{.*}}TestCXX11DeclAttr -// CHECK-NEXT: WarnUnusedResultAttr - -int TestAlignedNull __attribute__((aligned)); -// CHECK: VarDecl{{.*}}TestAlignedNull -// CHECK-NEXT: AlignedAttr {{.*}} aligned -// CHECK-NEXT: <<>> - -int TestAlignedExpr __attribute__((aligned(4))); -// CHECK: VarDecl{{.*}}TestAlignedExpr -// CHECK-NEXT: AlignedAttr {{.*}} aligned -// CHECK-NEXT: ConstantExpr -// CHECK-NEXT: value: Int 4 -// CHECK-NEXT: IntegerLiteral - -int TestEnum __attribute__((visibility("default"))); -// CHECK: VarDecl{{.*}}TestEnum -// CHECK-NEXT: VisibilityAttr{{.*}} Default - -class __attribute__((lockable)) Mutex { -} mu1, mu2; -int TestExpr __attribute__((guarded_by(mu1))); -// CHECK: VarDecl{{.*}}TestExpr -// CHECK-NEXT: GuardedByAttr -// CHECK-NEXT: DeclRefExpr{{.*}}mu1 - -class Mutex TestVariadicExpr __attribute__((acquired_after(mu1, mu2))); -// CHECK: VarDecl{{.*}}TestVariadicExpr -// CHECK: AcquiredAfterAttr -// CHECK-NEXT: DeclRefExpr{{.*}}mu1 -// CHECK-NEXT: DeclRefExpr{{.*}}mu2 - -void function1(void *) { - int TestFunction __attribute__((cleanup(function1))); -} -// CHECK: VarDecl{{.*}}TestFunction -// CHECK-NEXT: CleanupAttr{{.*}} Function{{.*}}function1 - -void TestIdentifier(void *, int) -__attribute__((pointer_with_type_tag(ident1,1,2))); -// CHECK: FunctionDecl{{.*}}TestIdentifier -// CHECK: ArgumentWithTypeTagAttr{{.*}} pointer_with_type_tag ident1 - -void TestBool(void *, int) -__attribute__((pointer_with_type_tag(bool1,1,2))); -// CHECK: FunctionDecl{{.*}}TestBool -// CHECK: ArgumentWithTypeTagAttr{{.*}}pointer_with_type_tag bool1 1 2 IsPointer - -void TestUnsigned(void *, int) -__attribute__((pointer_with_type_tag(unsigned1,1,2))); -// CHECK: FunctionDecl{{.*}}TestUnsigned -// CHECK: ArgumentWithTypeTagAttr{{.*}} pointer_with_type_tag unsigned1 1 2 - -void TestInt(void) __attribute__((constructor(123))); -// CHECK: FunctionDecl{{.*}}TestInt -// CHECK-NEXT: ConstructorAttr{{.*}} 123 - -static int TestString __attribute__((alias("alias1"))); -// CHECK: VarDecl{{.*}}TestString -// CHECK-NEXT: AliasAttr{{.*}} "alias1" - -extern struct s1 TestType -__attribute__((type_tag_for_datatype(ident1,int))); -// CHECK: VarDecl{{.*}}TestType -// CHECK-NEXT: TypeTagForDatatypeAttr{{.*}} int - -void TestLabel() { -L: __attribute__((unused)) int i; -// CHECK: LabelStmt{{.*}}'L' -// CHECK: VarDecl{{.*}}i 'int' -// CHECK-NEXT: UnusedAttr{{.*}} - -M: __attribute(()) int j; -// CHECK: LabelStmt {{.*}} 'M' -// CHECK-NEXT: DeclStmt -// CHECK-NEXT: VarDecl {{.*}} j 'int' - -N: __attribute(()) ; -// CHECK: LabelStmt {{.*}} 'N' -// CHECK-NEXT: NullStmt -} - -namespace Test { -extern "C" int printf(const char *format, ...); -// CHECK: FunctionDecl{{.*}}printf -// CHECK-NEXT: ParmVarDecl{{.*}}format{{.*}}'const char *' -// CHECK-NEXT: BuiltinAttr{{.*}}Implicit -// CHECK-NEXT: FormatAttr{{.*}}Implicit printf 1 2 - -alignas(8) extern int x; -extern int x; -// CHECK: VarDecl{{.*}} x 'int' -// CHECK: VarDecl{{.*}} x 'int' -// CHECK-NEXT: AlignedAttr{{.*}} Inherited -} - -int __attribute__((cdecl)) TestOne(void), TestTwo(void); -// CHECK: FunctionDecl{{.*}}TestOne{{.*}}__attribute__((cdecl)) -// CHECK: FunctionDecl{{.*}}TestTwo{{.*}}__attribute__((cdecl)) - -void func() { - auto Test = []() __attribute__((no_thread_safety_analysis)) {}; - // CHECK: CXXMethodDecl{{.*}}operator() 'void () const' - // CHECK: NoThreadSafetyAnalysisAttr - - // Because GNU's noreturn applies to the function type, and this lambda does - // not have a capture list, the call operator and the function pointer - // conversion should both be noreturn, but the method should not contain a - // NoReturnAttr because the attribute applied to the type. - auto Test2 = []() __attribute__((noreturn)) { while(1); }; - // CHECK: CXXMethodDecl{{.*}}operator() 'void () __attribute__((noreturn)) const' - // CHECK-NOT: NoReturnAttr - // CHECK: CXXConversionDecl{{.*}}operator void (*)() __attribute__((noreturn)) -} - -namespace PR20930 { -struct S { - struct { int Test __attribute__((deprecated)); }; - // CHECK: FieldDecl{{.*}}Test 'int' - // CHECK-NEXT: DeprecatedAttr -}; - -void f() { - S s; - s.Test = 1; - // CHECK: IndirectFieldDecl{{.*}}Test 'int' - // CHECK: DeprecatedAttr -} -} - -struct __attribute__((objc_bridge_related(NSParagraphStyle,,))) TestBridgedRef; -// CHECK: CXXRecordDecl{{.*}} struct TestBridgedRef -// CHECK-NEXT: ObjCBridgeRelatedAttr{{.*}} NSParagraphStyle - -void TestExternalSourceSymbolAttr1() -__attribute__((external_source_symbol(language="Swift", defined_in="module", generated_declaration))); -// CHECK: FunctionDecl{{.*}} TestExternalSourceSymbolAttr1 -// CHECK-NEXT: ExternalSourceSymbolAttr{{.*}} "Swift" "module" GeneratedDeclaration - -void TestExternalSourceSymbolAttr2() -__attribute__((external_source_symbol(defined_in="module", language="Swift"))); -// CHECK: FunctionDecl{{.*}} TestExternalSourceSymbolAttr2 -// CHECK-NEXT: ExternalSourceSymbolAttr{{.*}} "Swift" "module"{{$}} - -void TestExternalSourceSymbolAttr3() -__attribute__((external_source_symbol(generated_declaration, language="Objective-C++", defined_in="module"))); -// CHECK: FunctionDecl{{.*}} TestExternalSourceSymbolAttr3 -// CHECK-NEXT: ExternalSourceSymbolAttr{{.*}} "Objective-C++" "module" GeneratedDeclaration - -void TestExternalSourceSymbolAttr4() -__attribute__((external_source_symbol(defined_in="Some external file.cs", generated_declaration, language="C Sharp"))); -// CHECK: FunctionDecl{{.*}} TestExternalSourceSymbolAttr4 -// CHECK-NEXT: ExternalSourceSymbolAttr{{.*}} "C Sharp" "Some external file.cs" GeneratedDeclaration - -void TestExternalSourceSymbolAttr5() -__attribute__((external_source_symbol(generated_declaration, defined_in="module", language="Swift"))); -// CHECK: FunctionDecl{{.*}} TestExternalSourceSymbolAttr5 -// CHECK-NEXT: ExternalSourceSymbolAttr{{.*}} "Swift" "module" GeneratedDeclaration - -namespace TestNoEscape { - void noescapeFunc(int *p0, __attribute__((noescape)) int *p1) {} - // CHECK: `-FunctionDecl{{.*}} noescapeFunc 'void (int *, __attribute__((noescape)) int *)' - // CHECK-NEXT: ParmVarDecl - // CHECK-NEXT: ParmVarDecl - // CHECK-NEXT: NoEscapeAttr -} - -namespace TestSuppress { - [[gsl::suppress("at-namespace")]]; - // CHECK: NamespaceDecl{{.*}} TestSuppress - // CHECK-NEXT: EmptyDecl{{.*}} - // CHECK-NEXT: SuppressAttr{{.*}} at-namespace - [[gsl::suppress("on-decl")]] - void TestSuppressFunction(); - // CHECK: FunctionDecl{{.*}} TestSuppressFunction - // CHECK-NEXT: SuppressAttr{{.*}} on-decl - - void f() { - int *i; - - [[gsl::suppress("on-stmt")]] { - // CHECK: AttributedStmt - // CHECK-NEXT: SuppressAttr{{.*}} on-stmt - // CHECK-NEXT: CompoundStmt - i = reinterpret_cast(7); - } - } -} - -namespace TestLifetimeCategories { -class [[gsl::Owner(int)]] AOwner{}; -// CHECK: CXXRecordDecl{{.*}} class AOwner -// CHECK: OwnerAttr {{.*}} int -class [[gsl::Pointer(int)]] APointer{}; -// CHECK: CXXRecordDecl{{.*}} class APointer -// CHECK: PointerAttr {{.*}} int - -class [[gsl::Pointer]] PointerWithoutArgument{}; -// CHECK: CXXRecordDecl{{.*}} class PointerWithoutArgument -// CHECK: PointerAttr - -class [[gsl::Owner]] OwnerWithoutArgument{}; -// CHECK: CXXRecordDecl{{.*}} class OwnerWithoutArgument -// CHECK: OwnerAttr -} // namespace TestLifetimeCategories - -// Verify the order of attributes in the Ast. It must reflect the order -// in the parsed source. -int mergeAttrTest() __attribute__((deprecated)) __attribute__((warn_unused_result)); -int mergeAttrTest() __attribute__((annotate("test"))); -int mergeAttrTest() __attribute__((unused,no_thread_safety_analysis)); -// CHECK: FunctionDecl{{.*}} mergeAttrTest -// CHECK-NEXT: DeprecatedAttr -// CHECK-NEXT: WarnUnusedResultAttr - -// CHECK: FunctionDecl{{.*}} mergeAttrTest -// CHECK-NEXT: DeprecatedAttr{{.*}} Inherited -// CHECK-NEXT: WarnUnusedResultAttr{{.*}} Inherited -// CHECK-NEXT: AnnotateAttr{{.*}} - -// CHECK: FunctionDecl{{.*}} mergeAttrTest -// CHECK-NEXT: DeprecatedAttr{{.*}} Inherited -// CHECK-NEXT: WarnUnusedResultAttr{{.*}} Inherited -// CHECK-NEXT: AnnotateAttr{{.*}} Inherited -// CHECK-NEXT: UnusedAttr -// CHECK-NEXT: NoThreadSafetyAnalysisAttr +// Test without serialization: +// RUN: %clang_cc1 -triple x86_64-pc-linux -std=c++11 -Wno-deprecated-declarations -ast-dump -ast-dump-filter Test %s \ +// RUN: | FileCheck --strict-whitespace %s +// +// Test with serialization: +// RUN: %clang_cc1 -triple x86_64-pc-linux -std=c++11 -Wno-deprecated-declarations -emit-pch -o %t %s +// RUN: %clang_cc1 -x c++ -triple x86_64-pc-linux -std=c++11 -Wno-deprecated-declarations \ +// RUN: -include-pch %t -ast-dump-all -ast-dump-filter Test /dev/null \ +// RUN: | sed -e "s/ //" -e "s/ imported//" \ +// RUN: | FileCheck --strict-whitespace %s + +int TestLocation +__attribute__((unused)); +// CHECK: VarDecl{{.*}}TestLocation +// CHECK-NEXT: UnusedAttr 0x{{[^ ]*}} + +int TestIndent +__attribute__((unused)); +// CHECK: {{^}}VarDecl{{.*TestIndent[^()]*$}} +// CHECK-NEXT: {{^}}`-UnusedAttr{{[^()]*$}} + +void TestAttributedStmt() { + switch (1) { + case 1: + [[clang::fallthrough]]; + case 2: + ; + } +} +// CHECK: FunctionDecl{{.*}}TestAttributedStmt +// CHECK: AttributedStmt +// CHECK-NEXT: FallThroughAttr +// CHECK-NEXT: NullStmt + +[[clang::warn_unused_result]] int TestCXX11DeclAttr(); +// CHECK: FunctionDecl{{.*}}TestCXX11DeclAttr +// CHECK-NEXT: WarnUnusedResultAttr + +int TestAlignedNull __attribute__((aligned)); +// CHECK: VarDecl{{.*}}TestAlignedNull +// CHECK-NEXT: AlignedAttr {{.*}} aligned +// CHECK-NEXT: <<>> + +int TestAlignedExpr __attribute__((aligned(4))); +// CHECK: VarDecl{{.*}}TestAlignedExpr +// CHECK-NEXT: AlignedAttr {{.*}} aligned +// CHECK-NEXT: ConstantExpr +// CHECK-NEXT: value: Int 4 +// CHECK-NEXT: IntegerLiteral + +int TestEnum __attribute__((visibility("default"))); +// CHECK: VarDecl{{.*}}TestEnum +// CHECK-NEXT: VisibilityAttr{{.*}} Default + +class __attribute__((lockable)) Mutex { +} mu1, mu2; +int TestExpr __attribute__((guarded_by(mu1))); +// CHECK: VarDecl{{.*}}TestExpr +// CHECK-NEXT: GuardedByAttr +// CHECK-NEXT: DeclRefExpr{{.*}}mu1 + +class Mutex TestVariadicExpr __attribute__((acquired_after(mu1, mu2))); +// CHECK: VarDecl{{.*}}TestVariadicExpr +// CHECK: AcquiredAfterAttr +// CHECK-NEXT: DeclRefExpr{{.*}}mu1 +// CHECK-NEXT: DeclRefExpr{{.*}}mu2 + +void function1(void *) { + int TestFunction __attribute__((cleanup(function1))); +} +// CHECK: VarDecl{{.*}}TestFunction +// CHECK-NEXT: CleanupAttr{{.*}} Function{{.*}}function1 + +void TestIdentifier(void *, int) +__attribute__((pointer_with_type_tag(ident1,1,2))); +// CHECK: FunctionDecl{{.*}}TestIdentifier +// CHECK: ArgumentWithTypeTagAttr{{.*}} pointer_with_type_tag ident1 + +void TestBool(void *, int) +__attribute__((pointer_with_type_tag(bool1,1,2))); +// CHECK: FunctionDecl{{.*}}TestBool +// CHECK: ArgumentWithTypeTagAttr{{.*}}pointer_with_type_tag bool1 1 2 IsPointer + +void TestUnsigned(void *, int) +__attribute__((pointer_with_type_tag(unsigned1,1,2))); +// CHECK: FunctionDecl{{.*}}TestUnsigned +// CHECK: ArgumentWithTypeTagAttr{{.*}} pointer_with_type_tag unsigned1 1 2 + +void TestInt(void) __attribute__((constructor(123))); +// CHECK: FunctionDecl{{.*}}TestInt +// CHECK-NEXT: ConstructorAttr{{.*}} 123 + +static int TestString __attribute__((alias("alias1"))); +// CHECK: VarDecl{{.*}}TestString +// CHECK-NEXT: AliasAttr{{.*}} "alias1" + +extern struct s1 TestType +__attribute__((type_tag_for_datatype(ident1,int))); +// CHECK: VarDecl{{.*}}TestType +// CHECK-NEXT: TypeTagForDatatypeAttr{{.*}} int + +void TestLabel() { +L: __attribute__((unused)) int i; +// CHECK: LabelStmt{{.*}}'L' +// CHECK: VarDecl{{.*}}i 'int' +// CHECK-NEXT: UnusedAttr{{.*}} + +M: __attribute(()) int j; +// CHECK: LabelStmt {{.*}} 'M' +// CHECK-NEXT: DeclStmt +// CHECK-NEXT: VarDecl {{.*}} j 'int' + +N: __attribute(()) ; +// CHECK: LabelStmt {{.*}} 'N' +// CHECK-NEXT: NullStmt +} + +namespace Test { +extern "C" int printf(const char *format, ...); +// CHECK: FunctionDecl{{.*}}printf +// CHECK-NEXT: ParmVarDecl{{.*}}format{{.*}}'const char *' +// CHECK-NEXT: BuiltinAttr{{.*}}Implicit +// CHECK-NEXT: FormatAttr{{.*}}Implicit printf 1 2 + +alignas(8) extern int x; +extern int x; +// CHECK: VarDecl{{.*}} x 'int' +// CHECK: VarDecl{{.*}} x 'int' +// CHECK-NEXT: AlignedAttr{{.*}} Inherited +} + +int __attribute__((cdecl)) TestOne(void), TestTwo(void); +// CHECK: FunctionDecl{{.*}}TestOne{{.*}}__attribute__((cdecl)) +// CHECK: FunctionDecl{{.*}}TestTwo{{.*}}__attribute__((cdecl)) + +void func() { + auto Test = []() __attribute__((no_thread_safety_analysis)) {}; + // CHECK: CXXMethodDecl{{.*}}operator() 'void () const' + // CHECK: NoThreadSafetyAnalysisAttr + + // Because GNU's noreturn applies to the function type, and this lambda does + // not have a capture list, the call operator and the function pointer + // conversion should both be noreturn, but the method should not contain a + // NoReturnAttr because the attribute applied to the type. + auto Test2 = []() __attribute__((noreturn)) { while(1); }; + // CHECK: CXXMethodDecl{{.*}}operator() 'void () __attribute__((noreturn)) const' + // CHECK-NOT: NoReturnAttr + // CHECK: CXXConversionDecl{{.*}}operator void (*)() __attribute__((noreturn)) +} + +namespace PR20930 { +struct S { + struct { int Test __attribute__((deprecated)); }; + // CHECK: FieldDecl{{.*}}Test 'int' + // CHECK-NEXT: DeprecatedAttr +}; + +void f() { + S s; + s.Test = 1; + // CHECK: IndirectFieldDecl{{.*}}Test 'int' + // CHECK: DeprecatedAttr +} +} + +struct __attribute__((objc_bridge_related(NSParagraphStyle,,))) TestBridgedRef; +// CHECK: CXXRecordDecl{{.*}} struct TestBridgedRef +// CHECK-NEXT: ObjCBridgeRelatedAttr{{.*}} NSParagraphStyle + +void TestExternalSourceSymbolAttr1() +__attribute__((external_source_symbol(language="Swift", defined_in="module", generated_declaration))); +// CHECK: FunctionDecl{{.*}} TestExternalSourceSymbolAttr1 +// CHECK-NEXT: ExternalSourceSymbolAttr{{.*}} "Swift" "module" GeneratedDeclaration + +void TestExternalSourceSymbolAttr2() +__attribute__((external_source_symbol(defined_in="module", language="Swift"))); +// CHECK: FunctionDecl{{.*}} TestExternalSourceSymbolAttr2 +// CHECK-NEXT: ExternalSourceSymbolAttr{{.*}} "Swift" "module"{{$}} + +void TestExternalSourceSymbolAttr3() +__attribute__((external_source_symbol(generated_declaration, language="Objective-C++", defined_in="module"))); +// CHECK: FunctionDecl{{.*}} TestExternalSourceSymbolAttr3 +// CHECK-NEXT: ExternalSourceSymbolAttr{{.*}} "Objective-C++" "module" GeneratedDeclaration + +void TestExternalSourceSymbolAttr4() +__attribute__((external_source_symbol(defined_in="Some external file.cs", generated_declaration, language="C Sharp"))); +// CHECK: FunctionDecl{{.*}} TestExternalSourceSymbolAttr4 +// CHECK-NEXT: ExternalSourceSymbolAttr{{.*}} "C Sharp" "Some external file.cs" GeneratedDeclaration + +void TestExternalSourceSymbolAttr5() +__attribute__((external_source_symbol(generated_declaration, defined_in="module", language="Swift"))); +// CHECK: FunctionDecl{{.*}} TestExternalSourceSymbolAttr5 +// CHECK-NEXT: ExternalSourceSymbolAttr{{.*}} "Swift" "module" GeneratedDeclaration + +namespace TestNoEscape { + void noescapeFunc(int *p0, __attribute__((noescape)) int *p1) {} + // CHECK: `-FunctionDecl{{.*}} noescapeFunc 'void (int *, __attribute__((noescape)) int *)' + // CHECK-NEXT: ParmVarDecl + // CHECK-NEXT: ParmVarDecl + // CHECK-NEXT: NoEscapeAttr +} + +namespace TestSuppress { + [[gsl::suppress("at-namespace")]]; + // CHECK: NamespaceDecl{{.*}} TestSuppress + // CHECK-NEXT: EmptyDecl{{.*}} + // CHECK-NEXT: SuppressAttr{{.*}} at-namespace + [[gsl::suppress("on-decl")]] + void TestSuppressFunction(); + // CHECK: FunctionDecl{{.*}} TestSuppressFunction + // CHECK-NEXT: SuppressAttr{{.*}} on-decl + + void f() { + int *i; + + [[gsl::suppress("on-stmt")]] { + // CHECK: AttributedStmt + // CHECK-NEXT: SuppressAttr{{.*}} on-stmt + // CHECK-NEXT: CompoundStmt + i = reinterpret_cast(7); + } + } +} + +namespace TestLifetimeCategories { +class [[gsl::Owner(int)]] AOwner{}; +// CHECK: CXXRecordDecl{{.*}} class AOwner +// CHECK: OwnerAttr {{.*}} int +class [[gsl::Pointer(int)]] APointer{}; +// CHECK: CXXRecordDecl{{.*}} class APointer +// CHECK: PointerAttr {{.*}} int + +class [[gsl::Pointer]] PointerWithoutArgument{}; +// CHECK: CXXRecordDecl{{.*}} class PointerWithoutArgument +// CHECK: PointerAttr + +class [[gsl::Owner]] OwnerWithoutArgument{}; +// CHECK: CXXRecordDecl{{.*}} class OwnerWithoutArgument +// CHECK: OwnerAttr +} // namespace TestLifetimeCategories + +// Verify the order of attributes in the Ast. It must reflect the order +// in the parsed source. +int mergeAttrTest() __attribute__((deprecated)) __attribute__((warn_unused_result)); +int mergeAttrTest() __attribute__((annotate("test"))); +int mergeAttrTest() __attribute__((unused,no_thread_safety_analysis)); +// CHECK: FunctionDecl{{.*}} mergeAttrTest +// CHECK-NEXT: DeprecatedAttr +// CHECK-NEXT: WarnUnusedResultAttr + +// CHECK: FunctionDecl{{.*}} mergeAttrTest +// CHECK-NEXT: DeprecatedAttr{{.*}} Inherited +// CHECK-NEXT: WarnUnusedResultAttr{{.*}} Inherited +// CHECK-NEXT: AnnotateAttr{{.*}} + +// CHECK: FunctionDecl{{.*}} mergeAttrTest +// CHECK-NEXT: DeprecatedAttr{{.*}} Inherited +// CHECK-NEXT: WarnUnusedResultAttr{{.*}} Inherited +// CHECK-NEXT: AnnotateAttr{{.*}} Inherited +// CHECK-NEXT: UnusedAttr +// CHECK-NEXT: NoThreadSafetyAnalysisAttr diff --git a/clang/test/AST/ast-dump-attr.m b/clang/test/AST/ast-dump-attr.m index c7b133df332a00..c4a769d85e55c9 100644 --- a/clang/test/AST/ast-dump-attr.m +++ b/clang/test/AST/ast-dump-attr.m @@ -1,68 +1,68 @@ -// Test without serialization: -// RUN: %clang_cc1 -fdouble-square-bracket-attributes -triple x86_64-apple-macosx10.10.0 \ -// RUN: -ast-dump -ast-dump-filter Test %s \ -// RUN: | FileCheck --strict-whitespace %s -// -// Test with serialization: -// RUN: %clang_cc1 -fdouble-square-bracket-attributes -triple x86_64-apple-macosx10.10.0 \ -// RUN: -emit-pch -o %t %s -// RUN: %clang_cc1 -x objective-c -fdouble-square-bracket-attributes -triple x86_64-apple-macosx10.10.0 \ -// RUN: -include-pch %t -ast-dump-all -ast-dump-filter Test /dev/null \ -// RUN: | sed -e "s/ //" -e "s/ imported//" \ -// RUN: | FileCheck --strict-whitespace %s - -@interface NSObject -@end - -[[clang::objc_exception]] -@interface Test1 { -// CHECK: ObjCInterfaceDecl{{.*}} Test1 -// CHECK-NEXT: ObjCExceptionAttr{{.*}} - [[clang::iboutlet]] NSObject *Test2; -// CHECK: ObjCIvarDecl{{.*}} Test2 -// CHECK-NEXT: IBOutletAttr -} -@property (readonly) [[clang::objc_returns_inner_pointer]] void *Test3, *Test4; -// CHECK: ObjCPropertyDecl{{.*}} Test3 'void *' readonly -// CHECK-NEXT: ObjCReturnsInnerPointerAttr -// CHECK-NEXT: ObjCPropertyDecl{{.*}} Test4 'void *' readonly -// CHECK-NEXT: ObjCReturnsInnerPointerAttr - -@property (readonly) [[clang::iboutlet]] NSObject *Test5; -// CHECK: ObjCPropertyDecl{{.*}} Test5 'NSObject *' readonly -// CHECK-NEXT: IBOutletAttr - -// CHECK: ObjCMethodDecl{{.*}} implicit{{.*}} Test3 -// CHECK-NEXT: ObjCReturnsInnerPointerAttr -// CHECK: ObjCMethodDecl{{.*}} implicit{{.*}} Test4 -// CHECK-NEXT: ObjCReturnsInnerPointerAttr -// CHECK: ObjCMethodDecl{{.*}} implicit{{.*}} Test5 -// CHECK-NOT: IBOutletAttr -@end - -[[clang::objc_runtime_name("name")]] @protocol Test6; -// CHECK: ObjCProtocolDecl{{.*}} Test6 -// CHECK-NEXT: ObjCRuntimeNameAttr{{.*}} "name" - -[[clang::objc_protocol_requires_explicit_implementation]] -@protocol Test7 -// CHECK: ObjCProtocolDecl{{.*}} Test7 -// CHECK-NEXT: ObjCExplicitProtocolImplAttr -@end - -@interface Test8 -// CHECK: ObjCInterfaceDecl{{.*}} Test8 --(void)Test9 [[clang::ns_consumes_self]]; -// CHECK: ObjCMethodDecl{{.*}} Test9 'void' -// CHECK-NEXT: NSConsumesSelfAttr --(void) [[clang::ns_consumes_self]] Test10: (int)Test11; -// CHECK: ObjCMethodDecl{{.*}} Test10: 'void' -// CHECK-NEXT: |-ParmVarDecl{{.*}} Test11 'int' -// CHECK-NEXT: `-NSConsumesSelfAttr --(void)Test12: (int *) [[clang::noescape]] Test13 to:(int)Test14 [[clang::ns_consumes_self]]; -// CHECK: ObjCMethodDecl{{.*}} Test12:to: 'void' -// CHECK-NEXT: |-ParmVarDecl{{.*}} Test13 'int *' -// CHECK-NEXT: | `-NoEscapeAttr -// CHECK-NEXT: |-ParmVarDecl{{.*}} Test14 'int' -// CHECK-NEXT: `-NSConsumesSelfAttr -@end +// Test without serialization: +// RUN: %clang_cc1 -fdouble-square-bracket-attributes -triple x86_64-apple-macosx10.10.0 \ +// RUN: -ast-dump -ast-dump-filter Test %s \ +// RUN: | FileCheck --strict-whitespace %s +// +// Test with serialization: +// RUN: %clang_cc1 -fdouble-square-bracket-attributes -triple x86_64-apple-macosx10.10.0 \ +// RUN: -emit-pch -o %t %s +// RUN: %clang_cc1 -x objective-c -fdouble-square-bracket-attributes -triple x86_64-apple-macosx10.10.0 \ +// RUN: -include-pch %t -ast-dump-all -ast-dump-filter Test /dev/null \ +// RUN: | sed -e "s/ //" -e "s/ imported//" \ +// RUN: | FileCheck --strict-whitespace %s + +@interface NSObject +@end + +[[clang::objc_exception]] +@interface Test1 { +// CHECK: ObjCInterfaceDecl{{.*}} Test1 +// CHECK-NEXT: ObjCExceptionAttr{{.*}} + [[clang::iboutlet]] NSObject *Test2; +// CHECK: ObjCIvarDecl{{.*}} Test2 +// CHECK-NEXT: IBOutletAttr +} +@property (readonly) [[clang::objc_returns_inner_pointer]] void *Test3, *Test4; +// CHECK: ObjCPropertyDecl{{.*}} Test3 'void *' readonly +// CHECK-NEXT: ObjCReturnsInnerPointerAttr +// CHECK-NEXT: ObjCPropertyDecl{{.*}} Test4 'void *' readonly +// CHECK-NEXT: ObjCReturnsInnerPointerAttr + +@property (readonly) [[clang::iboutlet]] NSObject *Test5; +// CHECK: ObjCPropertyDecl{{.*}} Test5 'NSObject *' readonly +// CHECK-NEXT: IBOutletAttr + +// CHECK: ObjCMethodDecl{{.*}} implicit{{.*}} Test3 +// CHECK-NEXT: ObjCReturnsInnerPointerAttr +// CHECK: ObjCMethodDecl{{.*}} implicit{{.*}} Test4 +// CHECK-NEXT: ObjCReturnsInnerPointerAttr +// CHECK: ObjCMethodDecl{{.*}} implicit{{.*}} Test5 +// CHECK-NOT: IBOutletAttr +@end + +[[clang::objc_runtime_name("name")]] @protocol Test6; +// CHECK: ObjCProtocolDecl{{.*}} Test6 +// CHECK-NEXT: ObjCRuntimeNameAttr{{.*}} "name" + +[[clang::objc_protocol_requires_explicit_implementation]] +@protocol Test7 +// CHECK: ObjCProtocolDecl{{.*}} Test7 +// CHECK-NEXT: ObjCExplicitProtocolImplAttr +@end + +@interface Test8 +// CHECK: ObjCInterfaceDecl{{.*}} Test8 +-(void)Test9 [[clang::ns_consumes_self]]; +// CHECK: ObjCMethodDecl{{.*}} Test9 'void' +// CHECK-NEXT: NSConsumesSelfAttr +-(void) [[clang::ns_consumes_self]] Test10: (int)Test11; +// CHECK: ObjCMethodDecl{{.*}} Test10: 'void' +// CHECK-NEXT: |-ParmVarDecl{{.*}} Test11 'int' +// CHECK-NEXT: `-NSConsumesSelfAttr +-(void)Test12: (int *) [[clang::noescape]] Test13 to:(int)Test14 [[clang::ns_consumes_self]]; +// CHECK: ObjCMethodDecl{{.*}} Test12:to: 'void' +// CHECK-NEXT: |-ParmVarDecl{{.*}} Test13 'int *' +// CHECK-NEXT: | `-NoEscapeAttr +// CHECK-NEXT: |-ParmVarDecl{{.*}} Test14 'int' +// CHECK-NEXT: `-NSConsumesSelfAttr +@end diff --git a/clang/test/AST/ast-dump-c-attr.c b/clang/test/AST/ast-dump-c-attr.c index 1f28501f1bb023..f1d76deeb472da 100644 --- a/clang/test/AST/ast-dump-c-attr.c +++ b/clang/test/AST/ast-dump-c-attr.c @@ -1,54 +1,54 @@ -// Test without serialization: -// RUN: %clang_cc1 -triple x86_64-pc-linux -fdouble-square-bracket-attributes \ -// RUN: -Wno-deprecated-declarations -ast-dump -ast-dump-filter Test %s \ -// RUN: | FileCheck --strict-whitespace %s -// -// Test with serialization: -// RUN: %clang_cc1 -triple x86_64-pc-linux -fdouble-square-bracket-attributes \ -// RUN: -Wno-deprecated-declarations -emit-pch -o %t %s -// RUN: %clang_cc1 -x c -triple x86_64-pc-linux -fdouble-square-bracket-attributes \ -// RUN: -Wno-deprecated-declarations -include-pch %t -ast-dump-all -ast-dump-filter Test /dev/null \ -// RUN: | sed -e "s/ //" -e "s/ imported//" \ -// RUN: | FileCheck --strict-whitespace %s - -int Test1 [[deprecated]]; -// CHECK: VarDecl{{.*}}Test1 -// CHECK-NEXT: DeprecatedAttr 0x{{[^ ]*}} "" "" - -enum [[deprecated("Frobble")]] Test2 { - Test3 [[deprecated]] -}; -// CHECK: EnumDecl{{.*}}Test2 -// CHECK-NEXT: DeprecatedAttr 0x{{[^ ]*}} "Frobble" "" -// CHECK-NEXT: EnumConstantDecl{{.*}}Test3 -// CHECK-NEXT: DeprecatedAttr 0x{{[^ ]*}} "" "" - -struct [[deprecated]] Test4 { - [[deprecated("Frobble")]] int Test5, Test6; - int Test7 [[deprecated]] : 12; -}; -// CHECK: RecordDecl{{.*}}Test4 -// CHECK-NEXT: DeprecatedAttr 0x{{[^ ]*}} "" "" -// CHECK-NEXT: FieldDecl{{.*}}Test5 -// CHECK-NEXT: DeprecatedAttr 0x{{[^ ]*}} "Frobble" "" -// CHECK-NEXT: FieldDecl{{.*}}Test6 -// CHECK-NEXT: DeprecatedAttr 0x{{[^ ]*}} "Frobble" "" -// CHECK-NEXT: FieldDecl{{.*}}Test7 -// CHECK-NEXT: ConstantExpr{{.*}}'int' -// CHECK-NEXT: value: Int 12 -// CHECK-NEXT: IntegerLiteral{{.*}}'int' 12 -// CHECK-NEXT: DeprecatedAttr 0x{{[^ ]*}} "" "" - -struct [[deprecated]] Test8; -// CHECK: RecordDecl{{.*}}Test8 -// CHECK-NEXT: DeprecatedAttr 0x{{[^ ]*}} "" "" - -[[deprecated]] void Test9(int Test10 [[deprecated]]); -// CHECK: FunctionDecl{{.*}}Test9 -// CHECK-NEXT: ParmVarDecl{{.*}}Test10 -// CHECK-NEXT: DeprecatedAttr 0x{{[^ ]*}} "" "" -// CHECK-NEXT: DeprecatedAttr 0x{{[^ ]*}} "" "" - -void Test11 [[deprecated]](void); -// CHECK: FunctionDecl{{.*}}Test11 -// CHECK-NEXT: DeprecatedAttr 0x{{[^ ]*}} "" "" +// Test without serialization: +// RUN: %clang_cc1 -triple x86_64-pc-linux -fdouble-square-bracket-attributes \ +// RUN: -Wno-deprecated-declarations -ast-dump -ast-dump-filter Test %s \ +// RUN: | FileCheck --strict-whitespace %s +// +// Test with serialization: +// RUN: %clang_cc1 -triple x86_64-pc-linux -fdouble-square-bracket-attributes \ +// RUN: -Wno-deprecated-declarations -emit-pch -o %t %s +// RUN: %clang_cc1 -x c -triple x86_64-pc-linux -fdouble-square-bracket-attributes \ +// RUN: -Wno-deprecated-declarations -include-pch %t -ast-dump-all -ast-dump-filter Test /dev/null \ +// RUN: | sed -e "s/ //" -e "s/ imported//" \ +// RUN: | FileCheck --strict-whitespace %s + +int Test1 [[deprecated]]; +// CHECK: VarDecl{{.*}}Test1 +// CHECK-NEXT: DeprecatedAttr 0x{{[^ ]*}} "" "" + +enum [[deprecated("Frobble")]] Test2 { + Test3 [[deprecated]] +}; +// CHECK: EnumDecl{{.*}}Test2 +// CHECK-NEXT: DeprecatedAttr 0x{{[^ ]*}} "Frobble" "" +// CHECK-NEXT: EnumConstantDecl{{.*}}Test3 +// CHECK-NEXT: DeprecatedAttr 0x{{[^ ]*}} "" "" + +struct [[deprecated]] Test4 { + [[deprecated("Frobble")]] int Test5, Test6; + int Test7 [[deprecated]] : 12; +}; +// CHECK: RecordDecl{{.*}}Test4 +// CHECK-NEXT: DeprecatedAttr 0x{{[^ ]*}} "" "" +// CHECK-NEXT: FieldDecl{{.*}}Test5 +// CHECK-NEXT: DeprecatedAttr 0x{{[^ ]*}} "Frobble" "" +// CHECK-NEXT: FieldDecl{{.*}}Test6 +// CHECK-NEXT: DeprecatedAttr 0x{{[^ ]*}} "Frobble" "" +// CHECK-NEXT: FieldDecl{{.*}}Test7 +// CHECK-NEXT: ConstantExpr{{.*}}'int' +// CHECK-NEXT: value: Int 12 +// CHECK-NEXT: IntegerLiteral{{.*}}'int' 12 +// CHECK-NEXT: DeprecatedAttr 0x{{[^ ]*}} "" "" + +struct [[deprecated]] Test8; +// CHECK: RecordDecl{{.*}}Test8 +// CHECK-NEXT: DeprecatedAttr 0x{{[^ ]*}} "" "" + +[[deprecated]] void Test9(int Test10 [[deprecated]]); +// CHECK: FunctionDecl{{.*}}Test9 +// CHECK-NEXT: ParmVarDecl{{.*}}Test10 +// CHECK-NEXT: DeprecatedAttr 0x{{[^ ]*}} "" "" +// CHECK-NEXT: DeprecatedAttr 0x{{[^ ]*}} "" "" + +void Test11 [[deprecated]](void); +// CHECK: FunctionDecl{{.*}}Test11 +// CHECK-NEXT: DeprecatedAttr 0x{{[^ ]*}} "" "" diff --git a/clang/test/AST/ast-dump-decl.cpp b/clang/test/AST/ast-dump-decl.cpp index 97bb7964c47b82..0ff947ae3b4835 100644 --- a/clang/test/AST/ast-dump-decl.cpp +++ b/clang/test/AST/ast-dump-decl.cpp @@ -1,806 +1,806 @@ -// Test without serialization: -// RUN: %clang_cc1 -std=c++11 -triple x86_64-linux-gnu -fms-extensions \ -// RUN: -ast-dump -ast-dump-filter Test %s \ -// RUN: | FileCheck --strict-whitespace %s -// -// Test with serialization: FIXME: Find why the outputs differs and fix it! -// : %clang_cc1 -std=c++11 -triple x86_64-linux-gnu -fms-extensions -emit-pch -o %t %s -// : %clang_cc1 -x c++ -std=c++11 -triple x86_64-linux-gnu -fms-extensions -include-pch %t \ -// : -ast-dump-all -ast-dump-filter Test /dev/null \ -// : | sed -e "s/ //" -e "s/ imported//" \ -// : | FileCheck --strict-whitespace %s - -class testEnumDecl { - enum class TestEnumDeclScoped; - enum TestEnumDeclFixed : int; -}; -// CHECK: EnumDecl{{.*}} class TestEnumDeclScoped 'int' -// CHECK: EnumDecl{{.*}} TestEnumDeclFixed 'int' - -class testFieldDecl { - int TestFieldDeclInit = 0; -}; -// CHECK: FieldDecl{{.*}} TestFieldDeclInit 'int' -// CHECK-NEXT: IntegerLiteral - -namespace testVarDeclNRVO { - class A { }; - A foo() { - A TestVarDeclNRVO; - return TestVarDeclNRVO; - } -} -// CHECK: VarDecl{{.*}} TestVarDeclNRVO 'testVarDeclNRVO::A' nrvo - -void testParmVarDeclInit(int TestParmVarDeclInit = 0); -// CHECK: ParmVarDecl{{.*}} TestParmVarDeclInit 'int' -// CHECK-NEXT: IntegerLiteral{{.*}} - -namespace TestNamespaceDecl { - int i; -} -// CHECK: NamespaceDecl{{.*}} TestNamespaceDecl -// CHECK-NEXT: VarDecl - -namespace TestNamespaceDecl { - int j; -} -// CHECK: NamespaceDecl{{.*}} TestNamespaceDecl -// CHECK-NEXT: original Namespace -// CHECK-NEXT: VarDecl - -inline namespace TestNamespaceDeclInline { -} -// CHECK: NamespaceDecl{{.*}} TestNamespaceDeclInline inline - -namespace testUsingDirectiveDecl { - namespace A { - } -} -namespace TestUsingDirectiveDecl { - using namespace testUsingDirectiveDecl::A; -} -// CHECK: NamespaceDecl{{.*}} TestUsingDirectiveDecl -// CHECK-NEXT: UsingDirectiveDecl{{.*}} Namespace{{.*}} 'A' - -namespace testNamespaceAlias { - namespace A { - } -} -namespace TestNamespaceAlias = testNamespaceAlias::A; -// CHECK: NamespaceAliasDecl{{.*}} TestNamespaceAlias -// CHECK-NEXT: Namespace{{.*}} 'A' - -using TestTypeAliasDecl = int; -// CHECK: TypeAliasDecl{{.*}} TestTypeAliasDecl 'int' - -namespace testTypeAliasTemplateDecl { - template class A; - template using TestTypeAliasTemplateDecl = A; -} -// CHECK: TypeAliasTemplateDecl{{.*}} TestTypeAliasTemplateDecl -// CHECK-NEXT: TemplateTypeParmDecl -// CHECK-NEXT: TypeAliasDecl{{.*}} TestTypeAliasTemplateDecl 'A' - -namespace testCXXRecordDecl { - class TestEmpty {}; -// CHECK: CXXRecordDecl{{.*}} class TestEmpty -// CHECK-NEXT: DefinitionData pass_in_registers empty aggregate standard_layout trivially_copyable pod trivial literal has_constexpr_non_copy_move_ctor can_const_default_init -// CHECK-NEXT: DefaultConstructor exists trivial constexpr -// CHECK-NEXT: CopyConstructor simple trivial has_const_param -// CHECK-NEXT: MoveConstructor exists simple trivial -// CHECK-NEXT: CopyAssignment simple trivial has_const_param -// CHECK-NEXT: MoveAssignment exists simple trivial -// CHECK-NEXT: Destructor simple irrelevant trivial - - class A { }; - class B { }; - class TestCXXRecordDecl : virtual A, public B { - int i; - }; -} -// CHECK: CXXRecordDecl{{.*}} class TestCXXRecordDecl -// CHECK-NEXT: DefinitionData{{$}} -// CHECK-NEXT: DefaultConstructor exists non_trivial -// CHECK-NEXT: CopyConstructor simple non_trivial has_const_param -// CHECK-NEXT: MoveConstructor exists simple non_trivial -// CHECK-NEXT: CopyAssignment simple non_trivial has_const_param -// CHECK-NEXT: MoveAssignment exists simple non_trivial -// CHECK-NEXT: Destructor simple irrelevant trivial -// CHECK-NEXT: virtual private 'testCXXRecordDecl::A' -// CHECK-NEXT: public 'testCXXRecordDecl::B' -// CHECK-NEXT: CXXRecordDecl{{.*}} class TestCXXRecordDecl -// CHECK-NEXT: FieldDecl - -template -class TestCXXRecordDeclPack : public T... { -}; -// CHECK: CXXRecordDecl{{.*}} class TestCXXRecordDeclPack -// CHECK: public 'T'... -// CHECK-NEXT: CXXRecordDecl{{.*}} class TestCXXRecordDeclPack - -thread_local int TestThreadLocalInt; -// CHECK: TestThreadLocalInt {{.*}} tls_dynamic - -class testCXXMethodDecl { - virtual void TestCXXMethodDeclPure() = 0; - void TestCXXMethodDeclDelete() = delete; - void TestCXXMethodDeclThrow() throw(); - void TestCXXMethodDeclThrowType() throw(int); -}; -// CHECK: CXXMethodDecl{{.*}} TestCXXMethodDeclPure 'void ()' virtual pure -// CHECK: CXXMethodDecl{{.*}} TestCXXMethodDeclDelete 'void ()' delete -// CHECK: CXXMethodDecl{{.*}} TestCXXMethodDeclThrow 'void () throw()' -// CHECK: CXXMethodDecl{{.*}} TestCXXMethodDeclThrowType 'void () throw(int)' - -namespace testCXXConstructorDecl { - class A { }; - class TestCXXConstructorDecl : public A { - int I; - TestCXXConstructorDecl(A &a, int i) : A(a), I(i) { } - TestCXXConstructorDecl(A &a) : TestCXXConstructorDecl(a, 0) { } - }; -} -// CHECK: CXXConstructorDecl{{.*}} TestCXXConstructorDecl 'void {{.*}}' -// CHECK-NEXT: ParmVarDecl{{.*}} a -// CHECK-NEXT: ParmVarDecl{{.*}} i -// CHECK-NEXT: CXXCtorInitializer{{.*}}A -// CHECK-NEXT: Expr -// CHECK: CXXCtorInitializer{{.*}}I -// CHECK-NEXT: Expr -// CHECK: CompoundStmt -// CHECK: CXXConstructorDecl{{.*}} TestCXXConstructorDecl 'void {{.*}}' -// CHECK-NEXT: ParmVarDecl{{.*}} a -// CHECK-NEXT: CXXCtorInitializer{{.*}}TestCXXConstructorDecl -// CHECK-NEXT: CXXConstructExpr{{.*}}TestCXXConstructorDecl - -class TestCXXDestructorDecl { - ~TestCXXDestructorDecl() { } -}; -// CHECK: CXXDestructorDecl{{.*}} ~TestCXXDestructorDecl 'void () noexcept' -// CHECK-NEXT: CompoundStmt - -// Test that the range of a defaulted members is computed correctly. -class TestMemberRanges { -public: - TestMemberRanges() = default; - TestMemberRanges(const TestMemberRanges &Other) = default; - TestMemberRanges(TestMemberRanges &&Other) = default; - ~TestMemberRanges() = default; - TestMemberRanges &operator=(const TestMemberRanges &Other) = default; - TestMemberRanges &operator=(TestMemberRanges &&Other) = default; -}; -void SomeFunction() { - TestMemberRanges A; - TestMemberRanges B(A); - B = A; - A = static_cast(B); - TestMemberRanges C(static_cast(A)); -} -// CHECK: CXXConstructorDecl{{.*}} -// CHECK: CXXConstructorDecl{{.*}} -// CHECK: CXXConstructorDecl{{.*}} -// CHECK: CXXDestructorDecl{{.*}} -// CHECK: CXXMethodDecl{{.*}} -// CHECK: CXXMethodDecl{{.*}} - -class TestCXXConversionDecl { - operator int() { return 0; } -}; -// CHECK: CXXConversionDecl{{.*}} operator int 'int ()' -// CHECK-NEXT: CompoundStmt - -namespace TestStaticAssertDecl { - static_assert(true, "msg"); -} -// CHECK: NamespaceDecl{{.*}} TestStaticAssertDecl -// CHECK-NEXT: StaticAssertDecl{{.*> .*$}} -// CHECK-NEXT: CXXBoolLiteralExpr -// CHECK-NEXT: StringLiteral - -namespace testFunctionTemplateDecl { - class A { }; - class B { }; - class C { }; - class D { }; - template void TestFunctionTemplate(T) { } - - // implicit instantiation - void bar(A a) { TestFunctionTemplate(a); } - - // explicit specialization - template<> void TestFunctionTemplate(B); - - // explicit instantiation declaration - extern template void TestFunctionTemplate(C); - - // explicit instantiation definition - template void TestFunctionTemplate(D); -} - // CHECK: FunctionTemplateDecl 0x{{.+}} <{{.+}}:[[@LINE-14]]:3, col:55> col:29 TestFunctionTemplate - // CHECK-NEXT: |-TemplateTypeParmDecl 0x{{.+}} col:21 referenced typename depth 0 index 0 T - // CHECK-NEXT: |-FunctionDecl 0x{{.+}} col:29 TestFunctionTemplate 'void (T)' - // CHECK-NEXT: | |-ParmVarDecl 0x{{.+}} col:51 'T' - // CHECK-NEXT: | `-CompoundStmt 0x{{.+}} - // CHECK-NEXT: |-FunctionDecl 0x{{.+}} col:29 used TestFunctionTemplate 'void (testFunctionTemplateDecl::A)' - // CHECK-NEXT: | |-TemplateArgument type 'testFunctionTemplateDecl::A' - // CHECK-NEXT: | | `-RecordType 0{{.+}} 'testFunctionTemplateDecl::A' - // CHECK-NEXT: | | `-CXXRecord 0x{{.+}} 'A' - // CHECK-NEXT: | |-ParmVarDecl 0x{{.+}} col:51 'testFunctionTemplateDecl::A':'testFunctionTemplateDecl::A' - // CHECK-NEXT: | `-CompoundStmt 0x{{.+}} - // CHECK-NEXT: |-Function 0x{{.+}} 'TestFunctionTemplate' 'void (testFunctionTemplateDecl::B)' - // CHECK-NEXT: |-FunctionDecl 0x{{.+}} col:29 TestFunctionTemplate 'void (testFunctionTemplateDecl::C)' - // CHECK-NEXT: | |-TemplateArgument type 'testFunctionTemplateDecl::C' - // CHECK-NEXT: | | `-RecordType 0{{.+}} 'testFunctionTemplateDecl::C' - // CHECK-NEXT: | | `-CXXRecord 0x{{.+}} 'C' - // CHECK-NEXT: | `-ParmVarDecl 0x{{.+}} col:51 'testFunctionTemplateDecl::C':'testFunctionTemplateDecl::C' - // CHECK-NEXT: `-FunctionDecl 0x{{.+}} col:29 TestFunctionTemplate 'void (testFunctionTemplateDecl::D)' - // CHECK-NEXT: |-TemplateArgument type 'testFunctionTemplateDecl::D' - // CHECK-NEXT: | `-RecordType 0{{.+}} 'testFunctionTemplateDecl::D' - // CHECK-NEXT: | `-CXXRecord 0x{{.+}} 'D' - // CHECK-NEXT: |-ParmVarDecl 0x{{.+}} col:51 'testFunctionTemplateDecl::D':'testFunctionTemplateDecl::D' - // CHECK-NEXT: `-CompoundStmt 0x{{.+}} - - // CHECK: FunctionDecl 0x{{.+}} prev 0x{{.+}} <{{.+}}:[[@LINE-32]]:3, col:41> col:19 TestFunctionTemplate 'void (testFunctionTemplateDecl::B)' - // CHECK-NEXT: |-TemplateArgument type 'testFunctionTemplateDecl::B' - // CHECK-NEXT: | `-RecordType 0{{.+}} 'testFunctionTemplateDecl::B' - // CHECK-NEXT: | `-CXXRecord 0x{{.+}} 'B' - // CHECK-NEXT: `-ParmVarDecl 0x{{.+}} col:41 'testFunctionTemplateDecl::B' - - -namespace testClassTemplateDecl { - class A { }; - class B { }; - class C { }; - class D { }; - - template class TestClassTemplate { - public: - TestClassTemplate(); - ~TestClassTemplate(); - int j(); - int i; - }; - - // implicit instantiation - TestClassTemplate a; - - // explicit specialization - template<> class TestClassTemplate { - int j; - }; - - // explicit instantiation declaration - extern template class TestClassTemplate; - - // explicit instantiation definition - template class TestClassTemplate; - - // partial explicit specialization - template class TestClassTemplatePartial { - int i; - }; - template class TestClassTemplatePartial { - int j; - }; - - template struct TestTemplateDefaultType; - template struct TestTemplateDefaultType { }; - - template struct TestTemplateDefaultNonType; - template struct TestTemplateDefaultNonType { }; - - template class TT = TestClassTemplate> struct TestTemplateTemplateDefaultType; - template class TT> struct TestTemplateTemplateDefaultType { }; -} - -// CHECK: ClassTemplateDecl 0x{{.+}} <{{.+}}:[[@LINE-40]]:3, line:[[@LINE-34]]:3> line:[[@LINE-40]]:30 TestClassTemplate -// CHECK-NEXT: |-TemplateTypeParmDecl 0x{{.+}} col:21 typename depth 0 index 0 T -// CHECK-NEXT: |-CXXRecordDecl 0x{{.+}} line:[[@LINE-42]]:30 class TestClassTemplate definition -// CHECK-NEXT: | |-DefinitionData standard_layout has_user_declared_ctor can_const_default_init -// CHECK-NEXT: | | |-DefaultConstructor exists non_trivial user_provided -// CHECK-NEXT: | | |-CopyConstructor simple trivial has_const_param needs_implicit implicit_has_const_param -// CHECK-NEXT: | | |-MoveConstructor -// CHECK-NEXT: | | |-CopyAssignment simple trivial has_const_param needs_implicit implicit_has_const_param -// CHECK-NEXT: | | |-MoveAssignment -// CHECK-NEXT: | | `-Destructor non_trivial user_declared -// CHECK-NEXT: | |-CXXRecordDecl 0x{{.+}} col:30 implicit referenced class TestClassTemplate -// CHECK-NEXT: | |-AccessSpecDecl 0x{{.+}} col:3 public -// CHECK-NEXT: | |-CXXConstructorDecl 0x{{.+}} col:5 TestClassTemplate 'void ()' -// CHECK-NEXT: | |-CXXDestructorDecl 0x{{.+}} col:5 ~TestClassTemplate 'void ()' -// CHECK-NEXT: | |-CXXMethodDecl 0x{{.+}} col:9 j 'int ()' -// CHECK-NEXT: | `-FieldDecl 0x{{.+}} col:9 i 'int' -// CHECK-NEXT: |-ClassTemplateSpecializationDecl 0x{{.+}} line:[[@LINE-56]]:30 class TestClassTemplate definition -// CHECK-NEXT: | |-DefinitionData standard_layout has_user_declared_ctor can_const_default_init -// CHECK-NEXT: | | |-DefaultConstructor exists non_trivial user_provided -// CHECK-NEXT: | | |-CopyConstructor simple trivial has_const_param implicit_has_const_param -// CHECK-NEXT: | | |-MoveConstructor -// CHECK-NEXT: | | |-CopyAssignment simple trivial has_const_param needs_implicit implicit_has_const_param -// CHECK-NEXT: | | |-MoveAssignment -// CHECK-NEXT: | | `-Destructor non_trivial user_declared -// CHECK-NEXT: | |-TemplateArgument type 'testClassTemplateDecl::A' -// CHECK-NEXT: | | `-RecordType 0{{.+}} 'testClassTemplateDecl::A' -// CHECK-NEXT: | | `-CXXRecord 0x{{.+}} 'A' -// CHECK-NEXT: | |-CXXRecordDecl 0x{{.+}} prev 0x{{.+}} col:30 implicit class TestClassTemplate -// CHECK-NEXT: | |-AccessSpecDecl 0x{{.+}} col:3 public -// CHECK-NEXT: | |-CXXConstructorDecl 0x{{.+}} col:5 used TestClassTemplate 'void ()' -// CHECK-NEXT: | |-CXXDestructorDecl 0x{{.+}} col:5 used ~TestClassTemplate 'void () noexcept' -// CHECK-NEXT: | |-CXXMethodDecl 0x{{.+}} col:9 j 'int ()' -// CHECK-NEXT: | |-FieldDecl 0x{{.+}} col:9 i 'int' -// CHECK-NEXT: | `-CXXConstructorDecl 0x{{.+}} col:30 implicit constexpr TestClassTemplate 'void (const testClassTemplateDecl::TestClassTemplate &)' inline default trivial noexcept-unevaluated 0x{{.+}} -// CHECK-NEXT: | `-ParmVarDecl 0x{{.+}} col:30 'const testClassTemplateDecl::TestClassTemplate &' -// CHECK-NEXT: |-ClassTemplateSpecialization 0x{{.+}} 'TestClassTemplate' -// CHECK-NEXT: |-ClassTemplateSpecialization 0x{{.+}} 'TestClassTemplate' -// CHECK-NEXT: `-ClassTemplateSpecialization 0x{{.+}} 'TestClassTemplate' - -// CHECK: ClassTemplateSpecializationDecl 0x{{.+}} <{{.+}}:[[@LINE-67]]:3, line:[[@LINE-65]]:3> line:[[@LINE-67]]:20 class TestClassTemplate definition -// CHECK-NEXT: |-DefinitionData pass_in_registers standard_layout trivially_copyable trivial literal -// CHECK-NEXT: | |-DefaultConstructor exists trivial needs_implicit -// CHECK-NEXT: | |-CopyConstructor simple trivial has_const_param needs_implicit implicit_has_const_param -// CHECK-NEXT: | |-MoveConstructor exists simple trivial needs_implicit -// CHECK-NEXT: | |-CopyAssignment simple trivial has_const_param needs_implicit implicit_has_const_param -// CHECK-NEXT: | |-MoveAssignment exists simple trivial needs_implicit -// CHECK-NEXT: | `-Destructor simple irrelevant trivial needs_implicit -// CHECK-NEXT: |-TemplateArgument type 'testClassTemplateDecl::B' -// CHECK-NEXT: | `-RecordType 0{{.+}} 'testClassTemplateDecl::B' -// CHECK-NEXT: | `-CXXRecord 0x{{.+}} 'B' -// CHECK-NEXT: |-CXXRecordDecl 0x{{.+}} col:20 implicit class TestClassTemplate -// CHECK-NEXT: `-FieldDecl 0x{{.+}} col:9 j 'int' - -// CHECK: ClassTemplateSpecializationDecl 0x{{.+}} <{{.+}}:{{.*}}:3, col:44> col:25 class TestClassTemplate definition -// CHECK-NEXT: |-DefinitionData standard_layout has_user_declared_ctor can_const_default_init -// CHECK-NEXT: | |-DefaultConstructor exists non_trivial user_provided -// CHECK-NEXT: | |-CopyConstructor simple trivial has_const_param needs_implicit implicit_has_const_param -// CHECK-NEXT: | |-MoveConstructor -// CHECK-NEXT: | |-CopyAssignment simple trivial has_const_param needs_implicit implicit_has_const_param -// CHECK-NEXT: | |-MoveAssignment -// CHECK-NEXT: | `-Destructor non_trivial user_declared -// CHECK-NEXT: |-TemplateArgument type 'testClassTemplateDecl::C' -// CHECK-NEXT: | `-RecordType 0{{.+}} 'testClassTemplateDecl::C' -// CHECK-NEXT: | `-CXXRecord 0x{{.+}} 'C' -// CHECK-NEXT: |-CXXRecordDecl 0x{{.+}} prev 0x{{.+}} col:30 implicit class TestClassTemplate -// CHECK-NEXT: |-AccessSpecDecl 0x{{.+}} col:3 public -// CHECK-NEXT: |-CXXConstructorDecl 0x{{.+}} col:5 TestClassTemplate 'void ()' -// CHECK-NEXT: |-CXXDestructorDecl 0x{{.+}} col:5 ~TestClassTemplate 'void ()' noexcept-unevaluated 0x{{.+}} -// CHECK-NEXT: |-CXXMethodDecl 0x{{.+}} col:9 j 'int ()' -// CHECK-NEXT: `-FieldDecl 0x{{.+}} col:9 i 'int' - -// CHECK: ClassTemplateSpecializationDecl 0x{{.+}} <{{.+}}:[[@LINE-91]]:3, col:37> col:18 class TestClassTemplate definition -// CHECK-NEXT: |-DefinitionData standard_layout has_user_declared_ctor can_const_default_init -// CHECK-NEXT: | |-DefaultConstructor exists non_trivial user_provided -// CHECK-NEXT: | |-CopyConstructor simple trivial has_const_param needs_implicit implicit_has_const_param -// CHECK-NEXT: | |-MoveConstructor -// CHECK-NEXT: | |-CopyAssignment simple trivial has_const_param needs_implicit implicit_has_const_param -// CHECK-NEXT: | |-MoveAssignment -// CHECK-NEXT: | `-Destructor non_trivial user_declared -// CHECK-NEXT: |-TemplateArgument type 'testClassTemplateDecl::D' -// CHECK-NEXT: | `-RecordType 0{{.+}} 'testClassTemplateDecl::D' -// CHECK-NEXT: | `-CXXRecord 0x{{.+}} 'D' -// CHECK-NEXT: |-CXXRecordDecl 0x{{.+}} prev 0x{{.+}} col:30 implicit class TestClassTemplate -// CHECK-NEXT: |-AccessSpecDecl 0x{{.+}} col:3 public -// CHECK-NEXT: |-CXXConstructorDecl 0x{{.+}} col:5 TestClassTemplate 'void ()' -// CHECK-NEXT: |-CXXDestructorDecl 0x{{.+}} col:5 ~TestClassTemplate 'void ()' noexcept-unevaluated 0x{{.+}} -// CHECK-NEXT: |-CXXMethodDecl 0x{{.+}} col:9 j 'int ()' -// CHECK-NEXT: `-FieldDecl 0x{{.+}} col:9 i 'int' - -// CHECK: ClassTemplateDecl 0x{{.+}} <{{.+}}:[[@LINE-106]]:3, line:[[@LINE-104]]:3> line:[[@LINE-106]]:44 TestClassTemplatePartial -// CHECK-NEXT: |-TemplateTypeParmDecl 0x{{.+}} col:21 typename depth 0 index 0 T1 -// CHECK-NEXT: |-TemplateTypeParmDecl 0x{{.+}} col:34 typename depth 0 index 1 T2 -// CHECK-NEXT: `-CXXRecordDecl 0x{{.+}} line:[[@LINE-109]]:44 class TestClassTemplatePartial definition -// CHECK-NEXT: |-DefinitionData standard_layout trivially_copyable trivial literal -// CHECK-NEXT: | |-DefaultConstructor exists trivial needs_implicit -// CHECK-NEXT: | |-CopyConstructor simple trivial has_const_param needs_implicit implicit_has_const_param -// CHECK-NEXT: | |-MoveConstructor exists simple trivial needs_implicit -// CHECK-NEXT: | |-CopyAssignment simple trivial has_const_param needs_implicit implicit_has_const_param -// CHECK-NEXT: | |-MoveAssignment exists simple trivial needs_implicit -// CHECK-NEXT: | `-Destructor simple irrelevant trivial needs_implicit -// CHECK-NEXT: |-CXXRecordDecl 0x{{.+}} col:44 implicit class TestClassTemplatePartial -// CHECK-NEXT: `-FieldDecl 0x{{.+}} col:9 i 'int' - -// CHECK: ClassTemplatePartialSpecializationDecl 0x{{.+}} <{{.+}}:[[@LINE-117]]:3, line:[[@LINE-115]]:3> line:[[@LINE-117]]:31 class TestClassTemplatePartial definition -// CHECK-NEXT: |-DefinitionData standard_layout trivially_copyable trivial literal -// CHECK-NEXT: | |-DefaultConstructor exists trivial needs_implicit -// CHECK-NEXT: | |-CopyConstructor simple trivial has_const_param needs_implicit implicit_has_const_param -// CHECK-NEXT: | |-MoveConstructor exists simple trivial needs_implicit -// CHECK-NEXT: | |-CopyAssignment simple trivial has_const_param needs_implicit implicit_has_const_param -// CHECK-NEXT: | |-MoveAssignment exists simple trivial needs_implicit -// CHECK-NEXT: | `-Destructor simple irrelevant trivial needs_implicit -// CHECK-NEXT: |-TemplateArgument type 'type-parameter-0-0' -// CHECK-NEXT: | `-TemplateTypeParmType 0x{{.+}} 'type-parameter-0-0' dependent depth 0 index 0 -// CHECK-NEXT: |-TemplateArgument type 'testClassTemplateDecl::A' -// CHECK-NEXT: | `-RecordType 0x{{.+}} 'testClassTemplateDecl::A' -// CHECK-NEXT: | `-CXXRecord 0x{{.+}} 'A' -// CHECK-NEXT: |-TemplateTypeParmDecl 0x{{.+}} col:21 referenced typename depth 0 index 0 T1 -// CHECK-NEXT: |-CXXRecordDecl 0x{{.+}} col:31 implicit class TestClassTemplatePartial -// CHECK-NEXT: `-FieldDecl 0x{{.+}} col:9 j 'int' - -// CHECK: ClassTemplateDecl 0x{{.+}} <{{.+}}:[[@LINE-130]]:3, col:37> col:37 TestTemplateDefaultType -// CHECK-NEXT: |-TemplateTypeParmDecl 0x{{.+}} col:21 typename depth 0 index 0 T -// CHECK-NEXT: | `-TemplateArgument type 'int' -// CHECK-NEXT: | `-BuiltinType 0x{{.+}} 'int' -// CHECK-NEXT: `-CXXRecordDecl 0x{{.+}} col:37 struct TestTemplateDefaultType - -// CHECK: ClassTemplateDecl 0x{{.+}} prev 0x{{.+}} <{{.+}}:[[@LINE-135]]:3, col:57> col:31 TestTemplateDefaultType -// CHECK-NEXT: |-TemplateTypeParmDecl 0x{{.+}} col:21 typename depth 0 index 0 T -// CHECK-NEXT: | `-TemplateArgument type 'int' -// CHECK-NEXT: | |-inherited from TemplateTypeParm 0x{{.+}} 'T' -// CHECK-NEXT: | `-BuiltinType 0x{{.+}} 'int' -// CHECK-NEXT: `-CXXRecordDecl 0x{{.+}} prev 0x{{.+}} col:31 struct TestTemplateDefaultType definition -// CHECK-NEXT: |-DefinitionData empty aggregate standard_layout trivially_copyable pod trivial literal has_constexpr_non_copy_move_ctor can_const_default_init -// CHECK-NEXT: | |-DefaultConstructor exists trivial constexpr needs_implicit defaulted_is_constexpr -// CHECK-NEXT: | |-CopyConstructor simple trivial has_const_param needs_implicit implicit_has_const_param -// CHECK-NEXT: | |-MoveConstructor exists simple trivial needs_implicit -// CHECK-NEXT: | |-CopyAssignment simple trivial has_const_param needs_implicit implicit_has_const_param -// CHECK-NEXT: | |-MoveAssignment exists simple trivial needs_implicit -// CHECK-NEXT: | `-Destructor simple irrelevant trivial needs_implicit -// CHECK-NEXT: `-CXXRecordDecl 0x{{.+}} col:31 implicit struct TestTemplateDefaultType - -// CHECK: ClassTemplateDecl 0x{{.+}} <{{.+}}:[[@LINE-148]]:3, col:31> col:31 TestTemplateDefaultNonType -// CHECK-NEXT: |-NonTypeTemplateParmDecl 0x{{.+}} col:16 'int' depth 0 index 0 I -// CHECK-NEXT: | `-TemplateArgument expr -// CHECK-NEXT: | `-ConstantExpr 0x{{.+}} 'int' -// CHECK-NEXT: | |-value: Int 42 -// CHECK-NEXT: | `-IntegerLiteral 0x{{.+}} 'int' 42 -// CHECK-NEXT: `-CXXRecordDecl 0x{{.+}} col:31 struct TestTemplateDefaultNonType - -// CHECK: ClassTemplateDecl 0x{{.+}} <{{.+}}:{{.*}}:3, col:68> col:68 TestTemplateTemplateDefaultType -// CHECK-NEXT: |-TemplateTemplateParmDecl 0x{{.+}} col:37 depth 0 index 0 TT -// CHECK-NEXT: | |-TemplateTypeParmDecl 0x{{.+}} col:29 typename depth 1 index 0 -// CHECK-NEXT: | `-TemplateArgument template TestClassTemplate -// CHECK-NEXT: `-CXXRecordDecl 0x{{.+}} col:68 struct TestTemplateTemplateDefaultType - -// CHECK: ClassTemplateDecl 0x{{.+}} prev 0x{{.+}} <{{.+}}:{{.*}}:3, col:82> col:48 TestTemplateTemplateDefaultType -// CHECK-NEXT: |-TemplateTemplateParmDecl 0x{{.+}} col:37 depth 0 index 0 TT -// CHECK-NEXT: | |-TemplateTypeParmDecl 0x{{.+}} col:29 typename depth 1 index 0 -// CHECK-NEXT: | `-TemplateArgument template TestClassTemplate -// CHECK-NEXT: | `-inherited from TemplateTemplateParm 0x{{.+}} 'TT' -// CHECK-NEXT: `-CXXRecordDecl 0x{{.+}} prev 0x{{.+}} col:48 struct TestTemplateTemplateDefaultType definition -// CHECK-NEXT: |-DefinitionData empty aggregate standard_layout trivially_copyable pod trivial literal has_constexpr_non_copy_move_ctor can_const_default_init -// CHECK-NEXT: | |-DefaultConstructor exists trivial constexpr needs_implicit defaulted_is_constexpr -// CHECK-NEXT: | |-CopyConstructor simple trivial has_const_param needs_implicit implicit_has_const_param -// CHECK-NEXT: | |-MoveConstructor exists simple trivial needs_implicit -// CHECK-NEXT: | |-CopyAssignment simple trivial has_const_param needs_implicit implicit_has_const_param -// CHECK-NEXT: | |-MoveAssignment exists simple trivial needs_implicit -// CHECK-NEXT: | `-Destructor simple irrelevant trivial needs_implicit -// CHECK-NEXT: `-CXXRecordDecl 0x{{.+}} col:48 implicit struct TestTemplateTemplateDefaultType - - -// PR15220 dump instantiation only once -namespace testCanonicalTemplate { - class A {}; - - template void TestFunctionTemplate(T); - template void TestFunctionTemplate(T); - void bar(A a) { TestFunctionTemplate(a); } - // CHECK: FunctionTemplateDecl 0x{{.+}} <{{.+}}:[[@LINE-3]]:3, col:51> col:29 TestFunctionTemplate - // CHECK-NEXT: |-TemplateTypeParmDecl 0x{{.+}} col:21 referenced typename depth 0 index 0 T - // CHECK-NEXT: |-FunctionDecl 0x{{.*}} col:29 TestFunctionTemplate 'void (T)' - // CHECK-NEXT: | `-ParmVarDecl 0x{{.*}} col:51 'T' - // CHECK-NEXT: `-FunctionDecl 0x{{.*}} col:29 used TestFunctionTemplate 'void (testCanonicalTemplate::A)' - // CHECK-NEXT: |-TemplateArgument type 'testCanonicalTemplate::A' - // CHECK-NEXT: | `-RecordType 0x{{.+}} 'testCanonicalTemplate::A' - // CHECK-NEXT: | `-CXXRecord 0x{{.+}} 'A' - // CHECK-NEXT: `-ParmVarDecl 0x{{.*}} col:51 'testCanonicalTemplate::A':'testCanonicalTemplate::A' - - // CHECK: FunctionTemplateDecl 0x{{.+}} prev 0x{{.+}} <{{.+}}:[[@LINE-12]]:3, col:51> col:29 TestFunctionTemplate - // CHECK-NEXT: |-TemplateTypeParmDecl 0x{{.+}} col:21 referenced typename depth 0 index 0 T - // CHECK-NEXT: |-FunctionDecl{{.*}} 0x{{.+}} prev 0x{{.+}} col:29 TestFunctionTemplate 'void (T)' - // CHECK-NEXT: | `-ParmVarDecl 0x{{.+}} col:51 'T' - // CHECK-NEXT: `-Function 0x{{.+}} 'TestFunctionTemplate' 'void (testCanonicalTemplate::A)' - // CHECK-NOT: TemplateArgument - - template class TestClassTemplate { - template friend class TestClassTemplate; - }; - TestClassTemplate a; - // CHECK: ClassTemplateDecl 0x{{.+}} <{{.+}}:[[@LINE-4]]:3, line:[[@LINE-2]]:3> line:[[@LINE-4]]:31 TestClassTemplate - // CHECK-NEXT: |-TemplateTypeParmDecl 0x{{.+}} col:21 typename depth 0 index 0 T1 - // CHECK-NEXT: |-CXXRecordDecl 0x{{.+}} line:[[@LINE-6]]:31 class TestClassTemplate definition - // CHECK-NEXT: | |-DefinitionData empty aggregate standard_layout trivially_copyable pod trivial literal has_constexpr_non_copy_move_ctor can_const_default_init - // CHECK-NEXT: | | |-DefaultConstructor exists trivial constexpr needs_implicit defaulted_is_constexpr - // CHECK-NEXT: | | |-CopyConstructor simple trivial has_const_param needs_implicit implicit_has_const_param - // CHECK-NEXT: | | |-MoveConstructor exists simple trivial needs_implicit - // CHECK-NEXT: | | |-CopyAssignment simple trivial has_const_param needs_implicit implicit_has_const_param - // CHECK-NEXT: | | |-MoveAssignment exists simple trivial needs_implicit - // CHECK-NEXT: | | `-Destructor simple irrelevant trivial needs_implicit - // CHECK-NEXT: | |-CXXRecordDecl 0x{{.+}} col:31 implicit class TestClassTemplate - // CHECK-NEXT: | `-FriendDecl 0x{{.+}} col:40 - // CHECK-NEXT: | `-ClassTemplateDecl 0x{{.+}} parent 0x{{.+}} col:40 TestClassTemplate - // CHECK-NEXT: | |-TemplateTypeParmDecl 0x{{.+}} col:23 typename depth 1 index 0 T2 - // CHECK-NEXT: | `-CXXRecordDecl 0x{{.+}} parent 0x{{.+}} col:40 class TestClassTemplate - // CHECK-NEXT: `-ClassTemplateSpecializationDecl 0x{{.+}} line:[[@LINE-19]]:31 class TestClassTemplate definition - // CHECK-NEXT: |-DefinitionData pass_in_registers empty aggregate standard_layout trivially_copyable pod trivial literal has_constexpr_non_copy_move_ctor can_const_default_init - // CHECK-NEXT: | |-DefaultConstructor exists trivial constexpr defaulted_is_constexpr - // CHECK-NEXT: | |-CopyConstructor simple trivial has_const_param implicit_has_const_param - // CHECK-NEXT: | |-MoveConstructor exists simple trivial - // CHECK-NEXT: | |-CopyAssignment simple trivial has_const_param needs_implicit implicit_has_const_param - // CHECK-NEXT: | |-MoveAssignment exists simple trivial needs_implicit - // CHECK-NEXT: | `-Destructor simple irrelevant trivial needs_implicit - // CHECK-NEXT: |-TemplateArgument type 'testCanonicalTemplate::A' - // CHECK-NEXT: | `-RecordType 0x{{.+}} 'testCanonicalTemplate::A' - // CHECK-NEXT: | `-CXXRecord 0x{{.+}} 'A' - // CHECK-NEXT: |-CXXRecordDecl 0x{{.+}} prev 0x{{.+}} col:31 implicit class TestClassTemplate - // CHECK-NEXT: |-FriendDecl 0x{{.+}} col:40 - // CHECK-NEXT: | `-ClassTemplateDecl 0x{{.+}} parent 0x{{.+}} prev 0x{{.+}} col:40 TestClassTemplate - // CHECK-NEXT: | |-TemplateTypeParmDecl 0x{{.+}} col:23 typename depth 0 index 0 T2 - // CHECK-NEXT: | |-CXXRecordDecl 0x{{.+}} parent 0x{{.+}} prev 0x{{.+}} col:40 class TestClassTemplate - // CHECK-NEXT: | `-ClassTemplateSpecialization 0x{{.+}} 'TestClassTemplate' - // CHECK-NEXT: |-CXXConstructorDecl 0x{{.+}} col:31 implicit used constexpr TestClassTemplate 'void () noexcept' inline default trivial - // CHECK-NEXT: | `-CompoundStmt 0x{{.+}} - // CHECK-NEXT: |-CXXConstructorDecl 0x{{.+}} col:31 implicit constexpr TestClassTemplate 'void (const testCanonicalTemplate::TestClassTemplate &)' inline default trivial noexcept-unevaluated 0x{{.+}} - // CHECK-NEXT: | `-ParmVarDecl 0x{{.+}} col:31 'const testCanonicalTemplate::TestClassTemplate &' - // CHECK-NEXT: `-CXXConstructorDecl 0x{{.+}} col:31 implicit constexpr TestClassTemplate 'void (testCanonicalTemplate::TestClassTemplate &&)' inline default trivial noexcept-unevaluated 0x{{.+}} - // CHECK-NEXT: `-ParmVarDecl 0x{{.+}} col:31 'testCanonicalTemplate::TestClassTemplate &&' - - - template class TestClassTemplate2; - template class TestClassTemplate2; - template class TestClassTemplate2 { - }; - TestClassTemplate2 a2; - // CHECK: ClassTemplateDecl 0x{{.+}} <{{.+}}:[[@LINE-5]]:3, col:31> col:31 TestClassTemplate2 - // CHECK-NEXT: |-TemplateTypeParmDecl 0x{{.+}} col:21 typename depth 0 index 0 T1 - // CHECK-NEXT: |-CXXRecordDecl 0x{{.+}} col:31 class TestClassTemplate2 - // CHECK-NEXT: `-ClassTemplateSpecializationDecl 0x{{.+}} line:[[@LINE-6]]:31 class TestClassTemplate2 definition - // CHECK-NEXT: |-DefinitionData pass_in_registers empty aggregate standard_layout trivially_copyable pod trivial literal has_constexpr_non_copy_move_ctor can_const_default_init - // CHECK-NEXT: | |-DefaultConstructor exists trivial constexpr defaulted_is_constexpr - // CHECK-NEXT: | |-CopyConstructor simple trivial has_const_param implicit_has_const_param - // CHECK-NEXT: | |-MoveConstructor exists simple trivial - // CHECK-NEXT: | |-CopyAssignment simple trivial has_const_param needs_implicit implicit_has_const_param - // CHECK-NEXT: | |-MoveAssignment exists simple trivial needs_implicit - // CHECK-NEXT: | `-Destructor simple irrelevant trivial needs_implicit - // CHECK-NEXT: |-TemplateArgument type 'testCanonicalTemplate::A' - // CHECK-NEXT: | `-RecordType 0x{{.+}} 'testCanonicalTemplate::A' - // CHECK-NEXT: | `-CXXRecord 0x{{.+}} 'A' - // CHECK-NEXT: |-CXXRecordDecl 0x{{.+}} prev 0x{{.+}} col:31 implicit class TestClassTemplate2 - // CHECK-NEXT: |-CXXConstructorDecl 0x{{.+}} col:31 implicit used constexpr TestClassTemplate2 'void () noexcept' inline default trivial - // CHECK-NEXT: | `-CompoundStmt 0x{{.+}} - // CHECK-NEXT: |-CXXConstructorDecl 0x{{.+}} col:31 implicit constexpr TestClassTemplate2 'void (const testCanonicalTemplate::TestClassTemplate2 &)' inline default trivial noexcept-unevaluated 0x{{.+}} - // CHECK-NEXT: | `-ParmVarDecl 0x{{.+}} col:31 'const testCanonicalTemplate::TestClassTemplate2 &' - // CHECK-NEXT: `-CXXConstructorDecl 0x{{.+}} col:31 implicit constexpr TestClassTemplate2 'void (testCanonicalTemplate::TestClassTemplate2 &&)' inline default trivial noexcept-unevaluated 0x{{.+}} - // CHECK-NEXT: `-ParmVarDecl 0x{{.+}} col:31 'testCanonicalTemplate::TestClassTemplate2 &&' - - // CHECK: ClassTemplateDecl 0x{{.+}} prev 0x{{.+}} <{{.+}}:[[@LINE-26]]:3, col:31> col:31 TestClassTemplate2 - // CHECK-NEXT: |-TemplateTypeParmDecl 0x{{.+}} col:21 typename depth 0 index 0 T1 - // CHECK-NEXT: |-CXXRecordDecl 0x{{.+}} prev 0x{{.+}} col:31 class TestClassTemplate2 - // CHECK-NEXT: `-ClassTemplateSpecialization 0x{{.+}} 'TestClassTemplate2' - - // CHECK: ClassTemplateDecl 0x{{.+}} prev 0x{{.+}} <{{.+}}:[[@LINE-30]]:3, line:[[@LINE-29]]:3> line:[[@LINE-30]]:31 TestClassTemplate2 - // CHECK-NEXT: |-TemplateTypeParmDecl 0x{{.+}} col:21 typename depth 0 index 0 T1 - // CHECK-NEXT: |-CXXRecordDecl 0x{{.+}} prev 0x{{.+}} line:[[@LINE-32]]:31 class TestClassTemplate2 definition - // CHECK-NEXT: | |-DefinitionData empty aggregate standard_layout trivially_copyable pod trivial literal has_constexpr_non_copy_move_ctor can_const_default_init - // CHECK-NEXT: | | |-DefaultConstructor exists trivial constexpr needs_implicit defaulted_is_constexpr - // CHECK-NEXT: | | |-CopyConstructor simple trivial has_const_param needs_implicit implicit_has_const_param - // CHECK-NEXT: | | |-MoveConstructor exists simple trivial needs_implicit - // CHECK-NEXT: | | |-CopyAssignment simple trivial has_const_param needs_implicit implicit_has_const_param - // CHECK-NEXT: | | |-MoveAssignment exists simple trivial needs_implicit - // CHECK-NEXT: | | `-Destructor simple irrelevant trivial needs_implicit - // CHECK-NEXT: | `-CXXRecordDecl 0x{{.+}} col:31 implicit class TestClassTemplate2 - // CHECK-NEXT: `-ClassTemplateSpecialization 0x{{.+}} 'TestClassTemplate2' - - struct S { - template static const T TestVarTemplate; // declaration of a static data member template - }; - template - const T S::TestVarTemplate = { }; // definition of a static data member template - - void f() - { - int i = S::TestVarTemplate; - int j = S::TestVarTemplate; - } - - // CHECK: VarTemplateDecl 0x{{.+}} <{{.+}}:[[@LINE-11]]:7, col:43> col:43 TestVarTemplate - // CHECK-NEXT: |-TemplateTypeParmDecl 0x{{.+}} col:25 referenced typename depth 0 index 0 T - // CHECK-NEXT: |-VarDecl 0x{{.+}} col:43 TestVarTemplate 'const T' static - // CHECK-NEXT: |-VarTemplateSpecializationDecl 0x{{.+}} parent 0x{{.+}} prev 0x{{.+}} col:14 referenced TestVarTemplate 'const int':'const int' cinit - // CHECK-NEXT: | |-TemplateArgument type 'int' - // CHECK-NEXT: | | `-BuiltinType 0x{{.+}} 'int' - // CHECK-NEXT: | `-InitListExpr 0x{{.+}} 'int':'int' - // CHECK-NEXT: `-VarTemplateSpecializationDecl 0x{{.+}} col:43 referenced TestVarTemplate 'const int':'const int' static - // CHECK-NEXT: `-TemplateArgument type 'int' - - // CHECK: VarTemplateSpecializationDecl 0x{{.+}} <{{.+}}:[[@LINE-21]]:28, col:43> col:43 referenced TestVarTemplate 'const int':'const int' static - // CHECK-NEXT:`-TemplateArgument type 'int' - // CHECK-NEXT: `-BuiltinType 0x{{.+}} 'int' - - // CHECK: VarTemplateDecl 0x{{.+}} parent 0x{{.+}} prev 0x{{.+}} <{{.+}}:[[@LINE-23]]:3, line:[[@LINE-22]]:34> col:14 TestVarTemplate - // CHECK-NEXT: |-TemplateTypeParmDecl 0x{{.+}} col:21 referenced typename depth 0 index 0 T - // CHECK-NEXT: |-VarDecl 0x{{.+}} parent 0x{{.+}} prev 0x{{.+}} col:14 TestVarTemplate 'const T' cinit - // CHECK-NEXT: | `-InitListExpr 0x{{.+}} 'void' - // CHECK-NEXT: |-VarTemplateSpecialization 0x{{.+}} 'TestVarTemplate' 'const int':'const int' - // CHECK-NEXT: `-VarTemplateSpecialization 0x{{.+}} 'TestVarTemplate' 'const int':'const int' - - // CHECK: VarTemplateSpecializationDecl 0x{{.+}} parent 0x{{.+}} prev 0x{{.+}} <{{.+}}:[[@LINE-29]]:3, col:34> col:14 referenced TestVarTemplate 'const int':'const int' cinit - // CHECK-NEXT: |-TemplateArgument type 'int' - // CHECK-NEXT: | `-BuiltinType 0x{{.+}} 'int' - // CHECK-NEXT: `-InitListExpr 0x{{.+}} 'int':'int' -} - -template -class TestClassScopeFunctionSpecialization { - template void foo(U a) { } - template<> void foo(int a) { } -}; -// CHECK: ClassScopeFunctionSpecializationDecl -// CHECK-NEXT: CXXMethod{{.*}} foo 'void (int)' -// CHECK-NEXT: ParmVarDecl -// CHECK-NEXT: CompoundStmt -// CHECK-NEXT: TemplateArgument{{.*}} 'int' - -namespace TestTemplateTypeParmDecl { - template void foo(); -} -// CHECK: NamespaceDecl{{.*}} TestTemplateTypeParmDecl -// CHECK-NEXT: FunctionTemplateDecl -// CHECK-NEXT: TemplateTypeParmDecl{{.*}} typename depth 0 index 0 ... T -// CHECK-NEXT: TemplateTypeParmDecl{{.*}} class depth 0 index 1 U -// CHECK-NEXT: TemplateArgument type 'int' - -namespace TestNonTypeTemplateParmDecl { - template void foo(); -} -// CHECK: NamespaceDecl{{.*}} TestNonTypeTemplateParmDecl -// CHECK-NEXT: FunctionTemplateDecl -// CHECK-NEXT: NonTypeTemplateParmDecl{{.*}} 'int' depth 0 index 0 I -// CHECK-NEXT: TemplateArgument expr -// CHECK-NEXT: ConstantExpr{{.*}} 'int' -// CHECK-NEXT: value: Int 1 -// CHECK-NEXT: IntegerLiteral{{.*}} 'int' 1 -// CHECK-NEXT: NonTypeTemplateParmDecl{{.*}} 'int' depth 0 index 1 ... J - -namespace TestTemplateTemplateParmDecl { - template class A; - template