[clang-tools-extra] [clang-doc] add Markdown parser (PR #155887)
Paul Kirth via cfe-commits
cfe-commits at lists.llvm.org
Fri Aug 29 13:55:07 PDT 2025
================
@@ -0,0 +1,99 @@
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_DOC_MD_PARSER_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_DOC_MD_PARSER_H
+#include "llvm/ADT/SmallString.h"
+#include "llvm/Support/Allocator.h"
+#include "llvm/Support/StringSaver.h"
+#include <list>
+
+using namespace llvm;
+
+namespace clang {
+namespace doc {
+using llvm::SmallString;
+enum class MDState { Emphasis, Strong, None };
+
+enum class MDType {
+ Paragraph,
+ Emphasis,
+ Strong,
+ Text,
+ Softbreak,
+};
+
+enum class MDTokenType { LeftDelimiterRun, RightDelimiterRun, Text };
+
+struct Node {
+ SmallVector<Node*> Children;
+ MDType Type;
+ Node *Parent;
+ std::string Content;
+};
+
+struct DelimiterContext {
+ bool RightFlanking;
+ bool LeftFlanking;
+ bool CanOpen;
+ bool CanClose;
+ char DelimChar;
+ // Since Content is a StringRef, we separately track the length so that we can
+ // decrement when necessary without modifying the string.
+ size_t Length;
+};
----------------
ilovepi wrote:
```suggestion
struct DelimiterContext {
// Since Content is a StringRef, we separately track the length so that we can
// decrement when necessary without modifying the string.
size_t Length;
char DelimChar;
bool RightFlanking;
bool LeftFlanking;
bool CanOpen;
bool CanClose;
};
```
lets order the fields by size, so we avoid padding.
https://github.com/llvm/llvm-project/pull/155887
More information about the cfe-commits
mailing list