summaryrefslogtreecommitdiffstats
path: root/clang/lib/Driver
diff options
context:
space:
mode:
authorJohn Brawn <john.brawn@arm.com>2015-05-08 12:52:18 +0000
committerJohn Brawn <john.brawn@arm.com>2015-05-08 12:52:18 +0000
commita95c1a8315ed601fde152645abde2f0c0a337840 (patch)
treed9424b22c1cd4bc1df5cb1fc575a7d02eda560a6 /clang/lib/Driver
parent50ed9470dcd867c3341991bdc3fe704db43aae4d (diff)
downloadbcm5719-llvm-a95c1a8315ed601fde152645abde2f0c0a337840.tar.gz
bcm5719-llvm-a95c1a8315ed601fde152645abde2f0c0a337840.zip
[ARM] Give an error on invalid -march values
llvm::Triple::getARMCPUForArch now returns nullptr for invalid -march values, instead of silently translating it to arm7tdmi. Use this to give an error message, which is consistent with how gcc behaves. Differential Revision: http://reviews.llvm.org/D9602 llvm-svn: 236846
Diffstat (limited to 'clang/lib/Driver')
-rw-r--r--clang/lib/Driver/Tools.cpp15
1 files changed, 14 insertions, 1 deletions
diff --git a/clang/lib/Driver/Tools.cpp b/clang/lib/Driver/Tools.cpp
index a6f650c2cc3..88e42217102 100644
--- a/clang/lib/Driver/Tools.cpp
+++ b/clang/lib/Driver/Tools.cpp
@@ -743,6 +743,13 @@ static void getARMTargetFeatures(const Driver &D, const llvm::Triple &Triple,
if (const Arg *A = Args.getLastArg(options::OPT_mhwdiv_EQ))
getARMHWDivFeatures(D, A, Args, Features);
+ // -march is handled in getARMCPUForMarch by translating it into a CPU name,
+ // but it needs to return an empty string on invalid arguments. We therefore
+ // check and give an error here if the -march is invalid.
+ if (const Arg *A = Args.getLastArg(options::OPT_march_EQ))
+ if (!Triple.getARMCPUForArch(A->getValue()))
+ D.Diag(diag::err_drv_clang_unsupported) << A->getAsString(Args);
+
// Setting -msoft-float effectively disables NEON because of the GCC
// implementation, although the same isn't true of VFP or VFP3.
if (FloatABI == "soft") {
@@ -5619,7 +5626,13 @@ const char *arm::getARMCPUForMArch(const ArgList &Args,
}
}
- return Triple.getARMCPUForArch(MArch);
+ // We need to return an empty string here on invalid MArch values as the
+ // various places that call this function can't cope with a null result.
+ const char *result = Triple.getARMCPUForArch(MArch);
+ if (result)
+ return result;
+ else
+ return "";
}
/// getARMTargetCPU - Get the (LLVM) name of the ARM cpu we are targeting.
OpenPOWER on IntegriCloud