Open Quuxplusone opened 10 years ago
Bugzilla Link | PR17665 |
Status | NEW |
Importance | P normal |
Reported by | octoploid (octoploid@yandex.com) |
Reported on | 2013-10-23 12:28:38 -0700 |
Last modified on | 2018-10-25 20:12:03 -0700 |
Version | trunk |
Hardware | PC Linux |
CC | alp@nuanti.com, llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk |
Fixed by commit(s) | |
Attachments | |
Blocks | |
Blocked by | |
See also |
Could you provide some code that reproduces the issue?
(In reply to comment #1)
> Could you provide some code that reproduces the issue?
Sorry, no. As I wrote above you need clang_delta from creduce to
trigger the issue.
I've been using the following patch as a workaround without any issues:
diff --git a/clang/lib/Analysis/CFG.cpp b/clang/lib/Analysis/CFG.cpp
index d6361e8767c7..d0335d1a3068 100644
--- a/clang/lib/Analysis/CFG.cpp
+++ b/clang/lib/Analysis/CFG.cpp
@@ -1112,7 +1112,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();
@@ -3596,7 +3596,7 @@ CFGBlock
*CFGBuilder::VisitCXXBindTemporaryExprForTemporaryDtors(
// a new block for the destructor which does not have as a successor
// anything built thus far. Control won't flow out of this block.
const CXXDestructorDecl *Dtor = E->getTemporary()->getDestructor();
- if (Dtor->isNoReturn()) {
+ if (Dtor && Dtor->isNoReturn()) {
Succ = B;
Block = createNoReturnBlock();
} else {
(In reply to comment #2)
> (In reply to comment #1)
> > Could you provide some code that reproduces the issue?
>
> Sorry, no. As I wrote above you need clang_delta from creduce to
> trigger the issue.
If there's no way to reproduce this with ordinary source input to clang,
getDestructor() is guaranteed to return non-null here and the fault lies with
the third-party tool.
Perhaps your clang_delta tool isn't synthesising the necessary implicit
destructor to form a valid AST?
(In reply to comment #3)
> (In reply to comment #2)
> > (In reply to comment #1)
> > > Could you provide some code that reproduces the issue?
> >
> > Sorry, no. As I wrote above you need clang_delta from creduce to
> > trigger the issue.
>
> If there's no way to reproduce this with ordinary source input to clang,
> getDestructor() is guaranteed to return non-null here and the fault lies
> with the third-party tool.
>
> Perhaps your clang_delta tool isn't synthesising the necessary implicit
> destructor to form a valid AST?
Yes, that's possible. But isn't robustness when used with third-party tools
something to strive for?
(In reply to comment #4)
> (In reply to comment #3)
> > (In reply to comment #2)
> > > (In reply to comment #1)
> > > > Could you provide some code that reproduces the issue?
> > >
> > > Sorry, no. As I wrote above you need clang_delta from creduce to
> > > trigger the issue.
> >
> > If there's no way to reproduce this with ordinary source input to clang,
> > getDestructor() is guaranteed to return non-null here and the fault lies
> > with the third-party tool.
> >
> > Perhaps your clang_delta tool isn't synthesising the necessary implicit
> > destructor to form a valid AST?
>
> Yes, that's possible. But isn't robustness when used with third-party tools
> something to strive for?
Ordinarily I'd agree and say a null-check is pretty harmless.
In this case though I'm concerned that the tool could well be dropping a valid
declaration. Silently skipping here with a null check isn't necessarily the
right thing to do, especially since clang CodeGen also makes the same non-null
assumption.
So it's not a question of shifting the blame, but rather that this appears to
be uncovering some genuine undefined behaviour in the tool.
In this case it may be the nature of the tool. Creduce will
(as the name implies) try to reduce the input file as much as
possible. It never uses the CodeGen. It is a purely source to
source transformer.