[clang] 0ad4948 - NFC: Move TypeList implementation up the file

Stephen Kelly via cfe-commits cfe-commits at lists.llvm.org
Fri May 7 16:36:29 PDT 2021


Author: Weston Carvalho
Date: 2021-05-08T00:35:13+01:00
New Revision: 0ad494838b8576de14144776490faa710fa2a099

URL: https://github.com/llvm/llvm-project/commit/0ad494838b8576de14144776490faa710fa2a099
DIFF: https://github.com/llvm/llvm-project/commit/0ad494838b8576de14144776490faa710fa2a099.diff

LOG: NFC: Move TypeList implementation up the file

This will make it possible for more code to use it.

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/clang/include/clang/ASTMatchers/ASTMatchersInternal.h b/clang/include/clang/ASTMatchers/ASTMatchersInternal.h
index e8f427bafa257..8d346a6b9315a 100644
--- a/clang/include/clang/ASTMatchers/ASTMatchersInternal.h
+++ b/clang/include/clang/ASTMatchers/ASTMatchersInternal.h
@@ -83,6 +83,37 @@ class BoundNodes;
 
 namespace internal {
 
+/// A type-list implementation.
+///
+/// A "linked list" of types, accessible by using the ::head and ::tail
+/// typedefs.
+template <typename... Ts> struct TypeList {}; // Empty sentinel type list.
+
+template <typename T1, typename... Ts> struct TypeList<T1, Ts...> {
+  /// The first type on the list.
+  using head = T1;
+
+  /// A sublist with the tail. ie everything but the head.
+  ///
+  /// This type is used to do recursion. TypeList<>/EmptyTypeList indicates the
+  /// end of the list.
+  using tail = TypeList<Ts...>;
+};
+
+/// The empty type list.
+using EmptyTypeList = TypeList<>;
+
+/// Helper meta-function to determine if some type \c T is present or
+///   a parent type in the list.
+template <typename AnyTypeList, typename T> struct TypeListContainsSuperOf {
+  static const bool value =
+      std::is_base_of<typename AnyTypeList::head, T>::value ||
+      TypeListContainsSuperOf<typename AnyTypeList::tail, T>::value;
+};
+template <typename T> struct TypeListContainsSuperOf<EmptyTypeList, T> {
+  static const bool value = false;
+};
+
 /// Variadic function object.
 ///
 /// Most of the functions below that use VariadicFunction could be implemented
@@ -1120,39 +1151,6 @@ struct IsBaseType {
 template <typename T>
 const bool IsBaseType<T>::value;
 
-/// A type-list implementation.
-///
-/// A "linked list" of types, accessible by using the ::head and ::tail
-/// typedefs.
-template <typename... Ts> struct TypeList {}; // Empty sentinel type list.
-
-template <typename T1, typename... Ts> struct TypeList<T1, Ts...> {
-  /// The first type on the list.
-  using head = T1;
-
-  /// A sublist with the tail. ie everything but the head.
-  ///
-  /// This type is used to do recursion. TypeList<>/EmptyTypeList indicates the
-  /// end of the list.
-  using tail = TypeList<Ts...>;
-};
-
-/// The empty type list.
-using EmptyTypeList = TypeList<>;
-
-/// Helper meta-function to determine if some type \c T is present or
-///   a parent type in the list.
-template <typename AnyTypeList, typename T>
-struct TypeListContainsSuperOf {
-  static const bool value =
-      std::is_base_of<typename AnyTypeList::head, T>::value ||
-      TypeListContainsSuperOf<typename AnyTypeList::tail, T>::value;
-};
-template <typename T>
-struct TypeListContainsSuperOf<EmptyTypeList, T> {
-  static const bool value = false;
-};
-
 /// A "type list" that contains all types.
 ///
 /// Useful for matchers like \c anything and \c unless.


        


More information about the cfe-commits mailing list