[PATCH] D72066: [clangd] Assert that the testcases in LocateSymbol.All have no diagnostics
Nathan Ridge via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Jan 1 22:15:05 PST 2020
nridge created this revision.
Herald added subscribers: cfe-commits, usaxena95, kadircet, arphaman, jkorous, MaskRay, ilya-biryukov.
Herald added a project: clang.
Also fix some bugs in the testcases which this exposed.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D72066
Files:
clang-tools-extra/clangd/unittests/XRefsTests.cpp
Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===================================================================
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ 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) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D72066.235827.patch
Type: text/x-patch
Size: 2286 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200102/21c7ac66/attachment.bin>
More information about the cfe-commits
mailing list