forked from OSchip/llvm-project
[flang] Revert to forwarding on variadic messaging APIs
Original-commit: flang-compiler/f18@d2e464eb15 Reviewed-on: https://github.com/flang-compiler/f18/pull/390 Tree-same-pre-rewrite: false
This commit is contained in:
parent
84f7c4a658
commit
d0e7775431
|
@ -267,7 +267,7 @@ std::optional<std::tuple<A...>> AllPresent(std::optional<A> &&... x) {
|
|||
// N.B. If the function returns std::optional, MapOptional will return
|
||||
// std::optional<std::optional<...>> and you will probably want to
|
||||
// run it through JoinOptional to "squash" it.
|
||||
template<typename R, typename... A, NO_LVALUE_REFERENCE(A)>
|
||||
template<typename R, typename... A>
|
||||
std::optional<R> MapOptional(
|
||||
std::function<R(A &&...)> &&f, std::optional<A> &&... x) {
|
||||
if (auto args{AllPresent(std::move(x)...)}) {
|
||||
|
@ -275,7 +275,7 @@ std::optional<R> MapOptional(
|
|||
}
|
||||
return std::nullopt;
|
||||
}
|
||||
template<typename R, typename... A, NO_LVALUE_REFERENCE(A)>
|
||||
template<typename R, typename... A>
|
||||
std::optional<R> MapOptional(R (*f)(A &&...), std::optional<A> &&... x) {
|
||||
return MapOptional(std::function<R(A && ...)>{f}, std::move(x)...);
|
||||
}
|
||||
|
|
|
@ -151,9 +151,8 @@ public:
|
|||
attachmentIsContext_ = true;
|
||||
}
|
||||
Message &Attach(Message *);
|
||||
template<typename... A, NO_LVALUE_REFERENCE(A)>
|
||||
Message &Attach(A &&... args) {
|
||||
return Attach(new Message{std::move(args)...}); // reference-counted
|
||||
template<typename... A> Message &Attach(A &&... args) {
|
||||
return Attach(new Message{std::forward<A>(args)...}); // reference-counted
|
||||
}
|
||||
|
||||
bool SortBefore(const Message &that) const;
|
||||
|
@ -206,7 +205,7 @@ public:
|
|||
bool empty() const { return messages_.empty(); }
|
||||
|
||||
template<typename... A> Message &Say(A... args) {
|
||||
last_ = messages_.emplace_after(last_, args...);
|
||||
last_ = messages_.emplace_after(last_, std::forward<A>(args)...);
|
||||
return *last_;
|
||||
}
|
||||
|
||||
|
@ -254,17 +253,16 @@ public:
|
|||
return common::ScopedSet(at_, std::move(at));
|
||||
}
|
||||
|
||||
template<typename... A, NO_LVALUE_REFERENCE(A)>
|
||||
Message *Say(CharBlock at, A &&... args) {
|
||||
template<typename... A> Message *Say(CharBlock at, A &&... args) {
|
||||
if (messages_ != nullptr) {
|
||||
return &messages_->Say(at, std::move(args)...);
|
||||
return &messages_->Say(at, std::forward<A>(args)...);
|
||||
} else {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
template<typename... A, NO_LVALUE_REFERENCE(A)> Message *Say(A &&... args) {
|
||||
return Say(at_, std::move(args)...);
|
||||
template<typename... A> Message *Say(A &&... args) {
|
||||
return Say(at_, std::forward<A>(args)...);
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
|
@ -143,18 +143,19 @@ public:
|
|||
context_ = context_->attachment();
|
||||
}
|
||||
|
||||
template<typename... A> void Say(CharBlock range, A... args) {
|
||||
template<typename... A> void Say(CharBlock range, A &&... args) {
|
||||
if (deferMessages_) {
|
||||
anyDeferredMessages_ = true;
|
||||
} else {
|
||||
messages_.Say(range, args...).SetContext(context_.get());
|
||||
messages_.Say(range, std::forward<A>(args)...).SetContext(context_.get());
|
||||
}
|
||||
}
|
||||
template<typename... A> void Say(const MessageFixedText &text, A... args) {
|
||||
Say(p_, text, args...);
|
||||
template<typename... A> void Say(const MessageFixedText &text, A &&... args) {
|
||||
Say(p_, text, std::forward<A>(args)...);
|
||||
}
|
||||
template<typename... A> void Say(const MessageExpectedText &text, A... args) {
|
||||
Say(p_, text, args...);
|
||||
template<typename... A>
|
||||
void Say(const MessageExpectedText &text, A &&... args) {
|
||||
Say(p_, text, std::forward<A>(args)...);
|
||||
}
|
||||
|
||||
void Nonstandard(LanguageFeature lf, const MessageFixedText &msg) {
|
||||
|
|
|
@ -108,7 +108,7 @@ struct GenericExprWrapper; // forward definition, wraps Expr<SomeType>
|
|||
// Many other classes below simply wrap a std::tuple<> structure, which
|
||||
// is conventionally named "t".
|
||||
#define TUPLE_CLASS_BOILERPLATE(classname) \
|
||||
template<typename... Ts, bool = (... && !std::is_lvalue_reference_v<Ts>)> \
|
||||
template<typename... Ts, NO_LVALUE_REFERENCE(Ts)> \
|
||||
classname(Ts &&... args) : t(std::move(args)...) {} \
|
||||
using TupleTrait = std::true_type; \
|
||||
BOILERPLATE(classname)
|
||||
|
|
|
@ -70,8 +70,8 @@ public:
|
|||
TokenSequence TokenizePreprocessorDirective();
|
||||
Provenance GetCurrentProvenance() const { return GetProvenance(at_); }
|
||||
|
||||
template<typename... A> Message &Say(A... a) {
|
||||
Message &m{messages_.Say(a...)};
|
||||
template<typename... A> Message &Say(A &&... a) {
|
||||
Message &m{messages_.Say(std::forward<A>(a)...)};
|
||||
std::optional<ProvenanceRange> range{m.GetProvenanceRange(cooked_)};
|
||||
CHECK(!range.has_value() || cooked_.IsValid(*range));
|
||||
return m;
|
||||
|
|
|
@ -120,8 +120,8 @@ private:
|
|||
|
||||
MaskExpr GetMask(const parser::LogicalExpr &, bool defaultValue = true) const;
|
||||
|
||||
template<typename... A> parser::Message *Say(A... args) {
|
||||
return messages_.Say(args...);
|
||||
template<typename... A> parser::Message *Say(A &&... args) {
|
||||
return messages_.Say(std::forward<A>(args)...);
|
||||
}
|
||||
|
||||
SemanticsContext &context_;
|
||||
|
|
|
@ -80,14 +80,13 @@ public:
|
|||
return GetFoldingContext().messages();
|
||||
}
|
||||
|
||||
template<typename... A, NO_LVALUE_REFERENCE(A)>
|
||||
parser::Message *Say(A &&... args) {
|
||||
return GetContextualMessages().Say(std::move(args)...);
|
||||
template<typename... A> parser::Message *Say(A &&... args) {
|
||||
return GetContextualMessages().Say(std::forward<A>(args)...);
|
||||
}
|
||||
|
||||
template<typename T, typename... A, NO_LVALUE_REFERENCE(A)>
|
||||
template<typename T, typename... A>
|
||||
parser::Message *SayAt(const T &parsed, A &&... args) {
|
||||
return Say(parser::FindSourceLocation(parsed), std::move(args)...);
|
||||
return Say(parser::FindSourceLocation(parsed), std::forward<A>(args)...);
|
||||
}
|
||||
|
||||
int GetDefaultKind(common::TypeCategory);
|
||||
|
|
|
@ -172,12 +172,11 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
template<typename... A, NO_LVALUE_REFERENCE(A)>
|
||||
Message &Say(const parser::Name &name, A &&... args) {
|
||||
return messageHandler_.Say(name.source, std::move(args)...);
|
||||
template<typename... A> Message &Say(const parser::Name &name, A &&... args) {
|
||||
return messageHandler_.Say(name.source, std::forward<A>(args)...);
|
||||
}
|
||||
template<typename... A, NO_LVALUE_REFERENCE(A)> Message &Say(A &&... args) {
|
||||
return messageHandler_.Say(std::move(args)...);
|
||||
template<typename... A> Message &Say(A &&... args) {
|
||||
return messageHandler_.Say(std::forward<A>(args)...);
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
|
@ -83,14 +83,13 @@ public:
|
|||
|
||||
bool AnyFatalError() const;
|
||||
|
||||
template<typename... A, NO_LVALUE_REFERENCE(A)>
|
||||
template<typename... A>
|
||||
parser::Message &Say(const parser::CharBlock &at, A &&... args) {
|
||||
return messages_.Say(at, std::move(args)...);
|
||||
return messages_.Say(at, std::forward<A>(args)...);
|
||||
}
|
||||
template<typename... A, NO_LVALUE_REFERENCE(A)>
|
||||
parser::Message &Say(A &&... args) {
|
||||
template<typename... A> parser::Message &Say(A &&... args) {
|
||||
CHECK(location_);
|
||||
return messages_.Say(*location_, std::move(args)...);
|
||||
return messages_.Say(*location_, std::forward<A>(args)...);
|
||||
}
|
||||
parser::Message &Say(parser::Message &&msg) {
|
||||
return messages_.Say(std::move(msg));
|
||||
|
|
Loading…
Reference in New Issue