r348101 - Replace FullComment member being visited with parameter

Stephen Kelly via cfe-commits cfe-commits at lists.llvm.org
Sun Dec 2 09:30:40 PST 2018


Author: steveire
Date: Sun Dec  2 09:30:40 2018
New Revision: 348101

URL: http://llvm.org/viewvc/llvm-project?rev=348101&view=rev
Log:
Replace FullComment member being visited with parameter

Reviewers: aaron.ballman

Subscribers: cfe-commits

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

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=348101&r1=348100&r2=348101&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ASTDumper.cpp (original)
+++ cfe/trunk/lib/AST/ASTDumper.cpp Sun Dec  2 09:30:40 2018
@@ -109,8 +109,11 @@ namespace  {
   };
 
   class ASTDumper
-      : public ConstDeclVisitor<ASTDumper>, public ConstStmtVisitor<ASTDumper>,
-        public ConstCommentVisitor<ASTDumper>, public TypeVisitor<ASTDumper> {
+      : public ConstDeclVisitor<ASTDumper>,
+        public ConstStmtVisitor<ASTDumper>,
+        public ConstCommentVisitor<ASTDumper, void, const FullComment *>,
+        public TypeVisitor<ASTDumper> {
+
     raw_ostream &OS;
     const CommandTraits *Traits;
     const SourceManager *SM;
@@ -139,9 +142,6 @@ namespace  {
     const char *LastLocFilename = "";
     unsigned LastLocLine = ~0U;
 
-    /// The \c FullComment parent of the comment being dumped.
-    const FullComment *FC = nullptr;
-
     const bool ShowColors;
 
     /// Dump a child of the current node.
@@ -161,8 +161,7 @@ namespace  {
         return;
       }
 
-      const FullComment *OrigFC = FC;
-      auto dumpWithIndent = [this, doDumpChild, OrigFC](bool isLastChild) {
+      auto dumpWithIndent = [this, doDumpChild](bool isLastChild) {
         // Print out the appropriate tree structure and work out the prefix for
         // children of this node. For instance:
         //
@@ -186,7 +185,6 @@ namespace  {
         FirstChild = true;
         unsigned Depth = Pending.size();
 
-        FC = OrigFC;
         doDumpChild();
 
         // If any children are left, they're the last at their nesting level.
@@ -584,21 +582,30 @@ namespace  {
 
     // Comments.
     const char *getCommandName(unsigned CommandID);
-    void dumpComment(const Comment *C);
+    void dumpComment(const Comment *C, const FullComment *FC);
 
     // Inline comments.
-    void visitTextComment(const TextComment *C);
-    void visitInlineCommandComment(const InlineCommandComment *C);
-    void visitHTMLStartTagComment(const HTMLStartTagComment *C);
-    void visitHTMLEndTagComment(const HTMLEndTagComment *C);
+    void visitTextComment(const TextComment *C, const FullComment *FC);
+    void visitInlineCommandComment(const InlineCommandComment *C,
+                                   const FullComment *FC);
+    void visitHTMLStartTagComment(const HTMLStartTagComment *C,
+                                  const FullComment *FC);
+    void visitHTMLEndTagComment(const HTMLEndTagComment *C,
+                                const FullComment *FC);
 
     // Block comments.
-    void visitBlockCommandComment(const BlockCommandComment *C);
-    void visitParamCommandComment(const ParamCommandComment *C);
-    void visitTParamCommandComment(const TParamCommandComment *C);
-    void visitVerbatimBlockComment(const VerbatimBlockComment *C);
-    void visitVerbatimBlockLineComment(const VerbatimBlockLineComment *C);
-    void visitVerbatimLineComment(const VerbatimLineComment *C);
+    void visitBlockCommandComment(const BlockCommandComment *C,
+                                  const FullComment *FC);
+    void visitParamCommandComment(const ParamCommandComment *C,
+                                  const FullComment *FC);
+    void visitTParamCommandComment(const TParamCommandComment *C,
+                                   const FullComment *FC);
+    void visitVerbatimBlockComment(const VerbatimBlockComment *C,
+                                   const FullComment *FC);
+    void visitVerbatimBlockLineComment(const VerbatimBlockLineComment *C,
+                                       const FullComment *FC);
+    void visitVerbatimLineComment(const VerbatimLineComment *C,
+                                  const FullComment *FC);
   };
 }
 
@@ -2640,13 +2647,10 @@ const char *ASTDumper::getCommandName(un
 void ASTDumper::dumpFullComment(const FullComment *C) {
   if (!C)
     return;
-
-  FC = C;
-  dumpComment(C);
-  FC = nullptr;
+  dumpComment(C, C);
 }
 
-void ASTDumper::dumpComment(const Comment *C) {
+void ASTDumper::dumpComment(const Comment *C, const FullComment *FC) {
   dumpChild([=] {
     if (!C) {
       ColorScope Color(OS, ShowColors, NullColor);
@@ -2660,18 +2664,19 @@ void ASTDumper::dumpComment(const Commen
     }
     dumpPointer(C);
     dumpSourceRange(C->getSourceRange());
-    ConstCommentVisitor<ASTDumper>::visit(C);
+    ConstCommentVisitor<ASTDumper, void, const FullComment *>::visit(C, FC);
     for (Comment::child_iterator I = C->child_begin(), E = C->child_end();
          I != E; ++I)
-      dumpComment(*I);
+      dumpComment(*I, FC);
   });
 }
 
-void ASTDumper::visitTextComment(const TextComment *C) {
+void ASTDumper::visitTextComment(const TextComment *C, const FullComment *) {
   OS << " Text=\"" << C->getText() << "\"";
 }
 
-void ASTDumper::visitInlineCommandComment(const InlineCommandComment *C) {
+void ASTDumper::visitInlineCommandComment(const InlineCommandComment *C,
+                                          const FullComment *) {
   OS << " Name=\"" << getCommandName(C->getCommandID()) << "\"";
   switch (C->getRenderKind()) {
   case InlineCommandComment::RenderNormal:
@@ -2692,7 +2697,8 @@ void ASTDumper::visitInlineCommandCommen
     OS << " Arg[" << i << "]=\"" << C->getArgText(i) << "\"";
 }
 
-void ASTDumper::visitHTMLStartTagComment(const HTMLStartTagComment *C) {
+void ASTDumper::visitHTMLStartTagComment(const HTMLStartTagComment *C,
+                                         const FullComment *) {
   OS << " Name=\"" << C->getTagName() << "\"";
   if (C->getNumAttrs() != 0) {
     OS << " Attrs: ";
@@ -2705,17 +2711,20 @@ void ASTDumper::visitHTMLStartTagComment
     OS << " SelfClosing";
 }
 
-void ASTDumper::visitHTMLEndTagComment(const HTMLEndTagComment *C) {
+void ASTDumper::visitHTMLEndTagComment(const HTMLEndTagComment *C,
+                                       const FullComment *) {
   OS << " Name=\"" << C->getTagName() << "\"";
 }
 
-void ASTDumper::visitBlockCommandComment(const BlockCommandComment *C) {
+void ASTDumper::visitBlockCommandComment(const BlockCommandComment *C,
+                                         const FullComment *) {
   OS << " Name=\"" << getCommandName(C->getCommandID()) << "\"";
   for (unsigned i = 0, e = C->getNumArgs(); i != e; ++i)
     OS << " Arg[" << i << "]=\"" << C->getArgText(i) << "\"";
 }
 
-void ASTDumper::visitParamCommandComment(const ParamCommandComment *C) {
+void ASTDumper::visitParamCommandComment(const ParamCommandComment *C,
+                                         const FullComment *FC) {
   OS << " " << ParamCommandComment::getDirectionAsString(C->getDirection());
 
   if (C->isDirectionExplicit())
@@ -2734,7 +2743,8 @@ void ASTDumper::visitParamCommandComment
     OS << " ParamIndex=" << C->getParamIndex();
 }
 
-void ASTDumper::visitTParamCommandComment(const TParamCommandComment *C) {
+void ASTDumper::visitTParamCommandComment(const TParamCommandComment *C,
+                                          const FullComment *FC) {
   if (C->hasParamName()) {
     if (C->isPositionValid())
       OS << " Param=\"" << C->getParamName(FC) << "\"";
@@ -2753,17 +2763,19 @@ void ASTDumper::visitTParamCommandCommen
   }
 }
 
-void ASTDumper::visitVerbatimBlockComment(const VerbatimBlockComment *C) {
+void ASTDumper::visitVerbatimBlockComment(const VerbatimBlockComment *C,
+                                          const FullComment *) {
   OS << " Name=\"" << getCommandName(C->getCommandID()) << "\""
         " CloseName=\"" << C->getCloseName() << "\"";
 }
 
-void ASTDumper::visitVerbatimBlockLineComment(
-    const VerbatimBlockLineComment *C) {
+void ASTDumper::visitVerbatimBlockLineComment(const VerbatimBlockLineComment *C,
+                                              const FullComment *) {
   OS << " Text=\"" << C->getText() << "\"";
 }
 
-void ASTDumper::visitVerbatimLineComment(const VerbatimLineComment *C) {
+void ASTDumper::visitVerbatimLineComment(const VerbatimLineComment *C,
+                                         const FullComment *) {
   OS << " Text=\"" << C->getText() << "\"";
 }
 




More information about the cfe-commits mailing list