diff --git a/clang/include/clang/AST/Comment.h b/clang/include/clang/AST/Comment.h index 7cbed3600d282..06effad42db45 100644 --- a/clang/include/clang/AST/Comment.h +++ b/clang/include/clang/AST/Comment.h @@ -297,31 +297,24 @@ class TextComment : public InlineContentComment { bool isWhitespaceNoCache() const; }; +/// The most appropriate rendering mode for this command, chosen on command +/// semantics in Doxygen. +enum InlineCommandRenderKind { Normal, Bold, Monospaced, Emphasized, Anchor }; + /// A command with word-like arguments that is considered inline content. class InlineCommandComment : public InlineContentComment { -public: - /// The most appropriate rendering mode for this command, chosen on command - /// semantics in Doxygen. - enum RenderKind { - RenderNormal, - RenderBold, - RenderMonospaced, - RenderEmphasized, - RenderAnchor - }; - protected: /// Command arguments. ArrayRef Args; public: InlineCommandComment(SourceLocation LocBegin, SourceLocation LocEnd, - unsigned CommandID, RenderKind RK, + unsigned CommandID, InlineCommandRenderKind RK, ArrayRef Args) : InlineContentComment(CommentKind::InlineCommandComment, LocBegin, LocEnd), Args(Args) { - InlineCommandCommentBits.RenderKind = RK; + InlineCommandCommentBits.RenderKind = llvm::to_underlying(RK); InlineCommandCommentBits.CommandID = CommandID; } @@ -345,8 +338,9 @@ class InlineCommandComment : public InlineContentComment { return SourceRange(getBeginLoc().getLocWithOffset(-1), getEndLoc()); } - RenderKind getRenderKind() const { - return static_cast(InlineCommandCommentBits.RenderKind); + InlineCommandRenderKind getRenderKind() const { + return static_cast( + InlineCommandCommentBits.RenderKind); } unsigned getNumArgs() const { diff --git a/clang/include/clang/AST/CommentSema.h b/clang/include/clang/AST/CommentSema.h index 5d8df7dbf385a..03f13283ac0d9 100644 --- a/clang/include/clang/AST/CommentSema.h +++ b/clang/include/clang/AST/CommentSema.h @@ -244,8 +244,7 @@ class Sema { StringRef Typo, const TemplateParameterList *TemplateParameters); - InlineCommandComment::RenderKind - getInlineCommandRenderKind(StringRef Name) const; + InlineCommandRenderKind getInlineCommandRenderKind(StringRef Name) const; }; } // end namespace comments diff --git a/clang/lib/AST/CommentSema.cpp b/clang/lib/AST/CommentSema.cpp index 66660512d6af5..6f68577954137 100644 --- a/clang/lib/AST/CommentSema.cpp +++ b/clang/lib/AST/CommentSema.cpp @@ -380,9 +380,7 @@ InlineContentComment *Sema::actOnUnknownCommand(SourceLocation LocBegin, unsigned CommandID) { ArrayRef Args; return new (Allocator) InlineCommandComment( - LocBegin, LocEnd, CommandID, - InlineCommandComment::RenderNormal, - Args); + LocBegin, LocEnd, CommandID, InlineCommandRenderKind::Normal, Args); } TextComment *Sema::actOnText(SourceLocation LocBegin, @@ -1108,16 +1106,15 @@ StringRef Sema::correctTypoInTParamReference( return StringRef(); } -InlineCommandComment::RenderKind -Sema::getInlineCommandRenderKind(StringRef Name) const { +InlineCommandRenderKind Sema::getInlineCommandRenderKind(StringRef Name) const { assert(Traits.getCommandInfo(Name)->IsInlineCommand); - return llvm::StringSwitch(Name) - .Case("b", InlineCommandComment::RenderBold) - .Cases("c", "p", InlineCommandComment::RenderMonospaced) - .Cases("a", "e", "em", InlineCommandComment::RenderEmphasized) - .Case("anchor", InlineCommandComment::RenderAnchor) - .Default(InlineCommandComment::RenderNormal); + return llvm::StringSwitch(Name) + .Case("b", InlineCommandRenderKind::Bold) + .Cases("c", "p", InlineCommandRenderKind::Monospaced) + .Cases("a", "e", "em", InlineCommandRenderKind::Emphasized) + .Case("anchor", InlineCommandRenderKind::Anchor) + .Default(InlineCommandRenderKind::Normal); } } // end namespace comments diff --git a/clang/lib/AST/JSONNodeDumper.cpp b/clang/lib/AST/JSONNodeDumper.cpp index bc7bc7337b15e..cfcf27ecddebb 100644 --- a/clang/lib/AST/JSONNodeDumper.cpp +++ b/clang/lib/AST/JSONNodeDumper.cpp @@ -1680,19 +1680,19 @@ void JSONNodeDumper::visitInlineCommandComment( JOS.attribute("name", getCommentCommandName(C->getCommandID())); switch (C->getRenderKind()) { - case comments::InlineCommandComment::RenderNormal: + case comments::InlineCommandRenderKind::Normal: JOS.attribute("renderKind", "normal"); break; - case comments::InlineCommandComment::RenderBold: + case comments::InlineCommandRenderKind::Bold: JOS.attribute("renderKind", "bold"); break; - case comments::InlineCommandComment::RenderEmphasized: + case comments::InlineCommandRenderKind::Emphasized: JOS.attribute("renderKind", "emphasized"); break; - case comments::InlineCommandComment::RenderMonospaced: + case comments::InlineCommandRenderKind::Monospaced: JOS.attribute("renderKind", "monospaced"); break; - case comments::InlineCommandComment::RenderAnchor: + case comments::InlineCommandRenderKind::Anchor: JOS.attribute("renderKind", "anchor"); break; } diff --git a/clang/lib/AST/TextNodeDumper.cpp b/clang/lib/AST/TextNodeDumper.cpp index 8d0f421e3a7db..e8274fcd5cfe9 100644 --- a/clang/lib/AST/TextNodeDumper.cpp +++ b/clang/lib/AST/TextNodeDumper.cpp @@ -862,19 +862,19 @@ void TextNodeDumper::visitInlineCommandComment( const comments::InlineCommandComment *C, const comments::FullComment *) { OS << " Name=\"" << getCommandName(C->getCommandID()) << "\""; switch (C->getRenderKind()) { - case comments::InlineCommandComment::RenderNormal: + case comments::InlineCommandRenderKind::Normal: OS << " RenderNormal"; break; - case comments::InlineCommandComment::RenderBold: + case comments::InlineCommandRenderKind::Bold: OS << " RenderBold"; break; - case comments::InlineCommandComment::RenderMonospaced: + case comments::InlineCommandRenderKind::Monospaced: OS << " RenderMonospaced"; break; - case comments::InlineCommandComment::RenderEmphasized: + case comments::InlineCommandRenderKind::Emphasized: OS << " RenderEmphasized"; break; - case comments::InlineCommandComment::RenderAnchor: + case comments::InlineCommandRenderKind::Anchor: OS << " RenderAnchor"; break; } diff --git a/clang/lib/Index/CommentToXML.cpp b/clang/lib/Index/CommentToXML.cpp index ddd3498f92718..e7f5bfebec233 100644 --- a/clang/lib/Index/CommentToXML.cpp +++ b/clang/lib/Index/CommentToXML.cpp @@ -274,32 +274,32 @@ void CommentASTToHTMLConverter::visitInlineCommandComment( return; switch (C->getRenderKind()) { - case InlineCommandComment::RenderNormal: + case InlineCommandRenderKind::Normal: for (unsigned i = 0, e = C->getNumArgs(); i != e; ++i) { appendToResultWithHTMLEscaping(C->getArgText(i)); Result << " "; } return; - case InlineCommandComment::RenderBold: + case InlineCommandRenderKind::Bold: assert(C->getNumArgs() == 1); Result << ""; appendToResultWithHTMLEscaping(Arg0); Result << ""; return; - case InlineCommandComment::RenderMonospaced: + case InlineCommandRenderKind::Monospaced: assert(C->getNumArgs() == 1); Result << ""; appendToResultWithHTMLEscaping(Arg0); Result<< ""; return; - case InlineCommandComment::RenderEmphasized: + case InlineCommandRenderKind::Emphasized: assert(C->getNumArgs() == 1); Result << ""; appendToResultWithHTMLEscaping(Arg0); Result << ""; return; - case InlineCommandComment::RenderAnchor: + case InlineCommandRenderKind::Anchor: assert(C->getNumArgs() == 1); Result << ""; return; @@ -623,31 +623,31 @@ void CommentASTToXMLConverter::visitInlineCommandComment( return; switch (C->getRenderKind()) { - case InlineCommandComment::RenderNormal: + case InlineCommandRenderKind::Normal: for (unsigned i = 0, e = C->getNumArgs(); i != e; ++i) { appendToResultWithXMLEscaping(C->getArgText(i)); Result << " "; } return; - case InlineCommandComment::RenderBold: + case InlineCommandRenderKind::Bold: assert(C->getNumArgs() == 1); Result << ""; appendToResultWithXMLEscaping(Arg0); Result << ""; return; - case InlineCommandComment::RenderMonospaced: + case InlineCommandRenderKind::Monospaced: assert(C->getNumArgs() == 1); Result << ""; appendToResultWithXMLEscaping(Arg0); Result << ""; return; - case InlineCommandComment::RenderEmphasized: + case InlineCommandRenderKind::Emphasized: assert(C->getNumArgs() == 1); Result << ""; appendToResultWithXMLEscaping(Arg0); Result << ""; return; - case InlineCommandComment::RenderAnchor: + case InlineCommandRenderKind::Anchor: assert(C->getNumArgs() == 1); Result << ""; return; diff --git a/clang/tools/libclang/CXComment.cpp b/clang/tools/libclang/CXComment.cpp index 79b42ae0c0012..5abbf9c1161a1 100644 --- a/clang/tools/libclang/CXComment.cpp +++ b/clang/tools/libclang/CXComment.cpp @@ -148,19 +148,19 @@ clang_InlineCommandComment_getRenderKind(CXComment CXC) { return CXCommentInlineCommandRenderKind_Normal; switch (ICC->getRenderKind()) { - case InlineCommandComment::RenderNormal: + case InlineCommandRenderKind::Normal: return CXCommentInlineCommandRenderKind_Normal; - case InlineCommandComment::RenderBold: + case InlineCommandRenderKind::Bold: return CXCommentInlineCommandRenderKind_Bold; - case InlineCommandComment::RenderMonospaced: + case InlineCommandRenderKind::Monospaced: return CXCommentInlineCommandRenderKind_Monospaced; - case InlineCommandComment::RenderEmphasized: + case InlineCommandRenderKind::Emphasized: return CXCommentInlineCommandRenderKind_Emphasized; - case InlineCommandComment::RenderAnchor: + case InlineCommandRenderKind::Anchor: return CXCommentInlineCommandRenderKind_Anchor; } llvm_unreachable("unknown InlineCommandComment::RenderKind");