Skip to content

Commit 71ec4db

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. rdar://97610458
1 parent aac83a9 commit 71ec4db

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

include/swift/AST/IRGenOptions.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -549,13 +549,19 @@ class IRGenOptions {
549549
return OptMode == OptimizationMode::ForSize;
550550
}
551551

552-
std::string getDebugFlags(StringRef PrivateDiscriminator) const {
552+
std::string getDebugFlags(StringRef PrivateDiscriminator,
553+
bool EnableCXXInterop) const {
553554
std::string Flags = DebugFlags;
554555
if (!PrivateDiscriminator.empty()) {
555556
if (!Flags.empty())
556557
Flags += " ";
557558
Flags += ("-private-discriminator " + PrivateDiscriminator).str();
558559
}
560+
if (EnableCXXInterop) {
561+
if (!Flags.empty())
562+
Flags += " ";
563+
Flags += "-enable-experimental-cxx-interop";
564+
}
559565
return Flags;
560566
}
561567

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()) {

0 commit comments

Comments
 (0)