[Coverage] Avoid null deref in skipRegionMappingForDecl (fixes PR32761)

Patch by Adam Folwarczny!

Differential Revision: https://reviews.llvm.org/D32406

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@301249 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Vedant Kumar 2017-04-24 20:52:04 +00:00
parent 4316aeccae
commit 29f0cdc96e
2 changed files with 14 additions and 0 deletions

View File

@ -669,6 +669,9 @@ bool CodeGenPGO::skipRegionMappingForDecl(const Decl *D) {
if (SkipCoverageMapping)
return true;
if (!D->getBody())
return true;
// Don't map the functions in system headers.
const auto &SM = CGM.getContext().getSourceManager();
auto Loc = D->getBody()->getLocStart();

View File

@ -0,0 +1,11 @@
// RUN: %clang_cc1 -triple i686-windows -emit-llvm-only -fcoverage-mapping -dump-coverage-mapping -fprofile-instrument=clang %s | FileCheck %s
struct A {
virtual ~A();
};
// CHECK: ?PR32761@@YAXXZ:
// CHECK-NEXT: File 0, [[@LINE+1]]:16 -> [[@LINE+3]]:2 = #0
void PR32761() {
A a;
}