Author: phyBrackets Date: 2022-02-14T20:54:59+05:30 New Revision: 6745b6a0f18523d6b871f627ceb46a92b7c2c43d
URL: https://github.com/llvm/llvm-project/commit/6745b6a0f18523d6b871f627ceb46a92b7c2c43d DIFF: https://github.com/llvm/llvm-project/commit/6745b6a0f18523d6b871f627ceb46a92b7c2c43d.diff LOG: [analyzer][NFCi] Use the correct BugType in CStringChecker. There is different bug types for different types of bugs but the **emitAdditionOverflowbug** seems to use bugtype **BT_NotCSting** but actually it have to use **BT_AdditionOverflow** . Reviewed By: steakhal Differential Revision: https://reviews.llvm.org/D119462 Added: Modified: clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp Removed: ################################################################################ diff --git a/clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp index 6955efe8e6c2e..8483a1a47cea1 100644 --- a/clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp @@ -257,7 +257,6 @@ class CStringChecker : public Checker< eval::Call, void emitNotCStringBug(CheckerContext &C, ProgramStateRef State, const Stmt *S, StringRef WarningMsg) const; void emitAdditionOverflowBug(CheckerContext &C, ProgramStateRef State) const; - ProgramStateRef checkAdditionOverflow(CheckerContext &C, ProgramStateRef state, NonLoc left, @@ -420,7 +419,6 @@ ProgramStateRef CStringChecker::CheckBufferAccess(CheckerContext &C, SVal BufEnd = svalBuilder.evalBinOpLN(State, BO_Add, *BufLoc, LastOffset, PtrTy); - State = CheckLocation(C, State, Buffer, BufEnd, Access); // If the buffer isn't large enough, abort. @@ -622,8 +620,8 @@ void CStringChecker::emitNotCStringBug(CheckerContext &C, ProgramStateRef State, void CStringChecker::emitAdditionOverflowBug(CheckerContext &C, ProgramStateRef State) const { if (ExplodedNode *N = C.generateErrorNode(State)) { - if (!BT_NotCString) - BT_NotCString.reset( + if (!BT_AdditionOverflow) + BT_AdditionOverflow.reset( new BuiltinBug(Filter.CheckNameCStringOutOfBounds, "API", "Sum of expressions causes overflow.")); @@ -634,8 +632,8 @@ void CStringChecker::emitAdditionOverflowBug(CheckerContext &C, "This expression will create a string whose length is too big to " "be represented as a size_t"; - auto Report = - std::make_unique<PathSensitiveBugReport>(*BT_NotCString, WarningMsg, N); + auto Report = std::make_unique<PathSensitiveBugReport>(*BT_AdditionOverflow, + WarningMsg, N); C.emitReport(std::move(Report)); } } _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits