[PATCH] D20052: Add new ASTMatcher that matches dynamic exception specifications.

don hinton via cfe-commits cfe-commits at lists.llvm.org
Sat May 7 19:43:42 PDT 2016


hintonda created this revision.
hintonda added a reviewer: alexfh.
hintonda added a subscriber: cfe-commits.
Herald added a subscriber: klimek.

Add new ASTMatcher that matches dynamic exception specifications.

http://reviews.llvm.org/D20052

Files:
  include/clang/ASTMatchers/ASTMatchers.h

Index: include/clang/ASTMatchers/ASTMatchers.h
===================================================================
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -3212,6 +3212,25 @@
   return Node.isDefaulted();
 }
 
+/// \brief Matches functions that have a dynamic exception specification.
+///
+/// Given:
+/// \code
+///   void f();
+///   void g() noexcept;
+///   void h() throw();
+///   void i() throw(int);
+///   void j() throw(...);
+///   void k() noexcept(false);
+/// \endcode
+/// functionDecl(hasDynamicExceptionSpec())
+///   matches the declarations of h, i, and j, but not f, g or k.
+AST_MATCHER(FunctionDecl, hasDynamicExceptionSpec) {
+  if (const auto *FnTy = Node.getType()->getAs<FunctionProtoType>())
+    return FnTy->hasDynamicExceptionSpec();
+  return false;
+}
+
 /// \brief Matches functions that have a non-throwing exception specification.
 ///
 /// Given:


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D20052.56510.patch
Type: text/x-patch
Size: 935 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160508/00c71284/attachment.bin>


More information about the cfe-commits mailing list