diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2012-10-10 18:34:52 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2012-10-10 18:34:52 +0000 |
commit | bf967be66ea8c51b66c61659c23240f762a56dbe (patch) | |
tree | 41a5fab46daa1e64b94cd5460874794072abd2b8 /tools | |
parent | 4eff6b5d6a5cbb6bd669854a84365aa61d70819e (diff) | |
download | clang-bf967be66ea8c51b66c61659c23240f762a56dbe.tar.gz clang-bf967be66ea8c51b66c61659c23240f762a56dbe.tar.bz2 clang-bf967be66ea8c51b66c61659c23240f762a56dbe.tar.xz |
[Doc parsing] This patch searches overridden objc/c++
methods looking for documentation on a particular base
class inherited by any method that overrides the base class.
In case of redeclaration, as when objc method is defined
in the implementation, it also looks up for documentation
in class/class extension being redeclared.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165643 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools')
-rw-r--r-- | tools/libclang/CXComment.cpp | 37 |
1 files changed, 22 insertions, 15 deletions
diff --git a/tools/libclang/CXComment.cpp b/tools/libclang/CXComment.cpp index b0e190a204..5fac0d8779 100644 --- a/tools/libclang/CXComment.cpp +++ b/tools/libclang/CXComment.cpp @@ -254,7 +254,7 @@ CXString clang_ParamCommandComment_getParamName(CXComment CXC) { if (!PCC || !PCC->hasParamName()) return createCXString((const char *) 0); - return createCXString(PCC->getParamName(), /*DupString=*/ false); + return createCXString(PCC->getParamName(0), /*DupString=*/ false); } unsigned clang_ParamCommandComment_isParamIndexValid(CXComment CXC) { @@ -535,9 +535,10 @@ class CommentASTToHTMLConverter : public ConstCommentVisitor<CommentASTToHTMLConverter> { public: /// \param Str accumulator for HTML. - CommentASTToHTMLConverter(SmallVectorImpl<char> &Str, + CommentASTToHTMLConverter(FullComment *FC, + SmallVectorImpl<char> &Str, const CommandTraits &Traits) : - Result(Str), Traits(Traits) + FC(FC), Result(Str), Traits(Traits) { } // Inline content. @@ -566,6 +567,7 @@ public: void appendToResultWithHTMLEscaping(StringRef S); private: + FullComment *FC; /// Output stream for HTML. llvm::raw_svector_ostream Result; @@ -669,7 +671,7 @@ void CommentASTToHTMLConverter::visitParamCommandComment( } else Result << "<dt class=\"param-name-index-invalid\">"; - appendToResultWithHTMLEscaping(C->getParamName()); + appendToResultWithHTMLEscaping(C->getParamName(FC->getDeclForCommentLookup())); Result << "</dt>"; if (C->isParamIndexValid()) { @@ -827,7 +829,7 @@ CXString clang_HTMLTagComment_getAsString(CXComment CXC) { return createCXString((const char *) 0); SmallString<128> HTML; - CommentASTToHTMLConverter Converter(HTML, getCommandTraits(CXC)); + CommentASTToHTMLConverter Converter(0, HTML, getCommandTraits(CXC)); Converter.visit(HTC); return createCXString(HTML.str(), /* DupString = */ true); } @@ -838,7 +840,8 @@ CXString clang_FullComment_getAsHTML(CXComment CXC) { return createCXString((const char *) 0); SmallString<1024> HTML; - CommentASTToHTMLConverter Converter(HTML, getCommandTraits(CXC)); + CommentASTToHTMLConverter Converter(const_cast<FullComment *>(FC), + HTML, getCommandTraits(CXC)); Converter.visit(FC); return createCXString(HTML.str(), /* DupString = */ true); } @@ -850,10 +853,11 @@ class CommentASTToXMLConverter : public ConstCommentVisitor<CommentASTToXMLConverter> { public: /// \param Str accumulator for XML. - CommentASTToXMLConverter(SmallVectorImpl<char> &Str, + CommentASTToXMLConverter(FullComment *FC, + SmallVectorImpl<char> &Str, const CommandTraits &Traits, const SourceManager &SM) : - Result(Str), Traits(Traits), SM(SM) { } + FC(FC), Result(Str), Traits(Traits), SM(SM) { } // Inline content. void visitTextComment(const TextComment *C); @@ -876,6 +880,8 @@ public: void appendToResultWithXMLEscaping(StringRef S); private: + FullComment *FC; + /// Output stream for XML. llvm::raw_svector_ostream Result; @@ -954,7 +960,7 @@ void CommentASTToXMLConverter::visitBlockCommandComment(const BlockCommandCommen void CommentASTToXMLConverter::visitParamCommandComment(const ParamCommandComment *C) { Result << "<Parameter><Name>"; - appendToResultWithXMLEscaping(C->getParamName()); + appendToResultWithXMLEscaping(C->getParamName(FC->getDeclForCommentLookup())); Result << "</Name>"; if (C->isParamIndexValid()) @@ -1090,7 +1096,7 @@ void CommentASTToXMLConverter::visitFullComment(const FullComment *C) { { // Print line and column number. - SourceLocation Loc = DI->ThisDecl->getLocation(); + SourceLocation Loc = DI->CommentDecl->getLocation(); std::pair<FileID, unsigned> LocInfo = SM.getDecomposedLoc(Loc); FileID FID = LocInfo.first; unsigned FileOffset = LocInfo.second; @@ -1111,7 +1117,7 @@ void CommentASTToXMLConverter::visitFullComment(const FullComment *C) { Result << ">"; bool FoundName = false; - if (const NamedDecl *ND = dyn_cast<NamedDecl>(DI->ThisDecl)) { + if (const NamedDecl *ND = dyn_cast<NamedDecl>(DI->CommentDecl)) { if (DeclarationName DeclName = ND->getDeclName()) { Result << "<Name>"; std::string Name = DeclName.getAsString(); @@ -1126,7 +1132,7 @@ void CommentASTToXMLConverter::visitFullComment(const FullComment *C) { { // Print USR. SmallString<128> USR; - cxcursor::getDeclCursorUSR(DI->ThisDecl, USR); + cxcursor::getDeclCursorUSR(DI->CommentDecl, USR); if (!USR.empty()) { Result << "<USR>"; appendToResultWithXMLEscaping(USR); @@ -1171,8 +1177,8 @@ void CommentASTToXMLConverter::visitFullComment(const FullComment *C) { Result << "</ResultDiscussion>"; } - if (DI->ThisDecl->hasAttrs()) { - const AttrVec &Attrs = DI->ThisDecl->getAttrs(); + if (DI->CommentDecl->hasAttrs()) { + const AttrVec &Attrs = DI->CommentDecl->getAttrs(); for (unsigned i = 0, e = Attrs.size(); i != e; i++) { const AvailabilityAttr *AA = dyn_cast<AvailabilityAttr>(Attrs[i]); if (!AA) { @@ -1295,7 +1301,8 @@ CXString clang_FullComment_getAsXML(CXComment CXC) { SourceManager &SM = static_cast<ASTUnit *>(TU->TUData)->getSourceManager(); SmallString<1024> XML; - CommentASTToXMLConverter Converter(XML, getCommandTraits(CXC), SM); + CommentASTToXMLConverter Converter(const_cast<FullComment *>(FC), XML, + getCommandTraits(CXC), SM); Converter.visit(FC); return createCXString(XML.str(), /* DupString = */ true); } |