r305860 - Special-case handling of destructors in override lists when dumping ASTs.
Lang Hames via cfe-commits
cfe-commits at lists.llvm.org
Thu Jul 13 14:09:44 PDT 2017
FWIW: Replacing the call to getName with getNameAsString seems to fix the
destructor issue as well (i.e. I can remove the special case for
destructors) so I've committed this r307959.
If the getName failure for destructors is unexpected it may be worth
digging into as a separate issue.
Cheers,
Lang.
On Thu, Jul 13, 2017 at 2:00 PM, Lang Hames <lhames at gmail.com> wrote:
> Sure.
>
> Richard - is this likely to be related to your query? Calling getName() on
> at least one destructor in Sema/ms_class_layout triggers the assertion in
> NamedDecl::getName():
>
> (lldb)
> frame #4: 0x00000001039600e2 clang`clang::NamedDecl::getName(this=0x0000000112897490)
> const at Decl.h:238
> 235 /// This requires that the declaration have a name and that it
> be a simple
> 236 /// identifier.
> 237 StringRef getName() const {
> -> 238 assert(Name.isIdentifier() && "Name is not a simple
> identifier");
> 239 return getIdentifier() ? getIdentifier()->getName() : "";
> 240 }
> 241
> (lldb) expr this->dump()
> CXXDestructorDecl 0x112897490 </Users/lhames/Projects/llvm/
> llvm-svn-tot/llvm/tools/clang/test/Sema/ms_class_layout.cpp:102:3,
> col:17> col:11 used ~IA 'void (void) __attribute__((thiscall))' virtual
> `-CompoundStmt 0x1128977f8 <col:16, col:17>
>
> - Lang.
>
> On Wed, Jul 12, 2017 at 10:36 PM, Akira Hatanaka <ahatanaka at apple.com>
> wrote:
>
>> Hi Lang,
>>
>> clang crashes when I compile the following code with "-Xclang -ast-dump”:
>>
>> class Base {
>> public:
>> virtual void operator()() {}
>> };
>>
>> class Derived : public Base {
>> public:
>> void operator()() override {}
>> };
>>
>> If I change “OS << D->getName()” to “OS << D->getNameAsString()”, the
>> crash disappears.
>>
>> Can you take a look please?
>>
>> On Jun 20, 2017, at 2:30 PM, Lang Hames via cfe-commits <
>> cfe-commits at lists.llvm.org> wrote:
>>
>> Author: lhames
>> Date: Tue Jun 20 16:30:43 2017
>> New Revision: 305860
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=305860&view=rev
>> Log:
>> Special-case handling of destructors in override lists when dumping ASTs.
>>
>> Fixes a bug in r305850: CXXDestructors don't have names, so we need to
>> handle
>> printing of them separately.
>>
>>
>> Modified:
>> cfe/trunk/lib/AST/ASTDumper.cpp
>>
>> Modified: cfe/trunk/lib/AST/ASTDumper.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTDum
>> per.cpp?rev=305860&r1=305859&r2=305860&view=diff
>> ============================================================
>> ==================
>> --- cfe/trunk/lib/AST/ASTDumper.cpp (original)
>> +++ cfe/trunk/lib/AST/ASTDumper.cpp Tue Jun 20 16:30:43 2017
>> @@ -1189,9 +1189,12 @@ void ASTDumper::VisitFunctionDecl(const
>> auto dumpOverride =
>> [=](const CXXMethodDecl *D) {
>> SplitQualType T_split = D->getType().split();
>> - OS << D << " " << D->getParent()->getName() << "::"
>> - << D->getName() << " '"
>> - << QualType::getAsString(T_split) << "'";
>> + OS << D << " " << D->getParent()->getName() << "::";
>> + if (isa<CXXDestructorDecl>(D))
>> + OS << "~" << D->getParent()->getName();
>> + else
>> + OS << D->getName();
>>
>> + OS << " '" << QualType::getAsString(T_split) << "'";
>> };
>>
>> dumpChild([=] {
>>
>>
>> _______________________________________________
>> cfe-commits mailing list
>> cfe-commits at lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170713/db7f9412/attachment.html>
More information about the cfe-commits
mailing list