diff --git a/llvm/include/llvm/Support/Automaton.h b/llvm/include/llvm/Support/Automaton.h index 7c13a698e4922e..c2b921311a8ceb 100644 --- a/llvm/include/llvm/Support/Automaton.h +++ b/llvm/include/llvm/Support/Automaton.h @@ -117,6 +117,10 @@ class NfaTranscriber { reset(); } + ArrayRef getTransitionInfo() const { + return TransitionInfo; + } + void reset() { Paths.clear(); Heads.clear(); @@ -198,7 +202,13 @@ template class Automaton { M->emplace(std::make_pair(I.FromDfaState, I.Action), std::make_pair(I.ToDfaState, I.InfoIdx)); } - Automaton(const Automaton &) = default; + Automaton(const Automaton &Other) + : M(Other.M), State(Other.State), Transcribe(Other.Transcribe) { + // Transcriber is not thread-safe, so create a new instance on copy. + if (Other.Transcriber) + Transcriber = std::make_shared( + Other.Transcriber->getTransitionInfo()); + } /// Reset the automaton to its initial state. void reset() {