================ @@ -0,0 +1,304 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// +/// +/// \file +/// Defines the Markdown AST node hierarchy for the clang-doc Markdown parser. +/// +/// Block nodes represent structural constructs (paragraphs, headings, lists, +/// fenced code blocks, etc). Inline nodes represent span-level content (text, +/// emphasis, inline code) that appears inside block nodes. +/// +/// All nodes are arena-allocated via ASTContext, which manages their lifetime. +/// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_DOC_SUPPORT_MARKDOWN_H +#define LLVM_CLANG_TOOLS_EXTRA_CLANG_DOC_SUPPORT_MARKDOWN_H + +#include "llvm/ADT/StringRef.h" +#include "llvm/ADT/simple_ilist.h" +#include "llvm/Support/Casting.h" +#include "llvm/Support/Compiler.h" +#include "llvm/Support/raw_ostream.h" + +namespace clang::doc::markdown { + +enum class NodeKind { + // Inline nodes + NK_Text, + NK_InlineCode, + NK_Emphasis, + NK_Strong, + // Block nodes + NK_Paragraph, + NK_Heading, + NK_FencedCode, + NK_Table, // TODO: add TableNode + NK_UnorderedList, + NK_OrderedList, + NK_BlockQuote, + NK_ThematicBreak, + NK_Document, +}; + +/// Base class for all inline nodes. Inline nodes represent span-level content +/// such as text, emphasis, and inline code. +class InlineNode : public llvm::ilist_node<InlineNode> { +public: + explicit InlineNode(NodeKind K) : Kind(K) {} + virtual ~InlineNode() = default; + NodeKind getKind() const { return Kind; } + /// Recursively prints the node and its children to OS. + virtual void print(llvm::raw_ostream &OS) const = 0; + /// Prints to llvm::errs(). Only available in assert builds. + LLVM_DUMP_METHOD void dump() const; ---------------- ilovepi wrote:
I think you need to wrap this with macros, per the documentation for the attribute, if you want to guarantee it won't be compiled in outside of assert builds. https://github.com/llvm/llvm-project/blob/0705e7be49abd0d0f8b545065700a04322e2682c/llvm/include/llvm/Support/Compiler.h#L656-L667 I'd also just move the definition inline, since this is an abstract base class anyway. https://github.com/llvm/llvm-project/pull/205609 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
