From b1d331a36e908a8f4b22347b2ad7215eca640e85 Mon Sep 17 00:00:00 2001 From: Vedant Kumar Date: Tue, 20 Jun 2017 02:05:35 +0000 Subject: [Coverage] PR33517: Check for failure to load func records With PR33517, it became apparent that symbol table creation can fail when presented with malformed inputs. This patch makes that sort of error detectable, so llvm-cov etc. can fail more gracefully. Specifically, we now check that function records loaded from corrupted coverage mapping data are rejected, e.g when the recorded function name is garbage. Testing: check-{llvm,clang,profile}, some unit test updates. llvm-svn: 305767 --- llvm/lib/ProfileData/Coverage/CoverageMapping.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'llvm/lib/ProfileData') diff --git a/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp b/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp index 015b3c6c202..953972968d6 100644 --- a/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp +++ b/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp @@ -200,6 +200,9 @@ Error CoverageMapping::loadFunctionRecord( const CoverageMappingRecord &Record, IndexedInstrProfReader &ProfileReader) { StringRef OrigFuncName = Record.FunctionName; + if (OrigFuncName.empty()) + return make_error(coveragemap_error::malformed); + if (Record.Filenames.empty()) OrigFuncName = getFuncNameWithoutPrefix(OrigFuncName); else -- cgit v1.2.3