[clang] [analyzer] Handle [[assume(cond)]] as __builtin_assume(cond) (PR #116462)
Vinay Deshmukh via cfe-commits
cfe-commits at lists.llvm.org
Mon Nov 18 18:22:34 PST 2024
================
@@ -1200,3 +1200,20 @@ void ExprEngine::VisitLambdaExpr(const LambdaExpr *LE, ExplodedNode *Pred,
// FIXME: Move all post/pre visits to ::Visit().
getCheckerManager().runCheckersForPostStmt(Dst, Tmp, LE, *this);
}
+
+void ExprEngine::VisitAttributedStmt(const AttributedStmt *A,
+ ExplodedNode *Pred, ExplodedNodeSet &Dst) {
+ ExplodedNodeSet CheckerPreStmt;
+ getCheckerManager().runCheckersForPreStmt(CheckerPreStmt, Pred, A, *this);
+
+ ExplodedNodeSet EvalSet;
+ StmtNodeBuilder Bldr(CheckerPreStmt, EvalSet, *currBldrCtx);
+
+ if (const auto *AssumeAttr = getSpecificAttr<CXXAssumeAttr>(A->getAttrs())) {
----------------
vinay-deshmukh wrote:
@steakhal
Q:
As this is a `if()` instead of `for(const auto *AssumeAttr: A->getAttrs())`, won't it ignore the `assume()` expressions _after_ the first one? Should we restore the for loop so the ExprEngine processes all `assume()` attributes?
i.e. this change: https://github.com/llvm/llvm-project/commit/7f1e341e59a52017d9f73ab09e1be45444536731
Before:
https://github.com/llvm/llvm-project/blob/daddb9e13db6ca8373dc7298d17aa36a03014aeb/clang/lib/Analysis/CFG.cpp#L469-L479
After:
https://github.com/llvm/llvm-project/blob/7f1e341e59a52017d9f73ab09e1be45444536731/clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp#L1212-L1216
https://github.com/llvm/llvm-project/pull/116462
More information about the cfe-commits
mailing list