forked from OSchip/llvm-project
[flang] some clean-up
Original-commit: flang-compiler/f18@6134e1c2f2 Reviewed-on: https://github.com/flang-compiler/f18/pull/490 Tree-same-pre-rewrite: false
This commit is contained in:
parent
7269dc8a82
commit
82f119414c
|
@ -149,7 +149,7 @@ public:
|
|||
std::optional<Success> Parse(ParseState &state) const {
|
||||
ParseState forked{state};
|
||||
forked.set_deferMessages(true);
|
||||
if (parser_.Parse(forked).has_value()) {
|
||||
if (parser_.Parse(forked)) {
|
||||
return Success{};
|
||||
}
|
||||
return std::nullopt;
|
||||
|
@ -295,26 +295,24 @@ public:
|
|||
Messages messages{std::move(state.messages())};
|
||||
ParseState backtrack{state};
|
||||
std::optional<resultType> result{std::get<0>(ps_).Parse(state)};
|
||||
if constexpr (sizeof...(Ps) > 0) {
|
||||
if (!result.has_value()) {
|
||||
ParseRest<1>(result, state, backtrack);
|
||||
}
|
||||
}
|
||||
state.messages().Restore(std::move(messages));
|
||||
return result;
|
||||
}
|
||||
|
||||
private:
|
||||
template<int J>
|
||||
void ParseRest(std::optional<resultType> &result, ParseState &state,
|
||||
ParseState &backtrack) const {
|
||||
if constexpr (J <= sizeof...(Ps)) {
|
||||
void ParseRest(std::optional<resultType> &result, ParseState &state, ParseState &backtrack) const {
|
||||
ParseState prevState{std::move(state)};
|
||||
state = backtrack;
|
||||
const auto &parser{std::get<J>(ps_)};
|
||||
static_assert(std::is_same_v<resultType,
|
||||
typename std::decay_t<decltype(parser)>::resultType>);
|
||||
result = parser.Parse(state);
|
||||
result = std::get<J>(ps_).Parse(state);
|
||||
if (!result.has_value()) {
|
||||
state.CombineFailedParses(std::move(prevState));
|
||||
if constexpr (J < sizeof...(Ps)) {
|
||||
ParseRest<J + 1>(result, state, backtrack);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -498,7 +498,7 @@ struct DigitStringIgnoreSpaces {
|
|||
if (overflow) {
|
||||
state.Say(*firstDigit, "overflow in decimal literal"_err_en_US);
|
||||
}
|
||||
return {value};
|
||||
return value;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue