[clang] [CodeGen][NFCI] Don't re-implement parts of ASTContext::getIntWidth (PR #101765)
Jessica Clarke via cfe-commits
cfe-commits at lists.llvm.org
Fri Aug 2 15:31:42 PDT 2024
https://github.com/jrtc27 created https://github.com/llvm/llvm-project/pull/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.
>From ae187a16a1fc7f009bd531f693f12f9894cef7bd Mon Sep 17 00:00:00 2001
From: Jessica Clarke <jrtc27 at jrtc27.com>
Date: Fri, 2 Aug 2024 23:17:42 +0100
Subject: [PATCH] [CodeGen][NFCI] Don't re-implement parts of
ASTContext::getIntWidth
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.
---
clang/lib/CodeGen/CGBuiltin.cpp | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 3221989e14351..a0140b81925d1 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