X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=utils%2FTableGen%2FStringMatcher.cpp;h=6aedcbf458a86b3fcb6b3828cc4d015047aafa88;hb=db37e4072361bc44f2c0661cb1add90e74012b13;hp=68fbe7fcf31c1ebbbe0d98913d06437e64979e3f;hpb=902edf21668f48a279389bc3a585bcce40487c56;p=oota-llvm.git diff --git a/utils/TableGen/StringMatcher.cpp b/utils/TableGen/StringMatcher.cpp index 68fbe7fcf31..6aedcbf458a 100644 --- a/utils/TableGen/StringMatcher.cpp +++ b/utils/TableGen/StringMatcher.cpp @@ -51,9 +51,18 @@ EmitStringMatcherForChar(const std::vector &Matches, if (CharNo == Matches[0]->first.size()) { assert(Matches.size() == 1 && "Had duplicate keys to match on"); - // FIXME: If Matches[0].first has embeded \n, this will be bad. - OS << Indent << Matches[0]->second << "\t // \"" << Matches[0]->first - << "\"\n"; + // If the to-execute code has \n's in it, indent each subsequent line. + StringRef Code = Matches[0]->second; + + std::pair Split = Code.split('\n'); + OS << Indent << Split.first << "\t // \"" << Matches[0]->first << "\"\n"; + + Code = Split.second; + while (!Code.empty()) { + Split = Code.split('\n'); + OS << Indent << Split.first << "\n"; + Code = Split.second; + } return false; } @@ -78,9 +87,9 @@ EmitStringMatcherForChar(const std::vector &Matches, << Matches[0]->first[CharNo] << "')\n"; OS << Indent << " break;\n"; } else { - // Do the comparison with if (Str.substr(1,3) != "foo"). + // Do the comparison with if (Str.substr(1, 3) != "foo"). // FIXME: Need to escape general strings. - OS << Indent << "if (" << StrVariableName << ".substr(" << CharNo << "," + OS << Indent << "if (" << StrVariableName << ".substr(" << CharNo << ", " << NumChars << ") != \""; OS << Matches[0]->first.substr(CharNo, NumChars) << "\")\n"; OS << Indent << " break;\n";