diff options
| author | Fariborz Jahanian <fjahanian@apple.com> | 2013-06-19 18:08:03 +0000 |
|---|---|---|
| committer | Fariborz Jahanian <fjahanian@apple.com> | 2013-06-19 18:08:03 +0000 |
| commit | c0607ed68b739ac7c9a8aa415ef60010eacd838b (patch) | |
| tree | f491d6da190dccacd5207662e7f743b09b30a63a | |
| parent | 351a88f697363a2a6910602c1443f696a8c0b2eb (diff) | |
| download | bcm5719-llvm-c0607ed68b739ac7c9a8aa415ef60010eacd838b.tar.gz bcm5719-llvm-c0607ed68b739ac7c9a8aa415ef60010eacd838b.zip | |
documentation parsing: patch to make @class work for
class templates; and similarly, @function works for
function templates. // rdar://14124702
llvm-svn: 184329
| -rw-r--r-- | clang/include/clang/AST/CommentSema.h | 2 | ||||
| -rw-r--r-- | clang/lib/AST/CommentSema.cpp | 24 | ||||
| -rw-r--r-- | clang/test/Sema/warn-documentation.cpp | 44 |
3 files changed, 67 insertions, 3 deletions
diff --git a/clang/include/clang/AST/CommentSema.h b/clang/include/clang/AST/CommentSema.h index 15e454dcc38..753cae3e81d 100644 --- a/clang/include/clang/AST/CommentSema.h +++ b/clang/include/clang/AST/CommentSema.h @@ -220,6 +220,8 @@ public: bool isUnionDecl(); bool isObjCInterfaceDecl(); bool isObjCProtocolDecl(); + bool isClassTemplateDecl(); + bool isFunctionTemplateDecl(); ArrayRef<const ParmVarDecl *> getParamVars(); diff --git a/clang/lib/AST/CommentSema.cpp b/clang/lib/AST/CommentSema.cpp index c242eb0f606..06f23462ef2 100644 --- a/clang/lib/AST/CommentSema.cpp +++ b/clang/lib/AST/CommentSema.cpp @@ -99,10 +99,10 @@ void Sema::checkFunctionDeclVerbatimLine(const BlockCommandComment *Comment) { unsigned DiagSelect; switch (Comment->getCommandID()) { case CommandTraits::KCI_function: - DiagSelect = !isAnyFunctionDecl() ? 1 : 0; + DiagSelect = (!isAnyFunctionDecl() && !isFunctionTemplateDecl())? 1 : 0; break; case CommandTraits::KCI_functiongroup: - DiagSelect = !isAnyFunctionDecl() ? 2 : 0; + DiagSelect = (!isAnyFunctionDecl() && !isFunctionTemplateDecl())? 2 : 0; break; case CommandTraits::KCI_method: DiagSelect = !isObjCMethodDecl() ? 3 : 0; @@ -131,7 +131,7 @@ void Sema::checkContainerDeclVerbatimLine(const BlockCommandComment *Comment) { unsigned DiagSelect; switch (Comment->getCommandID()) { case CommandTraits::KCI_class: - DiagSelect = !isClassOrStructDecl() ? 1 : 0; + DiagSelect = (!isClassOrStructDecl() && !isClassTemplateDecl()) ? 1 : 0; // Allow @class command on @interface declarations. // FIXME. Currently, \class and @class are indistinguishable. So, // \class is also allowed on an @interface declaration @@ -870,6 +870,24 @@ bool Sema::isClassOrStructDecl() { isa<RecordDecl>(ThisDeclInfo->CurrentDecl) && !isUnionDecl(); } + +bool Sema::isClassTemplateDecl() { + if (!ThisDeclInfo) + return false; + if (!ThisDeclInfo->IsFilled) + inspectThisDecl(); + return ThisDeclInfo->CurrentDecl && + (isa<ClassTemplateDecl>(ThisDeclInfo->CurrentDecl)); +} + +bool Sema::isFunctionTemplateDecl() { + if (!ThisDeclInfo) + return false; + if (!ThisDeclInfo->IsFilled) + inspectThisDecl(); + return ThisDeclInfo->CurrentDecl && + (isa<FunctionTemplateDecl>(ThisDeclInfo->CurrentDecl)); +} bool Sema::isObjCInterfaceDecl() { if (!ThisDeclInfo) diff --git a/clang/test/Sema/warn-documentation.cpp b/clang/test/Sema/warn-documentation.cpp index b3ab0199dcb..1306ac991fc 100644 --- a/clang/test/Sema/warn-documentation.cpp +++ b/clang/test/Sema/warn-documentation.cpp @@ -950,3 +950,47 @@ class C1; @struct S3; */ class S3; + +// rdar://14124702 +//---------------------------------------------------------------------- +/// @class Predicate Predicate.h "lldb/Host/Predicate.h" +/// @brief A C++ wrapper class for providing threaded access to a value +/// of type T. +/// +/// A templatized class. +/// specified values. +//---------------------------------------------------------------------- +template <class T, class T1> +class Predicate +{ +}; + +//---------------------------------------------------------------------- +/// @class Predicate<int, char> Predicate.h "lldb/Host/Predicate.h" +/// @brief A C++ wrapper class for providing threaded access to a value +/// of type T. +/// +/// A template specilization class. +//---------------------------------------------------------------------- +template<> class Predicate<int, char> +{ +}; + +//---------------------------------------------------------------------- +/// @class Predicate<T, int> Predicate.h "lldb/Host/Predicate.h" +/// @brief A C++ wrapper class for providing threaded access to a value +/// of type T. +/// +/// A partial specialization template class. +//---------------------------------------------------------------------- +template<class T> class Predicate<T, int> +{ +}; + +/*! @function test_function +*/ +template <class T> T test_function (T arg); + +/*! @function test_function<int> +*/ +template <> int test_function<int> (int arg); |

