r363335 - Use fully qualified name when printing S_CONSTANT records

Amy Huang via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 13 15:53:43 PDT 2019


Author: akhuang
Date: Thu Jun 13 15:53:43 2019
New Revision: 363335

URL: http://llvm.org/viewvc/llvm-project?rev=363335&view=rev
Log:
Use fully qualified name when printing S_CONSTANT records

Summary:
Before it was using the fully qualified name only for static data members.
Now it does for all variable names to match MSVC.

Reviewers: rnk

Subscribers: hiraditya, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D63012

Modified:
    cfe/trunk/lib/CodeGen/CGDebugInfo.cpp

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=363335&r1=363334&r2=363335&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Thu Jun 13 15:53:43 2019
@@ -4361,13 +4361,18 @@ void CGDebugInfo::EmitGlobalVariable(con
   StringRef Name = VD->getName();
   llvm::DIType *Ty = getOrCreateType(VD->getType(), Unit);
 
-  // Do not use global variables for enums, unless for CodeView.
+  // Do not use global variables for enums, unless in CodeView.
   if (const auto *ECD = dyn_cast<EnumConstantDecl>(VD)) {
     const auto *ED = cast<EnumDecl>(ECD->getDeclContext());
     assert(isa<EnumType>(ED->getTypeForDecl()) && "Enum without EnumType?");
     (void)ED;
 
-    if (!CGM.getCodeGenOpts().EmitCodeView)
+    // If CodeView, emit enums as global variables, unless they are defined
+    // inside a class. We do this because MSVC doesn't emit S_CONSTANTs for
+    // enums in classes, and because it is difficult to attach this scope
+    // information to the global variable.
+    if (!CGM.getCodeGenOpts().EmitCodeView ||
+        isa<RecordDecl>(ED->getDeclContext()))
       return;
   }
 




More information about the cfe-commits mailing list