Endre =?utf-8?q?Fülöp?= <endre.fu...@sigmatechnology.se>, Endre =?utf-8?q?Fülöp?= <endre.fu...@sigmatechnology.se> Message-ID: In-Reply-To: <llvm/llvm-project/pull/68191/cl...@github.com>
================ @@ -72,21 +72,36 @@ EnumValueVector getDeclValuesForEnum(const EnumDecl *ED) { EnumValueVector DeclValues( std::distance(ED->enumerator_begin(), ED->enumerator_end())); llvm::transform(ED->enumerators(), DeclValues.begin(), - [](const EnumConstantDecl *D) { return D->getInitVal(); }); + [](const EnumConstantDecl *D) { return D->getInitVal(); }); return DeclValues; } } // namespace -void EnumCastOutOfRangeChecker::reportWarning(CheckerContext &C) const { +void EnumCastOutOfRangeChecker::reportWarning(CheckerContext &C, + const EnumDecl *E) const { + assert(E && "valid EnumDecl* is expected"); if (const ExplodedNode *N = C.generateNonFatalErrorNode()) { if (!EnumValueCastOutOfRange) EnumValueCastOutOfRange.reset( new BugType(this, "Enum cast out of range")); - constexpr llvm::StringLiteral Msg = - "The value provided to the cast expression is not in the valid range" - " of values for the enum"; - C.emitReport(std::make_unique<PathSensitiveBugReport>( - *EnumValueCastOutOfRange, Msg, N)); + + llvm::SmallString<128> Msg{"The value provided to the cast expression is " + "not in the valid range of values for "}; + StringRef EnumName{E->getName()}; + if (EnumName.empty()) { + Msg += "the enum"; ---------------- DonatNagyE wrote: Could you add a testcase that shows an example where this branch is used? (Is this for the C-style `typedef enum {...} foo_t;` declarations?) https://github.com/llvm/llvm-project/pull/68191 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits