diff options
author | Douglas Gregor <dgregor@apple.com> | 2012-08-13 16:37:30 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2012-08-13 16:37:30 +0000 |
commit | cd81df2dcff4e13eea6edfbfd52a4458d978d174 (patch) | |
tree | 4ec3e36586f18b562c1293d5c54142d11c4b3e82 /lib/AST/ASTContext.cpp | |
parent | 21efbb606fe905b0f5a479b7b3e6d79023cb82ee (diff) |
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.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@161762 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/ASTContext.cpp')
-rw-r--r-- | lib/AST/ASTContext.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp index 10cba7a813..1426a29f17 100644 --- a/lib/AST/ASTContext.cpp +++ b/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 = |