Skip to content

Commit 6745b6a

Browse files
committed
[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
1 parent f037082 commit 6745b6a

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,6 @@ class CStringChecker : public Checker< eval::Call,
257257
void emitNotCStringBug(CheckerContext &C, ProgramStateRef State,
258258
const Stmt *S, StringRef WarningMsg) const;
259259
void emitAdditionOverflowBug(CheckerContext &C, ProgramStateRef State) const;
260-
261260
ProgramStateRef checkAdditionOverflow(CheckerContext &C,
262261
ProgramStateRef state,
263262
NonLoc left,
@@ -420,7 +419,6 @@ ProgramStateRef CStringChecker::CheckBufferAccess(CheckerContext &C,
420419

421420
SVal BufEnd =
422421
svalBuilder.evalBinOpLN(State, BO_Add, *BufLoc, LastOffset, PtrTy);
423-
424422
State = CheckLocation(C, State, Buffer, BufEnd, Access);
425423

426424
// If the buffer isn't large enough, abort.
@@ -622,8 +620,8 @@ void CStringChecker::emitNotCStringBug(CheckerContext &C, ProgramStateRef State,
622620
void CStringChecker::emitAdditionOverflowBug(CheckerContext &C,
623621
ProgramStateRef State) const {
624622
if (ExplodedNode *N = C.generateErrorNode(State)) {
625-
if (!BT_NotCString)
626-
BT_NotCString.reset(
623+
if (!BT_AdditionOverflow)
624+
BT_AdditionOverflow.reset(
627625
new BuiltinBug(Filter.CheckNameCStringOutOfBounds, "API",
628626
"Sum of expressions causes overflow."));
629627

@@ -634,8 +632,8 @@ void CStringChecker::emitAdditionOverflowBug(CheckerContext &C,
634632
"This expression will create a string whose length is too big to "
635633
"be represented as a size_t";
636634

637-
auto Report =
638-
std::make_unique<PathSensitiveBugReport>(*BT_NotCString, WarningMsg, N);
635+
auto Report = std::make_unique<PathSensitiveBugReport>(*BT_AdditionOverflow,
636+
WarningMsg, N);
639637
C.emitReport(std::move(Report));
640638
}
641639
}

0 commit comments

Comments
 (0)