Skip to content

Commit

Permalink
[analyzer][NFC] Simplify BugType handling in core.BitwiseShift (llvm#…
Browse files Browse the repository at this point in the history
…74609)

Eliminate the `mutable unique_ptr` hack because it's no longer needed.
(This cleanup could be done anywhere, I'm doing it here now because it
was me who published this checker with the old hack when it was already
superfluous.)
  • Loading branch information
NagyDonat authored Dec 7, 2023
1 parent b768b39 commit e4c7ee3
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions clang/lib/StaticAnalyzer/Checkers/BitwiseShiftChecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ BitwiseShiftValidator::createBugReport(StringRef ShortMsg, StringRef Msg) const
} // anonymous namespace

class BitwiseShiftChecker : public Checker<check::PreStmt<BinaryOperator>> {
mutable std::unique_ptr<BugType> BTPtr;
BugType BT{this, "Bitwise shift", "Suspicious operation"};

public:
void checkPreStmt(const BinaryOperator *B, CheckerContext &Ctx) const {
Expand All @@ -353,11 +353,7 @@ class BitwiseShiftChecker : public Checker<check::PreStmt<BinaryOperator>> {
if (Op != BO_Shl && Op != BO_Shr)
return;

if (!BTPtr)
BTPtr = std::make_unique<BugType>(this, "Bitwise shift",
"Suspicious operation");

BitwiseShiftValidator(B, Ctx, *BTPtr, Pedantic).run();
BitwiseShiftValidator(B, Ctx, BT, Pedantic).run();
}

bool Pedantic = false;
Expand Down

0 comments on commit e4c7ee3

Please sign in to comment.