r343635 - [analyzer] Fix crash in exploded graph dumping

George Karpenkov via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 2 14:19:01 PDT 2018


Author: george.karpenkov
Date: Tue Oct  2 14:19:01 2018
New Revision: 343635

URL: http://llvm.org/viewvc/llvm-project?rev=343635&view=rev
Log:
[analyzer] Fix crash in exploded graph dumping

By allocating new DeclStmt to ASTContext

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

Modified:
    cfe/trunk/lib/Analysis/CFG.cpp
    cfe/trunk/test/Analysis/dump_egraph.c

Modified: cfe/trunk/lib/Analysis/CFG.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CFG.cpp?rev=343635&r1=343634&r2=343635&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/CFG.cpp (original)
+++ cfe/trunk/lib/Analysis/CFG.cpp Tue Oct  2 14:19:01 2018
@@ -2632,15 +2632,12 @@ CFGBlock *CFGBuilder::VisitDeclStmt(Decl
   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.

Modified: cfe/trunk/test/Analysis/dump_egraph.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/dump_egraph.c?rev=343635&r1=343634&r2=343635&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/dump_egraph.c (original)
+++ cfe/trunk/test/Analysis/dump_egraph.c Tue Oct  2 14:19:01 2018
@@ -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" {




More information about the cfe-commits mailing list