aboutsummaryrefslogtreecommitdiff
path: root/lib/Frontend/CompilerInvocation.cpp
diff options
context:
space:
mode:
authorWeiming Zhao <weimingz@codeaurora.org>2013-03-05 23:27:21 +0000
committerWeiming Zhao <weimingz@codeaurora.org>2013-03-05 23:27:21 +0000
commit46a2290c030597e26022fe2b535c8e4b0d30a765 (patch)
treeb2c62af6707798549500a3a4c1e15ef4664e66b7 /lib/Frontend/CompilerInvocation.cpp
parenteb8f69f094e95d0132e4a6817a2111ad188ab087 (diff)
PR 11326: Lack diagnosic message when ABI conflicts on ARM
When both Triple and -mabi are used, it may result into conflicting ABI value. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176531 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Frontend/CompilerInvocation.cpp')
-rw-r--r--lib/Frontend/CompilerInvocation.cpp20
1 files changed, 18 insertions, 2 deletions
diff --git a/lib/Frontend/CompilerInvocation.cpp b/lib/Frontend/CompilerInvocation.cpp
index d856c31a05..9cf4f3bcbd 100644
--- a/lib/Frontend/CompilerInvocation.cpp
+++ b/lib/Frontend/CompilerInvocation.cpp
@@ -1471,7 +1471,8 @@ static void ParsePreprocessorOutputArgs(PreprocessorOutputOptions &Opts,
Opts.RewriteIncludes = Args.hasArg(OPT_frewrite_includes);
}
-static void ParseTargetArgs(TargetOptions &Opts, ArgList &Args) {
+static void ParseTargetArgs(TargetOptions &Opts, ArgList &Args,
+ DiagnosticsEngine &Diags) {
using namespace options;
Opts.ABI = Args.getLastArgValue(OPT_target_abi);
Opts.CXXABI = Args.getLastArgValue(OPT_cxx_abi);
@@ -1483,6 +1484,21 @@ static void ParseTargetArgs(TargetOptions &Opts, ArgList &Args) {
// Use the default target triple if unspecified.
if (Opts.Triple.empty())
Opts.Triple = llvm::sys::getDefaultTargetTriple();
+
+ // Check if Opts.ABI conflicts with the environment of triple on ARM.
+ llvm::Triple T(Opts.Triple);
+ if (T.getArch() == llvm::Triple::arm && !Opts.ABI.empty() &&
+ !T.getEnvironmentName().empty()) {
+ llvm::Triple::EnvironmentType env = T.getEnvironment();
+ // Env and ABI (Triple::EnvironmentType and ARMABIInfo::ABIKind) are not
+ // 1-to-1 mapping. Later on, Env will be overrided by ABI option when
+ // computing ARMABIInfo.
+ bool isOpsEABI = StringRef(Opts.ABI).startswith("aapcs");
+ bool isEnvEABI = (env == llvm::Triple::GNUEABI || env == llvm::Triple::EABI
+ || env == llvm::Triple::Android);
+ if (isEnvEABI != isOpsEABI)
+ Diags.Report(diag::warn_target_override_abi) << T.getEnvironmentName();
+ }
}
//
@@ -1547,7 +1563,7 @@ bool CompilerInvocation::CreateFromArgs(CompilerInvocation &Res,
ParsePreprocessorArgs(Res.getPreprocessorOpts(), *Args, FileMgr, Diags);
ParsePreprocessorOutputArgs(Res.getPreprocessorOutputOpts(), *Args,
Res.getFrontendOpts().ProgramAction);
- ParseTargetArgs(Res.getTargetOpts(), *Args);
+ ParseTargetArgs(Res.getTargetOpts(), *Args, Diags);
return Success;
}