[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:31 PST 2024


================
@@ -4097,6 +4105,14 @@ FieldDecl *Expr::getSourceBitField() {
   return nullptr;
 }
 
+EnumConstantDecl *Expr::getEnumConstantDecl() {
+  Expr *E = this->IgnoreParenImpCasts();
+  if (DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E))
+    if (EnumConstantDecl *ECD = dyn_cast<EnumConstantDecl>(DRE->getDecl()))
----------------
erichkeane wrote:

```suggestion
    return dyn_cast<EnumConstantDecl>(DRE->getDecl());
```

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


More information about the cfe-commits mailing list