diff options
author | Quentin Colombet <qcolombet@apple.com> | 2016-03-08 00:37:07 +0000 |
---|---|---|
committer | Quentin Colombet <qcolombet@apple.com> | 2016-03-08 00:37:07 +0000 |
commit | dafed5d7d82613ca153c1bee70addb17d6d20c3a (patch) | |
tree | 55eff0c029daa02615e5e18769ebe0bcf26f990c /llvm/lib/AsmParser/LLParser.cpp | |
parent | b1bd398ceb5bead0251ec0f40ba5db0177e4a2df (diff) | |
download | bcm5719-llvm-dafed5d7d82613ca153c1bee70addb17d6d20c3a.tar.gz bcm5719-llvm-dafed5d7d82613ca153c1bee70addb17d6d20c3a.zip |
[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
Diffstat (limited to 'llvm/lib/AsmParser/LLParser.cpp')
-rw-r--r-- | llvm/lib/AsmParser/LLParser.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/llvm/lib/AsmParser/LLParser.cpp b/llvm/lib/AsmParser/LLParser.cpp index 9b9054dbaed..0da81e42c68 100644 --- a/llvm/lib/AsmParser/LLParser.cpp +++ b/llvm/lib/AsmParser/LLParser.cpp @@ -63,15 +63,19 @@ bool LLParser::parseStandaloneConstantValue(Constant *&C, 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; } |