[PATCH] D13157: Teach -Wtautological-overlap-compare about enums
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Fri Sep 25 06:14:41 PDT 2015
aaron.ballman added a subscriber: aaron.ballman.
aaron.ballman added a comment.
Thank you for working on this -- I think it's a good cleanup and feature-add! I have a few minor comments, but generally LGTM. You should wait for an okay from Richard, however.
================
Comment at: lib/Analysis/CFG.cpp:54
@@ +53,3 @@
+ auto *DR = dyn_cast<DeclRefExpr>(E->IgnoreParenImpCasts());
+ if (DR == nullptr)
+ return nullptr;
----------------
Please don't compare a pointer against nullptr with an equality operator. This can be simplified into:
```
if (const auto *DR = dyn_cast<>)
return isa<> ? "
return nullptr;
```
================
Comment at: lib/Analysis/CFG.cpp:97
@@ +96,3 @@
+ // Currently we're only given EnumConstantDecls or IntegerLiterals
+ auto *C1 = cast<EnumConstantDecl>(cast<DeclRefExpr>(A)->getDecl());
+ auto *C2 = cast<EnumConstantDecl>(cast<DeclRefExpr>(B)->getDecl());
----------------
Are you sure that A and B will only ever be DeclRefExprs? You dyn_cast elsewhere.
http://reviews.llvm.org/D13157
More information about the cfe-commits
mailing list