[llvm-branch-commits] [llvm-branch] r119207 - /llvm/branches/Apple/whitney/utils/TableGen/StringMatcher.cpp

Daniel Dunbar daniel at zuster.org
Mon Nov 15 13:43:38 PST 2010


Author: ddunbar
Date: Mon Nov 15 15:43:38 2010
New Revision: 119207

URL: http://llvm.org/viewvc/llvm-project?rev=119207&view=rev
Log:
Merge r117843:
--
Author: Chris Lattner <clattner at apple.com>
Date:   Sat Oct 30 19:57:17 2010 +0000

    fix a fixme in stringmatcher, having it generate nice looking code if the
    'tomatch' code contains \n's.

Modified:
    llvm/branches/Apple/whitney/utils/TableGen/StringMatcher.cpp

Modified: llvm/branches/Apple/whitney/utils/TableGen/StringMatcher.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/whitney/utils/TableGen/StringMatcher.cpp?rev=119207&r1=119206&r2=119207&view=diff
==============================================================================
--- llvm/branches/Apple/whitney/utils/TableGen/StringMatcher.cpp (original)
+++ llvm/branches/Apple/whitney/utils/TableGen/StringMatcher.cpp Mon Nov 15 15:43:38 2010
@@ -51,9 +51,18 @@
   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;
   }
   





More information about the llvm-branch-commits mailing list