[PATCH] D32406: [Coverage][Windows] Null pointer dereference in CodeGenPGO::skipRegionMappingForDecl (fixes PR32761)

Phabricator via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 24 14:05:03 PDT 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rL301249: [Coverage] Avoid null deref in skipRegionMappingForDecl (fixes PR32761) (authored by vedantk).

Changed prior to commit:
  https://reviews.llvm.org/D32406?vs=96454&id=96467#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D32406

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


Index: cfe/trunk/test/CoverageMapping/empty-destructor.cpp
===================================================================
--- cfe/trunk/test/CoverageMapping/empty-destructor.cpp
+++ cfe/trunk/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;
+}
Index: cfe/trunk/lib/CodeGen/CodeGenPGO.cpp
===================================================================
--- cfe/trunk/lib/CodeGen/CodeGenPGO.cpp
+++ cfe/trunk/lib/CodeGen/CodeGenPGO.cpp
@@ -669,6 +669,9 @@
   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();


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D32406.96467.patch
Type: text/x-patch
Size: 1008 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170424/cd02b30f/attachment.bin>


More information about the cfe-commits mailing list