diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2012-10-11 23:52:50 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2012-10-11 23:52:50 +0000 |
commit | 749ace614b6ea1ae11d194a60b18e1e43e1db243 (patch) | |
tree | cf228aa770ee85c3e1a8c5b42a88c87a3eaf4b38 /lib | |
parent | b43d87b0646aa04951056c7e0d1ab9a58eb09f66 (diff) |
search for overridden methods with comment when overriding method
has none of its own. Factor in Doug's comments.
// rdar://12378793
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165771 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/AST/ASTContext.cpp | 30 | ||||
-rw-r--r-- | lib/AST/Comment.cpp | 6 | ||||
-rw-r--r-- | lib/AST/CommentSema.cpp | 2 |
3 files changed, 24 insertions, 14 deletions
diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp index a58eca6a0a..71764dbd97 100644 --- a/lib/AST/ASTContext.cpp +++ b/lib/AST/ASTContext.cpp @@ -374,6 +374,20 @@ static void addRedeclaredMethods(const ObjCMethodDecl *ObjCMethod, } } +comments::FullComment *ASTContext::cloneFullComment(comments::FullComment *FC, + const Decl *D) const { + comments::DeclInfo *ThisDeclInfo = new (*this) comments::DeclInfo; + ThisDeclInfo->CommentDecl = D; + ThisDeclInfo->IsFilled = false; + ThisDeclInfo->fill(); + ThisDeclInfo->CommentDecl = FC->getDecl(); + comments::FullComment *CFC = + new (*this) comments::FullComment(FC->getBlocks(), + ThisDeclInfo); + return CFC; + +} + comments::FullComment *ASTContext::getCommentForDecl( const Decl *D, const Preprocessor *PP) const { @@ -384,16 +398,9 @@ comments::FullComment *ASTContext::getCommentForDecl( ParsedComments.find(Canonical); if (Pos != ParsedComments.end()) { - if (Canonical != D && - (isa<ObjCMethodDecl>(D) || isa<FunctionDecl>(D))) { - // case of method being redeclaration of the canonical, not - // overriding it; i.e. method in implementation, canonical in - // interface. Or, out-of-line cxx-method definition. + if (Canonical != D) { comments::FullComment *FC = Pos->second; - comments::FullComment *CFC = - new (*this) comments::FullComment(FC->getBlocks(), - FC->getThisDeclInfo(), - const_cast<Decl *>(D)); + comments::FullComment *CFC = cloneFullComment(FC, D); return CFC; } return Pos->second; @@ -411,10 +418,7 @@ comments::FullComment *ASTContext::getCommentForDecl( overridden); for (unsigned i = 0, e = overridden.size(); i < e; i++) { if (comments::FullComment *FC = getCommentForDecl(overridden[i], PP)) { - comments::FullComment *CFC = - new (*this) comments::FullComment(FC->getBlocks(), - FC->getThisDeclInfo(), - const_cast<Decl *>(D)); + comments::FullComment *CFC = cloneFullComment(FC, D); return CFC; } } diff --git a/lib/AST/Comment.cpp b/lib/AST/Comment.cpp index 09f4290f1b..a443b91d09 100644 --- a/lib/AST/Comment.cpp +++ b/lib/AST/Comment.cpp @@ -304,6 +304,12 @@ void DeclInfo::fill() { IsFilled = true; } +StringRef ParamCommandComment::getParamName(comments::FullComment *FC) const { + if (FC && isParamIndexValid()) + return FC->getThisDeclInfo()->ParamVars[getParamIndex()]->getName(); + return Args[0].Text; +} + } // end namespace comments } // end namespace clang diff --git a/lib/AST/CommentSema.cpp b/lib/AST/CommentSema.cpp index 59dc6c7295..d664bdb632 100644 --- a/lib/AST/CommentSema.cpp +++ b/lib/AST/CommentSema.cpp @@ -413,7 +413,7 @@ HTMLEndTagComment *Sema::actOnHTMLEndTag(SourceLocation LocBegin, FullComment *Sema::actOnFullComment( ArrayRef<BlockContentComment *> Blocks) { - FullComment *FC = new (Allocator) FullComment(Blocks, ThisDeclInfo, 0); + FullComment *FC = new (Allocator) FullComment(Blocks, ThisDeclInfo); resolveParamCommandIndexes(FC); return FC; } |