Hi Markus,

The crash was caused by the "deleted" function in c++11. I committed another fix, but thanks for the report!

- Yang

Markus Trippelsdorf wrote:
Running llvm trunk and creduce llvm-svn branch I get:

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

Program received signal SIGSEGV, Segmentation fault.
0x00000000010e670b in clang::Stmt::getSourceRange() const ()
(gdb) bt
#0  0x00000000010e670b in clang::Stmt::getSourceRange() const ()
#1  0x00000000008f6a9a in RewriteUtils::replaceFunctionDefWithStr (this=0x17da450, 
FD=FD@entry=0x7ffff64cba80, Str=";") at RewriteUtils.cpp:1348
#2  0x000000000088bc2b in ReplaceFunctionDefWithDecl::rewriteOneFunctionDef 
(this=this@entry=0x176e7f0, FD=0x7ffff64cba80) at 
ReplaceFunctionDefWithDecl.cpp:252
#3  0x000000000088bd37 in ReplaceFunctionDefWithDecl::doRewriting 
(this=0x176e7f0) at ReplaceFunctionDefWithDecl.cpp:278
#4  0x000000000088bf2c in ReplaceFunctionDefWithDecl::HandleTranslationUnit 
(this=0x176e7f0, Ctx=...) at ReplaceFunctionDefWithDecl.cpp:80
#5  0x0000000000bdabf5 in clang::ParseAST(clang::Sema&, bool, bool) ()
#6  0x0000000000a3f622 in TransformationManager::doTransformation (this=0x17735c0, 
ErrorMsg="", ErrorCode=@0x16e43b0: -1) at TransformationManager.cpp:200
#7  0x000000000046ee74 in main (argc=<optimized out>, argv=<optimized out>) at 
ClangDelta.cpp:211
(gdb) up
#1  0x00000000008f6a9a in RewriteUtils::replaceFunctionDefWithStr (this=0x17da450, 
FD=FD@entry=0x7ffff64cba80, Str=";") at RewriteUtils.cpp:1348
1348      return !TheRewriter->ReplaceText(Body->getSourceRange(), Str);
(gdb) p FD
$1 = (const clang::FunctionDecl *) 0x7ffff64cba80
(gdb) p Body
$2 = <optimized out>
(gdb)

The following patch seems to fix the issue:

diff --git a/clang_delta/RewriteUtils.cpp b/clang_delta/RewriteUtils.cpp
index 272e1627aec1..bdf1b2309402 100644
--- a/clang_delta/RewriteUtils.cpp
+++ b/clang_delta/RewriteUtils.cpp
@@ -1344,6 +1344,8 @@ bool RewriteUtils::replaceFunctionDefWithStr(const 
FunctionDecl *FD,
                                              const std::string &Str)
 {
   const Stmt *Body = FD->getBody();
+  if (!Body)
+    return false;
   TransAssert(Body && "FunctionDecl is not a definition!");
   return !TheRewriter->ReplaceText(Body->getSourceRange(), Str);
 }


Reply via email to