diff --git a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp --- a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp @@ -343,18 +343,6 @@ return FullyQualifiedName; } -std::string CodeViewDebug::getFullyQualifiedName(const DIScope *Scope, - StringRef Name) { - SmallVector QualifiedNameComponents; - collectParentScopeNames(Scope, QualifiedNameComponents); - return formatNestedName(QualifiedNameComponents, Name); -} - -std::string CodeViewDebug::getFullyQualifiedName(const DIScope *Ty) { - const DIScope *Scope = Ty->getScope(); - return getFullyQualifiedName(Scope, getPrettyScopeName(Ty)); -} - struct CodeViewDebug::TypeLoweringScope { TypeLoweringScope(CodeViewDebug &CVD) : CVD(CVD) { ++CVD.TypeEmissionLevel; } ~TypeLoweringScope() { @@ -367,6 +355,22 @@ CodeViewDebug &CVD; }; +std::string CodeViewDebug::getFullyQualifiedName(const DIScope *Scope, + StringRef Name) { + // Ensure types in the scope chain are emitted as soon as possible. + // This can create otherwise a situation where S_UDTs are emitted while + // looping in emitDebugInfoForUDTs. + TypeLoweringScope S(*this); + SmallVector QualifiedNameComponents; + collectParentScopeNames(Scope, QualifiedNameComponents); + return formatNestedName(QualifiedNameComponents, Name); +} + +std::string CodeViewDebug::getFullyQualifiedName(const DIScope *Ty) { + const DIScope *Scope = Ty->getScope(); + return getFullyQualifiedName(Scope, getPrettyScopeName(Ty)); +} + TypeIndex CodeViewDebug::getScopeIndex(const DIScope *Scope) { // No scope means global scope and that uses the zero index. if (!Scope || isa(Scope))