Skip to content

Commit b1dbb0a

Browse files
committed
Emit cxx interop into DW_AT_APPLE_flags
When compiling with interop enabled, emit the C++ interop compiler flag into the DW_AT_APPLE_flags, to make it so LLDB can accurately match the C++ interop mode when initializing its compiler instance. rdar://97610458
1 parent 5d11e9f commit b1dbb0a

File tree

4 files changed

+20
-5
lines changed

4 files changed

+20
-5
lines changed

include/swift/AST/IRGenOptions.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -557,13 +557,19 @@ class IRGenOptions {
557557
return OptMode == OptimizationMode::ForSize;
558558
}
559559

560-
std::string getDebugFlags(StringRef PrivateDiscriminator) const {
560+
std::string getDebugFlags(StringRef PrivateDiscriminator,
561+
bool EnableCXXInterop) const {
561562
std::string Flags = DebugFlags;
562563
if (!PrivateDiscriminator.empty()) {
563564
if (!Flags.empty())
564565
Flags += " ";
565566
Flags += ("-private-discriminator " + PrivateDiscriminator).str();
566567
}
568+
if (EnableCXXInterop) {
569+
if (!Flags.empty())
570+
Flags += " ";
571+
Flags += "-enable-experimental-cxx-interop";
572+
}
567573
return Flags;
568574
}
569575

lib/IRGen/IRGenDebugInfo.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1986,9 +1986,11 @@ IRGenDebugInfoImpl::IRGenDebugInfoImpl(const IRGenOptions &Opts,
19861986
SDK = *It;
19871987
}
19881988

1989+
bool EnableCXXInterop =
1990+
IGM.getSILModule().getASTContext().LangOpts.EnableCXXInterop;
19891991
TheCU = DBuilder.createCompileUnit(
1990-
Lang, MainFile, Producer, Opts.shouldOptimize(), Opts.getDebugFlags(PD),
1991-
MajorRuntimeVersion, SplitName,
1992+
Lang, MainFile, Producer, Opts.shouldOptimize(),
1993+
Opts.getDebugFlags(PD, EnableCXXInterop), MajorRuntimeVersion, SplitName,
19921994
Opts.DebugInfoLevel > IRGenDebugInfoLevel::LineTables
19931995
? llvm::DICompileUnit::FullDebug
19941996
: llvm::DICompileUnit::LineTablesOnly,

lib/IRGen/IRGenModule.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,13 +124,15 @@ static clang::CodeGenerator *createClangCodeGenerator(ASTContext &Context,
124124
case IRGenDebugInfoFormat::DWARF:
125125
CGO.DebugCompilationDir = Opts.DebugCompilationDir;
126126
CGO.DwarfVersion = Opts.DWARFVersion;
127-
CGO.DwarfDebugFlags = Opts.getDebugFlags(PD);
127+
CGO.DwarfDebugFlags =
128+
Opts.getDebugFlags(PD, Context.LangOpts.EnableCXXInterop);
128129
break;
129130
case IRGenDebugInfoFormat::CodeView:
130131
CGO.EmitCodeView = true;
131132
CGO.DebugCompilationDir = Opts.DebugCompilationDir;
132133
// This actually contains the debug flags for codeview.
133-
CGO.DwarfDebugFlags = Opts.getDebugFlags(PD);
134+
CGO.DwarfDebugFlags =
135+
Opts.getDebugFlags(PD, Context.LangOpts.EnableCXXInterop);
134136
break;
135137
}
136138
if (!Opts.TrapFuncName.empty()) {

test/DebugInfo/cxx_interop.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// Check that the "-enable-experimental-cxx-interop" is stored as a flag in the
2+
// Compile Unit.
3+
4+
// RUN: %target-swift-frontend -emit-ir -enable-experimental-cxx-interop -g %s -o - | %FileCheck %s
5+
// CHECK: !DICompileUnit({{.*}}flags: "-enable-experimental-cxx-interop"

0 commit comments

Comments
 (0)