[llvm-bugs] [Bug 32095] New: Null pointer crash caused by dyn_cast InheritanceGraphViewer
via llvm-bugs
llvm-bugs at lists.llvm.org
Tue Feb 28 08:06:43 PST 2017
http://bugs.llvm.org/show_bug.cgi?id=32095
Bug ID: 32095
Summary: Null pointer crash caused by dyn_cast
InheritanceGraphViewer
Product: clang
Version: trunk
Hardware: PC
OS: All
Status: NEW
Severity: normal
Priority: P
Component: Frontend
Assignee: unassignedclangbugs at nondot.org
Reporter: arphaman at gmail.com
CC: llvm-bugs at lists.llvm.org
Clang crashes when trying to generate inheritance graph for the record 'C' from
the following code:
template <class T> struct A {};
template <class U> class C: A<U>{};
Sample code from AST Visitor that reproduces this problem:
bool Visitor::VisitCXXRecordDecl(clang::CXXRecordDecl *c) {
if (c->getNumBases() || c->getNumVBases()) {
c->viewInheritance(astContext);
}
return true;
}
Backtrace:
* frame #0: 0x000000010089f970
libclang.dylib`clang::TagType::getDecl(this=0x0000000000000000) const + 16 at
Type.cpp:3018
frame #1: 0x00000001003dfbd5
libclang.dylib`clang::RecordType::getDecl(this=0x0000000000000000) const + 21
at Type.h:3760
frame #2: 0x00000001007aba01 libclang.dylib`(anonymous
namespace)::InheritanceHierarchyWriter::WriteNode(this=0x00007fff5fbfd5b0,
Type=QualType @ 0x00007fff5fbfd130, FromVirtual=false) + 2641 at
InheritViz.cpp:95
frame #3: 0x00000001007aaee2 libclang.dylib`(anonymous
namespace)::InheritanceHierarchyWriter::WriteGraph(this=0x00007fff5fbfd5b0,
Type=QualType @ 0x00007fff5fbfd538) + 146 at InheritViz.cpp:47
frame #4: 0x00000001007aad64
libclang.dylib`clang::CXXRecordDecl::viewInheritance(this=0x0000000110809150,
Context=0x000000010f805600) const + 564 at InheritViz.cpp:153
The problem is caused by this dyn_cast from InheritViz.cpp:
const CXXRecordDecl *Decl
= static_cast<const CXXRecordDecl *>(Type->getAs<RecordType>()->getDecl());
The actual type is:
InjectedClassNameType 0x7f868380e7d0 'C<U>' dependent
`-CXXRecord 0x7f868380e550 'C'
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20170228/833ff6b5/attachment.html>
More information about the llvm-bugs
mailing list