Wire up mangled macro names in debug info.

rdar://104894694
This commit is contained in:
Adrian Prantl
2023-02-01 14:43:46 -08:00
parent 168027b6bd
commit 5ff139dd6e
6 changed files with 22 additions and 15 deletions

View File

@@ -163,8 +163,8 @@ DeclName SILGenModule::getMagicFunctionName(SILDeclRef ref) {
void SILGenFunction::enterDebugScope(SILLocation Loc, bool isBindingScope,
Optional<SILLocation> MacroExpansion,
DeclNameRef MacroName,
DeclNameLoc MacroNameLoc) {
StringRef MacroName,
Optional<SILLocation> MacroLoc) {
auto *Parent = DebugScopeStack.size() ? DebugScopeStack.back().getPointer()
: F.getDebugScope();
auto *Scope = Parent;
@@ -172,7 +172,7 @@ void SILGenFunction::enterDebugScope(SILLocation Loc, bool isBindingScope,
if (RegularLocation(Parent->getLoc()) != RegularLocation(Loc)) {
SILDebugScope *InlinedAt = nullptr;
// Create an inline scope for a macro expansion.
if (MacroExpansion && MacroName && MacroNameLoc.isValid()) {
if (MacroExpansion && !MacroName.empty() && MacroLoc) {
InlinedAt = new (SGM.M) SILDebugScope(RegularLocation(*MacroExpansion),
&getFunction(), Parent);
SILGenFunctionBuilder B(SGM);
@@ -183,10 +183,9 @@ void SILGenFunction::enterDebugScope(SILLocation Loc, bool isBindingScope,
/*Results*/ {}, None, SubstitutionMap(), SubstitutionMap(),
SGM.M.getASTContext());
SILFunction *MacroFn = B.getOrCreateFunction(
Loc, MacroName.getBaseIdentifier().str(),
SILLinkage::DefaultForDeclaration, FunctionType, IsNotBare,
IsNotTransparent, IsNotSerialized, IsNotDynamic, IsNotDistributed,
IsNotRuntimeAccessible);
*MacroLoc, MacroName, SILLinkage::DefaultForDeclaration, FunctionType,
IsNotBare, IsNotTransparent, IsNotSerialized, IsNotDynamic,
IsNotDistributed, IsNotRuntimeAccessible);
auto MacroScope = new (SGM.M) SILDebugScope(Loc, MacroFn);
Parent = MacroScope;
}