[clang] [NFC][analyzer] Rename getTagDescription to getDebugName (PR #141511)
DonĂ¡t Nagy via cfe-commits
cfe-commits at lists.llvm.org
Mon May 26 11:53:13 PDT 2025
https://github.com/NagyDonat updated https://github.com/llvm/llvm-project/pull/141511
>From e19773f3a1c52213ec1afe5329c2715b6119ed33 Mon Sep 17 00:00:00 2001
From: Balazs Benics <benicsbalazs at gmail.com>
Date: Thu, 15 May 2025 19:44:55 +0200
Subject: [PATCH 1/2] [NFC][analyzer] Rename getTagDescription to getDebugName
---
clang/include/clang/Analysis/ProgramPoint.h | 4 ++--
.../Core/BugReporter/BugReporter.h | 4 ++--
.../include/clang/StaticAnalyzer/Core/Checker.h | 16 ++++++++--------
clang/lib/Analysis/ProgramPoint.cpp | 2 +-
.../StaticAnalyzer/Checkers/DivZeroChecker.cpp | 2 +-
.../Checkers/VirtualCallChecker.cpp | 2 +-
clang/lib/StaticAnalyzer/Core/Checker.cpp | 4 ++--
clang/lib/StaticAnalyzer/Core/CheckerManager.cpp | 8 ++++----
clang/lib/StaticAnalyzer/Core/ExprEngine.cpp | 2 +-
9 files changed, 22 insertions(+), 22 deletions(-)
diff --git a/clang/include/clang/Analysis/ProgramPoint.h b/clang/include/clang/Analysis/ProgramPoint.h
index b06d38baf4643..2d7c7367feac4 100644
--- a/clang/include/clang/Analysis/ProgramPoint.h
+++ b/clang/include/clang/Analysis/ProgramPoint.h
@@ -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 getDebugName() const = 0;
/// Used to implement 'isKind' in subclasses.
const void *getTagKind() const { return TagKind; }
@@ -55,7 +55,7 @@ class SimpleProgramPointTag : public ProgramPointTag {
std::string Desc;
public:
SimpleProgramPointTag(StringRef MsgProvider, StringRef Msg);
- StringRef getTagDescription() const override;
+ StringRef getDebugName() const override;
};
class ProgramPoint {
diff --git a/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h b/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
index 33d37febc7327..42b242ada3489 100644
--- a/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
+++ b/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
@@ -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 getDebugName() const override { return "Data Tag"; }
// Manage memory for DataTag objects.
class Factory {
@@ -809,7 +809,7 @@ class NoteTag : public DataTag {
return std::move(Msg);
}
- StringRef getTagDescription() const override {
+ StringRef getDebugName() const override {
// TODO: Remember a few examples of generated messages
// and display them in the ExplodedGraph dump by
// returning them from this function.
diff --git a/clang/include/clang/StaticAnalyzer/Core/Checker.h b/clang/include/clang/StaticAnalyzer/Core/Checker.h
index db3806b425dda..96e4ebbfb8e62 100644
--- a/clang/include/clang/StaticAnalyzer/Core/Checker.h
+++ b/clang/include/clang/StaticAnalyzer/Core/Checker.h
@@ -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 getDebugName() const override;
};
/// Simple checker classes that implement one frontend (i.e. checker name)
@@ -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 getDebugName()` 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 `getDebugName` 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
diff --git a/clang/lib/Analysis/ProgramPoint.cpp b/clang/lib/Analysis/ProgramPoint.cpp
index d7cd38a7325f5..337ee18b3e4c2 100644
--- a/clang/lib/Analysis/ProgramPoint.cpp
+++ b/clang/lib/Analysis/ProgramPoint.cpp
@@ -357,4 +357,4 @@ SimpleProgramPointTag::SimpleProgramPointTag(StringRef MsgProvider,
StringRef Msg)
: Desc((MsgProvider + " : " + Msg).str()) {}
-StringRef SimpleProgramPointTag::getTagDescription() const { return Desc; }
+StringRef SimpleProgramPointTag::getDebugName() const { return Desc; }
diff --git a/clang/lib/StaticAnalyzer/Checkers/DivZeroChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/DivZeroChecker.cpp
index 95a9582ecdcb1..164e79a142545 100644
--- a/clang/lib/StaticAnalyzer/Checkers/DivZeroChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/DivZeroChecker.cpp
@@ -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 getDebugName() const override { return "DivZeroChecker"; }
};
} // end anonymous namespace
diff --git a/clang/lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp
index 67429ee2c25f9..29df35c6f8f8c 100644
--- a/clang/lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp
@@ -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 getDebugName() const override { return "VirtualCallChecker"; }
private:
void registerCtorDtorCallInState(bool IsBeginFunction,
diff --git a/clang/lib/StaticAnalyzer/Core/Checker.cpp b/clang/lib/StaticAnalyzer/Core/Checker.cpp
index f5a07f5d305c5..54f07e40ae139 100644
--- a/clang/lib/StaticAnalyzer/Core/Checker.cpp
+++ b/clang/lib/StaticAnalyzer/Core/Checker.cpp
@@ -18,7 +18,7 @@ using namespace ento;
int ImplicitNullDerefEvent::Tag;
-StringRef CheckerBase::getTagDescription() const { return getName(); }
+StringRef CheckerBase::getDebugName() const { return getName(); }
void CheckerBackend::printState(raw_ostream &Out, ProgramStateRef State,
const char *NL, const char *Sep) const {}
@@ -29,4 +29,4 @@ CheckerProgramPointTag::CheckerProgramPointTag(StringRef CheckerName,
CheckerProgramPointTag::CheckerProgramPointTag(const CheckerBase *Checker,
StringRef Msg)
- : SimpleProgramPointTag(Checker->getTagDescription(), Msg) {}
+ : SimpleProgramPointTag(Checker->getDebugName(), Msg) {}
diff --git a/clang/lib/StaticAnalyzer/Core/CheckerManager.cpp b/clang/lib/StaticAnalyzer/Core/CheckerManager.cpp
index 4c37b65ae5c68..bcc7a7e6da22f 100644
--- a/clang/lib/StaticAnalyzer/Core/CheckerManager.cpp
+++ b/clang/lib/StaticAnalyzer/Core/CheckerManager.cpp
@@ -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->getDebugName() : "<unknown>";
return (Name + ":" + CheckerTag).str();
}
@@ -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->getDebugName());
llvm_unreachable(AssertionMessage.c_str());
}
#endif
if (evaluated) {
- evaluatorChecker = EvalCallChecker.Checker->getTagDescription();
+ evaluatorChecker = EvalCallChecker.Checker->getDebugName();
Dst.insert(checkDst);
#ifdef NDEBUG
break; // on release don't check that no other checker also evals.
@@ -798,7 +798,7 @@ void CheckerManager::runCheckersForPrintStateJson(raw_ostream &Out,
continue;
Indent(Out, Space, IsDot)
- << "{ \"checker\": \"" << CT.second->getTagDescription()
+ << "{ \"checker\": \"" << CT.second->getDebugName()
<< "\", \"messages\": [" << NL;
Indent(Out, InnerSpace, IsDot)
<< '\"' << TempBuf.str().trim() << '\"' << NL;
diff --git a/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp b/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
index 1afd4b52eb354..5b547db6dc482 100644
--- a/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
+++ b/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
@@ -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->getDebugName() << '\"';
else
Out << "null";
Out << ", \"node_id\": " << OtherNode->getID() <<
>From b43ee53ec70089ccc197fd9367ce11246734cae0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Don=C3=A1t=20Nagy?= <donat.nagy at ericsson.com>
Date: Mon, 26 May 2025 20:52:27 +0200
Subject: [PATCH 2/2] git diff --numstat HEAD^ | cut -f 3 | xargs sed -i
's/getDebugName/getDebugTag/g'
---
clang/include/clang/Analysis/ProgramPoint.h | 4 ++--
.../StaticAnalyzer/Core/BugReporter/BugReporter.h | 4 ++--
clang/include/clang/StaticAnalyzer/Core/Checker.h | 6 +++---
clang/lib/Analysis/ProgramPoint.cpp | 2 +-
clang/lib/StaticAnalyzer/Checkers/DivZeroChecker.cpp | 2 +-
.../StaticAnalyzer/Checkers/VirtualCallChecker.cpp | 2 +-
clang/lib/StaticAnalyzer/Core/Checker.cpp | 4 ++--
clang/lib/StaticAnalyzer/Core/CheckerManager.cpp | 11 +++++------
clang/lib/StaticAnalyzer/Core/ExprEngine.cpp | 2 +-
9 files changed, 18 insertions(+), 19 deletions(-)
diff --git a/clang/include/clang/Analysis/ProgramPoint.h b/clang/include/clang/Analysis/ProgramPoint.h
index 2d7c7367feac4..8b7d46177b11b 100644
--- a/clang/include/clang/Analysis/ProgramPoint.h
+++ b/clang/include/clang/Analysis/ProgramPoint.h
@@ -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 getDebugName() const = 0;
+ virtual StringRef getDebugTag() const = 0;
/// Used to implement 'isKind' in subclasses.
const void *getTagKind() const { return TagKind; }
@@ -55,7 +55,7 @@ class SimpleProgramPointTag : public ProgramPointTag {
std::string Desc;
public:
SimpleProgramPointTag(StringRef MsgProvider, StringRef Msg);
- StringRef getDebugName() const override;
+ StringRef getDebugTag() const override;
};
class ProgramPoint {
diff --git a/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h b/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
index 42b242ada3489..8696fce39add1 100644
--- a/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
+++ b/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
@@ -758,7 +758,7 @@ class BugReporterContext {
/// DataTag::Factory should be friend for every derived class.
class DataTag : public ProgramPointTag {
public:
- StringRef getDebugName() const override { return "Data Tag"; }
+ StringRef getDebugTag() const override { return "Data Tag"; }
// Manage memory for DataTag objects.
class Factory {
@@ -809,7 +809,7 @@ class NoteTag : public DataTag {
return std::move(Msg);
}
- StringRef getDebugName() 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.
diff --git a/clang/include/clang/StaticAnalyzer/Core/Checker.h b/clang/include/clang/StaticAnalyzer/Core/Checker.h
index 96e4ebbfb8e62..acd83602aeec4 100644
--- a/clang/include/clang/StaticAnalyzer/Core/Checker.h
+++ b/clang/include/clang/StaticAnalyzer/Core/Checker.h
@@ -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 getDebugName() const override;
+ StringRef getDebugTag() const override;
};
/// Simple checker classes that implement one frontend (i.e. checker name)
@@ -548,12 +548,12 @@ class Checker : public CheckerBase, public CHECKs... {
/// arguments of `FamilyChecker.`
///
/// NOTE: Classes deriving from `CheckerFamily` must implement the pure virtual
-/// method `StringRef getDebugName()` which is inherited from `ProgramPointTag`
+/// 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 `getDebugName` would need to take the name of
+/// 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`.
diff --git a/clang/lib/Analysis/ProgramPoint.cpp b/clang/lib/Analysis/ProgramPoint.cpp
index 337ee18b3e4c2..9e1205c28cb2f 100644
--- a/clang/lib/Analysis/ProgramPoint.cpp
+++ b/clang/lib/Analysis/ProgramPoint.cpp
@@ -357,4 +357,4 @@ SimpleProgramPointTag::SimpleProgramPointTag(StringRef MsgProvider,
StringRef Msg)
: Desc((MsgProvider + " : " + Msg).str()) {}
-StringRef SimpleProgramPointTag::getDebugName() const { return Desc; }
+StringRef SimpleProgramPointTag::getDebugTag() const { return Desc; }
diff --git a/clang/lib/StaticAnalyzer/Checkers/DivZeroChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/DivZeroChecker.cpp
index 164e79a142545..15d73fb9ca39a 100644
--- a/clang/lib/StaticAnalyzer/Checkers/DivZeroChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/DivZeroChecker.cpp
@@ -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 getDebugName() const override { return "DivZeroChecker"; }
+ StringRef getDebugTag() const override { return "DivZeroChecker"; }
};
} // end anonymous namespace
diff --git a/clang/lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp
index 29df35c6f8f8c..6c27f58d308aa 100644
--- a/clang/lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp
@@ -55,7 +55,7 @@ class VirtualCallChecker
void checkPreCall(const CallEvent &Call, CheckerContext &C) const;
/// Identifies this checker family for debugging purposes.
- StringRef getDebugName() const override { return "VirtualCallChecker"; }
+ StringRef getDebugTag() const override { return "VirtualCallChecker"; }
private:
void registerCtorDtorCallInState(bool IsBeginFunction,
diff --git a/clang/lib/StaticAnalyzer/Core/Checker.cpp b/clang/lib/StaticAnalyzer/Core/Checker.cpp
index 54f07e40ae139..00c829fa335ed 100644
--- a/clang/lib/StaticAnalyzer/Core/Checker.cpp
+++ b/clang/lib/StaticAnalyzer/Core/Checker.cpp
@@ -18,7 +18,7 @@ using namespace ento;
int ImplicitNullDerefEvent::Tag;
-StringRef CheckerBase::getDebugName() const { return getName(); }
+StringRef CheckerBase::getDebugTag() const { return getName(); }
void CheckerBackend::printState(raw_ostream &Out, ProgramStateRef State,
const char *NL, const char *Sep) const {}
@@ -29,4 +29,4 @@ CheckerProgramPointTag::CheckerProgramPointTag(StringRef CheckerName,
CheckerProgramPointTag::CheckerProgramPointTag(const CheckerBase *Checker,
StringRef Msg)
- : SimpleProgramPointTag(Checker->getDebugName(), Msg) {}
+ : SimpleProgramPointTag(Checker->getDebugTag(), Msg) {}
diff --git a/clang/lib/StaticAnalyzer/Core/CheckerManager.cpp b/clang/lib/StaticAnalyzer/Core/CheckerManager.cpp
index bcc7a7e6da22f..c82f7b549fce6 100644
--- a/clang/lib/StaticAnalyzer/Core/CheckerManager.cpp
+++ b/clang/lib/StaticAnalyzer/Core/CheckerManager.cpp
@@ -138,7 +138,7 @@ namespace {
std::string checkerScopeName(StringRef Name, const CheckerBackend *Checker) {
if (!llvm::timeTraceProfilerEnabled())
return "";
- StringRef CheckerTag = Checker ? Checker->getDebugName() : "<unknown>";
+ StringRef CheckerTag = Checker ? Checker->getDebugTag() : "<unknown>";
return (Name + ":" + CheckerTag).str();
}
@@ -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->getDebugName());
+ EvalCallChecker.Checker->getDebugTag());
llvm_unreachable(AssertionMessage.c_str());
}
#endif
if (evaluated) {
- evaluatorChecker = EvalCallChecker.Checker->getDebugName();
+ evaluatorChecker = EvalCallChecker.Checker->getDebugTag();
Dst.insert(checkDst);
#ifdef NDEBUG
break; // on release don't check that no other checker also evals.
@@ -797,9 +797,8 @@ void CheckerManager::runCheckersForPrintStateJson(raw_ostream &Out,
if (TempBuf.empty())
continue;
- Indent(Out, Space, IsDot)
- << "{ \"checker\": \"" << CT.second->getDebugName()
- << "\", \"messages\": [" << NL;
+ Indent(Out, Space, IsDot) << "{ \"checker\": \"" << CT.second->getDebugTag()
+ << "\", \"messages\": [" << NL;
Indent(Out, InnerSpace, IsDot)
<< '\"' << TempBuf.str().trim() << '\"' << NL;
Indent(Out, Space, IsDot) << "]}";
diff --git a/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp b/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
index 5b547db6dc482..518e4bb31edeb 100644
--- a/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
+++ b/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
@@ -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->getDebugName() << '\"';
+ Out << '\"' << Tag->getDebugTag() << '\"';
else
Out << "null";
Out << ", \"node_id\": " << OtherNode->getID() <<
More information about the cfe-commits
mailing list