[cfe-commits] r57684 - in /cfe/trunk/lib/CodeGen: CGDebugInfo.cpp CGDebugInfo.h CGDecl.cpp CGStmt.cpp CodeGenFunction.cpp CodeGenModule.cpp

Daniel Dunbar daniel at zuster.org
Fri Oct 17 09:15:48 PDT 2008


Author: ddunbar
Date: Fri Oct 17 11:15:48 2008
New Revision: 57684

URL: http://llvm.org/viewvc/llvm-project?rev=57684&view=rev
Log:
Change CGDebugInfo::setLocation to just ignore invalid locations. This
simplifies clients.

Also, add assert that RegionStack is empty when the CGDebugInfo is
destroyed.

Modified:
    cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
    cfe/trunk/lib/CodeGen/CGDebugInfo.h
    cfe/trunk/lib/CodeGen/CGDecl.cpp
    cfe/trunk/lib/CodeGen/CGStmt.cpp
    cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
    cfe/trunk/lib/CodeGen/CodeGenModule.cpp

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=57684&r1=57683&r2=57684&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Fri Oct 17 11:15:48 2008
@@ -59,6 +59,8 @@
 
 CGDebugInfo::~CGDebugInfo()
 {
+  assert(RegionStack.empty() && "Region stack mismatch, stack not empty!");
+
   delete SR;
 
   // Free CompileUnitCache.
@@ -111,7 +113,8 @@
 }
 
 void CGDebugInfo::setLocation(SourceLocation loc) {
-  CurLoc = M->getContext().getSourceManager().getLogicalLoc(loc);
+  if (loc.isValid())
+    CurLoc = M->getContext().getSourceManager().getLogicalLoc(loc);
 }
 
 /// getCastValueFor - Return a llvm representation for a given debug information
@@ -711,6 +714,7 @@
   llvm::DebugInfoDesc *DID = RegionStack.back();
   Builder.CreateCall(RegionEndFn, getCastValueFor(DID), "");
   RegionStack.pop_back();
+  // FIXME: Should be freeing here?
 }
 
 /// EmitDeclare - Emit local variable declaration debug info.

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.h?rev=57684&r1=57683&r2=57684&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CGDebugInfo.h (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.h Fri Oct 17 11:15:48 2008
@@ -101,6 +101,8 @@
   CGDebugInfo(CodeGenModule *m);
   ~CGDebugInfo();
 
+  /// setLocation - Update the current source location. If \arg loc is
+  /// invalid it is ignored.
   void setLocation(SourceLocation loc);
 
   /// EmitStopPoint - Emit a call to llvm.dbg.stoppoint to indicate a change of

Modified: cfe/trunk/lib/CodeGen/CGDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDecl.cpp?rev=57684&r1=57683&r2=57684&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CGDecl.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDecl.cpp Fri Oct 17 11:15:48 2008
@@ -130,8 +130,7 @@
   // Emit global variable debug descriptor for static vars.
   CGDebugInfo *DI = CGM.getDebugInfo();
   if(DI) {
-    if(D.getLocation().isValid())
-      DI->setLocation(D.getLocation());
+    DI->setLocation(D.getLocation());
     DI->EmitGlobalVariable(static_cast<llvm::GlobalVariable *>(GV), &D);
   }
 
@@ -177,8 +176,7 @@
   // Emit debug info for local var declaration.
   CGDebugInfo *DI = CGM.getDebugInfo();
   if(DI) {
-    if(D.getLocation().isValid())
-      DI->setLocation(D.getLocation());
+    DI->setLocation(D.getLocation());
     DI->EmitDeclare(&D, llvm::dwarf::DW_TAG_auto_variable,
                     DeclPtr, Builder);
   }
@@ -235,8 +233,7 @@
   // Emit debug info for param declaration.
   CGDebugInfo *DI = CGM.getDebugInfo();
   if(DI) {
-    if(D.getLocation().isValid())
-      DI->setLocation(D.getLocation());
+    DI->setLocation(D.getLocation());
     DI->EmitDeclare(&D, llvm::dwarf::DW_TAG_arg_variable,
                     DeclPtr, Builder);
   }

Modified: cfe/trunk/lib/CodeGen/CGStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmt.cpp?rev=57684&r1=57683&r2=57684&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CGStmt.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGStmt.cpp Fri Oct 17 11:15:48 2008
@@ -33,10 +33,7 @@
   // executable code. So do not generate a stoppoint for that.
   CGDebugInfo *DI = CGM.getDebugInfo();
   if (DI && S->getStmtClass() != Stmt::CompoundStmtClass) {
-    if (S->getLocStart().isValid()) {
-        DI->setLocation(S->getLocStart());
-    }
-
+    DI->setLocation(S->getLocStart());
     DI->EmitStopPoint(CurFn, Builder);
   }
 
@@ -122,8 +119,7 @@
   // FIXME: handle vla's etc.
   CGDebugInfo *DI = CGM.getDebugInfo();
   if (DI) {
-    if (S.getLBracLoc().isValid())
-      DI->setLocation(S.getLBracLoc());
+    DI->setLocation(S.getLBracLoc());
     DI->EmitRegionStart(CurFn, Builder);
   }
 
@@ -132,8 +128,7 @@
     EmitStmt(*I);
 
   if (DI) {
-    if (S.getRBracLoc().isValid())
-      DI->setLocation(S.getRBracLoc());
+    DI->setLocation(S.getRBracLoc());
     DI->EmitRegionEnd(CurFn, Builder);
   }
 

Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?rev=57684&r1=57683&r2=57684&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp Fri Oct 17 11:15:48 2008
@@ -73,9 +73,7 @@
 
   // Emit debug descriptor for function end.
   if (CGDebugInfo *DI = CGM.getDebugInfo()) {
-    if (EndLoc.isValid()) {
-      DI->setLocation(EndLoc);
-    }
+    DI->setLocation(EndLoc);
     DI->EmitRegionEnd(CurFn, Builder);
   }
  
@@ -126,10 +124,8 @@
   // FIXME: The cast here is a huge hack.
   if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
     if (CGDebugInfo *DI = CGM.getDebugInfo()) {
-      CompoundStmt* body = dyn_cast<CompoundStmt>(FD->getBody());
-      if (body && body->getLBracLoc().isValid()) {
+      if (CompoundStmt* body = dyn_cast<CompoundStmt>(FD->getBody()))
         DI->setLocation(body->getLBracLoc());
-      }
       DI->EmitFunctionStart(FD, CurFn, Builder);
     }
   }

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=57684&r1=57683&r2=57684&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Fri Oct 17 11:15:48 2008
@@ -615,8 +615,7 @@
   // Emit global variable debug information.
   CGDebugInfo *DI = getDebugInfo();
   if(DI) {
-    if(D->getLocation().isValid())
-      DI->setLocation(D->getLocation());
+    DI->setLocation(D->getLocation());
     DI->EmitGlobalVariable(GV, D);
   }
 }





More information about the cfe-commits mailing list