Author: Iris Shi Date: 2025-08-01T19:29:06+08:00 New Revision: f9088f1eb5647cafb63b6cd42df339e19735d9c6
URL: https://github.com/llvm/llvm-project/commit/f9088f1eb5647cafb63b6cd42df339e19735d9c6 DIFF: https://github.com/llvm/llvm-project/commit/f9088f1eb5647cafb63b6cd42df339e19735d9c6.diff LOG: [static analyzer] Fix crash on parenthesized expression in assume attribute (#151682) - Closes #151529 `ParenExpr` should be ignored before reaching `ExprEngine::Visit`. Failing to do so triggers the assertion. Added: Modified: clang/docs/ReleaseNotes.rst clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp clang/test/Analysis/builtin_assume.cpp Removed: ################################################################################ diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 4a2edae7509de..20cadbfd00d42 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -247,6 +247,8 @@ New features Crash and bug fixes ^^^^^^^^^^^^^^^^^^^ +- Fixed a crash in the static analyzer that when the expression in an + ``[[assume(expr)]]`` attribute was enclosed in parentheses. (#GH151529) Improvements ^^^^^^^^^^^^ diff --git a/clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp b/clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp index 85353848aa124..fe70558dfc45c 100644 --- a/clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp +++ b/clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp @@ -1227,7 +1227,7 @@ void ExprEngine::VisitAttributedStmt(const AttributedStmt *A, for (const auto *Attr : getSpecificAttrs<CXXAssumeAttr>(A->getAttrs())) { for (ExplodedNode *N : CheckerPreStmt) { - Visit(Attr->getAssumption(), N, EvalSet); + Visit(Attr->getAssumption()->IgnoreParens(), N, EvalSet); } } diff --git a/clang/test/Analysis/builtin_assume.cpp b/clang/test/Analysis/builtin_assume.cpp index 7158306be2b82..29a96c09d53ea 100644 --- a/clang/test/Analysis/builtin_assume.cpp +++ b/clang/test/Analysis/builtin_assume.cpp @@ -62,3 +62,16 @@ int using_builtin_assume_has_no_sideeffects(int y) { return y; } + +template <int ...args> +bool issue151529() { + // no-crash + [[assume((true))]]; + // no-crash + [[assume(((args >= 0) && ...))]]; // expected-warning {{pack fold expression is a C++17 extension}} + return ((args >= 0) && ...); // expected-warning {{pack fold expression is a C++17 extension}} +} + +void instantiate_issue151529() { + issue151529<0>(); +} _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
