Skip to content

Commit fa6335d

Browse files
committed
[static analyzer] Fix crash on parenthesized expression in assume attribute
1 parent 5146917 commit fa6335d

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,8 @@ Bug Fixes to Attribute Support
148148

149149
- ``[[nodiscard]]`` is now respected on Objective-C and Objective-C++ methods.
150150
(#GH141504)
151+
- Fixed a crash in the static analyzer that when the expression in an
152+
``[[assume(expr)]]`` attribute was enclosed in parentheses. (#GH151529)
151153

152154
Bug Fixes to C++ Support
153155
^^^^^^^^^^^^^^^^^^^^^^^^

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// RUN: %clang_analyze_cc1 -std=c++23 -analyzer-checker=cplusplus -verify %s
2+
// expected-no-diagnostics
3+
4+
template <int ...args>
5+
bool issue151529()
6+
{
7+
[[assume (((args >= 0) && ...))]];
8+
return ((args >= 0) && ...);
9+
}
10+
11+
int main() {
12+
issue151529();
13+
[[assume((true))]]; // crash
14+
return 0;
15+
}

0 commit comments

Comments
 (0)