File tree 2 files changed +33
-2
lines changed
2 files changed +33
-2
lines changed Original file line number Diff line number Diff line change @@ -1812,8 +1812,10 @@ struct CounterCoverageMappingBuilder
1812
1812
assert (S->isConstexpr ());
1813
1813
1814
1814
// 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 ();
1817
1819
1818
1820
extendRegion (S);
1819
1821
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
234
234
return i;
235
235
}
236
236
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
+
237
266
int instantiate_consteval (int i) {
238
267
i *= check_consteval_with_else_discarded_then (i);
239
268
i *= check_notconsteval_with_else_discarded_else (i);
You can’t perform that action at this time.
0 commit comments