[cfe-commits] r161762 - in /cfe/trunk: lib/AST/ASTContext.cpp test/Sema/warn-documentation.cpp
Douglas Gregor
dgregor at apple.com
Mon Aug 13 09:37:30 PDT 2012
Author: dgregor
Date: Mon Aug 13 11:37:30 2012
New Revision: 161762
URL: http://llvm.org/viewvc/llvm-project?rev=161762&view=rev
Log:
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.
Modified:
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/test/Sema/warn-documentation.cpp
Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=161762&r1=161761&r2=161762&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Mon Aug 13 11:37:30 2012
@@ -190,6 +190,17 @@
}
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 =
Modified: cfe/trunk/test/Sema/warn-documentation.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/warn-documentation.cpp?rev=161762&r1=161761&r2=161762&view=diff
==============================================================================
--- cfe/trunk/test/Sema/warn-documentation.cpp (original)
+++ cfe/trunk/test/Sema/warn-documentation.cpp Mon Aug 13 11:37:30 2012
@@ -652,3 +652,19 @@
/// \param\brief
void test_nocrash2(int);
+// PR13593
+
+/**
+* Bla.
+*/
+template <typename>
+void test_nocrash3();
+
+/// Foo
+template <typename, typename>
+void test_nocrash4() { }
+
+template <typename>
+void test_nocrash3()
+{
+}
More information about the cfe-commits
mailing list