Skip to content

Commit 4d8b33e

Browse files
committed
Markup: Move Doxygen converter into a proper MarkupASTNode visitor
Enclose the entire doc comment in /** */ to ensure that newlines don't cause comments to leak out and get parsed as C. rdar://problem/24923076
1 parent 4021836 commit 4d8b33e

File tree

5 files changed

+526
-417
lines changed

5 files changed

+526
-417
lines changed

include/swift/Markup/AST.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -729,6 +729,27 @@ bool isAFieldTag(StringRef Tag);
729729
void dump(const MarkupASTNode *Node, llvm::raw_ostream &OS, unsigned indent = 0);
730730
void printInlinesUnder(const MarkupASTNode *Node, llvm::raw_ostream &OS,
731731
bool PrintDecorators = false);
732+
733+
734+
template <typename ImplClass, typename RetTy = void, typename... Args>
735+
class MarkupASTVisitor {
736+
public:
737+
RetTy visit(const MarkupASTNode *Node, Args... args) {
738+
switch (Node->getKind()) {
739+
#define MARKUP_AST_NODE(Id, Parent) \
740+
case ASTNodeKind::Id: \
741+
return static_cast<ImplClass*>(this) \
742+
->visit##Id(cast<const Id>(Node), \
743+
::std::forward<Args>(args)...);
744+
#define ABSTRACT_MARKUP_AST_NODE(Id, Parent)
745+
#define MARKUP_AST_NODE_RANGE(Id, FirstId, LastId)
746+
#include "swift/Markup/ASTNodes.def"
747+
}
748+
}
749+
750+
virtual ~MarkupASTVisitor() {}
751+
};
752+
732753
} // namespace markup
733754
} // namespace swift
734755

0 commit comments

Comments
 (0)