[llvm-commits] CVS: llvm/include/llvm/ADT/Statistic.h
John Criswell
criswell at cs.uiuc.edu
Tue Dec 19 14:56:27 PST 2006
Changes in directory llvm/include/llvm/ADT:
Statistic.h updated: 1.21 -> 1.22
---
Log message:
Added operator methods to the Statistic class; some LLVM projects depend
on these.
---
Diffs of the changes: (+13 -1)
Statistic.h | 14 +++++++++++++-
1 files changed, 13 insertions(+), 1 deletion(-)
Index: llvm/include/llvm/ADT/Statistic.h
diff -u llvm/include/llvm/ADT/Statistic.h:1.21 llvm/include/llvm/ADT/Statistic.h:1.22
--- llvm/include/llvm/ADT/Statistic.h:1.21 Tue Dec 19 15:27:47 2006
+++ llvm/include/llvm/ADT/Statistic.h Tue Dec 19 16:55:57 2006
@@ -51,7 +51,7 @@
const StatisticBase &operator*=(const unsigned &V) {Value *= V;return init();}
const StatisticBase &operator/=(const unsigned &V) {Value /= V;return init();}
-private:
+protected:
StatisticBase &init() {
if (!Initialized) RegisterStatistic();
return *this;
@@ -63,6 +63,18 @@
Statistic(const char *name, const char *desc) {
Name = name; Desc = desc; Value = 0; Initialized = 0;
}
+
+ // Allow use of this class as the value itself.
+ operator unsigned() const { return Value; }
+ const Statistic &operator=(unsigned Val) { Value = Val; init(); return *this;}
+ const Statistic &operator++() { ++Value; init(); return *this;}
+ unsigned operator++(int) { init(); return Value++; }
+ const Statistic &operator--() { --Value; init(); return *this;}
+ unsigned operator--(int) { init(); return Value--; }
+ const Statistic &operator+=(const unsigned &V) {Value += V;init();return *this;}
+ const Statistic &operator-=(const unsigned &V) {Value -= V;init();return *this;}
+ const Statistic &operator*=(const unsigned &V) {Value *= V;init();return *this;}
+ const Statistic &operator/=(const unsigned &V) {Value /= V;init();return *this;}
};
More information about the llvm-commits
mailing list