[clang] [compiler-rt] [ubsan] Improve scoped enum diagnostic printer (PR #216460)
Yanzuo Liu via cfe-commits
cfe-commits at lists.llvm.org
Wed Aug 19 18:48:26 PDT 2026
================
@@ -3959,6 +3959,14 @@ llvm::Constant *CodeGenFunction::EmitCheckTypeDescriptor(QualType T) {
uint16_t TypeInfo = 0;
bool IsBitInt = false;
+ // isIntegerType() never holds for scoped enums, and getAs<BitIntType> can't
+ // see through the EnumType node to a __BitInt underlying type even for
+ // unscoped enums.
+ QualType BackupT = T;
+ if (const EnumType *ET = T->getAs<EnumType>())
+ if (ET->getDecl()->isComplete())
----------------
zwuis wrote:
> But "incomplete" can be a little weird with enums. For example:
>
> ```
> enum class E : bool;
> int f(E* x) { return (int)*x; }
> ```
>
> The type isn't incomplete, but the enum decl is.
For this enum, `TagDecl::isCompleteDefinition` returns `false` because the enum doesn't have 'body' (`{}`); `EnumDecl::isComplete` returns `true`.
https://github.com/llvm/llvm-project/pull/216460
More information about the cfe-commits
mailing list