r218779 - Do not use delegated constructors.

Samuel Benzaquen sbenza at google.com
Wed Oct 1 10:58:42 PDT 2014


Author: sbenza
Date: Wed Oct  1 12:58:42 2014
New Revision: 218779

URL: http://llvm.org/viewvc/llvm-project?rev=218779&view=rev
Log:
Do not use delegated constructors.

Do not use delegated constructors.
It is not supported on all platforms yet.
Fixes build broken by r218769.

Modified:
    cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h

Modified: cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h?rev=218779&r1=218778&r2=218779&view=diff
==============================================================================
--- cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h (original)
+++ cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h Wed Oct  1 12:58:42 2014
@@ -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>()));
   }





More information about the cfe-commits mailing list