llvm.org GIT mirror llvm / ee57318
Use StringSwitch. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141305 91177308-0d34-0410-b5e6-96231b3b80d8 Benjamin Kramer 8 years ago
1 changed file(s) with 21 addition(s) and 19 deletion(s). Raw diff Collapse all Expand all
216216 // Check to see if this identifier is a keyword.
217217 StringRef Str(IdentStart, CurPtr-IdentStart);
218218
219 if (Str == "int") return tgtok::Int;
220 if (Str == "bit") return tgtok::Bit;
221 if (Str == "bits") return tgtok::Bits;
222 if (Str == "string") return tgtok::String;
223 if (Str == "list") return tgtok::List;
224 if (Str == "code") return tgtok::Code;
225 if (Str == "dag") return tgtok::Dag;
226
227 if (Str == "class") return tgtok::Class;
228 if (Str == "def") return tgtok::Def;
229 if (Str == "multidef") return tgtok::MultiDef;
230 if (Str == "defm") return tgtok::Defm;
231 if (Str == "multiclass") return tgtok::MultiClass;
232 if (Str == "field") return tgtok::Field;
233 if (Str == "let") return tgtok::Let;
234 if (Str == "in") return tgtok::In;
235
236219 if (Str == "include") {
237220 if (LexInclude()) return tgtok::Error;
238221 return Lex();
239222 }
240223
241 CurStrVal.assign(Str.begin(), Str.end());
242 return tgtok::Id;
224 tgtok::TokKind Kind = StringSwitch(Str)
225 .Case("int", tgtok::Int)
226 .Case("bit", tgtok::Bit)
227 .Case("bits", tgtok::Bits)
228 .Case("string", tgtok::String)
229 .Case("list", tgtok::List)
230 .Case("code", tgtok::Code)
231 .Case("dag", tgtok::Dag)
232 .Case("class", tgtok::Class)
233 .Case("def", tgtok::Def)
234 .Case("multidef", tgtok::MultiDef)
235 .Case("defm", tgtok::Defm)
236 .Case("multiclass", tgtok::MultiClass)
237 .Case("field", tgtok::Field)
238 .Case("let", tgtok::Let)
239 .Case("in", tgtok::In)
240 .Default(tgtok::Id);
241
242 if (Kind == tgtok::Id)
243 CurStrVal.assign(Str.begin(), Str.end());
244 return Kind;
243245 }
244246
245247 /// LexInclude - We just read the "include" token. Get the string token that