File tree Expand file tree Collapse file tree 2 files changed +23
-2
lines changed Expand file tree Collapse file tree 2 files changed +23
-2
lines changed Original file line number Diff line number Diff line change @@ -2793,9 +2793,14 @@ PathDiagnosticPieceRef ConditionBRVisitor::VisitTerminator(
27932793 // more tricky because there are more than two branches to account for.
27942794 default :
27952795 return nullptr ;
2796- case Stmt::IfStmtClass:
2797- Cond = cast<IfStmt>(Term)->getCond ();
2796+ case Stmt::IfStmtClass: {
2797+ const auto *IfStatement = cast<IfStmt>(Term);
2798+ // Handle if consteval which doesn't have a traditional condition.
2799+ if (IfStatement->isConsteval ())
2800+ return nullptr ;
2801+ Cond = IfStatement->getCond ();
27982802 break ;
2803+ }
27992804 case Stmt::ConditionalOperatorClass:
28002805 Cond = cast<ConditionalOperator>(Term)->getCond ();
28012806 break ;
Original file line number Diff line number Diff line change 1+ // RUN: %clang_analyze_cc1 -std=c++23 -analyzer-checker=core -verify %s
2+ // RUN: %clang_analyze_cc1 -std=c++26 -analyzer-checker=core -verify %s
3+
4+ void test_consteval () {
5+ if consteval {
6+ int *ptr = nullptr ;
7+ *ptr = 42 ; // expected-warning{{Dereference of null pointer (loaded from variable 'ptr')}}
8+ }
9+ }
10+
11+ void test_not_consteval () {
12+ if !consteval {
13+ int *ptr = nullptr ;
14+ *ptr = 42 ; // expected-warning{{Dereference of null pointer (loaded from variable 'ptr')}}
15+ }
16+ }
You can’t perform that action at this time.
0 commit comments