summaryrefslogtreecommitdiff
path: root/lib/IR/GCOV.cpp
diff options
context:
space:
mode:
authorYuchen Wu <yuchenericwu@hotmail.com>2013-11-20 04:15:05 +0000
committerYuchen Wu <yuchenericwu@hotmail.com>2013-11-20 04:15:05 +0000
commitd23c759c0fa10b7fb244b4d2911b49b95138a7e1 (patch)
tree4346b143320207b2cc677a34902d7e0ddc697eb8 /lib/IR/GCOV.cpp
parent523d929368829b5157748f46f85b4577b7fd6ca1 (diff)
downloadllvm-d23c759c0fa10b7fb244b4d2911b49b95138a7e1.tar.gz
llvm-d23c759c0fa10b7fb244b4d2911b49b95138a7e1.tar.bz2
llvm-d23c759c0fa10b7fb244b4d2911b49b95138a7e1.tar.xz
llvm-cov: Added file checksum to gcno and gcda files.
Instead of permanently outputting "MVLL" as the file checksum, clang will create gcno and gcda checksums by hashing the destination block numbers of every arc. This allows for llvm-cov to check if the two gcov files are synchronized. Regenerated the test files so they contain the checksum. Also added negative test to ensure error when the checksums don't match. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@195191 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/IR/GCOV.cpp')
-rw-r--r--lib/IR/GCOV.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/IR/GCOV.cpp b/lib/IR/GCOV.cpp
index 25a4ff669d..622c4f7851 100644
--- a/lib/IR/GCOV.cpp
+++ b/lib/IR/GCOV.cpp
@@ -46,6 +46,7 @@ bool GCOVFile::read(GCOVBuffer &Buffer) {
return false;
if (isGCNOFile(Format)) {
+ if (!Buffer.readInt(Checksum)) return false;
while (true) {
if (!Buffer.readFunctionTag()) break;
GCOVFunction *GFun = new GCOVFunction();
@@ -55,6 +56,12 @@ bool GCOVFile::read(GCOVBuffer &Buffer) {
}
}
else if (isGCDAFile(Format)) {
+ uint32_t Checksum2;
+ if (!Buffer.readInt(Checksum2)) return false;
+ if (Checksum != Checksum2) {
+ errs() << "File checksum does not match.\n";
+ return false;
+ }
for (size_t i = 0, e = Functions.size(); i < e; ++i) {
if (!Buffer.readFunctionTag()) {
errs() << "Unexpected number of functions.\n";