diff options
author | Yuchen Wu <yuchenericwu@hotmail.com> | 2013-10-23 19:45:03 +0000 |
---|---|---|
committer | Yuchen Wu <yuchenericwu@hotmail.com> | 2013-10-23 19:45:03 +0000 |
commit | 9db9663d1d2e4e336c2787bacff4ee7125622e21 (patch) | |
tree | 652abc47085c02c07ced5c8cf14ffdff53940a45 /include/llvm/Support/GCOV.h | |
parent | 1e0437804c084dabda8894508f5867fdfb4df915 (diff) | |
download | llvm-9db9663d1d2e4e336c2787bacff4ee7125622e21.tar.gz llvm-9db9663d1d2e4e336c2787bacff4ee7125622e21.tar.bz2 llvm-9db9663d1d2e4e336c2787bacff4ee7125622e21.tar.xz |
Use a map instead of vector to store line counts.
There are a few motivations for this:
- Using a map allows for checking if line is in map. This differentiates
unexecutable lines (such as comments) from unexecuted logical lines of
code. "#####" is now outputted in this case, in line with gcov.
- Source files are no longer read in twice: once when storing the line
counts, and once when outputting the data.
- Greatly simplifies the function FileInfo::addLineCount().
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193264 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Support/GCOV.h')
-rw-r--r-- | include/llvm/Support/GCOV.h | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/include/llvm/Support/GCOV.h b/include/llvm/Support/GCOV.h index aa436fbea9..f1e7998bc4 100644 --- a/include/llvm/Support/GCOV.h +++ b/include/llvm/Support/GCOV.h @@ -15,6 +15,7 @@ #ifndef LLVM_SUPPORT_GCOV_H #define LLVM_SUPPORT_GCOV_H +#include "llvm/ADT/DenseMap.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringMap.h" #include "llvm/Support/MemoryBuffer.h" @@ -212,10 +213,12 @@ private: SmallVector<uint32_t, 4> Lines; }; -typedef SmallVector<uint64_t, 16> LineCounts; +typedef DenseMap<uint32_t, uint64_t> LineCounts; class FileInfo { public: - void addLineCount(StringRef Filename, uint32_t Line, uint64_t Count); + void addLineCount(StringRef Filename, uint32_t Line, uint64_t Count) { + LineInfo[Filename][Line-1] = Count; + } void print(StringRef gcnoFile, StringRef gcdaFile); private: StringMap<LineCounts> LineInfo; |