diff options
Diffstat (limited to 'llvm/include/Support/SlowOperationInformer.h')
-rw-r--r-- | llvm/include/Support/SlowOperationInformer.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/llvm/include/Support/SlowOperationInformer.h b/llvm/include/Support/SlowOperationInformer.h index 75c5796aaab..67edf7df42b 100644 --- a/llvm/include/Support/SlowOperationInformer.h +++ b/llvm/include/Support/SlowOperationInformer.h @@ -32,6 +32,7 @@ #define SUPPORT_SLOW_OPERATION_INFORMER_H #include <string> +#include <cassert> namespace llvm { class SlowOperationInformer { @@ -49,6 +50,15 @@ namespace llvm { /// along the operation is, given in 1/10ths of a percent (in other words, /// Amount should range from 0 to 1000). void progress(unsigned Amount); + + /// progress - Same as the method above, but this performs the division for + /// you, and helps you avoid overflow if you are dealing with largish + /// numbers. + void progress(unsigned Current, unsigned Maximum) { + assert(Maximum != 0 && + "Shouldn't be doing work if there is nothing to do!"); + progress(Current*1000ULL/Maximum); + } }; } // end namespace llvm |