<html>
    <head>
      <base href="http://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - Creduce crashes in CFGBuilder::addAutomaticObjDtors"
   href="http://llvm.org/bugs/show_bug.cgi?id=17665">17665</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Creduce crashes in CFGBuilder::addAutomaticObjDtors
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>-New Bugs
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>octoploid@yandex.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Creduce crashes quite often when build with current trunk clang.

markus@x4 /tmp % gdb --args /var/tmp/creduce/clang_delta/clang_delta
--query-instances=replace-function-def-with-decl test.ii
Reading symbols from /var/tmp/creduce/clang_delta/clang_delta...done.
(gdb) run
Starting program: /var/tmp/creduce/clang_delta/clang_delta
--query-instances=replace-function-def-with-decl test.ii
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/libthread_db.so.1".

Program received signal SIGSEGV, Segmentation fault.
clang::FunctionDecl::isNoReturn (this=0x0) at
/home/markus/llvm/tools/clang/lib/AST/Decl.cpp:2412
2412      return hasAttr<NoReturnAttr>() || hasAttr<CXX11NoReturnAttr>() ||
(gdb) bt
#0  clang::FunctionDecl::isNoReturn (this=0x0) at
/home/markus/llvm/tools/clang/lib/AST/Decl.cpp:2412
#1  0x0000000000f81099 in (anonymous
namespace)::CFGBuilder::addAutomaticObjDtors (this=0x7fffffffcc50, S=0x1bde4f0,
B=..., E=...)
    at /home/markus/llvm/tools/clang/lib/Analysis/CFG.cpp:854
#2  0x0000000000f815ff in (anonymous
namespace)::CFGBuilder::addLocalScopeAndDtors (this=<optimized out>,
S=<optimized out>)
    at /home/markus/llvm/tools/clang/lib/Analysis/CFG.cpp:1028
#3  0x0000000000f85585 in addLocalScopeAndDtors (S=0x1bde4f0,
this=0x7fffffffcc50) at /home/markus/llvm/tools/clang/lib/Analysis/CFG.cpp:1572
#4  (anonymous namespace)::CFGBuilder::VisitCompoundStmt
(this=this@entry=0x7fffffffcc50, C=C@entry=0x1bde4f0) at
/home/markus/llvm/tools/clang/lib/Analysis/CFG.cpp:1557
#5  0x0000000000f83f43 in (anonymous namespace)::CFGBuilder::Visit
(this=this@entry=0x7fffffffcc50, S=S@entry=0x1bde4f0, asc=..., asc@entry=...)
    at /home/markus/llvm/tools/clang/lib/Analysis/CFG.cpp:1092
#6  0x0000000000f88390 in addStmt (S=0x1bde4f0, this=0x7fffffffcc50) at
/home/markus/llvm/tools/clang/lib/Analysis/CFG.cpp:434
#7  buildCFG (Statement=0x1bde4f0, D=<optimized out>, this=0x7fffffffcc50) at
/home/markus/llvm/tools/clang/lib/Analysis/CFG.cpp:660
#8  clang::CFG::buildCFG (D=<optimized out>, Statement=0x1bde4f0,
C=C@entry=0x1737160, BO=...) at
/home/markus/llvm/tools/clang/lib/Analysis/CFG.cpp:3421
#9  0x0000000000f75c47 in clang::AnalysisDeclContext::getCFG
(this=this@entry=0x7fffffffcfe0) at
/home/markus/llvm/tools/clang/lib/Analysis/AnalysisDeclContext.cpp:179
#10 0x0000000000f68804 in CheckFallThrough (AC=...) at
/home/markus/llvm/tools/clang/lib/Sema/AnalysisBasedWarnings.cpp:102
#11 CheckFallThroughForBody (AC=..., CD=..., blkExpr=<optimized out>,
Body=0x1bde4f0, D=0x1bddce0, S=...)
    at /home/markus/llvm/tools/clang/lib/Sema/AnalysisBasedWarnings.cpp:359
#12 clang::sema::AnalysisBasedWarnings::IssueWarnings
(this=this@entry=0x17584b8, P=..., fscope=fscope@entry=0x1758f80,
D=D@entry=0x1bddce0, blkExpr=blkExpr@entry=0x0)
    at /home/markus/llvm/tools/clang/lib/Sema/AnalysisBasedWarnings.cpp:1714
#13 0x0000000000c526d7 in clang::Sema::PopFunctionScopeInfo
(this=this@entry=0x1756c70, WP=WP@entry=0x7fffffffd280, D=D@entry=0x1bddce0,
blkExpr=blkExpr@entry=0x0)
    at /home/markus/llvm/tools/clang/lib/Sema/Sema.cpp:1052
#14 0x0000000000ce131e in clang::Sema::ActOnFinishFunctionBody (this=0x1756c70,
dcl=dcl@entry=0x1bddce0, Body=0x1bde4f0,
IsInstantiation=IsInstantiation@entry=false)
    at /home/markus/llvm/tools/clang/lib/Sema/SemaDecl.cpp:9806
#15 0x0000000000ce1b87 in clang::Sema::ActOnFinishFunctionBody (this=<optimized
out>, D=D@entry=0x1bddce0, BodyArg=<optimized out>)
    at /home/markus/llvm/tools/clang/lib/Sema/SemaDecl.cpp:9654
#16 0x0000000000c2de95 in clang::Parser::ParseFunctionStatementBody
(this=this@entry=0x1771f90, Decl=0x1bddce0, BodyScope=...)
    at /home/markus/llvm/tools/clang/lib/Parse/ParseStmt.cpp:2419
#17 0x0000000000c3b6e4 in clang::Parser::ParseLexedMethodDef (this=0x1771f90,
LM=...) at
/home/markus/llvm/tools/clang/lib/Parse/ParseCXXInlineMethods.cpp:461
#18 0x0000000000c3b500 in clang::Parser::ParseLexedMethodDefs (this=0x1771f90,
Class=...) at
/home/markus/llvm/tools/clang/lib/Parse/ParseCXXInlineMethods.cpp:398
#19 0x0000000000bf3e00 in clang::Parser::ParseCXXMemberSpecification
(this=this@entry=0x1771f90, RecordLoc=..., AttrFixitLoc=...,
AttrFixitLoc@entry=..., Attrs=..., 
    TagType=TagType@entry=18, TagDecl=TagDecl@entry=0x1bdd0b0) at
/home/markus/llvm/tools/clang/lib/Parse/ParseDeclCXX.cpp:2713
#20 0x0000000000bf585a in clang::Parser::ParseClassSpecifier
(this=this@entry=0x1771f90, TagTokKind=TagTokKind@entry=clang::tok::kw_class,
StartLoc=..., DS=..., 
    TemplateInfo=..., AS=AS@entry=clang::AS_none,
EnteringContext=EnteringContext@entry=true,
DSC=DSC@entry=clang::Parser::DSC_top_level, Attributes=...)
    at /home/markus/llvm/tools/clang/lib/Parse/ParseDeclCXX.cpp:1614
#21 0x0000000000bd9555 in clang::Parser::ParseDeclarationSpecifiers
(this=this@entry=0x1771f90, DS=..., TemplateInfo=...,
AS=AS@entry=clang::AS_none, 
    DSContext=DSContext@entry=clang::Parser::DSC_top_level,
LateAttrs=LateAttrs@entry=0x0) at
/home/markus/llvm/tools/clang/lib/Parse/ParseDecl.cpp:3043
#22 0x0000000000bcbdf4 in clang::Parser::ParseDeclOrFunctionDefInternal
(this=this@entry=0x1771f90, attrs=..., DS=..., AS=AS@entry=clang::AS_none)
    at /home/markus/llvm/tools/clang/lib/Parse/Parser.cpp:852
#23 0x0000000000bcc4f9 in clang::Parser::ParseDeclarationOrFunctionDefinition
(this=0x1771f90, attrs=..., AS=clang::AS_none, DS=0x0)
    at /home/markus/llvm/tools/clang/lib/Parse/Parser.cpp:918
#24 0x0000000000bcc52f in clang::Parser::ParseDeclarationOrFunctionDefinition
(this=<optimized out>, attrs=..., DS=<optimized out>, AS=<optimized out>)
    at /home/markus/llvm/tools/clang/lib/Parse/Parser.cpp:920
#25 0x0000000000bd0403 in clang::Parser::ParseExternalDeclaration
(this=this@entry=0x1771f90, attrs=..., DS=DS@entry=0x0)
    at /home/markus/llvm/tools/clang/lib/Parse/Parser.cpp:783
#26 0x0000000000bd0ce2 in clang::Parser::ParseTopLevelDecl
(this=this@entry=0x1771f90, Result=...) at
/home/markus/llvm/tools/clang/lib/Parse/Parser.cpp:588
#27 0x0000000000bc72eb in clang::ParseAST (S=...,
PrintStats=PrintStats@entry=false,
SkipFunctionBodies=SkipFunctionBodies@entry=false)
    at /home/markus/llvm/tools/clang/lib/Parse/ParseAST.cpp:134
#28 0x0000000000a32602 in TransformationManager::doTransformation
(this=0x170d5c0, ErrorMsg="", ErrorCode=@0x167e170: -1) at
TransformationManager.cpp:200
#29 0x000000000046ec34 in main (argc=<optimized out>, argv=<optimized out>) at
ClangDelta.cpp:211
(gdb) q

As you can see dtor is NULL in CFGBuilder::addAutomaticObjDtors
lib/Analysis/CFG.cpp.

The following patch fixes the issue for me:

diff --git a/lib/Analysis/CFG.cpp b/lib/Analysis/CFG.cpp
index 5b48a15def0e..18931334cdc6 100644
--- a/lib/Analysis/CFG.cpp
+++ b/lib/Analysis/CFG.cpp
@@ -851,7 +851,7 @@ void
CFGBuilder::addAutomaticObjDtors(LocalScope::const_iterator B,
     Ty = Context->getBaseElementType(Ty);

     const CXXDestructorDecl *Dtor = Ty->getAsCXXRecordDecl()->getDestructor();
-    if (Dtor->isNoReturn())
+    if (Dtor && Dtor->isNoReturn())
       Block = createNoReturnBlock();
     else
       autoCreateBlock();</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>