diff options
Diffstat (limited to 'tools')
-rw-r--r-- | tools/c-index-test/c-index-test.c | 14 | ||||
-rw-r--r-- | tools/libclang/CXComment.cpp | 64 | ||||
-rw-r--r-- | tools/libclang/libclang.exports | 1 |
3 files changed, 58 insertions, 21 deletions
diff --git a/tools/c-index-test/c-index-test.c b/tools/c-index-test/c-index-test.c index 574c9f7383..df7c72a9d8 100644 --- a/tools/c-index-test/c-index-test.c +++ b/tools/c-index-test/c-index-test.c @@ -283,6 +283,20 @@ static void DumpCXCommentInternal(struct CommentASTDumpingContext *Ctx, PrintCXStringWithPrefixAndDispose( "CommandName", clang_InlineCommandComment_getCommandName(Comment)); + switch (clang_InlineCommandComment_getRenderKind(Comment)) { + case CXCommentInlineCommandRenderKind_Normal: + printf(" RenderNormal"); + break; + case CXCommentInlineCommandRenderKind_Bold: + printf(" RenderBold"); + break; + case CXCommentInlineCommandRenderKind_Monospaced: + printf(" RenderMonospaced"); + break; + case CXCommentInlineCommandRenderKind_Emphasized: + printf(" RenderEmphasized"); + break; + } for (i = 0, e = clang_InlineCommandComment_getNumArgs(Comment); i != e; ++i) { printf(" Arg[%u]=", i); diff --git a/tools/libclang/CXComment.cpp b/tools/libclang/CXComment.cpp index b0ed9bcc00..6cd92356fd 100644 --- a/tools/libclang/CXComment.cpp +++ b/tools/libclang/CXComment.cpp @@ -126,6 +126,28 @@ CXString clang_InlineCommandComment_getCommandName(CXComment CXC) { return createCXString(ICC->getCommandName(), /*DupString=*/ false); } +enum CXCommentInlineCommandRenderKind +clang_InlineCommandComment_getRenderKind(CXComment CXC) { + const InlineCommandComment *ICC = getASTNodeAs<InlineCommandComment>(CXC); + if (!ICC) + return CXCommentInlineCommandRenderKind_Normal; + + switch (ICC->getRenderKind()) { + case InlineCommandComment::RenderNormal: + return CXCommentInlineCommandRenderKind_Normal; + + case InlineCommandComment::RenderBold: + return CXCommentInlineCommandRenderKind_Bold; + + case InlineCommandComment::RenderMonospaced: + return CXCommentInlineCommandRenderKind_Monospaced; + + case InlineCommandComment::RenderEmphasized: + return CXCommentInlineCommandRenderKind_Emphasized; + } + llvm_unreachable("unknown InlineCommandComment::RenderKind"); +} + unsigned clang_InlineCommandComment_getNumArgs(CXComment CXC) { const InlineCommandComment *ICC = getASTNodeAs<InlineCommandComment>(CXC); if (!ICC) @@ -344,34 +366,34 @@ void CommentASTToHTMLConverter::visitTextComment(const TextComment *C) { void CommentASTToHTMLConverter::visitInlineCommandComment( const InlineCommandComment *C) { - StringRef CommandName = C->getCommandName(); - bool HasArg0 = C->getNumArgs() > 0 && !C->getArgText(0).empty(); - StringRef Arg0; - if (HasArg0) - Arg0 = C->getArgText(0); - - if (CommandName == "b") { - if (!HasArg0) - return; + // Nothing to render if no arguments supplied. + if (C->getNumArgs() == 0) + return; + + // Nothing to render if argument is empty. + StringRef Arg0 = C->getArgText(0); + if (Arg0.empty()) + return; + + switch (C->getRenderKind()) { + case InlineCommandComment::RenderNormal: + for (unsigned i = 0, e = C->getNumArgs(); i != e; ++i) + Result << C->getArgText(i) << " "; + return; + + case InlineCommandComment::RenderBold: + assert(C->getNumArgs() == 1); Result << "<b>" << Arg0 << "</b>"; return; - } - if (CommandName == "c" || CommandName == "p") { - if (!HasArg0) - return; + case InlineCommandComment::RenderMonospaced: + assert(C->getNumArgs() == 1); Result << "<tt>" << Arg0 << "</tt>"; return; - } - if (CommandName == "a" || CommandName == "e" || CommandName == "em") { - if (!HasArg0) - return; + case InlineCommandComment::RenderEmphasized: + assert(C->getNumArgs() == 1); Result << "<em>" << Arg0 << "</em>"; return; } - - // We don't recognize this command, so just print its arguments. - for (unsigned i = 0, e = C->getNumArgs(); i != e; ++i) - Result << C->getArgText(i) << " "; } void CommentASTToHTMLConverter::visitHTMLStartTagComment( diff --git a/tools/libclang/libclang.exports b/tools/libclang/libclang.exports index 7d3b2a9c5d..bc8c113fad 100644 --- a/tools/libclang/libclang.exports +++ b/tools/libclang/libclang.exports @@ -25,6 +25,7 @@ clang_Comment_isWhitespace clang_InlineContentComment_hasTrailingNewline clang_TextComment_getText clang_InlineCommandComment_getCommandName +clang_InlineCommandComment_getRenderKind clang_InlineCommandComment_getNumArgs clang_InlineCommandComment_getArgText clang_HTMLTagComment_getTagName |