[PATCH] D141570: [clang] Add no-argument dump to DynTypedNode

Chris Cotter via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jan 11 23:45:46 PST 2023


ccotter updated this revision to Diff 488495.
ccotter added a comment.

remove accidental change


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D141570/new/

https://reviews.llvm.org/D141570

Files:
  clang/include/clang/AST/ASTTypeTraits.h
  clang/lib/AST/ASTTypeTraits.cpp


Index: clang/lib/AST/ASTTypeTraits.cpp
===================================================================
--- clang/lib/AST/ASTTypeTraits.cpp
+++ clang/lib/AST/ASTTypeTraits.cpp
@@ -213,6 +213,18 @@
     OS << "Unable to dump values of type " << NodeKind.asStringRef() << "\n";
 }
 
+void DynTypedNode::dump() const {
+  if (const Decl *D = get<Decl>())
+    D->dump();
+  else if (const Stmt *S = get<Stmt>())
+    S->dump();
+  else if (const Type *T = get<Type>())
+    T->dump();
+  else
+    llvm::errs() << "Unable to dump values of type " << NodeKind.asStringRef()
+                 << "\n";
+}
+
 SourceRange DynTypedNode::getSourceRange() const {
   if (const CXXCtorInitializer *CCI = get<CXXCtorInitializer>())
     return CCI->getSourceRange();
Index: clang/include/clang/AST/ASTTypeTraits.h
===================================================================
--- clang/include/clang/AST/ASTTypeTraits.h
+++ clang/include/clang/AST/ASTTypeTraits.h
@@ -296,6 +296,9 @@
   /// Dumps the node to the given output stream.
   void dump(llvm::raw_ostream &OS, const ASTContext &Context) const;
 
+  /// Dumps the node to \c llvm::errs().
+  void dump() const;
+
   /// For nodes which represent textual entities in the source code,
   /// return their SourceRange.  For all other nodes, return SourceRange().
   SourceRange getSourceRange() const;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D141570.488495.patch
Type: text/x-patch
Size: 1355 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230112/13a4f1f2/attachment.bin>


More information about the cfe-commits mailing list