summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorJustin Bogner <mail@justinbogner.com>2014-03-27 00:06:36 +0000
committerJustin Bogner <mail@justinbogner.com>2014-03-27 00:06:36 +0000
commit11d89f4c2744ea5cf19d7883069ed1fc8bfd0f37 (patch)
treec229b7d368874ac2ad410b19b4f7668dc623636c /include
parentf20d9ee6a65e3c1eea9ea9c7619e984628fe020b (diff)
downloadllvm-11d89f4c2744ea5cf19d7883069ed1fc8bfd0f37.tar.gz
llvm-11d89f4c2744ea5cf19d7883069ed1fc8bfd0f37.tar.bz2
llvm-11d89f4c2744ea5cf19d7883069ed1fc8bfd0f37.tar.xz
llvm-cov: When reading strings in gcov data, skip leading zeros
It seems that gcov, when faced with a string that is apparently zero length, just keeps reading words until it finds a length it likes better. I'm not really sure why this is, but it's simple enough to make llvm-cov follow suit. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@204881 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r--include/llvm/Support/GCOV.h7
1 files changed, 5 insertions, 2 deletions
diff --git a/include/llvm/Support/GCOV.h b/include/llvm/Support/GCOV.h
index aeac4555ce..902f2dbc83 100644
--- a/include/llvm/Support/GCOV.h
+++ b/include/llvm/Support/GCOV.h
@@ -204,8 +204,11 @@ public:
}
bool readString(StringRef &Str) {
- uint32_t Len;
- if (!readInt(Len)) return false;
+ uint32_t Len = 0;
+ // Keep reading until we find a non-zero length. This emulates gcov's
+ // behaviour, which appears to do the same.
+ while (Len == 0)
+ if (!readInt(Len)) return false;
Len *= 4;
if (Buffer->getBuffer().size() < Cursor+Len) {
errs() << "Unexpected end of memory buffer: " << Cursor+Len << ".\n";