Merge pull request #13293 from adrian-prantl/35714074
diff --git a/include/swift/ClangImporter/ClangImporterOptions.h b/include/swift/ClangImporter/ClangImporterOptions.h
index 9084770..b688dba 100644
--- a/include/swift/ClangImporter/ClangImporterOptions.h
+++ b/include/swift/ClangImporter/ClangImporterOptions.h
@@ -97,6 +97,9 @@
/// When set, don't look for or load adapter modules.
bool DisableAdapterModules = false;
+ /// When set, don't enforce warnings with -Werror.
+ bool DebuggerSupport = false;
+
/// Return a hash code of any components from these options that should
/// contribute to a Swift Bridging PCH hash.
llvm::hash_code getPCHHashComponents() const {
diff --git a/lib/ClangImporter/ClangImporter.cpp b/lib/ClangImporter/ClangImporter.cpp
index 241f9ce..fa05e4f 100644
--- a/lib/ClangImporter/ClangImporter.cpp
+++ b/lib/ClangImporter/ClangImporter.cpp
@@ -446,11 +446,6 @@
// Construct the invocation arguments for the current target.
// Add target-independent options first.
invocationArgStrs.insert(invocationArgStrs.end(), {
- // Enable modules
- "-fmodules",
- "-Werror=non-modular-include-in-framework-module",
- "-Xclang", "-fmodule-feature", "-Xclang", "swift",
-
// Don't emit LLVM IR.
"-fsyntax-only",
@@ -464,6 +459,18 @@
SHIMS_INCLUDE_FLAG, searchPathOpts.RuntimeResourcePath,
});
+ // Enable modules.
+ invocationArgStrs.insert(invocationArgStrs.end(), {
+ "-fmodules",
+ "-Xclang", "-fmodule-feature", "-Xclang", "swift"
+ });
+ // Don't enforce strict rules when inside the debugger to work around search
+ // path problems caused by a module existing in both the build/install
+ // directory and the source directory.
+ if (!importerOpts.DebuggerSupport)
+ invocationArgStrs.push_back(
+ "-Werror=non-modular-include-in-framework-module");
+
if (LangOpts.EnableObjCInterop) {
invocationArgStrs.insert(invocationArgStrs.end(),
{"-x", "objective-c", "-std=gnu11", "-fobjc-arc"});
diff --git a/lib/Frontend/CompilerInvocation.cpp b/lib/Frontend/CompilerInvocation.cpp
index 7772da4..3aef06d 100644
--- a/lib/Frontend/CompilerInvocation.cpp
+++ b/lib/Frontend/CompilerInvocation.cpp
@@ -1234,6 +1234,7 @@
Opts.PCHDisableValidation |= Args.hasArg(OPT_pch_disable_validation);
}
+ Opts.DebuggerSupport |= Args.hasArg(OPT_debugger_support);
return false;
}
diff --git a/test/ClangImporter/non-modular-include.swift b/test/ClangImporter/non-modular-include.swift
index 9c8a07a..9db78b3 100644
--- a/test/ClangImporter/non-modular-include.swift
+++ b/test/ClangImporter/non-modular-include.swift
@@ -6,6 +6,11 @@
// CHECK-native: error: could not build C module 'Foo'
// CHECK-NOT: error
+// RUN: %target-swift-frontend -debugger-support -typecheck %s -I %S/Inputs/non-modular -F %S/Inputs/non-modular 2>&1 | %FileCheck --allow-empty --check-prefix=CHECK-DEBUGGER %s
+
+// CHECK-DEBUGGER-NOT: error:
+
+
import Foo
_ = Foo.x