]> granicus.if.org Git - clang/commitdiff
Initialize Column.
authorDevang Patel <dpatel@apple.com>
Mon, 10 May 2010 23:48:38 +0000 (23:48 +0000)
committerDevang Patel <dpatel@apple.com>
Mon, 10 May 2010 23:48:38 +0000 (23:48 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103448 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGDebugInfo.cpp

index 59b6b72ad528766b202ce92bf08862632b7cb296..cb6efe881c34632cfe3377bf11747c0bf7cc2d3d 100644 (file)
@@ -1530,15 +1530,21 @@ void CGDebugInfo::EmitDeclare(const BlockDeclRefExpr *BDRE, unsigned Tag,
     Ty = getOrCreateType(VD->getType(), Unit);
 
   // Get location information.
+  unsigned Line = 0;
+  unsigned Column = 0;
   SourceManager &SM = CGM.getContext().getSourceManager();
   PresumedLoc PLoc = SM.getPresumedLoc(VD->getLocation());
-  unsigned Line = 0;
-  if (!PLoc.isInvalid())
+  if (PLoc.isInvalid())
+    // If variable location is invalid then try current location.
+    PLoc = SM.getPresumedLoc(CurLoc);
+  if (!PLoc.isInvalid()) {
     Line = PLoc.getLine();
-  else
-    // If variable location is invalid, use current location to find 
-    // corresponding file info.
+    Column = PLoc.getColumn();
+  }
+  else {
+    // If current location is also invalid, then use main compile unit.
     Unit = getOrCreateFile(CurLoc);
+  }
 
   CharUnits offset = CGF->BlockDecls[VD];
   llvm::SmallVector<llvm::Value *, 9> addr;
@@ -1570,7 +1576,7 @@ void CGDebugInfo::EmitDeclare(const BlockDeclRefExpr *BDRE, unsigned Tag,
     DebugFactory.InsertDeclare(Storage, D, Builder.GetInsertBlock());
   
   llvm::MDNode *Scope = RegionStack.back();
-  Call->setDebugLoc(llvm::DebugLoc::get(Line, PLoc.getColumn(), Scope));
+  Call->setDebugLoc(llvm::DebugLoc::get(Line, Column, Scope));
 }
 
 void CGDebugInfo::EmitDeclareOfAutoVariable(const VarDecl *VD,