diff options
Diffstat (limited to 'lib/IR/GCOV.cpp')
| -rw-r--r-- | lib/IR/GCOV.cpp | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/lib/IR/GCOV.cpp b/lib/IR/GCOV.cpp index 35b8157751b6c..a9f7f45ee3059 100644 --- a/lib/IR/GCOV.cpp +++ b/lib/IR/GCOV.cpp @@ -22,6 +22,7 @@ #include "llvm/Support/raw_ostream.h" #include <algorithm> #include <system_error> + using namespace llvm; //===----------------------------------------------------------------------===// @@ -104,7 +105,7 @@ bool GCOVFile::readGCDA(GCOVBuffer &Buffer) { } /// dump - Dump GCOVFile content to dbgs() for debugging purposes. -void GCOVFile::dump() const { +LLVM_DUMP_METHOD void GCOVFile::dump() const { for (const auto &FPtr : Functions) FPtr->dump(); } @@ -247,10 +248,12 @@ bool GCOVFunction::readGCNO(GCOVBuffer &Buff, GCOV::GCOVVersion Version) { /// readGCDA - Read a function from the GCDA buffer. Return false if an error /// occurs. bool GCOVFunction::readGCDA(GCOVBuffer &Buff, GCOV::GCOVVersion Version) { - uint32_t Dummy; - if (!Buff.readInt(Dummy)) + uint32_t HeaderLength; + if (!Buff.readInt(HeaderLength)) return false; // Function header length + uint64_t EndPos = Buff.getCursor() + HeaderLength * sizeof(uint32_t); + uint32_t GCDAIdent; if (!Buff.readInt(GCDAIdent)) return false; @@ -280,13 +283,15 @@ bool GCOVFunction::readGCDA(GCOVBuffer &Buff, GCOV::GCOVVersion Version) { } } - StringRef GCDAName; - if (!Buff.readString(GCDAName)) - return false; - if (Name != GCDAName) { - errs() << "Function names do not match: " << Name << " != " << GCDAName - << ".\n"; - return false; + if (Buff.getCursor() < EndPos) { + StringRef GCDAName; + if (!Buff.readString(GCDAName)) + return false; + if (Name != GCDAName) { + errs() << "Function names do not match: " << Name << " != " << GCDAName + << ".\n"; + return false; + } } if (!Buff.readArcTag()) { @@ -340,7 +345,7 @@ uint64_t GCOVFunction::getExitCount() const { } /// dump - Dump GCOVFunction content to dbgs() for debugging purposes. -void GCOVFunction::dump() const { +LLVM_DUMP_METHOD void GCOVFunction::dump() const { dbgs() << "===== " << Name << " (" << Ident << ") @ " << Filename << ":" << LineNumber << "\n"; for (const auto &Block : Blocks) @@ -397,7 +402,7 @@ void GCOVBlock::collectLineCounts(FileInfo &FI) { } /// dump - Dump GCOVBlock content to dbgs() for debugging purposes. -void GCOVBlock::dump() const { +LLVM_DUMP_METHOD void GCOVBlock::dump() const { dbgs() << "Block : " << Number << " Counter : " << Counter << "\n"; if (!SrcEdges.empty()) { dbgs() << "\tSource Edges : "; @@ -496,7 +501,7 @@ public: OS << format("%5u:", LineNum) << Line << "\n"; } }; -} +} // end anonymous namespace /// Convert a path to a gcov filename. If PreservePaths is true, this /// translates "/" to "#", ".." to "^", and drops ".", to match gcov. @@ -683,7 +688,6 @@ void FileInfo::print(raw_ostream &InfoOS, StringRef MainFilename, if (Options.FuncCoverage) printFuncCoverage(InfoOS); printFileCoverage(InfoOS); - return; } /// printFunctionSummary - Print function and block summary. |
