[llvm-branch-commits] [cfe-branch] r119256 - /cfe/branches/Apple/whitney/lib/CodeGen/CGDebugInfo.cpp

Daniel Dunbar daniel at zuster.org
Mon Nov 15 13:46:27 PST 2010


Author: ddunbar
Date: Mon Nov 15 15:46:27 2010
New Revision: 119256

URL: http://llvm.org/viewvc/llvm-project?rev=119256&view=rev
Log:
Merge r118834:
--
Author: Douglas Gregor <dgregor at apple.com>
Date:   Thu Nov 11 20:45:16 2010 +0000

    Teach debug-info generation that SourceManager::getPresumedLoc() can
    produce an invalid location even when given a valid location, if the
    file system has changed underneath us. Recovery more gracefully.

Modified:
    cfe/branches/Apple/whitney/lib/CodeGen/CGDebugInfo.cpp

Modified: cfe/branches/Apple/whitney/lib/CodeGen/CGDebugInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/whitney/lib/CodeGen/CGDebugInfo.cpp?rev=119256&r1=119255&r2=119256&view=diff
==============================================================================
--- cfe/branches/Apple/whitney/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/branches/Apple/whitney/lib/CodeGen/CGDebugInfo.cpp Mon Nov 15 15:46:27 2010
@@ -153,13 +153,14 @@
 
 /// getOrCreateFile - Get the file debug info descriptor for the input location.
 llvm::DIFile CGDebugInfo::getOrCreateFile(SourceLocation Loc) {
-  if (!Loc.isValid())
-    // If Location is not valid then use main input file.
-    return DebugFactory.CreateFile(TheCU.getFilename(), TheCU.getDirectory(),
-                                   TheCU);
   SourceManager &SM = CGM.getContext().getSourceManager();
   PresumedLoc PLoc = SM.getPresumedLoc(Loc);
 
+  if (PLoc.isInvalid())
+    // If the location is not valid then use main input file.
+    return DebugFactory.CreateFile(TheCU.getFilename(), TheCU.getDirectory(),
+                                   TheCU);
+
   // Cache the results.
   const char *fname = PLoc.getFilename();
   llvm::DenseMap<const char *, llvm::WeakVH>::iterator it =
@@ -191,7 +192,7 @@
   assert (CurLoc.isValid() && "Invalid current location!");
   SourceManager &SM = CGM.getContext().getSourceManager();
   PresumedLoc PLoc = SM.getPresumedLoc(Loc.isValid() ? Loc : CurLoc);
-  return PLoc.getLine();
+  return PLoc.isValid()? PLoc.getLine() : 0;
 }
 
 /// getColumnNumber - Get column number for the location. If location is 
@@ -200,7 +201,7 @@
   assert (CurLoc.isValid() && "Invalid current location!");
   SourceManager &SM = CGM.getContext().getSourceManager();
   PresumedLoc PLoc = SM.getPresumedLoc(Loc.isValid() ? Loc : CurLoc);
-  return PLoc.getColumn();
+  return PLoc.isValid()? PLoc.getColumn() : 0;
 }
 
 llvm::StringRef CGDebugInfo::getCurrentDirname() {
@@ -1652,7 +1653,8 @@
   PresumedLoc PCLoc = SM.getPresumedLoc(CurLoc);
   PresumedLoc PPLoc = SM.getPresumedLoc(PrevLoc);
 
-  if (!strcmp(PPLoc.getFilename(), PCLoc.getFilename()))
+  if (PCLoc.isInvalid() || PPLoc.isInvalid() ||
+      !strcmp(PPLoc.getFilename(), PCLoc.getFilename()))
     return;
 
   // If #line directive stack is empty then we are entering a new scope.





More information about the llvm-branch-commits mailing list