[clang-tools-extra] r307025 - [clangd] Add -ffreestanding on VFS tests.
Ilya Biryukov via cfe-commits
cfe-commits at lists.llvm.org
Mon Jul 3 07:46:04 PDT 2017
Author: ibiryukov
Date: Mon Jul 3 07:46:03 2017
New Revision: 307025
URL: http://llvm.org/viewvc/llvm-project?rev=307025&view=rev
Log:
[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
Modified:
clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp
Modified: clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp?rev=307025&r1=307024&r2=307025&view=diff
==============================================================================
--- clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp (original)
+++ clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp Mon Jul 3 07:46:03 2017
@@ -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);
More information about the cfe-commits
mailing list