summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2012-08-13 16:37:30 +0000
committerDouglas Gregor <dgregor@apple.com>2012-08-13 16:37:30 +0000
commit35ceb27fa4af18156d2cfec43dbabe0513a10cee (patch)
tree592ad714baa6ed83a7a1a896e88d742911a5568f /clang/lib
parent700de17aeaf29dacbe8f15163ca679a1bbf28527 (diff)
downloadbcm5719-llvm-35ceb27fa4af18156d2cfec43dbabe0513a10cee.tar.gz
bcm5719-llvm-35ceb27fa4af18156d2cfec43dbabe0513a10cee.zip
When looking for the comment associated with a declaration, adjust the
'templated' declaration for a function or class template to refer to the function or class template itself, to which the documentation will be attached. Fixes PR13593. llvm-svn: 161762
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/AST/ASTContext.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 10cba7a813d..1426a29f17e 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -190,6 +190,17 @@ RawComment *ASTContext::getRawCommentForDeclNoCache(const Decl *D) const {
}
const RawComment *ASTContext::getRawCommentForAnyRedecl(const Decl *D) const {
+ // If we have a 'templated' declaration for a template, adjust 'D' to
+ // refer to the actual template.
+ if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
+ if (const FunctionTemplateDecl *FTD = FD->getDescribedFunctionTemplate())
+ D = FTD;
+ } else if (const CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(D)) {
+ if (const ClassTemplateDecl *CTD = RD->getDescribedClassTemplate())
+ D = CTD;
+ }
+ // FIXME: Alias templates?
+
// Check whether we have cached a comment for this declaration already.
{
llvm::DenseMap<const Decl *, RawCommentAndCacheFlags>::iterator Pos =
OpenPOWER on IntegriCloud