diff options
author | Chris Lattner <sabre@nondot.org> | 2010-09-06 03:50:59 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2010-09-06 03:50:59 +0000 |
commit | 96fe532c6789810e9ec3753c601847cfec643f30 (patch) | |
tree | b03ef683ca4ce0299c27a6f1ad0347fc1c65ce73 /llvm/utils/TableGen/StringMatcher.cpp | |
parent | 497d13e82b3ebd8b2715308cd908a37ee756d202 (diff) | |
download | bcm5719-llvm-96fe532c6789810e9ec3753c601847cfec643f30.tar.gz bcm5719-llvm-96fe532c6789810e9ec3753c601847cfec643f30.zip |
allow specifying an indentation level for the string matcher.
llvm-svn: 113143
Diffstat (limited to 'llvm/utils/TableGen/StringMatcher.cpp')
-rw-r--r-- | llvm/utils/TableGen/StringMatcher.cpp | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/llvm/utils/TableGen/StringMatcher.cpp b/llvm/utils/TableGen/StringMatcher.cpp index f9b5924069c..68fbe7fcf31 100644 --- a/llvm/utils/TableGen/StringMatcher.cpp +++ b/llvm/utils/TableGen/StringMatcher.cpp @@ -112,7 +112,10 @@ EmitStringMatcherForChar(const std::vector<const StringPair*> &Matches, /// Emit - Top level entry point. /// -void StringMatcher::Emit() const { +void StringMatcher::Emit(unsigned Indent) const { + // If nothing to match, just fall through. + if (Matches.empty()) return; + // First level categorization: group strings by length. std::map<unsigned, std::vector<const StringPair*> > MatchesByLength; @@ -121,16 +124,17 @@ void StringMatcher::Emit() const { // Output a switch statement on length and categorize the elements within each // bin. - OS << " switch (" << StrVariableName << ".size()) {\n"; - OS << " default: break;\n"; + OS.indent(Indent*2+2) << "switch (" << StrVariableName << ".size()) {\n"; + OS.indent(Indent*2+2) << "default: break;\n"; for (std::map<unsigned, std::vector<const StringPair*> >::iterator LI = MatchesByLength.begin(), E = MatchesByLength.end(); LI != E; ++LI) { - OS << " case " << LI->first << ":\t // " << LI->second.size() + OS.indent(Indent*2+2) << "case " << LI->first << ":\t // " + << LI->second.size() << " string" << (LI->second.size() == 1 ? "" : "s") << " to match.\n"; - if (EmitStringMatcherForChar(LI->second, 0, 0)) - OS << " break;\n"; + if (EmitStringMatcherForChar(LI->second, 0, Indent)) + OS.indent(Indent*2+4) << "break;\n"; } - OS << " }\n"; + OS.indent(Indent*2+2) << "}\n"; } |