diff --git a/lib/AST/Comment.cpp b/lib/AST/Comment.cpp index f88e9e212e3774ad80ad433741551d0aa1d1bcca..89a7b7fa902e2de05d7aa1b02c237b86c9abb13c 100644 --- a/lib/AST/Comment.cpp +++ b/lib/AST/Comment.cpp @@ -226,12 +226,15 @@ void DeclInfo::fill() { case Decl::Namespace: Kind = NamespaceKind; break; + case Decl::TypeAlias: case Decl::Typedef: { Kind = TypedefKind; - // If this is a typedef to something we consider a function, extract + // If this is a typedef / using to something we consider a function, extract // arguments and return type. - const TypedefDecl *TD = cast<TypedefDecl>(CommentDecl); - const TypeSourceInfo *TSI = TD->getTypeSourceInfo(); + const TypeSourceInfo *TSI = + K == Decl::Typedef + ? cast<TypedefDecl>(CommentDecl)->getTypeSourceInfo() + : cast<TypeAliasDecl>(CommentDecl)->getTypeSourceInfo(); if (!TSI) break; TypeLoc TL = TSI->getTypeLoc().getUnqualifiedLoc(); @@ -302,9 +305,6 @@ void DeclInfo::fill() { } break; } - case Decl::TypeAlias: - Kind = TypedefKind; - break; case Decl::TypeAliasTemplate: { const TypeAliasTemplateDecl *TAT = cast<TypeAliasTemplateDecl>(CommentDecl); Kind = TypedefKind; diff --git a/test/Sema/warn-documentation.cpp b/test/Sema/warn-documentation.cpp index 5d866359aa75f0222531c2ce2cfc058b1b007a2b..2f2f44d63250db7b94a638fe747bd59de0ce0ce2 100644 --- a/test/Sema/warn-documentation.cpp +++ b/test/Sema/warn-documentation.cpp @@ -368,6 +368,69 @@ typedef unsigned int test_not_function_like_typedef3; /// \param aaa Meow. typedef foo::not_a_function_wrapper<1> test_not_function_like_typedef4; +// expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}} +/// \param aaa Meow. +/// \param bbb Bbb. +/// \returns aaa. +using test_function_like_using1 = int (int aaa, int ccc); + +// expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}} +/// \param aaa Meow. +/// \param bbb Bbb. +/// \returns aaa. +using test_function_like_using2 = int (*)(int aaa, int ccc); + +// expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}} +/// \param aaa Meow. +/// \param bbb Bbb. +/// \returns aaa. +using test_function_like_using3 = int (* const)(int aaa, int ccc); + +// expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}} +/// \param aaa Meow. +/// \param bbb Bbb. +/// \returns aaa. +using test_function_like_using4 = int (C::*)(int aaa, int ccc); + +// expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}} +/// \param aaa Meow. +/// \param bbb Bbb. +/// \returns aaa. +using test_function_like_using5 = foo::function_wrapper<int (int aaa, int ccc)>; + +// expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}} +/// \param aaa Meow. +/// \param bbb Bbb. +/// \returns aaa. +using test_function_like_using6 = foo::function_wrapper<int (int aaa, int ccc)> *; + +// expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}} +/// \param aaa Meow. +/// \param bbb Bbb. +/// \returns aaa. +using test_function_like_using7 = foo::function_wrapper<int (int aaa, int ccc)> &; + +// expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}} +/// \param aaa Meow. +/// \param bbb Bbb. +/// \returns aaa. +using test_function_like_using8 = foo::function_wrapper<int (int aaa, int ccc)> &&; + +using test_not_function_like_using1 = int (*)(int aaa); + +// expected-warning@+1 {{'\param' command used in a comment that is not attached to a function declaration}} +/// \param aaa Meow. +using test_not_function_like_using2 = test_not_function_like_using1; + +// Check that the diagnostic uses the same command marker as the comment. +// expected-warning@+1 {{'@param' command used in a comment that is not attached to a function declaration}} +/// @param aaa Meow. +using test_not_function_like_using3 = unsigned int; + +// expected-warning@+1 {{'\param' command used in a comment that is not attached to a function declaration}} +/// \param aaa Meow. +using test_not_function_like_using4 = foo::not_a_function_wrapper<1>; + /// \param aaa Aaa /// \param ... Vararg int test_vararg_param1(int aaa, ...);