brintos

brintos / llvm-project-archived public Read only

0
0
Text · 76.1 KiB · 2e528ed Raw
2257 lines · cpp
1//===--- MockHeaders.cpp - Mock headers for dataflow analyses -*- C++ ---*-===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8//9// This file defines mock headers for testing of dataflow analyses.10//11//===----------------------------------------------------------------------===//12 13#include "MockHeaders.h"14 15namespace clang {16namespace dataflow {17namespace test {18static constexpr char CStdDefHeader[] = R"(19#ifndef CSTDDEF_H20#define CSTDDEF_H21 22namespace std {23 24typedef decltype(sizeof(char)) size_t;25 26using nullptr_t = decltype(nullptr);27 28} // namespace std29 30typedef decltype(sizeof(char)) size_t;31typedef decltype(sizeof(char*)) ptrdiff_t;32 33#endif // CSTDDEF_H34)";35 36static constexpr char StdTypeTraitsHeader[] = R"(37#ifndef STD_TYPE_TRAITS_H38#define STD_TYPE_TRAITS_H39 40#include "cstddef.h"41 42namespace std {43 44template <typename T, T V>45struct integral_constant {46  static constexpr T value = V;47};48 49using true_type = integral_constant<bool, true>;50using false_type = integral_constant<bool, false>;51 52template< class T > struct remove_reference      {typedef T type;};53template< class T > struct remove_reference<T&>  {typedef T type;};54template< class T > struct remove_reference<T&&> {typedef T type;};55 56template <class T>57  using remove_reference_t = typename remove_reference<T>::type;58 59template <class T>60struct remove_extent {61  typedef T type;62};63 64template <class T>65struct remove_extent<T[]> {66  typedef T type;67};68 69template <class T, size_t N>70struct remove_extent<T[N]> {71  typedef T type;72};73 74template <class T>75struct is_array : false_type {};76 77template <class T>78struct is_array<T[]> : true_type {};79 80template <class T, size_t N>81struct is_array<T[N]> : true_type {};82 83template <class>84struct is_function : false_type {};85 86template <class Ret, class... Args>87struct is_function<Ret(Args...)> : true_type {};88 89namespace detail {90 91template <class T>92struct type_identity {93  using type = T;94};  // or use type_identity (since C++20)95 96template <class T>97auto try_add_pointer(int) -> type_identity<typename remove_reference<T>::type*>;98template <class T>99auto try_add_pointer(...) -> type_identity<T>;100 101}  // namespace detail102 103template <class T>104struct add_pointer : decltype(detail::try_add_pointer<T>(0)) {};105 106template <bool B, class T, class F>107struct conditional {108  typedef T type;109};110 111template <class T, class F>112struct conditional<false, T, F> {113  typedef F type;114};115 116template <class T>117struct remove_cv {118  typedef T type;119};120template <class T>121struct remove_cv<const T> {122  typedef T type;123};124template <class T>125struct remove_cv<volatile T> {126  typedef T type;127};128template <class T>129struct remove_cv<const volatile T> {130  typedef T type;131};132 133template <class T>134using remove_cv_t = typename remove_cv<T>::type;135 136template <class T>137struct decay {138 private:139  typedef typename remove_reference<T>::type U;140 141 public:142  typedef typename conditional<143      is_array<U>::value, typename remove_extent<U>::type*,144      typename conditional<is_function<U>::value, typename add_pointer<U>::type,145                           typename remove_cv<U>::type>::type>::type type;146};147 148template <bool B, class T = void>149struct enable_if {};150 151template <class T>152struct enable_if<true, T> {153  typedef T type;154};155 156template <bool B, class T = void>157using enable_if_t = typename enable_if<B, T>::type;158 159template <class T, class U>160struct is_same : false_type {};161 162template <class T>163struct is_same<T, T> : true_type {};164 165template <class T>166struct is_void : is_same<void, typename remove_cv<T>::type> {};167 168namespace detail {169 170template <class T>171auto try_add_lvalue_reference(int) -> type_identity<T&>;172template <class T>173auto try_add_lvalue_reference(...) -> type_identity<T>;174 175template <class T>176auto try_add_rvalue_reference(int) -> type_identity<T&&>;177template <class T>178auto try_add_rvalue_reference(...) -> type_identity<T>;179 180}  // namespace detail181 182template <class T>183struct add_lvalue_reference : decltype(detail::try_add_lvalue_reference<T>(0)) {184};185 186template <class T>187struct add_rvalue_reference : decltype(detail::try_add_rvalue_reference<T>(0)) {188};189 190template <class T>191typename add_rvalue_reference<T>::type declval() noexcept;192 193namespace detail {194 195template <class T>196auto test_returnable(int)197    -> decltype(void(static_cast<T (*)()>(nullptr)), true_type{});198template <class>199auto test_returnable(...) -> false_type;200 201template <class From, class To>202auto test_implicitly_convertible(int)203    -> decltype(void(declval<void (&)(To)>()(declval<From>())), true_type{});204template <class, class>205auto test_implicitly_convertible(...) -> false_type;206 207}  // namespace detail208 209template <class From, class To>210struct is_convertible211    : integral_constant<bool,212                        (decltype(detail::test_returnable<To>(0))::value &&213                         decltype(detail::test_implicitly_convertible<From, To>(214                             0))::value) ||215                            (is_void<From>::value && is_void<To>::value)> {};216 217template <class From, class To>218inline constexpr bool is_convertible_v = is_convertible<From, To>::value;219 220template <class...>221using void_t = void;222 223template <class, class T, class... Args>224struct is_constructible_ : false_type {};225 226template <class T, class... Args>227struct is_constructible_<void_t<decltype(T(declval<Args>()...))>, T, Args...>228    : true_type {};229 230template <class T, class... Args>231using is_constructible = is_constructible_<void_t<>, T, Args...>;232 233template <class T, class... Args>234inline constexpr bool is_constructible_v = is_constructible<T, Args...>::value;235 236template <class _Tp>237struct __uncvref {238  typedef typename remove_cv<typename remove_reference<_Tp>::type>::type type;239};240 241template <class _Tp>242using __uncvref_t = typename __uncvref<_Tp>::type;243 244template <bool _Val>245using _BoolConstant = integral_constant<bool, _Val>;246 247template <class _Tp, class _Up>248using _IsSame = _BoolConstant<__is_same(_Tp, _Up)>;249 250template <class _Tp, class _Up>251using _IsNotSame = _BoolConstant<!__is_same(_Tp, _Up)>;252 253template <bool>254struct _MetaBase;255template <>256struct _MetaBase<true> {257  template <class _Tp, class _Up>258  using _SelectImpl = _Tp;259  template <template <class...> class _FirstFn, template <class...> class,260            class... _Args>261  using _SelectApplyImpl = _FirstFn<_Args...>;262  template <class _First, class...>263  using _FirstImpl = _First;264  template <class, class _Second, class...>265  using _SecondImpl = _Second;266  template <class _Result, class _First, class... _Rest>267  using _OrImpl =268      typename _MetaBase<_First::value != true && sizeof...(_Rest) != 0>::269          template _OrImpl<_First, _Rest...>;270};271 272template <>273struct _MetaBase<false> {274  template <class _Tp, class _Up>275  using _SelectImpl = _Up;276  template <template <class...> class, template <class...> class _SecondFn,277            class... _Args>278  using _SelectApplyImpl = _SecondFn<_Args...>;279  template <class _Result, class...>280  using _OrImpl = _Result;281};282 283template <bool _Cond, class _IfRes, class _ElseRes>284using _If = typename _MetaBase<_Cond>::template _SelectImpl<_IfRes, _ElseRes>;285 286template <class... _Rest>287using _Or = typename _MetaBase<sizeof...(_Rest) !=288                               0>::template _OrImpl<false_type, _Rest...>;289 290template <bool _Bp, class _Tp = void>291using __enable_if_t = typename enable_if<_Bp, _Tp>::type;292 293template <class...>294using __expand_to_true = true_type;295template <class... _Pred>296__expand_to_true<__enable_if_t<_Pred::value>...> __and_helper(int);297template <class...>298false_type __and_helper(...);299template <class... _Pred>300using _And = decltype(__and_helper<_Pred...>(0));301 302template <class _Pred>303struct _Not : _BoolConstant<!_Pred::value> {};304 305struct __check_tuple_constructor_fail {306  static constexpr bool __enable_explicit_default() { return false; }307  static constexpr bool __enable_implicit_default() { return false; }308  template <class...>309  static constexpr bool __enable_explicit() {310    return false;311  }312  template <class...>313  static constexpr bool __enable_implicit() {314    return false;315  }316};317 318template <typename, typename _Tp>319struct __select_2nd {320  typedef _Tp type;321};322template <class _Tp, class _Arg>323typename __select_2nd<decltype((declval<_Tp>() = declval<_Arg>())),324                      true_type>::type325__is_assignable_test(int);326template <class, class>327false_type __is_assignable_test(...);328template <class _Tp, class _Arg,329          bool = is_void<_Tp>::value || is_void<_Arg>::value>330struct __is_assignable_imp331    : public decltype((__is_assignable_test<_Tp, _Arg>(0))) {};332template <class _Tp, class _Arg>333struct __is_assignable_imp<_Tp, _Arg, true> : public false_type {};334template <class _Tp, class _Arg>335struct is_assignable : public __is_assignable_imp<_Tp, _Arg> {};336 337template <class _Tp>338struct __libcpp_is_integral : public false_type {};339template <>340struct __libcpp_is_integral<bool> : public true_type {};341template <>342struct __libcpp_is_integral<char> : public true_type {};343template <>344struct __libcpp_is_integral<signed char> : public true_type {};345template <>346struct __libcpp_is_integral<unsigned char> : public true_type {};347template <>348struct __libcpp_is_integral<wchar_t> : public true_type {};349template <>350struct __libcpp_is_integral<short> : public true_type {};  // NOLINT351template <>352struct __libcpp_is_integral<unsigned short> : public true_type {};  // NOLINT353template <>354struct __libcpp_is_integral<int> : public true_type {};355template <>356struct __libcpp_is_integral<unsigned int> : public true_type {};357template <>358struct __libcpp_is_integral<long> : public true_type {};  // NOLINT359template <>360struct __libcpp_is_integral<unsigned long> : public true_type {};  // NOLINT361template <>362struct __libcpp_is_integral<long long> : public true_type {};  // NOLINT363template <>                                                    // NOLINTNEXTLINE364struct __libcpp_is_integral<unsigned long long> : public true_type {};365template <class _Tp>366struct is_integral367    : public __libcpp_is_integral<typename remove_cv<_Tp>::type> {};368 369template <class _Tp>370struct __libcpp_is_floating_point : public false_type {};371template <>372struct __libcpp_is_floating_point<float> : public true_type {};373template <>374struct __libcpp_is_floating_point<double> : public true_type {};375template <>376struct __libcpp_is_floating_point<long double> : public true_type {};377template <class _Tp>378struct is_floating_point379    : public __libcpp_is_floating_point<typename remove_cv<_Tp>::type> {};380 381template <class _Tp>382struct is_arithmetic383    : public integral_constant<bool, is_integral<_Tp>::value ||384                                         is_floating_point<_Tp>::value> {};385 386template <class _Tp>387struct __libcpp_is_pointer : public false_type {};388template <class _Tp>389struct __libcpp_is_pointer<_Tp*> : public true_type {};390template <class _Tp>391struct is_pointer : public __libcpp_is_pointer<typename remove_cv<_Tp>::type> {392};393 394template <class _Tp>395struct __libcpp_is_member_pointer : public false_type {};396template <class _Tp, class _Up>397struct __libcpp_is_member_pointer<_Tp _Up::*> : public true_type {};398template <class _Tp>399struct is_member_pointer400    : public __libcpp_is_member_pointer<typename remove_cv<_Tp>::type> {};401 402template <class _Tp>403struct __libcpp_union : public false_type {};404template <class _Tp>405struct is_union : public __libcpp_union<typename remove_cv<_Tp>::type> {};406 407template <class T>408struct is_reference : false_type {};409template <class T>410struct is_reference<T&> : true_type {};411template <class T>412struct is_reference<T&&> : true_type {};413 414template <class T>415inline constexpr bool is_reference_v = is_reference<T>::value;416 417struct __two {418  char __lx[2];419};420 421namespace __is_class_imp {422template <class _Tp>423char __test(int _Tp::*);424template <class _Tp>425__two __test(...);426}  // namespace __is_class_imp427template <class _Tp>428struct is_class429    : public integral_constant<bool,430                               sizeof(__is_class_imp::__test<_Tp>(0)) == 1 &&431                                   !is_union<_Tp>::value> {};432 433template <class _Tp>434struct __is_nullptr_t_impl : public false_type {};435template <>436struct __is_nullptr_t_impl<nullptr_t> : public true_type {};437template <class _Tp>438struct __is_nullptr_t439    : public __is_nullptr_t_impl<typename remove_cv<_Tp>::type> {};440template <class _Tp>441struct is_null_pointer442    : public __is_nullptr_t_impl<typename remove_cv<_Tp>::type> {};443 444template <class _Tp>445struct is_enum446    : public integral_constant<447          bool, !is_void<_Tp>::value && !is_integral<_Tp>::value &&448                    !is_floating_point<_Tp>::value && !is_array<_Tp>::value &&449                    !is_pointer<_Tp>::value && !is_reference<_Tp>::value &&450                    !is_member_pointer<_Tp>::value && !is_union<_Tp>::value &&451                    !is_class<_Tp>::value && !is_function<_Tp>::value> {};452 453template <class _Tp>454struct is_scalar455    : public integral_constant<456          bool, is_arithmetic<_Tp>::value || is_member_pointer<_Tp>::value ||457                    is_pointer<_Tp>::value || __is_nullptr_t<_Tp>::value ||458                    is_enum<_Tp>::value> {};459template <>460struct is_scalar<nullptr_t> : public true_type {};461 462struct in_place_t {};463 464constexpr in_place_t in_place;465 466} // namespace std467 468#endif // STD_TYPE_TRAITS_H469)";470 471static constexpr char AbslTypeTraitsHeader[] = R"(472#ifndef ABSL_TYPE_TRAITS_H473#define ABSL_TYPE_TRAITS_H474 475#include "std_type_traits.h"476 477namespace absl {478 479template <typename... Ts>480struct conjunction : std::true_type {};481 482template <typename T, typename... Ts>483struct conjunction<T, Ts...>484    : std::conditional<T::value, conjunction<Ts...>, T>::type {};485 486template <typename T>487struct conjunction<T> : T {};488 489template <typename... Ts>490struct disjunction : std::false_type {};491 492template <typename T, typename... Ts>493struct disjunction<T, Ts...>494    : std::conditional<T::value, T, disjunction<Ts...>>::type {};495 496template <typename T>497struct disjunction<T> : T {};498 499template <typename T>500struct negation : std::integral_constant<bool, !T::value> {};501 502template <bool B, typename T = void>503using enable_if_t = typename std::enable_if<B, T>::type;504 505 506template <bool B, typename T, typename F>507using conditional_t = typename std::conditional<B, T, F>::type;508 509template <typename T>510using remove_cv_t = typename std::remove_cv<T>::type;511 512template <typename T>513using remove_reference_t = typename std::remove_reference<T>::type;514 515template <typename T>516using decay_t = typename std::decay<T>::type;517 518using std::in_place;519using std::in_place_t;520} // namespace absl521 522#endif // ABSL_TYPE_TRAITS_H523)";524 525static constexpr char StdStringHeader[] = R"(526#ifndef STRING_H527#define STRING_H528 529namespace std {530 531struct string {532  string(const char*);533  ~string();534  const char *c_str() const;535  bool empty();536};537 538struct string_view {539  string_view(const char*);540  ~string_view();541  bool empty();542};543 544bool operator!=(const string &LHS, const char *RHS);545 546} // namespace std547 548#endif // STRING_H549)";550 551static constexpr char StdUtilityHeader[] = R"(552#ifndef UTILITY_H553#define UTILITY_H554 555#include "std_type_traits.h"556 557namespace std {558 559template <typename T>560constexpr remove_reference_t<T>&& move(T&& x);561 562template <typename T>563void swap(T& a, T& b) noexcept;564 565} // namespace std566 567#endif // UTILITY_H568)";569 570static constexpr char StdInitializerListHeader[] = R"(571#ifndef INITIALIZER_LIST_H572#define INITIALIZER_LIST_H573 574namespace std {575 576template <typename T>577class initializer_list {578 public:579  const T *a, *b;580  initializer_list() noexcept;581};582 583} // namespace std584 585#endif // INITIALIZER_LIST_H586)";587 588static constexpr char StdOptionalHeader[] = R"(589#include "std_initializer_list.h"590#include "std_type_traits.h"591#include "std_utility.h"592 593namespace std {594 595struct nullopt_t {596  constexpr explicit nullopt_t() {}597};598constexpr nullopt_t nullopt;599 600template <class _Tp>601struct __optional_destruct_base {602  constexpr void reset() noexcept;603};604 605template <class _Tp>606struct __optional_storage_base : __optional_destruct_base<_Tp> {607  constexpr bool has_value() const noexcept;608};609 610template <typename _Tp>611class optional : private __optional_storage_base<_Tp> {612  using __base = __optional_storage_base<_Tp>;613 614 public:615  using value_type = _Tp;616 617 private:618  struct _CheckOptionalArgsConstructor {619    template <class _Up>620    static constexpr bool __enable_implicit() {621      return is_constructible_v<_Tp, _Up&&> && is_convertible_v<_Up&&, _Tp>;622    }623 624    template <class _Up>625    static constexpr bool __enable_explicit() {626      return is_constructible_v<_Tp, _Up&&> && !is_convertible_v<_Up&&, _Tp>;627    }628  };629  template <class _Up>630  using _CheckOptionalArgsCtor =631      _If<_IsNotSame<__uncvref_t<_Up>, in_place_t>::value &&632              _IsNotSame<__uncvref_t<_Up>, optional>::value,633          _CheckOptionalArgsConstructor, __check_tuple_constructor_fail>;634  template <class _QualUp>635  struct _CheckOptionalLikeConstructor {636    template <class _Up, class _Opt = optional<_Up>>637    using __check_constructible_from_opt =638        _Or<is_constructible<_Tp, _Opt&>, is_constructible<_Tp, _Opt const&>,639            is_constructible<_Tp, _Opt&&>, is_constructible<_Tp, _Opt const&&>,640            is_convertible<_Opt&, _Tp>, is_convertible<_Opt const&, _Tp>,641            is_convertible<_Opt&&, _Tp>, is_convertible<_Opt const&&, _Tp>>;642    template <class _Up, class _QUp = _QualUp>643    static constexpr bool __enable_implicit() {644      return is_convertible<_QUp, _Tp>::value &&645             !__check_constructible_from_opt<_Up>::value;646    }647    template <class _Up, class _QUp = _QualUp>648    static constexpr bool __enable_explicit() {649      return !is_convertible<_QUp, _Tp>::value &&650             !__check_constructible_from_opt<_Up>::value;651    }652  };653 654  template <class _Up, class _QualUp>655  using _CheckOptionalLikeCtor =656      _If<_And<_IsNotSame<_Up, _Tp>, is_constructible<_Tp, _QualUp>>::value,657          _CheckOptionalLikeConstructor<_QualUp>,658          __check_tuple_constructor_fail>;659 660 661  template <class _Up, class _QualUp>662  using _CheckOptionalLikeAssign = _If<663      _And<664          _IsNotSame<_Up, _Tp>,665          is_constructible<_Tp, _QualUp>,666          is_assignable<_Tp&, _QualUp>667      >::value,668      _CheckOptionalLikeConstructor<_QualUp>,669      __check_tuple_constructor_fail670    >;671 672 public:673  constexpr optional() noexcept {}674  constexpr optional(const optional&) = default;675  constexpr optional(optional&&) = default;676  constexpr optional(nullopt_t) noexcept {}677 678  template <679      class _InPlaceT, class... _Args,680      class = enable_if_t<_And<_IsSame<_InPlaceT, in_place_t>,681                             is_constructible<value_type, _Args...>>::value>>682  constexpr explicit optional(_InPlaceT, _Args&&... __args);683 684  template <class _Up, class... _Args,685            class = enable_if_t<is_constructible_v<686                value_type, initializer_list<_Up>&, _Args...>>>687  constexpr explicit optional(in_place_t, initializer_list<_Up> __il,688                              _Args&&... __args);689 690  template <691      class _Up = value_type,692      enable_if_t<_CheckOptionalArgsCtor<_Up>::template __enable_implicit<_Up>(),693                int> = 0>694  constexpr optional(_Up&& __v);695 696  template <697      class _Up,698      enable_if_t<_CheckOptionalArgsCtor<_Up>::template __enable_explicit<_Up>(),699                int> = 0>700  constexpr explicit optional(_Up&& __v);701 702  template <class _Up, enable_if_t<_CheckOptionalLikeCtor<_Up, _Up const&>::703                                     template __enable_implicit<_Up>(),704                                 int> = 0>705  constexpr optional(const optional<_Up>& __v);706 707  template <class _Up, enable_if_t<_CheckOptionalLikeCtor<_Up, _Up const&>::708                                     template __enable_explicit<_Up>(),709                                 int> = 0>710  constexpr explicit optional(const optional<_Up>& __v);711 712  template <class _Up, enable_if_t<_CheckOptionalLikeCtor<_Up, _Up&&>::713                                     template __enable_implicit<_Up>(),714                                 int> = 0>715  constexpr optional(optional<_Up>&& __v);716 717  template <class _Up, enable_if_t<_CheckOptionalLikeCtor<_Up, _Up&&>::718                                     template __enable_explicit<_Up>(),719                                 int> = 0>720  constexpr explicit optional(optional<_Up>&& __v);721 722  constexpr optional& operator=(nullopt_t) noexcept;723 724  optional& operator=(const optional&);725 726  optional& operator=(optional&&);727 728  template <class _Up = value_type,729            class = enable_if_t<_And<_IsNotSame<__uncvref_t<_Up>, optional>,730                                   _Or<_IsNotSame<__uncvref_t<_Up>, value_type>,731                                       _Not<is_scalar<value_type>>>,732                                   is_constructible<value_type, _Up>,733                                   is_assignable<value_type&, _Up>>::value>>734  constexpr optional& operator=(_Up&& __v);735 736  template <class _Up, enable_if_t<_CheckOptionalLikeAssign<_Up, _Up const&>::737                                     template __enable_assign<_Up>(),738                                 int> = 0>739  constexpr optional& operator=(const optional<_Up>& __v);740 741  template <class _Up, enable_if_t<_CheckOptionalLikeCtor<_Up, _Up&&>::742                                     template __enable_assign<_Up>(),743                                 int> = 0>744  constexpr optional& operator=(optional<_Up>&& __v);745 746  const _Tp& operator*() const&;747  _Tp& operator*() &;748  const _Tp&& operator*() const&&;749  _Tp&& operator*() &&;750 751  const _Tp* operator->() const;752  _Tp* operator->();753 754  const _Tp& value() const&;755  _Tp& value() &;756  const _Tp&& value() const&&;757  _Tp&& value() &&;758 759  template <typename U>760  constexpr _Tp value_or(U&& v) const&;761  template <typename U>762  _Tp value_or(U&& v) &&;763 764  template <typename... Args>765  _Tp& emplace(Args&&... args);766 767  template <typename U, typename... Args>768  _Tp& emplace(std::initializer_list<U> ilist, Args&&... args);769 770  using __base::reset;771 772  constexpr explicit operator bool() const noexcept;773  using __base::has_value;774 775  constexpr void swap(optional& __opt) noexcept;776};777 778template <typename T>779constexpr optional<typename std::decay<T>::type> make_optional(T&& v);780 781template <typename T, typename... Args>782constexpr optional<T> make_optional(Args&&... args);783 784template <typename T, typename U, typename... Args>785constexpr optional<T> make_optional(std::initializer_list<U> il,786                                    Args&&... args);787 788template <typename T, typename U>789constexpr bool operator==(const optional<T> &lhs, const optional<U> &rhs);790template <typename T, typename U>791constexpr bool operator!=(const optional<T> &lhs, const optional<U> &rhs);792 793template <typename T>794constexpr bool operator==(const optional<T> &opt, nullopt_t);795 796// C++20 and later do not define the following overloads because they are797// provided by rewritten candidates instead.798#if __cplusplus < 202002L799template <typename T>800constexpr bool operator==(nullopt_t, const optional<T> &opt);801template <typename T>802constexpr bool operator!=(const optional<T> &opt, nullopt_t);803template <typename T>804constexpr bool operator!=(nullopt_t, const optional<T> &opt);805#endif  // __cplusplus < 202002L806 807template <typename T, typename U>808constexpr bool operator==(const optional<T> &opt, const U &value);809template <typename T, typename U>810constexpr bool operator==(const T &value, const optional<U> &opt);811template <typename T, typename U>812constexpr bool operator!=(const optional<T> &opt, const U &value);813template <typename T, typename U>814constexpr bool operator!=(const T &value, const optional<U> &opt);815 816} // namespace std817)";818 819static constexpr char AbslOptionalHeader[] = R"(820#include "absl_type_traits.h"821#include "std_initializer_list.h"822#include "std_type_traits.h"823#include "std_utility.h"824 825namespace absl {826 827struct nullopt_t {828  constexpr explicit nullopt_t() {}829};830constexpr nullopt_t nullopt;831 832template <typename T>833class optional;834 835namespace optional_internal {836 837template <typename T, typename U>838struct is_constructible_convertible_from_optional839    : std::integral_constant<840          bool, std::is_constructible<T, optional<U>&>::value ||841                    std::is_constructible<T, optional<U>&&>::value ||842                    std::is_constructible<T, const optional<U>&>::value ||843                    std::is_constructible<T, const optional<U>&&>::value ||844                    std::is_convertible<optional<U>&, T>::value ||845                    std::is_convertible<optional<U>&&, T>::value ||846                    std::is_convertible<const optional<U>&, T>::value ||847                    std::is_convertible<const optional<U>&&, T>::value> {};848 849template <typename T, typename U>850struct is_constructible_convertible_assignable_from_optional851    : std::integral_constant<852          bool, is_constructible_convertible_from_optional<T, U>::value ||853                    std::is_assignable<T&, optional<U>&>::value ||854                    std::is_assignable<T&, optional<U>&&>::value ||855                    std::is_assignable<T&, const optional<U>&>::value ||856                    std::is_assignable<T&, const optional<U>&&>::value> {};857 858}  // namespace optional_internal859 860template <typename T>861class optional {862 public:863  constexpr optional() noexcept;864 865  constexpr optional(nullopt_t) noexcept;866 867  optional(const optional&) = default;868 869  optional(optional&&) = default;870 871  template <typename InPlaceT, typename... Args,872            absl::enable_if_t<absl::conjunction<873                std::is_same<InPlaceT, in_place_t>,874                std::is_constructible<T, Args&&...>>::value>* = nullptr>875  constexpr explicit optional(InPlaceT, Args&&... args);876 877  template <typename U, typename... Args,878            typename = typename std::enable_if<std::is_constructible<879                T, std::initializer_list<U>&, Args&&...>::value>::type>880  constexpr explicit optional(in_place_t, std::initializer_list<U> il,881                              Args&&... args);882 883  template <884      typename U = T,885      typename std::enable_if<886          absl::conjunction<absl::negation<std::is_same<887                                in_place_t, typename std::decay<U>::type>>,888                            absl::negation<std::is_same<889                                optional<T>, typename std::decay<U>::type>>,890                            std::is_convertible<U&&, T>,891                            std::is_constructible<T, U&&>>::value,892          bool>::type = false>893  constexpr optional(U&& v);894 895  template <896      typename U = T,897      typename std::enable_if<898          absl::conjunction<absl::negation<std::is_same<899                                in_place_t, typename std::decay<U>::type>>,900                            absl::negation<std::is_same<901                                optional<T>, typename std::decay<U>::type>>,902                            absl::negation<std::is_convertible<U&&, T>>,903                            std::is_constructible<T, U&&>>::value,904          bool>::type = false>905  explicit constexpr optional(U&& v);906 907  template <typename U,908            typename std::enable_if<909                absl::conjunction<910                    absl::negation<std::is_same<T, U>>,911                    std::is_constructible<T, const U&>,912                    absl::negation<913                        optional_internal::914                            is_constructible_convertible_from_optional<T, U>>,915                    std::is_convertible<const U&, T>>::value,916                bool>::type = false>917  optional(const optional<U>& rhs);918 919  template <typename U,920            typename std::enable_if<921                absl::conjunction<922                    absl::negation<std::is_same<T, U>>,923                    std::is_constructible<T, const U&>,924                    absl::negation<925                        optional_internal::926                            is_constructible_convertible_from_optional<T, U>>,927                    absl::negation<std::is_convertible<const U&, T>>>::value,928                bool>::type = false>929  explicit optional(const optional<U>& rhs);930 931  template <932      typename U,933      typename std::enable_if<934          absl::conjunction<935              absl::negation<std::is_same<T, U>>, std::is_constructible<T, U&&>,936              absl::negation<937                  optional_internal::is_constructible_convertible_from_optional<938                      T, U>>,939              std::is_convertible<U&&, T>>::value,940          bool>::type = false>941  optional(optional<U>&& rhs);942 943  template <944      typename U,945      typename std::enable_if<946          absl::conjunction<947              absl::negation<std::is_same<T, U>>, std::is_constructible<T, U&&>,948              absl::negation<949                  optional_internal::is_constructible_convertible_from_optional<950                      T, U>>,951              absl::negation<std::is_convertible<U&&, T>>>::value,952          bool>::type = false>953  explicit optional(optional<U>&& rhs);954 955  optional& operator=(nullopt_t) noexcept;956 957  optional& operator=(const optional& src);958 959  optional& operator=(optional&& src);960 961  template <962      typename U = T,963      typename = typename std::enable_if<absl::conjunction<964          absl::negation<965              std::is_same<optional<T>, typename std::decay<U>::type>>,966          absl::negation<967              absl::conjunction<std::is_scalar<T>,968                                std::is_same<T, typename std::decay<U>::type>>>,969          std::is_constructible<T, U>, std::is_assignable<T&, U>>::value>::type>970  optional& operator=(U&& v);971 972  template <973      typename U,974      typename = typename std::enable_if<absl::conjunction<975          absl::negation<std::is_same<T, U>>,976          std::is_constructible<T, const U&>, std::is_assignable<T&, const U&>,977          absl::negation<978              optional_internal::979                  is_constructible_convertible_assignable_from_optional<980                      T, U>>>::value>::type>981  optional& operator=(const optional<U>& rhs);982 983  template <typename U,984            typename = typename std::enable_if<absl::conjunction<985                absl::negation<std::is_same<T, U>>, std::is_constructible<T, U>,986                std::is_assignable<T&, U>,987                absl::negation<988                    optional_internal::989                        is_constructible_convertible_assignable_from_optional<990                            T, U>>>::value>::type>991  optional& operator=(optional<U>&& rhs);992 993  const T& operator*() const&;994  T& operator*() &;995  const T&& operator*() const&&;996  T&& operator*() &&;997 998  const T* operator->() const;999  T* operator->();1000 1001  const T& value() const&;1002  T& value() &;1003  const T&& value() const&&;1004  T&& value() &&;1005 1006  template <typename U>1007  constexpr T value_or(U&& v) const&;1008  template <typename U>1009  T value_or(U&& v) &&;1010 1011  template <typename... Args>1012  T& emplace(Args&&... args);1013 1014  template <typename U, typename... Args>1015  T& emplace(std::initializer_list<U> ilist, Args&&... args);1016 1017  void reset() noexcept;1018 1019  constexpr explicit operator bool() const noexcept;1020  constexpr bool has_value() const noexcept;1021 1022  void swap(optional& rhs) noexcept;1023};1024 1025template <typename T>1026constexpr optional<typename std::decay<T>::type> make_optional(T&& v);1027 1028template <typename T, typename... Args>1029constexpr optional<T> make_optional(Args&&... args);1030 1031template <typename T, typename U, typename... Args>1032constexpr optional<T> make_optional(std::initializer_list<U> il,1033                                    Args&&... args);1034 1035template <typename T, typename U>1036constexpr bool operator==(const optional<T> &lhs, const optional<U> &rhs);1037template <typename T, typename U>1038constexpr bool operator!=(const optional<T> &lhs, const optional<U> &rhs);1039 1040template <typename T>1041constexpr bool operator==(const optional<T> &opt, nullopt_t);1042template <typename T>1043constexpr bool operator==(nullopt_t, const optional<T> &opt);1044template <typename T>1045constexpr bool operator!=(const optional<T> &opt, nullopt_t);1046template <typename T>1047constexpr bool operator!=(nullopt_t, const optional<T> &opt);1048 1049template <typename T, typename U>1050constexpr bool operator==(const optional<T> &opt, const U &value);1051template <typename T, typename U>1052constexpr bool operator==(const T &value, const optional<U> &opt);1053template <typename T, typename U>1054constexpr bool operator!=(const optional<T> &opt, const U &value);1055template <typename T, typename U>1056constexpr bool operator!=(const T &value, const optional<U> &opt);1057 1058} // namespace absl1059)";1060 1061static constexpr char BaseOptionalHeader[] = R"(1062#include "std_initializer_list.h"1063#include "std_type_traits.h"1064#include "std_utility.h"1065 1066namespace base {1067 1068struct in_place_t {};1069constexpr in_place_t in_place;1070 1071struct nullopt_t {1072  constexpr explicit nullopt_t() {}1073};1074constexpr nullopt_t nullopt;1075 1076template <typename T>1077class Optional;1078 1079namespace internal {1080 1081template <typename T>1082using RemoveCvRefT = std::remove_cv_t<std::remove_reference_t<T>>;1083 1084template <typename T, typename U>1085struct IsConvertibleFromOptional1086    : std::integral_constant<1087          bool, std::is_constructible<T, Optional<U>&>::value ||1088                    std::is_constructible<T, const Optional<U>&>::value ||1089                    std::is_constructible<T, Optional<U>&&>::value ||1090                    std::is_constructible<T, const Optional<U>&&>::value ||1091                    std::is_convertible<Optional<U>&, T>::value ||1092                    std::is_convertible<const Optional<U>&, T>::value ||1093                    std::is_convertible<Optional<U>&&, T>::value ||1094                    std::is_convertible<const Optional<U>&&, T>::value> {};1095 1096template <typename T, typename U>1097struct IsAssignableFromOptional1098    : std::integral_constant<1099          bool, IsConvertibleFromOptional<T, U>::value ||1100                    std::is_assignable<T&, Optional<U>&>::value ||1101                    std::is_assignable<T&, const Optional<U>&>::value ||1102                    std::is_assignable<T&, Optional<U>&&>::value ||1103                    std::is_assignable<T&, const Optional<U>&&>::value> {};1104 1105}  // namespace internal1106 1107template <typename T>1108class Optional {1109 public:1110  using value_type = T;1111 1112  constexpr Optional() = default;1113  constexpr Optional(const Optional& other) noexcept = default;1114  constexpr Optional(Optional&& other) noexcept = default;1115 1116  constexpr Optional(nullopt_t);1117 1118  template <typename U,1119            typename std::enable_if<1120                std::is_constructible<T, const U&>::value &&1121                    !internal::IsConvertibleFromOptional<T, U>::value &&1122                    std::is_convertible<const U&, T>::value,1123                bool>::type = false>1124  Optional(const Optional<U>& other) noexcept;1125 1126  template <typename U,1127            typename std::enable_if<1128                std::is_constructible<T, const U&>::value &&1129                    !internal::IsConvertibleFromOptional<T, U>::value &&1130                    !std::is_convertible<const U&, T>::value,1131                bool>::type = false>1132  explicit Optional(const Optional<U>& other) noexcept;1133 1134  template <typename U,1135            typename std::enable_if<1136                std::is_constructible<T, U&&>::value &&1137                    !internal::IsConvertibleFromOptional<T, U>::value &&1138                    std::is_convertible<U&&, T>::value,1139                bool>::type = false>1140  Optional(Optional<U>&& other) noexcept;1141 1142  template <typename U,1143            typename std::enable_if<1144                std::is_constructible<T, U&&>::value &&1145                    !internal::IsConvertibleFromOptional<T, U>::value &&1146                    !std::is_convertible<U&&, T>::value,1147                bool>::type = false>1148  explicit Optional(Optional<U>&& other) noexcept;1149 1150  template <class... Args>1151  constexpr explicit Optional(in_place_t, Args&&... args);1152 1153  template <class U, class... Args,1154            class = typename std::enable_if<std::is_constructible<1155                value_type, std::initializer_list<U>&, Args...>::value>::type>1156  constexpr explicit Optional(in_place_t, std::initializer_list<U> il,1157                              Args&&... args);1158 1159  template <1160      typename U = value_type,1161      typename std::enable_if<1162          std::is_constructible<T, U&&>::value &&1163              !std::is_same<internal::RemoveCvRefT<U>, in_place_t>::value &&1164              !std::is_same<internal::RemoveCvRefT<U>, Optional<T>>::value &&1165              std::is_convertible<U&&, T>::value,1166          bool>::type = false>1167  constexpr Optional(U&& value);1168 1169  template <1170      typename U = value_type,1171      typename std::enable_if<1172          std::is_constructible<T, U&&>::value &&1173              !std::is_same<internal::RemoveCvRefT<U>, in_place_t>::value &&1174              !std::is_same<internal::RemoveCvRefT<U>, Optional<T>>::value &&1175              !std::is_convertible<U&&, T>::value,1176          bool>::type = false>1177  constexpr explicit Optional(U&& value);1178 1179  Optional& operator=(const Optional& other) noexcept;1180 1181  Optional& operator=(Optional&& other) noexcept;1182 1183  Optional& operator=(nullopt_t);1184 1185  template <typename U>1186  typename std::enable_if<1187      !std::is_same<internal::RemoveCvRefT<U>, Optional<T>>::value &&1188          std::is_constructible<T, U>::value &&1189          std::is_assignable<T&, U>::value &&1190          (!std::is_scalar<T>::value ||1191           !std::is_same<typename std::decay<U>::type, T>::value),1192      Optional&>::type1193  operator=(U&& value) noexcept;1194 1195  template <typename U>1196  typename std::enable_if<!internal::IsAssignableFromOptional<T, U>::value &&1197                              std::is_constructible<T, const U&>::value &&1198                              std::is_assignable<T&, const U&>::value,1199                          Optional&>::type1200  operator=(const Optional<U>& other) noexcept;1201 1202  template <typename U>1203  typename std::enable_if<!internal::IsAssignableFromOptional<T, U>::value &&1204                              std::is_constructible<T, U>::value &&1205                              std::is_assignable<T&, U>::value,1206                          Optional&>::type1207  operator=(Optional<U>&& other) noexcept;1208 1209  const T& operator*() const&;1210  T& operator*() &;1211  const T&& operator*() const&&;1212  T&& operator*() &&;1213 1214  const T* operator->() const;1215  T* operator->();1216 1217  const T& value() const&;1218  T& value() &;1219  const T&& value() const&&;1220  T&& value() &&;1221 1222  template <typename U>1223  constexpr T value_or(U&& v) const&;1224  template <typename U>1225  T value_or(U&& v) &&;1226 1227  template <typename... Args>1228  T& emplace(Args&&... args);1229 1230  template <typename U, typename... Args>1231  T& emplace(std::initializer_list<U> ilist, Args&&... args);1232 1233  void reset() noexcept;1234 1235  constexpr explicit operator bool() const noexcept;1236  constexpr bool has_value() const noexcept;1237 1238  void swap(Optional& other);1239};1240 1241template <typename T>1242constexpr Optional<typename std::decay<T>::type> make_optional(T&& v);1243 1244template <typename T, typename... Args>1245constexpr Optional<T> make_optional(Args&&... args);1246 1247template <typename T, typename U, typename... Args>1248constexpr Optional<T> make_optional(std::initializer_list<U> il,1249                                    Args&&... args);1250 1251template <typename T, typename U>1252constexpr bool operator==(const Optional<T> &lhs, const Optional<U> &rhs);1253template <typename T, typename U>1254constexpr bool operator!=(const Optional<T> &lhs, const Optional<U> &rhs);1255 1256template <typename T>1257constexpr bool operator==(const Optional<T> &opt, nullopt_t);1258template <typename T>1259constexpr bool operator==(nullopt_t, const Optional<T> &opt);1260template <typename T>1261constexpr bool operator!=(const Optional<T> &opt, nullopt_t);1262template <typename T>1263constexpr bool operator!=(nullopt_t, const Optional<T> &opt);1264 1265template <typename T, typename U>1266constexpr bool operator==(const Optional<T> &opt, const U &value);1267template <typename T, typename U>1268constexpr bool operator==(const T &value, const Optional<U> &opt);1269template <typename T, typename U>1270constexpr bool operator!=(const Optional<T> &opt, const U &value);1271template <typename T, typename U>1272constexpr bool operator!=(const T &value, const Optional<U> &opt);1273 1274} // namespace base1275)";1276 1277constexpr const char StatusDefsHeader[] =1278    R"cc(1279#ifndef STATUS_H_1280#define STATUS_H_1281 1282#include "absl_type_traits.h"1283#include "std_initializer_list.h"1284#include "std_string.h"1285#include "std_type_traits.h"1286#include "std_utility.h"1287 1288namespace absl {1289struct SourceLocation {1290  static constexpr SourceLocation current();1291  static constexpr SourceLocation1292  DoNotInvokeDirectlyNoSeriouslyDont(int line, const char *file_name);1293};1294} // namespace absl1295namespace absl {1296enum class StatusCode : int {1297  kOk,1298  kCancelled,1299  kUnknown,1300  kInvalidArgument,1301  kDeadlineExceeded,1302  kNotFound,1303  kAlreadyExists,1304  kPermissionDenied,1305  kResourceExhausted,1306  kFailedPrecondition,1307  kAborted,1308  kOutOfRange,1309  kUnimplemented,1310  kInternal,1311  kUnavailable,1312  kDataLoss,1313  kUnauthenticated,1314};1315} // namespace absl1316 1317namespace absl {1318enum class StatusToStringMode : int {1319  kWithNoExtraData = 0,1320  kWithPayload = 1 << 0,1321  kWithSourceLocation = 1 << 1,1322  kWithEverything = ~kWithNoExtraData,1323  kDefault = kWithPayload,1324};1325class Status {1326public:1327  Status();1328  template <typename Enum> Status(Enum code, std::string_view msg);1329  Status(absl::StatusCode code, std::string_view msg,1330         absl::SourceLocation loc = SourceLocation::current());1331  Status(const Status &base_status, absl::SourceLocation loc);1332  Status(Status &&base_status, absl::SourceLocation loc);1333  ~Status() {}1334 1335  Status(const Status &);1336  Status &operator=(const Status &x);1337 1338  Status(Status &&) noexcept;1339  Status &operator=(Status &&);1340 1341  friend bool operator==(const Status &, const Status &);1342  friend bool operator!=(const Status &, const Status &);1343 1344  bool ok() const { return true; }1345  void CheckSuccess() const;1346  void IgnoreError() const;1347  int error_code() const;1348  absl::Status ToCanonical() const;1349  std::string1350  ToString(StatusToStringMode m = StatusToStringMode::kDefault) const;1351  void Update(const Status &new_status);1352  void Update(Status &&new_status);1353};1354 1355bool operator==(const Status &lhs, const Status &rhs);1356bool operator!=(const Status &lhs, const Status &rhs);1357 1358Status OkStatus();1359Status InvalidArgumentError(const char *);1360 1361#endif // STATUS_H1362)cc";1363 1364constexpr const char StatusOrDefsHeader[] = R"cc(1365#ifndef STATUSOR_H_1366#define STATUSOR_H_1367#include "absl_type_traits.h"1368#include "status_defs.h"1369#include "std_initializer_list.h"1370#include "std_type_traits.h"1371#include "std_utility.h"1372 1373template <typename T> struct StatusOr;1374 1375namespace internal_statusor {1376 1377template <typename T, typename U, typename = void>1378struct HasConversionOperatorToStatusOr : std::false_type {};1379 1380template <typename T, typename U>1381void test(char (*)[sizeof(std::declval<U>().operator absl::StatusOr<T>())]);1382 1383template <typename T, typename U>1384struct HasConversionOperatorToStatusOr<T, U, decltype(test<T, U>(0))>1385    : std::true_type {};1386 1387template <typename T, typename U>1388using IsConstructibleOrConvertibleFromStatusOr =1389    absl::disjunction<std::is_constructible<T, StatusOr<U> &>,1390                      std::is_constructible<T, const StatusOr<U> &>,1391                      std::is_constructible<T, StatusOr<U> &&>,1392                      std::is_constructible<T, const StatusOr<U> &&>,1393                      std::is_convertible<StatusOr<U> &, T>,1394                      std::is_convertible<const StatusOr<U> &, T>,1395                      std::is_convertible<StatusOr<U> &&, T>,1396                      std::is_convertible<const StatusOr<U> &&, T>>;1397 1398template <typename T, typename U>1399using IsConstructibleOrConvertibleOrAssignableFromStatusOr =1400    absl::disjunction<IsConstructibleOrConvertibleFromStatusOr<T, U>,1401                      std::is_assignable<T &, StatusOr<U> &>,1402                      std::is_assignable<T &, const StatusOr<U> &>,1403                      std::is_assignable<T &, StatusOr<U> &&>,1404                      std::is_assignable<T &, const StatusOr<U> &&>>;1405 1406template <typename T, typename U>1407struct IsDirectInitializationAmbiguous1408    : public absl::conditional_t<1409          std::is_same<absl::remove_cv_t<absl::remove_reference_t<U>>,1410                       U>::value,1411          std::false_type,1412          IsDirectInitializationAmbiguous<1413              T, absl::remove_cv_t<absl::remove_reference_t<U>>>> {};1414 1415template <typename T, typename V>1416struct IsDirectInitializationAmbiguous<T, absl::StatusOr<V>>1417    : public IsConstructibleOrConvertibleFromStatusOr<T, V> {};1418 1419template <typename T, typename U>1420using IsDirectInitializationValid = absl::disjunction<1421    // Short circuits if T is basically U.1422    std::is_same<T, absl::remove_cv_t<absl::remove_reference_t<U>>>,1423    absl::negation<absl::disjunction<1424        std::is_same<absl::StatusOr<T>,1425                     absl::remove_cv_t<absl::remove_reference_t<U>>>,1426        std::is_same<absl::Status,1427                     absl::remove_cv_t<absl::remove_reference_t<U>>>,1428        std::is_same<absl::in_place_t,1429                     absl::remove_cv_t<absl::remove_reference_t<U>>>,1430        IsDirectInitializationAmbiguous<T, U>>>>;1431 1432template <typename T, typename U>1433struct IsForwardingAssignmentAmbiguous1434    : public absl::conditional_t<1435          std::is_same<absl::remove_cv_t<absl::remove_reference_t<U>>,1436                       U>::value,1437          std::false_type,1438          IsForwardingAssignmentAmbiguous<1439              T, absl::remove_cv_t<absl::remove_reference_t<U>>>> {};1440 1441template <typename T, typename U>1442struct IsForwardingAssignmentAmbiguous<T, absl::StatusOr<U>>1443    : public IsConstructibleOrConvertibleOrAssignableFromStatusOr<T, U> {};1444 1445template <typename T, typename U>1446using IsForwardingAssignmentValid = absl::disjunction<1447    // Short circuits if T is basically U.1448    std::is_same<T, absl::remove_cv_t<absl::remove_reference_t<U>>>,1449    absl::negation<absl::disjunction<1450        std::is_same<absl::StatusOr<T>,1451                     absl::remove_cv_t<absl::remove_reference_t<U>>>,1452        std::is_same<absl::Status,1453                     absl::remove_cv_t<absl::remove_reference_t<U>>>,1454        std::is_same<absl::in_place_t,1455                     absl::remove_cv_t<absl::remove_reference_t<U>>>,1456        IsForwardingAssignmentAmbiguous<T, U>>>>;1457 1458template <typename T, typename U>1459using IsForwardingAssignmentValid = absl::disjunction<1460    // Short circuits if T is basically U.1461    std::is_same<T, absl::remove_cv_t<absl::remove_reference_t<U>>>,1462    absl::negation<absl::disjunction<1463        std::is_same<absl::StatusOr<T>,1464                     absl::remove_cv_t<absl::remove_reference_t<U>>>,1465        std::is_same<absl::Status,1466                     absl::remove_cv_t<absl::remove_reference_t<U>>>,1467        std::is_same<absl::in_place_t,1468                     absl::remove_cv_t<absl::remove_reference_t<U>>>,1469        IsForwardingAssignmentAmbiguous<T, U>>>>;1470 1471template <typename T> struct OperatorBase {1472  const T &value() const &;1473  T &value() &;1474  const T &&value() const &&;1475  T &&value() &&;1476 1477  const T &operator*() const &;1478  T &operator*() &;1479  const T &&operator*() const &&;1480  T &&operator*() &&;1481 1482  // To test that analyses are okay if there is a use of operator*1483  // within this base class.1484  const T *operator->() const { return __builtin_addressof(**this); }1485  T *operator->() { return __builtin_addressof(**this); }1486};1487 1488} // namespace internal_statusor1489 1490template <typename T>1491struct StatusOr : private internal_statusor::OperatorBase<T> {1492  explicit StatusOr();1493 1494  StatusOr(const StatusOr &) = default;1495  StatusOr &operator=(const StatusOr &) = default;1496 1497  StatusOr(StatusOr &&) = default;1498  StatusOr &operator=(StatusOr &&) = default;1499 1500  template <1501      typename U,1502      absl::enable_if_t<1503          absl::conjunction<1504              absl::negation<std::is_same<T, U>>,1505              std::is_constructible<T, const U &>,1506              std::is_convertible<const U &, T>,1507              absl::negation<1508                  internal_statusor::IsConstructibleOrConvertibleFromStatusOr<1509                      T, U>>>::value,1510          int> = 0>1511  StatusOr(const StatusOr<U> &);1512 1513  template <1514      typename U,1515      absl::enable_if_t<1516          absl::conjunction<1517              absl::negation<std::is_same<T, U>>,1518              std::is_constructible<T, const U &>,1519              absl::negation<std::is_convertible<const U &, T>>,1520              absl::negation<1521                  internal_statusor::IsConstructibleOrConvertibleFromStatusOr<1522                      T, U>>>::value,1523          int> = 0>1524  explicit StatusOr(const StatusOr<U> &);1525 1526  template <1527      typename U,1528      absl::enable_if_t<1529          absl::conjunction<1530              absl::negation<std::is_same<T, U>>,1531              std::is_constructible<T, U &&>, std::is_convertible<U &&, T>,1532              absl::negation<1533                  internal_statusor::IsConstructibleOrConvertibleFromStatusOr<1534                      T, U>>>::value,1535          int> = 0>1536  StatusOr(StatusOr<U> &&);1537 1538  template <1539      typename U,1540      absl::enable_if_t<1541          absl::conjunction<1542              absl::negation<std::is_same<T, U>>,1543              std::is_constructible<T, U &&>,1544              absl::negation<std::is_convertible<U &&, T>>,1545              absl::negation<1546                  internal_statusor::IsConstructibleOrConvertibleFromStatusOr<1547                      T, U>>>::value,1548          int> = 0>1549  explicit StatusOr(StatusOr<U> &&);1550 1551  template <1552      typename U,1553      absl::enable_if_t<1554          absl::conjunction<1555              absl::negation<std::is_same<T, U>>,1556              std::is_constructible<T, const U &>,1557              std::is_assignable<T, const U &>,1558              absl::negation<1559                  internal_statusor::1560                      IsConstructibleOrConvertibleOrAssignableFromStatusOr<1561                          T, U>>>::value,1562          int> = 0>1563  StatusOr &operator=(const StatusOr<U> &);1564 1565  template <1566      typename U,1567      absl::enable_if_t<1568          absl::conjunction<1569              absl::negation<std::is_same<T, U>>,1570              std::is_constructible<T, U &&>, std::is_assignable<T, U &&>,1571              absl::negation<1572                  internal_statusor::1573                      IsConstructibleOrConvertibleOrAssignableFromStatusOr<1574                          T, U>>>::value,1575          int> = 0>1576  StatusOr &operator=(StatusOr<U> &&);1577 1578  template <1579      typename U = absl::Status,1580      absl::enable_if_t<1581          absl::conjunction<1582              std::is_convertible<U &&, absl::Status>,1583              std::is_constructible<absl::Status, U &&>,1584              absl::negation<std::is_same<absl::decay_t<U>, absl::StatusOr<T>>>,1585              absl::negation<std::is_same<absl::decay_t<U>, T>>,1586              absl::negation<std::is_same<absl::decay_t<U>, absl::in_place_t>>,1587              absl::negation<internal_statusor::HasConversionOperatorToStatusOr<1588                  T, U &&>>>::value,1589          int> = 0>1590  StatusOr(U &&);1591 1592  template <1593      typename U = absl::Status,1594      absl::enable_if_t<1595          absl::conjunction<1596              absl::negation<std::is_convertible<U &&, absl::Status>>,1597              std::is_constructible<absl::Status, U &&>,1598              absl::negation<std::is_same<absl::decay_t<U>, absl::StatusOr<T>>>,1599              absl::negation<std::is_same<absl::decay_t<U>, T>>,1600              absl::negation<std::is_same<absl::decay_t<U>, absl::in_place_t>>,1601              absl::negation<internal_statusor::HasConversionOperatorToStatusOr<1602                  T, U &&>>>::value,1603          int> = 0>1604  explicit StatusOr(U &&);1605 1606  template <1607      typename U = absl::Status,1608      absl::enable_if_t<1609          absl::conjunction<1610              std::is_convertible<U &&, absl::Status>,1611              std::is_constructible<absl::Status, U &&>,1612              absl::negation<std::is_same<absl::decay_t<U>, absl::StatusOr<T>>>,1613              absl::negation<std::is_same<absl::decay_t<U>, T>>,1614              absl::negation<std::is_same<absl::decay_t<U>, absl::in_place_t>>,1615              absl::negation<internal_statusor::HasConversionOperatorToStatusOr<1616                  T, U &&>>>::value,1617          int> = 0>1618  StatusOr &operator=(U &&);1619 1620  template <1621      typename U = T,1622      typename = typename std::enable_if<absl::conjunction<1623          std::is_constructible<T, U &&>, std::is_assignable<T &, U &&>,1624          absl::disjunction<1625              std::is_same<absl::remove_cv_t<absl::remove_reference_t<U>>, T>,1626              absl::conjunction<1627                  absl::negation<std::is_convertible<U &&, absl::Status>>,1628                  absl::negation<1629                      internal_statusor::HasConversionOperatorToStatusOr<1630                          T, U &&>>>>,1631          internal_statusor::IsForwardingAssignmentValid<T, U &&>>::value>::1632          type>1633  StatusOr &operator=(U &&);1634 1635  template <typename... Args> explicit StatusOr(absl::in_place_t, Args &&...);1636 1637  template <typename U, typename... Args>1638  explicit StatusOr(absl::in_place_t, std::initializer_list<U>, Args &&...);1639 1640  template <1641      typename U = T,1642      absl::enable_if_t<1643          absl::conjunction<1644              internal_statusor::IsDirectInitializationValid<T, U &&>,1645              std::is_constructible<T, U &&>, std::is_convertible<U &&, T>,1646              absl::disjunction<1647                  std::is_same<absl::remove_cv_t<absl::remove_reference_t<U>>,1648                               T>,1649                  absl::conjunction<1650                      absl::negation<std::is_convertible<U &&, absl::Status>>,1651                      absl::negation<1652                          internal_statusor::HasConversionOperatorToStatusOr<1653                              T, U &&>>>>>::value,1654          int> = 0>1655  StatusOr(U &&);1656 1657  template <1658      typename U = T,1659      absl::enable_if_t<1660          absl::conjunction<1661              internal_statusor::IsDirectInitializationValid<T, U &&>,1662              absl::disjunction<1663                  std::is_same<absl::remove_cv_t<absl::remove_reference_t<U>>,1664                               T>,1665                  absl::conjunction<1666                      absl::negation<std::is_constructible<absl::Status, U &&>>,1667                      absl::negation<1668                          internal_statusor::HasConversionOperatorToStatusOr<1669                              T, U &&>>>>,1670              std::is_constructible<T, U &&>,1671              absl::negation<std::is_convertible<U &&, T>>>::value,1672          int> = 0>1673  explicit StatusOr(U &&);1674 1675  bool ok() const;1676 1677  const Status &status() const & { return status_; }1678  Status status() &&;1679 1680  using StatusOr::OperatorBase::value;1681 1682  const T &ValueOrDie() const &;1683  T &ValueOrDie() &;1684  const T &&ValueOrDie() const &&;1685  T &&ValueOrDie() &&;1686 1687  using StatusOr::OperatorBase::operator*;1688  using StatusOr::OperatorBase::operator->;1689 1690  template <typename U> T value_or(U &&default_value) const &;1691  template <typename U> T value_or(U &&default_value) &&;1692 1693  template <typename... Args> T &emplace(Args &&...args);1694 1695  template <1696      typename U, typename... Args,1697      absl::enable_if_t<std::is_constructible<T, std::initializer_list<U> &,1698                                              Args &&...>::value,1699                        int> = 0>1700  T &emplace(std::initializer_list<U> ilist, Args &&...args);1701 1702private:1703  absl::Status status_;1704};1705 1706template <typename T>1707bool operator==(const StatusOr<T> &lhs, const StatusOr<T> &rhs);1708 1709template <typename T>1710bool operator!=(const StatusOr<T> &lhs, const StatusOr<T> &rhs);1711 1712} // namespace absl1713 1714#endif // STATUSOR_H_1715)cc";1716 1717static constexpr char StdVectorHeader[] = R"cc(1718#ifndef STD_VECTOR_H1719#define STD_VECTOR_H1720namespace std {1721template <class T> struct allocator {1722  typedef size_t size_type;1723  typedef ptrdiff_t difference_type;1724  typedef T *pointer;1725  typedef const T *const_pointer;1726  typedef T value_type;1727 1728  T *allocate(size_t n);1729};1730 1731template <class Alloc> struct allocator_traits {1732  typedef Alloc allocator_type;1733  typedef typename allocator_type::value_type value_type;1734  typedef typename allocator_type::pointer pointer;1735  typedef typename allocator_type::const_pointer const_pointer;1736  typedef typename allocator_type::difference_type difference_type;1737  typedef typename allocator_type::size_type size_type;1738};1739 1740template <typename T, class Allocator = allocator<T>> class vector {1741public:1742  using value_type = T;1743  using size_type = typename allocator_traits<Allocator>::size_type;1744 1745  // Constructors.1746  vector() {}1747  vector(size_type, const Allocator & = Allocator()) {}1748  vector(initializer_list<T> initializer_list,1749         const Allocator & = Allocator()) {}1750  vector(const vector &vector) {}1751  ~vector();1752 1753  // Modifiers.1754  void push_back(const T &value);1755  void push_back(T &&value);1756  template <typename... Args> T &emplace_back(Args &&...args);1757 1758  // Iterators1759  class InputIterator {1760  public:1761    InputIterator(const InputIterator &);1762    ~InputIterator();1763    InputIterator &operator=(const InputIterator &);1764    InputIterator &operator++();1765    T &operator*() const;1766    bool operator!=(const InputIterator &) const;1767    bool operator==(const InputIterator &) const;1768  };1769  typedef InputIterator iterator;1770  typedef const InputIterator const_iterator;1771  iterator begin() noexcept;1772  const_iterator begin() const noexcept;1773  const_iterator cbegin() const noexcept;1774  iterator end() noexcept;1775  const_iterator end() const noexcept;1776  const_iterator cend() const noexcept;1777  T *data() noexcept;1778  const T *data() const noexcept;1779  T &operator[](int n);1780  const T &operator[](int n) const;1781  T &at(int n);1782  const T &at(int n) const;1783  size_t size() const;1784};1785} // namespace std1786#endif // STD_VECTOR_H1787)cc";1788 1789static constexpr char StdPairHeader[] = R"cc(1790#ifndef STD_PAIR_H1791#define STD_PAIR_H1792namespace std {1793template <class T1, class T2> struct pair {1794  T1 first;1795  T2 second;1796 1797  typedef T1 first_type;1798  typedef T2 second_type;1799 1800  constexpr pair();1801 1802  template <class U1, class U2> pair(pair<U1, U2> &&p);1803 1804  template <class U1, class U2> pair(U1 &&x, U2 &&y);1805};1806 1807template <class T1, class T2> pair<T1, T2> make_pair(T1 &&t1, T2 &&t2);1808} // namespace std1809#endif // STD_PAIR_H1810)cc";1811 1812constexpr const char AbslLogHeader[] = R"cc(1813#ifndef ABSL_LOG_H1814#define ABSL_LOG_H1815 1816#include "std_pair.h"1817 1818namespace absl {1819 1820#define ABSL_PREDICT_FALSE(x) (__builtin_expect(false || (x), false))1821#define ABSL_PREDICT_TRUE(x) (__builtin_expect(false || (x), true))1822 1823namespace log_internal {1824class LogMessage {1825public:1826  LogMessage();1827  LogMessage &stream();1828  LogMessage &InternalStream();1829  LogMessage &WithVerbosity(int verboselevel);1830  template <typename T> LogMessage &operator<<(const T &);1831};1832class LogMessageFatal : public LogMessage {1833public:1834  LogMessageFatal();1835  ~LogMessageFatal() __attribute__((noreturn));1836};1837class LogMessageQuietlyFatal : public LogMessage {1838public:1839  LogMessageQuietlyFatal();1840  ~LogMessageQuietlyFatal() __attribute__((noreturn));1841};1842class Voidify final {1843public:1844  // This has to be an operator with a precedence lower than << but higher1845  // than1846  // ?:1847  template <typename T> void operator&&(const T &) const && {}1848};1849} // namespace log_internal1850} // namespace absl1851 1852#ifndef NULL1853#define NULL __null1854#endif1855extern "C" void abort() {}1856#define ABSL_LOG_INTERNAL_LOG_INFO ::absl::log_internal::LogMessage()1857#define ABSL_LOG_INTERNAL_LOG_WARNING ::absl::log_internal::LogMessage()1858#define ABSL_LOG_INTERNAL_LOG_ERROR ::absl::log_internal::LogMessage()1859#define ABSL_LOG_INTERNAL_LOG_FATAL ::absl::log_internal::LogMessageFatal()1860#define ABSL_LOG_INTERNAL_LOG_QFATAL                                           \1861  ::absl::log_internal::LogMessageQuietlyFatal()1862#define LOG(severity) ABSL_LOG_INTERNAL_LOG_##severity.InternalStream()1863 1864#define PREDICT_FALSE(x) (__builtin_expect(x, 0))1865#define ABSL_LOG_INTERNAL_STRIP_STRING_LITERAL(lit) lit1866 1867#define ABSL_LOG_INTERNAL_STATELESS_CONDITION(condition)                       \1868  switch (0)                                                                   \1869  case 0:                                                                      \1870  default:                                                                     \1871    !(condition) ? (void)0 : ::absl::log_internal::Voidify() &&1872 1873#define ABSL_LOG_INTERNAL_CONDITION_INFO(type, condition)                      \1874  ABSL_LOG_INTERNAL_##type##_CONDITION(condition)1875 1876#define ABSL_LOG_INTERNAL_CONDITION_FATAL(type, condition)                     \1877  ABSL_LOG_INTERNAL_##type##_CONDITION(condition)1878 1879#define ABSL_LOG_INTERNAL_CONDITION_QFATAL(type, condition)                    \1880  ABSL_LOG_INTERNAL_##type##_CONDITION(condition)1881 1882#define ABSL_CHECK_IMPL(condition, condition_text)                             \1883  ABSL_LOG_INTERNAL_CONDITION_FATAL(STATELESS,                                 \1884                                    ABSL_PREDICT_FALSE(!(condition)))          \1885  ABSL_LOG_INTERNAL_CHECK(condition_text).InternalStream()1886 1887#define ABSL_QCHECK_IMPL(condition, condition_text)                            \1888  ABSL_LOG_INTERNAL_CONDITION_QFATAL(STATELESS,                                \1889                                     ABSL_PREDICT_FALSE(!(condition)))         \1890  ABSL_LOG_INTERNAL_QCHECK(condition_text).InternalStream()1891 1892#define CHECK(condition) ABSL_CHECK_IMPL((condition), #condition)1893#define DCHECK(condition) CHECK(condition)1894#define QCHECK(condition) ABSL_QCHECK_IMPL((condition), #condition)1895 1896#define ABSL_LOG_INTERNAL_MAX_LOG_VERBOSITY_CHECK(x)1897 1898namespace absl {1899 1900template <typename T> class StatusOr;1901class Status;1902 1903namespace status_internal {1904std::string *MakeCheckFailString(const absl::Status *status,1905                                 const char *prefix);1906} // namespace status_internal1907 1908namespace log_internal {1909template <class T> const T &GetReferenceableValue(const T &t);1910char GetReferenceableValue(char t);1911unsigned char GetReferenceableValue(unsigned char t);1912signed char GetReferenceableValue(signed char t);1913short GetReferenceableValue(short t);1914unsigned short GetReferenceableValue(unsigned short t);1915int GetReferenceableValue(int t);1916unsigned int GetReferenceableValue(unsigned int t);1917long GetReferenceableValue(long t);1918unsigned long GetReferenceableValue(unsigned long t);1919long long GetReferenceableValue(long long t);1920unsigned long long GetReferenceableValue(unsigned long long t);1921const absl::Status *AsStatus(const absl::Status &s);1922template <typename T> const absl::Status *AsStatus(const absl::StatusOr<T> &s);1923} // namespace log_internal1924} // namespace absl1925// TODO(tkd): this still doesn't allow operator<<, unlike the real CHECK_1926// macros.1927#define ABSL_LOG_INTERNAL_CHECK_OP(name, op, val1, val2)                       \1928  while (char *_result = ::absl::log_internal::name##Impl(                     \1929             ::absl::log_internal::GetReferenceableValue(val1),                \1930             ::absl::log_internal::GetReferenceableValue(val2),                \1931             #val1 " " #op " " #val2))                                         \1932  (void)01933#define ABSL_LOG_INTERNAL_QCHECK_OP(name, op, val1, val2)                      \1934  while (char *_result = ::absl::log_internal::name##Impl(                     \1935             ::absl::log_internal::GetReferenceableValue(val1),                \1936             ::absl::log_internal::GetReferenceableValue(val2),                \1937             #val1 " " #op " " #val2))                                         \1938  (void)01939namespace absl {1940namespace log_internal {1941template <class T1, class T2>1942char *Check_NEImpl(const T1 &v1, const T2 &v2, const char *names);1943template <class T1, class T2>1944char *Check_EQImpl(const T1 &v1, const T2 &v2, const char *names);1945template <class T1, class T2>1946char *Check_LTImpl(const T1 &v1, const T2 &v2, const char *names);1947 1948#define CHECK_EQ(a, b) ABSL_LOG_INTERNAL_CHECK_OP(Check_EQ, ==, a, b)1949#define CHECK_NE(a, b) ABSL_LOG_INTERNAL_CHECK_OP(Check_NE, !=, a, b)1950#define CHECK_LT(a, b) ABSL_LOG_INTERNAL_CHECK_OP(Check_EQ, <, a, b)1951 1952#define QCHECK_EQ(a, b) ABSL_LOG_INTERNAL_QCHECK_OP(Check_EQ, ==, a, b)1953#define QCHECK_NE(a, b) ABSL_LOG_INTERNAL_QCHECK_OP(Check_NE, !=, a, b)1954} // namespace log_internal1955} // namespace absl1956 1957#define CHECK_NOTNULL(x) CHECK((x) != nullptr)1958 1959#define ABSL_LOG_INTERNAL_CHECK(failure_message)                               \1960  ::absl::log_internal::LogMessageFatal()1961#define ABSL_LOG_INTERNAL_QCHECK(failure_message)                              \1962  ::absl::log_internal::LogMessageQuietlyFatal()1963#define ABSL_LOG_INTERNAL_CHECK_OK(val)                                        \1964  for (::std::pair<const ::absl::Status *, ::std::string *>                    \1965           absl_log_internal_check_ok_goo;                                     \1966       absl_log_internal_check_ok_goo.first =                                  \1967           ::absl::log_internal::AsStatus(val),                                \1968       absl_log_internal_check_ok_goo.second =                                 \1969           ABSL_PREDICT_TRUE(absl_log_internal_check_ok_goo.first->ok())       \1970               ? nullptr                                                       \1971               : ::absl::status_internal::MakeCheckFailString(                 \1972                     absl_log_internal_check_ok_goo.first,                     \1973                     ABSL_LOG_INTERNAL_STRIP_STRING_LITERAL(#val " is OK")),   \1974       !ABSL_PREDICT_TRUE(absl_log_internal_check_ok_goo.first->ok());)        \1975  ABSL_LOG_INTERNAL_CHECK(*absl_log_internal_check_ok_goo.second)              \1976      .InternalStream()1977#define ABSL_LOG_INTERNAL_QCHECK_OK(val)                                       \1978  for (::std::pair<const ::absl::Status *, ::std::string *>                    \1979           absl_log_internal_check_ok_goo;                                     \1980       absl_log_internal_check_ok_goo.first =                                  \1981           ::absl::log_internal::AsStatus(val),                                \1982       absl_log_internal_check_ok_goo.second =                                 \1983           ABSL_PREDICT_TRUE(absl_log_internal_check_ok_goo.first->ok())       \1984               ? nullptr                                                       \1985               : ::absl::status_internal::MakeCheckFailString(                 \1986                     absl_log_internal_check_ok_goo.first,                     \1987                     ABSL_LOG_INTERNAL_STRIP_STRING_LITERAL(#val " is OK")),   \1988       !ABSL_PREDICT_TRUE(absl_log_internal_check_ok_goo.first->ok());)        \1989  ABSL_LOG_INTERNAL_QCHECK(*absl_log_internal_check_ok_goo.second)             \1990      .InternalStream()1991 1992#define CHECK_OK(val) ABSL_LOG_INTERNAL_CHECK_OK(val)1993#define DCHECK_OK(val) ABSL_LOG_INTERNAL_CHECK_OK(val)1994#define QCHECK_OK(val) ABSL_LOG_INTERNAL_QCHECK_OK(val)1995 1996#endif // ABSL_LOG_H1997)cc";1998 1999constexpr const char TestingDefsHeader[] = R"cc(2000#pragma clang system_header2001 2002#ifndef TESTING_DEFS_H2003#define TESTING_DEFS_H2004 2005#include "absl_type_traits.h"2006#include "std_initializer_list.h"2007#include "std_string.h"2008#include "std_type_traits.h"2009#include "std_utility.h"2010 2011namespace testing {2012struct AssertionResult {2013  template <typename T>2014  explicit AssertionResult(const T &res, bool enable_if = true) {}2015  ~AssertionResult();2016  operator bool() const;2017  template <typename T> AssertionResult &operator<<(const T &value);2018  const char *failure_message() const;2019};2020 2021class TestPartResult {2022public:2023  enum Type { kSuccess, kNonFatalFailure, kFatalFailure, kSkip };2024};2025 2026class Test {2027public:2028  virtual ~Test() = default;2029 2030protected:2031  virtual void SetUp() {}2032};2033 2034class Message {2035public:2036  template <typename T> Message &operator<<(const T &val);2037};2038 2039namespace internal {2040class AssertHelper {2041public:2042  AssertHelper(TestPartResult::Type type, const char *file, int line,2043               const char *message);2044  void operator=(const Message &message) const;2045};2046 2047class EqHelper {2048public:2049  template <typename T1, typename T2>2050  static AssertionResult Compare(const char *lhx, const char *rhx,2051                                 const T1 &lhs, const T2 &rhs);2052};2053 2054#define GTEST_IMPL_CMP_HELPER_(op_name)                                        \2055  template <typename T1, typename T2>                                          \2056  AssertionResult CmpHelper##op_name(const char *expr1, const char *expr2,     \2057                                     const T1 &val1, const T2 &val2);2058 2059GTEST_IMPL_CMP_HELPER_(NE)2060GTEST_IMPL_CMP_HELPER_(LE)2061GTEST_IMPL_CMP_HELPER_(LT)2062GTEST_IMPL_CMP_HELPER_(GE)2063GTEST_IMPL_CMP_HELPER_(GT)2064 2065#undef GTEST_IMPL_CMP_HELPER_2066 2067std::string GetBoolAssertionFailureMessage(2068    const AssertionResult &assertion_result, const char *expression_text,2069    const char *actual_predicate_value, const char *expected_predicate_value);2070 2071template <typename M> class PredicateFormatterFromMatcher {2072public:2073  template <typename T>2074  AssertionResult operator()(const char *value_text, const T &x) const;2075};2076 2077template <typename M>2078inline PredicateFormatterFromMatcher<M>2079MakePredicateFormatterFromMatcher(M matcher) {2080  return PredicateFormatterFromMatcher<M>();2081}2082} // namespace internal2083 2084namespace status {2085namespace internal_status {2086class IsOkMatcher {};2087 2088class StatusIsMatcher {};2089 2090class CanonicalStatusIsMatcher {};2091 2092template <typename M> class IsOkAndHoldsMatcher {};2093 2094} // namespace internal_status2095 2096internal_status::IsOkMatcher IsOk();2097 2098template <typename StatusCodeMatcher>2099internal_status::StatusIsMatcher StatusIs(StatusCodeMatcher &&code_matcher);2100 2101template <typename StatusCodeMatcher>2102internal_status::CanonicalStatusIsMatcher2103CanonicalStatusIs(StatusCodeMatcher &&code_matcher);2104 2105template <typename InnerMatcher>2106internal_status::IsOkAndHoldsMatcher<InnerMatcher> IsOkAndHolds(InnerMatcher m);2107} // namespace status2108 2109class IsTrueMatcher {};2110IsTrueMatcher IsTrue();2111 2112class IsFalseMatcher {};2113IsFalseMatcher IsFalse();2114 2115} // namespace testing2116 2117namespace absl_testing {2118namespace status_internal {2119class IsOkMatcher {};2120template <typename M> class IsOkAndHoldsMatcher {};2121class StatusIsMatcher {};2122class CanonicalStatusIsMatcher {};2123} // namespace status_internal2124status_internal::IsOkMatcher IsOk();2125template <typename InnerMatcher>2126status_internal::IsOkAndHoldsMatcher<InnerMatcher> IsOkAndHolds(InnerMatcher m);2127template <typename StatusCodeMatcher>2128status_internal::StatusIsMatcher StatusIs(StatusCodeMatcher &&code_matcher);2129 2130template <typename StatusCodeMatcher>2131status_internal::CanonicalStatusIsMatcher2132CanonicalStatusIs(StatusCodeMatcher &&code_matcher);2133} // namespace absl_testing2134 2135using testing::AssertionResult;2136#define EXPECT_TRUE(x)                                                         \2137  switch (0)                                                                   \2138  case 0:                                                                      \2139  default:                                                                     \2140    if (const AssertionResult gtest_ar_ = AssertionResult(x)) {                \2141    } else /* NOLINT */                                                        \2142      ::testing::Message()2143#define EXPECT_FALSE(x) EXPECT_TRUE(!(x))2144 2145#define GTEST_AMBIGUOUS_ELSE_BLOCKER_                                          \2146  switch (0)                                                                   \2147  case 0:                                                                      \2148  default:2149 2150#define GTEST_ASSERT_(expression, on_failure)                                  \2151  GTEST_AMBIGUOUS_ELSE_BLOCKER_                                                \2152  if (const ::testing::AssertionResult gtest_ar = (expression))                \2153    ;                                                                          \2154  else                                                                         \2155    on_failure(gtest_ar.failure_message())2156#define GTEST_PRED_FORMAT1_(pred_format, v1, on_failure)                       \2157  GTEST_ASSERT_(pred_format(#v1, v1), on_failure)2158#define GTEST_PRED_FORMAT2_(pred_format, v1, v2, on_failure)                   \2159  GTEST_ASSERT_(pred_format(#v1, #v2, v1, v2), on_failure)2160#define GTEST_MESSAGE_AT_(file, line, message, result_type)                    \2161  ::testing::internal::AssertHelper(result_type, file, line, message) =        \2162      ::testing::Message()2163#define GTEST_MESSAGE_(message, result_type)                                   \2164  GTEST_MESSAGE_AT_(__FILE__, __LINE__, message, result_type)2165#define GTEST_FATAL_FAILURE_(message)                                          \2166  return GTEST_MESSAGE_(message, ::testing::TestPartResult::kFatalFailure)2167#define GTEST_NONFATAL_FAILURE_(message)                                       \2168  GTEST_MESSAGE_(message, ::testing::TestPartResult::kNonFatalFailure)2169 2170#define ASSERT_PRED_FORMAT1(pred_format, v1)                                   \2171  GTEST_PRED_FORMAT1_(pred_format, v1, GTEST_FATAL_FAILURE_)2172#define ASSERT_PRED_FORMAT2(pred_format, v1, v2)                               \2173  GTEST_PRED_FORMAT2_(pred_format, v1, v2, GTEST_FATAL_FAILURE_)2174 2175#define ASSERT_THAT(value, matcher)                                            \2176  ASSERT_PRED_FORMAT1(                                                         \2177      ::testing::internal::MakePredicateFormatterFromMatcher(matcher), value)2178#define ASSERT_OK(x) ASSERT_THAT(x, ::testing::status::IsOk())2179 2180#define EXPECT_PRED_FORMAT1(pred_format, v1)                                   \2181  GTEST_PRED_FORMAT1_(pred_format, v1, GTEST_NONFATAL_FAILURE_)2182#define EXPECT_PRED_FORMAT2(pred_format, v1, v2)                               \2183  GTEST_PRED_FORMAT2_(pred_format, v1, v2, GTEST_NONFATAL_FAILURE_)2184#define EXPECT_THAT(value, matcher)                                            \2185  EXPECT_PRED_FORMAT1(                                                         \2186      ::testing::internal::MakePredicateFormatterFromMatcher(matcher), value)2187#define EXPECT_OK(expression) EXPECT_THAT(expression, ::testing::status::IsOk())2188 2189#define GTEST_TEST_BOOLEAN_(expression, text, actual, expected, fail)          \2190  GTEST_AMBIGUOUS_ELSE_BLOCKER_                                                \2191  if (const ::testing::AssertionResult gtest_ar_ =                             \2192          ::testing::AssertionResult(expression))                              \2193    ;                                                                          \2194  else                                                                         \2195    fail(::testing::internal::GetBoolAssertionFailureMessage(                  \2196             gtest_ar_, text, #actual, #expected)                              \2197             .c_str())2198#define GTEST_ASSERT_TRUE(condition)                                           \2199  GTEST_TEST_BOOLEAN_(condition, #condition, false, true, GTEST_FATAL_FAILURE_)2200#define GTEST_ASSERT_FALSE(condition)                                          \2201  GTEST_TEST_BOOLEAN_(!(condition), #condition, true, false,                   \2202                      GTEST_FATAL_FAILURE_)2203#define ASSERT_TRUE(condition) GTEST_ASSERT_TRUE(condition)2204#define ASSERT_FALSE(condition) GTEST_ASSERT_FALSE(condition)2205 2206#define EXPECT_EQ(x, y)                                                        \2207  EXPECT_PRED_FORMAT2(::testing::internal::EqHelper::Compare, x, y)2208#define EXPECT_NE(x, y)                                                        \2209  EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperNE, x, y)2210#define EXPECT_LT(x, y)                                                        \2211  EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperLT, x, y)2212#define EXPECT_GT(x, y)                                                        \2213  EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperGT, x, y)2214#define EXPECT_LE(x, y)                                                        \2215  EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperLE, x, y)2216#define EXPECT_GE(x, y)                                                        \2217  EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperGE, x, y)2218 2219#define ASSERT_EQ(x, y)                                                        \2220  ASSERT_PRED_FORMAT2(testing::internal::EqHelper::Compare, x, y)2221#define ASSERT_NE(x, y)                                                        \2222  ASSERT_PRED_FORMAT2(testing::internal::CmpHelperNE, x, y)2223#define ASSERT_LT(x, y)                                                        \2224  ASSERT_PRED_FORMAT2(testing::internal::CmpHelperLT, x, y)2225#define ASSERT_GT(x, y)                                                        \2226  ASSERT_PRED_FORMAT2(testing::internal::CmpHelperGT, x, y)2227#define ASSERT_LE(x, y)                                                        \2228  ASSERT_PRED_FORMAT2(testing::internal::CmpHelperLE, x, y)2229#define ASSERT_GE(x, y)                                                        \2230  ASSERT_PRED_FORMAT2(testing::internal::CmpHelperGE, x, y)2231 2232#endif // TESTING_DEFS_H2233)cc";2234 2235std::vector<std::pair<std::string, std::string>> getMockHeaders() {2236  std::vector<std::pair<std::string, std::string>> Headers;2237  Headers.emplace_back("cstddef.h", CStdDefHeader);2238  Headers.emplace_back("std_initializer_list.h", StdInitializerListHeader);2239  Headers.emplace_back("std_string.h", StdStringHeader);2240  Headers.emplace_back("std_type_traits.h", StdTypeTraitsHeader);2241  Headers.emplace_back("std_utility.h", StdUtilityHeader);2242  Headers.emplace_back("std_optional.h", StdOptionalHeader);2243  Headers.emplace_back("absl_type_traits.h", AbslTypeTraitsHeader);2244  Headers.emplace_back("absl_optional.h", AbslOptionalHeader);2245  Headers.emplace_back("base_optional.h", BaseOptionalHeader);2246  Headers.emplace_back("std_vector.h", StdVectorHeader);2247  Headers.emplace_back("std_pair.h", StdPairHeader);2248  Headers.emplace_back("status_defs.h", StatusDefsHeader);2249  Headers.emplace_back("statusor_defs.h", StatusOrDefsHeader);2250  Headers.emplace_back("absl_log.h", AbslLogHeader);2251  Headers.emplace_back("testing_defs.h", TestingDefsHeader);2252  return Headers;2253}2254 2255} // namespace test2256} // namespace dataflow2257} // namespace clang