]> granicus.if.org Git - clang/commitdiff
Do not use delegated constructors.
authorSamuel Benzaquen <sbenza@google.com>
Wed, 1 Oct 2014 17:58:42 +0000 (17:58 +0000)
committerSamuel Benzaquen <sbenza@google.com>
Wed, 1 Oct 2014 17:58:42 +0000 (17:58 +0000)
Do not use delegated constructors.
It is not supported on all platforms yet.
Fixes build broken by r218769.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@218779 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/ASTMatchers/ASTMatchersInternal.h

index a89b37a6b2378b1a3745c9b013417f35635e17ef..f00277c1a6126f5fd01c4b11ad2dcafda848546f 100644 (file)
@@ -367,7 +367,10 @@ public:
   Matcher(const Matcher<From> &Other,
           typename std::enable_if<std::is_base_of<From, T>::value &&
                                   !std::is_same<From, T>::value>::type * = 0)
-      : Matcher(Other.Implementation) {}
+      : Implementation(restrictMatcher(Other.Implementation)) {
+    assert(Implementation.getSupportedKind().isSame(
+        ast_type_traits::ASTNodeKind::getFromNodeKind<T>()));
+  }
 
   /// \brief Implicitly converts \c Matcher<Type> to \c Matcher<QualType>.
   ///
@@ -432,9 +435,12 @@ public:
 private:
   template <typename U> friend class Matcher;
 
+  static DynTypedMatcher restrictMatcher(const DynTypedMatcher &Other) {
+    return Other.dynCastTo(ast_type_traits::ASTNodeKind::getFromNodeKind<T>());
+  }
+
   explicit Matcher(const DynTypedMatcher &Implementation)
-      : Implementation(Implementation.dynCastTo(
-            ast_type_traits::ASTNodeKind::getFromNodeKind<T>())) {
+      : Implementation(restrictMatcher(Implementation)) {
     assert(this->Implementation.getSupportedKind()
                .isSame(ast_type_traits::ASTNodeKind::getFromNodeKind<T>()));
   }