================ @@ -0,0 +1,157 @@ +//===----------------------------------------------------------------------===// +// +// 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" +#include "llvm/ADT/SmallVector.h" +#include "llvm/ADT/StringRef.h" +#include "llvm/Support/Allocator.h" +#include "llvm/Support/Debug.h" +#include "llvm/Support/raw_ostream.h" + +#define DEBUG_TYPE "clang-doc-markdown" + +namespace clang { +namespace doc { +namespace markdown { + +static MDNode makeText(llvm::StringRef S) { + return {NodeKind::NK_Text, S, {}}; +} + +// A line is a table separator if it only contains |, -, :, and spaces, +// and has at least one -. +static bool isSepRow(llvm::StringRef Line) { + return Line.contains('-') && + Line.find_first_not_of("|-: ") == llvm::StringRef::npos; +} + +static llvm::ArrayRef<MDNode> +allocateNodes(llvm::SmallVectorImpl<MDNode> &Nodes, + llvm::BumpPtrAllocator &Arena) { + if (Nodes.empty()) + return {}; + MDNode *Allocated = Arena.Allocate<MDNode>(Nodes.size()); + std::uninitialized_copy(Nodes.begin(), Nodes.end(), Allocated); + return llvm::ArrayRef<MDNode>(Allocated, Nodes.size()); +} + +llvm::ArrayRef<MDNode> parseMarkdown(llvm::StringRef ParagraphText, + llvm::BumpPtrAllocator &Arena) { + if (ParagraphText.trim().empty()) { + LLVM_DEBUG(llvm::dbgs() << "[md] empty input, returning nothing\n"); ---------------- ilovepi wrote:
It's pretty typical. https://github.com/llvm/llvm-project/blob/c8faaf9a9ef24873fe97d46554ad5fb909d0fd5d/llvm/lib/Support/Mustache.cpp#L391 We have lots of lines like this all over LLVM. LLVM_DEBUG just opens a scope that's optionally compiled in. What you linked to is a utility that basicallly wraps some of the basic LLVM_DEBUG usage. See https://github.com/llvm/llvm-project/blob/c8faaf9a9ef24873fe97d46554ad5fb909d0fd5d/llvm/include/llvm/Support/DebugLog.h#L29 This seems fairly recent (w/in the last year) from what I can tell, so maybe just use that. In mustache I wanted to tag things not just w/ the DEBUG_TYPE name, but the operation, so it made sense to do things that way. In your case the new macro may be just as easy. do note the advice in the programmers manual about wrapping the whole set of expressions in LLVM_DEBUG(...) though. https://github.com/llvm/llvm-project/pull/200302 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
