summaryrefslogtreecommitdiff
path: root/clang-tools-extra/unittests/clangd/ClangdUnitTests.cpp
diff options
context:
space:
mode:
authorKadir Cetinkaya <kadircet@google.com>2018-10-09 08:41:12 +0000
committerKadir Cetinkaya <kadircet@google.com>2018-10-09 08:41:12 +0000
commitaddd56f3bc80c552f09c0ed2f50b642968e26c18 (patch)
tree2cf61949103733db0bd4f5be67534bcf37779089 /clang-tools-extra/unittests/clangd/ClangdUnitTests.cpp
parent39106a761cf315de2202e24498fe045f48bd3479 (diff)
[clangd] Revert back to previous heuristic for diagnostic range extraction.
Summary: Also add a few new test cases and a special case into handling of empty fixit ranges that collides with location of a diag. Reviewers: sammccall, ilya-biryukov Reviewed By: sammccall Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D52889
Diffstat (limited to 'clang-tools-extra/unittests/clangd/ClangdUnitTests.cpp')
-rw-r--r--clang-tools-extra/unittests/clangd/ClangdUnitTests.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/clang-tools-extra/unittests/clangd/ClangdUnitTests.cpp b/clang-tools-extra/unittests/clangd/ClangdUnitTests.cpp
index 51cfcfe48f3..fe3fc200635 100644
--- a/clang-tools-extra/unittests/clangd/ClangdUnitTests.cpp
+++ b/clang-tools-extra/unittests/clangd/ClangdUnitTests.cpp
@@ -75,13 +75,17 @@ Position pos(int line, int character) {
TEST(DiagnosticsTest, DiagnosticRanges) {
// Check we report correct ranges, including various edge-cases.
Annotations Test(R"cpp(
+ namespace test{};
void $decl[[foo]]();
int main() {
$typo[[go\
o]]();
foo()$semicolon[[]]//with comments
$unk[[unknown]]();
- double bar = $type[["foo"]];
+ double $type[[bar]] = "foo";
+ struct Foo { int x; }; Foo a;
+ a.$nomember[[y]];
+ test::$nomembernamespace[[test]];
}
)cpp");
EXPECT_THAT(
@@ -103,7 +107,10 @@ o]]();
Diag(Test.range("unk"), "use of undeclared identifier 'unknown'"),
Diag(Test.range("type"),
"cannot initialize a variable of type 'double' with an lvalue "
- "of type 'const char [4]'")));
+ "of type 'const char [4]'"),
+ Diag(Test.range("nomember"), "no member named 'y' in 'Foo'"),
+ Diag(Test.range("nomembernamespace"),
+ "no member named 'test' in namespace 'test'")));
}
TEST(DiagnosticsTest, FlagsMatter) {