[cfe-commits] r69813 - /cfe/trunk/lib/Analysis/BugReporter.cpp

Ted Kremenek kremenek at apple.com
Wed Apr 22 11:16:20 PDT 2009


Author: kremenek
Date: Wed Apr 22 13:16:20 2009
New Revision: 69813

URL: http://llvm.org/viewvc/llvm-project?rev=69813&view=rev
Log:
BugReporter (extensive diagnostic algorithm): The initial control-flow edge now
starts from the first character of the first statement.

Modified:
    cfe/trunk/lib/Analysis/BugReporter.cpp

Modified: cfe/trunk/lib/Analysis/BugReporter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/BugReporter.cpp?rev=69813&r1=69812&r2=69813&view=diff

==============================================================================
--- cfe/trunk/lib/Analysis/BugReporter.cpp (original)
+++ cfe/trunk/lib/Analysis/BugReporter.cpp Wed Apr 22 13:16:20 2009
@@ -796,8 +796,9 @@
 public:
   EdgeBuilder(PathDiagnostic &pd, PathDiagnosticBuilder &pdb)
     : PD(pd), PDB(pdb) {
-      CLocs.push_back(PathDiagnosticLocation(&PDB.getCodeDecl(),
-                                             PDB.getSourceManager()));
+      
+      // If the PathDiagnostic already has pieces, add the enclosing statement
+      // of the first piece as a context as well.
       if (!PD.empty()) {
         PrevLoc = PD.begin()->getLocation();
         
@@ -808,6 +809,15 @@
 
   ~EdgeBuilder() {
     while (!CLocs.empty()) popLocation();
+    
+    // Finally, add an initial edge from the start location of the first
+    // statement (if it doesn't already exist).
+    if (const CompoundStmt *CS = PDB.getCodeDecl().getBody(PDB.getContext()))
+      if (!CS->body_empty()) {
+        SourceLocation Loc = (*CS->body_begin())->getLocStart();
+        rawAddEdge(PathDiagnosticLocation(Loc, PDB.getSourceManager()));
+      }
+    
   }
 
   void addEdge(PathDiagnosticLocation NewLoc, bool alwaysAdd = false);
@@ -907,6 +917,10 @@
 }
 
 void EdgeBuilder::addEdge(PathDiagnosticLocation NewLoc, bool alwaysAdd) {
+  
+  if (!alwaysAdd && NewLoc.asLocation().isMacroID())
+    return;
+  
   const PathDiagnosticLocation &CLoc = getContextLocation(NewLoc);
 
   while (!CLocs.empty()) {





More information about the cfe-commits mailing list