summaryrefslogtreecommitdiffstats
path: root/llvm/tools
diff options
context:
space:
mode:
authorDevang Patel <dpatel@apple.com>2011-09-29 17:06:40 +0000
committerDevang Patel <dpatel@apple.com>2011-09-29 17:06:40 +0000
commite5a8f2f9f3f17942403f65ff1eec71411064180c (patch)
treed90ec8b3929c15893a7572ea38cb8064d29085b7 /llvm/tools
parent4d01ace4fdde223f92a6290697abcd00e9a77763 (diff)
downloadbcm5719-llvm-e5a8f2f9f3f17942403f65ff1eec71411064180c.tar.gz
bcm5719-llvm-e5a8f2f9f3f17942403f65ff1eec71411064180c.zip
Simplify.
llvm-svn: 140789
Diffstat (limited to 'llvm/tools')
-rw-r--r--llvm/tools/llvm-cov/GCOVReader.cpp28
1 files changed, 17 insertions, 11 deletions
diff --git a/llvm/tools/llvm-cov/GCOVReader.cpp b/llvm/tools/llvm-cov/GCOVReader.cpp
index e4570b1229f..2b40a84f8ef 100644
--- a/llvm/tools/llvm-cov/GCOVReader.cpp
+++ b/llvm/tools/llvm-cov/GCOVReader.cpp
@@ -27,6 +27,16 @@ GCOVFile::~GCOVFile() {
DeleteContainerPointers(Functions);
}
+/// isGCDAFile - Return true if Format identifies a .gcda file.
+static bool isGCDAFile(GCOVFormat Format) {
+ return Format == GCDA_402 || Format == GCDA_404;
+}
+
+/// isGCNOFile - Return true if Format identifies a .gcno file.
+static bool isGCNOFile(GCOVFormat Format) {
+ return Format == GCNO_402 || Format == GCNO_404;
+}
+
/// read - Read GCOV buffer.
bool GCOVFile::read(GCOVBuffer &Buffer) {
GCOVFormat Format = Buffer.readGCOVFormat();
@@ -36,20 +46,16 @@ bool GCOVFile::read(GCOVBuffer &Buffer) {
unsigned i = 0;
while (1) {
GCOVFunction *GFun = NULL;
- if (Format == GCDA_402 || Format == GCDA_404) {
- if (i < Functions.size())
- GFun = Functions[i];
- } else
+ if (isGCDAFile(Format)) {
+ // Use existing function while reading .gcda file.
+ assert (i < Functions.size() && ".gcda data does not match .gcno data");
+ GFun = Functions[i];
+ } else if (isGCNOFile(Format)){
GFun = new GCOVFunction();
-
- if (GFun && GFun->read(Buffer, Format)) {
- if (Format == GCNO_402 || Format == GCNO_404)
- Functions.push_back(GFun);
+ Functions.push_back(GFun);
}
- else {
- delete GFun;
+ if (!GFun || !GFun->read(Buffer, Format))
break;
- }
++i;
}
return true;
OpenPOWER on IntegriCloud