From ee573189c653c3261102ccd627bb571ab7535034 Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Thu, 6 Oct 2011 18:53:43 +0000 Subject: [PATCH] Use StringSwitch. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141305 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/TableGen/TGLexer.cpp | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/lib/TableGen/TGLexer.cpp b/lib/TableGen/TGLexer.cpp index 55bf522366e..5a6c8aa8a5b 100644 --- a/lib/TableGen/TGLexer.cpp +++ b/lib/TableGen/TGLexer.cpp @@ -217,30 +217,32 @@ tgtok::TokKind TGLexer::LexIdentifier() { // Check to see if this identifier is a keyword. StringRef Str(IdentStart, CurPtr-IdentStart); - if (Str == "int") return tgtok::Int; - if (Str == "bit") return tgtok::Bit; - if (Str == "bits") return tgtok::Bits; - if (Str == "string") return tgtok::String; - if (Str == "list") return tgtok::List; - if (Str == "code") return tgtok::Code; - if (Str == "dag") return tgtok::Dag; - - if (Str == "class") return tgtok::Class; - if (Str == "def") return tgtok::Def; - if (Str == "multidef") return tgtok::MultiDef; - if (Str == "defm") return tgtok::Defm; - if (Str == "multiclass") return tgtok::MultiClass; - if (Str == "field") return tgtok::Field; - if (Str == "let") return tgtok::Let; - if (Str == "in") return tgtok::In; - if (Str == "include") { if (LexInclude()) return tgtok::Error; return Lex(); } - CurStrVal.assign(Str.begin(), Str.end()); - return tgtok::Id; + tgtok::TokKind Kind = StringSwitch(Str) + .Case("int", tgtok::Int) + .Case("bit", tgtok::Bit) + .Case("bits", tgtok::Bits) + .Case("string", tgtok::String) + .Case("list", tgtok::List) + .Case("code", tgtok::Code) + .Case("dag", tgtok::Dag) + .Case("class", tgtok::Class) + .Case("def", tgtok::Def) + .Case("multidef", tgtok::MultiDef) + .Case("defm", tgtok::Defm) + .Case("multiclass", tgtok::MultiClass) + .Case("field", tgtok::Field) + .Case("let", tgtok::Let) + .Case("in", tgtok::In) + .Default(tgtok::Id); + + if (Kind == tgtok::Id) + CurStrVal.assign(Str.begin(), Str.end()); + return Kind; } /// LexInclude - We just read the "include" token. Get the string token that