[PATCH] MIR Lexer: adopt the 'maybeLex...' pattern.

Sean Silva chisophugis at gmail.com
Mon Jun 29 18:36:53 PDT 2015


LGTM with a nit.


REPOSITORY
  rL LLVM

================
Comment at: lib/CodeGen/MIRParser/MILexer.cpp:182
@@ -164,16 +181,3 @@
 
-  auto Char = C.peek();
-  if (isalpha(Char) || Char == '_')
-    return lexIdentifier(C, Token).remaining();
-  if (Char == '%') {
-    if (C.remaining().startswith("%bb."))
-      return lexMachineBasicBlock(C, Token, ErrorCallback).remaining();
-    return lexPercent(C, Token).remaining();
-  }
-  if (Char == '@')
-    return lexGlobalValue(C, Token).remaining();
-  if (isdigit(Char) || (Char == '-' && isdigit(C.peek(1))))
-    return lexIntegerLiteral(C, Token).remaining();
-  MIToken::TokenKind Kind = symbolToken(Char);
-  if (Kind != MIToken::Error)
-    return lexSymbol(C, Kind, Token).remaining();
+  if (auto R = maybeLexIdentifier(C, Token))
+    return R.remaining();
----------------
Even though I know this pattern returns a cursor, I found myself looking around to confirm that the `auto` was hiding a cursor. I would prefer to just say `Cursor`.

http://reviews.llvm.org/D10817

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the llvm-commits mailing list