[cfe-commits] r126246 - in /cfe/trunk: lib/CodeGen/CGClass.cpp test/CodeGenCXX/debug-info-limit.cpp

Devang Patel dpatel at apple.com
Tue Feb 22 12:55:26 PST 2011


Author: dpatel
Date: Tue Feb 22 14:55:26 2011
New Revision: 126246

URL: http://llvm.org/viewvc/llvm-project?rev=126246&view=rev
Log:
A constructor call should force class's debug info even if -flimit-debug-info is enabled.

Added:
    cfe/trunk/test/CodeGenCXX/debug-info-limit.cpp
Modified:
    cfe/trunk/lib/CodeGen/CGClass.cpp

Modified: cfe/trunk/lib/CodeGen/CGClass.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGClass.cpp?rev=126246&r1=126245&r2=126246&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGClass.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGClass.cpp Tue Feb 22 14:55:26 2011
@@ -17,6 +17,7 @@
 #include "clang/AST/EvaluatedExprVisitor.h"
 #include "clang/AST/RecordLayout.h"
 #include "clang/AST/StmtCXX.h"
+#include "clang/Frontend/CodeGenOptions.h"
 
 using namespace clang;
 using namespace CodeGen;
@@ -1140,6 +1141,16 @@
                                         llvm::Value *This,
                                         CallExpr::const_arg_iterator ArgBeg,
                                         CallExpr::const_arg_iterator ArgEnd) {
+
+  CGDebugInfo *DI = getDebugInfo();
+  if (DI && CGM.getCodeGenOpts().LimitDebugInfo) {
+    // If debug info for this class has been emitted then this is the right time
+    // to do so.
+    const CXXRecordDecl *Parent = D->getParent();
+    DI->getOrCreateRecordType(CGM.getContext().getTypeDeclType(Parent),
+                              Parent->getLocation());
+  }
+
   if (D->isTrivial()) {
     if (ArgBeg == ArgEnd) {
       // Trivial default constructor, no codegen required.

Added: cfe/trunk/test/CodeGenCXX/debug-info-limit.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-limit.cpp?rev=126246&view=auto
==============================================================================
--- cfe/trunk/test/CodeGenCXX/debug-info-limit.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/debug-info-limit.cpp Tue Feb 22 14:55:26 2011
@@ -0,0 +1,14 @@
+// RUN: %clang  -emit-llvm -g -S %s -o - | FileCheck %s
+
+// TAG_member is used to encode debug info for class constructor.
+// CHECK: TAG_member
+class A {
+public:
+  int z;
+};
+
+A *foo () {
+  A *a = new A();
+  return a;
+}
+





More information about the cfe-commits mailing list