aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/CGDebugInfo.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2010-11-11 20:45:16 +0000
committerDouglas Gregor <dgregor@apple.com>2010-11-11 20:45:16 +0000
commit8c457a8395676692225cd4c90bfb54d430199fdf (patch)
tree48cd1448d86044d3af8ca1870c34d46b01be1293 /lib/CodeGen/CGDebugInfo.cpp
parente0e6d3b5cf61dfefad3c0393f4786d2cf3d9c272 (diff)
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@118834 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGDebugInfo.cpp')
-rw-r--r--lib/CodeGen/CGDebugInfo.cpp16
1 files changed, 9 insertions, 7 deletions
diff --git a/lib/CodeGen/CGDebugInfo.cpp b/lib/CodeGen/CGDebugInfo.cpp
index 9229eeb85c..29276c3636 100644
--- a/lib/CodeGen/CGDebugInfo.cpp
+++ b/lib/CodeGen/CGDebugInfo.cpp
@@ -153,13 +153,14 @@ CGDebugInfo::getClassName(RecordDecl *RD) {
/// 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 @@ unsigned CGDebugInfo::getLineNumber(SourceLocation Loc) {
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 @@ unsigned CGDebugInfo::getColumnNumber(SourceLocation Loc) {
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() {
@@ -1653,7 +1654,8 @@ void CGDebugInfo::UpdateLineDirectiveRegion(CGBuilderTy &Builder) {
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.