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(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 +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>(); +}