From 2a6873fdf3fa413cd7ef09b368fab64aa936d027 Mon Sep 17 00:00:00 2001 From: Justin Bogner Date: Wed, 26 Mar 2014 22:03:06 +0000 Subject: [PATCH] llvm-cov: Handle functions with no line number Functions may in an instrumented binary but not in the original source when they're inserted by the compiler or the runtime. These functions aren't meaningful to the user, so teach llvm-cov to skip over them instead of crashing. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@204863 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/IR/GCOV.cpp | 5 +++ .../llvm-cov/Inputs/copy_block_helper.gcda | Bin 0 -> 432 bytes .../llvm-cov/Inputs/copy_block_helper.gcno | Bin 0 -> 1140 bytes test/tools/llvm-cov/copy_block_helper.m | 29 ++++++++++++++++++ test/tools/llvm-cov/lit.local.cfg | 2 +- 5 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 test/tools/llvm-cov/Inputs/copy_block_helper.gcda create mode 100644 test/tools/llvm-cov/Inputs/copy_block_helper.gcno create mode 100644 test/tools/llvm-cov/copy_block_helper.m diff --git a/lib/IR/GCOV.cpp b/lib/IR/GCOV.cpp index dc9cb4b2a81..f69bdc4f8cc 100644 --- a/lib/IR/GCOV.cpp +++ b/lib/IR/GCOV.cpp @@ -308,6 +308,11 @@ void GCOVFunction::dump() const { /// collectLineCounts - Collect line counts. This must be used after /// reading .gcno and .gcda files. void GCOVFunction::collectLineCounts(FileInfo &FI) { + // If the line number is zero, this is a function that doesn't actually appear + // in the source file, so there isn't anything we can do with it. + if (LineNumber == 0) + return; + for (SmallVectorImpl::iterator I = Blocks.begin(), E = Blocks.end(); I != E; ++I) (*I)->collectLineCounts(FI); diff --git a/test/tools/llvm-cov/Inputs/copy_block_helper.gcda b/test/tools/llvm-cov/Inputs/copy_block_helper.gcda new file mode 100644 index 0000000000000000000000000000000000000000..d7ff4696df7622fb7a8378186aeed9df61a3ce26 GIT binary patch literal 432 zcmYdHNlw=?GB8PMK48MYz`)1`BtRhR!m2yWK)NKgxFkL!HK!o82*_K=$O0r8ffxi} zG>FLx`ke{L2I&J*K!95h2T&HI_D17}=OF#@@nGAMa`Kb2<1_Qh^0QO%>gNQ? zg4}rKGS69%yW``N^9w4Wu8oHn0~7`Vh#Mem6p|5S2FOn@!`CxF%t!&cyeJ>j7~E!n l+z!G<$Nil_{>e?u%mY$DfYa{_LH5D`QaHkdkm<$98~{66In@9F literal 0 HcmV?d00001 diff --git a/test/tools/llvm-cov/Inputs/copy_block_helper.gcno b/test/tools/llvm-cov/Inputs/copy_block_helper.gcno new file mode 100644 index 0000000000000000000000000000000000000000..a9d10840646e44175bdbd13847c86fb0cb27b920 GIT binary patch literal 1140 zcmd1LOHS7^GB8PMK48MYz`)20BtRhR!m2yWK)NKgxFkL!HK!o8h=CQzPtGr>j8DqR zPtJyl>g6(sf;2EVGJ@2j0%y1wBU}O^2I4cp#a!X);6eA36`2g*r-6d(X2KadS__l?F6&q4a)