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

Roman Lebedev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Nov 4 02:02:40 PST 2018


lebedev.ri added inline comments.


================
Comment at: lib/StaticAnalyzer/Checkers/EnumCastOutOfRangeChecker.cpp:96
+  // Get the value of the expression to cast.
+  const auto ValueToCastOptional =
+      C.getSVal(CE->getSubExpr()).getAs<DefinedOrUnknownSVal>();
----------------
ZaMaZaN4iK wrote:
> aaron.ballman wrote:
> > `const auto *`
> Why do we need this change here? If I understand correctly, with `const auto*` we also need change initializer to `C.getSVal(CE->getSubExpr()).getAs<DefinedOrUnknownSVal>().getPointer()`. But I don't understand why we need this.
Is `ValueToCastOptional` a pointer, a reference, or just an actual `DefinedOrUnknownSVal`? I can't tell.
(sidenote: would be great to have a clang-tidy check for this.)


https://reviews.llvm.org/D33672





More information about the cfe-commits mailing list