aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2013-03-11 20:51:52 +0000
committerTed Kremenek <kremenek@apple.com>2013-03-11 20:51:52 +0000
commitebf0f43f07e2fdc0e35554afb38f41c8be314b02 (patch)
treee475d5c708a9564f41867feace5b0694674caf98
parentebbd7e07aa0f22722da6ed8dd3a55beed9699171 (diff)
Disallow using -fmodules with -no-integrated-as.
Modules enables features such as auto-linking, and we simply do not want to support a matrix of subtly enabled/disabled features depending on whether or not a user is using the integrated assembler. It isn't clear if this is the best place to do this check. For one thing, these kind of errors are not caught by the serialized diagnostics. Fixes <rdar://problem/13289240> git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176826 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/Basic/DiagnosticDriverKinds.td7
-rw-r--r--lib/Driver/Tools.cpp16
-rw-r--r--test/Driver/modules_integrated_as.c4
3 files changed, 24 insertions, 3 deletions
diff --git a/include/clang/Basic/DiagnosticDriverKinds.td b/include/clang/Basic/DiagnosticDriverKinds.td
index 964d2bc193..469bae8dd4 100644
--- a/include/clang/Basic/DiagnosticDriverKinds.td
+++ b/include/clang/Basic/DiagnosticDriverKinds.td
@@ -75,7 +75,7 @@ def err_drv_invalid_libcxx_deployment : Error<
"invalid deployment target for -stdlib=libc++ (requires %0 or later)">;
def err_drv_invalid_feature : Error<
"invalid feature '%0' for CPU '%1'">;
-
+
def err_drv_I_dash_not_supported : Error<
"'%0' not supported, please use -iquote instead">;
def err_drv_unknown_argument : Error<"unknown argument: '%0'">;
@@ -150,4 +150,9 @@ def err_analyzer_config_no_value : Error<
"analyzer-config option '%0' has a key but no value">;
def err_analyzer_config_multiple_values : Error<
"analyzer-config option '%0' should contain only one '='">;
+
+def err_drv_modules_integrated_as : Error<
+ "modules can only be used with the compiler's integrated assembler">;
+def note_drv_modules_integrated_as : Note<
+ "'-no-integrated-as' cannot be used with '-fmodules'">;
}
diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp
index 62b1febd52..ef759ff6d3 100644
--- a/lib/Driver/Tools.cpp
+++ b/lib/Driver/Tools.cpp
@@ -1429,12 +1429,18 @@ static bool ShouldDisableCFI(const ArgList &Args,
Default);
}
-static bool ShouldDisableDwarfDirectory(const ArgList &Args,
- const ToolChain &TC) {
+static bool ShouldUseIntegratedAssembler(const ArgList &Args,
+ const ToolChain &TC) {
bool IsIADefault = TC.IsIntegratedAssemblerDefault();
bool UseIntegratedAs = Args.hasFlag(options::OPT_integrated_as,
options::OPT_no_integrated_as,
IsIADefault);
+ return UseIntegratedAs;
+}
+
+static bool ShouldDisableDwarfDirectory(const ArgList &Args,
+ const ToolChain &TC) {
+ bool UseIntegratedAs = ShouldUseIntegratedAssembler(Args, TC);
bool UseDwarfDirectory = Args.hasFlag(options::OPT_fdwarf_directory_asm,
options::OPT_fno_dwarf_directory_asm,
UseIntegratedAs);
@@ -2778,6 +2784,12 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
CmdArgs.push_back("-fmodules");
HaveModules = true;
}
+
+ if (HaveModules && !ShouldUseIntegratedAssembler(Args, getToolChain())) {
+ D.Diag(diag::err_drv_modules_integrated_as);
+ D.Diag(diag::note_drv_modules_integrated_as);
+ return;
+ }
}
// If a module path was provided, pass it along. Otherwise, use a temporary
diff --git a/test/Driver/modules_integrated_as.c b/test/Driver/modules_integrated_as.c
new file mode 100644
index 0000000000..037cdd0c3c
--- /dev/null
+++ b/test/Driver/modules_integrated_as.c
@@ -0,0 +1,4 @@
+// RUN: %clang -fmodules -no-integrated-as -fsyntax-only %s 2>&1 | FileCheck %s
+
+// CHECK: error: modules can only be used with the compiler's integrated assembler
+// CHECK note: '-no-integrated-as' cannot be used with '-fmodules'