Loading clang/include/clang/AST/Comment.h +90 −113 Original line number Diff line number Diff line Loading @@ -47,6 +47,17 @@ enum CommandMarkerKind { CMK_At = 1 }; enum class CommentKind { None = 0, #define COMMENT(CLASS, PARENT) CLASS, #define COMMENT_RANGE(BASE, FIRST, LAST) \ First##BASE##Constant = FIRST, Last##BASE##Constant = LAST, #define LAST_COMMENT_RANGE(BASE, FIRST, LAST) \ First##BASE##Constant = FIRST, Last##BASE##Constant = LAST #define ABSTRACT_COMMENT(COMMENT) #include "clang/AST/CommentNodes.inc" }; /// Any part of the comment. /// Abstract class. class Comment { Loading Loading @@ -183,17 +194,6 @@ protected: } public: enum CommentKind { NoCommentKind = 0, #define COMMENT(CLASS, PARENT) CLASS##Kind, #define COMMENT_RANGE(BASE, FIRST, LAST) \ First##BASE##Constant=FIRST##Kind, Last##BASE##Constant=LAST##Kind, #define LAST_COMMENT_RANGE(BASE, FIRST, LAST) \ First##BASE##Constant=FIRST##Kind, Last##BASE##Constant=LAST##Kind #define ABSTRACT_COMMENT(COMMENT) #include "clang/AST/CommentNodes.inc" }; struct Argument { SourceRange Range; StringRef Text; Loading @@ -203,7 +203,7 @@ public: SourceLocation LocBegin, SourceLocation LocEnd) : Loc(LocBegin), Range(SourceRange(LocBegin, LocEnd)) { CommentBits.Kind = K; CommentBits.Kind = llvm::to_underlying(K); } CommentKind getCommentKind() const { Loading Loading @@ -249,8 +249,9 @@ protected: public: static bool classof(const Comment *C) { return C->getCommentKind() >= FirstInlineContentCommentConstant && C->getCommentKind() <= LastInlineContentCommentConstant; return C->getCommentKind() >= CommentKind::FirstInlineContentCommentConstant && C->getCommentKind() <= CommentKind::LastInlineContentCommentConstant; } void addTrailingNewline() { Loading @@ -267,16 +268,14 @@ class TextComment : public InlineContentComment { StringRef Text; public: TextComment(SourceLocation LocBegin, SourceLocation LocEnd, StringRef Text) : InlineContentComment(TextCommentKind, LocBegin, LocEnd), TextComment(SourceLocation LocBegin, SourceLocation LocEnd, StringRef Text) : InlineContentComment(CommentKind::TextComment, LocBegin, LocEnd), Text(Text) { TextCommentBits.IsWhitespaceValid = false; } static bool classof(const Comment *C) { return C->getCommentKind() == TextCommentKind; return C->getCommentKind() == CommentKind::TextComment; } child_iterator child_begin() const { return nullptr; } Loading Loading @@ -316,19 +315,18 @@ protected: ArrayRef<Argument> Args; public: InlineCommandComment(SourceLocation LocBegin, SourceLocation LocEnd, unsigned CommandID, RenderKind RK, ArrayRef<Argument> Args) : InlineContentComment(InlineCommandCommentKind, LocBegin, LocEnd), InlineCommandComment(SourceLocation LocBegin, SourceLocation LocEnd, unsigned CommandID, RenderKind RK, ArrayRef<Argument> Args) : InlineContentComment(CommentKind::InlineCommandComment, LocBegin, LocEnd), Args(Args) { InlineCommandCommentBits.RenderKind = RK; InlineCommandCommentBits.CommandID = CommandID; } static bool classof(const Comment *C) { return C->getCommentKind() == InlineCommandCommentKind; return C->getCommentKind() == CommentKind::InlineCommandComment; } child_iterator child_begin() const { return nullptr; } Loading Loading @@ -386,8 +384,8 @@ protected: public: static bool classof(const Comment *C) { return C->getCommentKind() >= FirstHTMLTagCommentConstant && C->getCommentKind() <= LastHTMLTagCommentConstant; return C->getCommentKind() >= CommentKind::FirstHTMLTagCommentConstant && C->getCommentKind() <= CommentKind::LastHTMLTagCommentConstant; } StringRef getTagName() const LLVM_READONLY { return TagName; } Loading Loading @@ -443,18 +441,16 @@ private: ArrayRef<Attribute> Attributes; public: HTMLStartTagComment(SourceLocation LocBegin, StringRef TagName) : HTMLTagComment(HTMLStartTagCommentKind, LocBegin, LocBegin.getLocWithOffset(1 + TagName.size()), TagName, HTMLStartTagComment(SourceLocation LocBegin, StringRef TagName) : HTMLTagComment(CommentKind::HTMLStartTagComment, LocBegin, LocBegin.getLocWithOffset(1 + TagName.size()), TagName, LocBegin.getLocWithOffset(1), LocBegin.getLocWithOffset(1 + TagName.size())) { HTMLStartTagCommentBits.IsSelfClosing = false; } static bool classof(const Comment *C) { return C->getCommentKind() == HTMLStartTagCommentKind; return C->getCommentKind() == CommentKind::HTMLStartTagComment; } child_iterator child_begin() const { return nullptr; } Loading Loading @@ -498,18 +494,14 @@ public: /// A closing HTML tag. class HTMLEndTagComment : public HTMLTagComment { public: HTMLEndTagComment(SourceLocation LocBegin, SourceLocation LocEnd, StringRef TagName) : HTMLTagComment(HTMLEndTagCommentKind, LocBegin, LocEnd, TagName, LocBegin.getLocWithOffset(2), LocBegin.getLocWithOffset(2 + TagName.size())) { } HTMLEndTagComment(SourceLocation LocBegin, SourceLocation LocEnd, StringRef TagName) : HTMLTagComment(CommentKind::HTMLEndTagComment, LocBegin, LocEnd, TagName, LocBegin.getLocWithOffset(2), LocBegin.getLocWithOffset(2 + TagName.size())) {} static bool classof(const Comment *C) { return C->getCommentKind() == HTMLEndTagCommentKind; return C->getCommentKind() == CommentKind::HTMLEndTagComment; } child_iterator child_begin() const { return nullptr; } Loading @@ -529,8 +521,9 @@ protected: public: static bool classof(const Comment *C) { return C->getCommentKind() >= FirstBlockContentCommentConstant && C->getCommentKind() <= LastBlockContentCommentConstant; return C->getCommentKind() >= CommentKind::FirstBlockContentCommentConstant && C->getCommentKind() <= CommentKind::LastBlockContentCommentConstant; } }; Loading @@ -539,9 +532,8 @@ class ParagraphComment : public BlockContentComment { ArrayRef<InlineContentComment *> Content; public: ParagraphComment(ArrayRef<InlineContentComment *> Content) : BlockContentComment(ParagraphCommentKind, SourceLocation(), ParagraphComment(ArrayRef<InlineContentComment *> Content) : BlockContentComment(CommentKind::ParagraphComment, SourceLocation(), SourceLocation()), Content(Content) { if (Content.empty()) { Loading @@ -558,7 +550,7 @@ public: } static bool classof(const Comment *C) { return C->getCommentKind() == ParagraphCommentKind; return C->getCommentKind() == CommentKind::ParagraphComment; } child_iterator child_begin() const { Loading Loading @@ -606,11 +598,9 @@ protected: } public: BlockCommandComment(SourceLocation LocBegin, SourceLocation LocEnd, unsigned CommandID, CommandMarkerKind CommandMarker) : BlockContentComment(BlockCommandCommentKind, LocBegin, LocEnd), BlockCommandComment(SourceLocation LocBegin, SourceLocation LocEnd, unsigned CommandID, CommandMarkerKind CommandMarker) : BlockContentComment(CommentKind::BlockCommandComment, LocBegin, LocEnd), Paragraph(nullptr) { setLocation(getCommandNameBeginLoc()); BlockCommandCommentBits.CommandID = CommandID; Loading @@ -618,8 +608,9 @@ public: } static bool classof(const Comment *C) { return C->getCommentKind() >= FirstBlockCommandCommentConstant && C->getCommentKind() <= LastBlockCommandCommentConstant; return C->getCommentKind() >= CommentKind::FirstBlockCommandCommentConstant && C->getCommentKind() <= CommentKind::LastBlockCommandCommentConstant; } child_iterator child_begin() const { Loading Loading @@ -702,11 +693,9 @@ public: VarArgParamIndex = ~0U/*InvalidParamIndex*/ - 1U }; ParamCommandComment(SourceLocation LocBegin, SourceLocation LocEnd, unsigned CommandID, CommandMarkerKind CommandMarker) : BlockCommandComment(ParamCommandCommentKind, LocBegin, LocEnd, ParamCommandComment(SourceLocation LocBegin, SourceLocation LocEnd, unsigned CommandID, CommandMarkerKind CommandMarker) : BlockCommandComment(CommentKind::ParamCommandComment, LocBegin, LocEnd, CommandID, CommandMarker), ParamIndex(InvalidParamIndex) { ParamCommandCommentBits.Direction = In; Loading @@ -714,7 +703,7 @@ public: } static bool classof(const Comment *C) { return C->getCommentKind() == ParamCommandCommentKind; return C->getCommentKind() == CommentKind::ParamCommandComment; } enum PassDirection { Loading Loading @@ -796,16 +785,13 @@ private: ArrayRef<unsigned> Position; public: TParamCommandComment(SourceLocation LocBegin, SourceLocation LocEnd, unsigned CommandID, CommandMarkerKind CommandMarker) : BlockCommandComment(TParamCommandCommentKind, LocBegin, LocEnd, CommandID, CommandMarker) { } TParamCommandComment(SourceLocation LocBegin, SourceLocation LocEnd, unsigned CommandID, CommandMarkerKind CommandMarker) : BlockCommandComment(CommentKind::TParamCommandComment, LocBegin, LocEnd, CommandID, CommandMarker) {} static bool classof(const Comment *C) { return C->getCommentKind() == TParamCommandCommentKind; return C->getCommentKind() == CommentKind::TParamCommandComment; } bool hasParamName() const { Loading Loading @@ -847,16 +833,13 @@ class VerbatimBlockLineComment : public Comment { StringRef Text; public: VerbatimBlockLineComment(SourceLocation LocBegin, StringRef Text) : Comment(VerbatimBlockLineCommentKind, LocBegin, VerbatimBlockLineComment(SourceLocation LocBegin, StringRef Text) : Comment(CommentKind::VerbatimBlockLineComment, LocBegin, LocBegin.getLocWithOffset(Text.size())), Text(Text) { } Text(Text) {} static bool classof(const Comment *C) { return C->getCommentKind() == VerbatimBlockLineCommentKind; return C->getCommentKind() == CommentKind::VerbatimBlockLineComment; } child_iterator child_begin() const { return nullptr; } Loading @@ -878,16 +861,15 @@ protected: ArrayRef<VerbatimBlockLineComment *> Lines; public: VerbatimBlockComment(SourceLocation LocBegin, SourceLocation LocEnd, unsigned CommandID) : BlockCommandComment(VerbatimBlockCommentKind, LocBegin, LocEnd, CommandID, VerbatimBlockComment(SourceLocation LocBegin, SourceLocation LocEnd, unsigned CommandID) : BlockCommandComment(CommentKind::VerbatimBlockComment, LocBegin, LocEnd, CommandID, CMK_At) // FIXME: improve source fidelity. {} static bool classof(const Comment *C) { return C->getCommentKind() == VerbatimBlockCommentKind; return C->getCommentKind() == CommentKind::VerbatimBlockComment; } child_iterator child_begin() const { Loading Loading @@ -929,21 +911,16 @@ protected: SourceLocation TextBegin; public: VerbatimLineComment(SourceLocation LocBegin, SourceLocation LocEnd, unsigned CommandID, SourceLocation TextBegin, StringRef Text) : BlockCommandComment(VerbatimLineCommentKind, LocBegin, LocEnd, VerbatimLineComment(SourceLocation LocBegin, SourceLocation LocEnd, unsigned CommandID, SourceLocation TextBegin, StringRef Text) : BlockCommandComment(CommentKind::VerbatimLineComment, LocBegin, LocEnd, CommandID, CMK_At), // FIXME: improve source fidelity. Text(Text), TextBegin(TextBegin) { } Text(Text), TextBegin(TextBegin) {} static bool classof(const Comment *C) { return C->getCommentKind() == VerbatimLineCommentKind; return C->getCommentKind() == CommentKind::VerbatimLineComment; } child_iterator child_begin() const { return nullptr; } Loading Loading @@ -1079,8 +1056,8 @@ class FullComment : public Comment { DeclInfo *ThisDeclInfo; public: FullComment(ArrayRef<BlockContentComment *> Blocks, DeclInfo *D) : Comment(FullCommentKind, SourceLocation(), SourceLocation()), FullComment(ArrayRef<BlockContentComment *> Blocks, DeclInfo *D) : Comment(CommentKind::FullComment, SourceLocation(), SourceLocation()), Blocks(Blocks), ThisDeclInfo(D) { if (Blocks.empty()) return; Loading @@ -1091,7 +1068,7 @@ public: } static bool classof(const Comment *C) { return C->getCommentKind() == FullCommentKind; return C->getCommentKind() == CommentKind::FullComment; } child_iterator child_begin() const { Loading clang/include/clang/AST/CommentVisitor.h +3 −2 Original line number Diff line number Diff line Loading @@ -32,7 +32,8 @@ public: default: llvm_unreachable("Unknown comment kind!"); #define ABSTRACT_COMMENT(COMMENT) #define COMMENT(CLASS, PARENT) \ case Comment::CLASS##Kind: DISPATCH(CLASS, CLASS); case CommentKind::CLASS: \ DISPATCH(CLASS, CLASS); #include "clang/AST/CommentNodes.inc" #undef ABSTRACT_COMMENT #undef COMMENT Loading clang/lib/AST/Comment.cpp +12 −9 Original line number Diff line number Diff line Loading @@ -34,10 +34,11 @@ static_assert(std::is_trivially_destructible_v<DeclInfo>, const char *Comment::getCommentKindName() const { switch (getCommentKind()) { case NoCommentKind: return "NoCommentKind"; case CommentKind::None: return "None"; #define ABSTRACT_COMMENT(COMMENT) #define COMMENT(CLASS, PARENT) \ case CLASS##Kind: \ case CommentKind::CLASS: \ return #CLASS; #include "clang/AST/CommentNodes.inc" #undef COMMENT Loading Loading @@ -81,10 +82,11 @@ static inline void CheckCommentASTNodes() { Comment::child_iterator Comment::child_begin() const { switch (getCommentKind()) { case NoCommentKind: llvm_unreachable("comment without a kind"); case CommentKind::None: llvm_unreachable("comment without a kind"); #define ABSTRACT_COMMENT(COMMENT) #define COMMENT(CLASS, PARENT) \ case CLASS##Kind: \ case CommentKind::CLASS: \ return static_cast<const CLASS *>(this)->child_begin(); #include "clang/AST/CommentNodes.inc" #undef COMMENT Loading @@ -95,10 +97,11 @@ Comment::child_iterator Comment::child_begin() const { Comment::child_iterator Comment::child_end() const { switch (getCommentKind()) { case NoCommentKind: llvm_unreachable("comment without a kind"); case CommentKind::None: llvm_unreachable("comment without a kind"); #define ABSTRACT_COMMENT(COMMENT) #define COMMENT(CLASS, PARENT) \ case CLASS##Kind: \ case CommentKind::CLASS: \ return static_cast<const CLASS *>(this)->child_end(); #include "clang/AST/CommentNodes.inc" #undef COMMENT Loading clang/lib/Index/CommentToXML.cpp +13 −13 Original line number Diff line number Diff line Loading @@ -103,10 +103,10 @@ FullCommentParts::FullCommentParts(const FullComment *C, if (!Child) continue; switch (Child->getCommentKind()) { case Comment::NoCommentKind: case CommentKind::None: continue; case Comment::ParagraphCommentKind: { case CommentKind::ParagraphComment: { const ParagraphComment *PC = cast<ParagraphComment>(Child); if (PC->isWhitespace()) break; Loading @@ -117,7 +117,7 @@ FullCommentParts::FullCommentParts(const FullComment *C, break; } case Comment::BlockCommandCommentKind: { case CommentKind::BlockCommandComment: { const BlockCommandComment *BCC = cast<BlockCommandComment>(Child); const CommandInfo *Info = Traits.getCommandInfo(BCC->getCommandID()); if (!Brief && Info->IsBriefCommand) { Loading @@ -140,7 +140,7 @@ FullCommentParts::FullCommentParts(const FullComment *C, break; } case Comment::ParamCommandCommentKind: { case CommentKind::ParamCommandComment: { const ParamCommandComment *PCC = cast<ParamCommandComment>(Child); if (!PCC->hasParamName()) break; Loading @@ -152,7 +152,7 @@ FullCommentParts::FullCommentParts(const FullComment *C, break; } case Comment::TParamCommandCommentKind: { case CommentKind::TParamCommandComment: { const TParamCommandComment *TPCC = cast<TParamCommandComment>(Child); if (!TPCC->hasParamName()) break; Loading @@ -164,11 +164,11 @@ FullCommentParts::FullCommentParts(const FullComment *C, break; } case Comment::VerbatimBlockCommentKind: case CommentKind::VerbatimBlockComment: MiscBlocks.push_back(cast<BlockCommandComment>(Child)); break; case Comment::VerbatimLineCommentKind: { case CommentKind::VerbatimLineComment: { const VerbatimLineComment *VLC = cast<VerbatimLineComment>(Child); const CommandInfo *Info = Traits.getCommandInfo(VLC->getCommandID()); if (!Info->IsDeclarationCommand) Loading @@ -176,12 +176,12 @@ FullCommentParts::FullCommentParts(const FullComment *C, break; } case Comment::TextCommentKind: case Comment::InlineCommandCommentKind: case Comment::HTMLStartTagCommentKind: case Comment::HTMLEndTagCommentKind: case Comment::VerbatimBlockLineCommentKind: case Comment::FullCommentKind: case CommentKind::TextComment: case CommentKind::InlineCommandComment: case CommentKind::HTMLStartTagComment: case CommentKind::HTMLEndTagComment: case CommentKind::VerbatimBlockLineComment: case CommentKind::FullComment: llvm_unreachable("AST node of this kind can't be a child of " "a FullComment"); } Loading clang/tools/libclang/CXComment.cpp +13 −13 Original line number Diff line number Diff line Loading @@ -44,43 +44,43 @@ enum CXCommentKind clang_Comment_getKind(CXComment CXC) { return CXComment_Null; switch (C->getCommentKind()) { case Comment::NoCommentKind: case CommentKind::None: return CXComment_Null; case Comment::TextCommentKind: case CommentKind::TextComment: return CXComment_Text; case Comment::InlineCommandCommentKind: case CommentKind::InlineCommandComment: return CXComment_InlineCommand; case Comment::HTMLStartTagCommentKind: case CommentKind::HTMLStartTagComment: return CXComment_HTMLStartTag; case Comment::HTMLEndTagCommentKind: case CommentKind::HTMLEndTagComment: return CXComment_HTMLEndTag; case Comment::ParagraphCommentKind: case CommentKind::ParagraphComment: return CXComment_Paragraph; case Comment::BlockCommandCommentKind: case CommentKind::BlockCommandComment: return CXComment_BlockCommand; case Comment::ParamCommandCommentKind: case CommentKind::ParamCommandComment: return CXComment_ParamCommand; case Comment::TParamCommandCommentKind: case CommentKind::TParamCommandComment: return CXComment_TParamCommand; case Comment::VerbatimBlockCommentKind: case CommentKind::VerbatimBlockComment: return CXComment_VerbatimBlockCommand; case Comment::VerbatimBlockLineCommentKind: case CommentKind::VerbatimBlockLineComment: return CXComment_VerbatimBlockLine; case Comment::VerbatimLineCommentKind: case CommentKind::VerbatimLineComment: return CXComment_VerbatimLine; case Comment::FullCommentKind: case CommentKind::FullComment: return CXComment_FullComment; } llvm_unreachable("unknown CommentKind"); Loading Loading
clang/include/clang/AST/Comment.h +90 −113 Original line number Diff line number Diff line Loading @@ -47,6 +47,17 @@ enum CommandMarkerKind { CMK_At = 1 }; enum class CommentKind { None = 0, #define COMMENT(CLASS, PARENT) CLASS, #define COMMENT_RANGE(BASE, FIRST, LAST) \ First##BASE##Constant = FIRST, Last##BASE##Constant = LAST, #define LAST_COMMENT_RANGE(BASE, FIRST, LAST) \ First##BASE##Constant = FIRST, Last##BASE##Constant = LAST #define ABSTRACT_COMMENT(COMMENT) #include "clang/AST/CommentNodes.inc" }; /// Any part of the comment. /// Abstract class. class Comment { Loading Loading @@ -183,17 +194,6 @@ protected: } public: enum CommentKind { NoCommentKind = 0, #define COMMENT(CLASS, PARENT) CLASS##Kind, #define COMMENT_RANGE(BASE, FIRST, LAST) \ First##BASE##Constant=FIRST##Kind, Last##BASE##Constant=LAST##Kind, #define LAST_COMMENT_RANGE(BASE, FIRST, LAST) \ First##BASE##Constant=FIRST##Kind, Last##BASE##Constant=LAST##Kind #define ABSTRACT_COMMENT(COMMENT) #include "clang/AST/CommentNodes.inc" }; struct Argument { SourceRange Range; StringRef Text; Loading @@ -203,7 +203,7 @@ public: SourceLocation LocBegin, SourceLocation LocEnd) : Loc(LocBegin), Range(SourceRange(LocBegin, LocEnd)) { CommentBits.Kind = K; CommentBits.Kind = llvm::to_underlying(K); } CommentKind getCommentKind() const { Loading Loading @@ -249,8 +249,9 @@ protected: public: static bool classof(const Comment *C) { return C->getCommentKind() >= FirstInlineContentCommentConstant && C->getCommentKind() <= LastInlineContentCommentConstant; return C->getCommentKind() >= CommentKind::FirstInlineContentCommentConstant && C->getCommentKind() <= CommentKind::LastInlineContentCommentConstant; } void addTrailingNewline() { Loading @@ -267,16 +268,14 @@ class TextComment : public InlineContentComment { StringRef Text; public: TextComment(SourceLocation LocBegin, SourceLocation LocEnd, StringRef Text) : InlineContentComment(TextCommentKind, LocBegin, LocEnd), TextComment(SourceLocation LocBegin, SourceLocation LocEnd, StringRef Text) : InlineContentComment(CommentKind::TextComment, LocBegin, LocEnd), Text(Text) { TextCommentBits.IsWhitespaceValid = false; } static bool classof(const Comment *C) { return C->getCommentKind() == TextCommentKind; return C->getCommentKind() == CommentKind::TextComment; } child_iterator child_begin() const { return nullptr; } Loading Loading @@ -316,19 +315,18 @@ protected: ArrayRef<Argument> Args; public: InlineCommandComment(SourceLocation LocBegin, SourceLocation LocEnd, unsigned CommandID, RenderKind RK, ArrayRef<Argument> Args) : InlineContentComment(InlineCommandCommentKind, LocBegin, LocEnd), InlineCommandComment(SourceLocation LocBegin, SourceLocation LocEnd, unsigned CommandID, RenderKind RK, ArrayRef<Argument> Args) : InlineContentComment(CommentKind::InlineCommandComment, LocBegin, LocEnd), Args(Args) { InlineCommandCommentBits.RenderKind = RK; InlineCommandCommentBits.CommandID = CommandID; } static bool classof(const Comment *C) { return C->getCommentKind() == InlineCommandCommentKind; return C->getCommentKind() == CommentKind::InlineCommandComment; } child_iterator child_begin() const { return nullptr; } Loading Loading @@ -386,8 +384,8 @@ protected: public: static bool classof(const Comment *C) { return C->getCommentKind() >= FirstHTMLTagCommentConstant && C->getCommentKind() <= LastHTMLTagCommentConstant; return C->getCommentKind() >= CommentKind::FirstHTMLTagCommentConstant && C->getCommentKind() <= CommentKind::LastHTMLTagCommentConstant; } StringRef getTagName() const LLVM_READONLY { return TagName; } Loading Loading @@ -443,18 +441,16 @@ private: ArrayRef<Attribute> Attributes; public: HTMLStartTagComment(SourceLocation LocBegin, StringRef TagName) : HTMLTagComment(HTMLStartTagCommentKind, LocBegin, LocBegin.getLocWithOffset(1 + TagName.size()), TagName, HTMLStartTagComment(SourceLocation LocBegin, StringRef TagName) : HTMLTagComment(CommentKind::HTMLStartTagComment, LocBegin, LocBegin.getLocWithOffset(1 + TagName.size()), TagName, LocBegin.getLocWithOffset(1), LocBegin.getLocWithOffset(1 + TagName.size())) { HTMLStartTagCommentBits.IsSelfClosing = false; } static bool classof(const Comment *C) { return C->getCommentKind() == HTMLStartTagCommentKind; return C->getCommentKind() == CommentKind::HTMLStartTagComment; } child_iterator child_begin() const { return nullptr; } Loading Loading @@ -498,18 +494,14 @@ public: /// A closing HTML tag. class HTMLEndTagComment : public HTMLTagComment { public: HTMLEndTagComment(SourceLocation LocBegin, SourceLocation LocEnd, StringRef TagName) : HTMLTagComment(HTMLEndTagCommentKind, LocBegin, LocEnd, TagName, LocBegin.getLocWithOffset(2), LocBegin.getLocWithOffset(2 + TagName.size())) { } HTMLEndTagComment(SourceLocation LocBegin, SourceLocation LocEnd, StringRef TagName) : HTMLTagComment(CommentKind::HTMLEndTagComment, LocBegin, LocEnd, TagName, LocBegin.getLocWithOffset(2), LocBegin.getLocWithOffset(2 + TagName.size())) {} static bool classof(const Comment *C) { return C->getCommentKind() == HTMLEndTagCommentKind; return C->getCommentKind() == CommentKind::HTMLEndTagComment; } child_iterator child_begin() const { return nullptr; } Loading @@ -529,8 +521,9 @@ protected: public: static bool classof(const Comment *C) { return C->getCommentKind() >= FirstBlockContentCommentConstant && C->getCommentKind() <= LastBlockContentCommentConstant; return C->getCommentKind() >= CommentKind::FirstBlockContentCommentConstant && C->getCommentKind() <= CommentKind::LastBlockContentCommentConstant; } }; Loading @@ -539,9 +532,8 @@ class ParagraphComment : public BlockContentComment { ArrayRef<InlineContentComment *> Content; public: ParagraphComment(ArrayRef<InlineContentComment *> Content) : BlockContentComment(ParagraphCommentKind, SourceLocation(), ParagraphComment(ArrayRef<InlineContentComment *> Content) : BlockContentComment(CommentKind::ParagraphComment, SourceLocation(), SourceLocation()), Content(Content) { if (Content.empty()) { Loading @@ -558,7 +550,7 @@ public: } static bool classof(const Comment *C) { return C->getCommentKind() == ParagraphCommentKind; return C->getCommentKind() == CommentKind::ParagraphComment; } child_iterator child_begin() const { Loading Loading @@ -606,11 +598,9 @@ protected: } public: BlockCommandComment(SourceLocation LocBegin, SourceLocation LocEnd, unsigned CommandID, CommandMarkerKind CommandMarker) : BlockContentComment(BlockCommandCommentKind, LocBegin, LocEnd), BlockCommandComment(SourceLocation LocBegin, SourceLocation LocEnd, unsigned CommandID, CommandMarkerKind CommandMarker) : BlockContentComment(CommentKind::BlockCommandComment, LocBegin, LocEnd), Paragraph(nullptr) { setLocation(getCommandNameBeginLoc()); BlockCommandCommentBits.CommandID = CommandID; Loading @@ -618,8 +608,9 @@ public: } static bool classof(const Comment *C) { return C->getCommentKind() >= FirstBlockCommandCommentConstant && C->getCommentKind() <= LastBlockCommandCommentConstant; return C->getCommentKind() >= CommentKind::FirstBlockCommandCommentConstant && C->getCommentKind() <= CommentKind::LastBlockCommandCommentConstant; } child_iterator child_begin() const { Loading Loading @@ -702,11 +693,9 @@ public: VarArgParamIndex = ~0U/*InvalidParamIndex*/ - 1U }; ParamCommandComment(SourceLocation LocBegin, SourceLocation LocEnd, unsigned CommandID, CommandMarkerKind CommandMarker) : BlockCommandComment(ParamCommandCommentKind, LocBegin, LocEnd, ParamCommandComment(SourceLocation LocBegin, SourceLocation LocEnd, unsigned CommandID, CommandMarkerKind CommandMarker) : BlockCommandComment(CommentKind::ParamCommandComment, LocBegin, LocEnd, CommandID, CommandMarker), ParamIndex(InvalidParamIndex) { ParamCommandCommentBits.Direction = In; Loading @@ -714,7 +703,7 @@ public: } static bool classof(const Comment *C) { return C->getCommentKind() == ParamCommandCommentKind; return C->getCommentKind() == CommentKind::ParamCommandComment; } enum PassDirection { Loading Loading @@ -796,16 +785,13 @@ private: ArrayRef<unsigned> Position; public: TParamCommandComment(SourceLocation LocBegin, SourceLocation LocEnd, unsigned CommandID, CommandMarkerKind CommandMarker) : BlockCommandComment(TParamCommandCommentKind, LocBegin, LocEnd, CommandID, CommandMarker) { } TParamCommandComment(SourceLocation LocBegin, SourceLocation LocEnd, unsigned CommandID, CommandMarkerKind CommandMarker) : BlockCommandComment(CommentKind::TParamCommandComment, LocBegin, LocEnd, CommandID, CommandMarker) {} static bool classof(const Comment *C) { return C->getCommentKind() == TParamCommandCommentKind; return C->getCommentKind() == CommentKind::TParamCommandComment; } bool hasParamName() const { Loading Loading @@ -847,16 +833,13 @@ class VerbatimBlockLineComment : public Comment { StringRef Text; public: VerbatimBlockLineComment(SourceLocation LocBegin, StringRef Text) : Comment(VerbatimBlockLineCommentKind, LocBegin, VerbatimBlockLineComment(SourceLocation LocBegin, StringRef Text) : Comment(CommentKind::VerbatimBlockLineComment, LocBegin, LocBegin.getLocWithOffset(Text.size())), Text(Text) { } Text(Text) {} static bool classof(const Comment *C) { return C->getCommentKind() == VerbatimBlockLineCommentKind; return C->getCommentKind() == CommentKind::VerbatimBlockLineComment; } child_iterator child_begin() const { return nullptr; } Loading @@ -878,16 +861,15 @@ protected: ArrayRef<VerbatimBlockLineComment *> Lines; public: VerbatimBlockComment(SourceLocation LocBegin, SourceLocation LocEnd, unsigned CommandID) : BlockCommandComment(VerbatimBlockCommentKind, LocBegin, LocEnd, CommandID, VerbatimBlockComment(SourceLocation LocBegin, SourceLocation LocEnd, unsigned CommandID) : BlockCommandComment(CommentKind::VerbatimBlockComment, LocBegin, LocEnd, CommandID, CMK_At) // FIXME: improve source fidelity. {} static bool classof(const Comment *C) { return C->getCommentKind() == VerbatimBlockCommentKind; return C->getCommentKind() == CommentKind::VerbatimBlockComment; } child_iterator child_begin() const { Loading Loading @@ -929,21 +911,16 @@ protected: SourceLocation TextBegin; public: VerbatimLineComment(SourceLocation LocBegin, SourceLocation LocEnd, unsigned CommandID, SourceLocation TextBegin, StringRef Text) : BlockCommandComment(VerbatimLineCommentKind, LocBegin, LocEnd, VerbatimLineComment(SourceLocation LocBegin, SourceLocation LocEnd, unsigned CommandID, SourceLocation TextBegin, StringRef Text) : BlockCommandComment(CommentKind::VerbatimLineComment, LocBegin, LocEnd, CommandID, CMK_At), // FIXME: improve source fidelity. Text(Text), TextBegin(TextBegin) { } Text(Text), TextBegin(TextBegin) {} static bool classof(const Comment *C) { return C->getCommentKind() == VerbatimLineCommentKind; return C->getCommentKind() == CommentKind::VerbatimLineComment; } child_iterator child_begin() const { return nullptr; } Loading Loading @@ -1079,8 +1056,8 @@ class FullComment : public Comment { DeclInfo *ThisDeclInfo; public: FullComment(ArrayRef<BlockContentComment *> Blocks, DeclInfo *D) : Comment(FullCommentKind, SourceLocation(), SourceLocation()), FullComment(ArrayRef<BlockContentComment *> Blocks, DeclInfo *D) : Comment(CommentKind::FullComment, SourceLocation(), SourceLocation()), Blocks(Blocks), ThisDeclInfo(D) { if (Blocks.empty()) return; Loading @@ -1091,7 +1068,7 @@ public: } static bool classof(const Comment *C) { return C->getCommentKind() == FullCommentKind; return C->getCommentKind() == CommentKind::FullComment; } child_iterator child_begin() const { Loading
clang/include/clang/AST/CommentVisitor.h +3 −2 Original line number Diff line number Diff line Loading @@ -32,7 +32,8 @@ public: default: llvm_unreachable("Unknown comment kind!"); #define ABSTRACT_COMMENT(COMMENT) #define COMMENT(CLASS, PARENT) \ case Comment::CLASS##Kind: DISPATCH(CLASS, CLASS); case CommentKind::CLASS: \ DISPATCH(CLASS, CLASS); #include "clang/AST/CommentNodes.inc" #undef ABSTRACT_COMMENT #undef COMMENT Loading
clang/lib/AST/Comment.cpp +12 −9 Original line number Diff line number Diff line Loading @@ -34,10 +34,11 @@ static_assert(std::is_trivially_destructible_v<DeclInfo>, const char *Comment::getCommentKindName() const { switch (getCommentKind()) { case NoCommentKind: return "NoCommentKind"; case CommentKind::None: return "None"; #define ABSTRACT_COMMENT(COMMENT) #define COMMENT(CLASS, PARENT) \ case CLASS##Kind: \ case CommentKind::CLASS: \ return #CLASS; #include "clang/AST/CommentNodes.inc" #undef COMMENT Loading Loading @@ -81,10 +82,11 @@ static inline void CheckCommentASTNodes() { Comment::child_iterator Comment::child_begin() const { switch (getCommentKind()) { case NoCommentKind: llvm_unreachable("comment without a kind"); case CommentKind::None: llvm_unreachable("comment without a kind"); #define ABSTRACT_COMMENT(COMMENT) #define COMMENT(CLASS, PARENT) \ case CLASS##Kind: \ case CommentKind::CLASS: \ return static_cast<const CLASS *>(this)->child_begin(); #include "clang/AST/CommentNodes.inc" #undef COMMENT Loading @@ -95,10 +97,11 @@ Comment::child_iterator Comment::child_begin() const { Comment::child_iterator Comment::child_end() const { switch (getCommentKind()) { case NoCommentKind: llvm_unreachable("comment without a kind"); case CommentKind::None: llvm_unreachable("comment without a kind"); #define ABSTRACT_COMMENT(COMMENT) #define COMMENT(CLASS, PARENT) \ case CLASS##Kind: \ case CommentKind::CLASS: \ return static_cast<const CLASS *>(this)->child_end(); #include "clang/AST/CommentNodes.inc" #undef COMMENT Loading
clang/lib/Index/CommentToXML.cpp +13 −13 Original line number Diff line number Diff line Loading @@ -103,10 +103,10 @@ FullCommentParts::FullCommentParts(const FullComment *C, if (!Child) continue; switch (Child->getCommentKind()) { case Comment::NoCommentKind: case CommentKind::None: continue; case Comment::ParagraphCommentKind: { case CommentKind::ParagraphComment: { const ParagraphComment *PC = cast<ParagraphComment>(Child); if (PC->isWhitespace()) break; Loading @@ -117,7 +117,7 @@ FullCommentParts::FullCommentParts(const FullComment *C, break; } case Comment::BlockCommandCommentKind: { case CommentKind::BlockCommandComment: { const BlockCommandComment *BCC = cast<BlockCommandComment>(Child); const CommandInfo *Info = Traits.getCommandInfo(BCC->getCommandID()); if (!Brief && Info->IsBriefCommand) { Loading @@ -140,7 +140,7 @@ FullCommentParts::FullCommentParts(const FullComment *C, break; } case Comment::ParamCommandCommentKind: { case CommentKind::ParamCommandComment: { const ParamCommandComment *PCC = cast<ParamCommandComment>(Child); if (!PCC->hasParamName()) break; Loading @@ -152,7 +152,7 @@ FullCommentParts::FullCommentParts(const FullComment *C, break; } case Comment::TParamCommandCommentKind: { case CommentKind::TParamCommandComment: { const TParamCommandComment *TPCC = cast<TParamCommandComment>(Child); if (!TPCC->hasParamName()) break; Loading @@ -164,11 +164,11 @@ FullCommentParts::FullCommentParts(const FullComment *C, break; } case Comment::VerbatimBlockCommentKind: case CommentKind::VerbatimBlockComment: MiscBlocks.push_back(cast<BlockCommandComment>(Child)); break; case Comment::VerbatimLineCommentKind: { case CommentKind::VerbatimLineComment: { const VerbatimLineComment *VLC = cast<VerbatimLineComment>(Child); const CommandInfo *Info = Traits.getCommandInfo(VLC->getCommandID()); if (!Info->IsDeclarationCommand) Loading @@ -176,12 +176,12 @@ FullCommentParts::FullCommentParts(const FullComment *C, break; } case Comment::TextCommentKind: case Comment::InlineCommandCommentKind: case Comment::HTMLStartTagCommentKind: case Comment::HTMLEndTagCommentKind: case Comment::VerbatimBlockLineCommentKind: case Comment::FullCommentKind: case CommentKind::TextComment: case CommentKind::InlineCommandComment: case CommentKind::HTMLStartTagComment: case CommentKind::HTMLEndTagComment: case CommentKind::VerbatimBlockLineComment: case CommentKind::FullComment: llvm_unreachable("AST node of this kind can't be a child of " "a FullComment"); } Loading
clang/tools/libclang/CXComment.cpp +13 −13 Original line number Diff line number Diff line Loading @@ -44,43 +44,43 @@ enum CXCommentKind clang_Comment_getKind(CXComment CXC) { return CXComment_Null; switch (C->getCommentKind()) { case Comment::NoCommentKind: case CommentKind::None: return CXComment_Null; case Comment::TextCommentKind: case CommentKind::TextComment: return CXComment_Text; case Comment::InlineCommandCommentKind: case CommentKind::InlineCommandComment: return CXComment_InlineCommand; case Comment::HTMLStartTagCommentKind: case CommentKind::HTMLStartTagComment: return CXComment_HTMLStartTag; case Comment::HTMLEndTagCommentKind: case CommentKind::HTMLEndTagComment: return CXComment_HTMLEndTag; case Comment::ParagraphCommentKind: case CommentKind::ParagraphComment: return CXComment_Paragraph; case Comment::BlockCommandCommentKind: case CommentKind::BlockCommandComment: return CXComment_BlockCommand; case Comment::ParamCommandCommentKind: case CommentKind::ParamCommandComment: return CXComment_ParamCommand; case Comment::TParamCommandCommentKind: case CommentKind::TParamCommandComment: return CXComment_TParamCommand; case Comment::VerbatimBlockCommentKind: case CommentKind::VerbatimBlockComment: return CXComment_VerbatimBlockCommand; case Comment::VerbatimBlockLineCommentKind: case CommentKind::VerbatimBlockLineComment: return CXComment_VerbatimBlockLine; case Comment::VerbatimLineCommentKind: case CommentKind::VerbatimLineComment: return CXComment_VerbatimLine; case Comment::FullCommentKind: case CommentKind::FullComment: return CXComment_FullComment; } llvm_unreachable("unknown CommentKind"); Loading