From: Hans Wennborg Date: Tue, 25 Feb 2020 14:15:25 +0000 (+0100) Subject: Fix DfaEmitter::visitDfaState() crash in MSVC x86 debug builds (PR44945) X-Git-Tag: llvmorg-12-init~13711 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=edae4be8e21c5deb9a8ffc24a8c17e70b878bf39;p=platform%2Fupstream%2Fllvm.git Fix DfaEmitter::visitDfaState() crash in MSVC x86 debug builds (PR44945) No functionality change (intended), but this seems to make the code a bit clearer for the compiler and maybe for human readers too. --- diff --git a/llvm/utils/TableGen/DFAEmitter.cpp b/llvm/utils/TableGen/DFAEmitter.cpp index 91c8638..7391f68 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) { diff --git a/llvm/utils/TableGen/DFAEmitter.h b/llvm/utils/TableGen/DFAEmitter.h index 76de8f7..f7724ce 100644 --- a/llvm/utils/TableGen/DFAEmitter.h +++ b/llvm/utils/TableGen/DFAEmitter.h @@ -99,7 +99,7 @@ private: void constructDfa(); /// Visit a single DFA state and construct all possible transitions to new DFA /// states. - void visitDfaState(DfaState DS); + void visitDfaState(const DfaState &DS); }; } // namespace llvm