Skip to content

Commit

Permalink
[Coverage] Avoid null deref in skipRegionMappingForDecl (fixes PR32761)
Browse files Browse the repository at this point in the history
Patch by Adam Folwarczny!

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

llvm-svn: 301249
  • Loading branch information
vedantk committed Apr 24, 2017
1 parent c7524f0 commit bc370f0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
3 changes: 3 additions & 0 deletions clang/lib/CodeGen/CodeGenPGO.cpp
Expand Up @@ -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();
Expand Down
11 changes: 11 additions & 0 deletions clang/test/CoverageMapping/empty-destructor.cpp
@@ -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;
}

0 comments on commit bc370f0

Please sign in to comment.