Skip to content

[NFC][analyzer] Remove CheckerNameRef::getName() #130780

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion clang/include/clang/StaticAnalyzer/Core/CheckerManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ class CheckerNameRef {
public:
CheckerNameRef() = default;

StringRef getName() const { return Name; }
operator StringRef() const { return Name; }
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ void ExprInspectionChecker::analyzerHashDump(const CallExpr *CE,
const SourceManager &SM = C.getSourceManager();
FullSourceLoc FL(CE->getArg(0)->getBeginLoc(), SM);
std::string HashContent =
getIssueString(FL, getCheckerName().getName(), "Category",
getIssueString(FL, getCheckerName(), "Category",
C.getLocationContext()->getDecl(), Opts);

reportBug(HashContent, C);
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3885,7 +3885,7 @@ void MallocChecker::printState(raw_ostream &Out, ProgramStateRef State,
Out << " : ";
Data.dump(Out);
if (CheckKind)
Out << " (" << CheckNames[*CheckKind].getName() << ")";
Out << " (" << CheckNames[*CheckKind] << ")";
Out << NL;
}
}
Expand Down
12 changes: 6 additions & 6 deletions clang/lib/StaticAnalyzer/Checkers/ValistChecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -272,12 +272,12 @@ void ValistChecker::reportLeakedVALists(const RegionVector &LeakedVALists,
if (!BT_leakedvalist) {
// FIXME: maybe creating a new check name for this type of bug is a better
// solution.
BT_leakedvalist.reset(
new BugType(CheckNames[CK_Unterminated].getName().empty()
? CheckNames[CK_Uninitialized]
: CheckNames[CK_Unterminated],
"Leaked va_list", categories::MemoryError,
/*SuppressOnSink=*/true));
BT_leakedvalist.reset(new BugType(
static_cast<StringRef>(CheckNames[CK_Unterminated]).empty()
? CheckNames[CK_Uninitialized]
: CheckNames[CK_Unterminated],
"Leaked va_list", categories::MemoryError,
/*SuppressOnSink=*/true));
}

const ExplodedNode *StartNode = getStartCallSite(N, Reg);
Expand Down
4 changes: 2 additions & 2 deletions clang/lib/StaticAnalyzer/Core/BugReporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3442,8 +3442,8 @@ void BugReporter::EmitBasicReport(const Decl *DeclWithIssue,
BugType *BugReporter::getBugTypeForName(CheckerNameRef CheckName,
StringRef name, StringRef category) {
SmallString<136> fullDesc;
llvm::raw_svector_ostream(fullDesc) << CheckName.getName() << ":" << name
<< ":" << category;
llvm::raw_svector_ostream(fullDesc)
<< CheckName << ":" << name << ":" << category;
std::unique_ptr<BugType> &BT = StrBugTypes[fullDesc];
if (!BT)
BT = std::make_unique<BugType>(CheckName, name, category);
Expand Down
8 changes: 3 additions & 5 deletions clang/lib/StaticAnalyzer/Core/Checker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ using namespace ento;

int ImplicitNullDerefEvent::Tag;

StringRef CheckerBase::getTagDescription() const {
return getCheckerName().getName();
}
StringRef CheckerBase::getTagDescription() const { return getCheckerName(); }

CheckerNameRef CheckerBase::getCheckerName() const { return Name; }

Expand All @@ -30,10 +28,10 @@ CheckerProgramPointTag::CheckerProgramPointTag(StringRef CheckerName,

CheckerProgramPointTag::CheckerProgramPointTag(const CheckerBase *Checker,
StringRef Msg)
: SimpleProgramPointTag(Checker->getCheckerName().getName(), Msg) {}
: SimpleProgramPointTag(Checker->getCheckerName(), Msg) {}

raw_ostream& clang::ento::operator<<(raw_ostream &Out,
const CheckerBase &Checker) {
Out << Checker.getCheckerName().getName();
Out << Checker.getCheckerName();
return Out;
}
6 changes: 3 additions & 3 deletions clang/lib/StaticAnalyzer/Core/CheckerManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ std::string checkerScopeName(StringRef Name, const CheckerBase *Checker) {
if (!llvm::timeTraceProfilerEnabled())
return "";
StringRef CheckerName =
Checker ? Checker->getCheckerName().getName() : "<unknown>";
Checker ? static_cast<StringRef>(Checker->getCheckerName()) : "<unknown>";
return (Name + ":" + CheckerName).str();
}

Expand Down Expand Up @@ -721,7 +721,7 @@ void CheckerManager::runCheckersForEvalCall(ExplodedNodeSet &Dst,
"The '{0}' call has been already evaluated by the {1} checker, "
"while the {2} checker also tried to evaluate the same call. At "
"most one checker supposed to evaluate a call.",
toString(Call), evaluatorChecker->getName(),
toString(Call), evaluatorChecker,
EvalCallChecker.Checker->getCheckerName());
llvm_unreachable(AssertionMessage.c_str());
}
Expand Down Expand Up @@ -799,7 +799,7 @@ void CheckerManager::runCheckersForPrintStateJson(raw_ostream &Out,
continue;

Indent(Out, Space, IsDot)
<< "{ \"checker\": \"" << CT.second->getCheckerName().getName()
<< "{ \"checker\": \"" << CT.second->getCheckerName()
<< "\", \"messages\": [" << NL;
Indent(Out, InnerSpace, IsDot)
<< '\"' << TempBuf.str().trim() << '\"' << NL;
Expand Down