diff options
Diffstat (limited to 'clang-tools-extra/unittests/clangd/XRefsTests.cpp')
-rw-r--r-- | clang-tools-extra/unittests/clangd/XRefsTests.cpp | 42 |
1 files changed, 27 insertions, 15 deletions
diff --git a/clang-tools-extra/unittests/clangd/XRefsTests.cpp b/clang-tools-extra/unittests/clangd/XRefsTests.cpp index c2dd053bf11..2617b4ae57e 100644 --- a/clang-tools-extra/unittests/clangd/XRefsTests.cpp +++ b/clang-tools-extra/unittests/clangd/XRefsTests.cpp @@ -119,7 +119,7 @@ TEST(GoToDefinition, All) { const char *Tests[] = { R"cpp(// Local variable int main() { - [[int bonjour]]; + int [[bonjour]]; ^bonjour = 2; int test1 = bonjour; } @@ -127,7 +127,7 @@ TEST(GoToDefinition, All) { R"cpp(// Struct namespace ns1 { - [[struct MyClass {}]]; + struct [[MyClass]] {}; } // namespace ns1 int main() { ns1::My^Class* Params; @@ -135,21 +135,21 @@ TEST(GoToDefinition, All) { )cpp", R"cpp(// Function definition via pointer - [[int foo(int) {}]] + int [[foo]](int) {} int main() { auto *X = &^foo; } )cpp", R"cpp(// Function declaration via call - [[int foo(int)]]; + int [[foo]](int); int main() { return ^foo(42); } )cpp", R"cpp(// Field - struct Foo { [[int x]]; }; + struct Foo { int [[x]]; }; int main() { Foo bar; bar.^x; @@ -158,27 +158,27 @@ TEST(GoToDefinition, All) { R"cpp(// Field, member initializer struct Foo { - [[int x]]; + int [[x]]; Foo() : ^x(0) {} }; )cpp", R"cpp(// Field, GNU old-style field designator - struct Foo { [[int x]]; }; + struct Foo { int [[x]]; }; int main() { Foo bar = { ^x : 1 }; } )cpp", R"cpp(// Field, field designator - struct Foo { [[int x]]; }; + struct Foo { int [[x]]; }; int main() { Foo bar = { .^x = 2 }; } )cpp", R"cpp(// Method call - struct Foo { [[int x()]]; }; + struct Foo { int [[x]](); }; int main() { Foo bar; bar.^x(); @@ -186,7 +186,7 @@ TEST(GoToDefinition, All) { )cpp", R"cpp(// Typedef - [[typedef int Foo]]; + typedef int [[Foo]]; int main() { ^Foo bar; } @@ -199,9 +199,9 @@ TEST(GoToDefinition, All) { )cpp", */ R"cpp(// Namespace - [[namespace ns { + namespace [[ns]] { struct Foo { static void bar(); } - }]] // namespace ns + } // namespace ns int main() { ^ns::Foo::bar(); } )cpp", @@ -215,14 +215,26 @@ TEST(GoToDefinition, All) { R"cpp(// Forward class declaration class Foo; - [[class Foo {}]]; + class [[Foo]] {}; F^oo* foo(); )cpp", R"cpp(// Function declaration void foo(); void g() { f^oo(); } - [[void foo() {}]] + void [[foo]]() {} + )cpp", + + R"cpp( + #define FF(name) class name##_Test {}; + [[FF]](my); + void f() { my^_Test a; } + )cpp", + + R"cpp( + #define FF() class [[Test]] {}; + FF(); + void f() { T^est a; } )cpp", }; for (const char *Test : Tests) { @@ -236,7 +248,7 @@ TEST(GoToDefinition, All) { TEST(GoToDefinition, RelPathsInCompileCommand) { Annotations SourceAnnotations(R"cpp( -[[int foo]]; +int [[foo]]; int baz = f^oo; )cpp"); |