[clang] [analyzer][NFC] Substitute operator() with lambda in StreamChecker (PR #69844)

Ben Shi via cfe-commits cfe-commits at lists.llvm.org
Sat Oct 21 07:03:28 PDT 2023


================
@@ -407,23 +407,15 @@ class StreamChecker : public Checker<check::PreCall, eval::Call,
 
   /// Generate a message for BugReporterVisitor if the stored symbol is
   /// marked as interesting by the actual bug report.
-  // FIXME: Use lambda instead.
-  struct NoteFn {
-    const BugType *BT_ResourceLeak;
-    SymbolRef StreamSym;
-    std::string Message;
-
-    std::string operator()(PathSensitiveBugReport &BR) const {
-      if (BR.isInteresting(StreamSym) && &BR.getBugType() == BT_ResourceLeak)
-        return Message;
-
-      return "";
-    }
-  };
-
   const NoteTag *constructNoteTag(CheckerContext &C, SymbolRef StreamSym,
                                   const std::string &Message) const {
-    return C.getNoteTag(NoteFn{&BT_ResourceLeak, StreamSym, Message});
+    return C.getNoteTag(
+        [this, StreamSym, Message](PathSensitiveBugReport &BR) -> std::string {
+          if (BR.isInteresting(StreamSym) &&
+              &BR.getBugType() == &(this->BT_ResourceLeak))
----------------
benshi001 wrote:

Thanks. I fixed it.

https://github.com/llvm/llvm-project/pull/69844


More information about the cfe-commits mailing list