diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2017-12-18 20:11:37 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2017-12-18 20:11:37 +0000 |
commit | 461a67fa15370a9ec88f8f8a240bf7c123bb2029 (patch) | |
tree | 6942083d7d56bba40ec790a453ca58ad3baf6832 /test/Index | |
parent | 75c3240472ba6ac2669ee72ca67eb72d4e2851fc (diff) |
Notes
Diffstat (limited to 'test/Index')
33 files changed, 468 insertions, 30 deletions
diff --git a/test/Index/Core/index-dependent-source.cpp b/test/Index/Core/index-dependent-source.cpp index 59c6286cd3dd9..2e111339af612 100644 --- a/test/Index/Core/index-dependent-source.cpp +++ b/test/Index/Core/index-dependent-source.cpp @@ -158,3 +158,69 @@ void infiniteTraitRecursion(Trait<T> &t) { // Shouldn't crash! t.lookup; } + +template <typename T> +struct UsingA { +// CHECK: [[@LINE+1]]:15 | type-alias/C | Type | c:index-dependent-source.cpp@ST>1#T@UsingA@T@Type | <no-cgname> | Def,RelChild | rel: 1 + typedef int Type; +// CHECK: [[@LINE+1]]:15 | static-method/C++ | func | c:@ST>1#T@UsingA@F@func#S | <no-cgname> | Decl,RelChild | rel: 1 + static void func(); +// CHECK: [[@LINE+1]]:8 | instance-method/C++ | operator() | c:@ST>1#T@UsingA@F@operator()#I# | <no-cgname> | Decl,RelChild | rel: 1 + void operator()(int); +// CHECK: [[@LINE+1]]:8 | instance-method/C++ | operator+ | c:@ST>1#T@UsingA@F@operator+#&1>@ST>1#T@UsingA1t0.0# | <no-cgname> | Decl,RelChild | rel: 1 + void operator+(const UsingA &); +}; + +template <typename T> +struct OtherUsing {}; + +template <typename T> +struct UsingB : public UsingA<T> { +// CHECK: [[@LINE+2]]:40 | type-alias/C | TypeB | c:index-dependent-source.cpp@ST>1#T@UsingB@T@TypeB | <no-cgname> | Def,RelChild | rel: 1 +// CHECK: [[@LINE+1]]:20 | struct(Gen)/C++ | OtherUsing | c:@ST>1#T@OtherUsing | <no-cgname> | Ref,RelCont | rel: 1 + typedef typename OtherUsing<T>::Type TypeB; +// CHECK: [[@LINE+2]]:29 | using/using-typename(Gen)/C++ | Type | c:index-dependent-source.cpp@ST>1#T@UsingB@UUT@UsingA<T>::Type | <no-cgname> | Decl,RelChild | rel: 1 +// CHECK: [[@LINE+1]]:18 | struct(Gen)/C++ | UsingA | c:@ST>1#T@UsingA | <no-cgname> | Ref,RelCont | rel: 1 + using typename UsingA<T>::Type; +// CHECK: [[@LINE+2]]:20 | using/using-value(Gen)/C++ | func | c:index-dependent-source.cpp@ST>1#T@UsingB@UUV@UsingA<T>::func | <no-cgname> | Decl,RelChild | rel: 1 +// CHECK: [[@LINE+1]]:9 | struct(Gen)/C++ | UsingA | c:@ST>1#T@UsingA | <no-cgname> | Ref,RelCont | rel: 1 + using UsingA<T>::func; + +// CHECK: [[@LINE+2]]:20 | using/using-value(Gen)/C++ | operator() | c:index-dependent-source.cpp@ST>1#T@UsingB@UUV@UsingA<T>::operator() | <no-cgname> | Decl,RelChild | rel: 1 +// CHECK: [[@LINE+1]]:9 | struct(Gen)/C++ | UsingA | c:@ST>1#T@UsingA | <no-cgname> | Ref,RelCont | rel: 1 + using UsingA<T>::operator(); +// CHECK: [[@LINE+2]]:20 | using/using-value(Gen)/C++ | operator+ | c:index-dependent-source.cpp@ST>1#T@UsingB@UUV@UsingA<T>::operator+ | <no-cgname> | Decl,RelChild | rel: 1 +// CHECK: [[@LINE+1]]:9 | struct(Gen)/C++ | UsingA | c:@ST>1#T@UsingA | <no-cgname> | Ref,RelCont | rel: 1 + using UsingA<T>::operator+; +}; + +template <typename T> +struct UsingC : public UsingB<T> { + static void test() { +// CHECK: [[@LINE+2]]:25 | type-alias/C | TypeB | c:index-dependent-source.cpp@ST>1#T@UsingB@T@TypeB | <no-cgname> | Ref,RelCont | rel: 1 +// CHECK: [[@LINE+1]]:14 | struct(Gen)/C++ | UsingB | c:@ST>1#T@UsingB | <no-cgname> | Ref,RelCont | rel: 1 + typename UsingB<T>::TypeB value1; +// CHECK: [[@LINE+2]]:25 | using/using-typename(Gen)/C++ | Type | c:index-dependent-source.cpp@ST>1#T@UsingB@UUT@UsingA<T>::Type | <no-cgname> | Ref,RelCont | rel: 1 +// CHECK: [[@LINE+1]]:14 | struct(Gen)/C++ | UsingB | c:@ST>1#T@UsingB | <no-cgname> | Ref,RelCont | rel: 1 + typename UsingB<T>::Type value2; +// CHECK: [[@LINE+2]]:16 | using/using-value(Gen)/C++ | func | c:index-dependent-source.cpp@ST>1#T@UsingB@UUV@UsingA<T>::func | <no-cgname> | Ref,Call,RelCall,RelCont | rel: 1 +// CHECK: [[@LINE+1]]:5 | struct(Gen)/C++ | UsingB | c:@ST>1#T@UsingB | <no-cgname> | Ref,RelCont | rel: 1 + UsingB<T>::func(); + } +}; + +template <typename T> +struct UsingD { +// CHECK: [[@LINE+1]]:8 | instance-method/C++ | foo | c:@ST>1#T@UsingD@F@foo#t0.0# | <no-cgname> | Decl,RelChild | rel: 1 + void foo(T); +}; + +template <typename T, typename U> +struct UsingE : public UsingD<T>, public UsingD<U> { +// CHECK: [[@LINE+2]]:20 | using/using-value(Gen)/C++ | foo | c:index-dependent-source.cpp@ST>2#T#T@UsingE@UUV@UsingD<T>::foo | <no-cgname> | Decl,RelChild | rel: 1 +// CHECK: [[@LINE+1]]:9 | struct(Gen)/C++ | UsingD | c:@ST>1#T@UsingD | <no-cgname> | Ref,RelCont | rel: 1 + using UsingD<T>::foo; +// CHECK: [[@LINE+2]]:20 | using/using-value(Gen)/C++ | foo | c:index-dependent-source.cpp@ST>2#T#T@UsingE@UUV@UsingD<U>::foo | <no-cgname> | Decl,RelChild | rel: 1 +// CHECK: [[@LINE+1]]:9 | struct(Gen)/C++ | UsingD | c:@ST>1#T@UsingD | <no-cgname> | Ref,RelCont | rel: 1 + using UsingD<U>::foo; +}; diff --git a/test/Index/Core/index-source.cpp b/test/Index/Core/index-source.cpp index 4864d6cf0150a..6f485feb47c50 100644 --- a/test/Index/Core/index-source.cpp +++ b/test/Index/Core/index-source.cpp @@ -201,8 +201,8 @@ class PseudoOverridesInSpecializations<double, int> { template<typename U> class InnerClass; -// CHECK: [[@LINE-1]]:9 | class(Gen)/C++ | InnerClass | c:@S@PseudoOverridesInSpecializations>#d#I@ST>1#T@InnerClass | <no-cgname> | Ref,RelCont,RelSpecialization | rel: 2 -// CHECK-NEXT: RelCont +// CHECK: [[@LINE-1]]:9 | class(Gen)/C++ | InnerClass | c:@S@PseudoOverridesInSpecializations>#d#I@ST>1#T@InnerClass | <no-cgname> | Decl,RelChild,RelSpecialization | rel: 2 +// CHECK-NEXT: RelChild // CHECK-NEXT: RelSpecialization | InnerClass | c:@ST>2#T#T@PseudoOverridesInSpecializations@ST>1#T@InnerClass }; @@ -274,7 +274,7 @@ void ContainsSpecializedMemberFunction::memberSpecialization<int>() { template<typename T> class SpecializationDecl; -// CHECK: [[@LINE-1]]:7 | class(Gen)/C++ | SpecializationDecl | c:@ST>1#T@SpecializationDecl | <no-cgname> | Ref | rel: 0 +// CHECK: [[@LINE-1]]:7 | class(Gen)/C++ | SpecializationDecl | c:@ST>1#T@SpecializationDecl | <no-cgname> | Decl | rel: 0 template<typename T> class SpecializationDecl { }; @@ -497,6 +497,19 @@ void localStructuredBindingAndRef() { } +template<typename T> +struct Guided { T t; }; +// CHECK: [[@LINE-1]]:8 | struct(Gen)/C++ | Guided | c:@ST>1#T@Guided | <no-cgname> | Def | rel: 0 +// CHECK-NEXT: [[@LINE-2]]:19 | field/C++ | t | c:@ST>1#T@Guided@FI@t | <no-cgname> | Def,RelChild | rel: 1 +// CHECK-NEXT: RelChild | Guided | c:@ST>1#T@Guided +Guided(double) -> Guided<float>; +// CHECK: [[@LINE-1]]:19 | struct(Gen)/C++ | Guided | c:@ST>1#T@Guided | <no-cgname> | Ref | rel: 0 +// CHECK-NEXT: [[@LINE-2]]:1 | struct(Gen)/C++ | Guided | c:@ST>1#T@Guided | <no-cgname> | Ref | rel: 0 +auto guided = Guided{1.0}; +// CHECK: [[@LINE-1]]:6 | variable/C | guided | c:@guided | _guided | Def | rel: 0 +// CHECK-NEXT: [[@LINE-2]]:15 | struct(Gen)/C++ | Guided | c:@ST>1#T@Guided | <no-cgname> | Ref,RelCont | rel: 1 +// CHECK-NEXT: RelCont | guided | c:@guided + namespace rd33122110 { struct Outer { @@ -512,3 +525,36 @@ struct rd33122110::Outer::Nested<int>; // CHECK-NEXT: RelCont | Nested | c:@N@rd33122110@S@Outer@S@Nested>#I // CHECK: [[@LINE-3]]:20 | struct/C++ | Outer | c:@N@rd33122110@S@Outer | <no-cgname> | Ref,RelCont | rel: 1 // CHECK-NEXT: RelCont | Nested | c:@N@rd33122110@S@Outer@S@Nested>#I + +namespace index_offsetof { + +struct Struct { + int field; +}; + +struct Struct2 { + Struct array[4][2]; +}; + +void foo() { + __builtin_offsetof(Struct, field); +// CHECK: [[@LINE-1]]:30 | field/C | field | c:@N@index_offsetof@S@Struct@FI@field | <no-cgname> | Ref,RelCont | rel: 1 +// CHECK-NEXT: RelCont | foo | c:@N@index_offsetof@F@foo# + __builtin_offsetof(Struct2, array[1][0].field); +// CHECK: [[@LINE-1]]:31 | field/C | array | c:@N@index_offsetof@S@Struct2@FI@array | <no-cgname> | Ref,RelCont | rel: 1 +// CHECK-NEXT: RelCont | foo | c:@N@index_offsetof@F@foo# +// CHECK: [[@LINE-3]]:43 | field/C | field | c:@N@index_offsetof@S@Struct@FI@field | <no-cgname> | Ref,RelCont | rel: 1 +// CHECK-NEXT: RelCont | foo | c:@N@index_offsetof@F@foo# +} + +#define OFFSET_OF_(X, Y) __builtin_offsetof(X, Y) + +class SubclassOffsetof : public Struct { + void foo() { + OFFSET_OF_(SubclassOffsetof, field); +// CHECK: [[@LINE-1]]:34 | field/C | field | c:@N@index_offsetof@S@Struct@FI@field | <no-cgname> | Ref,RelCont | rel: 1 +// CHECK-NEXT: RelCont | foo | c:@N@index_offsetof@S@SubclassOffsetof@F@foo# + } +}; + +} diff --git a/test/Index/Core/index-source.m b/test/Index/Core/index-source.m index 1333cafd75750..2931e664eac6a 100644 --- a/test/Index/Core/index-source.m +++ b/test/Index/Core/index-source.m @@ -389,6 +389,15 @@ struct Separate separateE; @interface ClassReceivers @property(class) int p1; +// CHECK: [[@LINE-1]]:22 | class-method/acc-get/ObjC | p1 | c:objc(cs)ClassReceivers(cm)p1 | +[ClassReceivers p1] | Decl,Dyn,Impl,RelChild,RelAcc | rel: 2 +// CHECK-NEXT: RelChild | ClassReceivers | c:objc(cs)ClassReceivers +// CHECK-NEXT: RelAcc | p1 | c:objc(cs)ClassReceivers(cpy)p1 +// CHECK: [[@LINE-4]]:22 | class-method/acc-set/ObjC | setP1: | c:objc(cs)ClassReceivers(cm)setP1: | +[ClassReceivers setP1:] | Decl,Dyn,Impl,RelChild,RelAcc | rel: 2 +// CHECK-NEXT: RelChild | ClassReceivers | c:objc(cs)ClassReceivers +// CHECK-NEXT: RelAcc | p1 | c:objc(cs)ClassReceivers(cpy)p1 +// CHECK: [[@LINE-7]]:22 | instance-property/ObjC | p1 | c:objc(cs)ClassReceivers(cpy)p1 | <no-cgname> | Decl,RelChild | rel: 1 +// CHECK-NEXT: RelChild | ClassReceivers | c:objc(cs)ClassReceivers + + (int)implicit; + (void)setImplicit:(int)x; @@ -399,13 +408,13 @@ void classReceivers() { // CHECK: [[@LINE-1]]:3 | class/ObjC | ClassReceivers | c:objc(cs)ClassReceivers | _OBJC_CLASS_$_ClassReceivers | Ref,RelCont | rel: 1 // CHECK: [[@LINE-2]]:18 | instance-property/ObjC | p1 | c:objc(cs)ClassReceivers(cpy)p1 | <no-cgname> | Ref,Writ,RelCont | rel: 1 // CHECK-NEXT: RelCont | classReceivers | c:@F@classReceivers -// CHECK: [[@LINE-4]]:18 | class-method/ObjC | setP1: | c:objc(cs)ClassReceivers(cm)setP1: | +[ClassReceivers setP1:] | Ref,Call,Impl,RelCall,RelCont | rel: 1 +// CHECK: [[@LINE-4]]:18 | class-method/acc-set/ObjC | setP1: | c:objc(cs)ClassReceivers(cm)setP1: | +[ClassReceivers setP1:] | Ref,Call,Impl,RelCall,RelCont | rel: 1 // CHECK-NEXT: RelCall,RelCont | classReceivers | c:@F@classReceivers (void)ClassReceivers.p1; // CHECK: [[@LINE-1]]:9 | class/ObjC | ClassReceivers | c:objc(cs)ClassReceivers | _OBJC_CLASS_$_ClassReceivers | Ref,RelCont | rel: 1 // CHECK: [[@LINE-2]]:24 | instance-property/ObjC | p1 | c:objc(cs)ClassReceivers(cpy)p1 | <no-cgname> | Ref,RelCont | rel: 1 // CHECK-NEXT: RelCont | classReceivers | c:@F@classReceivers -// CHECK: [[@LINE-4]]:24 | class-method/ObjC | p1 | c:objc(cs)ClassReceivers(cm)p1 | +[ClassReceivers p1] | Ref,Call,Impl,RelCall,RelCont | rel: 1 +// CHECK: [[@LINE-4]]:24 | class-method/acc-get/ObjC | p1 | c:objc(cs)ClassReceivers(cm)p1 | +[ClassReceivers p1] | Ref,Call,Impl,RelCall,RelCont | rel: 1 // CHECK-NEXT: RelCall,RelCont | classReceivers | c:@F@classReceivers ClassReceivers.implicit = 0; diff --git a/test/Index/Inputs/record-parsing-invocation-remap.c b/test/Index/Inputs/record-parsing-invocation-remap.c new file mode 100644 index 0000000000000..4a32ca66ef085 --- /dev/null +++ b/test/Index/Inputs/record-parsing-invocation-remap.c @@ -0,0 +1,2 @@ + +#pragma clang __debug parser_crash diff --git a/test/Index/USR/array-type.cpp b/test/Index/USR/array-type.cpp new file mode 100644 index 0000000000000..40ff20d388a58 --- /dev/null +++ b/test/Index/USR/array-type.cpp @@ -0,0 +1,11 @@ +// RUN: c-index-test core -print-source-symbols -- %s | FileCheck %s + +// Function template specializations differing in array type parameter should have unique USRs. + +template<class buffer> void foo(buffer); +// CHECK: {{[0-9]+}}:17 | function(Gen,TS)/C++ | foo | c:@F@foo<#{n16C>#*C# +template<> void foo<char[16]>(char[16]); +// CHECK: {{[0-9]+}}:17 | function(Gen,TS)/C++ | foo | c:@F@foo<#{n32C>#*C# +template<> void foo<char[32]>(char[32]); +// CHECK: {{[0-9]+}}:17 | function(Gen,TS)/C++ | foo | c:@F@foo<#{n64C>#*C# +template<> void foo<char[64]>(char[64]); diff --git a/test/Index/USR/func-type.cpp b/test/Index/USR/func-type.cpp new file mode 100644 index 0000000000000..ff1cd37a7fc42 --- /dev/null +++ b/test/Index/USR/func-type.cpp @@ -0,0 +1,18 @@ +// RUN: c-index-test core -print-source-symbols -- %s | FileCheck %s + +// Functions taking function pointer parameters with different signatures should result in unique USRs. + +typedef void (*_VoidToVoidPtr_)(); +typedef void (*_IntToVoidPtr_)( int ); +typedef _VoidToVoidPtr_ (*IntTo_VoidToVoidPtr_Ptr)( int ); +typedef _IntToVoidPtr_ (*VoidTo_IntToVoidPtr_Ptr)(); + +void Func( IntTo_VoidToVoidPtr_Ptr ); +// CHECK: {{[0-9]+}}:6 | function/C | Func | c:@F@Func#*F*Fv()(#I)# | +void Func( VoidTo_IntToVoidPtr_Ptr ); +// CHECK: {{[0-9]+}}:6 | function/C | Func | c:@F@Func#*F*Fv(#I)()# | + +void Func( void (* (*)(int, int))(int, int) ); +// CHECK: {{[0-9]+}}:6 | function/C | Func | c:@F@Func#*F*Fv(#I#I)(#I#I)# | +void Func( void (* (*)(int, int, int))(int) ); +// CHECK: {{[0-9]+}}:6 | function/C | Func | c:@F@Func#*F*Fv(#I)(#I#I#I)# | diff --git a/test/Index/annotate-attribute.cpp b/test/Index/annotate-attribute.cpp index d822210e493e4..bf415fc8fe64d 100644 --- a/test/Index/annotate-attribute.cpp +++ b/test/Index/annotate-attribute.cpp @@ -16,6 +16,12 @@ protected: void methodWithoutAttribute(); }; +template <typename T> +class __attribute__((annotate("works"))) TemplateTest {}; + +template <typename T> +int templateFunction(T value) __attribute__((annotate("works"))); + // CHECK: ClassDecl=Test:3:7 (Definition) Extent=[3:1 - 17:2] // CHECK-NEXT: CXXAccessSpecifier=:4:1 (Definition) Extent=[4:1 - 4:8] // CHECK-NEXT: CXXMethod=aMethod:5:51 Extent=[5:3 - 5:60] @@ -31,3 +37,9 @@ protected: // CHECK-NEXT: CompoundStmt= Extent=[12:23 - 12:25] // CHECK-NEXT: CXXAccessSpecifier=:14:1 (Definition) Extent=[14:1 - 14:11] // CHECK-NEXT: CXXMethod=methodWithoutAttribute:16:8 Extent=[16:3 - 16:32] +// CHECK: ClassTemplate=TemplateTest:20:42 (Definition) Extent=[19:1 - 20:57] +// CHECK-NEXT: TemplateTypeParameter=T:19:20 (Definition) Extent=[19:11 - 19:21] [access=public] +// CHECK-NEXT: attribute(annotate)=works Extent=[20:22 - 20:39] +// CHECK: FunctionTemplate=templateFunction:23:5 Extent=[22:1 - 23:65] +// CHECK-NEXT: TemplateTypeParameter=T:22:20 (Definition) Extent=[22:11 - 22:21] [access=public] +// CHECK-NEXT: attribute(annotate)=works Extent=[23:46 - 23:63] diff --git a/test/Index/code-completion.cpp b/test/Index/code-completion.cpp index f52bb10a35b09..00f158f3d09da 100644 --- a/test/Index/code-completion.cpp +++ b/test/Index/code-completion.cpp @@ -37,6 +37,16 @@ Z::operator int() const { return 0; } +template <typename T> +struct Foo { T member; }; + +template<typename T> using Bar = Foo<T>; + +void test_template_alias() { + // RUN: env CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:47:1 %s | FileCheck -check-prefix=CHECK-TEMPLATE-ALIAS %s + +} + // CHECK-MEMBER: FieldDecl:{ResultType double}{TypedText member} // CHECK-MEMBER: FieldDecl:{ResultType int}{Text X::}{TypedText member} // CHECK-MEMBER: FieldDecl:{ResultType float}{Text Y::}{TypedText member} @@ -88,3 +98,5 @@ Z::operator int() const { // CHECK-EXPR-NEXT: Class name // CHECK-EXPR-NEXT: Nested name specifier // CHECK-EXPR-NEXT: Objective-C interface + +// CHECK-TEMPLATE-ALIAS: AliasTemplateDecl:{TypedText Bar}{LeftAngle <}{Placeholder typename T}{RightAngle >} (50) diff --git a/test/Index/comment-cplus-decls.cpp b/test/Index/comment-cplus-decls.cpp index 6e32c60a22286..c4b08eb779a10 100644 --- a/test/Index/comment-cplus-decls.cpp +++ b/test/Index/comment-cplus-decls.cpp @@ -46,7 +46,7 @@ protected: data* reserved; }; // CHECK: <Declaration>class Test {}</Declaration> -// CHECK: <Declaration>Test() : reserved(new Test::data()) {}</Declaration> +// CHECK: <Declaration>Test()</Declaration> // CHECK: <Declaration>unsigned int getID() const</Declaration> // CHECK: <Declaration>~Test(){{( noexcept)?}}</Declaration> // CHECK: <Declaration>Test::data *reserved</Declaration> diff --git a/test/Index/comment-to-html-xml-conversion-with-original-literals.cpp b/test/Index/comment-to-html-xml-conversion-with-original-literals.cpp new file mode 100644 index 0000000000000..26ca2238834e0 --- /dev/null +++ b/test/Index/comment-to-html-xml-conversion-with-original-literals.cpp @@ -0,0 +1,26 @@ +// RUN: c-index-test -test-load-source all -comments-xml-schema=%S/../../bindings/xml/comment-xml-schema.rng %s -std=c++11 | FileCheck %s + +constexpr int value(float f) { return int(f); } + +enum MyEnum { +hexadecimal = 0x10 //!< a +// CHECK: <Declaration>hexadecimal = 0x10</Declaration> + +, withSuffix = 1u + 010 //!< b +// CHECK: <Declaration>withSuffix = 1u + 010</Declaration> + +#define ARG(x) x +, macroArg = ARG(0x1) //!< c +// CHECK: <Declaration>macroArg = ARG(0x1)</Declaration> + +#define MACROCONCAT(x, y) 22##x##y +, macroConcat = MACROCONCAT(3, 2) //!< d +// CHECK: <Declaration>macroConcat = MACROCONCAT(3, 2)</Declaration> + +#define MACRO(a,n) = 0x##a##n +, weirdMacros MACRO(2,1) //!< e +// CHECK: <Declaration>weirdMacros = 33</Declaration> + +, floatLiteral = value(0.25e3) //!< f +// CHECK: <Declaration>floatLiteral = value(0.25e3)</Declaration> +}; diff --git a/test/Index/complete-access-checks.cpp b/test/Index/complete-access-checks.cpp index c77a5d656a97c..7eec41ec56109 100644 --- a/test/Index/complete-access-checks.cpp +++ b/test/Index/complete-access-checks.cpp @@ -41,12 +41,12 @@ void Y::doSomething() { // CHECK-SUPER-ACCESS: FieldDecl:{ResultType int}{Informative X::}{TypedText member1} (37) // CHECK-SUPER-ACCESS: FieldDecl:{ResultType int}{Informative X::}{TypedText member2} (37) (inaccessible) // CHECK-SUPER-ACCESS: FieldDecl:{ResultType int}{Informative X::}{TypedText member3} (37) (inaccessible) -// CHECK-SUPER-ACCESS: CXXMethod:{ResultType Y &}{TypedText operator=}{LeftParen (}{Placeholder const Y &}{RightParen )} (34) -// CHECK-SUPER-ACCESS: CXXMethod:{ResultType X &}{Text X::}{TypedText operator=}{LeftParen (}{Placeholder const X &}{RightParen )} (36) +// CHECK-SUPER-ACCESS: CXXMethod:{ResultType Y &}{TypedText operator=}{LeftParen (}{Placeholder const Y &}{RightParen )} (79) +// CHECK-SUPER-ACCESS: CXXMethod:{ResultType X &}{Text X::}{TypedText operator=}{LeftParen (}{Placeholder const X &}{RightParen )} (81) // CHECK-SUPER-ACCESS: StructDecl:{TypedText X}{Text ::} (77) // CHECK-SUPER-ACCESS: StructDecl:{TypedText Y}{Text ::} (75) -// CHECK-SUPER-ACCESS: CXXDestructor:{ResultType void}{Informative X::}{TypedText ~X}{LeftParen (}{RightParen )} (36) -// CHECK-SUPER-ACCESS: CXXDestructor:{ResultType void}{TypedText ~Y}{LeftParen (}{RightParen )} (34) +// CHECK-SUPER-ACCESS: CXXDestructor:{ResultType void}{Informative X::}{TypedText ~X}{LeftParen (}{RightParen )} (81) +// CHECK-SUPER-ACCESS: CXXDestructor:{ResultType void}{TypedText ~Y}{LeftParen (}{RightParen )} (79) // CHECK-ACCESS: CXXMethod:{ResultType void}{TypedText func1}{LeftParen (}{RightParen )} (34) // CHECK-ACCESS: CXXMethod:{ResultType void}{TypedText func2}{LeftParen (}{RightParen )} (34) (inaccessible) @@ -54,9 +54,9 @@ void Y::doSomething() { // CHECK-ACCESS: FieldDecl:{ResultType int}{TypedText member1} (35) // CHECK-ACCESS: FieldDecl:{ResultType int}{TypedText member2} (35) (inaccessible) // CHECK-ACCESS: FieldDecl:{ResultType int}{TypedText member3} (35) (inaccessible) -// CHECK-ACCESS: CXXMethod:{ResultType Z &}{TypedText operator=}{LeftParen (}{Placeholder const Z &}{RightParen )} (34) +// CHECK-ACCESS: CXXMethod:{ResultType Z &}{TypedText operator=}{LeftParen (}{Placeholder const Z &}{RightParen )} (79) // CHECK-ACCESS: ClassDecl:{TypedText Z}{Text ::} (75) -// CHECK-ACCESS: CXXDestructor:{ResultType void}{TypedText ~Z}{LeftParen (}{RightParen )} (34) +// CHECK-ACCESS: CXXDestructor:{ResultType void}{TypedText ~Z}{LeftParen (}{RightParen )} (79) class P { protected: @@ -76,14 +76,14 @@ void f(P x, Q y) { } // CHECK-USING-INACCESSIBLE: FieldDecl:{ResultType int}{TypedText member} (35) (inaccessible) -// CHECK-USING-INACCESSIBLE: CXXMethod:{ResultType P &}{TypedText operator=}{LeftParen (}{Placeholder const P &}{RightParen )} (34) +// CHECK-USING-INACCESSIBLE: CXXMethod:{ResultType P &}{TypedText operator=}{LeftParen (}{Placeholder const P &}{RightParen )} (79) // CHECK-USING-INACCESSIBLE: ClassDecl:{TypedText P}{Text ::} (75) -// CHECK-USING-INACCESSIBLE: CXXDestructor:{ResultType void}{TypedText ~P}{LeftParen (}{RightParen )} (34) +// CHECK-USING-INACCESSIBLE: CXXDestructor:{ResultType void}{TypedText ~P}{LeftParen (}{RightParen )} (79) // CHECK-USING-ACCESSIBLE: FieldDecl:{ResultType int}{TypedText member} (35) -// CHECK-USING-ACCESSIBLE: CXXMethod:{ResultType Q &}{TypedText operator=}{LeftParen (}{Placeholder const Q &}{RightParen )} (34) -// CHECK-USING-ACCESSIBLE: CXXMethod:{ResultType P &}{Text P::}{TypedText operator=}{LeftParen (}{Placeholder const P &}{RightParen )} (36) +// CHECK-USING-ACCESSIBLE: CXXMethod:{ResultType Q &}{TypedText operator=}{LeftParen (}{Placeholder const Q &}{RightParen )} (79) +// CHECK-USING-ACCESSIBLE: CXXMethod:{ResultType P &}{Text P::}{TypedText operator=}{LeftParen (}{Placeholder const P &}{RightParen )} (81) // CHECK-USING-ACCESSIBLE: ClassDecl:{TypedText P}{Text ::} (77) // CHECK-USING-ACCESSIBLE: ClassDecl:{TypedText Q}{Text ::} (75) -// CHECK-USING-ACCESSIBLE: CXXDestructor:{ResultType void}{Informative P::}{TypedText ~P}{LeftParen (}{RightParen )} (36) -// CHECK-USING-ACCESSIBLE: CXXDestructor:{ResultType void}{TypedText ~Q}{LeftParen (}{RightParen )} (34) +// CHECK-USING-ACCESSIBLE: CXXDestructor:{ResultType void}{Informative P::}{TypedText ~P}{LeftParen (}{RightParen )} (81) +// CHECK-USING-ACCESSIBLE: CXXDestructor:{ResultType void}{TypedText ~Q}{LeftParen (}{RightParen )} (79) diff --git a/test/Index/complete-call.cpp b/test/Index/complete-call.cpp index 9750bd6f71004..ca116485ac95c 100644 --- a/test/Index/complete-call.cpp +++ b/test/Index/complete-call.cpp @@ -94,6 +94,24 @@ int main() { s.foo_7(42,); } +struct Bar { + static void foo_1(); + void foo_1(float); + static void foo_1(int); +}; + +void test() { + Bar::foo_1(); + Bar b; + b.foo_1(); +} + +struct Bar2 : public Bar { + Bar2() { + Bar::foo_1(); + } +}; + // RUN: c-index-test -code-completion-at=%s:47:9 %s | FileCheck -check-prefix=CHECK-CC1 %s // CHECK-CC1: OverloadCandidate:{ResultType void}{Text foo_1}{LeftParen (}{RightParen )} (1) // CHECK-CC1: Completion contexts: @@ -803,3 +821,46 @@ int main() { // CHECK-CC59-NEXT: Class name // CHECK-CC59-NEXT: Nested name specifier // CHECK-CC59-NEXT: Objective-C interface + +// RUN: c-index-test -code-completion-at=%s:104:14 %s | FileCheck -check-prefix=CHECK-CC60 %s +// CHECK-CC60: OverloadCandidate:{ResultType void}{Text foo_1}{LeftParen (}{RightParen )} (1) +// CHECK-CC60: OverloadCandidate:{ResultType void}{Text foo_1}{LeftParen (}{CurrentParameter float}{RightParen )} (1) +// CHECK-CC60: OverloadCandidate:{ResultType void}{Text foo_1}{LeftParen (}{CurrentParameter int}{RightParen )} (1) +// CHECK-CC60: Completion contexts: +// CHECK-CC60-NEXT: Any type +// CHECK-CC60-NEXT: Any value +// CHECK-CC60-NEXT: Enum tag +// CHECK-CC60-NEXT: Union tag +// CHECK-CC60-NEXT: Struct tag +// CHECK-CC60-NEXT: Class name +// CHECK-CC60-NEXT: Nested name specifier +// CHECK-CC60-NEXT: Objective-C interface + +// RUN: c-index-test -code-completion-at=%s:106:11 %s | FileCheck -check-prefix=CHECK-CC61 %s +// CHECK-CC61: OverloadCandidate:{ResultType void}{Text foo_1}{LeftParen (}{RightParen )} (1) +// CHECK-CC61: OverloadCandidate:{ResultType void}{Text foo_1}{LeftParen (}{CurrentParameter float}{RightParen )} (1) +// CHECK-CC61: OverloadCandidate:{ResultType void}{Text foo_1}{LeftParen (}{CurrentParameter int}{RightParen )} (1) +// CHECK-CC61: Completion contexts: +// CHECK-CC61-NEXT: Any type +// CHECK-CC61-NEXT: Any value +// CHECK-CC61-NEXT: Enum tag +// CHECK-CC61-NEXT: Union tag +// CHECK-CC61-NEXT: Struct tag +// CHECK-CC61-NEXT: Class name +// CHECK-CC61-NEXT: Nested name specifier +// CHECK-CC61-NEXT: Objective-C interface + +// RUN: c-index-test -code-completion-at=%s:111:16 %s | FileCheck -check-prefix=CHECK-CC62 %s +// CHECK-CC62: OverloadCandidate:{ResultType void}{Text foo_1}{LeftParen (}{RightParen )} (1) +// CHECK-CC62: OverloadCandidate:{ResultType void}{Text foo_1}{LeftParen (}{CurrentParameter float}{RightParen )} (1) +// CHECK-CC62: OverloadCandidate:{ResultType void}{Text foo_1}{LeftParen (}{CurrentParameter int}{RightParen )} (1) +// CHECK-CC62: Completion contexts: +// CHECK-CC62-NEXT: Any type +// CHECK-CC62-NEXT: Any value +// CHECK-CC62-NEXT: Enum tag +// CHECK-CC62-NEXT: Union tag +// CHECK-CC62-NEXT: Struct tag +// CHECK-CC62-NEXT: Class name +// CHECK-CC62-NEXT: Nested name specifier +// CHECK-CC62-NEXT: Objective-C interface + diff --git a/test/Index/complete-constructor-params.cpp b/test/Index/complete-constructor-params.cpp index 6685626a58759..949077a2143a9 100644 --- a/test/Index/complete-constructor-params.cpp +++ b/test/Index/complete-constructor-params.cpp @@ -18,6 +18,20 @@ int main() { int(42); } +struct Foo { + Foo() = default; + Foo(const Foo&) = delete; +}; + +struct Bar { + Foo f; +}; + +void function() { + Bar b1; + Bar b2(b1); +} + // RUN: c-index-test -code-completion-at=%s:11:10 %s | FileCheck -check-prefix=CHECK-CC1 %s // CHECK-CC1: OverloadCandidate:{Text S}{LeftParen (}{CurrentParameter const S<int> &}{RightParen )} (1) // CHECK-CC1: OverloadCandidate:{Text S}{LeftParen (}{CurrentParameter int}{Comma , }{Placeholder U}{Comma , }{Placeholder U}{RightParen )} (1) @@ -138,3 +152,6 @@ int main() { // CHECK-CC10-NEXT: Class name // CHECK-CC10-NEXT: Nested name specifier // CHECK-CC10-NEXT: Objective-C interface + +// RUN: c-index-test -code-completion-at=%s:32:12 -std=c++11 %s | FileCheck -check-prefix=CHECK-CC11 %s +// CHECK-CC11-NOT: OverloadCandidate:{Text Bar}{LeftParen (}{CurrentParameter const Bar &}{RightParen )} (1) diff --git a/test/Index/complete-cxx-inline-methods.cpp b/test/Index/complete-cxx-inline-methods.cpp index ee359f75e4455..0f78e8caa748c 100644 --- a/test/Index/complete-cxx-inline-methods.cpp +++ b/test/Index/complete-cxx-inline-methods.cpp @@ -25,11 +25,11 @@ private: // RUN: c-index-test -code-completion-at=%s:4:9 -std=c++98 %s | FileCheck %s // RUN: c-index-test -code-completion-at=%s:13:7 -std=c++98 %s | FileCheck %s -// CHECK: CXXMethod:{ResultType MyCls::Vec &}{TypedText operator=}{LeftParen (}{Placeholder const MyCls::Vec &}{RightParen )} (34) +// CHECK: CXXMethod:{ResultType Vec &}{TypedText operator=}{LeftParen (}{Placeholder const Vec &}{RightParen )} (79) // CHECK-NEXT: StructDecl:{TypedText Vec}{Text ::} (75) // CHECK-NEXT: FieldDecl:{ResultType int}{TypedText x} (35) // CHECK-NEXT: FieldDecl:{ResultType int}{TypedText y} (35) -// CHECK-NEXT: CXXDestructor:{ResultType void}{TypedText ~Vec}{LeftParen (}{RightParen )} (34) +// CHECK-NEXT: CXXDestructor:{ResultType void}{TypedText ~Vec}{LeftParen (}{RightParen )} (79) // CHECK-NEXT: Completion contexts: // CHECK-NEXT: Dot member access // CHECK-NEXT: Container Kind: StructDecl diff --git a/test/Index/complete-interfaces.m b/test/Index/complete-interfaces.m index 2f86c3d8f43cf..3e90407c78d7c 100644 --- a/test/Index/complete-interfaces.m +++ b/test/Index/complete-interfaces.m @@ -45,3 +45,19 @@ // RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:11:12 %s | FileCheck -check-prefix=CHECK-CC2 %s + + +void useClasses() { + int i = 0; + [Int3 message:1]; +} + +// RUN: c-index-test -code-completion-at=%s:51:11 %s | FileCheck -check-prefix=CHECK-USE %s +// RUN: c-index-test -code-completion-at=%s:52:17 %s | FileCheck -check-prefix=CHECK-USE %s +// CHECK-USE: ObjCInterfaceDecl:{TypedText Int2} (50) +// CHECK-USE: ObjCInterfaceDecl:{TypedText Int3} (50) +// CHECK-USE-NOT: Int1 +// CHECK-USE-NOT: Int4 + +// Caching should work too: +// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:51:11 %s | FileCheck -check-prefix=CHECK-USE %s diff --git a/test/Index/complete-method-decls.m b/test/Index/complete-method-decls.m index 8a1714226664a..f561f81496a90 100644 --- a/test/Index/complete-method-decls.m +++ b/test/Index/complete-method-decls.m @@ -236,3 +236,25 @@ typedef A *MyObjectRef; // RUN: c-index-test -code-completion-at=%s:107:2 %s -target x86_64-apple-macosx10.7 | FileCheck -check-prefix=CHECK-NULLABILITY2 %s // CHECK-NULLABILITY2: ObjCInstanceMethodDecl:{LeftParen (}{Text instancetype}{RightParen )}{TypedText getI3} (40) // CHECK-NULLABILITY2: ObjCInstanceMethodDecl:{LeftParen (}{Text I3 *}{RightParen )}{TypedText produceI3}{TypedText :}{LeftParen (}{Text I3 *}{RightParen )}{Text i3} (40) + +@interface CompleteWithoutLeadingPrefix + +- (void)aMethod; ++ (int)aClassMethod:(int)x; +@property int p; + +@end + +@implementation CompleteWithoutLeadingPrefix + + + +@end + +// RUN: c-index-test -code-completion-at=%s:250:1 %s | FileCheck -check-prefix=CHECK-COMP-NO-PREFIX %s +// CHECK-COMP-NO-PREFIX: NotImplemented:{TypedText @end} (40) +// CHECK-COMP-NO-PREFIX: ObjCClassMethodDecl:{Text +}{HorizontalSpace }{LeftParen (}{Text int}{RightParen )}{TypedText aClassMethod}{TypedText :}{LeftParen (}{Text int}{RightParen )}{Text x} (40) +// CHECK-COMP-NO-PREFIX: ObjCInstanceMethodDecl:{Text -}{HorizontalSpace }{LeftParen (}{Text void}{RightParen )}{TypedText aMethod} (40) +// CHECK-COMP-NO-PREFIX: ObjCInterfaceDecl:{TypedText I1} +// CHECK-COMP-NO-PREFIX: ObjCInstanceMethodDecl:{Text -}{HorizontalSpace }{LeftParen (}{Text int}{RightParen )}{TypedText p} (40) +// CHECK-COMP-NO-PREFIX: ObjCInstanceMethodDecl:{Text -}{HorizontalSpace }{LeftParen (}{Text void}{RightParen )}{TypedText setP}{TypedText :}{LeftParen (}{Text int}{RightParen )}{Text p} (40) diff --git a/test/Index/complete-qualified.cpp b/test/Index/complete-qualified.cpp index a17ea25370c7d..11abd53b86c28 100644 --- a/test/Index/complete-qualified.cpp +++ b/test/Index/complete-qualified.cpp @@ -17,4 +17,4 @@ void foo() // CHECK-CC1: FieldDecl:{ResultType C<Foo, class Bar>}{TypedText c} (35) // CHECK-CC1: ClassDecl:{TypedText Foo} (35) // CHECK-CC1: CXXMethod:{ResultType Foo &}{TypedText operator=}{LeftParen (}{Placeholder const Foo &}{RightParen )} -// CHECK-CC1: CXXDestructor:{ResultType void}{TypedText ~Foo}{LeftParen (}{RightParen )} (35) +// CHECK-CC1: CXXDestructor:{ResultType void}{TypedText ~Foo}{LeftParen (}{RightParen )} (80) diff --git a/test/Index/complete-super.cpp b/test/Index/complete-super.cpp index 9ffa7c8a40563..92d3f7f585f3b 100644 --- a/test/Index/complete-super.cpp +++ b/test/Index/complete-super.cpp @@ -40,3 +40,8 @@ void B::bar(float real) { // CHECK-ACCESS-PATTERN: NotImplemented:{TypedText private}{Colon :} (40) // CHECK-ACCESS-PATTERN: NotImplemented:{TypedText protected}{Colon :} (40) // CHECK-ACCESS-PATTERN: NotImplemented:{TypedText public}{Colon :} (40) + +// RUN: env CINDEXTEST_CODE_COMPLETE_PATTERNS=1 c-index-test -code-completion-at=%s:10:12 %s | FileCheck -check-prefix=CHECK-INHERITANCE-PATTERN %s +// CHECK-INHERITANCE-PATTERN: NotImplemented:{TypedText private} (40) +// CHECK-INHERITANCE-PATTERN: NotImplemented:{TypedText protected} (40) +// CHECK-INHERITANCE-PATTERN: NotImplemented:{TypedText public} (40) diff --git a/test/Index/complete-with-annotations.cpp b/test/Index/complete-with-annotations.cpp index afa8d9ed66070..7bad8f1b7cbe0 100644 --- a/test/Index/complete-with-annotations.cpp +++ b/test/Index/complete-with-annotations.cpp @@ -17,7 +17,7 @@ void X::doSomething() { // CHECK: FieldDecl:{ResultType int}{TypedText field} (35) ("three", "two", "one") // CHECK: CXXMethod:{ResultType void}{TypedText func2}{LeftParen (}{RightParen )} (34) ("some annotation") // CHECK: FieldDecl:{ResultType int}{TypedText member2} (35) ("another annotation", "some annotation") -// CHECK: CXXMethod:{ResultType X &}{TypedText operator=}{LeftParen (}{Placeholder const X &}{RightParen )} (34) +// CHECK: CXXMethod:{ResultType X &}{TypedText operator=}{LeftParen (}{Placeholder const X &}{RightParen )} (79) // CHECK: ClassDecl:{TypedText X}{Text ::} (75) -// CHECK: CXXDestructor:{ResultType void}{TypedText ~X}{LeftParen (}{RightParen )} (34) +// CHECK: CXXDestructor:{ResultType void}{TypedText ~X}{LeftParen (}{RightParen )} (79) diff --git a/test/Index/get-cursor.cpp b/test/Index/get-cursor.cpp index 8aa12d5bc3101..e997fc493d8cc 100644 --- a/test/Index/get-cursor.cpp +++ b/test/Index/get-cursor.cpp @@ -152,6 +152,11 @@ void f_dynamic_noexcept_none() throw(); void f_dynamic_noexcept() throw(int); void f_dynamic_noexcept_any() throw(...); +enum EnumType { Enumerator }; +struct Z { + EnumType e = Enumerator; +}; + // RUN: c-index-test -cursor-at=%s:6:4 %s | FileCheck -check-prefix=CHECK-COMPLETION-1 %s // CHECK-COMPLETION-1: CXXConstructor=X:6:3 // CHECK-COMPLETION-1-NEXT: Completion string: {TypedText X}{LeftParen (}{Placeholder int}{Comma , }{Placeholder int}{RightParen )} @@ -275,3 +280,6 @@ void f_dynamic_noexcept_any() throw(...); // CHECK-FORRANGE: 141:18 DeclRefExpr=coll:140:20 Extent=[141:18 - 141:22] Spelling=coll ([141:18 - 141:22]) // CHECK-FORRANGE: 142:11 DeclRefExpr=lv:141:13 Extent=[142:11 - 142:13] Spelling=lv ([142:11 - 142:13]) +// RUN: c-index-test -cursor-at=%s:157:18 -std=c++11 %s | FileCheck -check-prefix=CHECK-INCLASSINITIALIZER %s +// CHECK-INCLASSINITIALIZER: 157:18 DeclRefExpr=Enumerator:155:17 Extent=[157:18 - 157:28] Spelling=Enumerator ([157:18 - 157:28]) + diff --git a/test/Index/index-pch.cpp b/test/Index/index-pch.cpp index caab2d7f97bd5..e86e446ef026b 100644 --- a/test/Index/index-pch.cpp +++ b/test/Index/index-pch.cpp @@ -1,4 +1,4 @@ -// RUN: c-index-test -write-pch %t.pch -fshort-wchar %s +// RUN: c-index-test -write-pch %t.pch -fwchar-type=short -fno-signed-wchar %s // RUN: env LIBCLANG_NOTHREADS=1 c-index-test -index-tu %t.pch | FileCheck %s // CHECK: [indexDeclaration]: kind: variable | name: wideStr diff --git a/test/Index/index-template-template-param.cpp b/test/Index/index-template-template-param.cpp new file mode 100644 index 0000000000000..af1c4634adb58 --- /dev/null +++ b/test/Index/index-template-template-param.cpp @@ -0,0 +1,7 @@ +// RUN: c-index-test -index-file %s -x objective-c++ | FileCheck %s + +template <typename T> class Template1 {}; + +template <template <class> class TMPL = Template1> class Template2; + +// CHECK: [indexEntityReference]: kind: c++-class-template | name: Template1 | diff --git a/test/Index/index-templates.cpp b/test/Index/index-templates.cpp index 966cc4f5ea7fe..424a638ffbb8f 100644 --- a/test/Index/index-templates.cpp +++ b/test/Index/index-templates.cpp @@ -219,6 +219,6 @@ using alias = T; // CHECK-USRS: index-templates.cpp c:@ST>2#T#T@Y Extent=[27:1 - 31:2] // CHECK-USRS: index-templates.cpp c:index-templates.cpp@443 Extent=[27:10 - 27:20] // CHECK-USRS: index-templates.cpp c:index-templates.cpp@455 Extent=[27:22 - 27:32] -// CHECK-USRS-NOT: type +// CHECK-USRS: index-templates.cpp c:index-templates.cpp@ST>2#T#T@Y@UUT@T::type Extent=[29:3 - 29:25] // CHECK-USRS: index-templates.cpp c:@S@Z3 Extent=[33:1 - 33:14] // CHECK-USRS: index-templates.cpp c:@F@f#$@S@map>#$@S@Z4#$@S@Pair>#I#S1_#$@S@compare>#$@S@Pair>#S1_#S2_#$@S@allocator>#S4_# diff --git a/test/Index/load-classes.cpp b/test/Index/load-classes.cpp index 8b1ed317e3be4..b6c25b4f7517d 100644 --- a/test/Index/load-classes.cpp +++ b/test/Index/load-classes.cpp @@ -29,7 +29,7 @@ X::X(int value) { } // RUN: c-index-test -test-load-source all %s | FileCheck %s -// CHECK: load-classes.cpp:3:8: StructDecl=X:3:8 (Definition) Extent=[3:1 - 26:2] +// CHECK: load-classes.cpp:3:8: StructDecl=X:3:8 (Definition) (abstract) Extent=[3:1 - 26:2] // CHECK: load-classes.cpp:4:3: CXXConstructor=X:4:3 (converting constructor) Extent=[4:3 - 4:15] [access=public] // FIXME: missing TypeRef in the constructor name // CHECK: load-classes.cpp:4:9: ParmDecl=value:4:9 (Definition) Extent=[4:5 - 4:14] diff --git a/test/Index/preamble-conditionals-inverted-with-error.cpp b/test/Index/preamble-conditionals-inverted-with-error.cpp new file mode 100644 index 0000000000000..95b0695b87331 --- /dev/null +++ b/test/Index/preamble-conditionals-inverted-with-error.cpp @@ -0,0 +1,8 @@ +// RUN: env CINDEXTEST_EDITING=1 c-index-test -test-load-source-reparse 5 \ +// RUN: local -std=c++14 %s 2>&1 \ +// RUN: | FileCheck %s +#ifdef FOO_H + +void foo(); + +// CHECK: preamble-conditionals-inverted-with-error.cpp:4:2: error: unterminated conditional directive diff --git a/test/Index/preamble-conditionals-inverted.cpp b/test/Index/preamble-conditionals-inverted.cpp new file mode 100644 index 0000000000000..f5cf1205e37dd --- /dev/null +++ b/test/Index/preamble-conditionals-inverted.cpp @@ -0,0 +1,10 @@ +// RUN: env CINDEXTEST_EDITING=1 c-index-test -test-load-source-reparse 5 \ +// RUN: local -std=c++14 %s 2>&1 \ +// RUN: | FileCheck %s --implicit-check-not "error:" +#ifdef FOO_H + +void foo() {} + +#endif + +int foo() { return 0; } diff --git a/test/Index/preamble-conditionals-skipping.cpp b/test/Index/preamble-conditionals-skipping.cpp new file mode 100644 index 0000000000000..fa5764cd5de90 --- /dev/null +++ b/test/Index/preamble-conditionals-skipping.cpp @@ -0,0 +1,16 @@ +// RUN: env CINDEXTEST_EDITING=1 c-index-test -test-load-source-reparse 5 \ +// RUN: local -std=c++14 %s 2>&1 \ +// RUN: | FileCheck %s --implicit-check-not "error:" + +#ifdef MYCPLUSPLUS +extern "C" { +#endif + +#ifdef MYCPLUSPLUS +} +#endif + +int main() +{ + return 0; +} diff --git a/test/Index/print-objc-manglings.m b/test/Index/print-objc-manglings.m new file mode 100644 index 0000000000000..1e7983ec6170e --- /dev/null +++ b/test/Index/print-objc-manglings.m @@ -0,0 +1,18 @@ +// RUN: c-index-test -write-pch %t.macho.ast -target i686-apple-darwin %s +// RUN: c-index-test -test-print-manglings %t.macho.ast | FileCheck --check-prefix=MACHO %s + +// RUN: c-index-test -write-pch %t.itanium.ast -target i686-pc-linux-gnu %s +// RUN: c-index-test -test-print-manglings %t.itanium.ast | FileCheck --check-prefix=ITANIUM %s + +@interface C +@end + +// MACHO: ObjCInterfaceDecl=C{{.*}} [mangled=_OBJC_CLASS_$_C] [mangled=_OBJC_METACLASS_$_C] +// ITANIUM: ObjCInterfaceDecl=C{{.*}} [mangled=_OBJC_CLASS_C] [mangled=_OBJC_METACLASS_C] + +@implementation C +@end + +// MACHO: ObjCImplementationDecl=C{{.*}} (Definition) [mangled=_OBJC_CLASS_$_C] [mangled=_OBJC_METACLASS_$_C] +// ITANIUM: ObjCImplementationDecl=C{{.*}} (Definition) [mangled=_OBJC_CLASS_C] [mangled=_OBJC_METACLASS_C] + diff --git a/test/Index/record-completion-invocation.c b/test/Index/record-completion-invocation.c new file mode 100644 index 0000000000000..c249565a4b681 --- /dev/null +++ b/test/Index/record-completion-invocation.c @@ -0,0 +1,11 @@ +// RUN: rm -rf %t +// RUN: mkdir %t +// RUN: env CINDEXTEST_INVOCATION_EMISSION_PATH=%t not c-index-test -code-completion-at=%s:10:1 "-remap-file=%s,%S/Inputs/record-parsing-invocation-remap.c" %s +// RUN: cat %t/libclang-* | FileCheck %s + +// RUN: rm -rf %t +// RUN: mkdir %t +// RUN: env LIBCLANG_DISABLE_CRASH_RECOVERY=1 CINDEXTEST_INVOCATION_EMISSION_PATH=%t not --crash c-index-test -code-completion-at=%s:10:1 "-remap-file=%s,%S/Inputs/record-parsing-invocation-remap.c" %s +// RUN: cat %t/libclang-* | FileCheck %s + +// CHECK: {"toolchain":"{{.*}}","libclang.operation":"complete","libclang.opts":1,"args":["clang","-fno-spell-checking","{{.*}}record-completion-invocation.c","-Xclang","-detailed-preprocessing-record","-fallow-editor-placeholders"],"invocation-args":["-code-completion-at={{.*}}record-completion-invocation.c:10:1"],"unsaved_file_hashes":[{"name":"{{.*}}record-completion-invocation.c","md5":"aee23773de90e665992b48209351d70e"}]} diff --git a/test/Index/record-parsing-invocation.c b/test/Index/record-parsing-invocation.c new file mode 100644 index 0000000000000..3254e58aef048 --- /dev/null +++ b/test/Index/record-parsing-invocation.c @@ -0,0 +1,28 @@ +// RUN: rm -rf %t +// RUN: mkdir %t +// RUN: env CINDEXTEST_INVOCATION_EMISSION_PATH=%t not c-index-test -test-load-source all %s +// RUN: cat %t/libclang-* | FileCheck %s + +// RUN: rm -rf %t +// RUN: mkdir %t +// RUN: env LIBCLANG_DISABLE_CRASH_RECOVERY=1 CINDEXTEST_INVOCATION_EMISSION_PATH=%t not --crash c-index-test -test-load-source all %s +// RUN: cat %t/libclang-* | FileCheck %s + +// Verify that the file is removed for successful operation: +// RUN: rm -rf %t +// RUN: mkdir %t +// RUN: env CINDEXTEST_INVOCATION_EMISSION_PATH=%t c-index-test -test-load-source all %s -DAVOID_CRASH +// RUN: ls %t | count 0 + +// Make sure we record the unsaved file hash. +// RUN: rm -rf %t +// RUN: mkdir %t +// RUN: env CINDEXTEST_INVOCATION_EMISSION_PATH=%t not c-index-test -test-load-source all "-remap-file=%s,%S/Inputs/record-parsing-invocation-remap.c" %s +// RUN: cat %t/libclang-* | FileCheck --check-prefix=CHECK-UNSAVED %s + +#ifndef AVOID_CRASH +# pragma clang __debug parser_crash +#endif + +// CHECK: {"toolchain":"{{.*}}","libclang.operation":"parse","libclang.opts":1,"args":["clang","-fno-spell-checking","{{.*}}record-parsing-invocation.c","-Xclang","-detailed-preprocessing-record","-fallow-editor-placeholders"]} +// CHECK-UNSAVED: {"toolchain":"{{.*}}","libclang.operation":"parse","libclang.opts":1,"args":["clang","-fno-spell-checking","{{.*}}record-parsing-invocation.c","-Xclang","-detailed-preprocessing-record","-fallow-editor-placeholders"],"unsaved_file_hashes":[{"name":"{{.*}}record-parsing-invocation.c","md5":"aee23773de90e665992b48209351d70e"}]} diff --git a/test/Index/recover-bad-code-rdar_7487294.c b/test/Index/recover-bad-code-rdar_7487294.c index c2803006ac43e..bbbc035a0a9bf 100644 --- a/test/Index/recover-bad-code-rdar_7487294.c +++ b/test/Index/recover-bad-code-rdar_7487294.c @@ -1,4 +1,4 @@ -// RUN: not %clang-cc1 -fsyntax-only %s 2>&1 | FileCheck %s +// RUN: not %clang_cc1 -fsyntax-only %s 2>&1 | FileCheck %s // IMPORTANT: This test case intentionally DOES NOT use --disable-free. It // tests that we are properly reclaiming the ASTs and we do not have a double free. diff --git a/test/Index/skipped-function-bodies.cpp b/test/Index/skipped-function-bodies.cpp new file mode 100644 index 0000000000000..9378f664bb6f8 --- /dev/null +++ b/test/Index/skipped-function-bodies.cpp @@ -0,0 +1,9 @@ +// RUN: env CINDEXTEST_SKIP_FUNCTION_BODIES=1 c-index-test -test-load-source all %s 2>&1 \ +// RUN: | FileCheck %s + +inline int with_body() { return 10; } +inline int without_body(); + +int x = with_body() + without_body(); +// CHECK-NOT: warning: inline function 'with_body' is not defined +// CHECK: warning: inline function 'without_body' is not defined diff --git a/test/Index/skipped-ranges.c b/test/Index/skipped-ranges.c index bd16fb3856b27..f6c6c7f638ecd 100644 --- a/test/Index/skipped-ranges.c +++ b/test/Index/skipped-ranges.c @@ -20,6 +20,6 @@ int probably_hot = 1; #endif // cool // RUN: env CINDEXTEST_SHOW_SKIPPED_RANGES=1 c-index-test -test-annotate-tokens=%s:1:1:16:1 %s | FileCheck %s -// CHECK: Skipping: [5:2 - 6:7] -// CHECK: Skipping: [8:2 - 12:7] -// CHECK: Skipping: [14:2 - 20:7] +// CHECK: Skipping: [5:1 - 6:7] +// CHECK: Skipping: [8:1 - 12:7] +// CHECK: Skipping: [14:1 - 20:7] |