Skip to content

Commit 9a6ad6f

Browse files
authored
Merge pull request #65069 from augusto2112/main-interop-debug-flags
Emit cxx interop into DW_AT_APPLE_flags
2 parents 6b3a17b + dbaf5e5 commit 9a6ad6f

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
@@ -560,13 +560,19 @@ class IRGenOptions {
560560
return OptMode == OptimizationMode::ForSize;
561561
}
562562

563-
std::string getDebugFlags(StringRef PrivateDiscriminator) const {
563+
std::string getDebugFlags(StringRef PrivateDiscriminator,
564+
bool EnableCXXInterop) const {
564565
std::string Flags = DebugFlags;
565566
if (!PrivateDiscriminator.empty()) {
566567
if (!Flags.empty())
567568
Flags += " ";
568569
Flags += ("-private-discriminator " + PrivateDiscriminator).str();
569570
}
571+
if (EnableCXXInterop) {
572+
if (!Flags.empty())
573+
Flags += " ";
574+
Flags += "-enable-experimental-cxx-interop";
575+
}
570576
return Flags;
571577
}
572578

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

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)