================
@@ -0,0 +1,263 @@
+// RUN: %check_clang_tidy -std=c++23-or-later %s modernize-use-if-consteval %t
+
+namespace std {
+constexpr bool is_constant_evaluated() noexcept {
+ return __builtin_is_constant_evaluated();
+}
+}
+
+namespace mine {
+constexpr bool is_constant_evaluated() noexcept {
+ return __builtin_is_constant_evaluated();
+}
+}
+
+namespace alias = std;
+
+#define ICE_CALL() std::is_constant_evaluated()
+#define IF_ICE_HEADER if (std::is_constant_evaluated())
+#define RETURN_ONE() return 1;
+#define RETURN_THREE() return 3;
+
+bool runtime_predicate();
+
+int direct() {
+ if (std::is_constant_evaluated())
+ return 1;
+ else
+ return 2;
+ // CHECK-MESSAGES: :[[@LINE-4]]:7: warning: use 'if consteval' instead of
checking 'std::is_constant_evaluated()' in this 'if' statement
[modernize-use-if-consteval]
+ // CHECK-FIXES: if consteval {
+ // CHECK-FIXES-NEXT: return 1;
+ // CHECK-FIXES-NEXT: } else {
----------------
localspook wrote:
Nit: these checks are easier to read when they're aligned:
```suggestion
// CHECK-FIXES: if consteval {
// CHECK-FIXES-NEXT: return 1;
// CHECK-FIXES-NEXT: } else {
```
https://github.com/llvm/llvm-project/pull/189743
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits