From 85aa4f6eee9c055c7911656e9d1a018b6088eb73 Mon Sep 17 00:00:00 2001 From: Nick Lewycky Date: Sun, 23 Sep 2012 03:58:21 +0000 Subject: [PATCH] Don't do actual work inside an assert statement. Fixes PR11760! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@164474 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/VMCore/GCOV.cpp | 10 ++++++---- test/Other/Inputs/llvm-cov.gcda | Bin 0 -> 296 bytes test/Other/Inputs/llvm-cov.gcno | Bin 0 -> 984 bytes test/Other/llvm-cov.test | 3 +++ 4 files changed, 9 insertions(+), 4 deletions(-) create mode 100644 test/Other/Inputs/llvm-cov.gcda create mode 100644 test/Other/Inputs/llvm-cov.gcno create mode 100644 test/Other/llvm-cov.test diff --git a/lib/VMCore/GCOV.cpp b/lib/VMCore/GCOV.cpp index 5bc1ac9f5d3..ea2f0a6d556 100644 --- a/lib/VMCore/GCOV.cpp +++ b/lib/VMCore/GCOV.cpp @@ -48,7 +48,7 @@ bool GCOVFile::read(GCOVBuffer &Buffer) { GCOVFunction *GFun = NULL; if (isGCDAFile(Format)) { // Use existing function while reading .gcda file. - assert (i < Functions.size() && ".gcda data does not match .gcno data"); + assert(i < Functions.size() && ".gcda data does not match .gcno data"); GFun = Functions[i]; } else if (isGCNOFile(Format)){ GFun = new GCOVFunction(); @@ -113,7 +113,9 @@ bool GCOVFunction::read(GCOVBuffer &Buff, GCOV::GCOVFormat Format) { LineNumber = Buff.readInt(); // read blocks. - assert (Buff.readBlockTag() && "Block Tag not found!"); + bool BlockTagFound = Buff.readBlockTag(); + (void)BlockTagFound; + assert(BlockTagFound && "Block Tag not found!"); uint32_t BlockCount = Buff.readInt(); for (int i = 0, e = BlockCount; i != e; ++i) { Buff.readInt(); // Block flags; @@ -124,7 +126,7 @@ bool GCOVFunction::read(GCOVBuffer &Buff, GCOV::GCOVFormat Format) { while (Buff.readEdgeTag()) { uint32_t EdgeCount = (Buff.readInt() - 1) / 2; uint32_t BlockNo = Buff.readInt(); - assert (BlockNo < BlockCount && "Unexpected Block number!"); + assert(BlockNo < BlockCount && "Unexpected Block number!"); for (int i = 0, e = EdgeCount; i != e; ++i) { Blocks[BlockNo]->addEdge(Buff.readInt()); Buff.readInt(); // Edge flag @@ -136,7 +138,7 @@ bool GCOVFunction::read(GCOVBuffer &Buff, GCOV::GCOVFormat Format) { uint32_t LineTableLength = Buff.readInt(); uint32_t Size = Buff.getCursor() + LineTableLength*4; uint32_t BlockNo = Buff.readInt(); - assert (BlockNo < BlockCount && "Unexpected Block number!"); + assert(BlockNo < BlockCount && "Unexpected Block number!"); GCOVBlock *Block = Blocks[BlockNo]; Buff.readInt(); // flag while (Buff.getCursor() != (Size - 4)) { diff --git a/test/Other/Inputs/llvm-cov.gcda b/test/Other/Inputs/llvm-cov.gcda new file mode 100644 index 0000000000000000000000000000000000000000..9ae2286ea2f4bfab95aac46ca63e3fe7319f852a GIT binary patch literal 296 zcmYdHNlw=?GBEKC^YLL|U|{3|5&{Lwcz_fbumQ>V_~eR;`1G9oq{N)~vc#hJ%)HDJ zu<~E;x;<))`4Hvbi8P gFSv?O3vy#_VrCvh%|fsrVd|0W01LtRFdC)~09vIQYXATM literal 0 HcmV?d00001 diff --git a/test/Other/Inputs/llvm-cov.gcno b/test/Other/Inputs/llvm-cov.gcno new file mode 100644 index 0000000000000000000000000000000000000000..25e202386a8973091f80ab9ae7f09ee971d098e0 GIT binary patch literal 984 zcmb_aOH0Hs5T5vcAq5dHzVYNjqs#sP*V5a1^%`OUvFIpeC+;k~#U-*R1z#!V)NKn(%>$j<~x+bypsY Pmc_gO4B;=o;jQxlME_`a literal 0 HcmV?d00001 diff --git a/test/Other/llvm-cov.test b/test/Other/llvm-cov.test new file mode 100644 index 00000000000..c0aa203e2c1 --- /dev/null +++ b/test/Other/llvm-cov.test @@ -0,0 +1,3 @@ +PR11760 +RUN: llvm-cov -gcda=%S/Inputs/llvm-cov.gcda -gcno=%S/Inputs/llvm-cov.gcno +