aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--clang/docs/ReleaseNotes.rst2
-rw-r--r--clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp2
-rw-r--r--clang/test/Analysis/builtin_assume.cpp13
3 files changed, 16 insertions, 1 deletions
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 4a2edae..20cadbf 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 8535384..fe70558 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 7158306..29a96c0 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>();
+}