[clang-tools-extra] r354442 - [clangd] Testcase for bug 39811

Kadir Cetinkaya via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 20 01:41:26 PST 2019


Author: kadircet
Date: Wed Feb 20 01:41:26 2019
New Revision: 354442

URL: http://llvm.org/viewvc/llvm-project?rev=354442&view=rev
Log:
[clangd] Testcase for bug 39811

Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, jdoerfert, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D58133

Modified:
    clang-tools-extra/trunk/unittests/clangd/XRefsTests.cpp

Modified: clang-tools-extra/trunk/unittests/clangd/XRefsTests.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/XRefsTests.cpp?rev=354442&r1=354441&r2=354442&view=diff
==============================================================================
--- clang-tools-extra/trunk/unittests/clangd/XRefsTests.cpp (original)
+++ clang-tools-extra/trunk/unittests/clangd/XRefsTests.cpp Wed Feb 20 01:41:26 2019
@@ -1441,6 +1441,35 @@ TEST(FindReferences, NoQueryForLocalSymb
   }
 }
 
+TEST(GoTo, WithSysRoot) {
+  const char *CustoomRoot = "/sys/root/";
+  Annotations Main(R"cpp(
+      #include "header.h"
+      int main() {
+        return f^oo();
+      })cpp");
+  Annotations Header("int [[foo]](){return 42;}");
+
+  MockCompilationDatabase CDB;
+  CDB.ExtraClangFlags = {"--sysroot", CustoomRoot};
+  IgnoreDiagnostics DiagConsumer;
+  MockFSProvider FS;
+  ClangdServer Server(CDB, FS, DiagConsumer, ClangdServer::optsForTest());
+
+  // Fill the filesystem.
+  auto FooCpp = testPath("foo.cpp");
+  FS.Files[FooCpp] = Main.code();
+  auto HeaderPath = (llvm::StringRef(CustoomRoot) + "include/header.h").str();
+  FS.Files[HeaderPath] = Header.code();
+
+  runAddDocument(Server, FooCpp, Main.code());
+
+  // Go to a definition in main source file.
+  auto Locations = runLocateSymbolAt(Server, FooCpp, Main.point());
+  EXPECT_TRUE(bool(Locations)) << "findDefinitions returned an error";
+  EXPECT_THAT(*Locations, ElementsAre(Sym("foo", Header.range())));
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang




More information about the cfe-commits mailing list