[PATCH] D101572: Make `hasTypeLoc` matcher support more node types.

Weston Carvalho via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue May 4 10:18:55 PDT 2021


SilensAngelusNex added inline comments.


================
Comment at: clang/include/clang/ASTMatchers/ASTMatchersInternal.h:138-150
+template <typename... T> struct disjunction;
+template <typename T> struct disjunction<T> : public T {};
+template <typename Head, typename... Tail> struct disjunction<Head, Tail...> {
+  using type =
+      typename std::conditional<Head::value, Head, disjunction<Tail...>>::type;
+  static constexpr bool value = type::value;
+};
----------------
Is there a better way to express this? I was originally using

```
template <typename... Expected> struct is_one_of {
  template <typename T>
  static constexpr bool value = (std::is_base_of_v<Expected, T> || ...);
};
```
but that didn't compile because `is_base_of_v` and fold expressions are C++17 features.

Maybe it would be better to just explicitly write out an overload of `GetTypeSourceInfo` for each type?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D101572/new/

https://reviews.llvm.org/D101572



More information about the cfe-commits mailing list