Skip to content

Commit

Permalink
Update LLVM namespace (#89)
Browse files Browse the repository at this point in the history
  • Loading branch information
mariusz-sikora-at-amd authored Apr 3, 2024
1 parent e6cbcfd commit 55e176f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
21 changes: 14 additions & 7 deletions include/llvm-dialects/TableGen/Format.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@

namespace llvm_dialects {

namespace llvm_support_detail =
#if !defined(LLVM_MAIN_REVISION) || LLVM_MAIN_REVISION >= 494496
llvm::support::detail;
#else
llvm::detail;
#endif

/// Format context containing substitutions for special placeholders.
///
/// This context divides special placeholders into two categories: builtin ones
Expand Down Expand Up @@ -185,14 +192,14 @@ class FmtObjectBase {
// std::vector<Base*>.
struct CreateAdapters {
template <typename... Ts>
std::vector<llvm::detail::format_adapter *> operator()(Ts &...items) {
return std::vector<llvm::detail::format_adapter *>{&items...};
std::vector<llvm_support_detail::format_adapter *> operator()(Ts &...items) {
return std::vector<llvm_support_detail::format_adapter *>{&items...};
}
};

llvm::StringRef fmt;
const FmtContext *context;
std::vector<llvm::detail::format_adapter *> adapters;
std::vector<llvm_support_detail::format_adapter *> adapters;
std::vector<FmtReplacement> replacements;

public:
Expand Down Expand Up @@ -253,7 +260,7 @@ template <typename Tuple> class FmtObject : public FmtObjectBase {
class FmtStrVecObject : public FmtObjectBase {
public:
using StrFormatAdapter =
decltype(llvm::detail::build_format_adapter(std::declval<std::string>()));
decltype(llvm_support_detail::build_format_adapter(std::declval<std::string>()));

FmtStrVecObject(llvm::StringRef fmt, const FmtContext *ctx,
llvm::ArrayRef<std::string> params);
Expand Down Expand Up @@ -313,13 +320,13 @@ class FmtStrVecObject : public FmtObjectBase {
template <typename... Ts>
inline auto tgfmt(llvm::StringRef fmt, const FmtContext *ctx, Ts &&...vals)
-> FmtObject<decltype(std::make_tuple(
llvm::detail::build_format_adapter(std::forward<Ts>(vals))...))> {
llvm_support_detail::build_format_adapter(std::forward<Ts>(vals))...))> {
using ParamTuple = decltype(std::make_tuple(
llvm::detail::build_format_adapter(std::forward<Ts>(vals))...));
llvm_support_detail::build_format_adapter(std::forward<Ts>(vals))...));
return FmtObject<ParamTuple>(
fmt, ctx,
std::make_tuple(
llvm::detail::build_format_adapter(std::forward<Ts>(vals))...));
llvm_support_detail::build_format_adapter(std::forward<Ts>(vals))...));
}

inline FmtStrVecObject tgfmt(llvm::StringRef fmt, const FmtContext *ctx,
Expand Down
4 changes: 2 additions & 2 deletions lib/TableGen/Format.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ void FmtObjectBase::format(raw_ostream &s) const {
s << repl.spec << kMarkerForNoSubst;
continue;
}
auto range = ArrayRef<llvm::detail::format_adapter *>(adapters);
auto range = ArrayRef<llvm_support_detail::format_adapter *>(adapters);
range = range.drop_front(repl.index);
llvm::interleaveComma(range, s,
[&](auto &x) { x->format(s, /*Options=*/""); });
Expand Down Expand Up @@ -254,7 +254,7 @@ FmtStrVecObject::FmtStrVecObject(StringRef fmt, const FmtContext *ctx,
: FmtObjectBase(fmt, ctx, params.size()) {
parameters.reserve(params.size());
for (std::string p : params)
parameters.push_back(llvm::detail::build_format_adapter(std::move(p)));
parameters.push_back(llvm_support_detail::build_format_adapter(std::move(p)));

adapters.reserve(parameters.size());
for (auto &p : parameters)
Expand Down

0 comments on commit 55e176f

Please sign in to comment.