mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
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
(cherry picked from commit b1dbb0a321)
This commit is contained in:
@@ -560,13 +560,19 @@ public:
|
||||
return OptMode == OptimizationMode::ForSize;
|
||||
}
|
||||
|
||||
std::string getDebugFlags(StringRef PrivateDiscriminator) const {
|
||||
std::string getDebugFlags(StringRef PrivateDiscriminator,
|
||||
bool EnableCXXInterop) const {
|
||||
std::string Flags = DebugFlags;
|
||||
if (!PrivateDiscriminator.empty()) {
|
||||
if (!Flags.empty())
|
||||
Flags += " ";
|
||||
Flags += ("-private-discriminator " + PrivateDiscriminator).str();
|
||||
}
|
||||
if (EnableCXXInterop) {
|
||||
if (!Flags.empty())
|
||||
Flags += " ";
|
||||
Flags += "-enable-experimental-cxx-interop";
|
||||
}
|
||||
return Flags;
|
||||
}
|
||||
|
||||
|
||||
@@ -2001,9 +2001,11 @@ IRGenDebugInfoImpl::IRGenDebugInfoImpl(const IRGenOptions &Opts,
|
||||
SDK = *It;
|
||||
}
|
||||
|
||||
bool EnableCXXInterop =
|
||||
IGM.getSILModule().getASTContext().LangOpts.EnableCXXInterop;
|
||||
TheCU = DBuilder.createCompileUnit(
|
||||
Lang, MainFile, Producer, Opts.shouldOptimize(), Opts.getDebugFlags(PD),
|
||||
MajorRuntimeVersion, SplitName,
|
||||
Lang, MainFile, Producer, Opts.shouldOptimize(),
|
||||
Opts.getDebugFlags(PD, EnableCXXInterop), MajorRuntimeVersion, SplitName,
|
||||
Opts.DebugInfoLevel > IRGenDebugInfoLevel::LineTables
|
||||
? llvm::DICompileUnit::FullDebug
|
||||
: llvm::DICompileUnit::LineTablesOnly,
|
||||
|
||||
@@ -124,13 +124,15 @@ static clang::CodeGenerator *createClangCodeGenerator(ASTContext &Context,
|
||||
case IRGenDebugInfoFormat::DWARF:
|
||||
CGO.DebugCompilationDir = Opts.DebugCompilationDir;
|
||||
CGO.DwarfVersion = Opts.DWARFVersion;
|
||||
CGO.DwarfDebugFlags = Opts.getDebugFlags(PD);
|
||||
CGO.DwarfDebugFlags =
|
||||
Opts.getDebugFlags(PD, Context.LangOpts.EnableCXXInterop);
|
||||
break;
|
||||
case IRGenDebugInfoFormat::CodeView:
|
||||
CGO.EmitCodeView = true;
|
||||
CGO.DebugCompilationDir = Opts.DebugCompilationDir;
|
||||
// This actually contains the debug flags for codeview.
|
||||
CGO.DwarfDebugFlags = Opts.getDebugFlags(PD);
|
||||
CGO.DwarfDebugFlags =
|
||||
Opts.getDebugFlags(PD, Context.LangOpts.EnableCXXInterop);
|
||||
break;
|
||||
}
|
||||
if (!Opts.TrapFuncName.empty()) {
|
||||
|
||||
5
test/DebugInfo/cxx_interop.swift
Normal file
5
test/DebugInfo/cxx_interop.swift
Normal file
@@ -0,0 +1,5 @@
|
||||
// Check that the "-enable-experimental-cxx-interop" is stored as a flag in the
|
||||
// Compile Unit.
|
||||
|
||||
// RUN: %target-swift-frontend -emit-ir -enable-experimental-cxx-interop -g %s -o - | %FileCheck %s
|
||||
// CHECK: !DICompileUnit({{.*}}flags: "-enable-experimental-cxx-interop"
|
||||
Reference in New Issue
Block a user