Skip to content

Commit 0a1eff2

Browse files
authored
[analyzer] Drop assertion enforcing that assume args are known constants (#151908)
We sometimes don't know if the operand of [[assume]] is true/false, and that's okay. We can just ignore the attribute in that case. If we wanted something more fancy, we could bring the assumption to the constraints, but dropping them should be just as fine for now. Fixes #151854
1 parent 522ea9c commit 0a1eff2

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

clang/lib/StaticAnalyzer/Checkers/AssumeModeling.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ void AssumeModelingChecker::checkPostStmt(const AttributedStmt *A,
4545
continue;
4646

4747
const auto *Assumption = AssumptionVal.getAsInteger();
48-
assert(Assumption && "We should know the exact outcome of an assume expr");
4948
if (Assumption && Assumption->isZero()) {
5049
C.addSink();
5150
}

clang/test/Analysis/cxx23-assume-attribute.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,3 +69,8 @@ int assume_and_fallthrough_at_the_same_attrstmt(int a, int b) {
6969

7070
return 0;
7171
}
72+
73+
void assume_opaque_gh151854_no_crash() {
74+
extern bool opaque();
75+
[[assume(opaque())]]; // no-crash
76+
}

0 commit comments

Comments
 (0)