r219736 - DebugInfo: Lazily built static member variable declarations should use the canonical declaration for line/file information.

David Blaikie dblaikie at gmail.com
Tue Oct 14 15:22:17 PDT 2014


Author: dblaikie
Date: Tue Oct 14 17:22:17 2014
New Revision: 219736

URL: http://llvm.org/viewvc/llvm-project?rev=219736&view=rev
Log:
DebugInfo: Lazily built static member variable declarations should use the canonical declaration for line/file information.

When lazily constructing static member variable declarations (when
the vtable optimization fires and the definition of the type is omitted
(or built later, lazily), but the out of line definition of the static
member is provided and must be described in debug info) ensure we use
the canonical declaration when computing the file, line, etc for that
declaration (rather than the definition, which is also a declaration,
but not the canonical one).

Modified:
    cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
    cfe/trunk/test/CodeGenCXX/debug-info-static-member.cpp

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=219736&r1=219735&r2=219736&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Tue Oct 14 17:22:17 2014
@@ -895,6 +895,7 @@ CGDebugInfo::CreateRecordStaticField(con
                                      const RecordDecl* RD) {
   // Create the descriptor for the static variable, with or without
   // constant initializers.
+  Var = Var->getCanonicalDecl();
   llvm::DIFile VUnit = getOrCreateFile(Var->getLocation());
   llvm::DIType VTy = getOrCreateType(Var->getType(), VUnit);
 

Modified: cfe/trunk/test/CodeGenCXX/debug-info-static-member.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-static-member.cpp?rev=219736&r1=219735&r2=219736&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/debug-info-static-member.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/debug-info-static-member.cpp Tue Oct 14 17:22:17 2014
@@ -45,3 +45,13 @@ int main()
 // CHECK: metadata !{metadata !"0x34\00a\00{{.*}}", {{.*}} @_ZN1C1aE, metadata ![[DECL_A]]} ; [ DW_TAG_variable ] [a] {{.*}} [def]
 // CHECK: metadata !{metadata !"0x34\00b\00{{.*}}", {{.*}} @_ZN1C1bE, metadata ![[DECL_B]]} ; [ DW_TAG_variable ] [b] {{.*}} [def]
 // CHECK: metadata !{metadata !"0x34\00c\00{{.*}}", {{.*}} @_ZN1C1cE, metadata ![[DECL_C]]} ; [ DW_TAG_variable ] [c] {{.*}} [def]
+
+// Verify that even when a static member declaration is created lazily when
+// creating the definition, the declaration line is that of the canonical
+// declaration, not the definition.
+struct V {
+  virtual ~V(); // cause the definition of 'V' to be omitted by no-standalone-debug optimization
+  static const int const_va = 42;
+};
+// CHECK: ; [ DW_TAG_member ] [const_va] [line [[@LINE-2]],
+const int V::const_va;





More information about the cfe-commits mailing list