Make sure to always check the result of
SourceManager::getPresumedLoc(), so that we don't try to make use of
an invalid presumed location. Doing so can cause crashes.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@118885 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Checker/AnalyzerStatsChecker.cpp b/lib/Checker/AnalyzerStatsChecker.cpp
index 9badb79..c484537 100644
--- a/lib/Checker/AnalyzerStatsChecker.cpp
+++ b/lib/Checker/AnalyzerStatsChecker.cpp
@@ -83,16 +83,18 @@
   llvm::SmallString<128> buf;
   llvm::raw_svector_ostream output(buf);
   PresumedLoc Loc = SM.getPresumedLoc(D->getLocation());
-  output << Loc.getFilename() << " : ";
+  if (Loc.isValid()) {
+    output << Loc.getFilename() << " : ";
 
-  if (isa<FunctionDecl>(D) || isa<ObjCMethodDecl>(D)) {
-    const NamedDecl *ND = cast<NamedDecl>(D);
-    output << ND;
+    if (isa<FunctionDecl>(D) || isa<ObjCMethodDecl>(D)) {
+      const NamedDecl *ND = cast<NamedDecl>(D);
+      output << ND;
+    }
+    else if (isa<BlockDecl>(D)) {
+      output << "block(line:" << Loc.getLine() << ":col:" << Loc.getColumn();
+    }
   }
-  else if (isa<BlockDecl>(D)) {
-    output << "block(line:" << Loc.getLine() << ":col:" << Loc.getColumn();
-  }
-
+  
   output << " -> Total CFGBlocks: " << total << " | Unreachable CFGBlocks: "
       << unreachable << " | Aborted Block: "
       << (Eng.wasBlockAborted() ? "yes" : "no")