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

Vedant Kumar via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 24 13:52:05 PDT 2017


Author: vedantk
Date: Mon Apr 24 15:52:04 2017
New Revision: 301249

URL: http://llvm.org/viewvc/llvm-project?rev=301249&view=rev
Log:
[Coverage] Avoid null deref in skipRegionMappingForDecl (fixes PR32761)

Patch by Adam Folwarczny!

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

Added:
    cfe/trunk/test/CoverageMapping/empty-destructor.cpp
Modified:
    cfe/trunk/lib/CodeGen/CodeGenPGO.cpp

Modified: cfe/trunk/lib/CodeGen/CodeGenPGO.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenPGO.cpp?rev=301249&r1=301248&r2=301249&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenPGO.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenPGO.cpp Mon Apr 24 15:52:04 2017
@@ -669,6 +669,9 @@ bool CodeGenPGO::skipRegionMappingForDec
   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();

Added: cfe/trunk/test/CoverageMapping/empty-destructor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CoverageMapping/empty-destructor.cpp?rev=301249&view=auto
==============================================================================
--- cfe/trunk/test/CoverageMapping/empty-destructor.cpp (added)
+++ cfe/trunk/test/CoverageMapping/empty-destructor.cpp Mon Apr 24 15:52:04 2017
@@ -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;
+}




More information about the cfe-commits mailing list