diff options
Diffstat (limited to 'llvm/utils/TableGen/DFAEmitter.cpp')
-rw-r--r-- | llvm/utils/TableGen/DFAEmitter.cpp | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/llvm/utils/TableGen/DFAEmitter.cpp b/llvm/utils/TableGen/DFAEmitter.cpp index dd3db7c150ba6..7391f6845a4b2 100644 --- a/llvm/utils/TableGen/DFAEmitter.cpp +++ b/llvm/utils/TableGen/DFAEmitter.cpp @@ -53,14 +53,14 @@ void DfaEmitter::addTransition(state_type From, state_type To, action_type A) { ++NumNfaTransitions; } -void DfaEmitter::visitDfaState(DfaState DS) { +void DfaEmitter::visitDfaState(const DfaState &DS) { // For every possible action... auto FromId = DfaStates.idFor(DS); for (action_type A : Actions) { DfaState NewStates; DfaTransitionInfo TI; // For every represented state, word pair in the original NFA... - for (state_type &FromState : DS) { + for (state_type FromState : DS) { // If this action is possible from this state add the transitioned-to // states to NewStates. auto I = NfaTransitions.find({FromState, A}); @@ -90,8 +90,11 @@ void DfaEmitter::constructDfa() { // Note that UniqueVector starts indices at 1, not zero. unsigned DfaStateId = 1; - while (DfaStateId <= DfaStates.size()) - visitDfaState(DfaStates[DfaStateId++]); + while (DfaStateId <= DfaStates.size()) { + DfaState S = DfaStates[DfaStateId]; + visitDfaState(S); + DfaStateId++; + } } void DfaEmitter::emit(StringRef Name, raw_ostream &OS) { @@ -119,7 +122,7 @@ void DfaEmitter::emit(StringRef Name, raw_ostream &OS) { for (auto &T : DfaTransitions) Table.add(T.second.second); Table.layout(); - OS << "std::array<NfaStatePair, " << Table.size() << "> " << Name + OS << "const std::array<NfaStatePair, " << Table.size() << "> " << Name << "TransitionInfo = {{\n"; Table.emit( OS, @@ -143,8 +146,8 @@ void DfaEmitter::emit(StringRef Name, raw_ostream &OS) { OS << "// A table of DFA transitions, ordered by {FromDfaState, Action}.\n"; OS << "// The initial state is 1, not zero.\n"; - OS << "std::array<" << Name << "Transition, " << DfaTransitions.size() << "> " - << Name << "Transitions = {{\n"; + OS << "const std::array<" << Name << "Transition, " + << DfaTransitions.size() << "> " << Name << "Transitions = {{\n"; for (auto &KV : DfaTransitions) { dfa_state_type From = KV.first.first; dfa_state_type To = KV.second.first; @@ -345,7 +348,7 @@ Transition::Transition(Record *R, Automaton *Parent) { Types.emplace_back("unsigned"); } else if (isa<StringRecTy>(SymbolV->getType()) || isa<CodeRecTy>(SymbolV->getType())) { - Actions.emplace_back(nullptr, 0, R->getValueAsString(A)); + Actions.emplace_back(nullptr, 0, std::string(R->getValueAsString(A))); Types.emplace_back("std::string"); } else { report_fatal_error("Unhandled symbol type!"); @@ -353,7 +356,7 @@ Transition::Transition(Record *R, Automaton *Parent) { StringRef TypeOverride = Parent->getActionSymbolType(A); if (!TypeOverride.empty()) - Types.back() = TypeOverride; + Types.back() = std::string(TypeOverride); } } |