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/AST/ASTContext.cpp | |
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/AST/ASTContext.cpp')
-rw-r--r-- | lib/AST/ASTContext.cpp | 30 |
1 files changed, 17 insertions, 13 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; } } |