Author: Balazs Benics Date: 2025-08-05T17:03:53+02:00 New Revision: 0a1eff2ecedcb11acb3e9d4b75ee1e1bebd69a70
URL: https://github.com/llvm/llvm-project/commit/0a1eff2ecedcb11acb3e9d4b75ee1e1bebd69a70 DIFF: https://github.com/llvm/llvm-project/commit/0a1eff2ecedcb11acb3e9d4b75ee1e1bebd69a70.diff LOG: [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 Added: Modified: clang/lib/StaticAnalyzer/Checkers/AssumeModeling.cpp clang/test/Analysis/cxx23-assume-attribute.cpp Removed: ################################################################################ diff --git a/clang/lib/StaticAnalyzer/Checkers/AssumeModeling.cpp b/clang/lib/StaticAnalyzer/Checkers/AssumeModeling.cpp index 1e3adb4f266ca..789c7772d123a 100644 --- a/clang/lib/StaticAnalyzer/Checkers/AssumeModeling.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/AssumeModeling.cpp @@ -45,7 +45,6 @@ void AssumeModelingChecker::checkPostStmt(const AttributedStmt *A, continue; const auto *Assumption = AssumptionVal.getAsInteger(); - assert(Assumption && "We should know the exact outcome of an assume expr"); if (Assumption && Assumption->isZero()) { C.addSink(); } diff --git a/clang/test/Analysis/cxx23-assume-attribute.cpp b/clang/test/Analysis/cxx23-assume-attribute.cpp index 86e7662cd2af9..dd15ff5d43505 100644 --- a/clang/test/Analysis/cxx23-assume-attribute.cpp +++ b/clang/test/Analysis/cxx23-assume-attribute.cpp @@ -69,3 +69,8 @@ int assume_and_fallthrough_at_the_same_attrstmt(int a, int b) { return 0; } + +void assume_opaque_gh151854_no_crash() { + extern bool opaque(); + [[assume(opaque())]]; // no-crash +} _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits