================
@@ -337,26 +274,33 @@ computeBlockInputState(const CFGBlock &Block,
AnalysisContext &AC) {
AC.BlockStates[Pred->getBlockID()];
if (!MaybePredState)
continue;
-
- if (AC.Analysis.builtinOptions()) {
- if (const Stmt *PredTerminatorStmt = Pred->getTerminatorStmt()) {
- // We have a terminator: we need to mutate an environment to describe
- // when the terminator is taken. Copy now.
+ const TypeErasedDataflowAnalysisState &PredState = *MaybePredState;
+
+ if (const Stmt *PredTerminatorStmt = Pred->getTerminatorStmt()) {
----------------
martinboehme wrote:
I'd suggest doing the shorter case first, so this longer case can be indented
less:
```cxx
const Stmt *PredTerminatorStmt = Pred->getTerminatorStmt();
if (PredTerminatorStmt == nullptr) {
Builder.addUnowned(PredState);
continue;
}
```
Even better, introduce a short function `getTerminatorCondition()` that can
handle a null argument:
```cxx
const Expr *getTerminatorCondition(const Stmt *TerminatorStmt) {
if (TerminatorStmt == nullptr) return nullptr;
return TerminatorVisitor().Visit(TerminatorStmt);
}
```
Then you can do this:
```cxx
const Expr *TerminatorCond =
getTerminatorCondition(Pred->getTerminatorStmt());
if (TerminatorCond == nullptr) {
Builder.addUnowned(PredState);
continue;
}
```
https://github.com/llvm/llvm-project/pull/84499
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits