r181085 - [analyzer; alternate edges] - merge control edges where we descend to a subexpression and pop back out.

Ted Kremenek kremenek at apple.com
Fri May 3 18:13:05 PDT 2013


Author: kremenek
Date: Fri May  3 20:13:05 2013
New Revision: 181085

URL: http://llvm.org/viewvc/llvm-project?rev=181085&view=rev
Log:
[analyzer; alternate edges] - merge control edges where we descend to a subexpression and pop back out.

Modified:
    cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp?rev=181085&r1=181084&r2=181085&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp Fri May  3 20:13:05 2013
@@ -1802,6 +1802,26 @@ static bool optimizeEdges(PathPieces &pa
       hasChanges = true;
       continue;
     }
+
+    // Rule II.
+    //
+    // If we have two consecutive control edges where we decend to a
+    // subexpression and then pop out merge them.
+    //
+    // NOTE: this will be limited later in cases where we add barriers
+    // to prevent this optimization.
+    //
+    // For example:
+    //
+    // (1.1 -> 1.1.1) -> (1.1.1 -> 1.2) becomes (1.1 -> 1.2).
+    if (level1 && level2 &&
+        level1 == level4 &&
+        level2 == level3 && PM.getParent(level2) == level1) {
+      PieceI->setEndLocation(PieceNextI->getEndLocation());
+      path.erase(NextI);
+      hasChanges = true;
+      continue;
+    }
   }
 
   // No changes.





More information about the cfe-commits mailing list