================
@@ -41,19 +41,19 @@ class BugType {
         Checker(nullptr), SuppressOnSink(SuppressOnSink) {}
   BugType(const CheckerBase *Checker, StringRef Desc,
           StringRef Cat = categories::LogicError, bool SuppressOnSink = false)
-      : CheckerName(Checker->getCheckerName()), Description(Desc),
-        Category(Cat), Checker(Checker), SuppressOnSink(SuppressOnSink) {}
+      : CheckerName(), Description(Desc), Category(Cat), Checker(Checker),
+        SuppressOnSink(SuppressOnSink) {}
   virtual ~BugType() = default;
 
   StringRef getDescription() const { return Description; }
   StringRef getCategory() const { return Category; }
   StringRef getCheckerName() const {
-    // FIXME: This is a workaround to ensure that the correct checerk name is
+    // FIXME: This is a workaround to ensure that the correct checker name is
     // used. The checker names are set after the constructors are run.
     // In case the BugType object is initialized in the checker's ctor
     // the CheckerName field will be empty. To circumvent this problem we use
     // CheckerBase whenever it is possible.
-    StringRef Ret = Checker ? Checker->getCheckerName() : CheckerName;
----------------
NagyDonat wrote:

Under the current system we still need `CheckerName`, but we will be able to 
remove it when I implement my new multipart checker framework and all multipart 
checkers are transferred to it.

Right now both constructors of `BugType` are used and needed:
- In simple straightforward checkers `Checker->getCheckerName()` can return the 
(single) name of the checker, so we can directly initialize the bug types as 
`BugType BT{this, ...}` with the constructor which takes `CheckerBase *Checker` 
and default initializes `CheckerName`.
- In multipart checkers the `BugType` wouldn't be able to query the name of the 
relevant checker part from a `CheckerBase *` (because currently each multipart 
checker implements its own custom array of checker names), so we need to 
initialize the `BugType` with a `CheckerNameRef`, which requires lazy 
initialization (the ugly `mutable std::unique_ptr<BugType>`) because the names 
of the sub-checkers are not yet available when the checker object is 
constructed.

The main effect of my multipart checker change is (roughly speaking) that I 
will provide a `CheckerBase::getName(unsigned CheckerPartIdx)` and then 
`BugType`s can exactly reference a checker part with a pair of a `CheckerBase*` 
(the singleton instance of the checker class) and a numerical index (which 
identifies the part). After this, we can directly initialize each bug type 
object with either a `CheckerBase*` (simple checkers) or a `<CheckerBase*, 
unsigned>` pair (multipart checkers), so we can get rid of the `BugType` 
constructor that takes a raw `CheckerName` (and needs the awkward lazy 
initialization).

https://github.com/llvm/llvm-project/pull/130953
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to