46 uint64_t LLLexer::atoull(
const char *Buffer,
const char *
End) {
48 for (; Buffer !=
End; Buffer++) {
49 uint64_t OldRes = Result;
51 Result += *Buffer-
'0';
52 if (Result < OldRes) {
53 Error(
"constant bigger than 64 bits detected!");
60 uint64_t LLLexer::HexIntToVal(
const char *Buffer,
const char *End) {
62 for (; Buffer !=
End; ++Buffer) {
63 uint64_t OldRes = Result;
67 if (Result < OldRes) {
68 Error(
"constant bigger than 64 bits detected!");
75 void LLLexer::HexToIntPair(
const char *Buffer,
const char *End,
78 if (End - Buffer >= 16) {
79 for (
int i = 0; i < 16; i++, Buffer++) {
86 for (
int i = 0; i < 16 && Buffer !=
End; i++, Buffer++) {
91 Error(
"constant bigger than 128 bits detected!");
96 void LLLexer::FP80HexToIntPair(
const char *Buffer,
const char *End,
99 for (
int i=0; i<4 && Buffer !=
End; i++, Buffer++) {
105 for (
int i = 0; i < 16 && Buffer !=
End; i++, Buffer++) {
110 Error(
"constant bigger than 128 bits detected!");
116 if (Str.empty())
return;
118 char *Buffer = &Str[0], *EndBuffer = Buffer+Str.size();
120 for (
char *BIn = Buffer; BIn != EndBuffer; ) {
121 if (BIn[0] ==
'\\') {
122 if (BIn < EndBuffer-1 && BIn[1] ==
'\\') {
125 }
else if (BIn < EndBuffer-2 &&
126 isxdigit(static_cast<unsigned char>(BIn[1])) &&
127 isxdigit(static_cast<unsigned char>(BIn[2]))) {
138 Str.resize(BOut-Buffer);
143 return isalnum(static_cast<unsigned char>(C)) || C ==
'-' || C ==
'$' ||
144 C ==
'.' || C ==
'_';
150 if (CurPtr[0] ==
':')
return CurPtr+1;
163 CurPtr = CurBuf.
begin();
166 int LLLexer::getNextChar() {
167 char CurChar = *CurPtr++;
169 default:
return (
unsigned char)CurChar;
173 if (CurPtr-1 != CurBuf.
end())
186 int CurChar = getNextChar();
190 if (isalpha(static_cast<unsigned char>(CurChar)) || CurChar ==
'_')
191 return LexIdentifier();
202 case '+':
return LexPositive();
203 case '@':
return LexAt();
204 case '$':
return LexDollar();
205 case '%':
return LexPercent();
206 case '"':
return LexQuote();
210 StrVal.assign(TokStart, CurPtr-1);
213 if (CurPtr[0] ==
'.' && CurPtr[1] ==
'.') {
221 case '!':
return LexExclaim();
222 case '#':
return LexHash();
223 case '0':
case '1':
case '2':
case '3':
case '4':
224 case '5':
case '6':
case '7':
case '8':
case '9':
226 return LexDigitOrNegative();
243 void LLLexer::SkipLineComment() {
245 if (CurPtr[0] ==
'\n' || CurPtr[0] ==
'\r' || getNextChar() == EOF)
261 StrVal.assign(TokStart, CurPtr - 1);
266 if (CurPtr[0] ==
'"') {
270 int CurChar = getNextChar();
272 if (CurChar == EOF) {
273 Error(
"end of file in COMDAT variable name");
276 if (CurChar ==
'"') {
277 StrVal.assign(TokStart + 2, CurPtr - 1);
280 Error(
"Null bytes are not allowed in names");
297 const char *Start = CurPtr;
299 int CurChar = getNextChar();
301 if (CurChar == EOF) {
302 Error(
"end of file in string constant");
305 if (CurChar ==
'"') {
306 StrVal.assign(Start, CurPtr-1);
314 bool LLLexer::ReadVarName() {
315 const char *NameStart = CurPtr;
316 if (isalpha(static_cast<unsigned char>(CurPtr[0])) ||
317 CurPtr[0] ==
'-' || CurPtr[0] ==
'$' ||
318 CurPtr[0] ==
'.' || CurPtr[0] ==
'_') {
320 while (isalnum(static_cast<unsigned char>(CurPtr[0])) ||
321 CurPtr[0] ==
'-' || CurPtr[0] ==
'$' ||
322 CurPtr[0] ==
'.' || CurPtr[0] ==
'_')
325 StrVal.assign(NameStart, CurPtr);
333 if (CurPtr[0] ==
'"') {
337 int CurChar = getNextChar();
339 if (CurChar == EOF) {
340 Error(
"end of file in global variable name");
343 if (CurChar ==
'"') {
344 StrVal.assign(TokStart+2, CurPtr-1);
347 Error(
"Null bytes are not allowed in names");
360 if (isdigit(static_cast<unsigned char>(CurPtr[0]))) {
361 for (++CurPtr; isdigit(static_cast<unsigned char>(CurPtr[0])); ++CurPtr)
364 uint64_t Val = atoull(TokStart+1, CurPtr);
365 if ((
unsigned)Val != Val)
366 Error(
"invalid value number (too large)!");
389 if (CurPtr[0] ==
':') {
392 Error(
"Null bytes are not allowed in names");
407 if (isalpha(static_cast<unsigned char>(CurPtr[0])) ||
408 CurPtr[0] ==
'-' || CurPtr[0] ==
'$' ||
409 CurPtr[0] ==
'.' || CurPtr[0] ==
'_' || CurPtr[0] ==
'\\') {
411 while (isalnum(static_cast<unsigned char>(CurPtr[0])) ||
412 CurPtr[0] ==
'-' || CurPtr[0] ==
'$' ||
413 CurPtr[0] ==
'.' || CurPtr[0] ==
'_' || CurPtr[0] ==
'\\')
416 StrVal.assign(TokStart+1, CurPtr);
427 if (isdigit(static_cast<unsigned char>(CurPtr[0]))) {
428 for (++CurPtr; isdigit(static_cast<unsigned char>(CurPtr[0])); ++CurPtr)
431 uint64_t Val = atoull(TokStart+1, CurPtr);
432 if ((
unsigned)Val != Val)
433 Error(
"invalid value number (too large)!");
447 const char *StartChar = CurPtr;
448 const char *IntEnd = CurPtr[-1] ==
'i' ?
nullptr : StartChar;
449 const char *KeywordEnd =
nullptr;
453 if (!IntEnd && !isdigit(static_cast<unsigned char>(*CurPtr)))
455 if (!KeywordEnd && !isalnum(static_cast<unsigned char>(*CurPtr)) &&
461 if (*CurPtr ==
':') {
462 StrVal.assign(StartChar-1, CurPtr++);
468 if (!IntEnd) IntEnd = CurPtr;
469 if (IntEnd != StartChar) {
471 uint64_t NumBits = atoull(StartChar, CurPtr);
474 Error(
"bitwidth for integer type out of range!");
482 if (!KeywordEnd) KeywordEnd = CurPtr;
485 StringRef Keyword(StartChar, CurPtr - StartChar);
487 #define KEYWORD(STR) \
489 if (Keyword == #STR) \
490 return lltok::kw_##STR; \
513 KEYWORD(externally_initialized);
624 KEYWORD(dereferenceable_or_null);
626 KEYWORD(inaccessiblemem_or_argmemonly);
705 #define TYPEKEYWORD(STR, LLVMTY) \
707 if (Keyword == STR) { \
709 return lltok::Type; \
728 #define INSTKEYWORD(STR, Enum) \
730 if (Keyword == #STR) { \
731 UIntVal = Instruction::Enum; \
732 return lltok::kw_##STR; \
792 #define DWKEYWORD(TYPE, TOKEN) \
794 if (Keyword.startswith("DW_" #TYPE "_")) { \
795 StrVal.assign(Keyword.begin(), Keyword.end()); \
796 return lltok::TOKEN; \
810 if (Keyword.startswith(
"DIFlag")) {
811 StrVal.assign(Keyword.begin(), Keyword.end());
815 if (Keyword.startswith(
"CSK_")) {
816 StrVal.assign(Keyword.begin(), Keyword.end());
820 if (Keyword ==
"NoDebug" || Keyword ==
"FullDebug" ||
821 Keyword ==
"LineTablesOnly") {
822 StrVal.assign(Keyword.begin(), Keyword.end());
828 if ((TokStart[0] ==
'u' || TokStart[0] ==
's') &&
829 TokStart[1] ==
'0' && TokStart[2] ==
'x' &&
830 isxdigit(static_cast<unsigned char>(TokStart[3]))) {
831 int len = CurPtr-TokStart-3;
834 if (!
all_of(HexStr, isxdigit)) {
839 APInt Tmp(bits, HexStr, 16);
840 uint32_t activeBits = Tmp.getActiveBits();
841 if (activeBits > 0 && activeBits < bits)
842 Tmp = Tmp.trunc(activeBits);
843 APSIntVal =
APSInt(Tmp, TokStart[0] ==
'u');
848 if (TokStart[0] ==
'c' && TokStart[1] ==
'c') {
866 CurPtr = TokStart + 2;
869 if ((CurPtr[0] >=
'K' && CurPtr[0] <=
'M') || CurPtr[0] ==
'H') {
875 if (!isxdigit(static_cast<unsigned char>(CurPtr[0]))) {
881 while (isxdigit(static_cast<unsigned char>(CurPtr[0])))
889 APInt(64, HexIntToVal(TokStart + 2, CurPtr)));
898 FP80HexToIntPair(TokStart+3, CurPtr, Pair);
903 HexToIntPair(TokStart+3, CurPtr, Pair);
908 HexToIntPair(TokStart+3, CurPtr, Pair);
913 APInt(16,HexIntToVal(TokStart+3, CurPtr)));
929 if (!isdigit(static_cast<unsigned char>(TokStart[0])) &&
930 !isdigit(static_cast<unsigned char>(CurPtr[0]))) {
933 StrVal.assign(TokStart, End-1);
944 for (; isdigit(static_cast<unsigned char>(CurPtr[0])); ++CurPtr)
950 StrVal.assign(TokStart, End-1);
958 if (CurPtr[0] !=
'.') {
959 if (TokStart[0] ==
'0' && TokStart[1] ==
'x')
968 while (isdigit(static_cast<unsigned char>(CurPtr[0]))) ++CurPtr;
970 if (CurPtr[0] ==
'e' || CurPtr[0] ==
'E') {
971 if (isdigit(static_cast<unsigned char>(CurPtr[1])) ||
972 ((CurPtr[1] ==
'-' || CurPtr[1] ==
'+') &&
973 isdigit(static_cast<unsigned char>(CurPtr[2])))) {
975 while (isdigit(static_cast<unsigned char>(CurPtr[0]))) ++CurPtr;
989 if (!isdigit(static_cast<unsigned char>(CurPtr[0])))
993 for (++CurPtr; isdigit(static_cast<unsigned char>(CurPtr[0])); ++CurPtr)
997 if (CurPtr[0] !=
'.') {
1005 while (isdigit(static_cast<unsigned char>(CurPtr[0]))) ++CurPtr;
1007 if (CurPtr[0] ==
'e' || CurPtr[0] ==
'E') {
1008 if (isdigit(static_cast<unsigned char>(CurPtr[1])) ||
1009 ((CurPtr[1] ==
'-' || CurPtr[1] ==
'+') &&
1010 isdigit(static_cast<unsigned char>(CurPtr[2])))) {
1012 while (isdigit(static_cast<unsigned char>(CurPtr[0]))) ++CurPtr;
1017 StringRef(TokStart, CurPtr - TokStart));
static const fltSemantics & IEEEquad() LLVM_READNONE
static Type * getDoubleTy(LLVMContext &C)
GCNRegPressure max(const GCNRegPressure &P1, const GCNRegPressure &P2)
Maximum length of the test input libFuzzer tries to guess a good value based on the corpus and reports it always prefer smaller inputs during the corpus shuffle When libFuzzer itself reports a bug this exit code will be used If indicates the maximal total time in seconds to run the fuzzer minimizes the provided crash input Use with tries to cleanse the provided crash input to make it contain fewer original bytes Use with exact_artifact_path to specify the output Experimental Use value profile to guide fuzzing Number of jobs to run If min(jobs, NumberOfCpuCores()/2)\" is used.") FUZZER_FLAG_INT(reload
static const char * isLabelTail(const char *CurPtr)
isLabelTail - Return true if this pointer points to a valid end of a label.
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly...
#define DWKEYWORD(TYPE, TOKEN)
static void cleanup(BlockFrequencyInfoImplBase &BFI)
Clear all memory not needed downstream.
static Type * getMetadataTy(LLVMContext &C)
static Type * getX86_MMXTy(LLVMContext &C)
static Type * getX86_FP80Ty(LLVMContext &C)
void Warning(LocTy WarningLoc, const Twine &Msg) const
static Type * getTokenTy(LLVMContext &C)
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
static Type * getFloatTy(LLVMContext &C)
#define TYPEKEYWORD(STR, LLVMTY)
static Type * getPPC_FP128Ty(LLVMContext &C)
LLLexer(StringRef StartBuf, SourceMgr &SM, SMDiagnostic &, LLVMContext &C)
static bool isLabelChar(char C)
isLabelChar - Return true for [-a-zA-Z$._0-9].
This file implements a class to represent arbitrary precision integral constant values and operations...
static Type * getLabelTy(LLVMContext &C)
static const fltSemantics & IEEEdouble() LLVM_READNONE
This is an important class for using LLVM in a threaded context.
static Type * getVoidTy(LLVMContext &C)
static const unsigned End
static const fltSemantics & x87DoubleExtended() LLVM_READNONE
rewrite statepoints for gc
This owns the files read by a parser, handles include stacks, and handles diagnostic wrangling...
bool Error(LocTy L, const Twine &Msg) const
static Type * getFP128Ty(LLVMContext &C)
const APInt & umin(const APInt &A, const APInt &B)
Determine the smaller of two APInts considered to be signed.
static Type * getHalfTy(LLVMContext &C)
static IntegerType * get(LLVMContext &C, unsigned NumBits)
This static method is the primary way of constructing an IntegerType.
static const fltSemantics & IEEEhalf() LLVM_READNONE
Class for arbitrary precision integers.
Base class for user error types.
const APInt & umax(const APInt &A, const APInt &B)
Determine the larger of two APInts considered to be unsigned.
llvm_unreachable("Unknown RegBank!")
static const fltSemantics & PPCDoubleDouble() LLVM_READNONE
Minimum number of bits that can be specified.
Deduce function attributes
static void UnEscapeLexed(std::string &Str)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static unsigned hexDigitValue(char C)
Interpret the given character C as a hexadecimal digit and return its value.
StringRef - Represent a constant reference to a string, i.e.
SMDiagnostic GetMessage(SMLoc Loc, DiagKind Kind, const Twine &Msg, ArrayRef< SMRange > Ranges=None, ArrayRef< SMFixIt > FixIts=None) const
Return an SMDiagnostic at the specified location with the specified string.
void PrintMessage(raw_ostream &OS, SMLoc Loc, DiagKind Kind, const Twine &Msg, ArrayRef< SMRange > Ranges=None, ArrayRef< SMFixIt > FixIts=None, bool ShowColors=true) const
Emit a message about the specified location with the specified string.
Represents a location in source code.
#define INSTKEYWORD(STR, Enum)
Maximum number of bits that can be specified.
Instances of this class encapsulate one diagnostic report, allowing printing to a raw_ostream as a ca...