From 0817a9a621be59649992b3e0057117605bb475fe Mon Sep 17 00:00:00 2001 From: David Greene Date: Mon, 21 Dec 2009 21:21:34 +0000 Subject: Fix a bug in !subst where TableGen would go and resubstitute text it had just substituted. This could cause infinite looping in certain pathological cases. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91843 91177308-0d34-0410-b5e6-96231b3b80d8 --- utils/TableGen/Record.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'utils/TableGen/Record.cpp') diff --git a/utils/TableGen/Record.cpp b/utils/TableGen/Record.cpp index 53f9014..542735e 100644 --- a/utils/TableGen/Record.cpp +++ b/utils/TableGen/Record.cpp @@ -945,11 +945,13 @@ Init *TernOpInit::Fold(Record *CurRec, MultiClass *CurMultiClass) { std::string Val = RHSs->getValue(); std::string::size_type found; + std::string::size_type idx = 0; do { - found = Val.find(LHSs->getValue()); + found = Val.find(LHSs->getValue(), idx); if (found != std::string::npos) { Val.replace(found, LHSs->getValue().size(), MHSs->getValue()); } + idx = found + MHSs->getValue().size(); } while (found != std::string::npos); return new StringInit(Val); -- cgit v1.1