[PATCH] D126274: [clangd] Handle '--' in QueryDriverDatabase
Nathan Ridge via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue May 24 10:11:04 PDT 2022
This revision was automatically updated to reflect the committed changes.
Closed by commit rG175833ed6f62: [clangd] Handle '--' in QueryDriverDatabase (authored by nridge).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D126274/new/
https://reviews.llvm.org/D126274
Files:
clang-tools-extra/clangd/QueryDriverDatabase.cpp
Index: clang-tools-extra/clangd/QueryDriverDatabase.cpp
===================================================================
--- clang-tools-extra/clangd/QueryDriverDatabase.cpp
+++ clang-tools-extra/clangd/QueryDriverDatabase.cpp
@@ -50,6 +50,7 @@
#include "llvm/Support/Regex.h"
#include "llvm/Support/ScopedPrinter.h"
#include <algorithm>
+#include <iterator>
#include <map>
#include <string>
#include <vector>
@@ -238,10 +239,17 @@
tooling::CompileCommand &
addSystemIncludes(tooling::CompileCommand &Cmd,
llvm::ArrayRef<std::string> SystemIncludes) {
+ std::vector<std::string> ToAppend;
for (llvm::StringRef Include : SystemIncludes) {
// FIXME(kadircet): This doesn't work when we have "--driver-mode=cl"
- Cmd.CommandLine.push_back("-isystem");
- Cmd.CommandLine.push_back(Include.str());
+ ToAppend.push_back("-isystem");
+ ToAppend.push_back(Include.str());
+ }
+ if (!ToAppend.empty()) {
+ // Just append when `--` isn't present.
+ auto InsertAt = llvm::find(Cmd.CommandLine, "--");
+ Cmd.CommandLine.insert(InsertAt, std::make_move_iterator(ToAppend.begin()),
+ std::make_move_iterator(ToAppend.end()));
}
return Cmd;
}
@@ -254,7 +262,9 @@
if (Arg == "-target" || Arg.startswith("--target="))
return Cmd;
}
- Cmd.CommandLine.push_back("--target=" + Target);
+ // Just append when `--` isn't present.
+ auto InsertAt = llvm::find(Cmd.CommandLine, "--");
+ Cmd.CommandLine.insert(InsertAt, "--target=" + Target);
}
return Cmd;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D126274.431709.patch
Type: text/x-patch
Size: 1570 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220524/380c25c8/attachment.bin>
More information about the cfe-commits
mailing list