xref: /llvm-project/clang/test/Index/annotate-attribute.cpp (revision 578ac7a2ec4a772f97d9cb566c95764ff3d41625)
1ca98f2a6SErik Verbruggen // RUN: c-index-test -test-load-source all %s | FileCheck %s
2ca98f2a6SErik Verbruggen 
3ca98f2a6SErik Verbruggen class Test {
4ca98f2a6SErik Verbruggen public:
5ca98f2a6SErik Verbruggen   __attribute__((annotate("spiffy_method"))) void aMethod();
6ca98f2a6SErik Verbruggen 
7ca98f2a6SErik Verbruggen public __attribute__((annotate("works"))):
8ca98f2a6SErik Verbruggen   void anotherMethod(); // annotation attribute should be propagated.
9ca98f2a6SErik Verbruggen 
10ca98f2a6SErik Verbruggen private __attribute__((annotate("investigations"))):
11ca98f2a6SErik Verbruggen   //propagated annotation should have changed from "works" to "investigations"
inlineMethod()12ca98f2a6SErik Verbruggen   void inlineMethod() {}
13ca98f2a6SErik Verbruggen 
14ca98f2a6SErik Verbruggen protected:
15ca98f2a6SErik Verbruggen   // attribute propagation should have stopped here
16ca98f2a6SErik Verbruggen   void methodWithoutAttribute();
17ca98f2a6SErik Verbruggen };
18ca98f2a6SErik Verbruggen 
19*578ac7a2SJonathan Coe template <typename T>
20*578ac7a2SJonathan Coe class __attribute__((annotate("works"))) TemplateTest {};
21*578ac7a2SJonathan Coe 
22*578ac7a2SJonathan Coe template <typename T>
23*578ac7a2SJonathan Coe int templateFunction(T value) __attribute__((annotate("works")));
24*578ac7a2SJonathan Coe 
25ca98f2a6SErik Verbruggen // CHECK: ClassDecl=Test:3:7 (Definition) Extent=[3:1 - 17:2]
26fd979b1eSErik Verbruggen // CHECK-NEXT: CXXAccessSpecifier=:4:1 (Definition) Extent=[4:1 - 4:8]
27fd979b1eSErik Verbruggen // CHECK-NEXT: CXXMethod=aMethod:5:51 Extent=[5:3 - 5:60]
28fd979b1eSErik Verbruggen // CHECK-NEXT: attribute(annotate)=spiffy_method Extent=[5:18 - 5:43]
29fd979b1eSErik Verbruggen // CHECK-NEXT: CXXAccessSpecifier=:7:1 (Definition) Extent=[7:1 - 7:43]
30fd979b1eSErik Verbruggen // CHECK-NEXT: attribute(annotate)=works Extent=[7:23 - 7:40]
31fd979b1eSErik Verbruggen // CHECK-NEXT: CXXMethod=anotherMethod:8:8 Extent=[8:3 - 8:23]
32fd979b1eSErik Verbruggen // CHECK-NEXT: attribute(annotate)=works Extent=[7:23 - 7:40]
33fd979b1eSErik Verbruggen // CHECK-NEXT: CXXAccessSpecifier=:10:1 (Definition) Extent=[10:1 - 10:53]
34fd979b1eSErik Verbruggen // CHECK-NEXT: attribute(annotate)=investigations Extent=[10:24 - 10:50]
35fd979b1eSErik Verbruggen // CHECK-NEXT: CXXMethod=inlineMethod:12:8 (Definition) Extent=[12:3 - 12:25]
36fd979b1eSErik Verbruggen // CHECK-NEXT: attribute(annotate)=investigations Extent=[10:24 - 10:50]
37fd979b1eSErik Verbruggen // CHECK-NEXT: CompoundStmt= Extent=[12:23 - 12:25]
38fd979b1eSErik Verbruggen // CHECK-NEXT: CXXAccessSpecifier=:14:1 (Definition) Extent=[14:1 - 14:11]
39fd979b1eSErik Verbruggen // CHECK-NEXT: CXXMethod=methodWithoutAttribute:16:8 Extent=[16:3 - 16:32]
40*578ac7a2SJonathan Coe // CHECK: ClassTemplate=TemplateTest:20:42 (Definition) Extent=[19:1 - 20:57]
41*578ac7a2SJonathan Coe // CHECK-NEXT: TemplateTypeParameter=T:19:20 (Definition) Extent=[19:11 - 19:21] [access=public]
42*578ac7a2SJonathan Coe // CHECK-NEXT: attribute(annotate)=works Extent=[20:22 - 20:39]
43*578ac7a2SJonathan Coe // CHECK: FunctionTemplate=templateFunction:23:5 Extent=[22:1 - 23:65]
44*578ac7a2SJonathan Coe // CHECK-NEXT: TemplateTypeParameter=T:22:20 (Definition) Extent=[22:11 - 22:21] [access=public]
45*578ac7a2SJonathan Coe // CHECK-NEXT: attribute(annotate)=works Extent=[23:46 - 23:63]
46