From 2e5079701144078b901cac49f02f0fc000a3d83c Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Mon, 16 Feb 2015 20:37:00 +0000 Subject: [PATCH] ASTMatchers: Make TypeList a variadic template and remove the implicit flattening of TypeLists. Building trees of TypeLists is no longer necessary. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@229429 91177308-0d34-0410-b5e6-96231b3b80d8 --- .../clang/ASTMatchers/ASTMatchersInternal.h | 56 +++++-------------- include/clang/ASTMatchers/ASTMatchersMacros.h | 2 +- 2 files changed, 15 insertions(+), 43 deletions(-) diff --git a/include/clang/ASTMatchers/ASTMatchersInternal.h b/include/clang/ASTMatchers/ASTMatchersInternal.h index 3f4d64936e..86a31ea280 100644 --- a/include/clang/ASTMatchers/ASTMatchersInternal.h +++ b/include/clang/ASTMatchers/ASTMatchersInternal.h @@ -847,19 +847,11 @@ protected: /// \brief A type-list implementation. /// -/// A list is declared as a tree of type list nodes, where the leafs are the -/// types. -/// However, it is used as a "linked list" of types, by using the ::head and -/// ::tail typedefs. -/// Each node supports up to 4 children (instead of just 2) to reduce the -/// nesting required by large lists. -template -struct TypeList { - /// \brief Implementation detail. Combined with the specializations below, - /// this typedef allows for flattening of nested structures. - typedef TypeList self; +/// A "linked list" of types, accessible by using the ::head and ::tail +/// typedefs. +template struct TypeList {}; // Empty sentinel type list. +template struct TypeList { /// \brief The first type on the list. typedef T1 head; @@ -867,24 +859,7 @@ struct TypeList { /// /// This type is used to do recursion. TypeList<>/EmptyTypeList indicates the /// end of the list. - typedef typename TypeList::self tail; -}; - -/// \brief Template specialization to allow nested lists. -/// -/// First element is a typelist. Pop its first element. -template -struct TypeList, T2, T3, - T4> : public TypeList::self, - typename TypeList::self> {}; - -/// \brief Template specialization to allow nested lists. -/// -/// First element is an empty typelist. Skip it. -template -struct TypeList, T2, T3, T4> : public TypeList { + typedef TypeList tail; }; /// \brief The empty type list. @@ -906,9 +881,8 @@ struct TypeListContainsSuperOf { /// \brief A "type list" that contains all types. /// /// Useful for matchers like \c anything and \c unless. -typedef TypeList< - TypeList, - TypeList > AllNodeBaseTypes; +typedef TypeList AllNodeBaseTypes; /// \brief Helper meta-function to extract the argument out of a function of /// type void(Arg). @@ -921,17 +895,15 @@ template struct ExtractFunctionArgMeta { /// \brief Default type lists for ArgumentAdaptingMatcher matchers. typedef AllNodeBaseTypes AdaptativeDefaultFromTypes; -typedef TypeList, - TypeList > -AdaptativeDefaultToTypes; +typedef TypeList AdaptativeDefaultToTypes; /// \brief All types that are supported by HasDeclarationMatcher above. -typedef TypeList, - TypeList, - TypeList, - TypeList > -HasDeclarationSupportedTypes; +typedef TypeList HasDeclarationSupportedTypes; /// \brief Converts a \c Matcher to a matcher of desired type \c To by /// "adapting" a \c To into a \c T. diff --git a/include/clang/ASTMatchers/ASTMatchersMacros.h b/include/clang/ASTMatchers/ASTMatchersMacros.h index b7888be7c1..7167dfb898 100644 --- a/include/clang/ASTMatchers/ASTMatchersMacros.h +++ b/include/clang/ASTMatchers/ASTMatchersMacros.h @@ -201,7 +201,7 @@ #define AST_POLYMORPHIC_SUPPORTED_TYPES_4(t1, t2, t3, t4) \ void(internal::TypeList) #define AST_POLYMORPHIC_SUPPORTED_TYPES_5(t1, t2, t3, t4, t5) \ - void(internal::TypeList >) + void(internal::TypeList) /// \brief AST_POLYMORPHIC_MATCHER(DefineMatcher) { ... } /// defines a single-parameter function named DefineMatcher() that is -- 2.50.1