diff options
author | John Criswell <criswell@uiuc.edu> | 2006-12-19 22:55:57 +0000 |
---|---|---|
committer | John Criswell <criswell@uiuc.edu> | 2006-12-19 22:55:57 +0000 |
commit | 3d3a429acb1de79eb15575ed4d90a0a951fda576 (patch) | |
tree | 892e517596ad845dc1b86e02ebab337a1ea10468 /include/llvm | |
parent | 36343735cb23680c8f8675deafbbf825d46fd868 (diff) | |
download | external_llvm-3d3a429acb1de79eb15575ed4d90a0a951fda576.zip external_llvm-3d3a429acb1de79eb15575ed4d90a0a951fda576.tar.gz external_llvm-3d3a429acb1de79eb15575ed4d90a0a951fda576.tar.bz2 |
Added operator methods to the Statistic class; some LLVM projects depend
on these.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32701 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm')
-rw-r--r-- | include/llvm/ADT/Statistic.h | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/include/llvm/ADT/Statistic.h b/include/llvm/ADT/Statistic.h index 4bf4764..82d27ac 100644 --- a/include/llvm/ADT/Statistic.h +++ b/include/llvm/ADT/Statistic.h @@ -51,7 +51,7 @@ public: 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 @@ struct Statistic : public StatisticBase { 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;} }; |