[AsmParser] Expose an API to parse a string starting with a type.

Without actually parsing a type it is difficult to perdict where
the type definition ends. In other words, instead of expecting
the user of the parser API to hand over only the relevant bits
of the string being parsed, take the whole string, parse the type,
and get back the number of characters that have been read.

This will be used by the MIR testing infrastructure.

llvm-svn: 262884
diff --git a/llvm/lib/AsmParser/LLParser.cpp b/llvm/lib/AsmParser/LLParser.cpp
index 9b9054d..0da81e42 100644
--- a/llvm/lib/AsmParser/LLParser.cpp
+++ b/llvm/lib/AsmParser/LLParser.cpp
@@ -63,15 +63,19 @@
   return false;
 }
 
-bool LLParser::parseStandaloneType(Type *&Ty, const SlotMapping *Slots) {
+bool LLParser::parseTypeAtBeginning(Type *&Ty, unsigned &Read,
+                                    const SlotMapping *Slots) {
   restoreParsingState(Slots);
   Lex.Lex();
 
+  Read = 0;
+  SMLoc Start = Lex.getLoc();
   Ty = nullptr;
   if (ParseType(Ty))
     return true;
-  if (Lex.getKind() != lltok::Eof)
-    return Error(Lex.getLoc(), "expected end of string");
+  SMLoc End = Lex.getLoc();
+  Read = End.getPointer() - Start.getPointer();
+
   return false;
 }