Skip to content

[NFC][analyzer] Rename getTagDescription to getDebugName #141511

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 2 commits into from
May 26, 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
4 changes: 2 additions & 2 deletions clang/include/clang/Analysis/ProgramPoint.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class ProgramPointTag {

/// The description of this program point which will be dumped for debugging
/// purposes. Do not use in user-facing output!
virtual StringRef getTagDescription() const = 0;
virtual StringRef getDebugTag() const = 0;

/// Used to implement 'isKind' in subclasses.
const void *getTagKind() const { return TagKind; }
Expand All @@ -55,7 +55,7 @@ class SimpleProgramPointTag : public ProgramPointTag {
std::string Desc;
public:
SimpleProgramPointTag(StringRef MsgProvider, StringRef Msg);
StringRef getTagDescription() const override;
StringRef getDebugTag() const override;
};

class ProgramPoint {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -758,7 +758,7 @@ class BugReporterContext {
/// DataTag::Factory should be friend for every derived class.
class DataTag : public ProgramPointTag {
public:
StringRef getTagDescription() const override { return "Data Tag"; }
StringRef getDebugTag() const override { return "Data Tag"; }

// Manage memory for DataTag objects.
class Factory {
Expand Down Expand Up @@ -809,7 +809,7 @@ class NoteTag : public DataTag {
return std::move(Msg);
}

StringRef getTagDescription() const override {
StringRef getDebugTag() const override {
// TODO: Remember a few examples of generated messages
// and display them in the ExplodedGraph dump by
// returning them from this function.
Expand Down
16 changes: 8 additions & 8 deletions clang/include/clang/StaticAnalyzer/Core/Checker.h
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ class CheckerBase : public CheckerFrontend, public CheckerBackend {
public:
/// Attached to nodes created by this checker class when the ExplodedGraph is
/// dumped for debugging.
StringRef getTagDescription() const override;
StringRef getDebugTag() const override;
};

/// Simple checker classes that implement one frontend (i.e. checker name)
Expand All @@ -547,16 +547,16 @@ class Checker : public CheckerBase, public CHECKs... {
/// callbacks (i.e. classes like `check::PreStmt` or `eval::Call`) as template
/// arguments of `FamilyChecker.`
///
/// NOTE: Classes deriving from `CheckerFamily` must implement the pure
/// virtual method `StringRef getTagDescription()` which is inherited from
/// `ProgramPointTag` and should return the name of the class as a string.
/// NOTE: Classes deriving from `CheckerFamily` must implement the pure virtual
/// method `StringRef getDebugTag()` which is inherited from `ProgramPointTag`
/// and should return the name of the class as a string.
///
/// Obviously, this boilerplate is not a good thing, but unfortunately there is
/// no portable way to stringify the name of a type (e.g. class), so any
/// portable implementation of `getTagDescription` would need to take the
/// name of the class from *somewhere* where it's present as a string -- and
/// then directly placing it in a method override is much simpler than
/// loading it from `Checkers.td`.
/// portable implementation of `getDebugTag` would need to take the name of
/// the class from *somewhere* where it's present as a string -- and then
/// directly placing it in a method override is much simpler than loading it
/// from `Checkers.td`.
///
/// Note that the existing `CLASS` field in `Checkers.td` is not suitable for
/// our goals, because instead of storing the same class name for each
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Analysis/ProgramPoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -357,4 +357,4 @@ SimpleProgramPointTag::SimpleProgramPointTag(StringRef MsgProvider,
StringRef Msg)
: Desc((MsgProvider + " : " + Msg).str()) {}

StringRef SimpleProgramPointTag::getTagDescription() const { return Desc; }
StringRef SimpleProgramPointTag::getDebugTag() const { return Desc; }
2 changes: 1 addition & 1 deletion clang/lib/StaticAnalyzer/Checkers/DivZeroChecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class DivZeroChecker : public CheckerFamily<check::PreStmt<BinaryOperator>> {
void checkPreStmt(const BinaryOperator *B, CheckerContext &C) const;

/// Identifies this checker family for debugging purposes.
StringRef getTagDescription() const override { return "DivZeroChecker"; }
StringRef getDebugTag() const override { return "DivZeroChecker"; }
};
} // end anonymous namespace

Expand Down
2 changes: 1 addition & 1 deletion clang/lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class VirtualCallChecker
void checkPreCall(const CallEvent &Call, CheckerContext &C) const;

/// Identifies this checker family for debugging purposes.
StringRef getTagDescription() const override { return "VirtualCallChecker"; }
StringRef getDebugTag() const override { return "VirtualCallChecker"; }

private:
void registerCtorDtorCallInState(bool IsBeginFunction,
Expand Down
4 changes: 2 additions & 2 deletions clang/lib/StaticAnalyzer/Core/Checker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ using namespace ento;

int ImplicitNullDerefEvent::Tag;

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

void CheckerBackend::printState(raw_ostream &Out, ProgramStateRef State,
const char *NL, const char *Sep) const {}
Expand All @@ -29,4 +29,4 @@ CheckerProgramPointTag::CheckerProgramPointTag(StringRef CheckerName,

CheckerProgramPointTag::CheckerProgramPointTag(const CheckerBase *Checker,
StringRef Msg)
: SimpleProgramPointTag(Checker->getTagDescription(), Msg) {}
: SimpleProgramPointTag(Checker->getDebugTag(), Msg) {}
11 changes: 5 additions & 6 deletions clang/lib/StaticAnalyzer/Core/CheckerManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ namespace {
std::string checkerScopeName(StringRef Name, const CheckerBackend *Checker) {
if (!llvm::timeTraceProfilerEnabled())
return "";
StringRef CheckerTag = Checker ? Checker->getTagDescription() : "<unknown>";
StringRef CheckerTag = Checker ? Checker->getDebugTag() : "<unknown>";
return (Name + ":" + CheckerTag).str();
}

Expand Down Expand Up @@ -721,12 +721,12 @@ void CheckerManager::runCheckersForEvalCall(ExplodedNodeSet &Dst,
"while the {2} checker also tried to evaluate the same call. At "
"most one checker supposed to evaluate a call.",
toString(Call), evaluatorChecker,
EvalCallChecker.Checker->getTagDescription());
EvalCallChecker.Checker->getDebugTag());
llvm_unreachable(AssertionMessage.c_str());
}
#endif
if (evaluated) {
evaluatorChecker = EvalCallChecker.Checker->getTagDescription();
evaluatorChecker = EvalCallChecker.Checker->getDebugTag();
Dst.insert(checkDst);
#ifdef NDEBUG
break; // on release don't check that no other checker also evals.
Expand Down Expand Up @@ -797,9 +797,8 @@ void CheckerManager::runCheckersForPrintStateJson(raw_ostream &Out,
if (TempBuf.empty())
continue;

Indent(Out, Space, IsDot)
<< "{ \"checker\": \"" << CT.second->getTagDescription()
<< "\", \"messages\": [" << NL;
Indent(Out, Space, IsDot) << "{ \"checker\": \"" << CT.second->getDebugTag()
<< "\", \"messages\": [" << NL;
Indent(Out, InnerSpace, IsDot)
<< '\"' << TempBuf.str().trim() << '\"' << NL;
Indent(Out, Space, IsDot) << "]}";
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4029,7 +4029,7 @@ struct DOTGraphTraits<ExplodedGraph*> : public DefaultDOTGraphTraits {
OtherNode->getLocation().printJson(Out, /*NL=*/"\\l");
Out << ", \"tag\": ";
if (const ProgramPointTag *Tag = OtherNode->getLocation().getTag())
Out << '\"' << Tag->getTagDescription() << '\"';
Out << '\"' << Tag->getDebugTag() << '\"';
else
Out << "null";
Out << ", \"node_id\": " << OtherNode->getID() <<
Expand Down
Loading