[clang] e91e0f5 - [CodeGen][NFCI] Don't re-implement parts of ASTContext::getIntWidth (#101765)

via cfe-commits cfe-commits at lists.llvm.org
Fri Aug 9 14:52:13 PDT 2024


Author: Jessica Clarke
Date: 2024-08-09T22:52:08+01:00
New Revision: e91e0f52895e2b23bd690a86dbaafd979e027d29

URL: https://github.com/llvm/llvm-project/commit/e91e0f52895e2b23bd690a86dbaafd979e027d29
DIFF: https://github.com/llvm/llvm-project/commit/e91e0f52895e2b23bd690a86dbaafd979e027d29.diff

LOG: [CodeGen][NFCI] Don't re-implement parts of ASTContext::getIntWidth (#101765)

ASTContext::getIntWidth returns 1 if isBooleanType(), and falls back on
getTypeSize in the default case, which itself just returns the Width
from getTypeInfo's returned struct, so can be used in all cases here,
not just for _BitInt types.

Added: 
    

Modified: 
    clang/lib/CodeGen/CGBuiltin.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index d1af7fde157b6..7fe80b0cbdfbf 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -756,9 +756,7 @@ static WidthAndSignedness
 getIntegerWidthAndSignedness(const clang::ASTContext &context,
                              const clang::QualType Type) {
   assert(Type->isIntegerType() && "Given type is not an integer.");
-  unsigned Width = Type->isBooleanType()  ? 1
-                   : Type->isBitIntType() ? context.getIntWidth(Type)
-                                          : context.getTypeInfo(Type).Width;
+  unsigned Width = context.getIntWidth(Type);
   bool Signed = Type->isSignedIntegerType();
   return {Width, Signed};
 }


        


More information about the cfe-commits mailing list