[clang] [Clang][Sema] Fix missing warning when comparing mismatched enums in … (PR #81418)

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Thu Feb 22 07:54:32 PST 2024


================
@@ -263,6 +263,14 @@ namespace {
   }
 }
 
+QualType Expr::getEnumCoercedType(const ASTContext &Ctx) const {
+  bool NotEnumType = dyn_cast<EnumType>(this->getType()) == nullptr;
+  if (NotEnumType)
----------------
erichkeane wrote:

```suggestion
  if (!isa<EnumType>(this->getType()))
```

Though, would probably suggest just something like:
```
if (isa<EnumType>(getType())) return getType();

else if (const EnumConstantDecl *ECD = getEnumConstantDecl())
  return Ctx.getTypeDeclType...
return getType();

```

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


More information about the cfe-commits mailing list