[PATCH] D131400: [CodeView] Use non-qualified names for static local variables

Steve Merritt via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 8 08:05:37 PDT 2022


smerritt created this revision.
smerritt added reviewers: rnk, akhuang, bwyma, ykhatav.
Herald added a subscriber: hiraditya.
Herald added a project: All.
smerritt requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Static variables declared within a routine or lexical block should be emitted with a non-qualified name.  This allows the variables to be visible to the Visual Studio watch window.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D131400

Files:
  llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
  llvm/test/DebugInfo/COFF/global_visibility.ll


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 at 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 at 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 at 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 at 4HA
 ; CHECK:     }
 ; CHECK:     ProcEnd {
Index: llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
===================================================================
--- llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
+++ llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
@@ -3353,8 +3353,9 @@
   // 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.
   std::string QualifiedName =
-      (moduleIsInFortran()) ? std::string(DIGV->getName())
-                            : getFullyQualifiedName(Scope, DIGV->getName());
+      (moduleIsInFortran() || isa<DILocalScope>(Scope))
+          ? std::string(DIGV->getName())
+          : getFullyQualifiedName(Scope, DIGV->getName());
 
   if (const GlobalVariable *GV =
           CVGV.GVInfo.dyn_cast<const GlobalVariable *>()) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D131400.450807.patch
Type: text/x-patch
Size: 2052 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220808/f37acf2a/attachment.bin>


More information about the llvm-commits mailing list