summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Criswell <criswell@uiuc.edu>2006-12-19 22:55:57 +0000
committerJohn Criswell <criswell@uiuc.edu>2006-12-19 22:55:57 +0000
commita20006cd960969ff7d12359b0c36cd2daa9fd403 (patch)
tree19a3a0d56db908dac6c45ab00561808d0650af71
parentc346ecd78053321eb6ff39c859fc816c7d9163d4 (diff)
downloadbcm5719-llvm-a20006cd960969ff7d12359b0c36cd2daa9fd403.tar.gz
bcm5719-llvm-a20006cd960969ff7d12359b0c36cd2daa9fd403.zip
Added operator methods to the Statistic class; some LLVM projects depend
on these. llvm-svn: 32701
-rw-r--r--llvm/include/llvm/ADT/Statistic.h14
1 files changed, 13 insertions, 1 deletions
diff --git a/llvm/include/llvm/ADT/Statistic.h b/llvm/include/llvm/ADT/Statistic.h
index 4bf47640eee..82d27acb360 100644
--- a/llvm/include/llvm/ADT/Statistic.h
+++ b/llvm/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;}
};
OpenPOWER on IntegriCloud