[PATCH] D33672: [analyzer] INT50-CPP. Do not cast to an out-of-range enumeration checker

Endre Fülöp via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jul 24 05:12:07 PDT 2017


gamesh411 marked 2 inline comments as done.
gamesh411 added inline comments.


================
Comment at: lib/StaticAnalyzer/Checkers/EnumCastOutOfRangeChecker.cpp:104
+  // Check whether the cast type is an enum.
+  const auto ED = dyn_cast_or_null<EnumDecl>(T->getAsTagDecl());
+  // If it is not an enum, we skip.
----------------
xazax.hun wrote:
> You could do something like T->getAs<EnumDecl>() directly without repeated cast. 
Cannot get it with something like T->getAs<EnumDecl>() because T is a QualType, and it has an EnumDecl if it is an EnumeralType (note that it potentially has the Decl, not is the Decl). However the suggestion helped me refactor the method to make it more readable (see in the new diff).


https://reviews.llvm.org/D33672





More information about the cfe-commits mailing list