[clang-tools-extra] [clang-doc] Add Markdown AST node type definitions (PR #205609)
Paul Kirth via cfe-commits
cfe-commits at lists.llvm.org
Wed Jun 24 21:24:08 PDT 2026
================
@@ -0,0 +1,174 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_DOC_SUPPORT_MARKDOWN_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_DOC_SUPPORT_MARKDOWN_H
+
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/StringRef.h"
+#include <type_traits>
+
+namespace clang::doc::markdown {
+
+enum class NodeKind {
+ NK_Text,
+ NK_InlineCode,
+ NK_Emphasis,
+ NK_Strong,
+ NK_Paragraph,
+ NK_Heading,
+ NK_FencedCode,
+ NK_Table,
+ NK_UnorderedList,
+ NK_OrderedList,
+ NK_ListItem,
+ NK_BlockQuote,
+ NK_ThematicBreak,
+};
+
+struct Node {
+ NodeKind Kind;
+ explicit Node(NodeKind K) : Kind(K) {}
+};
+
+struct TextNode : Node {
+ llvm::StringRef Text;
+ explicit TextNode(llvm::StringRef T) : Node(NodeKind::NK_Text), Text(T) {}
+ static bool classof(const Node *N) { return N->Kind == NodeKind::NK_Text; }
----------------
ilovepi wrote:
It's probably a good practice to include the `llvm/Support/Casting.h` header here if you intend this to work w/ llvm style casts. Otherwise any file that uses the type needs to know it has to includ the header to use the casting facilities.
https://github.com/llvm/llvm-project/pull/205609
More information about the cfe-commits
mailing list