[TableGen] Fix a bug that caused the wrong name for a record built from a multiclass...
[oota-llvm.git] / lib / TableGen / StringMatcher.cpp
index 0ce626d4b19ea2f4102b34a7a095adce6dad2ccd..16681702d1d66cd9da597a813a8fe9508801d5ca 100644 (file)
@@ -87,11 +87,11 @@ EmitStringMatcherForChar(const std::vector<const StringPair*> &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 memcmp(Str.data()+1, "foo", 3).
       // FIXME: Need to escape general strings.
-      OS << Indent << "if (" << StrVariableName << ".substr(" << CharNo << ", "
-      << NumChars << ") != \"";
-      OS << Matches[0]->first.substr(CharNo, NumChars) << "\")\n";
+      OS << Indent << "if (memcmp(" << StrVariableName << ".data()+" << CharNo
+         << ", \"" << Matches[0]->first.substr(CharNo, NumChars) << "\", "
+         << NumChars << "))\n";
       OS << Indent << "  break;\n";
     }