From c27bc80a98b9558513b50956c930eedc9e461ae0 Mon Sep 17 00:00:00 2001 From: Dmitri Gribenko Date: Thu, 2 Aug 2012 20:49:51 +0000 Subject: [PATCH] Attaching comments to declarations: handle using-declaration. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@161211 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/AST/ASTContext.cpp | 4 +-- lib/Sema/SemaDeclCXX.cpp | 1 + test/Sema/warn-documentation.cpp | 43 +++++++++++++++++++------------- 3 files changed, 29 insertions(+), 19 deletions(-) diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp index 1c0c0c404d..0ff0e35a43 100644 --- a/lib/AST/ASTContext.cpp +++ b/lib/AST/ASTContext.cpp @@ -95,8 +95,8 @@ RawComment *ASTContext::getRawCommentForDeclNoCache(const Decl *D) const { SourceLocation DeclLoc; if (isa(D) || isa(D) || isa(D) || - isa(D) || - isa(D) || isa(D)) + isa(D) || + isa(D)) DeclLoc = D->getLocStart(); else DeclLoc = D->getLocation(); diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp index fae0b165ce..35364dca74 100644 --- a/lib/Sema/SemaDeclCXX.cpp +++ b/lib/Sema/SemaDeclCXX.cpp @@ -6649,6 +6649,7 @@ Decl *Sema::ActOnAliasDeclaration(Scope *S, if (!Redeclaration) PushOnScopeChains(NewND, S); + ActOnDocumentableDecl(NewND); return NewND; } diff --git a/test/Sema/warn-documentation.cpp b/test/Sema/warn-documentation.cpp index f0813682fc..b31e480db8 100644 --- a/test/Sema/warn-documentation.cpp +++ b/test/Sema/warn-documentation.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only -Wdocumentation -Wdocumentation-pedantic -verify %s +// RUN: %clang_cc1 -std=c++11 -fsyntax-only -Wdocumentation -Wdocumentation-pedantic -verify %s // expected-warning@+1 {{expected quoted string after equals sign}} /// @@ -387,66 +387,75 @@ class test_attach28 { T aaa; }; +// expected-warning@+1 {{empty paragraph passed to '\brief' command}} +/// \brief\brief Aaa +using test_attach29 = test_attach28; + // expected-warning@+1 {{empty paragraph passed to '\brief' command}} /// \brief\brief Aaa /// \tparam T Aaa template -class test_attach29 { }; +class test_attach30 { }; // expected-warning@+1 {{empty paragraph passed to '\brief' command}} /// \brief\brief Aaa /// \tparam T Aaa template -class test_attach29 { }; +class test_attach30 { }; // expected-warning@+1 {{empty paragraph passed to '\brief' command}} /// \brief\brief Aaa template<> -class test_attach29 { }; +class test_attach30 { }; + +// expected-warning@+1 {{empty paragraph passed to '\brief' command}} +/// \brief\brief Aaa +template +using test_attach31 = test_attach30; // expected-warning@+1 {{empty paragraph passed to '\brief' command}} /// \brief\brief Aaa /// \tparam T Aaa template -class test_attach30 { }; +class test_attach32 { }; // expected-warning@+1 {{empty paragraph passed to '\brief' command}} /// \brief\brief Aaa /// \tparam T Aaa template -class test_attach30 { }; +class test_attach32 { }; // expected-warning@+1 {{empty paragraph passed to '\brief' command}} /// \brief\brief Aaa /// \tparam T Aaa template -class test_attach30 { }; +class test_attach32 { }; // expected-warning@+2 {{empty paragraph passed to '\brief' command}} // expected-warning@+2 {{template parameter 'T' not found in the template declaration}} /// \brief\brief Aaa /// \tparam T Aaa template<> -class test_attach30 { }; +class test_attach32 { }; // expected-warning@+1 {{empty paragraph passed to '\brief' command}} /// \brief\brief Aaa -class test_attach31 { +class test_attach33 { // expected-warning@+1 {{empty paragraph passed to '\brief' command}} /// \brief\brief Aaa /// \tparam T Aaa template - void test_attach32(T aaa, U bbb); + void test_attach34(T aaa, U bbb); }; template -class test_attach33 { +class test_attach35 { // expected-warning@+2 {{empty paragraph passed to '\brief' command}} // expected-warning@+2 {{template parameter 'T' not found in the template declaration}} /// \brief\brief Aaa /// \tparam T Aaa template - void test_attach34(TT aaa, UU bbb); + void test_attach36(TT aaa, UU bbb); }; // expected-warning@+2 {{empty paragraph passed to '\brief' command}} @@ -454,29 +463,29 @@ class test_attach33 { /// \brief\brief Aaa /// \tparam T Aaa template<> template<> -void test_attach33::test_attach34(int aaa, int bbb) {} +void test_attach35::test_attach36(int aaa, int bbb) {} template -class test_attach35 { +class test_attach37 { // expected-warning@+2 {{empty paragraph passed to '\brief' command}} // expected-warning@+2 {{'\tparam' command used in a comment that is not attached to a template declaration}} /// \brief\brief Aaa /// \tparam T Aaa - void test_attach36(int aaa, int bbb); + void test_attach38(int aaa, int bbb); }; // expected-warning@+1 {{empty paragraph passed to '\brief' command}} /// \brief\brief Aaa /// \tparam T Aaa template -void test_attach35::test_attach36(int aaa, int bbb) {} +void test_attach37::test_attach38(int aaa, int bbb) {} // expected-warning@+2 {{empty paragraph passed to '\brief' command}} // expected-warning@+2 {{template parameter 'T' not found in the template declaration}} /// \brief\brief Aaa /// \tparam T Aaa template<> -void test_attach35::test_attach36(int aaa, int bbb) {} +void test_attach37::test_attach38(int aaa, int bbb) {} // PR13411, reduced. We used to crash on this. -- 2.40.0