[PATCH] D34936: [clangd] Add -ffreestanding on VFS tests.
Ilya Biryukov via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Jul 3 07:34:09 PDT 2017
ilya-biryukov created this revision.
They don't provide proper gcc installations and may fail on implicit
<stdc-predef.h> include.
https://reviews.llvm.org/D34936
Files:
unittests/clangd/ClangdTests.cpp
Index: unittests/clangd/ClangdTests.cpp
===================================================================
--- unittests/clangd/ClangdTests.cpp
+++ unittests/clangd/ClangdTests.cpp
@@ -164,6 +164,13 @@
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 @@
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 @@
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 @@
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 @@
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 @@
// 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 @@
TEST_F(ClangdCompletionTest, CheckContentsOverride) {
MockFSProvider FS;
ErrorCheckingDiagConsumer DiagConsumer;
- MockCompilationDatabase CDB;
+ MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
ClangdServer Server(CDB, DiagConsumer, FS,
/*RunSynchronously=*/false);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D34936.105041.patch
Type: text/x-patch
Size: 2894 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170703/8795b53f/attachment-0001.bin>
More information about the cfe-commits
mailing list