diff options
author | dim <dim@FreeBSD.org> | 2013-04-08 18:45:10 +0000 |
---|---|---|
committer | dim <dim@FreeBSD.org> | 2013-04-08 18:45:10 +0000 |
commit | c72c57c9e9b69944e3e009cd5e209634839581d3 (patch) | |
tree | 4fc2f184c499d106f29a386c452b49e5197bf63d /test/Misc | |
parent | 5b20025c30d23d521e12c1f33ec8fa6b821952cd (diff) | |
download | FreeBSD-src-c72c57c9e9b69944e3e009cd5e209634839581d3.zip FreeBSD-src-c72c57c9e9b69944e3e009cd5e209634839581d3.tar.gz |
Vendor import of clang trunk r178860:
http://llvm.org/svn/llvm-project/cfe/trunk@178860
Diffstat (limited to 'test/Misc')
28 files changed, 1700 insertions, 100 deletions
diff --git a/test/Misc/ast-dump-attr.cpp b/test/Misc/ast-dump-attr.cpp new file mode 100644 index 0000000..3efcd09 --- /dev/null +++ b/test/Misc/ast-dump-attr.cpp @@ -0,0 +1,97 @@ +// RUN: %clang_cc1 -triple x86_64-pc-linux -std=c++11 -ast-dump -ast-dump-filter Test %s | FileCheck --strict-whitespace %s + +int TestLocation +__attribute__((unused)); +// CHECK: VarDecl{{.*}}TestLocation +// CHECK-NEXT: UnusedAttr 0x{{[^ ]*}} <line:[[@LINE-2]]:16> + +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 +// CHECK-NEXT: <<<NULL>>> + +int TestAlignedExpr __attribute__((aligned(4))); +// CHECK: VarDecl{{.*}}TestAlignedExpr +// CHECK-NEXT: AlignedAttr +// 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{{.*}} ident1 + +void TestBool(void *, int) +__attribute__((pointer_with_type_tag(bool1,1,2))); +// CHECK: FunctionDecl{{.*}}TestBool +// CHECK: ArgumentWithTypeTagAttr{{.*}} IsPointer + +void TestUnsigned(void *, int) +__attribute__((pointer_with_type_tag(unsigned1,1,2))); +// CHECK: FunctionDecl{{.*}}TestUnsigned +// CHECK: ArgumentWithTypeTagAttr{{.*}} 0 1 + +void TestInt(void) __attribute__((constructor(123))); +// CHECK: FunctionDecl{{.*}}TestInt +// CHECK-NEXT: ConstructorAttr{{.*}} 123 + +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 *TestVariadicUnsigned1(int) __attribute__((alloc_size(1))); +// CHECK: FunctionDecl{{.*}}TestVariadicUnsigned1 +// CHECK: AllocSizeAttr{{.*}} 0 + +void *TestVariadicUnsigned2(int, int) __attribute__((alloc_size(1,2))); +// CHECK: FunctionDecl{{.*}}TestVariadicUnsigned2 +// CHECK: AllocSizeAttr{{.*}} 0 1 diff --git a/test/Misc/ast-dump-color.cpp b/test/Misc/ast-dump-color.cpp new file mode 100644 index 0000000..0367cc5 --- /dev/null +++ b/test/Misc/ast-dump-color.cpp @@ -0,0 +1,87 @@ +// RUN: %clang_cc1 -triple x86_64-pc-linux -std=c++11 -ast-dump -fcolor-diagnostics %s | FileCheck --strict-whitespace %s +// REQUIRES: ansi-escape-sequences + +/// <a>Hello</a> +/// <br/> +int Test __attribute__((unused)); + +/// Comment +void TestAttributedStmt() { + switch (1) { + case 1: + [[clang::fallthrough]]; + case 2: + ; + } +} + +class __attribute__((lockable)) Mutex { + /// A variable + int var1; + /// Another variable + /// + /// Like the other variable, but different + int var2; +} mu1, mu2; +int TestExpr __attribute__((guarded_by(mu1))); + +//CHECK: {{^}}[[Blue:.\[0;34m]][[RESET:.\[0m]][[GREEN:.\[0;1;32m]]TranslationUnitDecl[[RESET]][[Yellow:.\[0;33m]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]<invalid sloc>[[RESET]]>{{$}} +//CHECK: {{^}}[[Blue]]|-[[RESET]][[GREEN]]TypedefDecl[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]<invalid sloc>[[RESET]]>[[CYAN:.\[0;1;36m]] __int128_t[[RESET]] [[Green:.\[0;32m]]'__int128'[[RESET]]{{$}} +//CHECK: {{^}}[[Blue]]|-[[RESET]][[GREEN]]TypedefDecl[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]<invalid sloc>[[RESET]]>[[CYAN]] __uint128_t[[RESET]] [[Green]]'unsigned __int128'[[RESET]]{{$}} +//CHECK: {{^}}[[Blue]]|-[[RESET]][[GREEN]]TypedefDecl[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]<invalid sloc>[[RESET]]>[[CYAN]] __builtin_va_list[[RESET]] [[Green]]'__va_list_tag [1]'[[RESET]]{{$}} +//CHECK: {{^}}[[Blue]]|-[[RESET]][[GREEN]]VarDecl[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]{{.*}}ast-dump-color.cpp:6:1[[RESET]], [[Yellow]]col:5[[RESET]]>[[CYAN]] Test[[RESET]] [[Green]]'int'[[RESET]]{{$}} +//CHECK: {{^}}[[Blue]]| |-[[RESET]][[BLUE:.\[0;1;34m]]UnusedAttr[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]col:25[[RESET]]>{{$}} +//CHECK: {{^}}[[Blue]]| `-[[RESET]][[YELLOW:.\[0;1;33m]]FullComment[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]line:4:4[[RESET]], [[Yellow]]line:5:8[[RESET]]>{{$}} +//CHECK: {{^}}[[Blue]]| `-[[RESET]][[YELLOW]]ParagraphComment[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]line:4:4[[RESET]], [[Yellow]]line:5:8[[RESET]]>{{$}} +//CHECK: {{^}}[[Blue]]| |-[[RESET]][[YELLOW]]TextComment[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]line:4:4[[RESET]]> Text=" "{{$}} +//CHECK: {{^}}[[Blue]]| |-[[RESET]][[YELLOW]]HTMLStartTagComment[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]col:5[[RESET]], [[Yellow]]col:7[[RESET]]> Name="a"{{$}} +//CHECK: {{^}}[[Blue]]| |-[[RESET]][[YELLOW]]TextComment[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]col:8[[RESET]], [[Yellow]]col:12[[RESET]]> Text="Hello"{{$}} +//CHECK: {{^}}[[Blue]]| |-[[RESET]][[YELLOW]]HTMLEndTagComment[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]col:13[[RESET]], [[Yellow]]col:16[[RESET]]> Name="a"{{$}} +//CHECK: {{^}}[[Blue]]| |-[[RESET]][[YELLOW]]TextComment[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]line:5:4[[RESET]]> Text=" "{{$}} +//CHECK: {{^}}[[Blue]]| `-[[RESET]][[YELLOW]]HTMLStartTagComment[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]col:5[[RESET]], [[Yellow]]col:8[[RESET]]> Name="br" SelfClosing{{$}} +//CHECK: {{^}}[[Blue]]|-[[RESET]][[GREEN]]FunctionDecl[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]line:9:1[[RESET]], [[Yellow]]line:16:1[[RESET]]>[[CYAN]] TestAttributedStmt[[RESET]] [[Green]]'void (void)'[[RESET]]{{$}} +//CHECK: {{^}}[[Blue]]| |-[[RESET]][[MAGENTA:.\[0;1;35m]]CompoundStmt[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]line:9:27[[RESET]], [[Yellow]]line:16:1[[RESET]]>{{$}} +//CHECK: {{^}}[[Blue]]| | `-[[RESET]][[MAGENTA]]SwitchStmt[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]line:10:3[[RESET]], [[Yellow]]line:15:3[[RESET]]>{{$}} +//CHECK: {{^}}[[Blue]]| | |-[[RESET]][[Blue:.\[0;34m]]<<<NULL>>>[[RESET]]{{$}} +//CHECK: {{^}}[[Blue]]| | |-[[RESET]][[MAGENTA]]IntegerLiteral[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]line:10:11[[RESET]]> [[Green]]'int'[[RESET]][[Cyan:.\[0;36m]][[RESET]][[Cyan]][[RESET]][[CYAN]] 1[[RESET]]{{$}} +//CHECK: {{^}}[[Blue]]| | `-[[RESET]][[MAGENTA]]CompoundStmt[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]col:14[[RESET]], [[Yellow]]line:15:3[[RESET]]>{{$}} +//CHECK: {{^}}[[Blue]]| | |-[[RESET]][[MAGENTA]]CaseStmt[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]line:11:3[[RESET]], [[Yellow]]line:12:27[[RESET]]>{{$}} +//CHECK: {{^}}[[Blue]]| | | |-[[RESET]][[MAGENTA]]IntegerLiteral[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]line:11:8[[RESET]]> [[Green]]'int'[[RESET]][[Cyan]][[RESET]][[Cyan]][[RESET]][[CYAN]] 1[[RESET]]{{$}} +//CHECK: {{^}}[[Blue]]| | | |-[[RESET]][[Blue]]<<<NULL>>>[[RESET]]{{$}} +//CHECK: {{^}}[[Blue]]| | | `-[[RESET]][[MAGENTA]]AttributedStmt[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]line:12:5[[RESET]], [[Yellow]]col:27[[RESET]]>{{$}} +//CHECK: {{^}}[[Blue]]| | | |-[[RESET]][[BLUE]]FallThroughAttr[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]col:7[[RESET]], [[Yellow]]col:14[[RESET]]>{{$}} +//CHECK: {{^}}[[Blue]]| | | `-[[RESET]][[MAGENTA]]NullStmt[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]col:27[[RESET]]>{{$}} +//CHECK: {{^}}[[Blue]]| | `-[[RESET]][[MAGENTA]]CaseStmt[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]line:13:3[[RESET]], [[Yellow]]line:14:5[[RESET]]>{{$}} +//CHECK: {{^}}[[Blue]]| | |-[[RESET]][[MAGENTA]]IntegerLiteral[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]line:13:8[[RESET]]> [[Green]]'int'[[RESET]][[Cyan]][[RESET]][[Cyan]][[RESET]][[CYAN]] 2[[RESET]]{{$}} +//CHECK: {{^}}[[Blue]]| | |-[[RESET]][[Blue]]<<<NULL>>>[[RESET]]{{$}} +//CHECK: {{^}}[[Blue]]| | `-[[RESET]][[MAGENTA]]NullStmt[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]line:14:5[[RESET]]>{{$}} +//CHECK: {{^}}[[Blue]]| `-[[RESET]][[YELLOW]]FullComment[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]line:8:4[[RESET]], [[Yellow]]col:11[[RESET]]>{{$}} +//CHECK: {{^}}[[Blue]]| `-[[RESET]][[YELLOW]]ParagraphComment[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]col:4[[RESET]], [[Yellow]]col:11[[RESET]]>{{$}} +//CHECK: {{^}}[[Blue]]| `-[[RESET]][[YELLOW]]TextComment[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]col:4[[RESET]], [[Yellow]]col:11[[RESET]]> Text=" Comment"{{$}} +//CHECK: {{^}}[[Blue]]|-[[RESET]][[GREEN]]CXXRecordDecl[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]line:18:1[[RESET]], [[Yellow]]line:25:1[[RESET]]> class[[CYAN]] Mutex[[RESET]]{{$}} +//CHECK: {{^}}[[Blue]]| |-[[RESET]][[BLUE]]LockableAttr[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]line:18:22[[RESET]]>{{$}} +//CHECK: {{^}}[[Blue]]| |-[[RESET]][[GREEN]]CXXRecordDecl[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]col:1[[RESET]], [[Yellow]]col:33[[RESET]]> class[[CYAN]] Mutex[[RESET]]{{$}} +//CHECK: {{^}}[[Blue]]| |-[[RESET]][[GREEN]]FieldDecl[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]line:20:3[[RESET]], [[Yellow]]col:7[[RESET]]>[[CYAN]] var1[[RESET]] [[Green]]'int'[[RESET]]{{$}} +//CHECK: {{^}}[[Blue]]| | `-[[RESET]][[YELLOW]]FullComment[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]line:19:6[[RESET]], [[Yellow]]col:16[[RESET]]>{{$}} +//CHECK: {{^}}[[Blue]]| | `-[[RESET]][[YELLOW]]ParagraphComment[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]col:6[[RESET]], [[Yellow]]col:16[[RESET]]>{{$}} +//CHECK: {{^}}[[Blue]]| | `-[[RESET]][[YELLOW]]TextComment[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]col:6[[RESET]], [[Yellow]]col:16[[RESET]]> Text=" A variable"{{$}} +//CHECK: {{^}}[[Blue]]| |-[[RESET]][[GREEN]]FieldDecl[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]line:24:3[[RESET]], [[Yellow]]col:7[[RESET]]>[[CYAN]] var2[[RESET]] [[Green]]'int'[[RESET]]{{$}} +//CHECK: {{^}}[[Blue]]| | `-[[RESET]][[YELLOW]]FullComment[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]line:21:6[[RESET]], [[Yellow]]line:23:44[[RESET]]>{{$}} +//CHECK: {{^}}[[Blue]]| | |-[[RESET]][[YELLOW]]ParagraphComment[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]line:21:6[[RESET]], [[Yellow]]col:22[[RESET]]>{{$}} +//CHECK: {{^}}[[Blue]]| | | `-[[RESET]][[YELLOW]]TextComment[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]col:6[[RESET]], [[Yellow]]col:22[[RESET]]> Text=" Another variable"{{$}} +//CHECK: {{^}}[[Blue]]| | `-[[RESET]][[YELLOW]]ParagraphComment[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]line:23:6[[RESET]], [[Yellow]]col:44[[RESET]]>{{$}} +//CHECK: {{^}}[[Blue]]| | `-[[RESET]][[YELLOW]]TextComment[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]col:6[[RESET]], [[Yellow]]col:44[[RESET]]> Text=" Like the other variable, but different"{{$}} +//CHECK: {{^}}[[Blue]]| |-[[RESET]][[GREEN]]CXXConstructorDecl[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]line:18:33[[RESET]]>[[CYAN]] Mutex[[RESET]] [[Green]]'void (void)'[[RESET]] inline{{$}} +//CHECK: {{^}}[[Blue]]| | `-[[RESET]][[MAGENTA]]CompoundStmt[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]col:33[[RESET]]>{{$}} +//CHECK: {{^}}[[Blue]]| |-[[RESET]][[GREEN]]CXXConstructorDecl[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]col:33[[RESET]]>[[CYAN]] Mutex[[RESET]] [[Green]]'void (const class Mutex &)'[[RESET]] inline{{$}} +//CHECK: {{^}}[[Blue]]| | `-[[RESET]][[GREEN]]ParmVarDecl[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]col:33[[RESET]]> [[Green]]'const class Mutex &'[[RESET]]{{$}} +//CHECK: {{^}}[[Blue]]| `-[[RESET]][[GREEN]]CXXConstructorDecl[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]col:33[[RESET]]>[[CYAN]] Mutex[[RESET]] [[Green]]'void (class Mutex &&)'[[RESET]] inline{{$}} +//CHECK: {{^}}[[Blue]]| `-[[RESET]][[GREEN]]ParmVarDecl[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]col:33[[RESET]]> [[Green]]'class Mutex &&'[[RESET]]{{$}} +//CHECK: {{^}}[[Blue]]|-[[RESET]][[GREEN]]VarDecl[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]col:1[[RESET]], [[Yellow]]line:25:3[[RESET]]>[[CYAN]] mu1[[RESET]] [[Green]]'class Mutex':'class Mutex'[[RESET]]{{$}} +//CHECK: {{^}}[[Blue]]| `-[[RESET]][[MAGENTA]]CXXConstructExpr[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]col:3[[RESET]]> [[Green]]'class Mutex':'class Mutex'[[RESET]][[Cyan]][[RESET]][[Cyan]][[RESET]] [[Green]]'void (void)'[[RESET]]{{$}} +//CHECK: {{^}}[[Blue]]|-[[RESET]][[GREEN]]VarDecl[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]line:18:1[[RESET]], [[Yellow]]line:25:8[[RESET]]>[[CYAN]] mu2[[RESET]] [[Green]]'class Mutex':'class Mutex'[[RESET]]{{$}} +//CHECK: {{^}}[[Blue]]| `-[[RESET]][[MAGENTA]]CXXConstructExpr[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]col:8[[RESET]]> [[Green]]'class Mutex':'class Mutex'[[RESET]][[Cyan]][[RESET]][[Cyan]][[RESET]] [[Green]]'void (void)'[[RESET]]{{$}} +//CHECK: {{^}}[[Blue]]`-[[RESET]][[GREEN]]VarDecl[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]line:26:1[[RESET]], [[Yellow]]col:5[[RESET]]>[[CYAN]] TestExpr[[RESET]] [[Green]]'int'[[RESET]]{{$}} +//CHECK: {{^}}[[Blue]] `-[[RESET]][[BLUE]]GuardedByAttr[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]col:29[[RESET]]>{{$}} +//CHECK: {{^}}[[Blue]] `-[[RESET]][[MAGENTA]]DeclRefExpr[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]col:40[[RESET]]> [[Green]]'class Mutex':'class Mutex'[[RESET]][[Cyan]] lvalue[[RESET]][[Cyan]][[RESET]] [[GREEN]]Var[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]][[CYAN]] 'mu1'[[RESET]] [[Green]]'class Mutex':'class Mutex'[[RESET]]{{$}} + diff --git a/test/Misc/ast-dump-comment.cpp b/test/Misc/ast-dump-comment.cpp new file mode 100644 index 0000000..4e84af0 --- /dev/null +++ b/test/Misc/ast-dump-comment.cpp @@ -0,0 +1,69 @@ +// RUN: %clang_cc1 -Wdocumentation -ast-dump -ast-dump-filter Test %s | FileCheck -strict-whitespace %s + +/// Aaa +int TestLocation; +// CHECK: VarDecl{{.*}}TestLocation +// CHECK-NEXT: FullComment 0x{{[^ ]*}} <line:[[@LINE-3]]:4, col:7> + +/// +int TestIndent; +// CHECK: {{^VarDecl.*TestIndent[^()]*$}} +// CHECK-NEXT: {{^`-FullComment.*>$}} + +/// Aaa +int Test_TextComment; +// CHECK: VarDecl{{.*}}Test_TextComment +// CHECK-NEXT: FullComment +// CHECK-NEXT: ParagraphComment +// CHECK-NEXT: TextComment{{.*}} Text=" Aaa" + +/// \brief Aaa +int Test_BlockCommandComment; +// CHECK: VarDecl{{.*}}Test_BlockCommandComment +// CHECK: BlockCommandComment{{.*}} Name="brief" +// CHECK-NEXT: ParagraphComment +// CHECK-NEXT: TextComment{{.*}} Text=" Aaa" + +/// \param Aaa xxx +/// \param [in,out] Bbb yyy +void Test_ParamCommandComment(int Aaa, int Bbb); +// CHECK: FunctionDecl{{.*}}Test_ParamCommandComment +// CHECK: ParamCommandComment{{.*}} [in] implicitly Param="Aaa" ParamIndex=0 +// CHECK-NEXT: ParagraphComment +// CHECK-NEXT: TextComment{{.*}} Text=" xxx" +// CHECK: ParamCommandComment{{.*}} [in,out] explicitly Param="Bbb" ParamIndex=1 +// CHECK-NEXT: ParagraphComment +// CHECK-NEXT: TextComment{{.*}} Text=" yyy" + +/// \tparam Aaa xxx +template <typename Aaa> class Test_TParamCommandComment; +// CHECK: ClassTemplateDecl{{.*}}Test_TParamCommandComment +// CHECK: TParamCommandComment{{.*}} Param="Aaa" Position=<0> +// CHECK-NEXT: ParagraphComment +// CHECK-NEXT: TextComment{{.*}} Text=" xxx" + +/// \c Aaa +int Test_InlineCommandComment; +// CHECK: VarDecl{{.*}}Test_InlineCommandComment +// CHECK: InlineCommandComment{{.*}} Name="c" RenderMonospaced Arg[0]="Aaa" + +/// <a>Aaa</a> +/// <br/> +int Test_HTMLTagComment; +// CHECK: VarDecl{{.*}}Test_HTMLTagComment +// CHECK-NEXT: FullComment +// CHECK-NEXT: ParagraphComment +// CHECK-NEXT: TextComment{{.*}} Text=" " +// CHECK-NEXT: HTMLStartTagComment{{.*}} Name="a" +// CHECK-NEXT: TextComment{{.*}} Text="Aaa" +// CHECK-NEXT: HTMLEndTagComment{{.*}} Name="a" +// CHECK-NEXT: TextComment{{.*}} Text=" " +// CHECK-NEXT: HTMLStartTagComment{{.*}} Name="br" SelfClosing + +/// \verbatim +/// Aaa +/// \endverbatim +int Test_VerbatimBlockComment; +// CHECK: VarDecl{{.*}}Test_VerbatimBlockComment +// CHECK: VerbatimBlockComment{{.*}} Name="verbatim" CloseName="endverbatim" +// CHECK-NEXT: VerbatimBlockLineComment{{.*}} Text=" Aaa" diff --git a/test/Misc/ast-dump-decl.c b/test/Misc/ast-dump-decl.c new file mode 100644 index 0000000..c74da29 --- /dev/null +++ b/test/Misc/ast-dump-decl.c @@ -0,0 +1,152 @@ +// RUN: %clang_cc1 -triple x86_64-unknown-unknown -ast-dump -ast-dump-filter Test %s | FileCheck -check-prefix CHECK -strict-whitespace %s +// RUN: %clang_cc1 -triple x86_64-unknown-unknown -ast-dump %s | FileCheck -check-prefix CHECK-TU -strict-whitespace %s + +int TestLocation; +// CHECK: VarDecl 0x{{[^ ]*}} <{{.*}}:4:1, col:5> TestLocation + +struct TestIndent { + int x; +}; +// CHECK: {{^}}RecordDecl{{.*TestIndent[^()]*$}} +// CHECK-NEXT: {{^}}`-FieldDecl{{.*x[^()]*$}} + +struct TestChildren { + int x; + struct y { + int z; + }; +}; +// CHECK: RecordDecl{{.*}}TestChildren +// CHECK-NEXT: FieldDecl{{.*}}x +// CHECK-NEXT: RecordDecl{{.*}}y +// CHECK-NEXT: FieldDecl{{.*}}z + +// CHECK-TU: TranslationUnitDecl + +void testLabelDecl() { + __label__ TestLabelDecl; + TestLabelDecl: goto TestLabelDecl; +} +// CHECK: LabelDecl{{.*}} TestLabelDecl + +typedef int TestTypedefDecl; +// CHECK: TypedefDecl{{.*}} TestTypedefDecl 'int' + +__module_private__ typedef int TestTypedefDeclPrivate; +// CHECK: TypedefDecl{{.*}} TestTypedefDeclPrivate 'int' __module_private__ + +enum TestEnumDecl { + testEnumDecl +}; +// CHECK: EnumDecl{{.*}} TestEnumDecl +// CHECK-NEXT: EnumConstantDecl{{.*}} testEnumDecl + +struct TestEnumDeclAnon { + enum { + testEnumDeclAnon + } e; +}; +// CHECK: RecordDecl{{.*}} TestEnumDeclAnon +// CHECK-NEXT: EnumDecl{{.*>$}} + +enum TestEnumDeclForward; +// CHECK: EnumDecl{{.*}} TestEnumDeclForward + +__module_private__ enum TestEnumDeclPrivate; +// CHECK: EnumDecl{{.*}} TestEnumDeclPrivate __module_private__ + +struct TestRecordDecl { + int i; +}; +// CHECK: RecordDecl{{.*}} struct TestRecordDecl +// CHECK-NEXT: FieldDecl + +struct TestRecordDeclEmpty { +}; +// CHECK: RecordDecl{{.*}} struct TestRecordDeclEmpty + +struct TestRecordDeclAnon1 { + struct { + } testRecordDeclAnon1; +}; +// CHECK: RecordDecl{{.*}} struct TestRecordDeclAnon1 +// CHECK-NEXT: RecordDecl{{.*}} struct + +struct TestRecordDeclAnon2 { + struct { + }; +}; +// CHECK: RecordDecl{{.*}} struct TestRecordDeclAnon2 +// CHECK-NEXT: RecordDecl{{.*}} struct + +struct TestRecordDeclForward; +// CHECK: RecordDecl{{.*}} struct TestRecordDeclForward + +__module_private__ struct TestRecordDeclPrivate; +// CHECK: RecordDecl{{.*}} struct TestRecordDeclPrivate __module_private__ + +enum testEnumConstantDecl { + TestEnumConstantDecl, + TestEnumConstantDeclInit = 1 +}; +// CHECK: EnumConstantDecl{{.*}} TestEnumConstantDecl 'int' +// CHECK: EnumConstantDecl{{.*}} TestEnumConstantDeclInit 'int' +// CHECK-NEXT: IntegerLiteral + +struct testIndirectFieldDecl { + struct { + int TestIndirectFieldDecl; + }; +}; +// CHECK: IndirectFieldDecl{{.*}} TestIndirectFieldDecl 'int' +// CHECK-NEXT: Field{{.*}} '' +// CHECK-NEXT: Field{{.*}} 'TestIndirectFieldDecl' + +int TestFunctionDecl(int x, enum { e } y) { + return x; +} +// CHECK: FunctionDecl{{.*}} TestFunctionDecl 'int (int, enum {{.*}})' +// CHECK-NEXT: EnumDecl +// CHECK-NEXT: EnumConstantDecl{{.*}} e +// CHECK-NEXT: ParmVarDecl{{.*}} x +// CHECK-NEXT: ParmVarDecl{{.*}} y +// CHECK-NEXT: CompoundStmt + +int TestFunctionDeclProto(int x); +// CHECK: FunctionDecl{{.*}} TestFunctionDeclProto 'int (int)' +// CHECK-NEXT: ParmVarDecl{{.*}} x + +extern int TestFunctionDeclSC(); +// CHECK: FunctionDecl{{.*}} TestFunctionDeclSC 'int ()' extern + +inline int TestFunctionDeclInline(); +// CHECK: FunctionDecl{{.*}} TestFunctionDeclInline 'int ()' inline + +struct testFieldDecl { + int TestFieldDecl; + int TestFieldDeclWidth : 1; + __module_private__ int TestFieldDeclPrivate; +}; +// CHECK: FieldDecl{{.*}} TestFieldDecl 'int' +// CHECK: FieldDecl{{.*}} TestFieldDeclWidth 'int' +// CHECK-NEXT: IntegerLiteral +// CHECK: FieldDecl{{.*}} TestFieldDeclPrivate 'int' __module_private__ + +int TestVarDecl; +// CHECK: VarDecl{{.*}} TestVarDecl 'int' + +extern int TestVarDeclSC; +// CHECK: VarDecl{{.*}} TestVarDeclSC 'int' extern + +__thread int TestVarDeclThread; +// CHECK: VarDecl{{.*}} TestVarDeclThread 'int' __thread + +__module_private__ int TestVarDeclPrivate; +// CHECK: VarDecl{{.*}} TestVarDeclPrivate 'int' __module_private__ + +int TestVarDeclInit = 0; +// CHECK: VarDecl{{.*}} TestVarDeclInit 'int' +// CHECK-NEXT: IntegerLiteral + +void testParmVarDecl(int TestParmVarDecl); +// CHECK: ParmVarDecl{{.*}} TestParmVarDecl 'int' diff --git a/test/Misc/ast-dump-decl.cpp b/test/Misc/ast-dump-decl.cpp new file mode 100644 index 0000000..c8f7d2f --- /dev/null +++ b/test/Misc/ast-dump-decl.cpp @@ -0,0 +1,457 @@ +// RUN: %clang_cc1 -std=c++11 -fms-extensions -ast-dump -ast-dump-filter Test %s | FileCheck -check-prefix CHECK -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 'class 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<typename T> class A; + template<typename T> using TestTypeAliasTemplateDecl = A<T>; +} +// CHECK: TypeAliasTemplateDecl{{.*}} TestTypeAliasTemplateDecl +// CHECK-NEXT: TemplateTypeParmDecl +// CHECK-NEXT: TypeAliasDecl{{.*}} TestTypeAliasTemplateDecl 'A<T>' + +namespace testCXXRecordDecl { + class A { }; + class B { }; + class TestCXXRecordDecl : virtual A, public B { + int i; + }; +} +// CHECK: CXXRecordDecl{{.*}} class TestCXXRecordDecl +// CHECK-NEXT: virtual private 'class testCXXRecordDecl::A' +// CHECK-NEXT: public 'class testCXXRecordDecl::B' +// CHECK-NEXT: CXXRecordDecl{{.*}} class TestCXXRecordDecl +// CHECK-NEXT: FieldDecl + +template<class...T> +class TestCXXRecordDeclPack : public T... { +}; +// CHECK: CXXRecordDecl{{.*}} class TestCXXRecordDeclPack +// CHECK-NEXT: public 'T'... +// CHECK-NEXT: CXXRecordDecl{{.*}} class TestCXXRecordDeclPack + +__module_private__ class TestCXXRecordDeclPrivate; +// CHECK: CXXRecordDecl{{.*}} class TestCXXRecordDeclPrivate __module_private__ + +class testCXXMethodDecl { + __module_private__ void TestCXXMethodDeclPrivate(); + virtual void TestCXXMethodDeclPure() = 0; + void TestCXXMethodDeclDelete() = delete; + void TestCXXMethodDeclThrow() throw(); + void TestCXXMethodDeclThrowType() throw(int); +}; +// CHECK: CXXMethodDecl{{.*}} TestCXXMethodDeclPrivate 'void (void)' __module_private__ +// CHECK: CXXMethodDecl{{.*}} TestCXXMethodDeclPure 'void (void)' virtual pure +// CHECK: CXXMethodDecl{{.*}} TestCXXMethodDeclDelete 'void (void)' delete +// CHECK: CXXMethodDecl{{.*}} TestCXXMethodDeclThrow 'void (void) throw()' +// CHECK: CXXMethodDecl{{.*}} TestCXXMethodDeclThrowType 'void (void) throw(int)' + +namespace testCXXConstructorDecl { + class A { }; + class TestCXXConstructorDecl : public A { + int I; + TestCXXConstructorDecl(A &a, int i) : A(a), I(i) { } + }; +} +// 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 + +class TestCXXDestructorDecl { + ~TestCXXDestructorDecl() { } +}; +// CHECK: CXXDestructorDecl{{.*}} ~TestCXXDestructorDecl 'void (void) noexcept' +// CHECK-NEXT: CompoundStmt + +class TestCXXConversionDecl { + operator int() { return 0; } +}; +// CHECK: CXXConversionDecl{{.*}} operator int 'int (void)' +// 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<typename T> 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{{.*}} TestFunctionTemplate +// CHECK-NEXT: TemplateTypeParmDecl +// CHECK-NEXT: FunctionDecl{{.*}} TestFunctionTemplate 'void (T)' +// CHECK-NEXT: ParmVarDecl{{.*}} 'T' +// CHECK-NEXT: CompoundStmt +// CHECK-NEXT: FunctionDecl{{.*}} TestFunctionTemplate {{.*}}A +// CHECK-NEXT: TemplateArgument +// CHECK-NEXT: ParmVarDecl +// CHECK-NEXT: CompoundStmt +// CHECK-NEXT: Function{{.*}} 'TestFunctionTemplate' {{.*}}B +// CHECK-NEXT: FunctionDecl{{.*}} TestFunctionTemplate {{.*}}C +// CHECK-NEXT: TemplateArgument +// CHECK-NEXT: ParmVarDecl +// CHECK-NEXT: FunctionDecl{{.*}} TestFunctionTemplate {{.*}}D +// CHECK-NEXT: TemplateArgument +// CHECK-NEXT: ParmVarDecl +// CHECK-NEXT: CompoundStmt +// CHECK: FunctionDecl{{.*}} TestFunctionTemplate {{.*}}B +// CHECK-NEXT: TemplateArgument +// CHECK-NEXT: ParmVarDecl + +namespace testClassTemplateDecl { + class A { }; + class B { }; + class C { }; + class D { }; + + template<typename T> class TestClassTemplate { + int i; + }; + + // implicit instantiation + TestClassTemplate<A> a; + + // explicit specialization + template<> class TestClassTemplate<B> { + int j; + }; + + // explicit instantiation declaration + extern template class TestClassTemplate<C>; + + // explicit instantiation definition + template class TestClassTemplate<D>; + + // partial explicit specialization + template<typename T1, typename T2> class TestClassTemplatePartial { + int i; + }; + template<typename T1> class TestClassTemplatePartial<T1, A> { + int j; + }; +} +// CHECK: ClassTemplateDecl{{.*}} TestClassTemplate +// CHECK-NEXT: TemplateTypeParmDecl +// CHECK-NEXT: CXXRecordDecl{{.*}} class TestClassTemplate +// CHECK-NEXT: CXXRecordDecl{{.*}} class TestClassTemplate +// CHECK-NEXT: FieldDecl{{.*}} i +// CHECK-NEXT: ClassTemplateSpecializationDecl{{.*}} class TestClassTemplate +// CHECK-NEXT: TemplateArgument{{.*}}A +// CHECK-NEXT: CXXRecordDecl{{.*}} class TestClassTemplate +// CHECK-NEXT: FieldDecl{{.*}} i +// CHECK: ClassTemplateSpecialization{{.*}} 'TestClassTemplate' +// CHECK-NEXT: ClassTemplateSpecialization{{.*}} 'TestClassTemplate' +// CHECK-NEXT: ClassTemplateSpecialization{{.*}} 'TestClassTemplate' + +// CHECK: ClassTemplateSpecializationDecl{{.*}} class TestClassTemplate +// CHECK-NEXT: TemplateArgument{{.*}}B +// CHECK-NEXT: CXXRecordDecl{{.*}} class TestClassTemplate +// CHECK-NEXT: FieldDecl{{.*}} j + +// CHECK: ClassTemplateSpecializationDecl{{.*}} class TestClassTemplate +// CHECK-NEXT: TemplateArgument{{.*}}C +// CHECK-NEXT: CXXRecordDecl{{.*}} class TestClassTemplate +// CHECK-NEXT: FieldDecl{{.*}} i + +// CHECK: ClassTemplateSpecializationDecl{{.*}} class TestClassTemplate +// CHECK-NEXT: TemplateArgument{{.*}}D +// CHECK-NEXT: CXXRecordDecl{{.*}} class TestClassTemplate +// CHECK-NEXT: FieldDecl{{.*}} i + +// CHECK: ClassTemplatePartialSpecializationDecl{{.*}} class TestClassTemplatePartial +// CHECK-NEXT: TemplateArgument +// CHECK-NEXT: TemplateArgument{{.*}}A +// CHECK-NEXT: TemplateTypeParmDecl +// CHECK-NEXT: CXXRecordDecl{{.*}} class TestClassTemplatePartial +// CHECK-NEXT: FieldDecl{{.*}} j + +// PR15220 dump instantiation only once +namespace testCanonicalTemplate { + class A {}; + + template<typename T> void TestFunctionTemplate(T); + template<typename T> void TestFunctionTemplate(T); + void bar(A a) { TestFunctionTemplate(a); } + // CHECK: FunctionTemplateDecl{{.*}} TestFunctionTemplate + // CHECK-NEXT: TemplateTypeParmDecl + // CHECK-NEXT: FunctionDecl{{.*}} TestFunctionTemplate 'void (T)' + // CHECK-NEXT: ParmVarDecl{{.*}} 'T' + // CHECK-NEXT: FunctionDecl{{.*}} TestFunctionTemplate {{.*}}A + // CHECK-NEXT: TemplateArgument + // CHECK-NEXT: ParmVarDecl + // CHECK: FunctionTemplateDecl{{.*}} TestFunctionTemplate + // CHECK-NEXT: TemplateTypeParmDecl + // CHECK-NEXT: FunctionDecl{{.*}} TestFunctionTemplate 'void (T)' + // CHECK-NEXT: ParmVarDecl{{.*}} 'T' + // CHECK-NEXT: Function{{.*}} 'TestFunctionTemplate' + // CHECK-NEXT-NOT: TemplateArgument + + template<typename T1> class TestClassTemplate { + template<typename T2> friend class TestClassTemplate; + }; + TestClassTemplate<A> a; + // CHECK: ClassTemplateDecl{{.*}} TestClassTemplate + // CHECK-NEXT: TemplateTypeParmDecl + // CHECK-NEXT: CXXRecordDecl{{.*}} class TestClassTemplate + // CHECK-NEXT: CXXRecordDecl{{.*}} class TestClassTemplate + // CHECK-NEXT: FriendDecl + // CHECK-NEXT: ClassTemplateDecl{{.*}} TestClassTemplate + // CHECK-NEXT: TemplateTypeParmDecl + // CHECK-NEXT: CXXRecordDecl{{.*}} class TestClassTemplate + // CHECK-NEXT: ClassTemplateSpecialization{{.*}} 'TestClassTemplate' + // CHECK-NEXT: ClassTemplateSpecializationDecl{{.*}} class TestClassTemplate + // CHECK-NEXT: TemplateArgument{{.*}}A + // CHECK-NEXT: CXXRecordDecl{{.*}} class TestClassTemplate +} + +template <class T> +class TestClassScopeFunctionSpecialization { + template<class U> void foo(U a) { } + template<> void foo<int>(int a) { } +}; +// CHECK: ClassScopeFunctionSpecializationDecl +// CHECK-NEXT: CXXMethod{{.*}} 'foo' 'void (int)' +// CHECK-NEXT: TemplateArgument{{.*}} 'int' + +namespace TestTemplateTypeParmDecl { + template<typename ... T, class U = int> void foo(); +} +// CHECK: NamespaceDecl{{.*}} TestTemplateTypeParmDecl +// CHECK-NEXT: FunctionTemplateDecl +// CHECK-NEXT: TemplateTypeParmDecl{{.*}} typename ... T +// CHECK-NEXT: TemplateTypeParmDecl{{.*}} class U 'int' + +namespace TestNonTypeTemplateParmDecl { + template<int I = 1, int ... J> void foo(); +} +// CHECK: NamespaceDecl{{.*}} TestNonTypeTemplateParmDecl +// CHECK-NEXT: FunctionTemplateDecl +// CHECK-NEXT: NonTypeTemplateParmDecl{{.*}} 'int' I +// CHECK-NEXT: IntegerLiteral{{.*}} 'int' 1 +// CHECK-NEXT: NonTypeTemplateParmDecl{{.*}} 'int' ... J + +namespace TestTemplateTemplateParmDecl { + template<typename T> class A; + template <template <typename> class T = A, template <typename> class ... U> void foo(); +} +// CHECK: NamespaceDecl{{.*}} TestTemplateTemplateParmDecl +// CHECK: FunctionTemplateDecl +// CHECK-NEXT: TemplateTemplateParmDecl{{.*}} T +// CHECK-NEXT: TemplateTypeParmDecl{{.*}} typename +// CHECK-NEXT: TemplateArgument{{.*}} template A +// CHECK-NEXT: TemplateTemplateParmDecl{{.*}} ... U +// CHECK-NEXT: TemplateTypeParmDecl{{.*}} typename + +namespace TestTemplateArgument { + template<typename> class A { }; + template<template<typename> class ...> class B { }; + int foo(); + + template<typename> class testType { }; + template class testType<int>; + // CHECK: ClassTemplateSpecializationDecl{{.*}} class testType + // CHECK-NEXT: TemplateArgument{{.*}} type 'int' + + template<int fp(void)> class testDecl { }; + template class testDecl<foo>; + // CHECK: ClassTemplateSpecializationDecl{{.*}} class testDecl + // CHECK-NEXT: TemplateArgument{{.*}} decl + // CHECK-NEXT: Function{{.*}}foo + + template class testDecl<nullptr>; + // CHECK: ClassTemplateSpecializationDecl{{.*}} class testDecl + // CHECK-NEXT: TemplateArgument{{.*}} nullptr + + template<int> class testIntegral { }; + template class testIntegral<1>; + // CHECK: ClassTemplateSpecializationDecl{{.*}} class testIntegral + // CHECK-NEXT: TemplateArgument{{.*}} integral 1 + + template<template<typename> class> class testTemplate { }; + template class testTemplate<A>; + // CHECK: ClassTemplateSpecializationDecl{{.*}} class testTemplate + // CHECK-NEXT: TemplateArgument{{.*}} A + + template<template<typename> class ...T> class C { + B<T...> testTemplateExpansion; + }; + // FIXME: Need TemplateSpecializationType dumping to test TemplateExpansion. + + template<int, int = 0> class testExpr; + template<int I> class testExpr<I> { }; + // CHECK: ClassTemplatePartialSpecializationDecl{{.*}} class testExpr + // CHECK-NEXT: TemplateArgument{{.*}} expr + // CHECK-NEXT: DeclRefExpr{{.*}}I + + template<int, int ...> class testPack { }; + template class testPack<0, 1, 2>; + // CHECK: ClassTemplateSpecializationDecl{{.*}} class testPack + // CHECK-NEXT: TemplateArgument{{.*}} integral 0 + // CHECK-NEXT: TemplateArgument{{.*}} pack + // CHECK-NEXT: TemplateArgument{{.*}} integral 1 + // CHECK-NEXT: TemplateArgument{{.*}} integral 2 +} + +namespace testUsingDecl { + int i; +} +namespace TestUsingDecl { + using testUsingDecl::i; +} +// CHECK: NamespaceDecl{{.*}} TestUsingDecl +// CHECK-NEXT: UsingDecl{{.*}} testUsingDecl::i +// CHECK-NEXT: UsingShadowDecl{{.*}} Var{{.*}} 'i' 'int' + +namespace testUnresolvedUsing { + class A { }; + template<class T> class B { + public: + A a; + }; + template<class T> class TestUnresolvedUsing : public B<T> { + using typename B<T>::a; + using B<T>::a; + }; +} +// CHECK: CXXRecordDecl{{.*}} TestUnresolvedUsing +// CHECK: UnresolvedUsingTypenameDecl{{.*}} B<T>::a +// CHECK: UnresolvedUsingValueDecl{{.*}} B<T>::a + +namespace TestLinkageSpecDecl { + extern "C" void test1(); + extern "C++" void test2(); +} +// CHECK: NamespaceDecl{{.*}} TestLinkageSpecDecl +// CHECK-NEXT: LinkageSpecDecl{{.*}} C +// CHECK-NEXT: FunctionDecl +// CHECK-NEXT: LinkageSpecDecl{{.*}} C++ +// CHECK-NEXT: FunctionDecl + +class TestAccessSpecDecl { +public: +private: +protected: +}; +// CHECK: CXXRecordDecl{{.*}} class TestAccessSpecDecl +// CHECK-NEXT: CXXRecordDecl{{.*}} class TestAccessSpecDecl +// CHECK-NEXT: AccessSpecDecl{{.*}} public +// CHECK-NEXT: AccessSpecDecl{{.*}} private +// CHECK-NEXT: AccessSpecDecl{{.*}} protected + +template<typename T> class TestFriendDecl { + friend int foo(); + friend class A; + friend T; +}; +// CHECK: CXXRecord{{.*}} TestFriendDecl +// CHECK-NEXT: CXXRecord{{.*}} TestFriendDecl +// CHECK-NEXT: FriendDecl +// CHECK-NEXT: FunctionDecl{{.*}} foo +// CHECK-NEXT: FriendDecl{{.*}} 'class A':'class A' +// CHECK-NEXT: FriendDecl{{.*}} 'T' + +namespace TestFileScopeAsmDecl { + asm("ret"); +} +// CHECK: NamespaceDecl{{.*}} TestFileScopeAsmDecl{{$}} +// CHECK: FileScopeAsmDecl{{.*>$}} +// CHECK-NEXT: StringLiteral + +namespace TestFriendDecl2 { + void f(); + struct S { + friend void f(); + }; +} +// CHECK: NamespaceDecl [[TestFriendDecl2:0x.*]] <{{.*}}> TestFriendDecl2 +// CHECK: |-FunctionDecl [[TestFriendDecl2_f:0x.*]] <{{.*}}> f 'void (void)' +// CHECK: `-CXXRecordDecl {{.*}} struct S +// CHECK: |-CXXRecordDecl {{.*}} struct S +// CHECK: `-FriendDecl +// CHECK: `-FunctionDecl {{.*}} parent [[TestFriendDecl2]] prev [[TestFriendDecl2_f]] <{{.*}}> f 'void (void)' diff --git a/test/Misc/ast-dump-decl.m b/test/Misc/ast-dump-decl.m new file mode 100644 index 0000000..f8a5e5a --- /dev/null +++ b/test/Misc/ast-dump-decl.m @@ -0,0 +1,136 @@ +// RUN: %clang_cc1 -Wno-unused -fblocks -ast-dump -ast-dump-filter Test %s | FileCheck -strict-whitespace %s + +@protocol P +@end + +@interface A +@end + +@interface TestObjCIvarDecl : A +@end + +@implementation TestObjCIvarDecl { + int varDefault; + @private int varPrivate; + @protected int varProtected; + @public int varPublic; + @package int varPackage; +} +@end +// CHECK: ObjCImplementationDecl{{.*}} TestObjCIvarDecl +// CHECK-NEXT: ObjCInterface{{.*}} 'TestObjCIvarDecl' +// CHECK-NEXT: ObjCIvarDecl{{.*}} varDefault 'int' private +// CHECK-NEXT: ObjCIvarDecl{{.*}} varPrivate 'int' private +// CHECK-NEXT: ObjCIvarDecl{{.*}} varProtected 'int' protected +// CHECK-NEXT: ObjCIvarDecl{{.*}} varPublic 'int' public +// CHECK-NEXT: ObjCIvarDecl{{.*}} varPackage 'int' package + +@interface testObjCMethodDecl : A { +} +- (int) TestObjCMethodDecl: (int)i, ...; +// CHECK: ObjCMethodDecl{{.*}} - TestObjCMethodDecl: 'int' +// CHECK-NEXT: ParmVarDecl{{.*}} i 'int' +// CHECK-NEXT: ... +@end + +@implementation testObjCMethodDecl +- (int) TestObjCMethodDecl: (int)i, ... { + return 0; +} +// CHECK: ObjCMethodDecl{{.*}} - TestObjCMethodDecl: 'int' +// CHECK-NEXT: ImplicitParamDecl{{.*}} self +// CHECK-NEXT: ImplicitParamDecl{{.*}} _cmd +// CHECK-NEXT: ParmVarDecl{{.*}} i 'int' +// CHECK-NEXT: ... +// CHECK-NEXT: CompoundStmt +@end + +@protocol TestObjCProtocolDecl +- (void) foo; +@end +// CHECK: ObjCProtocolDecl{{.*}} TestObjCProtocolDecl +// CHECK-NEXT: ObjCMethodDecl{{.*}} foo + +@interface TestObjCClass : A <P> +- (void) foo; +@end +// CHECK: ObjCInterfaceDecl{{.*}} TestObjCClass +// CHECK-NEXT: super ObjCInterface{{.*}} 'A' +// CHECK-NEXT: ObjCImplementation{{.*}} 'TestObjCClass' +// CHECK-NEXT: ObjCProtocol{{.*}} 'P' +// CHECK-NEXT: ObjCMethodDecl{{.*}} foo + +@implementation TestObjCClass : A { + int i; +} +- (void) foo { +} +@end +// CHECK: ObjCImplementationDecl{{.*}} TestObjCClass +// CHECK-NEXT: super ObjCInterface{{.*}} 'A' +// CHECK-NEXT: ObjCInterface{{.*}} 'TestObjCClass' +// CHECK-NEXT: ObjCIvarDecl{{.*}} i +// CHECK-NEXT: ObjCMethodDecl{{.*}} foo + +@interface TestObjCClass (TestObjCCategoryDecl) <P> +- (void) bar; +@end +// CHECK: ObjCCategoryDecl{{.*}} TestObjCCategoryDecl +// CHECK-NEXT: ObjCInterface{{.*}} 'TestObjCClass' +// CHECK-NEXT: ObjCCategoryImpl{{.*}} 'TestObjCClass' +// CHECK-NEXT: ObjCProtocol{{.*}} 'P' +// CHECK-NEXT: ObjCMethodDecl{{.*}} bar + +@implementation TestObjCClass (TestObjCCategoryDecl) +- (void) bar { +} +@end +// CHECK: ObjCCategoryImplDecl{{.*}} TestObjCClass +// CHECK-NEXT: ObjCInterface{{.*}} 'TestObjCClass' +// CHECK-NEXT: ObjCCategory{{.*}} 'TestObjCCategoryDecl' +// CHECK-NEXT: ObjCMethodDecl{{.*}} bar + +@compatibility_alias TestObjCCompatibleAliasDecl A; +// CHECK: ObjCCompatibleAliasDecl{{.*}} TestObjCCompatibleAliasDecl +// CHECK-NEXT: ObjCInterface{{.*}} 'A' + +@interface TestObjCProperty: A +@property(getter=getterFoo, setter=setterFoo:) int foo; +@property int bar; +@end +// CHECK: ObjCInterfaceDecl{{.*}} TestObjCProperty +// CHECK: ObjCPropertyDecl{{.*}} foo 'int' assign readwrite atomic unsafe_unretained +// CHECK-NEXT: getter ObjCMethod{{.*}} 'getterFoo' +// CHECK-NEXT: setter ObjCMethod{{.*}} 'setterFoo:' +// CHECK-NEXT: ObjCPropertyDecl{{.*}} bar 'int' assign readwrite atomic unsafe_unretained +// CHECK-NEXT: ObjCMethodDecl{{.*}} getterFoo +// CHECK-NEXT: ObjCMethodDecl{{.*}} setterFoo: +// CHECK-NEXT: ParmVarDecl{{.*}} foo +// CHECK-NEXT: ObjCMethodDecl{{.*}} bar +// CHECK-NEXT: ObjCMethodDecl{{.*}} setBar: +// CHECK-NEXT: ParmVarDecl{{.*}} bar + +@implementation TestObjCProperty { + int i; +} +@synthesize foo=i; +@synthesize bar; +@end +// CHECK: ObjCImplementationDecl{{.*}} TestObjCProperty +// CHECK: ObjCPropertyImplDecl{{.*}} foo synthesize +// CHECK-NEXT: ObjCProperty{{.*}} 'foo' +// CHECK-NEXT: ObjCIvar{{.*}} 'i' 'int' +// CHECK-NEXT: ObjCIvarDecl{{.*}} bar 'int' synthesize private +// CHECK-NEXT: ObjCPropertyImplDecl{{.*}} bar synthesize +// CHECK-NEXT: ObjCProperty{{.*}} 'bar' +// CHECK-NEXT: ObjCIvar{{.*}} 'bar' 'int' + +void TestBlockDecl(int x) { + ^(int y, ...){ x; }; +} +// CHECK: FunctionDecl{{.*}}TestBlockDecl +// CHECK: BlockDecl +// CHECK-NEXT: ParmVarDecl{{.*}} y 'int' +// CHECK-NEXT: ... +// CHECK-NEXT: capture ParmVar{{.*}} 'x' 'int' +// CHECK-NEXT: CompoundStmt diff --git a/test/Misc/ast-dump-decl.mm b/test/Misc/ast-dump-decl.mm new file mode 100644 index 0000000..06ab515 --- /dev/null +++ b/test/Misc/ast-dump-decl.mm @@ -0,0 +1,23 @@ +// RUN: %clang_cc1 -Wno-unused -fblocks -ast-dump -ast-dump-filter Test %s | FileCheck -strict-whitespace %s + +@interface A +@end + +@interface TestObjCImplementation : A +@end + +@implementation TestObjCImplementation : A { + struct X { + int i; + } X; +} +- (void) foo { +} +@end +// CHECK: ObjCImplementationDecl{{.*}} TestObjCImplementation +// CHECK-NEXT: super ObjCInterface{{.*}} 'A' +// CHECK-NEXT: ObjCInterface{{.*}} 'TestObjCImplementation' +// CHECK-NEXT: CXXCtorInitializer{{.*}} 'X' +// CHECK-NEXT: CXXConstructExpr +// CHECK-NEXT: ObjCIvarDecl{{.*}} X +// CHECK-NEXT: ObjCMethodDecl{{.*}} foo diff --git a/test/Misc/ast-dump-stmt.c b/test/Misc/ast-dump-stmt.c index d7fdce8..1f21cf0 100644 --- a/test/Misc/ast-dump-stmt.c +++ b/test/Misc/ast-dump-stmt.c @@ -1,31 +1,31 @@ // RUN: %clang_cc1 -ast-dump -ast-dump-filter Test %s | FileCheck -strict-whitespace %s int TestLocation = 0; -// CHECK: Dumping TestLocation -// CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} <{{.*}}:3:20> 'int' 0 +// CHECK: VarDecl{{.*}}TestLocation +// CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} <col:20> 'int' 0 int TestIndent = 1 + (1); -// CHECK: Dumping TestIndent -// CHECK-NEXT: {{\(BinaryOperator[^()]*$}} -// CHECK-NEXT: {{^ \(IntegerLiteral.*0[^()]*\)$}} -// CHECK-NEXT: {{^ \(ParenExpr.*0[^()]*$}} -// CHECK-NEXT: {{^ \(IntegerLiteral.*0[^()]*\)\)\)$}} +// CHECK: VarDecl{{.*}}TestIndent +// CHECK-NEXT: {{^}}`-BinaryOperator{{[^()]*$}} +// CHECK-NEXT: {{^}} |-IntegerLiteral{{.*0[^()]*$}} +// CHECK-NEXT: {{^}} `-ParenExpr{{.*0[^()]*$}} +// CHECK-NEXT: {{^}} `-IntegerLiteral{{.*0[^()]*$}} void TestDeclStmt() { int x = 0; int y, z; } -// CHECK: Dumping TestDeclStmt +// CHECK: FunctionDecl{{.*}}TestDeclStmt // CHECK-NEXT: CompoundStmt // CHECK-NEXT: DeclStmt -// CHECK-NEXT: int x = +// CHECK-NEXT: VarDecl{{.*}}x // CHECK-NEXT: IntegerLiteral // CHECK-NEXT: DeclStmt -// CHECK-NEXT: int y -// CHECK-NEXT: int z +// CHECK-NEXT: VarDecl{{.*}}y +// CHECK-NEXT: VarDecl{{.*}}z int TestOpaqueValueExpr = 0 ?: 1; -// CHECK: Dumping TestOpaqueValueExpr +// CHECK: VarDecl{{.*}}TestOpaqueValueExpr // CHECK-NEXT: BinaryConditionalOperator // CHECK-NEXT: IntegerLiteral // CHECK-NEXT: OpaqueValueExpr diff --git a/test/Misc/ast-dump-stmt.cpp b/test/Misc/ast-dump-stmt.cpp new file mode 100644 index 0000000..cf3e8bf --- /dev/null +++ b/test/Misc/ast-dump-stmt.cpp @@ -0,0 +1,14 @@ +// RUN: %clang_cc1 -ast-dump -ast-dump-filter Test %s | FileCheck -strict-whitespace %s + +namespace n { +void function() {} +int Variable; +} +using n::function; +using n::Variable; +void TestFunction() { + void (*f)() = &function; +// CHECK: DeclRefExpr{{.*}} (UsingShadow{{.*}}function + Variable = 4; +// CHECK: DeclRefExpr{{.*}} (UsingShadow{{.*}}Variable +} diff --git a/test/Misc/ast-dump-stmt.m b/test/Misc/ast-dump-stmt.m index 8dfee74..8c0ca89 100644 --- a/test/Misc/ast-dump-stmt.m +++ b/test/Misc/ast-dump-stmt.m @@ -3,15 +3,14 @@ void TestBlockExpr(int x) { ^{ x; }; } -// CHECK: Dumping TestBlockExpr -// CHECK: BlockExpr{{.*}} decl= -// CHECK-NEXT: capture ParmVar -// CHECK-NEXT: CompoundStmt +// CHECK: FunctionDecl{{.*}}TestBlockExpr +// CHECK: BlockExpr{{.*}} 'void (^)(void)' +// CHECK-NEXT: BlockDecl void TestExprWithCleanup(int x) { ^{ x; }; } -// CHECK: Dumping TestExprWithCleanup +// CHECK: FunctionDecl{{.*}}TestExprWithCleanup // CHECK: ExprWithCleanups // CHECK-NEXT: cleanup Block // CHECK-NEXT: BlockExpr @@ -26,10 +25,11 @@ void TestObjCAtCatchStmt() { } @finally { } } -// CHECK: Dumping TestObjCAtCatchStmt +// CHECK: FunctionDecl{{.*}}TestObjCAtCatchStmt // CHECK: ObjCAtTryStmt // CHECK-NEXT: CompoundStmt -// CHECK-NEXT: ObjCAtCatchStmt{{.*}} catch parm = "A *a" +// CHECK-NEXT: ObjCAtCatchStmt{{.*}} +// CHECK-NEXT: VarDecl{{.*}}a // CHECK-NEXT: CompoundStmt // CHECK-NEXT: ObjCAtCatchStmt{{.*}} catch all // CHECK-NEXT: CompoundStmt diff --git a/test/Misc/ast-dump-templates.cpp b/test/Misc/ast-dump-templates.cpp index 7d56e7b..7e28da9 100644 --- a/test/Misc/ast-dump-templates.cpp +++ b/test/Misc/ast-dump-templates.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -ast-dump %s > %t +// RUN: %clang_cc1 -ast-print %s > %t // RUN: FileCheck < %t %s -check-prefix=CHECK1 // RUN: FileCheck < %t %s -check-prefix=CHECK2 @@ -27,8 +27,8 @@ void baz() { // CHECK2: template <int X = 2, typename Y = double, int Z = 3> struct foo { // Template definition - foo -// CHECK1: template <int X, typename Y, int Z = (IntegerLiteral {{.*}} 'int' 5) -// CHECK2: template <int X, typename Y, int Z = (IntegerLiteral {{.*}} 'int' 5) +// CHECK1: template <int X, typename Y, int Z = 5> struct foo { +// CHECK2: template <int X, typename Y, int Z = 5> struct foo { // Template instantiation - bar // CHECK1: template <int A = 5, typename B = int> int bar() diff --git a/test/Misc/ast-dump-wchar.cpp b/test/Misc/ast-dump-wchar.cpp index 87d962f..9768bc8 100644 --- a/test/Misc/ast-dump-wchar.cpp +++ b/test/Misc/ast-dump-wchar.cpp @@ -1,13 +1,13 @@ // RUN: %clang_cc1 -std=c++11 -ast-dump %s -triple x86_64-linux-gnu | FileCheck %s char c8[] = u8"test\0\\\"\t\a\b\234"; -// CHECK: char c8[12] = (StringLiteral {{.*}} lvalue u8"test\000\\\"\t\a\b\234") +// CHECK: StringLiteral {{.*}} lvalue u8"test\000\\\"\t\a\b\234" char16_t c16[] = u"test\0\\\"\t\a\b\234\u1234"; -// CHECK: char16_t c16[13] = (StringLiteral {{.*}} lvalue u"test\000\\\"\t\a\b\234\u1234") +// CHECK: StringLiteral {{.*}} lvalue u"test\000\\\"\t\a\b\234\u1234" char32_t c32[] = U"test\0\\\"\t\a\b\234\u1234\U0010ffff"; // \ -// CHECK: char32_t c32[14] = (StringLiteral {{.*}} lvalue U"test\000\\\"\t\a\b\234\u1234\U0010FFFF") +// CHECK: StringLiteral {{.*}} lvalue U"test\000\\\"\t\a\b\234\u1234\U0010FFFF" wchar_t wc[] = L"test\0\\\"\t\a\b\234\u1234\xffffffff"; // \ -// CHECK: wchar_t wc[14] = (StringLiteral {{.*}} lvalue L"test\000\\\"\t\a\b\234\x1234\xFFFFFFFF") +// CHECK: StringLiteral {{.*}} lvalue L"test\000\\\"\t\a\b\234\x1234\xFFFFFFFF" diff --git a/test/Misc/caret-diags-macros.c b/test/Misc/caret-diags-macros.c index 5faddb6..316454c 100644 --- a/test/Misc/caret-diags-macros.c +++ b/test/Misc/caret-diags-macros.c @@ -10,15 +10,15 @@ void foo() { // CHECK: {{.*}}:3:{{[0-9]+}}: note: expanded from macro 'M1' } -#define A 1 -#define B A -#define C B +#define A(x) x +#define B(x) A(x) +#define C(x) B(x) void bar() { - C; - // CHECK: {{.*}}:17:3: warning: expression result unused - // CHECK: {{.*}}:15:11: note: expanded from macro 'C' - // CHECK: {{.*}}:14:11: note: expanded from macro 'B' - // CHECK: {{.*}}:13:11: note: expanded from macro 'A' + C(1); + // CHECK: {{.*}}:17:5: warning: expression result unused + // CHECK: {{.*}}:15:16: note: expanded from macro 'C' + // CHECK: {{.*}}:14:16: note: expanded from macro 'B' + // CHECK: {{.*}}:13:14: note: expanded from macro 'A' } // rdar://7597492 @@ -113,21 +113,29 @@ void test3() { // CHECK: {{.*}}:102:41: note: expanded from macro 'variadic_pasting_args1' variadic_pasting_args3a(1, 2, 3, 4); - // CHECK: {{.*}}:115:30: warning: expression result unused - // CHECK: {{.*}}:106:71: note: expanded from macro 'variadic_pasting_args3a' - // CHECK: {{.*}}:104:70: note: expanded from macro 'variadic_pasting_args2a' - // CHECK: {{.*}}:102:41: note: expanded from macro 'variadic_pasting_args1' + // CHECK: {{.*}}:115:3: warning: expression result unused + // CHECK-NEXT: variadic_pasting_args3a(1, 2, 3, 4); + // CHECK-NEXT: {{ \^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}} + // CHECK: {{.*}}:106:44: note: expanded from macro 'variadic_pasting_args3a' + // CHECK-NEXT: #define variadic_pasting_args3a(x, y, ...) variadic_pasting_args2a(x, y, __VA_ARGS__) + // CHECK-NEXT: {{ \^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}} + // CHECK: {{.*}}:104:70: note: expanded from macro 'variadic_pasting_args2a' + // CHECK-NEXT: #define variadic_pasting_args2a(x, y, ...) variadic_pasting_args1(x, y ## __VA_ARGS__) + // CHECK-NEXT: {{ \^~~~~~~~~~~~~~~~}} + // CHECK: {{.*}}:102:41: note: expanded from macro 'variadic_pasting_args1' + // CHECK-NEXT: #define variadic_pasting_args1(x, y, z) y + // CHECK-NEXT: {{ \^}} } #define BAD_CONDITIONAL_OPERATOR (2<3)?2:3 int test4 = BAD_CONDITIONAL_OPERATOR+BAD_CONDITIONAL_OPERATOR; -// CHECK: {{.*}}:122:39: note: expanded from macro 'BAD_CONDITIONAL_OPERATOR' +// CHECK: {{.*}}:130:39: note: expanded from macro 'BAD_CONDITIONAL_OPERATOR' // CHECK-NEXT: #define BAD_CONDITIONAL_OPERATOR (2<3)?2:3 // CHECK-NEXT: {{^ \^}} -// CHECK: {{.*}}:122:39: note: expanded from macro 'BAD_CONDITIONAL_OPERATOR' +// CHECK: {{.*}}:130:39: note: expanded from macro 'BAD_CONDITIONAL_OPERATOR' // CHECK-NEXT: #define BAD_CONDITIONAL_OPERATOR (2<3)?2:3 // CHECK-NEXT: {{^ \^}} -// CHECK: {{.*}}:122:39: note: expanded from macro 'BAD_CONDITIONAL_OPERATOR' +// CHECK: {{.*}}:130:39: note: expanded from macro 'BAD_CONDITIONAL_OPERATOR' // CHECK-NEXT: #define BAD_CONDITIONAL_OPERATOR (2<3)?2:3 // CHECK-NEXT: {{^ ~~~~~\^~~~}} @@ -135,31 +143,85 @@ int test4 = BAD_CONDITIONAL_OPERATOR+BAD_CONDITIONAL_OPERATOR; #define TWOL (2< #define X 1+TWOL 3) QMARK 4:5 int x = X; -// CHECK: {{.*}}:137:9: note: place parentheses around the '+' expression to silence this warning +// CHECK: {{.*}}:145:9: note: place parentheses around the '+' expression to silence this warning // CHECK-NEXT: int x = X; // CHECK-NEXT: {{^ \^}} -// CHECK-NEXT: {{.*}}:136:21: note: expanded from macro 'X' +// CHECK-NEXT: {{.*}}:144:21: note: expanded from macro 'X' // CHECK-NEXT: #define X 1+TWOL 3) QMARK 4:5 // CHECK-NEXT: {{^ ~~~~~~~~~ \^}} -// CHECK-NEXT: {{.*}}:134:15: note: expanded from macro 'QMARK' +// CHECK-NEXT: {{.*}}:142:15: note: expanded from macro 'QMARK' // CHECK-NEXT: #define QMARK ? // CHECK-NEXT: {{^ \^}} -// CHECK-NEXT: {{.*}}:137:9: note: place parentheses around the '?:' expression to evaluate it first +// CHECK-NEXT: {{.*}}:145:9: note: place parentheses around the '?:' expression to evaluate it first // CHECK-NEXT: int x = X; // CHECK-NEXT: {{^ \^}} -// CHECK-NEXT: {{.*}}:136:21: note: expanded from macro 'X' +// CHECK-NEXT: {{.*}}:144:21: note: expanded from macro 'X' // CHECK-NEXT: #define X 1+TWOL 3) QMARK 4:5 // CHECK-NEXT: {{^ ~~~~~~~~\^~~~~~~~~}} #define ONEPLUS 1+ #define Y ONEPLUS (2<3) QMARK 4:5 int y = Y; -// CHECK: {{.*}}:156:9: warning: operator '?:' has lower precedence than '+'; '+' will be evaluated first +// CHECK: {{.*}}:164:9: warning: operator '?:' has lower precedence than '+'; '+' will be evaluated first // CHECK-NEXT: int y = Y; // CHECK-NEXT: {{^ \^}} -// CHECK-NEXT: {{.*}}:155:25: note: expanded from macro 'Y' +// CHECK-NEXT: {{.*}}:163:25: note: expanded from macro 'Y' // CHECK-NEXT: #define Y ONEPLUS (2<3) QMARK 4:5 // CHECK-NEXT: {{^ ~~~~~~~~~~~~~ \^}} -// CHECK-NEXT: {{.*}}:134:15: note: expanded from macro 'QMARK' +// CHECK-NEXT: {{.*}}:142:15: note: expanded from macro 'QMARK' // CHECK-NEXT: #define QMARK ? // CHECK-NEXT: {{^ \^}} + +// PR14399 +void iequals(int,int,int); +void foo_aa(char* s) +{ +#define /* */ BARC(c, /* */b, a) (a + b ? c : c) + iequals(__LINE__, BARC(123, (456 < 345), 789), 8); +} +// CHECK: {{.*}}:180:21: warning: operator '?:' has lower precedence than '+' +// CHECK-NEXT: iequals(__LINE__, BARC(123, (456 < 345), 789), 8); +// CHECK-NEXT: {{^ \^~~~~~~~~~~~~~~~~~~~~~~~~~~}} +// CHECK-NEXT: {{.*}}:179:41: note: expanded from macro 'BARC' +// CHECK-NEXT: #define /* */ BARC(c, /* */b, a) (a + b ? c : c) +// CHECK-NEXT: {{^ ~~~~~ \^}} + +#define APPEND2(NUM, SUFF) -1 != NUM ## SUFF +#define APPEND(NUM, SUFF) APPEND2(NUM, SUFF) +#define UTARG_MAX_U APPEND (MAX_UINT, UL) +#define MAX_UINT 18446744073709551615 +#if UTARG_MAX_U +#endif + +// CHECK: {{.*}}:193:5: warning: left side of operator converted from negative value to unsigned: -1 to 18446744073709551615 +// CHECK-NEXT: #if UTARG_MAX_U +// CHECK-NEXT: {{^ \^~~~~~~~~~~}} +// CHECK-NEXT: {{.*}}:191:21: note: expanded from macro 'UTARG_MAX_U' +// CHECK-NEXT: #define UTARG_MAX_U APPEND (MAX_UINT, UL) +// CHECK-NEXT: {{^ \^~~~~~~~~~~~~~~~~~~~~}} +// CHECK-NEXT: {{.*}}:190:27: note: expanded from macro 'APPEND' +// CHECK-NEXT: #define APPEND(NUM, SUFF) APPEND2(NUM, SUFF) +// CHECK-NEXT: {{^ \^~~~~~~~~~~~~~~~~~}} +// CHECK-NEXT: {{.*}}:189:31: note: expanded from macro 'APPEND2' +// CHECK-NEXT: #define APPEND2(NUM, SUFF) -1 != NUM ## SUFF +// CHECK-NEXT: {{^ ~~ \^ ~~~~~~~~~~~}} + +unsigned long strlen_test(const char *s); +#define __darwin_obsz(object) __builtin_object_size (object, 1) +#define sprintf2(str, ...) \ + __builtin___sprintf_chk (str, 0, __darwin_obsz(str), __VA_ARGS__) +#define Cstrlen(a) strlen_test(a) +#define Csprintf sprintf2 +void f(char* pMsgBuf, char* pKeepBuf) { +Csprintf(pMsgBuf,"\nEnter minimum anagram length (2-%1d): ", Cstrlen(pKeepBuf)); +} +// CHECK: {{.*}}:216:62: warning: format specifies type 'int' but the argument has type 'unsigned long' +// CHECK-NEXT: Csprintf(pMsgBuf,"\nEnter minimum anagram length (2-%1d): ", Cstrlen(pKeepBuf)); +// CHECK-NEXT: {{^ ~~~ \^}} +// CHECK-NEXT: {{^ %1lu}} +// CHECK-NEXT: {{.*}}:213:21: note: expanded from macro 'Cstrlen' +// CHECK-NEXT: #define Cstrlen(a) strlen_test(a) +// CHECK-NEXT: {{^ \^}} +// CHECK-NEXT: {{.*}}:212:56: note: expanded from macro 'sprintf2' +// CHECK-NEXT: __builtin___sprintf_chk (str, 0, __darwin_obsz(str), __VA_ARGS__) +// CHECK-NEXT: {{^ \^}} diff --git a/test/Misc/dev-fd-fs.c b/test/Misc/dev-fd-fs.c new file mode 100644 index 0000000..2bc4f29 --- /dev/null +++ b/test/Misc/dev-fd-fs.c @@ -0,0 +1,32 @@ +// Check that we can operate on files from /dev/fd. +// REQUIRES: dev-fd-fs + +// It has not been working since r169831 on freebsd. +// XFAIL: freebsd + +// Check reading from named pipes. We cat the input here instead of redirecting +// it to ensure that /dev/fd/0 is a named pipe, not just a redirected file. +// +// RUN: cat %s | %clang -x c /dev/fd/0 -E > %t +// RUN: FileCheck --check-prefix DEV-FD-INPUT < %t %s +// +// DEV-FD-INPUT: int x; + + +// Check writing to /dev/fd named pipes. We use cat here as before to ensure we +// get a named pipe. +// +// RUN: %clang -x c %s -E -o /dev/fd/1 | cat > %t +// RUN: FileCheck --check-prefix DEV-FD-FIFO-OUTPUT < %t %s +// +// DEV-FD-FIFO-OUTPUT: int x; + + +// Check writing to /dev/fd regular files. +// +// RUN: %clang -x c %s -E -o /dev/fd/1 > %t +// RUN: FileCheck --check-prefix DEV-FD-REG-OUTPUT < %t %s +// +// DEV-FD-REG-OUTPUT: int x; + +int x; diff --git a/test/Misc/diag-line-wrapping.cpp b/test/Misc/diag-line-wrapping.cpp index 830aa13..ea119af 100644 --- a/test/Misc/diag-line-wrapping.cpp +++ b/test/Misc/diag-line-wrapping.cpp @@ -1,4 +1,5 @@ // RUN: %clang_cc1 -fsyntax-only -fmessage-length 60 %s 2>&1 | FileCheck %s +// RUN: %clang_cc1 -fsyntax-only -fmessage-length 0 %s 2>&1 | FileCheck %s struct B { void f(); }; struct D1 : B {}; @@ -10,4 +11,13 @@ struct DD : D1, D2 { // CHECK: {{.*}}: error: // CHECK: struct DD -> struct D1 -> struct B // CHECK: struct DD -> struct D2 -> struct B -} +}; + +// A line longer than 4096 characters should cause us to suppress snippets no +// matter what -fmessage-length is set to. +#pragma clang diagnostic push +#pragma clang diagnostic warning "-Wconversion" +// CHECK: implicit conversion loses floating-point precision +// CHECK-NOT: static const float numbers[] +static const float numbers[] = {0.1764705882352941,0.1176470588235294,0.1176470588235294,0.1176470588235294,0.1176470588235294,0.3529411764705883,0.2352941176470588,0.1176470588235294,0.1176470588235294,0.1176470588235294,0.1176470588235294,0.4117647058823529,0.1176470588235294,0.1176470588235294,0.1176470588235294,0.1176470588235294,0.1764705882352941,0.3529411764705883,0.1764705882352941,0.1176470588235294,0.1176470588235294,0.1176470588235294,0.1764705882352941,0.4117647058823529,0.2352941176470588,0.1176470588235294,0.1176470588235294,0.1176470588235294,0.1764705882352941,0.4705882352941176,0.1176470588235294,0.1176470588235294,0.1176470588235294,0.1176470588235294,0.2352941176470588,0.4117647058823529,0.1764705882352941,0.1176470588235294,0.1176470588235294,0.1176470588235294,0.2352941176470588,0.4705882352941176,0.2352941176470588,0.1176470588235294,0.1176470588235294,0.1176470588235294,0.2352941176470588,0.5294117647058824,0.1176470588235294,0.1176470588235294,0.1176470588235294,0.1176470588235294,0.2941176470588235,0.4705882352941176,0.1764705882352941,0.1176470588235294,0.1176470588235294,0.1176470588235294,0.2941176470588235,0.5294117647058824,0.1176470588235294,0.1176470588235294,0.1176470588235294,0.1176470588235294,0.3529411764705883,0.5294117647058824,0.4117647058823529,0.1176470588235294,0.1176470588235294,0.1764705882352941,0.1764705882352941,0.1176470588235294,0.1176470588235294,0.1176470588235294,0.1176470588235294,0.1764705882352941,0.1764705882352941,0.3529411764705883,0.1764705882352941,0.1176470588235294,0.1176470588235294,0.1764705882352941,0.1764705882352941,0.4117647058823529,0.4117647058823529,0.1176470588235294,0.1176470588235294,0.1764705882352941,0.2352941176470588,0.1764705882352941,0.1176470588235294,0.1176470588235294,0.1176470588235294,0.1764705882352941,0.2352941176470588,0.4117647058823529,0.1764705882352941,0.1176470588235294,0.1176470588235294,0.1764705882352941,0.2352941176470588,0.4705882352941176,0.4117647058823529,0.1176470588235294,0.1176470588235294,0.1764705882352941,0.2941176470588235,0.2352941176470588,0.1176470588235294,0.1176470588235294,0.1176470588235294,0.1764705882352941,0.2941176470588235,0.4705882352941176,0.1764705882352941,0.1176470588235294,0.1176470588235294,0.1764705882352941,0.2941176470588235,0.5294117647058824,0.4117647058823529,0.1176470588235294,0.1176470588235294,0.1764705882352941,0.3529411764705883,0.2941176470588235,0.1176470588235294,0.1176470588235294,0.1176470588235294,0.1764705882352941,0.3529411764705883,0.5294117647058824,0.3529411764705883,0.1176470588235294,0.1176470588235294,0.2352941176470588,0.2352941176470588,0.1176470588235294,0.4117647058823529,0.1176470588235294,0.1176470588235294,0.2352941176470588,0.2352941176470588,0.1764705882352941,0.1176470588235294,0.1176470588235294,0.1176470588235294,0.2352941176470588,0.2352941176470588,0.4117647058823529,0.3529411764705883,0.1176470588235294,0.1176470588235294,0.2352941176470588,0.2941176470588235,0.1764705882352941,0.4117647058823529,0.1176470588235294,0.1176470588235294,0.2352941176470588,0.2941176470588235,0.2352941176470588,0.1176470588235294,0.1176470588235294,0.1176470588235294,0.2352941176470588,0.2941176470588235,0.4705882352941176,0.3529411764705883,0.1176470588235294,0.1176470588235294,0.2352941176470588,0.3529411764705883,0.2352941176470588,0.1176470588235294,0.1176470588235294,0.1176470588235294,0.2352941176470588,0.3529411764705883,0.5294117647058824,0.3529411764705883,0.1176470588235294,0.1176470588235294,0.2352941176470588,0.4117647058823529,0.2941176470588235,0.2941176470588235,0.1176470588235294,0.1176470588235294,0.2941176470588235,0.2941176470588235,0.1176470588235294,0.3529411764705883,0.1176470588235294,0.1176470588235294,0.2941176470588235,0.2941176470588235,0.1764705882352941,0.2941176470588235,0.1176470588235294,0.1176470588235294,0.2941176470588235,0.3529411764705883,0.1764705882352941,0.3529411764705883,0.1176470588235294,0.1176470588235294,0.2941176470588235,0.3529411764705883,0.2352941176470588,0.2941176470588235,0.1176470588235294,0.1176470588235294,0.2941176470588235,0.4117647058823529,0.2352941176470588,0.2941176470588235,0.1176470588235294,0.1176470588235294,0.2941176470588235,0.4705882352941176,0.2941176470588235,0.2352941176470588,0.1176470588235294,0.1176470588235294,0.3529411764705883,0.3529411764705883,0.1176470588235294,0.2941176470588235,0.1176470588235294,0.1176470588235294,0.3529411764705883,0.3529411764705883,0.1764705882352941,0.2352941176470588,0.1176470588235294,0.1176470588235294,0.3529411764705883,0.4117647058823529,0.1764705882352941,0.2941176470588235,0.1176470588235294,0.1176470588235294,0.3529411764705883,0.4117647058823529,0.2352941176470588,0.2352941176470588,0.1176470588235294,0.1176470588235294,0.3529411764705883,0.4705882352941176,0.2352941176470588,0.2352941176470588,0.1176470588235294,0.1176470588235294,0.3529411764705883,0.5294117647058824,0.2941176470588235,0.1764705882352941,0.1176470588235294,0.1176470588235294,0.4117647058823529}; +#pragma clang diagnostic pop diff --git a/test/Misc/diag-macro-backtrace.c b/test/Misc/diag-macro-backtrace.c index ea40cbe..0d28d7b 100644 --- a/test/Misc/diag-macro-backtrace.c +++ b/test/Misc/diag-macro-backtrace.c @@ -12,7 +12,7 @@ #define DROOL WAZ #define FOOL DROOL -FOOL +FOOL; // CHECK: :15:1: error: expected identifier or '(' // CHECK: FOOL @@ -50,4 +50,17 @@ FOOL // CHECK: :3:13: note: expanded from macro 'FOO' // CHECK: #define FOO 1+"hi" // CHECK: ^ -// CHECK: 1 error generated. + +#define ADD(a, b) a ## #b +ADD(L, foo) +// CHECK: error: expected identifier or '(' +// CHECK: ADD(L, foo) +// CHECK: {{^\^}} +// CHECK: note: expanded from macro 'ADD' +// CHECK: #define ADD(a, b) a ## #b +// CHECK: {{^ \^}} +// CHECK: note: expanded from here +// CHECK: L"foo" +// CHECK: {{^\^}} + +// CHECK: 2 errors generated. diff --git a/test/Misc/diag-presumed.c b/test/Misc/diag-presumed.c new file mode 100644 index 0000000..07b7cdf --- /dev/null +++ b/test/Misc/diag-presumed.c @@ -0,0 +1,36 @@ +// RUN: %clang_cc1 -fsyntax-only -pedantic-errors %s 2>&1 | FileCheck %s --check-prefix=PRESUMED +// RUN: %clang_cc1 -fsyntax-only -pedantic-errors -fno-diagnostics-use-presumed-location %s 2>&1 | FileCheck %s --check-prefix=SPELLING + +#line 100 +#define X(y) y +X(int n = error); + +// PRESUMED: diag-presumed.c:101:11: error: use of undeclared identifier 'error' +// PRESUMED: diag-presumed.c:100:14: note: expanded from +// SPELLING: diag-presumed.c:6:11: error: use of undeclared identifier 'error' +// SPELLING: diag-presumed.c:5:14: note: expanded from + +; +// PRESUMED: diag-presumed.c:108:1: error: extra ';' outside of a functio +// SPELLING: diag-presumed.c:13:1: error: extra ';' outside of a functio + +# 1 "thing1.cc" 1 +# 1 "thing1.h" 1 +# 1 "systemheader.h" 1 3 +; +// No diagnostic here: we're in a system header, even if we're using spelling +// locations for the diagnostics.. +// PRESUMED-NOT: extra ';' +// SPELLING-NOT: extra ';' + +another error; +// PRESUMED: included from {{.*}}diag-presumed.c:112: +// PRESUMED: from thing1.cc:1: +// PRESUMED: from thing1.h:1: +// PRESUMED: systemheader.h:7:1: error: unknown type name 'another' + +// SPELLING-NOT: included from +// SPELLING: diag-presumed.c:26:1: error: unknown type name 'another' + +# 1 "thing1.h" 2 +# 1 "thing1.cc" 2 diff --git a/test/Misc/diag-template-diffing-color.cpp b/test/Misc/diag-template-diffing-color.cpp index cfa1a68..c771857 100644 --- a/test/Misc/diag-template-diffing-color.cpp +++ b/test/Misc/diag-template-diffing-color.cpp @@ -6,17 +6,17 @@ void func(foo<int>); int main() { func(foo<double>()); } -// CHECK: {{.*}}candidate function not viable: no known conversion from 'foo<{{.}}[0;1;36mdouble{{.}}[0m>' to 'foo<{{.}}[0;1;36mint{{.}}[0m>' for 1st argument{{.}}[0m +// CHECK: {{.*}}candidate function not viable: no known conversion from 'foo<[[CYAN:.\[0;1;36m]]double[[RESET:.\[0m]]>' to 'foo<[[CYAN]]int[[RESET]]>' for 1st argument[[RESET]] // TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument // TREE: foo< -// TREE: [{{.}}[0;1;36mdouble{{.}}[0m != {{.}}[0;1;36mint{{.}}[0m]>{{.}}[0m +// TREE: {{\[}}[[CYAN:.\[0;1;36m]]double[[RESET:.\[0m]] != [[CYAN]]int[[RESET]]]>[[RESET]] foo<int> A; foo<double> &B = A; -// CHECK: {{.*}}non-const lvalue reference to type 'foo<{{.}}[0;1;36mdouble{{.}}[0m{{.}}[1m>' cannot bind to a value of unrelated type 'foo<{{.}}[0;1;36mint{{.}}[0m{{.}}[1m>'{{.}}[0m +// CHECK: {{.*}}non-const lvalue reference to type 'foo<[[CYAN]]double[[RESET]][[BOLD:.\[1m]]>' cannot bind to a value of unrelated type 'foo<[[CYAN]]int[[RESET]][[BOLD]]>'[[RESET]] // TREE: non-const lvalue reference cannot bind to a value of unrelated type // TREE: foo< -// TREE: [{{.}}[0;1;36mdouble{{.}}[0m{{.}}[1m != {{.}}[0;1;36mint{{.}}[0m{{.}}[1m]>{{.}}[0m +// TREE: {{\[}}[[CYAN]]double[[RESET]][[BOLD:.\[1m]] != [[CYAN]]int[[RESET]][[BOLD]]]>[[RESET]] template<typename> class vector {}; @@ -24,49 +24,63 @@ void set15(vector<const vector<int> >) {} void test15() { set15(vector<const vector<const int> >()); } -// CHECK: {{.*}}candidate function not viable: no known conversion from 'vector<const vector<{{.}}[0;1;36mconst{{ ?.}}[0m{{ ?}}int>>' to 'vector<const vector<int>>' for 1st argument +// CHECK: {{.*}}candidate function not viable: no known conversion from 'vector<const vector<[[CYAN]]const{{ ?}}[[RESET]]{{ ?}}int>>' to 'vector<const vector<int>>' for 1st argument // TREE: {{.*}}candidate function not viable: no known conversion from argument type to parameter type for 1st argument // TREE: vector< // TREE: const vector< -// TREE: [{{.}}[0;1;36mconst{{ ?.}}[0m{{ ?}}!= {{.}}[0;1;36m(no qualifiers){{.}}[0m] int>> +// TREE: {{\[}}[[CYAN]]const{{ ?}}[[RESET]]{{ ?}}!= [[CYAN]](no qualifiers)[[RESET]]] int>> void set16(vector<vector<int> >) {} void test16() { set16(vector<const vector<int> >()); } -// CHECK: {{.*}}candidate function not viable: no known conversion from 'vector<{{.}}[0;1;36mconst{{ ?.}}[0m{{ ?}}vector<[...]>>' to 'vector<vector<[...]>>' for 1st argument +// CHECK: {{.*}}candidate function not viable: no known conversion from 'vector<[[CYAN]]const{{ ?}}[[RESET]]{{ ?}}vector<[...]>>' to 'vector<vector<[...]>>' for 1st argument // TREE: {{.*}}candidate function not viable: no known conversion from argument type to parameter type for 1st argument // TREE: vector< -// TREE: [{{.}}[0;1;36mconst{{ ?.}}[0m{{ ?}}!= {{.}}[0;1;36m(no qualifiers){{ ?.}}[0m]{{ ?}}vector< +// TREE: {{\[}}[[CYAN]]const{{ ?}}[[RESET]]{{ ?}}!= [[CYAN]](no qualifiers){{ ?}}[[RESET]]]{{ ?}}vector< // TREE: [...]>> void set17(vector<const vector<int> >) {} void test17() { set17(vector<vector<int> >()); } -// CHECK: candidate function not viable: no known conversion from 'vector<vector<[...]>>' to 'vector<{{.}}[0;1;36mconst{{ ?.}}[0m{{ ?}}vector<[...]>>' for 1st argument +// CHECK: candidate function not viable: no known conversion from 'vector<vector<[...]>>' to 'vector<[[CYAN]]const{{ ?}}[[RESET]]{{ ?}}vector<[...]>>' for 1st argument // TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument // TREE: vector< -// TREE: [{{.}}[0;1;36m(no qualifiers){{ ?.}}[0m{{ ?}}!= {{.}}[0;1;36mconst{{.}}[0m] vector< +// TREE: {{\[}}[[CYAN]](no qualifiers){{ ?}}[[RESET]]{{ ?}}!= [[CYAN]]const[[RESET]]] vector< // TREE: [...]>> void set18(vector<volatile vector<int> >) {} void test18() { set18(vector<const vector<int> >()); } -// CHECK: candidate function not viable: no known conversion from 'vector<{{.}}[0;1;36mconst{{ ?.}}[0m{{ ?}}vector<[...]>>' to 'vector<{{.}}[0;1;36mvolatile{{ ?.}}[0m{{ ?}}vector<[...]>>' for 1st argument +// CHECK: candidate function not viable: no known conversion from 'vector<[[CYAN]]const{{ ?}}[[RESET]]{{ ?}}vector<[...]>>' to 'vector<[[CYAN]]volatile{{ ?}}[[RESET]]{{ ?}}vector<[...]>>' for 1st argument // TREE: no matching function for call to 'set18' // TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument // TREE: vector< -// TREE: [{{.}}[0;1;36mconst{{ ?.}}[0m{{ ?}}!= {{.}}[0;1;36mvolatile{{.}}[0m] vector< +// TREE: {{\[}}[[CYAN]]const{{ ?}}[[RESET]]{{ ?}}!= [[CYAN]]volatile[[RESET]]] vector< // TREE: [...]>> void set19(vector<const volatile vector<int> >) {} void test19() { set19(vector<const vector<int> >()); } -// CHECK: candidate function not viable: no known conversion from 'vector<const vector<[...]>>' to 'vector<const {{.}}[0;1;36mvolatile{{ ?.}}[0m{{ ?}}vector<[...]>>' for 1st argument +// CHECK: candidate function not viable: no known conversion from 'vector<const vector<[...]>>' to 'vector<const [[CYAN]]volatile{{ ?}}[[RESET]]{{ ?}}vector<[...]>>' for 1st argument // TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument // TREE: vector< -// TREE: [const != const {{.}}[0;1;36mvolatile{{.}}[0m] vector< +// TREE: [const != const [[CYAN]]volatile[[RESET]]] vector< // TREE: [...]>> + +namespace default_args { + template <int x, int y = 1+1, int z = 2> + class A {}; + + void foo(A<0> &M) { + // CHECK: no viable conversion from 'A<[...], (default) [[CYAN]]1 + 1[[RESET]][[BOLD]] aka [[CYAN]]2[[RESET]][[BOLD]], (default) [[CYAN]]2[[RESET]][[BOLD]]>' to 'A<[...], [[CYAN]]0[[RESET]][[BOLD]], [[CYAN]]0[[RESET]][[BOLD]]>' + A<0, 0, 0> N = M; + + // CHECK: no viable conversion from 'A<[2 * ...], (default) [[CYAN]]2[[RESET]][[BOLD]]>' to 'A<[2 * ...], [[CYAN]]0[[RESET]][[BOLD]]>' + A<0, 2, 0> N2 = M; + } + +} diff --git a/test/Misc/diag-template-diffing-cxx98.cpp b/test/Misc/diag-template-diffing-cxx98.cpp new file mode 100644 index 0000000..a21e4cf --- /dev/null +++ b/test/Misc/diag-template-diffing-cxx98.cpp @@ -0,0 +1,49 @@ +// RUN: %clang_cc1 -fsyntax-only %s -std=c++98 2>&1 | FileCheck %s + +namespace PR14342 { + template<typename T, char a> struct X {}; + X<int, 1> x = X<long, 257>(); + // CHECK: error: no viable conversion from 'X<long, [...]>' to 'X<int, [...]>' +} + +namespace PR15513 { + template <int x, int y = x+1> + class A {}; + + void foo(A<0> &M) { + // CHECK: no viable conversion from 'A<[...], (default) x + 1 aka 1>' to 'A<[...], 0>' + A<0, 0> N = M; + // CHECK: no viable conversion from 'A<0, [...]>' to 'A<1, [...]>' + A<1, 1> O = M; + } +} + +namespace default_args { + template <int x, int y = 1+1, int z = 2> + class A {}; + + void foo(A<0> &M) { + // CHECK: no viable conversion from 'A<[...], (default) 1 + 1 aka 2, (default) 2>' to 'A<[...], 0, 0>' + A<0, 0, 0> N = M; + + // CHECK: no viable conversion from 'A<[2 * ...], (default) 2>' to 'A<[2 * ...], 0>' + A<0, 2, 0> N2 = M; + } + +} + +namespace qualifiers { + template <class T> + void foo(void (func(T*)), T*) {} + + template <class T> + class vector{}; + + void bar(const vector<int>*) {} + + void test(volatile vector<int>* V) { + foo(bar, V); + } + + // CHECK: candidate template ignored: deduced conflicting types for parameter 'T' ('const vector<[...]>' vs. 'volatile vector<[...]>') +} diff --git a/test/Misc/diag-template-diffing.cpp b/test/Misc/diag-template-diffing.cpp index 2c044f8..add96ef 100644 --- a/test/Misc/diag-template-diffing.cpp +++ b/test/Misc/diag-template-diffing.cpp @@ -645,41 +645,41 @@ void Play1() { } // CHECK-ELIDE-NOTREE: no viable overloaded '=' -// CHECK-ELIDE-NOTREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from 'Foo1<1>' to 'Foo1<2>' for 1st argument +// CHECK-ELIDE-NOTREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from 'Foo1<1>' to 'const Foo1<2>' for 1st argument // CHECK-ELIDE-NOTREE: candidate function (the implicit move assignment operator) not viable: no known conversion from 'Foo1<1>' to 'Foo1<2>' for 1st argument // CHECK-ELIDE-NOTREE: no viable overloaded '=' -// CHECK-ELIDE-NOTREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from 'Foo1<2>' to 'Foo1<1>' for 1st argument +// CHECK-ELIDE-NOTREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from 'Foo1<2>' to 'const Foo1<1>' for 1st argument // CHECK-ELIDE-NOTREE: candidate function (the implicit move assignment operator) not viable: no known conversion from 'Foo1<2>' to 'Foo1<1>' for 1st argument // CHECK-NOELIDE-NOTREE: no viable overloaded '=' -// CHECK-NOELIDE-NOTREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from 'Foo1<1>' to 'Foo1<2>' for 1st argument +// CHECK-NOELIDE-NOTREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from 'Foo1<1>' to 'const Foo1<2>' for 1st argument // CHECK-NOELIDE-NOTREE: candidate function (the implicit move assignment operator) not viable: no known conversion from 'Foo1<1>' to 'Foo1<2>' for 1st argument // CHECK-NOELIDE-NOTREE: no viable overloaded '=' -// CHECK-NOELIDE-NOTREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from 'Foo1<2>' to 'Foo1<1>' for 1st argument +// CHECK-NOELIDE-NOTREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from 'Foo1<2>' to 'const Foo1<1>' for 1st argument // CHECK-NOELIDE-NOTREE: candidate function (the implicit move assignment operator) not viable: no known conversion from 'Foo1<2>' to 'Foo1<1>' for 1st argument // CHECK-ELIDE-TREE: no viable overloaded '=' // CHECK-ELIDE-TREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from argument type to parameter type for 1st argument -// CHECK-ELIDE-TREE: Foo1< +// CHECK-ELIDE-TREE: [(no qualifiers) != const] Foo1< // CHECK-ELIDE-TREE: [1 != 2]> // CHECK-ELIDE-TREE: candidate function (the implicit move assignment operator) not viable: no known conversion from argument type to parameter type for 1st argument // CHECK-ELIDE-TREE: Foo1< // CHECK-ELIDE-TREE: [1 != 2]> // CHECK-ELIDE-TREE: no viable overloaded '=' // CHECK-ELIDE-TREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from argument type to parameter type for 1st argument -// CHECK-ELIDE-TREE: Foo1< +// CHECK-ELIDE-TREE: [(no qualifiers) != const] Foo1< // CHECK-ELIDE-TREE: [2 != 1]> // CHECK-ELIDE-TREE: candidate function (the implicit move assignment operator) not viable: no known conversion from argument type to parameter type for 1st argument // CHECK-ELIDE-TREE: Foo1< // CHECK-ELIDE-TREE: [2 != 1]> // CHECK-NOELIDE-TREE: no viable overloaded '=' // CHECK-NOELIDE-TREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from argument type to parameter type for 1st argument -// CHECK-NOELIDE-TREE: Foo1< +// CHECK-NOELIDE-TREE: [(no qualifiers) != const] Foo1< // CHECK-NOELIDE-TREE: [1 != 2]> // CHECK-NOELIDE-TREE: candidate function (the implicit move assignment operator) not viable: no known conversion from argument type to parameter type for 1st argument // CHECK-NOELIDE-TREE: Foo1< // CHECK-NOELIDE-TREE: [1 != 2]> // CHECK-NOELIDE-TREE: no viable overloaded '=' // CHECK-NOELIDE-TREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from argument type to parameter type for 1st argument -// CHECK-NOELIDE-TREE: Foo1< +// CHECK-NOELIDE-TREE: [(no qualifiers) != const] Foo1< // CHECK-NOELIDE-TREE: [2 != 1]> // CHECK-NOELIDE-TREE: candidate function (the implicit move assignment operator) not viable: no known conversion from argument type to parameter type for 1st argument // CHECK-NOELIDE-TREE: Foo1< @@ -694,41 +694,41 @@ void Play2() { F3 = F2; } // CHECK-ELIDE-NOTREE: no viable overloaded '=' -// CHECK-ELIDE-NOTREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from 'Foo2<1>' to 'Foo2<2>' for 1st argument +// CHECK-ELIDE-NOTREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from 'Foo2<1>' to 'const Foo2<2>' for 1st argument // CHECK-ELIDE-NOTREE: candidate function (the implicit move assignment operator) not viable: no known conversion from 'Foo2<1>' to 'Foo2<2>' for 1st argument // CHECK-ELIDE-NOTREE: no viable overloaded '=' -// CHECK-ELIDE-NOTREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from 'Foo2<(default) 2>' to 'Foo2<1>' for 1st argument +// CHECK-ELIDE-NOTREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from 'Foo2<(default) 2>' to 'const Foo2<1>' for 1st argument // CHECK-ELIDE-NOTREE: candidate function (the implicit move assignment operator) not viable: no known conversion from 'Foo2<(default) 2>' to 'Foo2<1>' for 1st argument // CHECK-NOELIDE-NOTREE: no viable overloaded '=' -// CHECK-NOELIDE-NOTREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from 'Foo2<1>' to 'Foo2<2>' for 1st argument +// CHECK-NOELIDE-NOTREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from 'Foo2<1>' to 'const Foo2<2>' for 1st argument // CHECK-NOELIDE-NOTREE: candidate function (the implicit move assignment operator) not viable: no known conversion from 'Foo2<1>' to 'Foo2<2>' for 1st argument // CHECK-NOELIDE-NOTREE: no viable overloaded '=' -// CHECK-NOELIDE-NOTREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from 'Foo2<(default) 2>' to 'Foo2<1>' for 1st argument +// CHECK-NOELIDE-NOTREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from 'Foo2<(default) 2>' to 'const Foo2<1>' for 1st argument // CHECK-NOELIDE-NOTREE: candidate function (the implicit move assignment operator) not viable: no known conversion from 'Foo2<(default) 2>' to 'Foo2<1>' for 1st argument // CHECK-ELIDE-TREE: no viable overloaded '=' // CHECK-ELIDE-TREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from argument type to parameter type for 1st argument -// CHECK-ELIDE-TREE: Foo2< +// CHECK-ELIDE-TREE: [(no qualifiers) != const] Foo2< // CHECK-ELIDE-TREE: [1 != 2]> // CHECK-ELIDE-TREE: candidate function (the implicit move assignment operator) not viable: no known conversion from argument type to parameter type for 1st argument // CHECK-ELIDE-TREE: Foo2< // CHECK-ELIDE-TREE: [1 != 2]> // CHECK-ELIDE-TREE: no viable overloaded '=' // CHECK-ELIDE-TREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from argument type to parameter type for 1st argument -// CHECK-ELIDE-TREE: Foo2< +// CHECK-ELIDE-TREE: [(no qualifiers) != const] Foo2< // CHECK-ELIDE-TREE: [(default) 2 != 1]> // CHECK-ELIDE-TREE: candidate function (the implicit move assignment operator) not viable: no known conversion from argument type to parameter type for 1st argument // CHECK-ELIDE-TREE: Foo2< // CHECK-ELIDE-TREE: [(default) 2 != 1]> // CHECK-NOELIDE-TREE: no viable overloaded '=' // CHECK-NOELIDE-TREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from argument type to parameter type for 1st argument -// CHECK-NOELIDE-TREE: Foo2< +// CHECK-NOELIDE-TREE: [(no qualifiers) != const] Foo2< // CHECK-NOELIDE-TREE: [1 != 2]> // CHECK-NOELIDE-TREE: candidate function (the implicit move assignment operator) not viable: no known conversion from argument type to parameter type for 1st argument // CHECK-NOELIDE-TREE: Foo2< // CHECK-NOELIDE-TREE: [1 != 2]> // CHECK-NOELIDE-TREE: no viable overloaded '=' // CHECK-NOELIDE-TREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from argument type to parameter type for 1st argument -// CHECK-NOELIDE-TREE: Foo2< +// CHECK-NOELIDE-TREE: [(no qualifiers) != const] Foo2< // CHECK-NOELIDE-TREE: [(default) 2 != 1]> // CHECK-NOELIDE-TREE: candidate function (the implicit move assignment operator) not viable: no known conversion from argument type to parameter type for 1st argument // CHECK-NOELIDE-TREE: Foo2< @@ -743,20 +743,20 @@ void Play3() { F3 = F2; } // CHECK-ELIDE-NOTREE: no viable overloaded '=' -// CHECK-ELIDE-NOTREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from 'Foo3<1, (no argument)>' to 'Foo3<2, 1>' for 1st argument +// CHECK-ELIDE-NOTREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from 'Foo3<1, (no argument)>' to 'const Foo3<2, 1>' for 1st argument // CHECK-ELIDE-NOTREE: candidate function (the implicit move assignment operator) not viable: no known conversion from 'Foo3<1, (no argument)>' to 'Foo3<2, 1>' for 1st argument // CHECK-ELIDE-NOTREE: no viable overloaded '=' -// CHECK-ELIDE-NOTREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from 'Foo3<2, 1>' to 'Foo3<1, (no argument)>' for 1st argument +// CHECK-ELIDE-NOTREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from 'Foo3<2, 1>' to 'const Foo3<1, (no argument)>' for 1st argument // CHECK-ELIDE-NOTREE: candidate function (the implicit move assignment operator) not viable: no known conversion from 'Foo3<2, 1>' to 'Foo3<1, (no argument)>' for 1st argument // CHECK-NOELIDE-NOTREE: no viable overloaded '=' -// CHECK-NOELIDE-NOTREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from 'Foo3<1, (no argument)>' to 'Foo3<2, 1>' for 1st argument +// CHECK-NOELIDE-NOTREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from 'Foo3<1, (no argument)>' to 'const Foo3<2, 1>' for 1st argument // CHECK-NOELIDE-NOTREE: candidate function (the implicit move assignment operator) not viable: no known conversion from 'Foo3<1, (no argument)>' to 'Foo3<2, 1>' for 1st argument // CHECK-NOELIDE-NOTREE: no viable overloaded '=' -// CHECK-NOELIDE-NOTREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from 'Foo3<2, 1>' to 'Foo3<1, (no argument)>' for 1st argument +// CHECK-NOELIDE-NOTREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from 'Foo3<2, 1>' to 'const Foo3<1, (no argument)>' for 1st argument // CHECK-NOELIDE-NOTREE: candidate function (the implicit move assignment operator) not viable: no known conversion from 'Foo3<2, 1>' to 'Foo3<1, (no argument)>' for 1st argument // CHECK-ELIDE-TREE: no viable overloaded '=' // CHECK-ELIDE-TREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from argument type to parameter type for 1st argument -// CHECK-ELIDE-TREE: Foo3< +// CHECK-ELIDE-TREE: [(no qualifiers) != const] Foo3< // CHECK-ELIDE-TREE: [1 != 2], // CHECK-ELIDE-TREE: [(no argument) != 1]> // CHECK-ELIDE-TREE: candidate function (the implicit move assignment operator) not viable: no known conversion from argument type to parameter type for 1st argument @@ -765,7 +765,7 @@ void Play3() { // CHECK-ELIDE-TREE: [(no argument) != 1]> // CHECK-ELIDE-TREE: no viable overloaded '=' // CHECK-ELIDE-TREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from argument type to parameter type for 1st argument -// CHECK-ELIDE-TREE: Foo3< +// CHECK-ELIDE-TREE: [(no qualifiers) != const] Foo3< // CHECK-ELIDE-TREE: [2 != 1], // CHECK-ELIDE-TREE: [1 != (no argument)]> // CHECK-ELIDE-TREE: candidate function (the implicit move assignment operator) not viable: no known conversion from argument type to parameter type for 1st argument @@ -774,7 +774,7 @@ void Play3() { // CHECK-ELIDE-TREE: [1 != (no argument)]> // CHECK-NOELIDE-TREE: no viable overloaded '=' // CHECK-NOELIDE-TREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from argument type to parameter type for 1st argument -// CHECK-NOELIDE-TREE: Foo3< +// CHECK-NOELIDE-TREE: [(no qualifiers) != const] Foo3< // CHECK-NOELIDE-TREE: [1 != 2], // CHECK-NOELIDE-TREE: [(no argument) != 1]> // CHECK-NOELIDE-TREE: candidate function (the implicit move assignment operator) not viable: no known conversion from argument type to parameter type for 1st argument @@ -783,7 +783,7 @@ void Play3() { // CHECK-NOELIDE-TREE: [(no argument) != 1]> // CHECK-NOELIDE-TREE: no viable overloaded '=' // CHECK-NOELIDE-TREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from argument type to parameter type for 1st argument -// CHECK-NOELIDE-TREE: Foo3< +// CHECK-NOELIDE-TREE: [(no qualifiers) != const] Foo3< // CHECK-NOELIDE-TREE: [2 != 1], // CHECK-NOELIDE-TREE: [1 != (no argument)]> // CHECK-NOELIDE-TREE: candidate function (the implicit move assignment operator) not viable: no known conversion from argument type to parameter type for 1st argument @@ -792,8 +792,218 @@ void Play3() { // CHECK-NOELIDE-TREE: [1 != (no argument)]> } +namespace PR14342 { + template<typename T, short a> struct X {}; + X<int, (signed char)-1> x = X<long, -1>(); + X<int, 3UL> y = X<int, 2>(); + // CHECK-ELIDE-NOTREE: error: no viable conversion from 'X<long, [...]>' to 'X<int, [...]>' + // CHECK-ELIDE-NOTREE: error: no viable conversion from 'X<[...], 2>' to 'X<[...], 3>' +} + +namespace PR14489 { + // The important thing here is that the diagnostic diffs a template specialization + // with no arguments against itself. (We might need a different test if this + // diagnostic changes). + template<class ...V> + struct VariableList { + void ConnectAllToAll(VariableList<>& params = VariableList<>()) { + } + }; + // CHECK-ELIDE-NOTREE: non-const lvalue reference to type 'VariableList<>' cannot bind to a temporary of type 'VariableList<>' +} + +namespace rdar12456626 { + struct IntWrapper { + typedef int type; + }; + + template<typename T, typename T::type V> + struct X { }; + + struct A { + virtual X<IntWrapper, 1> foo(); + }; + + struct B : A { + // CHECK-ELIDE-NOTREE: virtual function 'foo' has a different return type + virtual X<IntWrapper, 2> foo(); + }; +} + +namespace PR15023 { + // Don't crash when non-QualTypes are passed to a diff modifier. + template <typename... Args> + void func(void (*func)(Args...), Args...) { } + + void bar(int, int &) { + } + + void foo(int x) { + func(bar, 1, x) + } + // CHECK-ELIDE-NOTREE: no matching function for call to 'func' + // CHECK-ELIDE-NOTREE: candidate template ignored: deduced conflicting types for parameter 'Args' (<int, int &> vs. <int, int>) +} + +namespace rdar12931988 { + namespace A { + template<typename T> struct X { }; + } + + namespace B { + template<typename T> struct X { }; + } + + void foo(A::X<int> &ax, B::X<int> bx) { + // CHECK-ELIDE-NOTREE: no viable overloaded '=' + // CHECK-ELIDE-NOTREE: no known conversion from 'B::X<int>' to 'const rdar12931988::A::X<int>' + ax = bx; + } + + template<template<typename> class> class Y {}; + + void bar(Y<A::X> ya, Y<B::X> yb) { + // CHECK-ELIDE-NOTREE: no viable overloaded '=' + // CHECK-ELIDE-NOTREE: no known conversion from 'Y<template rdar12931988::B::X>' to 'Y<template rdar12931988::A::X>' + ya = yb; + } +} + +namespace ValueDecl { + int int1, int2, default_int; + template <const int& T = default_int> + struct S {}; + + typedef S<int1> T1; + typedef S<int2> T2; + typedef S<> TD; + + void test() { + T1 t1; + T2 t2; + TD td; + + t1 = t2; + // CHECK-ELIDE-NOTREE: no viable overloaded '=' + // CHECK-ELIDE-NOTREE: no known conversion from 'S<int2>' to 'S<int1>' + + t2 = t1; + // CHECK-ELIDE-NOTREE: no viable overloaded '=' + // CHECK-ELIDE-NOTREE: no known conversion from 'S<int1>' to 'S<int2>' + + td = t1; + // TODO: Find out why (default) isn't printed on second template. + // CHECK-ELIDE-NOTREE: no viable overloaded '=' + // CHECK-ELIDE-NOTREE: no known conversion from 'S<int1>' to 'S<default_int>' + + t2 = td; + // CHECK-ELIDE-NOTREE: no viable overloaded '=' + // CHECK-ELIDE-NOTREE: no known conversion from 'S<(default) default_int>' to 'S<int2>' + + } +} + +namespace DependentDefault { + template <typename> struct Trait { + enum { V = 40 }; + typedef int Ty; + static int I; + }; + int other; + + template <typename T, int = Trait<T>::V > struct A {}; + template <typename T, typename = Trait<T>::Ty > struct B {}; + template <typename T, int& = Trait<T>::I > struct C {}; + + void test() { + + A<int> a1; + A<char> a2; + A<int, 10> a3; + a1 = a2; + // CHECK-ELIDE-NOTREE: no viable overloaded '=' + // CHECK-ELIDE-NOTREE: no known conversion from 'A<char, [...]>' to 'A<int, [...]>' + a3 = a1; + // CHECK-ELIDE-NOTREE: no viable overloaded '=' + // CHECK-ELIDE-NOTREE: no known conversion from 'A<[...], (default) 40>' to 'A<[...], 10>' + a2 = a3; + // CHECK-ELIDE-NOTREE: no viable overloaded '=' + // CHECK-ELIDE-NOTREE: no known conversion from 'A<int, 10>' to 'A<char, 40>' + + B<int> b1; + B<char> b2; + B<int, char> b3; + b1 = b2; + // CHECK-ELIDE-NOTREE: no viable overloaded '=' + // CHECK-ELIDE-NOTREE: no known conversion from 'B<char, (default) Trait<T>::Ty>' to 'B<int, int>' + b3 = b1; + // CHECK-ELIDE-NOTREE: no viable overloaded '=' + // CHECK-ELIDE-NOTREE: no known conversion from 'B<[...], (default) Trait<T>::Ty>' to 'B<[...], char>' + b2 = b3; + // CHECK-ELIDE-NOTREE: no viable overloaded '=' + // CHECK-ELIDE-NOTREE: no known conversion from 'B<int, char>' to 'B<char, int>' + + C<int> c1; + C<char> c2; + C<int, other> c3; + c1 = c2; + // CHECK-ELIDE-NOTREE: no viable overloaded '=' + // CHECK-ELIDE-NOTREE: no known conversion from 'C<char, (default) I>' to 'C<int, I>' + c3 = c1; + // CHECK-ELIDE-NOTREE: no viable overloaded '=' + // CHECK-ELIDE-NOTREE: no known conversion from 'C<[...], (default) I>' to 'C<[...], other>' + c2 = c3; + // CHECK-ELIDE-NOTREE: no viable overloaded '=' + // CHECK-ELIDE-NOTREE: no known conversion from 'C<int, other>' to 'C<char, I>' + } +} + +namespace VariadicDefault { + int i1, i2, i3; + template <int = 5, int...> struct A {}; + template <int& = i1, int& ...> struct B {}; + template <typename = void, typename...> struct C {}; + + void test() { + A<> a1; + A<5, 6, 7> a2; + A<1, 2> a3; + a2 = a1; + // CHECK-ELIDE-NOTREE: no viable overloaded '=' + // CHECK-ELIDE-NOTREE: no known conversion from 'A<[...], (no argument), (no argument)>' to 'A<[...], 6, 7>' + a3 = a1; + // CHECK-ELIDE-NOTREE: no viable overloaded '=' + // CHECK-ELIDE-NOTREE: no known conversion from 'A<(default) 5, (no argument)>' to 'A<1, 2>' + + B<> b1; + B<i1, i2, i3> b2; + B<i2, i3> b3; + b2 = b1; + // CHECK-ELIDE-NOTREE: no viable overloaded '=' + // CHECK-ELIDE-NOTREE: no known conversion from 'B<[...], (no argument), (no argument)>' to 'B<[...], i2, i3>' + b3 = b1; + // CHECK-ELIDE-NOTREE: no viable overloaded '=' + // CHECK-ELIDE-NOTREE: no known conversion from 'B<(default) i1, (no argument)>' to 'B<i2, i3>' + + B<i1, i2, i3> b4 = b1; + // CHECK-ELIDE-NOTREE: no viable conversion from 'B<[...], (no argument), (no argument)>' to 'B<[...], i2, i3>' + B<i2, i3> b5 = b1; + // CHECK-ELIDE-NOTREE: no viable conversion from 'B<(default) i1, (no argument)>' to 'B<i2, i3>' + + C<> c1; + C<void, void> c2; + C<char, char> c3; + c2 = c1; + // CHECK-ELIDE-NOTREE: no viable overloaded '=' + // CHECK-ELIDE-NOTREE: no known conversion from 'C<[...], (no argument)>' to 'C<[...], void>' + c3 = c1; + // CHECK-ELIDE-NOTREE: no viable overloaded '=' + // CHECK-ELIDE-NOTREE: no known conversion from 'C<(default) void, (no argument)>' to 'C<char, char>' + } +} // CHECK-ELIDE-NOTREE: {{[0-9]*}} errors generated. // CHECK-NOELIDE-NOTREE: {{[0-9]*}} errors generated. // CHECK-ELIDE-TREE: {{[0-9]*}} errors generated. // CHECK-NOELIDE-TREE: {{[0-9]*}} errors generated. + diff --git a/test/Misc/diagnostic-crash.cpp b/test/Misc/diagnostic-crash.cpp new file mode 100644 index 0000000..cbb9ac6 --- /dev/null +++ b/test/Misc/diagnostic-crash.cpp @@ -0,0 +1,39 @@ +// RUN: %clang_cc1 -verify -fsyntax-only %s +// The diagnostics we produce for this code tickled a bug in raw_ostream. +template <typename _Alloc> class allocator; +template <class _CharT> struct char_traits; +template <typename _CharT, typename _Traits = char_traits<_CharT>, + typename _Alloc = allocator<_CharT> > +class basic_string; +typedef basic_string<wchar_t> wstring; +class Closure { +}; +template <class A1> class Callback1 { +}; +template <class A1, class A2> class Callback2 { +}; +template <class R, class A2> class ResultCallback1 { +}; +template <bool del, class R, class T, class P1, class P2, class A1> +class AAAAAAAResultCallback_2_1 : public ResultCallback1<R, A1> { +}; +template <bool del, class T, class P1, class P2, class A1> +class AAAAAAAResultCallback_2_1< del, void, T, P1, P2, A1> : + public Callback1<A1> { + public: + typedef Callback1<A1> base; +}; +template <class T1, class T2, class R, class P1, class P2, class A1> +inline typename AAAAAAAResultCallback_2_1<true, R, T1, P1, P2, A1>::base* +NewCallback(T1* obj, R(T2::* member)(P1, P2, A1), const P1& p1, const P2& p2) {} +namespace util { class Status {}; } +class xxxxxxxxxxxxxxxxx { + void Bar(wstring* s, util::Status* status, + Callback2<util::Status, wstring>* done); + void Foo(); +}; +void xxxxxxxxxxxxxxxxx::Foo() { + wstring* s = __null; + util::Status* status = __null; + Closure* cb = NewCallback(this, &xxxxxxxxxxxxxxxxx::Bar, s, status); // expected-error{{cannot initialize}} +} diff --git a/test/Misc/freebsd-arm-size_t.c b/test/Misc/freebsd-arm-size_t.c new file mode 100644 index 0000000..ba7bfec --- /dev/null +++ b/test/Misc/freebsd-arm-size_t.c @@ -0,0 +1,9 @@ +// RUN: %clang_cc1 -triple arm-unknown-freebsd10.0 -verify %s +// expected-no-diagnostics + +/* Define a size_t as expected for FreeBSD ARM */ +typedef unsigned int size_t; + +/* Declare a builtin function that uses size_t */ +void *malloc(size_t); + diff --git a/test/Misc/integer-literal-printing.cpp b/test/Misc/integer-literal-printing.cpp index 4085d60..74bd8d0 100644 --- a/test/Misc/integer-literal-printing.cpp +++ b/test/Misc/integer-literal-printing.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 %s -fsyntax-only -verify +// RUN: %clang_cc1 %s -fsyntax-only -verify -std=c++11 // PR11179 template <short T> class Type1 {}; @@ -7,7 +7,73 @@ template <short T> void Function1(Type1<T>& x) {} // expected-note{{candidate fu template <unsigned short T> class Type2 {}; template <unsigned short T> void Function2(Type2<T>& x) {} // expected-note{{candidate function [with T = 42] not viable: expects an l-value for 1st argument}} +enum class boolTy : bool { + b = 0, +}; + +template <boolTy T> struct Type3Helper; +template <> struct Type3Helper<boolTy::b> { typedef boolTy Ty; }; +template <boolTy T, typename Type3Helper<T>::Ty U> struct Type3 {}; + +// PR14386 +enum class charTy : char { + c = 0, +}; + +template <charTy T> struct Type4Helper; +template <> struct Type4Helper<charTy::c> { typedef charTy Ty; }; +template <charTy T, typename Type4Helper<T>::Ty U> struct Type4 {}; + +enum class scharTy : signed char { + c = 0, +}; + +template <scharTy T> struct Type5Helper; +template <> struct Type5Helper<scharTy::c> { typedef scharTy Ty; }; +template <scharTy T, typename Type5Helper<T>::Ty U> struct Type5 {}; + +enum class ucharTy : unsigned char { + c = 0, +}; + +template <ucharTy T> struct Type6Helper; +template <> struct Type6Helper<ucharTy::c> { typedef ucharTy Ty; }; +template <ucharTy T, typename Type6Helper<T>::Ty U> struct Type6 {}; + +enum class wcharTy : wchar_t { + c = 0, +}; + +template <wcharTy T> struct Type7Helper; +template <> struct Type7Helper<wcharTy::c> { typedef wcharTy Ty; }; +template <wcharTy T, typename Type7Helper<T>::Ty U> struct Type7 {}; + +enum class char16Ty : char16_t { + c = 0, +}; + +template <char16Ty T> struct Type8Helper; +template <> struct Type8Helper<char16Ty::c> { typedef char16Ty Ty; }; +template <char16Ty T, typename Type8Helper<T>::Ty U> struct Type8 {}; + +enum class char32Ty : char16_t { + c = 0, +}; + +template <char32Ty T> struct Type9Helper; +template <> struct Type9Helper<char32Ty::c> { typedef char32Ty Ty; }; +template <char32Ty T, typename Type9Helper<T>::Ty U> struct Type9 {}; + void Function() { Function1(Type1<-42>()); // expected-error{{no matching function for call to 'Function1'}} Function2(Type2<42>()); // expected-error{{no matching function for call to 'Function2'}} + + struct Type3<boolTy::b, "3"> t3; // expected-error{{value of type 'const char [2]' is not implicitly convertible to 'typename Type3Helper<(boolTy)false>::Ty' (aka 'boolTy')}} + + struct Type4<charTy::c, "4"> t4; // expected-error{{value of type 'const char [2]' is not implicitly convertible to 'typename Type4Helper<(charTy)'\x00'>::Ty' (aka 'charTy')}} + struct Type5<scharTy::c, "5"> t5; // expected-error{{value of type 'const char [2]' is not implicitly convertible to 'typename Type5Helper<(scharTy)'\x00'>::Ty' (aka 'scharTy')}} + struct Type6<ucharTy::c, "6"> t6; // expected-error{{value of type 'const char [2]' is not implicitly convertible to 'typename Type6Helper<(ucharTy)'\x00'>::Ty' (aka 'ucharTy')}} + struct Type7<wcharTy::c, "7"> t7; // expected-error{{value of type 'const char [2]' is not implicitly convertible to 'typename Type7Helper<(wcharTy)L'\x00'>::Ty' (aka 'wcharTy')}} + struct Type8<char16Ty::c, "8"> t8; // expected-error{{value of type 'const char [2]' is not implicitly convertible to 'typename Type8Helper<(char16Ty)u'\x00'>::Ty' (aka 'char16Ty')}} + struct Type9<char32Ty::c, "9"> t9; // expected-error{{value of type 'const char [2]' is not implicitly convertible to 'typename Type9Helper<(char32Ty)u'\x00'>::Ty' (aka 'char32Ty')}} } diff --git a/test/Misc/serialized-diags-frontend.c b/test/Misc/serialized-diags-frontend.c index 453ed14..7eab021 100644 --- a/test/Misc/serialized-diags-frontend.c +++ b/test/Misc/serialized-diags-frontend.c @@ -1,5 +1,5 @@ // RUN: rm -f %t -// RUN: %clang -fsyntax-only %s -Wblahblah --serialize-diagnostics %t > /dev/null 2>&1 || true +// RUN: %clang -fsyntax-only %s -Wblahblah --serialize-diagnostics %t > /dev/null 2>&1 // RUN: c-index-test -read-diagnostics %t 2>&1 | FileCheck %s // This test case tests that we can handle frontend diagnostics. diff --git a/test/Misc/serialized-diags-no-category.c b/test/Misc/serialized-diags-no-category.c index 3074892..1b0f204 100644 --- a/test/Misc/serialized-diags-no-category.c +++ b/test/Misc/serialized-diags-no-category.c @@ -2,7 +2,7 @@ #error bar // RUN: rm -f %t -// RUN: %clang -ferror-limit=1 -fsyntax-only %s --serialize-diagnostics %t > /dev/null 2>&1 || true +// RUN: not %clang -ferror-limit=1 -fsyntax-only %s --serialize-diagnostics %t > /dev/null 2>&1 // RUN: c-index-test -read-diagnostics %t 2>&1 | FileCheck %s // This test case tests that we can handle both fatal errors and errors without categories. diff --git a/test/Misc/serialized-diags.c b/test/Misc/serialized-diags.c index ae4611b..1290b4e 100644 --- a/test/Misc/serialized-diags.c +++ b/test/Misc/serialized-diags.c @@ -31,7 +31,7 @@ void rdar11040133() { } // RUN: rm -f %t -// RUN: %clang -Wall -fsyntax-only %s --serialize-diagnostics %t.diag > /dev/null 2>&1 || true +// RUN: not %clang -Wall -fsyntax-only %s --serialize-diagnostics %t.diag > /dev/null 2>&1 // RUN: c-index-test -read-diagnostics %t.diag > %t 2>&1 // RUN: FileCheck --input-file=%t %s diff --git a/test/Misc/serialized-diags.m b/test/Misc/serialized-diags.m new file mode 100644 index 0000000..aac791e --- /dev/null +++ b/test/Misc/serialized-diags.m @@ -0,0 +1,30 @@ +@interface Foo +- (void) test; +- (void) test2; +@end + +@implementation Foo +- (void) test { + [_self test2]; +} +- (void) test2 {} +@end + +// RUN: rm -f %t +// RUN: not %clang -Wall -fsyntax-only %s --serialize-diagnostics %t.diag > /dev/null 2>&1 +// RUN: c-index-test -read-diagnostics %t.diag > %t 2>&1 +// RUN: FileCheck --input-file=%t %s + +// This test checks that serialized diagnostics handle notes with no source location. + +// CHECK: {{.*[/\\]}}serialized-diags.m:8:4: error: use of undeclared identifier '_self'; did you mean 'self'? [] [Semantic Issue] +// CHECK: Range: {{.*[/\\]}}serialized-diags.m:8:4 {{.*[/\\]}}serialized-diags.m:8:9 +// CHECK: Number FIXITs = 1 +// CHECK: FIXIT: ({{.*[/\\]}}serialized-diags.m:8:4 - {{.*[/\\]}}serialized-diags.m:8:9): "self" +// CHECK: +-(null):0:0: note: 'self' is an implicit parameter [] [] +// CHECK: Number FIXITs = 0 +// CHECK: {{.*[/\\]}}serialized-diags.m:1:12: warning: class 'Foo' defined without specifying a base class [-Wobjc-root-class] [Semantic Issue] +// CHECK: Number FIXITs = 0 +// CHECK: +-{{.*[/\\]}}serialized-diags.m:1:15: note: add a super class to fix this problem [] [Semantic Issue] +// CHECK: Number FIXITs = 0 +// CHECK: Number of diagnostics: 2 diff --git a/test/Misc/warning-flags.c b/test/Misc/warning-flags.c index c3f14bc..a6dc8f1 100644 --- a/test/Misc/warning-flags.c +++ b/test/Misc/warning-flags.c @@ -18,7 +18,7 @@ This test serves two purposes: The list of warnings below should NEVER grow. It should gradually shrink to 0. -CHECK: Warnings without flags (148): +CHECK: Warnings without flags (143): CHECK-NEXT: ext_delete_void_ptr_operand CHECK-NEXT: ext_enum_friend CHECK-NEXT: ext_expected_semi_decl_list @@ -44,7 +44,6 @@ CHECK-NEXT: pp_out_of_date_dependency CHECK-NEXT: pp_poisoning_existing_macro CHECK-NEXT: pp_pragma_once_in_main_file CHECK-NEXT: pp_pragma_sysheader_in_main_file -CHECK-NEXT: pp_undef_builtin_macro CHECK-NEXT: w_asm_qualifier_ignored CHECK-NEXT: warn_accessor_property_type_mismatch CHECK-NEXT: warn_anon_bitfield_width_exceeds_type_size @@ -106,7 +105,6 @@ CHECK-NEXT: warn_not_compound_assign CHECK-NEXT: warn_objc_property_copy_missing_on_block CHECK-NEXT: warn_objc_protocol_qualifier_missing_id CHECK-NEXT: warn_octal_escape_too_large -CHECK-NEXT: warn_odr_tag_type_inconsistent CHECK-NEXT: warn_on_superclass_use CHECK-NEXT: warn_param_default_argument_redefinition CHECK-NEXT: warn_partial_specs_not_deducible @@ -144,14 +142,12 @@ CHECK-NEXT: warn_property_attribute CHECK-NEXT: warn_property_getter_owning_mismatch CHECK-NEXT: warn_property_types_are_incompatible CHECK-NEXT: warn_readonly_property -CHECK-NEXT: warn_redecl_library_builtin CHECK-NEXT: warn_redeclaration_without_attribute_prev_attribute_ignored CHECK-NEXT: warn_register_objc_catch_parm CHECK-NEXT: warn_related_result_type_compatibility_class CHECK-NEXT: warn_related_result_type_compatibility_protocol CHECK-NEXT: warn_second_parameter_of_va_start_not_last_named_argument CHECK-NEXT: warn_second_parameter_to_va_arg_never_compatible -CHECK-NEXT: warn_standalone_specifier CHECK-NEXT: warn_static_inline_explicit_inst_ignored CHECK-NEXT: warn_static_non_static CHECK-NEXT: warn_template_export_unsupported @@ -162,7 +158,6 @@ CHECK-NEXT: warn_unavailable_fwdclass_message CHECK-NEXT: warn_undef_interface CHECK-NEXT: warn_undef_interface_suggest CHECK-NEXT: warn_undef_protocolref -CHECK-NEXT: warn_undefined_internal CHECK-NEXT: warn_unknown_method_family CHECK-NEXT: warn_use_out_of_scope_declaration CHECK-NEXT: warn_weak_identifier_undeclared |