[llvm] r243449 - MIR Parser: Move the function 'lexName'. NFC.

Alex Lorenz arphaman at gmail.com
Tue Jul 28 10:03:40 PDT 2015


Author: arphaman
Date: Tue Jul 28 12:03:40 2015
New Revision: 243449

URL: http://llvm.org/viewvc/llvm-project?rev=243449&view=rev
Log:
MIR Parser: Move the function 'lexName'. NFC.

This commit moves the function 'lexName' to the start of the file so it can
be reused by the function which will lex the named LLVM IR block references.

Modified:
    llvm/trunk/lib/CodeGen/MIRParser/MILexer.cpp

Modified: llvm/trunk/lib/CodeGen/MIRParser/MILexer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MIRParser/MILexer.cpp?rev=243449&r1=243448&r2=243449&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MIRParser/MILexer.cpp (original)
+++ llvm/trunk/lib/CodeGen/MIRParser/MILexer.cpp Tue Jul 28 12:03:40 2015
@@ -114,6 +114,26 @@ static Cursor lexStringConstant(
   return C;
 }
 
+static Cursor lexName(
+    Cursor C, MIToken &Token, MIToken::TokenKind Type,
+    MIToken::TokenKind QuotedType, unsigned PrefixLength,
+    function_ref<void(StringRef::iterator Loc, const Twine &)> ErrorCallback) {
+  auto Range = C;
+  C.advance(PrefixLength);
+  if (C.peek() == '"') {
+    if (Cursor R = lexStringConstant(C, ErrorCallback)) {
+      Token = MIToken(QuotedType, Range.upto(R), PrefixLength);
+      return R;
+    }
+    Token = MIToken(MIToken::Error, Range.remaining());
+    return Range;
+  }
+  while (isIdentifierChar(C.peek()))
+    C.advance();
+  Token = MIToken(Type, Range.upto(C), PrefixLength);
+  return C;
+}
+
 static MIToken::TokenKind getIdentifierKind(StringRef Identifier) {
   return StringSwitch<MIToken::TokenKind>(Identifier)
       .Case("_", MIToken::underscore)
@@ -248,26 +268,6 @@ static Cursor maybeLexRegister(Cursor C,
   return C;
 }
 
-static Cursor lexName(
-    Cursor C, MIToken &Token, MIToken::TokenKind Type,
-    MIToken::TokenKind QuotedType, unsigned PrefixLength,
-    function_ref<void(StringRef::iterator Loc, const Twine &)> ErrorCallback) {
-  auto Range = C;
-  C.advance(PrefixLength);
-  if (C.peek() == '"') {
-    if (Cursor R = lexStringConstant(C, ErrorCallback)) {
-      Token = MIToken(QuotedType, Range.upto(R), PrefixLength);
-      return R;
-    }
-    Token = MIToken(MIToken::Error, Range.remaining());
-    return Range;
-  }
-  while (isIdentifierChar(C.peek()))
-    C.advance();
-  Token = MIToken(Type, Range.upto(C), PrefixLength);
-  return C;
-}
-
 static Cursor maybeLexGlobalValue(
     Cursor C, MIToken &Token,
     function_ref<void(StringRef::iterator Loc, const Twine &)> ErrorCallback) {





More information about the llvm-commits mailing list