From 39271a195babb514ce99226f0718000f0d592aab Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 9 Dec 2018 13:20:43 +0000 Subject: [PATCH] Inline hasNodes into only caller It is easier to refactor with fewer utility methods. llvm-svn: 348716 --- clang/lib/AST/ASTDumper.cpp | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/clang/lib/AST/ASTDumper.cpp b/clang/lib/AST/ASTDumper.cpp index 78f8a9e..b95813e 100644 --- a/clang/lib/AST/ASTDumper.cpp +++ b/clang/lib/AST/ASTDumper.cpp @@ -91,7 +91,6 @@ namespace { void dumpTypeAsChild(const Type *T); void dumpDeclRef(const Decl *Node, const char *Label = nullptr); void dumpBareDeclRef(const Decl *Node) { NodeDumper.dumpBareDeclRef(Node); } - bool hasNodes(const DeclContext *DC); void dumpDeclContext(const DeclContext *DC); void dumpLookups(const DeclContext *DC, bool DumpDecls); void dumpAttr(const Attr *A); @@ -539,15 +538,6 @@ void ASTDumper::dumpDeclRef(const Decl *D, const char *Label) { }); } -bool ASTDumper::hasNodes(const DeclContext *DC) { - if (!DC) - return false; - - return DC->hasExternalLexicalStorage() || - (Deserialize ? DC->decls_begin() != DC->decls_end() - : DC->noload_decls_begin() != DC->noload_decls_end()); -} - void ASTDumper::dumpDeclContext(const DeclContext *DC) { if (!DC) return; @@ -833,9 +823,14 @@ void ASTDumper::dumpDecl(const Decl *D) { dumpComment(Comment, Comment); // Decls within functions are visited by the body. - if (!isa(*D) && !isa(*D) && - hasNodes(dyn_cast(D))) - dumpDeclContext(cast(D)); + if (!isa(*D) && !isa(*D)) { + auto DC = dyn_cast(D); + if (DC && + (DC->hasExternalLexicalStorage() || + (Deserialize ? DC->decls_begin() != DC->decls_end() + : DC->noload_decls_begin() != DC->noload_decls_end()))) + dumpDeclContext(DC); + } }); } -- 2.7.4