[llvm] r204881 - llvm-cov: When reading strings in gcov data, skip leading zeros

Justin Bogner mail at justinbogner.com
Wed Mar 26 17:06:36 PDT 2014


Author: bogner
Date: Wed Mar 26 19:06:36 2014
New Revision: 204881

URL: http://llvm.org/viewvc/llvm-project?rev=204881&view=rev
Log:
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.

Modified:
    llvm/trunk/include/llvm/Support/GCOV.h

Modified: llvm/trunk/include/llvm/Support/GCOV.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/GCOV.h?rev=204881&r1=204880&r2=204881&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/GCOV.h (original)
+++ llvm/trunk/include/llvm/Support/GCOV.h Wed Mar 26 19:06:36 2014
@@ -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";





More information about the llvm-commits mailing list