]> granicus.if.org Git - clang/commitdiff
[analyzer; alternate edges] - merge control edges where we descend to a subexpression...
authorTed Kremenek <kremenek@apple.com>
Sat, 4 May 2013 01:13:05 +0000 (01:13 +0000)
committerTed Kremenek <kremenek@apple.com>
Sat, 4 May 2013 01:13:05 +0000 (01:13 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181085 91177308-0d34-0410-b5e6-96231b3b80d8

lib/StaticAnalyzer/Core/BugReporter.cpp

index b3c0dac9646daa126e71077af0da3c0e96d19b7d..827bf09b05f31daa8329302b0c11d59d8afe2a70 100644 (file)
@@ -1802,6 +1802,26 @@ static bool optimizeEdges(PathPieces &path,
       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.