diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index 10cba7a813d16cbb4d6ed58a6252d8a1962913d5..1426a29f17ecf13f06d78b59a3ce1b96db5e00d3 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(D)) { + if (const FunctionTemplateDecl *FTD = FD->getDescribedFunctionTemplate()) + D = FTD; + } else if (const CXXRecordDecl *RD = dyn_cast(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::iterator Pos = diff --git a/clang/test/Sema/warn-documentation.cpp b/clang/test/Sema/warn-documentation.cpp index d116c3f8cae0f5cd0496af6a3f1f18372cb52828..16ba4297cdc4eb5ad155cb7bae6868246bd00ca3 100644 --- a/clang/test/Sema/warn-documentation.cpp +++ b/clang/test/Sema/warn-documentation.cpp @@ -652,3 +652,19 @@ void test_nocrash1(int); /// \param\brief void test_nocrash2(int); +// PR13593 + +/** +* Bla. +*/ +template +void test_nocrash3(); + +/// Foo +template +void test_nocrash4() { } + +template +void test_nocrash3() +{ +}