diff --git a/clang-tools-extra/clangd/unittests/XRefsTests.cpp b/clang-tools-extra/clangd/unittests/XRefsTests.cpp --- a/clang-tools-extra/clangd/unittests/XRefsTests.cpp +++ b/clang-tools-extra/clangd/unittests/XRefsTests.cpp @@ -253,7 +253,7 @@ )cpp", R"cpp(// Function definition via pointer - int [[foo]](int) {} + void [[foo]](int) {} int main() { auto *X = &^foo; } @@ -270,7 +270,7 @@ struct Foo { int [[x]]; }; int main() { Foo bar; - bar.^x; + (void)bar.^x; } )cpp", @@ -322,7 +322,7 @@ R"cpp(// Namespace namespace $decl[[ns]] { - struct Foo { static void bar(); } + struct Foo { static void bar(); }; } // namespace ns int main() { ^ns::Foo::bar(); } )cpp", @@ -352,7 +352,7 @@ R"cpp(// Symbol concatenated inside macro (not supported) int *pi; - #define POINTER(X) p # X; + #define POINTER(X) p ## X; int i = *POINTER(^i); )cpp", @@ -433,10 +433,10 @@ )cpp", R"cpp(// No implicit constructors - class X { + struct X { X(X&& x) = default; }; - X [[makeX]]() {} + X $decl[[makeX]](); void foo() { auto x = m^akeX(); } @@ -444,7 +444,7 @@ R"cpp( struct X { - X& [[operator]]++() {} + X& [[operator]]++() { return *this; } }; void foo(X& x) { +^+x; @@ -529,7 +529,20 @@ // parsing. TU.ExtraArgs.push_back("-fno-delayed-template-parsing"); + // Disable warnings which some testcases intentionally trigger, + // so that we can assert the testcases have no diagnostics and + // catch mistakes. + TU.ExtraArgs.push_back("-Wno-gnu-designator"); + TU.ExtraArgs.push_back("-Wno-macro-redefined"); + auto AST = TU.build(); + // We don't expect there to be diagnostics, but if there are, + // it facilitates debugging to print them. + for (auto &Diag : AST.getDiagnostics()) { + llvm::errs() << Diag << "\n"; + } + ASSERT_TRUE(AST.getDiagnostics().empty()) << Test; + auto Results = locateSymbolAt(AST, T.point()); if (!WantDecl) {