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
diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp
index a58eca6..71764db 100644
--- a/lib/AST/ASTContext.cpp
+++ b/lib/AST/ASTContext.cpp
@@ -374,6 +374,20 @@
}
}
+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 @@
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 @@
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 09f4290..a443b91 100644
--- a/lib/AST/Comment.cpp
+++ b/lib/AST/Comment.cpp
@@ -304,6 +304,12 @@
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 59dc6c7..d664bdb 100644
--- a/lib/AST/CommentSema.cpp
+++ b/lib/AST/CommentSema.cpp
@@ -413,7 +413,7 @@
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;
}