forked from OSchip/llvm-project
[clangd] Add -ffreestanding on VFS tests.
Summary: They don't provide proper gcc installations and may fail on implicit <stdc-predef.h> include. Reviewers: klimek, krasimir, bkramer Reviewed By: krasimir Subscribers: klimek, cfe-commits Tags: #clang-tools-extra Differential Revision: https://reviews.llvm.org/D34936 llvm-svn: 307025
This commit is contained in:
parent
dab798a25f
commit
53d69e329b
|
@ -164,6 +164,13 @@ private:
|
|||
|
||||
class MockCompilationDatabase : public GlobalCompilationDatabase {
|
||||
public:
|
||||
MockCompilationDatabase(bool AddFreestandingFlag) {
|
||||
// We have to add -ffreestanding to VFS-specific tests to avoid errors on
|
||||
// implicit includes of stdc-predef.h.
|
||||
if (AddFreestandingFlag)
|
||||
ExtraClangFlags.push_back("-ffreestanding");
|
||||
}
|
||||
|
||||
std::vector<tooling::CompileCommand>
|
||||
getCompileCommands(PathRef File) override {
|
||||
if (ExtraClangFlags.empty())
|
||||
|
@ -259,7 +266,7 @@ protected:
|
|||
bool ExpectErrors = false) {
|
||||
MockFSProvider FS;
|
||||
ErrorCheckingDiagConsumer DiagConsumer;
|
||||
MockCompilationDatabase CDB;
|
||||
MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
|
||||
ClangdServer Server(CDB, DiagConsumer, FS,
|
||||
/*RunSynchronously=*/false);
|
||||
for (const auto &FileWithContents : ExtraFiles)
|
||||
|
@ -315,7 +322,7 @@ int b = a;
|
|||
TEST_F(ClangdVFSTest, Reparse) {
|
||||
MockFSProvider FS;
|
||||
ErrorCheckingDiagConsumer DiagConsumer;
|
||||
MockCompilationDatabase CDB;
|
||||
MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
|
||||
ClangdServer Server(CDB, DiagConsumer, FS,
|
||||
/*RunSynchronously=*/false);
|
||||
|
||||
|
@ -350,7 +357,7 @@ int b = a;
|
|||
TEST_F(ClangdVFSTest, ReparseOnHeaderChange) {
|
||||
MockFSProvider FS;
|
||||
ErrorCheckingDiagConsumer DiagConsumer;
|
||||
MockCompilationDatabase CDB;
|
||||
MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
|
||||
|
||||
ClangdServer Server(CDB, DiagConsumer, FS,
|
||||
/*RunSynchronously=*/false);
|
||||
|
@ -388,7 +395,7 @@ int b = a;
|
|||
TEST_F(ClangdVFSTest, CheckVersions) {
|
||||
MockFSProvider FS;
|
||||
ErrorCheckingDiagConsumer DiagConsumer;
|
||||
MockCompilationDatabase CDB;
|
||||
MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
|
||||
ClangdServer Server(CDB, DiagConsumer, FS,
|
||||
/*RunSynchronously=*/true);
|
||||
|
||||
|
@ -414,8 +421,10 @@ TEST_F(ClangdVFSTest, SearchLibDir) {
|
|||
// Checks that searches for GCC installation is done through vfs.
|
||||
MockFSProvider FS;
|
||||
ErrorCheckingDiagConsumer DiagConsumer;
|
||||
MockCompilationDatabase CDB;
|
||||
CDB.ExtraClangFlags = {"-xc++", "-target", "x86_64-linux-unknown", "-m64"};
|
||||
MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
|
||||
CDB.ExtraClangFlags.insert(
|
||||
CDB.ExtraClangFlags.end(),
|
||||
{"-xc++", "-target", "x86_64-linux-unknown", "-m64"});
|
||||
ClangdServer Server(CDB, DiagConsumer, FS,
|
||||
/*RunSynchronously=*/true);
|
||||
|
||||
|
@ -472,7 +481,7 @@ protected:
|
|||
TEST_F(ClangdCompletionTest, CheckContentsOverride) {
|
||||
MockFSProvider FS;
|
||||
ErrorCheckingDiagConsumer DiagConsumer;
|
||||
MockCompilationDatabase CDB;
|
||||
MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
|
||||
|
||||
ClangdServer Server(CDB, DiagConsumer, FS,
|
||||
/*RunSynchronously=*/false);
|
||||
|
|
Loading…
Reference in New Issue