r351601 - [ASTDump] Mark null params with a tag rather than a child node

Stephen Kelly via cfe-commits cfe-commits at lists.llvm.org
Fri Jan 18 14:00:17 PST 2019


Author: steveire
Date: Fri Jan 18 14:00:16 2019
New Revision: 351601

URL: http://llvm.org/viewvc/llvm-project?rev=351601&view=rev
Log:
[ASTDump] Mark null params with a tag rather than a child node

Reviewers: aaron.ballman

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D56753

Modified:
    cfe/trunk/lib/AST/ASTDumper.cpp

Modified: cfe/trunk/lib/AST/ASTDumper.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTDumper.cpp?rev=351601&r1=351600&r2=351601&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ASTDumper.cpp (original)
+++ cfe/trunk/lib/AST/ASTDumper.cpp Fri Jan 18 14:00:16 2019
@@ -633,13 +633,18 @@ void ASTDumper::VisitFunctionDecl(const
     }
   }
 
+  // Since NumParams comes from the FunctionProtoType of the FunctionDecl and
+  // the Params are set later, it is possible for a dump during debugging to
+  // encounter a FunctionDecl that has been created but hasn't been assigned
+  // ParmVarDecls yet.
+  if (!D->param_empty() && !D->param_begin())
+    OS << " <<<NULL params x " << D->getNumParams() << ">>>";
+
   if (const auto *FTSI = 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())
+  if (D->param_begin())
+    for (const auto *Parameter : D->parameters())
       dumpDecl(Parameter);
 
   if (const auto *C = dyn_cast<CXXConstructorDecl>(D))




More information about the cfe-commits mailing list