summaryrefslogtreecommitdiffstats
path: root/clang/lib/Driver
diff options
context:
space:
mode:
authorNico Weber <nicolasweber@gmx.de>2019-07-27 01:13:00 +0000
committerNico Weber <nicolasweber@gmx.de>2019-07-27 01:13:00 +0000
commitb28ffd8f3578ca198f12ffa8beb8ca883bb2cb20 (patch)
tree568c25f07e429bd8c6e90a57271182ed019359cf /clang/lib/Driver
parent7bc4fad0fbee60530f0b50d8e3911a21d47046bd (diff)
downloadbcm5719-llvm-b28ffd8f3578ca198f12ffa8beb8ca883bb2cb20.tar.gz
bcm5719-llvm-b28ffd8f3578ca198f12ffa8beb8ca883bb2cb20.zip
driver: Don't warn about assembler flags being unused when not assembling; different approach
This morally relands r365703 (and r365714), originally reviewed at https://reviews.llvm.org/D64527, but with a different implementation. Relanding the same approach with a fix for the revert reason got a bit involved (see https://reviews.llvm.org/D65108) so use a simpler approach with a more localized implementation (that in return duplicates code a bit more). This approach also doesn't validate flags for the integrated assembler if the assembler step doesn't run. Fixes PR42066. Differential Revision: https://reviews.llvm.org/D65233 llvm-svn: 367165
Diffstat (limited to 'clang/lib/Driver')
-rw-r--r--clang/lib/Driver/ToolChains/Clang.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp
index 44663a4dbd7..bfaf7f3dc43 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -2079,6 +2079,9 @@ static void CollectArgsForIntegratedAssembler(Compilation &C,
break;
}
+ // If you add more args here, also add them to the block below that
+ // starts with "// If CollectArgsForIntegratedAssembler() isn't called below".
+
// When passing -I arguments to the assembler we sometimes need to
// unconditionally take the next argument. For example, when parsing
// '-Wa,-I -Wa,foo' we need to accept the -Wa,foo arg after seeing the
@@ -3543,6 +3546,35 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
// Select the appropriate action.
RewriteKind rewriteKind = RK_None;
+ // If CollectArgsForIntegratedAssembler() isn't called below, claim the args
+ // it claims when not running an assembler. Otherwise, clang would emit
+ // "argument unused" warnings for assembler flags when e.g. adding "-E" to
+ // flags while debugging something. That'd be somewhat inconvenient, and it's
+ // also inconsistent with most other flags -- we don't warn on
+ // -ffunction-sections not being used in -E mode either for example, even
+ // though it's not really used either.
+ if (!isa<AssembleJobAction>(JA)) {
+ // The args claimed here should match the args used in
+ // CollectArgsForIntegratedAssembler().
+ if (TC.useIntegratedAs()) {
+ Args.ClaimAllArgs(options::OPT_mrelax_all);
+ Args.ClaimAllArgs(options::OPT_mno_relax_all);
+ Args.ClaimAllArgs(options::OPT_mincremental_linker_compatible);
+ Args.ClaimAllArgs(options::OPT_mno_incremental_linker_compatible);
+ switch (C.getDefaultToolChain().getArch()) {
+ case llvm::Triple::arm:
+ case llvm::Triple::armeb:
+ case llvm::Triple::thumb:
+ case llvm::Triple::thumbeb:
+ Args.ClaimAllArgs(options::OPT_mimplicit_it_EQ);
+ default:
+ break;
+ }
+ }
+ Args.ClaimAllArgs(options::OPT_Wa_COMMA);
+ Args.ClaimAllArgs(options::OPT_Xassembler);
+ }
+
if (isa<AnalyzeJobAction>(JA)) {
assert(JA.getType() == types::TY_Plist && "Invalid output type.");
CmdArgs.push_back("-analyze");
OpenPOWER on IntegriCloud