[llvm] 1a2d4bf - [gcov] Don't error 'unexpected end of memory buffe'

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 3 22:07:26 PDT 2020


Author: Fangrui Song
Date: 2020-06-03T22:05:15-07:00
New Revision: 1a2d4bf34e19eec9563e871a102d1f9a5c183daa

URL: https://github.com/llvm/llvm-project/commit/1a2d4bf34e19eec9563e871a102d1f9a5c183daa
DIFF: https://github.com/llvm/llvm-project/commit/1a2d4bf34e19eec9563e871a102d1f9a5c183daa.diff

LOG: [gcov] Don't error 'unexpected end of memory buffe'

Added: 
    

Modified: 
    llvm/lib/ProfileData/GCOV.cpp
    llvm/test/tools/llvm-cov/llvm-cov.test

Removed: 
    


################################################################################
diff  --git a/llvm/lib/ProfileData/GCOV.cpp b/llvm/lib/ProfileData/GCOV.cpp
index 0b50bebe674d..137928426f47 100644
--- a/llvm/lib/ProfileData/GCOV.cpp
+++ b/llvm/lib/ProfileData/GCOV.cpp
@@ -57,7 +57,7 @@ bool GCOVFile::readGCNO(GCOVBuffer &buf) {
 
   uint32_t tag, length;
   GCOVFunction *fn;
-  while (buf.readInt(tag) && tag) {
+  while ((tag = buf.getWord())) {
     if (!buf.readInt(length))
       return false;
     if (tag == GCOV_TAG_FUNCTION) {
@@ -163,7 +163,7 @@ bool GCOVFile::readGCDA(GCOVBuffer &buf) {
   uint32_t dummy, tag, length;
   uint32_t ident;
   GCOVFunction *fn = nullptr;
-  while (buf.readInt(tag) && tag) {
+  while ((tag = buf.getWord())) {
     if (!buf.readInt(length))
       return false;
     uint32_t pos = buf.cursor.tell();

diff  --git a/llvm/test/tools/llvm-cov/llvm-cov.test b/llvm/test/tools/llvm-cov/llvm-cov.test
index e4a5bdfdf9a1..79e51b453c2c 100644
--- a/llvm/test/tools/llvm-cov/llvm-cov.test
+++ b/llvm/test/tools/llvm-cov/llvm-cov.test
@@ -11,9 +11,10 @@ RUN: cd %t
 RUN: cp %p/Inputs/test* .
 
 # Basic behaviour with no flags
-RUN: llvm-cov gcov test.c | FileCheck %s --check-prefixes=OUT,OUTFILE --match-full-lines --strict-whitespace
+RUN: llvm-cov gcov test.c 2> %t.err | FileCheck %s --check-prefixes=OUT,OUTFILE --match-full-lines --strict-whitespace
 RUN: FileCheck %s --check-prefix=C --match-full-lines --strict-whitespace < test.cpp.gcov
 RUN: 
diff  -aub test_no_options.h.gcov test.h.gcov
+RUN: count 0 < %t.err
 
 # Same, but specifying the object directory
 RUN: mkdir -p %t/objdir


        


More information about the llvm-commits mailing list