Skip to content

Commit d966fd8

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 4bc9671 commit d966fd8

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
@@ -552,13 +552,19 @@ class IRGenOptions {
552552
return OptMode == OptimizationMode::ForSize;
553553
}
554554

555-
std::string getDebugFlags(StringRef PrivateDiscriminator) const {
555+
std::string getDebugFlags(StringRef PrivateDiscriminator,
556+
bool EnableCXXInterop) const {
556557
std::string Flags = DebugFlags;
557558
if (!PrivateDiscriminator.empty()) {
558559
if (!Flags.empty())
559560
Flags += " ";
560561
Flags += ("-private-discriminator " + PrivateDiscriminator).str();
561562
}
563+
if (EnableCXXInterop) {
564+
if (!Flags.empty())
565+
Flags += " ";
566+
Flags += "-enable-experimental-cxx-interop";
567+
}
562568
return Flags;
563569
}
564570

lib/IRGen/IRGenDebugInfo.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2001,9 +2001,11 @@ IRGenDebugInfoImpl::IRGenDebugInfoImpl(const IRGenOptions &Opts,
20012001
SDK = *It;
20022002
}
20032003

2004+
bool EnableCXXInterop =
2005+
IGM.getSILModule().getASTContext().LangOpts.EnableCXXInterop;
20042006
TheCU = DBuilder.createCompileUnit(
2005-
Lang, MainFile, Producer, Opts.shouldOptimize(), Opts.getDebugFlags(PD),
2006-
MajorRuntimeVersion, SplitName,
2007+
Lang, MainFile, Producer, Opts.shouldOptimize(),
2008+
Opts.getDebugFlags(PD, EnableCXXInterop), MajorRuntimeVersion, SplitName,
20072009
Opts.DebugInfoLevel > IRGenDebugInfoLevel::LineTables
20082010
? llvm::DICompileUnit::FullDebug
20092011
: 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)