Skip to content

Commit 9c2a1f2

Browse files
[lldb] Allow swift-clang-override-options setting when using cc1 args
When using swift caching or direct cc1 mode, allow using setting to override clang arguments. Even this override option directly applies to cc1 arguments, not clang driver arguments, thus is a behavior change, but it can be handy for debugging or working around issues.
1 parent c7207cd commit 9c2a1f2

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1801,11 +1801,11 @@ void SwiftASTContext::AddExtraClangArgs(
18011801
importer_options.DirectClangCC1ModuleBuild = invocation_direct_cc1;
18021802

18031803
// If using direct cc1 flags, compute the arguments and return.
1804-
// Since this is cc1 flags, override options are driver flags and don't apply.
18051804
if (importer_options.DirectClangCC1ModuleBuild) {
18061805
if (!fresh_invocation)
18071806
importer_options.ExtraArgs.clear();
18081807
AddExtraClangCC1Args(ExtraArgs, importer_options.ExtraArgs);
1808+
applyOverrideOptions(importer_options.ExtraArgs, overrideOpts);
18091809
return;
18101810
}
18111811

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,14 @@ def test(self):
2121
lldbutil.run_to_source_breakpoint(self, "break here",
2222
lldb.SBFileSpec('main.swift'))
2323
log = self.getBuildArtifact("types.log")
24+
self.runCmd("settings set target.swift-clang-override-options +-DADDED=1")
2425
self.expect('log enable lldb types -f "%s"' % log)
2526
self.expect("expression obj", DATA_TYPES_DISPLAYED_CORRECTLY,
2627
substrs=["b ="])
2728
self.filecheck('platform shell cat "%s"' % log, __file__)
2829
### -cc1 should be round-tripped so there is no more `-cc1` in the extra args. Look for `-triple` which is a cc1 flag.
2930
# CHECK: SwiftASTContextForExpressions(module: "a", cu: "main.swift")::LogConfiguration() -- -triple
31+
# CHECK: SwiftASTContextForExpressions(module: "a", cu: "main.swift")::LogConfiguration() -- -DADDED=1
3032
# CHECK: SwiftASTContextForExpressions(module: "a", cu: "main.swift") Module import remark: loaded module 'ClangA'
3133
# CHECK-NOT: -cc1
3234
# CHECK-NOT: -fmodule-file-cache-key

0 commit comments

Comments
 (0)