Skip to content

Commit a027462

Browse files
committed
[LLDB] Filter out -Werror options when setting up -cc1 Clang Invocations
The non-caching code path was already doing this, but the code path for cc1 flags was missing this functionality. Even though LLDB is replaying the compile-time compiler invocation, we have seen reports where additional warnings get diagnosed at debug time, effectively rendering the debug session unusable. rdar://174422552
1 parent fb34fee commit a027462

3 files changed

Lines changed: 9 additions & 5 deletions

File tree

lldb/source/Plugins/TypeSystem/Swift/SwiftASTContext.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2112,12 +2112,15 @@ void SwiftASTContext::AddExtraClangCC1Args(
21122112
else
21132113
++it;
21142114
}
2115-
invocation.getFrontendOpts().ModuleFiles.erase(
2116-
llvm::remove_if(invocation.getFrontendOpts().ModuleFiles,
2117-
[&](const auto &mod) { return !CheckFileExists(mod); }),
2118-
invocation.getFrontendOpts().ModuleFiles.end());
2115+
llvm::erase_if(invocation.getFrontendOpts().ModuleFiles,
2116+
[&](const auto &mod) { return !CheckFileExists(mod); });
21192117
}
21202118

2119+
// Remove -Werror flags.
2120+
llvm::erase_if(
2121+
invocation.getDiagnosticOpts().Warnings,
2122+
[](StringRef Warning) { return Warning.starts_with("error"); });
2123+
21212124
invocation.generateCC1CommandLine(
21222125
[&](const llvm::Twine &arg) { dest.push_back(arg.str()); });
21232126

lldb/test/API/lang/swift/clangimporter/caching/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
SWIFT_SOURCES := main.swift
22
SWIFT_ENABLE_EXPLICIT_MODULES := YES
3-
SWIFTFLAGS_EXTRAS = -I$(SRCDIR) -I/TEST_DIR -F/FRAMEWORK_DIR -cache-compile-job -cas-path $(BUILDDIR)/cas
3+
SWIFTFLAGS_EXTRAS = -I$(SRCDIR) -I/TEST_DIR -F/FRAMEWORK_DIR -cache-compile-job -cas-path $(BUILDDIR)/cas -Xcc -Werror
44

55
all: a.out cas-config
66

lldb/test/API/lang/swift/clangimporter/caching/TestSwiftClangImporterCaching.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,6 @@ def test(self):
3434
# CHECK: SwiftASTContextForExpressions(module: "a", cu: "main.swift")::LogConfiguration() -- -DADDED=1
3535
# CHECK: SwiftASTContextForExpressions(module: "a", cu: "main.swift")::LogConfiguration() -- -DEXTRA=1
3636
# CHECK: SwiftASTContextForExpressions(module: "a", cu: "main.swift") Module import remark: loaded module 'ClangA'
37+
# CHECK-NOT: -Werror
3738
# CHECK-NOT: -cc1
3839
# CHECK-NOT: Clang error

0 commit comments

Comments
 (0)