@@ -187,6 +187,16 @@ class FmtObjectBase {
187187 // indexing capabilities. In order to enable runtime indexing, we use this
188188 // structure to put the parameters into a std::vector. Since the parameters
189189 // are not all the same type, we use some type-erasure by wrapping the
190+ #if !LLVM_MAIN_REVISION || LLVM_MAIN_REVISION >= 586890
191+ // parameters in a template class and refer to them using function_refs.
192+ struct CreateAdapters {
193+ template <typename ... Ts>
194+ std::vector<llvm::support::detail::FormatFunctorRef>
195+ operator ()(Ts &... items) {
196+ return std::vector<llvm::support::detail::FormatFunctorRef>{items...};
197+ }
198+ };
199+ #else // !LLVM_MAIN_REVISION || LLVM_MAIN_REVISION >= 586890
190200 // parameters in a template class that derives from a non-template superclass.
191201 // Essentially, we are converting a std::tuple<Derived<Ts...>> to a
192202 // std::vector<Base*>.
@@ -197,10 +207,15 @@ class FmtObjectBase {
197207 return std::vector<llvm::support::detail::format_adapter *>{&items...};
198208 }
199209 };
210+ #endif // LLVM_MAIN_REVISION
200211
201212 llvm::StringRef fmt;
202213 const FmtContext *context;
214+ #if !LLVM_MAIN_REVISION || LLVM_MAIN_REVISION >= 586890
215+ std::vector<llvm::support::detail::FormatFunctorRef> adapters;
216+ #else // !LLVM_MAIN_REVISION || LLVM_MAIN_REVISION >= 586890
203217 std::vector<llvm::support::detail::format_adapter *> adapters;
218+ #endif // LLVM_MAIN_REVISION
204219 std::vector<FmtReplacement> replacements;
205220
206221public:
@@ -260,8 +275,13 @@ template <typename Tuple> class FmtObject : public FmtObjectBase {
260275
261276class FmtStrVecObject : public FmtObjectBase {
262277public:
278+ #if !LLVM_MAIN_REVISION || LLVM_MAIN_REVISION >= 586890
279+ using StrFormatAdapter = decltype (
280+ llvm::support::detail::FormatFunctor (std::declval<std::string>()));
281+ #else // !LLVM_MAIN_REVISION || LLVM_MAIN_REVISION >= 586890
263282 using StrFormatAdapter = decltype (
264283 llvm::support::detail::build_format_adapter (std::declval<std::string>()));
284+ #endif // LLVM_MAIN_REVISION
265285
266286 FmtStrVecObject (llvm::StringRef fmt, const FmtContext *ctx,
267287 llvm::ArrayRef<std::string> params);
@@ -318,6 +338,20 @@ class FmtStrVecObject : public FmtObjectBase {
318338// / because '{' and '}' are frequently used in C++ code.
319339// / 2. This utility does not support format layout because it is rarely needed
320340// / in C++ code generation.
341+ #if !LLVM_MAIN_REVISION || LLVM_MAIN_REVISION >= 586890
342+ template <typename ... Ts>
343+ inline auto tgfmt (llvm::StringRef fmt, const FmtContext *ctx, Ts &&... vals)
344+ -> FmtObject<
345+ decltype(std::make_tuple(llvm::support::detail::FormatFunctor(
346+ std::forward<Ts>(vals))...))> {
347+ using ParamTuple = decltype (std::make_tuple (
348+ llvm::support::detail::FormatFunctor (std::forward<Ts>(vals))...));
349+ return FmtObject<ParamTuple>(
350+ fmt, ctx,
351+ std::make_tuple (llvm::support::detail::FormatFunctor (
352+ std::forward<Ts>(vals))...));
353+ }
354+ #else // !LLVM_MAIN_REVISION || LLVM_MAIN_REVISION >= 586890
321355template <typename ... Ts>
322356inline auto tgfmt (llvm::StringRef fmt, const FmtContext *ctx, Ts &&... vals)
323357 -> FmtObject<
@@ -330,6 +364,7 @@ inline auto tgfmt(llvm::StringRef fmt, const FmtContext *ctx, Ts &&... vals)
330364 std::make_tuple (llvm::support::detail::build_format_adapter (
331365 std::forward<Ts>(vals))...));
332366}
367+ #endif // LLVM_MAIN_REVISION
333368
334369inline FmtStrVecObject tgfmt (llvm::StringRef fmt, const FmtContext *ctx,
335370 llvm::ArrayRef<std::string> params) {
0 commit comments