mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-04-02 13:12:09 +00:00
[clangd] Testcase for bug 39811
Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, jdoerfert, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D58133 llvm-svn: 354442
This commit is contained in:
parent
69716394f3
commit
30d340839c
@ -1441,6 +1441,35 @@ TEST(FindReferences, NoQueryForLocalSymbols) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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
|
||||||
} // namespace clangd
|
} // namespace clangd
|
||||||
} // namespace clang
|
} // namespace clang
|
||||||
|
Loading…
x
Reference in New Issue
Block a user