[PATCH] D15254: Fix crash when dumping NamedDecl with NULL getQualifier().
Dawn Perchik via cfe-commits
cfe-commits at lists.llvm.org
Fri Dec 4 18:48:57 PST 2015
dawn created this revision.
dawn added reviewers: rsmith, alexfh.
dawn added a subscriber: cfe-commits.
dawn set the repository for this revision to rL LLVM.
This fixes calls to the dump() routine for cases when the NamedDecl's getQualifier() is NULL.
Since ASTDumper is a debugging utility, it should handle the case that getQualifier() is NULL. I don't know if the crash can happen in clang, but it can happen while debugging lldb for the source:
namespace ns {
int func();
int context() {
// execution context is here
}
}
commands in lldb being debugged:
p ns::func() <- adds the namespace to decl map in lldb
p func() <- crash while dumping the NamedDecl of the function's parent's
declaration contexts because getQualifier() is NULL.
Repository:
rL LLVM
http://reviews.llvm.org/D15254
Files:
lib/AST/ASTDumper.cpp
Index: lib/AST/ASTDumper.cpp
===================================================================
--- lib/AST/ASTDumper.cpp
+++ lib/AST/ASTDumper.cpp
@@ -1385,7 +1385,8 @@
void ASTDumper::VisitUsingDecl(const UsingDecl *D) {
OS << ' ';
- D->getQualifier()->print(OS, D->getASTContext().getPrintingPolicy());
+ if (D->getQualifier())
+ D->getQualifier()->print(OS, D->getASTContext().getPrintingPolicy());
OS << D->getNameAsString();
}
@@ -1392,13 +1393,15 @@
void ASTDumper::VisitUnresolvedUsingTypenameDecl(
const UnresolvedUsingTypenameDecl *D) {
OS << ' ';
- D->getQualifier()->print(OS, D->getASTContext().getPrintingPolicy());
+ if (D->getQualifier())
+ D->getQualifier()->print(OS, D->getASTContext().getPrintingPolicy());
OS << D->getNameAsString();
}
void ASTDumper::VisitUnresolvedUsingValueDecl(const UnresolvedUsingValueDecl *D) {
OS << ' ';
- D->getQualifier()->print(OS, D->getASTContext().getPrintingPolicy());
+ if (D->getQualifier())
+ D->getQualifier()->print(OS, D->getASTContext().getPrintingPolicy());
OS << D->getNameAsString();
dumpType(D->getType());
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D15254.41968.patch
Type: text/x-patch
Size: 1128 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20151205/7f1b759f/attachment.bin>
More information about the cfe-commits
mailing list