[PATCH] D55490: Add dumpMethodDeclOverrides to NodeDumper

Stephen Kelly via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Dec 9 05:45:16 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/D55490

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
@@ -168,6 +168,29 @@
         [=] { OS << "<<NULL params x " << D->getNumParams() << ">>"; });
 }
 
+void TextNodeDumper::dumpMethodDeclOverrides(const CXXMethodDecl *D) {
+  if (D->size_overridden_methods() != 0) {
+    auto dumpOverride = [=](const CXXMethodDecl *D) {
+      SplitQualType T_split = D->getType().split();
+      OS << D << " " << D->getParent()->getName()
+         << "::" << D->getNameAsString() << " '"
+         << QualType::getAsString(T_split, PrintPolicy) << "'";
+    };
+
+    TreeStructure.addChild([=] {
+      auto Overrides = D->overridden_methods();
+      OS << "Overrides: [ ";
+      dumpOverride(*Overrides.begin());
+      for (const auto *Override :
+           llvm::make_range(Overrides.begin() + 1, Overrides.end())) {
+        OS << ", ";
+        dumpOverride(Override);
+      }
+      OS << " ]";
+    });
+  }
+}
+
 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
@@ -101,6 +101,9 @@
         for (const ParmVarDecl *Parameter : D->parameters())
           dumpDecl(Parameter);
     }
+    void dumpMethodDeclOverrides(const CXXMethodDecl *D) {
+      NodeDumper.dumpMethodDeclOverrides(D);
+    }
 
     // C++ Utilities
     void dumpCXXCtorInitializer(const CXXCtorInitializer *Init);
@@ -916,26 +919,7 @@
       dumpCXXCtorInitializer(*I);
 
   if (const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(D)) {
-    if (MD->size_overridden_methods() != 0) {
-      auto dumpOverride = [=](const CXXMethodDecl *D) {
-        SplitQualType T_split = D->getType().split();
-        OS << D << " " << D->getParent()->getName()
-           << "::" << D->getNameAsString() << " '"
-           << QualType::getAsString(T_split, PrintPolicy) << "'";
-      };
-
-      dumpChild([=] {
-        auto Overrides = MD->overridden_methods();
-        OS << "Overrides: [ ";
-        dumpOverride(*Overrides.begin());
-        for (const auto *Override :
-             llvm::make_range(Overrides.begin() + 1, Overrides.end())) {
-          OS << ", ";
-          dumpOverride(Override);
-        }
-        OS << " ]";
-      });
-    }
+    dumpMethodDeclOverrides(MD);
   }
 
   if (D->doesThisDeclarationHaveABody())
Index: include/clang/AST/TextNodeDumper.h
===================================================================
--- include/clang/AST/TextNodeDumper.h
+++ include/clang/AST/TextNodeDumper.h
@@ -61,6 +61,7 @@
   void dumpAccessSpecifier(AccessSpecifier AS);
   void dumpCXXTemporary(const CXXTemporary *Temporary);
   void dumpFunctionDeclParameters(const FunctionDecl *D);
+  void dumpMethodDeclOverrides(const CXXMethodDecl *D);
 
   void dumpDeclRef(const Decl *D, const char *Label = nullptr);
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D55490.177416.patch
Type: text/x-patch
Size: 3006 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20181209/7c63be3d/attachment.bin>


More information about the cfe-commits mailing list