[PATCH] D55489: Implement dumpFunctionDeclParameters in NodeDumper

Stephen Kelly via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Dec 9 05:44:55 PST 2018


steveire created this revision.
steveire added a reviewer: aaron.ballman.
Herald added a subscriber: cfe-commits.

Repository:
  rC Clang

https://reviews.llvm.org/D55489

Files:
  include/clang/AST/TextNodeDumper.h
  lib/AST/ASTDumper.cpp
  lib/AST/TextNodeDumper.cpp


Index: lib/AST/TextNodeDumper.cpp
===================================================================
--- lib/AST/TextNodeDumper.cpp
+++ lib/AST/TextNodeDumper.cpp
@@ -162,6 +162,12 @@
   OS << ")";
 }
 
+void TextNodeDumper::dumpFunctionDeclParameters(const FunctionDecl *D) {
+  if (!D->param_begin() && D->getNumParams())
+    TreeStructure.addChild(
+        [=] { OS << "<<NULL params x " << D->getNumParams() << ">>"; });
+}
+
 void TextNodeDumper::dumpDeclRef(const Decl *D, const char *Label) {
   if (!D)
     return;
Index: lib/AST/ASTDumper.cpp
===================================================================
--- lib/AST/ASTDumper.cpp
+++ lib/AST/ASTDumper.cpp
@@ -95,6 +95,12 @@
     void dumpDeclContext(const DeclContext *DC);
     void dumpLookups(const DeclContext *DC, bool DumpDecls);
     void dumpAttr(const Attr *A);
+    void dumpFunctionDeclParameters(const FunctionDecl *D) {
+      NodeDumper.dumpFunctionDeclParameters(D);
+      if (D->param_begin() || !D->getNumParams())
+        for (const ParmVarDecl *Parameter : D->parameters())
+          dumpDecl(Parameter);
+    }
 
     // C++ Utilities
     void dumpCXXCtorInitializer(const CXXCtorInitializer *Init);
@@ -901,11 +907,7 @@
           D->getTemplateSpecializationInfo())
     dumpTemplateArgumentList(*FTSI->TemplateArguments);
 
-  if (!D->param_begin() && D->getNumParams())
-    dumpChild([=] { OS << "<<NULL params x " << D->getNumParams() << ">>"; });
-  else
-    for (const ParmVarDecl *Parameter : D->parameters())
-      dumpDecl(Parameter);
+  dumpFunctionDeclParameters(D);
 
   if (const CXXConstructorDecl *C = dyn_cast<CXXConstructorDecl>(D))
     for (CXXConstructorDecl::init_const_iterator I = C->init_begin(),
Index: include/clang/AST/TextNodeDumper.h
===================================================================
--- include/clang/AST/TextNodeDumper.h
+++ include/clang/AST/TextNodeDumper.h
@@ -60,6 +60,7 @@
   void dumpName(const NamedDecl *ND);
   void dumpAccessSpecifier(AccessSpecifier AS);
   void dumpCXXTemporary(const CXXTemporary *Temporary);
+  void dumpFunctionDeclParameters(const FunctionDecl *D);
 
   void dumpDeclRef(const Decl *D, const char *Label = nullptr);
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D55489.177415.patch
Type: text/x-patch
Size: 2199 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20181209/877333c3/attachment.bin>


More information about the cfe-commits mailing list