Skip to content

Commit 815013b

Browse files
Merge pull request #10620 from cachemeifyoucan/eng/PR-150238095
[lldb] Fix swift debugging with swift-extra-clang-flags
2 parents cb4c9cd + 737c43a commit 815013b

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

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

+12-2
Original file line numberDiff line numberDiff line change
@@ -1954,10 +1954,20 @@ void SwiftASTContext::AddExtraClangCC1Args(
19541954

19551955
void SwiftASTContext::AddUserClangArgs(TargetProperties &props) {
19561956
Args args(props.GetSwiftExtraClangFlags());
1957+
if (args.empty())
1958+
return;
1959+
19571960
std::vector<std::string> user_clang_flags;
1958-
for (const auto &arg : args.entries())
1961+
for (const auto &arg : args.entries()) {
1962+
if (arg.ref() == "--")
1963+
continue;
19591964
user_clang_flags.push_back(arg.ref().str());
1960-
AddExtraClangArgs(user_clang_flags, {}, {});
1965+
}
1966+
if (GetClangImporterOptions().DirectClangCC1ModuleBuild) {
1967+
llvm::append_range(GetClangImporterOptions().ExtraArgs, user_clang_flags);
1968+
} else {
1969+
AddExtraClangArgs(user_clang_flags, {}, {});
1970+
}
19611971
}
19621972

19631973
/// Turn relative paths in clang options into absolute paths based on

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

+2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ def test(self):
2020
lldb.SBFileSpec('main.swift'))
2121
log = self.getBuildArtifact("types.log")
2222
self.runCmd("settings set target.swift-clang-override-options +-DADDED=1")
23+
self.runCmd("settings set target.swift-extra-clang-flags -- -DEXTRA=1")
2324
self.expect('log enable lldb types -f "%s"' % log)
2425
self.expect("expression obj", DATA_TYPES_DISPLAYED_CORRECTLY,
2526
substrs=["b ="])
@@ -34,6 +35,7 @@ def test(self):
3435
# CHECK: SwiftASTContextForExpressions(module: "a", cu: "main.swift")::LogConfiguration() -- -F
3536
# CHECK-NEXT: SwiftASTContextForExpressions(module: "a", cu: "main.swift")::LogConfiguration() -- /FRAMEWORK_DIR
3637
# CHECK: SwiftASTContextForExpressions(module: "a", cu: "main.swift")::LogConfiguration() -- -DADDED=1
38+
# CHECK: SwiftASTContextForExpressions(module: "a", cu: "main.swift")::LogConfiguration() -- -DEXTRA=1
3739
# CHECK: SwiftASTContextForExpressions(module: "a", cu: "main.swift") Module import remark: loaded module 'ClangA'
3840
# CHECK-NOT: -cc1
3941
# CHECK-NOT: -fmodule-file-cache-key

0 commit comments

Comments
 (0)