[clang] f990650 - [analyzer][NFC] Substitute operator() with lambda in StreamChecker

via cfe-commits cfe-commits at lists.llvm.org
Sat Oct 21 07:29:18 PDT 2023


Author: Ben Shi
Date: 2023-10-21T16:29:14+02:00
New Revision: f9906508bc4f05d3950e2219b4c56f6c078a61ef

URL: https://github.com/llvm/llvm-project/commit/f9906508bc4f05d3950e2219b4c56f6c078a61ef
DIFF: https://github.com/llvm/llvm-project/commit/f9906508bc4f05d3950e2219b4c56f6c078a61ef.diff

LOG: [analyzer][NFC] Substitute operator() with lambda in StreamChecker

Added: 
    

Modified: 
    clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
index bad86682c91e25f..ef209f64f0c372c 100644
--- a/clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
@@ -407,23 +407,14 @@ 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() == &BT_ResourceLeak)
+        return Message;
+      return "";
+    });
   }
 
   const NoteTag *constructSetEofNoteTag(CheckerContext &C,


        


More information about the cfe-commits mailing list