Skip to content

Commit 5b2e380

Browse files
committed
When -nostdinc is used, do not add custom -isystem or the builtin mapping.
1 parent 51a889d commit 5b2e380

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

generator/main.cpp

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,7 @@ static bool proceedCommand(std::vector<std::string> command, llvm::StringRef Dir
236236
// This code change all the paths to be absolute paths
237237
// FIXME: it is a bit fragile.
238238
bool previousIsDashI = false;
239+
bool hasNoStdInc = false;
239240
for(std::string &A : command) {
240241
if (previousIsDashI && !A.empty() && A[0] != '/') {
241242
A = Directory % "/" % A;
@@ -244,6 +245,9 @@ static bool proceedCommand(std::vector<std::string> command, llvm::StringRef Dir
244245
} else if (A == "-I") {
245246
previousIsDashI = true;
246247
continue;
248+
} else if (A == "-nostdinc") {
249+
hasNoStdInc = true;
250+
continue;
247251
}
248252
previousIsDashI = false;
249253
if (A.empty()) continue;
@@ -268,17 +272,21 @@ static bool proceedCommand(std::vector<std::string> command, llvm::StringRef Dir
268272
command = clang::tooling::getClangSyntaxOnlyAdjuster()(command, file);
269273
command = clang::tooling::getClangStripOutputAdjuster()(command, file);
270274
#endif
271-
command.push_back("-isystem");
272-
command.push_back("/builtins");
275+
if (!hasNoStdInc) {
276+
command.push_back("-isystem");
277+
command.push_back("/builtins");
278+
}
273279
command.push_back("-Qunused-arguments");
274280
command.push_back("-Wno-unknown-warning-option");
275281
clang::tooling::ToolInvocation Inv(command, new BrowserAction(WasInDatabase), FM);
276282

277-
// Map the builtins includes
278-
const EmbeddedFile *f = EmbeddedFiles;
279-
while (f->filename) {
280-
Inv.mapVirtualFile(f->filename, {f->content , f->size } );
281-
f++;
283+
if (!hasNoStdInc) {
284+
// Map the builtins includes
285+
const EmbeddedFile *f = EmbeddedFiles;
286+
while (f->filename) {
287+
Inv.mapVirtualFile(f->filename, {f->content , f->size } );
288+
f++;
289+
}
282290
}
283291
bool result = Inv.run();
284292
if (!result) {

0 commit comments

Comments
 (0)