File tree Expand file tree Collapse file tree 2 files changed +33
-2
lines changed Expand file tree Collapse file tree 2 files changed +33
-2
lines changed Original file line number Diff line number Diff line change @@ -1812,8 +1812,10 @@ struct CounterCoverageMappingBuilder
18121812 assert (S->isConstexpr ());
18131813
18141814 // evaluate constant condition...
1815- const auto *E = cast<ConstantExpr>(S->getCond ());
1816- const bool isTrue = E->getResultAsAPSInt ().getExtValue ();
1815+ const bool isTrue =
1816+ S->getCond ()
1817+ ->EvaluateKnownConstInt (CVM.getCodeGenModule ().getContext ())
1818+ .getBoolValue ();
18171819
18181820 extendRegion (S);
18191821
Original file line number Diff line number Diff line change @@ -234,6 +234,35 @@ constexpr int check_macro_consteval_if_skipped(int i) { // CHECK-NEXT: [[@LINE
234234 return i;
235235}
236236
237+ struct false_value {
238+ constexpr operator bool () {
239+ return false ;
240+ }
241+ };
242+
243+ template <typename > struct dependable_false_value {
244+ constexpr operator bool () {
245+ return false ;
246+ }
247+ };
248+
249+ // GH-80285
250+ void should_not_crash () {
251+ if constexpr (false_value{}) { };
252+ }
253+
254+ template <typename > void should_not_crash_dependable () {
255+ if constexpr (dependable_false_value<int >{}) { };
256+ }
257+
258+ void should_not_crash_with_template_instance () {
259+ should_not_crash_dependable<int >();
260+ }
261+
262+ void should_not_crash_with_requires_expr () {
263+ if constexpr (requires {42 ;}) { };
264+ }
265+
237266int instantiate_consteval (int i) {
238267 i *= check_consteval_with_else_discarded_then (i);
239268 i *= check_notconsteval_with_else_discarded_else (i);
You can’t perform that action at this time.
0 commit comments