================ @@ -0,0 +1,93 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include "Markdown.h" + +namespace clang::doc::markdown { + +// TODO: print() currently outputs nodes flat with no indentation. Add +// S-expression style formatting (as used by the Swift AST printer) to make +// dumped trees easier to read. + +LLVM_DUMP_METHOD void InlineNode::dump() const { print(llvm::errs()); } + +void TextNode::print(llvm::raw_ostream &OS) const { + OS << "TextNode: " << getText() << "\n"; +} + +void InlineCodeNode::print(llvm::raw_ostream &OS) const { + OS << "InlineCodeNode: " << getCode() << "\n"; +} + +void EmphasisNode::print(llvm::raw_ostream &OS) const { + OS << "EmphasisNode\n"; + for (const auto &Child : children()) + Child.print(OS); +} + +void StrongNode::print(llvm::raw_ostream &OS) const { + OS << "StrongNode\n"; + for (const auto &Child : children()) + Child.print(OS); +} + +LLVM_DUMP_METHOD void BlockNode::dump() const { print(llvm::errs()); } ---------------- ilovepi wrote:
Do these need to be defined out of line in every derived class? they call the virtual `print()`, so I'd expect they would dispatch correctly... that's sort of the point of overriding the virtual method. https://github.com/llvm/llvm-project/pull/205609 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
