diff options
author | Chris Lattner <sabre@nondot.org> | 2010-10-30 19:57:17 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2010-10-30 19:57:17 +0000 |
commit | 25896af4bbb4171e6a72d7c360258917371c459b (patch) | |
tree | 9d67930801adf43c12021ac478c99d16e4740886 /llvm/utils/TableGen/StringMatcher.cpp | |
parent | d3f0054395e9db8948b1f2024b5dc888bd860864 (diff) | |
download | bcm5719-llvm-25896af4bbb4171e6a72d7c360258917371c459b.tar.gz bcm5719-llvm-25896af4bbb4171e6a72d7c360258917371c459b.zip |
fix a fixme in stringmatcher, having it generate nice looking code if the
'tomatch' code contains \n's.
llvm-svn: 117843
Diffstat (limited to 'llvm/utils/TableGen/StringMatcher.cpp')
-rw-r--r-- | llvm/utils/TableGen/StringMatcher.cpp | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/llvm/utils/TableGen/StringMatcher.cpp b/llvm/utils/TableGen/StringMatcher.cpp index 1c43b6d1c8a..6aedcbf458a 100644 --- a/llvm/utils/TableGen/StringMatcher.cpp +++ b/llvm/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; } |