Skip to content

Commit f9088f1

Browse files
authored
[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.
1 parent 5ea945a commit f9088f1

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,8 @@ New features
247247

248248
Crash and bug fixes
249249
^^^^^^^^^^^^^^^^^^^
250+
- Fixed a crash in the static analyzer that when the expression in an
251+
``[[assume(expr)]]`` attribute was enclosed in parentheses. (#GH151529)
250252

251253
Improvements
252254
^^^^^^^^^^^^

clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1227,7 +1227,7 @@ void ExprEngine::VisitAttributedStmt(const AttributedStmt *A,
12271227

12281228
for (const auto *Attr : getSpecificAttrs<CXXAssumeAttr>(A->getAttrs())) {
12291229
for (ExplodedNode *N : CheckerPreStmt) {
1230-
Visit(Attr->getAssumption(), N, EvalSet);
1230+
Visit(Attr->getAssumption()->IgnoreParens(), N, EvalSet);
12311231
}
12321232
}
12331233

clang/test/Analysis/builtin_assume.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,16 @@ int using_builtin_assume_has_no_sideeffects(int y) {
6262

6363
return y;
6464
}
65+
66+
template <int ...args>
67+
bool issue151529() {
68+
// no-crash
69+
[[assume((true))]];
70+
// no-crash
71+
[[assume(((args >= 0) && ...))]]; // expected-warning {{pack fold expression is a C++17 extension}}
72+
return ((args >= 0) && ...); // expected-warning {{pack fold expression is a C++17 extension}}
73+
}
74+
75+
void instantiate_issue151529() {
76+
issue151529<0>();
77+
}

0 commit comments

Comments
 (0)