[PATCH] D85077: [clang][Tooling] Optimize addTargetAndMode in case of invalid modes
Kadir Cetinkaya via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sat Aug 1 10:04:49 PDT 2020
kadircet created this revision.
kadircet added a reviewer: hokein.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
kadircet requested review of this revision.
This skips searching for `target` related flags in the existing args if
we don't have a valid target to insert.
Depends on D85076 <https://reviews.llvm.org/D85076>
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D85077
Files:
clang/lib/Tooling/Tooling.cpp
Index: clang/lib/Tooling/Tooling.cpp
===================================================================
--- clang/lib/Tooling/Tooling.cpp
+++ clang/lib/Tooling/Tooling.cpp
@@ -258,7 +258,10 @@
// --driver-mode=X
const std::string DriverModeOPT =
Table.getOption(driver::options::OPT_driver_mode).getPrefixedName();
- bool AlreadyHasTarget = false;
+ auto TargetMode =
+ driver::ToolChain::getTargetAndModeFromProgramName(InvokedAs);
+ // No need to search for target args if we don't have a mode to insert.
+ bool AlreadyHasTarget = !TargetMode.TargetIsValid;
bool AlreadyHasMode = false;
// Skip CommandLine[0].
for (auto Token = ++CommandLine.begin(); Token != CommandLine.end();
@@ -268,12 +271,10 @@
TokenRef.startswith(TargetOPT) || TokenRef.equals(TargetOPTLegacy);
AlreadyHasMode |= TokenRef.startswith(DriverModeOPT);
}
- auto TargetMode =
- driver::ToolChain::getTargetAndModeFromProgramName(InvokedAs);
if (!AlreadyHasMode && TargetMode.DriverMode) {
CommandLine.insert(++CommandLine.begin(), TargetMode.DriverMode);
}
- if (!AlreadyHasTarget && TargetMode.TargetIsValid) {
+ if (!AlreadyHasTarget) {
CommandLine.insert(++CommandLine.begin(),
TargetOPT + TargetMode.TargetPrefix);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D85077.282405.patch
Type: text/x-patch
Size: 1293 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200801/15e93c12/attachment.bin>
More information about the cfe-commits
mailing list