[PATCH] D52756: [analyzer] Fix crash in exploded graph dumping

George Karpenkov via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 2 14:20:48 PDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rC343635: [analyzer] Fix crash in exploded graph dumping (authored by george.karpenkov, committed by ).
Herald added a subscriber: cfe-commits.

Changed prior to commit:
  https://reviews.llvm.org/D52756?vs=167855&id=168026#toc

Repository:
  rC Clang

https://reviews.llvm.org/D52756

Files:
  lib/Analysis/CFG.cpp
  test/Analysis/dump_egraph.c


Index: lib/Analysis/CFG.cpp
===================================================================
--- lib/Analysis/CFG.cpp
+++ lib/Analysis/CFG.cpp
@@ -2632,15 +2632,12 @@
   for (DeclStmt::reverse_decl_iterator I = DS->decl_rbegin(),
                                        E = DS->decl_rend();
        I != E; ++I) {
-    // Get the alignment of the new DeclStmt, padding out to >=8 bytes.
-    unsigned A = alignof(DeclStmt) < 8 ? 8 : alignof(DeclStmt);
 
     // Allocate the DeclStmt using the BumpPtrAllocator.  It will get
     // automatically freed with the CFG.
     DeclGroupRef DG(*I);
     Decl *D = *I;
-    void *Mem = cfg->getAllocator().Allocate(sizeof(DeclStmt), A);
-    DeclStmt *DSNew = new (Mem) DeclStmt(DG, D->getLocation(), GetEndLoc(D));
+    DeclStmt *DSNew = new (Context) DeclStmt(DG, D->getLocation(), GetEndLoc(D));
     cfg->addSyntheticDeclStmt(DSNew, DS);
 
     // Append the fake DeclStmt to block.
Index: test/Analysis/dump_egraph.c
===================================================================
--- test/Analysis/dump_egraph.c
+++ test/Analysis/dump_egraph.c
@@ -5,8 +5,8 @@
 int getJ();
 
 int foo() {
-  int *x = 0;
-  return *x;
+  int *x = 0, *y = 0;
+  return *x + *y;
 }
 
 // CHECK: digraph "Exploded Graph" {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D52756.168026.patch
Type: text/x-patch
Size: 1258 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20181002/2bab15f7/attachment.bin>


More information about the cfe-commits mailing list