================
@@ -0,0 +1,306 @@
+// 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 IF_ONLY if
+#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()' [modernize-use-if-consteval]
+ // CHECK-FIXES: if consteval {
+ // CHECK-FIXES-NEXT: return 1;
+ // CHECK-FIXES-NEXT: } else {
+ // CHECK-FIXES-NEXT: return 2;
+ // CHECK-FIXES-NEXT: }
+}
+
+int direct_global() {
+ if (::std::is_constant_evaluated()) {
+ return 1;
+ }
+ return 2;
+ // CHECK-MESSAGES: :[[@LINE-4]]:7: warning: use 'if consteval' instead of
checking 'std::is_constant_evaluated()' [modernize-use-if-consteval]
----------------
zeyi2 wrote:
```suggestion
// CHECK-MESSAGES: :[[@LINE-4]]:7: warning: use 'if consteval' instead of
checking 'std::is_constant_evaluated()'
```
Same as below :)
https://github.com/llvm/llvm-project/pull/189743
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits