Index: llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp =================================================================== --- llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp +++ llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp @@ -3350,11 +3350,13 @@ if (const auto *MemberDecl = dyn_cast_or_null( DIGV->getRawStaticDataMemberDeclaration())) Scope = MemberDecl->getScope(); - // For Fortran, the scoping portion is elided in its name so that we can - // reference the variable in the command line of the VS debugger. + // For static local variables and Fortran, the scoping portion is elided + // in its name so that we can reference the variable in the command line + // of the VS debugger. std::string QualifiedName = - (moduleIsInFortran()) ? std::string(DIGV->getName()) - : getFullyQualifiedName(Scope, DIGV->getName()); + (moduleIsInFortran() || isa(Scope)) + ? std::string(DIGV->getName()) + : getFullyQualifiedName(Scope, DIGV->getName()); if (const GlobalVariable *GV = CVGV.GVInfo.dyn_cast()) { Index: llvm/test/DebugInfo/COFF/global_visibility.ll =================================================================== --- llvm/test/DebugInfo/COFF/global_visibility.ll +++ llvm/test/DebugInfo/COFF/global_visibility.ll @@ -53,12 +53,12 @@ ; CHECK: } ; CHECK: DataSym { ; CHECK: Kind: S_LDATA32 (0x110C) -; CHECK: DisplayName: foo::local_int +; CHECK: DisplayName: local_int ; CHECK: LinkageName: ?local_int@?1??foo@@YAXXZ@4HA ; CHECK: } ; CHECK: DataSym { ; CHECK: Kind: S_LDATA32 (0x110C) -; CHECK: DisplayName: foo::nested_int +; CHECK: DisplayName: nested_int ; CHECK: LinkageName: ?nested_int@?1??foo@@YAXXZ@4HA ; CHECK: } ; CHECK: ProcEnd { @@ -74,12 +74,12 @@ ; CHECK: } ; CHECK: DataSym { ; CHECK: Kind: S_LDATA32 (0x110C) -; CHECK: DisplayName: bar::local_int +; CHECK: DisplayName: local_int ; CHECK: LinkageName: ?local_int@?1??bar@@YAXXZ@4HA ; CHECK: } ; CHECK: DataSym { ; CHECK: Kind: S_LDATA32 (0x110C) -; CHECK: DisplayName: bar::nested_int +; CHECK: DisplayName: nested_int ; CHECK: LinkageName: ?nested_int@?1??bar@@YAXXZ@4HA ; CHECK: } ; CHECK: ProcEnd {