aboutsummaryrefslogtreecommitdiff
path: root/utils/TableGen/StringMatcher.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-10-30 19:57:17 +0000
committerChris Lattner <sabre@nondot.org>2010-10-30 19:57:17 +0000
commitd7e409da6db6e1d2d9e44dd8de5303c5cfd5bd29 (patch)
tree8c2efb2d54d3f190544004915272519ea64254a1 /utils/TableGen/StringMatcher.cpp
parent8cf8bcc40c977713e51fb85fb9f24a0ecfbde24b (diff)
fix a fixme in stringmatcher, having it generate nice looking code if the
'tomatch' code contains \n's. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@117843 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils/TableGen/StringMatcher.cpp')
-rw-r--r--utils/TableGen/StringMatcher.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/utils/TableGen/StringMatcher.cpp b/utils/TableGen/StringMatcher.cpp
index 1c43b6d1c8..6aedcbf458 100644
--- a/utils/TableGen/StringMatcher.cpp
+++ b/utils/TableGen/StringMatcher.cpp
@@ -51,9 +51,18 @@ EmitStringMatcherForChar(const std::vector<const StringPair*> &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<StringRef, StringRef> 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;
}