[clang-tools-extra] [clang-tidy] use upper case letters for bool conversion suffix (PR #102831)

Piotr Zegar via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 15 14:38:56 PDT 2024


================
@@ -39,14 +39,22 @@ AST_MATCHER(Stmt, isNULLMacroExpansion) {
 }
 
 StringRef getZeroLiteralToCompareWithForType(CastKind CastExprKind,
-                                             QualType Type,
-                                             ASTContext &Context) {
+                                             QualType Type, ASTContext &Context,
+                                             bool UseUpperCaseLiteralSuffix) {
   switch (CastExprKind) {
-  case CK_IntegralToBoolean:
-    return Type->isUnsignedIntegerType() ? "0u" : "0";
+  case CK_IntegralToBoolean: {
+    if (Type->isUnsignedIntegerType())
+      return UseUpperCaseLiteralSuffix ? "0U" : "0u";
----------------
PiotrZSL wrote:

Note: You could just use StringRef::upper to avoid using UseUpperCaseLiteralSuffix multiple times.

https://github.com/llvm/llvm-project/pull/102831


More information about the cfe-commits mailing list