Author: Yitzhak Mandelbaum
Date: 2022-03-15T15:10:32Z
New Revision: 4633c02eb0013ed38319b3fd708f59251bcd2aaf

URL: 
https://github.com/llvm/llvm-project/commit/4633c02eb0013ed38319b3fd708f59251bcd2aaf
DIFF: 
https://github.com/llvm/llvm-project/commit/4633c02eb0013ed38319b3fd708f59251bcd2aaf.diff

LOG: [clang][dataflow] Allow disabling built-in transfer functions for CFG 
terminators

Terminators are handled specially in the transfer functions so we need an
additional check on whether the analysis has disabled built-in transfer
functions.

Differential Revision: https://reviews.llvm.org/D121694

Added: 
    

Modified: 
    clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp 
b/clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
index 058922afd4838..6baf1a7fd42d6 100644
--- a/clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
+++ b/clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
@@ -170,6 +170,8 @@ static TypeErasedDataflowAnalysisState 
computeBlockInputState(
   }
 
   llvm::Optional<TypeErasedDataflowAnalysisState> MaybeState;
+  bool ApplyBuiltinTransfer = Analysis.applyBuiltinTransfer();
+
   for (const CFGBlock *Pred : Preds) {
     // Skip if the `Block` is unreachable or control flow cannot get past it.
     if (!Pred || Pred->hasNoReturnElement())
@@ -183,11 +185,13 @@ static TypeErasedDataflowAnalysisState 
computeBlockInputState(
       continue;
 
     TypeErasedDataflowAnalysisState PredState = MaybePredState.getValue();
-    if (const Stmt *PredTerminatorStmt = Pred->getTerminatorStmt()) {
-      const StmtToEnvMapImpl StmtToEnv(CFCtx, BlockStates);
-      TerminatorVisitor(StmtToEnv, PredState.Env,
-                        blockIndexInPredecessor(*Pred, Block))
-          .Visit(PredTerminatorStmt);
+    if (ApplyBuiltinTransfer) {
+      if (const Stmt *PredTerminatorStmt = Pred->getTerminatorStmt()) {
+        const StmtToEnvMapImpl StmtToEnv(CFCtx, BlockStates);
+        TerminatorVisitor(StmtToEnv, PredState.Env,
+                          blockIndexInPredecessor(*Pred, Block))
+            .Visit(PredTerminatorStmt);
+      }
     }
 
     if (MaybeState.hasValue()) {


        
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to