[PATCH] D111262: Comment AST: Factor out function type extraction in DeclInfo::fill (NFC)
This revision was automatically updated to reflect the committed changes. aaronpuchert marked an inline comment as done. Closed by commit rG3506e42ab67e: Comment AST: Factor out function type extraction in DeclInfo::fill (NFC) (authored by aaronpuchert). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D111262/new/ https://reviews.llvm.org/D111262 Files: clang/lib/AST/Comment.cpp Index: clang/lib/AST/Comment.cpp === --- clang/lib/AST/Comment.cpp +++ clang/lib/AST/Comment.cpp @@ -221,6 +221,7 @@ CurrentDecl = CommentDecl; Decl::Kind K = CommentDecl->getKind(); + const TypeSourceInfo *TSI = nullptr; switch (K) { default: // Defaults are should be good for declarations we don't handle explicitly. @@ -297,72 +298,46 @@ case Decl::EnumConstant: case Decl::ObjCIvar: case Decl::ObjCAtDefsField: - case Decl::ObjCProperty: { -const TypeSourceInfo *TSI; + case Decl::ObjCProperty: if (const auto *VD = dyn_cast(CommentDecl)) TSI = VD->getTypeSourceInfo(); else if (const auto *PD = dyn_cast(CommentDecl)) TSI = PD->getTypeSourceInfo(); -else - TSI = nullptr; -if (TSI) { - TypeLoc TL = TSI->getTypeLoc().getUnqualifiedLoc(); - FunctionTypeLoc FTL; - if (getFunctionTypeLoc(TL, FTL)) { -ParamVars = FTL.getParams(); -ReturnType = FTL.getReturnLoc().getType(); - } -} Kind = VariableKind; break; - } case Decl::Namespace: Kind = NamespaceKind; break; case Decl::TypeAlias: - case Decl::Typedef: { + case Decl::Typedef: Kind = TypedefKind; -// If this is a typedef / using to something we consider a function, extract -// arguments and return type. -const TypeSourceInfo *TSI = -K == Decl::Typedef -? cast(CommentDecl)->getTypeSourceInfo() -: cast(CommentDecl)->getTypeSourceInfo(); -if (!TSI) - break; -TypeLoc TL = TSI->getTypeLoc().getUnqualifiedLoc(); -FunctionTypeLoc FTL; -if (getFunctionTypeLoc(TL, FTL)) { - Kind = FunctionKind; - ParamVars = FTL.getParams(); - ReturnType = FTL.getReturnLoc().getType(); -} +TSI = cast(CommentDecl)->getTypeSourceInfo(); break; - } case Decl::TypeAliasTemplate: { const TypeAliasTemplateDecl *TAT = cast(CommentDecl); Kind = TypedefKind; TemplateKind = Template; TemplateParameters = TAT->getTemplateParameters(); -TypeAliasDecl *TAD = TAT->getTemplatedDecl(); -if (!TAD) - break; +if (TypeAliasDecl *TAD = TAT->getTemplatedDecl()) + TSI = TAD->getTypeSourceInfo(); +break; + } + case Decl::Enum: +Kind = EnumKind; +break; + } -const TypeSourceInfo *TSI = TAD->getTypeSourceInfo(); -if (!TSI) - break; + // If the type is a typedef / using to something we consider a function, + // extract arguments and return type. + if (TSI) { TypeLoc TL = TSI->getTypeLoc().getUnqualifiedLoc(); FunctionTypeLoc FTL; if (getFunctionTypeLoc(TL, FTL)) { - Kind = FunctionKind; + if (Kind == TypedefKind) +Kind = FunctionKind; ParamVars = FTL.getParams(); ReturnType = FTL.getReturnLoc().getType(); } -break; - } - case Decl::Enum: -Kind = EnumKind; -break; } IsFilled = true; ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D111262: Comment AST: Factor out function type extraction in DeclInfo::fill (NFC)
aaronpuchert marked an inline comment as done. aaronpuchert added a comment. Thanks for the review! Comment at: clang/lib/AST/Comment.cpp:337 + if (Kind == TypedefKind) +Kind = FunctionKind; ParamVars = FTL.getParams(); gribozavr2 wrote: > Phabricator shows a `>>` chevron on this line, which might be an accidental > tab. If it is one, please replace with spaces. This seems to be Phabricator's way of indicating that the line has been indented. Not sure why they're using this (arguably misleading) symbol for that. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D111262/new/ https://reviews.llvm.org/D111262 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D111262: Comment AST: Factor out function type extraction in DeclInfo::fill (NFC)
gribozavr2 accepted this revision. gribozavr2 added inline comments. This revision is now accepted and ready to land. Comment at: clang/lib/AST/Comment.cpp:337 + if (Kind == TypedefKind) +Kind = FunctionKind; ParamVars = FTL.getParams(); Phabricator shows a `>>` chevron on this line, which might be an accidental tab. If it is one, please replace with spaces. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D111262/new/ https://reviews.llvm.org/D111262 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D111262: Comment AST: Factor out function type extraction in DeclInfo::fill (NFC)
aaronpuchert added a comment. Ping. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D111262/new/ https://reviews.llvm.org/D111262 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D111262: Comment AST: Factor out function type extraction in DeclInfo::fill (NFC)
aaronpuchert added a comment. Ping @gribozavr2. (Ideally also the followups.) Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D111262/new/ https://reviews.llvm.org/D111262 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D111262: Comment AST: Factor out function type extraction in DeclInfo::fill (NFC)
aaronpuchert created this revision. aaronpuchert added reviewers: gribozavr2, Mordante. aaronpuchert requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D111262 Files: clang/lib/AST/Comment.cpp Index: clang/lib/AST/Comment.cpp === --- clang/lib/AST/Comment.cpp +++ clang/lib/AST/Comment.cpp @@ -221,6 +221,7 @@ CurrentDecl = CommentDecl; Decl::Kind K = CommentDecl->getKind(); + const TypeSourceInfo *TSI = nullptr; switch (K) { default: // Defaults are should be good for declarations we don't handle explicitly. @@ -297,72 +298,46 @@ case Decl::EnumConstant: case Decl::ObjCIvar: case Decl::ObjCAtDefsField: - case Decl::ObjCProperty: { -const TypeSourceInfo *TSI; + case Decl::ObjCProperty: if (const auto *VD = dyn_cast(CommentDecl)) TSI = VD->getTypeSourceInfo(); else if (const auto *PD = dyn_cast(CommentDecl)) TSI = PD->getTypeSourceInfo(); -else - TSI = nullptr; -if (TSI) { - TypeLoc TL = TSI->getTypeLoc().getUnqualifiedLoc(); - FunctionTypeLoc FTL; - if (getFunctionTypeLoc(TL, FTL)) { -ParamVars = FTL.getParams(); -ReturnType = FTL.getReturnLoc().getType(); - } -} Kind = VariableKind; break; - } case Decl::Namespace: Kind = NamespaceKind; break; case Decl::TypeAlias: - case Decl::Typedef: { + case Decl::Typedef: Kind = TypedefKind; -// If this is a typedef / using to something we consider a function, extract -// arguments and return type. -const TypeSourceInfo *TSI = -K == Decl::Typedef -? cast(CommentDecl)->getTypeSourceInfo() -: cast(CommentDecl)->getTypeSourceInfo(); -if (!TSI) - break; -TypeLoc TL = TSI->getTypeLoc().getUnqualifiedLoc(); -FunctionTypeLoc FTL; -if (getFunctionTypeLoc(TL, FTL)) { - Kind = FunctionKind; - ParamVars = FTL.getParams(); - ReturnType = FTL.getReturnLoc().getType(); -} +TSI = cast(CommentDecl)->getTypeSourceInfo(); break; - } case Decl::TypeAliasTemplate: { const TypeAliasTemplateDecl *TAT = cast(CommentDecl); Kind = TypedefKind; TemplateKind = Template; TemplateParameters = TAT->getTemplateParameters(); -TypeAliasDecl *TAD = TAT->getTemplatedDecl(); -if (!TAD) - break; +if (TypeAliasDecl *TAD = TAT->getTemplatedDecl()) + TSI = TAD->getTypeSourceInfo(); +break; + } + case Decl::Enum: +Kind = EnumKind; +break; + } -const TypeSourceInfo *TSI = TAD->getTypeSourceInfo(); -if (!TSI) - break; + // If the type is a typedef / using to something we consider a function, + // extract arguments and return type. + if (TSI) { TypeLoc TL = TSI->getTypeLoc().getUnqualifiedLoc(); FunctionTypeLoc FTL; if (getFunctionTypeLoc(TL, FTL)) { - Kind = FunctionKind; + if (Kind == TypedefKind) +Kind = FunctionKind; ParamVars = FTL.getParams(); ReturnType = FTL.getReturnLoc().getType(); } -break; - } - case Decl::Enum: -Kind = EnumKind; -break; } IsFilled = true; ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits