[llvm] 39809eb - [llvm-diff] add "reset" method to DiffConsumer

Bill Wendling via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 12 11:27:16 PDT 2021


Author: Bill Wendling
Date: 2021-08-12T11:25:47-07:00
New Revision: 39809eb1b33a5c13ce839cfa8145a5305e9d8133

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

LOG: [llvm-diff] add "reset" method to DiffConsumer

A DiffConsumer object may be reused, but we'd like to reset it before
the next use.

No functionality change intended.

Differential Revision: https://reviews.llvm.org/D107985

Added: 
    

Modified: 
    llvm/tools/llvm-diff/lib/DiffConsumer.cpp
    llvm/tools/llvm-diff/lib/DiffConsumer.h

Removed: 
    


################################################################################
diff  --git a/llvm/tools/llvm-
diff /lib/DiffConsumer.cpp b/llvm/tools/llvm-
diff /lib/DiffConsumer.cpp
index a703f42f14c36..afead86d9af50 100644
--- a/llvm/tools/llvm-
diff /lib/DiffConsumer.cpp
+++ b/llvm/tools/llvm-
diff /lib/DiffConsumer.cpp
@@ -134,6 +134,12 @@ void DiffConsumer::indent() {
   while (N--) out << ' ';
 }
 
+void DiffConsumer::reset() {
+  context.clear();
+  Differences = false;
+  Indent = 0;
+}
+
 bool DiffConsumer::hadDifferences() const {
   return Differences;
 }

diff  --git a/llvm/tools/llvm-
diff /lib/DiffConsumer.h b/llvm/tools/llvm-
diff /lib/DiffConsumer.h
index f7b2f2450eecc..08c3afcbe111e 100644
--- a/llvm/tools/llvm-
diff /lib/DiffConsumer.h
+++ b/llvm/tools/llvm-
diff /lib/DiffConsumer.h
@@ -78,6 +78,7 @@ class StringRef;
     DiffConsumer()
       : out(errs()), Differences(false), Indent(0) {}
 
+    void reset();
     bool hadDifferences() const;
     void enterContext(const Value *L, const Value *R) override;
     void exitContext() override;


        


More information about the llvm-commits mailing list