LLVM  16.0.0git
TGLexer.cpp
Go to the documentation of this file.
1 //===- TGLexer.cpp - Lexer for TableGen -----------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // Implement the Lexer for TableGen.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #include "TGLexer.h"
14 #include "llvm/ADT/ArrayRef.h"
15 #include "llvm/ADT/StringSwitch.h"
16 #include "llvm/ADT/Twine.h"
17 #include "llvm/Config/config.h" // for strtoull()/strtoll() define
18 #include "llvm/Support/Compiler.h"
20 #include "llvm/Support/SourceMgr.h"
21 #include "llvm/TableGen/Error.h"
22 #include <algorithm>
23 #include <cctype>
24 #include <cerrno>
25 #include <cstdint>
26 #include <cstdio>
27 #include <cstdlib>
28 #include <cstring>
29 
30 using namespace llvm;
31 
32 namespace {
33 // A list of supported preprocessing directives with their
34 // internal token kinds and names.
35 struct {
37  const char *Word;
38 } PreprocessorDirs[] = {
39  { tgtok::Ifdef, "ifdef" },
40  { tgtok::Ifndef, "ifndef" },
41  { tgtok::Else, "else" },
42  { tgtok::Endif, "endif" },
43  { tgtok::Define, "define" }
44 };
45 } // end anonymous namespace
46 
48  CurBuffer = SrcMgr.getMainFileID();
49  CurBuf = SrcMgr.getMemoryBuffer(CurBuffer)->getBuffer();
50  CurPtr = CurBuf.begin();
51  TokStart = nullptr;
52 
53  // Pretend that we enter the "top-level" include file.
54  PrepIncludeStack.push_back(
55  std::make_unique<std::vector<PreprocessorControlDesc>>());
56 
57  // Put all macros defined in the command line into the DefinedMacros set.
58  for (const std::string &MacroName : Macros)
59  DefinedMacros.insert(MacroName);
60 }
61 
63  return SMLoc::getFromPointer(TokStart);
64 }
65 
67  return {getLoc(), SMLoc::getFromPointer(CurPtr)};
68 }
69 
70 /// ReturnError - Set the error to the specified string at the specified
71 /// location. This is defined to always return tgtok::Error.
72 tgtok::TokKind TGLexer::ReturnError(SMLoc Loc, const Twine &Msg) {
73  PrintError(Loc, Msg);
74  return tgtok::Error;
75 }
76 
77 tgtok::TokKind TGLexer::ReturnError(const char *Loc, const Twine &Msg) {
78  return ReturnError(SMLoc::getFromPointer(Loc), Msg);
79 }
80 
81 bool TGLexer::processEOF() {
82  SMLoc ParentIncludeLoc = SrcMgr.getParentIncludeLoc(CurBuffer);
83  if (ParentIncludeLoc != SMLoc()) {
84  // If prepExitInclude() detects a problem with the preprocessing
85  // control stack, it will return false. Pretend that we reached
86  // the final EOF and stop lexing more tokens by returning false
87  // to LexToken().
88  if (!prepExitInclude(false))
89  return false;
90 
91  CurBuffer = SrcMgr.FindBufferContainingLoc(ParentIncludeLoc);
92  CurBuf = SrcMgr.getMemoryBuffer(CurBuffer)->getBuffer();
93  CurPtr = ParentIncludeLoc.getPointer();
94  // Make sure TokStart points into the parent file's buffer.
95  // LexToken() assigns to it before calling getNextChar(),
96  // so it is pointing into the included file now.
97  TokStart = CurPtr;
98  return true;
99  }
100 
101  // Pretend that we exit the "top-level" include file.
102  // Note that in case of an error (e.g. control stack imbalance)
103  // the routine will issue a fatal error.
104  prepExitInclude(true);
105  return false;
106 }
107 
108 int TGLexer::getNextChar() {
109  char CurChar = *CurPtr++;
110  switch (CurChar) {
111  default:
112  return (unsigned char)CurChar;
113 
114  case 0: {
115  // A NUL character in the stream is either the end of the current buffer or
116  // a spurious NUL in the file. Disambiguate that here.
117  if (CurPtr - 1 == CurBuf.end()) {
118  --CurPtr; // Arrange for another call to return EOF again.
119  return EOF;
120  }
121  PrintError(getLoc(),
122  "NUL character is invalid in source; treated as space");
123  return ' ';
124  }
125 
126  case '\n':
127  case '\r':
128  // Handle the newline character by ignoring it and incrementing the line
129  // count. However, be careful about 'dos style' files with \n\r in them.
130  // Only treat a \n\r or \r\n as a single line.
131  if ((*CurPtr == '\n' || (*CurPtr == '\r')) &&
132  *CurPtr != CurChar)
133  ++CurPtr; // Eat the two char newline sequence.
134  return '\n';
135  }
136 }
137 
138 int TGLexer::peekNextChar(int Index) const {
139  return *(CurPtr + Index);
140 }
141 
142 tgtok::TokKind TGLexer::LexToken(bool FileOrLineStart) {
143  TokStart = CurPtr;
144  // This always consumes at least one character.
145  int CurChar = getNextChar();
146 
147  switch (CurChar) {
148  default:
149  // Handle letters: [a-zA-Z_]
150  if (isalpha(CurChar) || CurChar == '_')
151  return LexIdentifier();
152 
153  // Unknown character, emit an error.
154  return ReturnError(TokStart, "Unexpected character");
155  case EOF:
156  // Lex next token, if we just left an include file.
157  // Note that leaving an include file means that the next
158  // symbol is located at the end of the 'include "..."'
159  // construct, so LexToken() is called with default
160  // false parameter.
161  if (processEOF())
162  return LexToken();
163 
164  // Return EOF denoting the end of lexing.
165  return tgtok::Eof;
166 
167  case ':': return tgtok::colon;
168  case ';': return tgtok::semi;
169  case ',': return tgtok::comma;
170  case '<': return tgtok::less;
171  case '>': return tgtok::greater;
172  case ']': return tgtok::r_square;
173  case '{': return tgtok::l_brace;
174  case '}': return tgtok::r_brace;
175  case '(': return tgtok::l_paren;
176  case ')': return tgtok::r_paren;
177  case '=': return tgtok::equal;
178  case '?': return tgtok::question;
179  case '#':
180  if (FileOrLineStart) {
181  tgtok::TokKind Kind = prepIsDirective();
182  if (Kind != tgtok::Error)
183  return lexPreprocessor(Kind);
184  }
185 
186  return tgtok::paste;
187 
188  // The period is a separate case so we can recognize the "..."
189  // range punctuator.
190  case '.':
191  if (peekNextChar(0) == '.') {
192  ++CurPtr; // Eat second dot.
193  if (peekNextChar(0) == '.') {
194  ++CurPtr; // Eat third dot.
195  return tgtok::dotdotdot;
196  }
197  return ReturnError(TokStart, "Invalid '..' punctuation");
198  }
199  return tgtok::dot;
200 
201  case '\r':
202  PrintFatalError("getNextChar() must never return '\r'");
203  return tgtok::Error;
204 
205  case ' ':
206  case '\t':
207  // Ignore whitespace.
208  return LexToken(FileOrLineStart);
209  case '\n':
210  // Ignore whitespace, and identify the new line.
211  return LexToken(true);
212  case '/':
213  // If this is the start of a // comment, skip until the end of the line or
214  // the end of the buffer.
215  if (*CurPtr == '/')
216  SkipBCPLComment();
217  else if (*CurPtr == '*') {
218  if (SkipCComment())
219  return tgtok::Error;
220  } else // Otherwise, this is an error.
221  return ReturnError(TokStart, "Unexpected character");
222  return LexToken(FileOrLineStart);
223  case '-': case '+':
224  case '0': case '1': case '2': case '3': case '4': case '5': case '6':
225  case '7': case '8': case '9': {
226  int NextChar = 0;
227  if (isdigit(CurChar)) {
228  // Allow identifiers to start with a number if it is followed by
229  // an identifier. This can happen with paste operations like
230  // foo#8i.
231  int i = 0;
232  do {
233  NextChar = peekNextChar(i++);
234  } while (isdigit(NextChar));
235 
236  if (NextChar == 'x' || NextChar == 'b') {
237  // If this is [0-9]b[01] or [0-9]x[0-9A-fa-f] this is most
238  // likely a number.
239  int NextNextChar = peekNextChar(i);
240  switch (NextNextChar) {
241  default:
242  break;
243  case '0': case '1':
244  if (NextChar == 'b')
245  return LexNumber();
246  [[fallthrough]];
247  case '2': case '3': case '4': case '5':
248  case '6': case '7': case '8': case '9':
249  case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
250  case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
251  if (NextChar == 'x')
252  return LexNumber();
253  break;
254  }
255  }
256  }
257 
258  if (isalpha(NextChar) || NextChar == '_')
259  return LexIdentifier();
260 
261  return LexNumber();
262  }
263  case '"': return LexString();
264  case '$': return LexVarName();
265  case '[': return LexBracket();
266  case '!': return LexExclaim();
267  }
268 }
269 
270 /// LexString - Lex "[^"]*"
271 tgtok::TokKind TGLexer::LexString() {
272  const char *StrStart = CurPtr;
273 
274  CurStrVal = "";
275 
276  while (*CurPtr != '"') {
277  // If we hit the end of the buffer, report an error.
278  if (*CurPtr == 0 && CurPtr == CurBuf.end())
279  return ReturnError(StrStart, "End of file in string literal");
280 
281  if (*CurPtr == '\n' || *CurPtr == '\r')
282  return ReturnError(StrStart, "End of line in string literal");
283 
284  if (*CurPtr != '\\') {
285  CurStrVal += *CurPtr++;
286  continue;
287  }
288 
289  ++CurPtr;
290 
291  switch (*CurPtr) {
292  case '\\': case '\'': case '"':
293  // These turn into their literal character.
294  CurStrVal += *CurPtr++;
295  break;
296  case 't':
297  CurStrVal += '\t';
298  ++CurPtr;
299  break;
300  case 'n':
301  CurStrVal += '\n';
302  ++CurPtr;
303  break;
304 
305  case '\n':
306  case '\r':
307  return ReturnError(CurPtr, "escaped newlines not supported in tblgen");
308 
309  // If we hit the end of the buffer, report an error.
310  case '\0':
311  if (CurPtr == CurBuf.end())
312  return ReturnError(StrStart, "End of file in string literal");
313  [[fallthrough]];
314  default:
315  return ReturnError(CurPtr, "invalid escape in string literal");
316  }
317  }
318 
319  ++CurPtr;
320  return tgtok::StrVal;
321 }
322 
323 tgtok::TokKind TGLexer::LexVarName() {
324  if (!isalpha(CurPtr[0]) && CurPtr[0] != '_')
325  return ReturnError(TokStart, "Invalid variable name");
326 
327  // Otherwise, we're ok, consume the rest of the characters.
328  const char *VarNameStart = CurPtr++;
329 
330  while (isalpha(*CurPtr) || isdigit(*CurPtr) || *CurPtr == '_')
331  ++CurPtr;
332 
333  CurStrVal.assign(VarNameStart, CurPtr);
334  return tgtok::VarName;
335 }
336 
337 tgtok::TokKind TGLexer::LexIdentifier() {
338  // The first letter is [a-zA-Z_].
339  const char *IdentStart = TokStart;
340 
341  // Match the rest of the identifier regex: [0-9a-zA-Z_]*
342  while (isalpha(*CurPtr) || isdigit(*CurPtr) || *CurPtr == '_')
343  ++CurPtr;
344 
345  // Check to see if this identifier is a reserved keyword.
346  StringRef Str(IdentStart, CurPtr-IdentStart);
347 
349  .Case("int", tgtok::Int)
350  .Case("bit", tgtok::Bit)
351  .Case("bits", tgtok::Bits)
352  .Case("string", tgtok::String)
353  .Case("list", tgtok::List)
354  .Case("code", tgtok::Code)
355  .Case("dag", tgtok::Dag)
356  .Case("class", tgtok::Class)
357  .Case("def", tgtok::Def)
358  .Case("true", tgtok::TrueVal)
359  .Case("false", tgtok::FalseVal)
360  .Case("foreach", tgtok::Foreach)
361  .Case("defm", tgtok::Defm)
362  .Case("defset", tgtok::Defset)
363  .Case("multiclass", tgtok::MultiClass)
364  .Case("field", tgtok::Field)
365  .Case("let", tgtok::Let)
366  .Case("in", tgtok::In)
367  .Case("defvar", tgtok::Defvar)
368  .Case("include", tgtok::Include)
369  .Case("if", tgtok::If)
370  .Case("then", tgtok::Then)
371  .Case("else", tgtok::ElseKW)
372  .Case("assert", tgtok::Assert)
373  .Default(tgtok::Id);
374 
375  // A couple of tokens require special processing.
376  switch (Kind) {
377  case tgtok::Include:
378  if (LexInclude()) return tgtok::Error;
379  return Lex();
380  case tgtok::Id:
381  CurStrVal.assign(Str.begin(), Str.end());
382  break;
383  default:
384  break;
385  }
386 
387  return Kind;
388 }
389 
390 /// LexInclude - We just read the "include" token. Get the string token that
391 /// comes next and enter the include.
392 bool TGLexer::LexInclude() {
393  // The token after the include must be a string.
394  tgtok::TokKind Tok = LexToken();
395  if (Tok == tgtok::Error) return true;
396  if (Tok != tgtok::StrVal) {
397  PrintError(getLoc(), "Expected filename after include");
398  return true;
399  }
400 
401  // Get the string.
402  std::string Filename = CurStrVal;
403  std::string IncludedFile;
404 
405  CurBuffer = SrcMgr.AddIncludeFile(Filename, SMLoc::getFromPointer(CurPtr),
406  IncludedFile);
407  if (!CurBuffer) {
408  PrintError(getLoc(), "Could not find include file '" + Filename + "'");
409  return true;
410  }
411 
412  Dependencies.insert(IncludedFile);
413  // Save the line number and lex buffer of the includer.
414  CurBuf = SrcMgr.getMemoryBuffer(CurBuffer)->getBuffer();
415  CurPtr = CurBuf.begin();
416 
417  PrepIncludeStack.push_back(
418  std::make_unique<std::vector<PreprocessorControlDesc>>());
419  return false;
420 }
421 
422 /// SkipBCPLComment - Skip over the comment by finding the next CR or LF.
423 /// Or we may end up at the end of the buffer.
424 void TGLexer::SkipBCPLComment() {
425  ++CurPtr; // skip the second slash.
426  auto EOLPos = CurBuf.find_first_of("\r\n", CurPtr - CurBuf.data());
427  CurPtr = (EOLPos == StringRef::npos) ? CurBuf.end() : CurBuf.data() + EOLPos;
428 }
429 
430 /// SkipCComment - This skips C-style /**/ comments. The only difference from C
431 /// is that we allow nesting.
432 bool TGLexer::SkipCComment() {
433  ++CurPtr; // skip the star.
434  unsigned CommentDepth = 1;
435 
436  while (true) {
437  int CurChar = getNextChar();
438  switch (CurChar) {
439  case EOF:
440  PrintError(TokStart, "Unterminated comment!");
441  return true;
442  case '*':
443  // End of the comment?
444  if (CurPtr[0] != '/') break;
445 
446  ++CurPtr; // End the */.
447  if (--CommentDepth == 0)
448  return false;
449  break;
450  case '/':
451  // Start of a nested comment?
452  if (CurPtr[0] != '*') break;
453  ++CurPtr;
454  ++CommentDepth;
455  break;
456  }
457  }
458 }
459 
460 /// LexNumber - Lex:
461 /// [-+]?[0-9]+
462 /// 0x[0-9a-fA-F]+
463 /// 0b[01]+
464 tgtok::TokKind TGLexer::LexNumber() {
465  if (CurPtr[-1] == '0') {
466  if (CurPtr[0] == 'x') {
467  ++CurPtr;
468  const char *NumStart = CurPtr;
469  while (isxdigit(CurPtr[0]))
470  ++CurPtr;
471 
472  // Requires at least one hex digit.
473  if (CurPtr == NumStart)
474  return ReturnError(TokStart, "Invalid hexadecimal number");
475 
476  errno = 0;
477  CurIntVal = strtoll(NumStart, nullptr, 16);
478  if (errno == EINVAL)
479  return ReturnError(TokStart, "Invalid hexadecimal number");
480  if (errno == ERANGE) {
481  errno = 0;
482  CurIntVal = (int64_t)strtoull(NumStart, nullptr, 16);
483  if (errno == EINVAL)
484  return ReturnError(TokStart, "Invalid hexadecimal number");
485  if (errno == ERANGE)
486  return ReturnError(TokStart, "Hexadecimal number out of range");
487  }
488  return tgtok::IntVal;
489  } else if (CurPtr[0] == 'b') {
490  ++CurPtr;
491  const char *NumStart = CurPtr;
492  while (CurPtr[0] == '0' || CurPtr[0] == '1')
493  ++CurPtr;
494 
495  // Requires at least one binary digit.
496  if (CurPtr == NumStart)
497  return ReturnError(CurPtr-2, "Invalid binary number");
498  CurIntVal = strtoll(NumStart, nullptr, 2);
499  return tgtok::BinaryIntVal;
500  }
501  }
502 
503  // Check for a sign without a digit.
504  if (!isdigit(CurPtr[0])) {
505  if (CurPtr[-1] == '-')
506  return tgtok::minus;
507  else if (CurPtr[-1] == '+')
508  return tgtok::plus;
509  }
510 
511  while (isdigit(CurPtr[0]))
512  ++CurPtr;
513  CurIntVal = strtoll(TokStart, nullptr, 10);
514  return tgtok::IntVal;
515 }
516 
517 /// LexBracket - We just read '['. If this is a code block, return it,
518 /// otherwise return the bracket. Match: '[' and '[{ ( [^}]+ | }[^]] )* }]'
519 tgtok::TokKind TGLexer::LexBracket() {
520  if (CurPtr[0] != '{')
521  return tgtok::l_square;
522  ++CurPtr;
523  const char *CodeStart = CurPtr;
524  while (true) {
525  int Char = getNextChar();
526  if (Char == EOF) break;
527 
528  if (Char != '}') continue;
529 
530  Char = getNextChar();
531  if (Char == EOF) break;
532  if (Char == ']') {
533  CurStrVal.assign(CodeStart, CurPtr-2);
534  return tgtok::CodeFragment;
535  }
536  }
537 
538  return ReturnError(CodeStart - 2, "Unterminated code block");
539 }
540 
541 /// LexExclaim - Lex '!' and '![a-zA-Z]+'.
542 tgtok::TokKind TGLexer::LexExclaim() {
543  if (!isalpha(*CurPtr))
544  return ReturnError(CurPtr - 1, "Invalid \"!operator\"");
545 
546  const char *Start = CurPtr++;
547  while (isalpha(*CurPtr))
548  ++CurPtr;
549 
550  // Check to see which operator this is.
552  StringSwitch<tgtok::TokKind>(StringRef(Start, CurPtr - Start))
553  .Case("eq", tgtok::XEq)
554  .Case("ne", tgtok::XNe)
555  .Case("le", tgtok::XLe)
556  .Case("lt", tgtok::XLt)
557  .Case("ge", tgtok::XGe)
558  .Case("gt", tgtok::XGt)
559  .Case("if", tgtok::XIf)
560  .Case("cond", tgtok::XCond)
561  .Case("isa", tgtok::XIsA)
562  .Case("head", tgtok::XHead)
563  .Case("tail", tgtok::XTail)
564  .Case("size", tgtok::XSize)
565  .Case("con", tgtok::XConcat)
566  .Case("dag", tgtok::XDag)
567  .Case("add", tgtok::XADD)
568  .Case("sub", tgtok::XSUB)
569  .Case("mul", tgtok::XMUL)
570  .Case("div", tgtok::XDIV)
571  .Case("not", tgtok::XNOT)
572  .Case("logtwo", tgtok::XLOG2)
573  .Case("and", tgtok::XAND)
574  .Case("or", tgtok::XOR)
575  .Case("xor", tgtok::XXOR)
576  .Case("shl", tgtok::XSHL)
577  .Case("sra", tgtok::XSRA)
578  .Case("srl", tgtok::XSRL)
579  .Case("cast", tgtok::XCast)
580  .Case("empty", tgtok::XEmpty)
581  .Case("subst", tgtok::XSubst)
582  .Case("foldl", tgtok::XFoldl)
583  .Case("foreach", tgtok::XForEach)
584  .Case("filter", tgtok::XFilter)
585  .Case("listconcat", tgtok::XListConcat)
586  .Case("listsplat", tgtok::XListSplat)
587  .Case("strconcat", tgtok::XStrConcat)
588  .Case("interleave", tgtok::XInterleave)
589  .Case("substr", tgtok::XSubstr)
590  .Case("find", tgtok::XFind)
591  .Cases("setdagop", "setop", tgtok::XSetDagOp) // !setop is deprecated.
592  .Cases("getdagop", "getop", tgtok::XGetDagOp) // !getop is deprecated.
593  .Case("exists", tgtok::XExists)
595 
596  return Kind != tgtok::Error ? Kind : ReturnError(Start-1, "Unknown operator");
597 }
598 
599 bool TGLexer::prepExitInclude(bool IncludeStackMustBeEmpty) {
600  // Report an error, if preprocessor control stack for the current
601  // file is not empty.
602  if (!PrepIncludeStack.back()->empty()) {
603  prepReportPreprocessorStackError();
604 
605  return false;
606  }
607 
608  // Pop the preprocessing controls from the include stack.
609  if (PrepIncludeStack.empty()) {
610  PrintFatalError("Preprocessor include stack is empty");
611  }
612 
613  PrepIncludeStack.pop_back();
614 
615  if (IncludeStackMustBeEmpty) {
616  if (!PrepIncludeStack.empty())
617  PrintFatalError("Preprocessor include stack is not empty");
618  } else {
619  if (PrepIncludeStack.empty())
620  PrintFatalError("Preprocessor include stack is empty");
621  }
622 
623  return true;
624 }
625 
626 tgtok::TokKind TGLexer::prepIsDirective() const {
627  for (const auto &PD : PreprocessorDirs) {
628  int NextChar = *CurPtr;
629  bool Match = true;
630  unsigned I = 0;
631  for (; I < strlen(PD.Word); ++I) {
632  if (NextChar != PD.Word[I]) {
633  Match = false;
634  break;
635  }
636 
637  NextChar = peekNextChar(I + 1);
638  }
639 
640  // Check for whitespace after the directive. If there is no whitespace,
641  // then we do not recognize it as a preprocessing directive.
642  if (Match) {
643  tgtok::TokKind Kind = PD.Kind;
644 
645  // New line and EOF may follow only #else/#endif. It will be reported
646  // as an error for #ifdef/#define after the call to prepLexMacroName().
647  if (NextChar == ' ' || NextChar == '\t' || NextChar == EOF ||
648  NextChar == '\n' ||
649  // It looks like TableGen does not support '\r' as the actual
650  // carriage return, e.g. getNextChar() treats a single '\r'
651  // as '\n'. So we do the same here.
652  NextChar == '\r')
653  return Kind;
654 
655  // Allow comments after some directives, e.g.:
656  // #else// OR #else/**/
657  // #endif// OR #endif/**/
658  //
659  // Note that we do allow comments after #ifdef/#define here, e.g.
660  // #ifdef/**/ AND #ifdef//
661  // #define/**/ AND #define//
662  //
663  // These cases will be reported as incorrect after calling
664  // prepLexMacroName(). We could have supported C-style comments
665  // after #ifdef/#define, but this would complicate the code
666  // for little benefit.
667  if (NextChar == '/') {
668  NextChar = peekNextChar(I + 1);
669 
670  if (NextChar == '*' || NextChar == '/')
671  return Kind;
672 
673  // Pretend that we do not recognize the directive.
674  }
675  }
676  }
677 
678  return tgtok::Error;
679 }
680 
681 bool TGLexer::prepEatPreprocessorDirective(tgtok::TokKind Kind) {
682  TokStart = CurPtr;
683 
684  for (const auto &PD : PreprocessorDirs)
685  if (PD.Kind == Kind) {
686  // Advance CurPtr to the end of the preprocessing word.
687  CurPtr += strlen(PD.Word);
688  return true;
689  }
690 
691  PrintFatalError("Unsupported preprocessing token in "
692  "prepEatPreprocessorDirective()");
693  return false;
694 }
695 
696 tgtok::TokKind TGLexer::lexPreprocessor(
697  tgtok::TokKind Kind, bool ReturnNextLiveToken) {
698 
699  // We must be looking at a preprocessing directive. Eat it!
700  if (!prepEatPreprocessorDirective(Kind))
701  PrintFatalError("lexPreprocessor() called for unknown "
702  "preprocessor directive");
703 
704  if (Kind == tgtok::Ifdef || Kind == tgtok::Ifndef) {
705  StringRef MacroName = prepLexMacroName();
706  StringRef IfTokName = Kind == tgtok::Ifdef ? "#ifdef" : "#ifndef";
707  if (MacroName.empty())
708  return ReturnError(TokStart, "Expected macro name after " + IfTokName);
709 
710  bool MacroIsDefined = DefinedMacros.count(MacroName) != 0;
711 
712  // Canonicalize ifndef to ifdef equivalent
713  if (Kind == tgtok::Ifndef) {
714  MacroIsDefined = !MacroIsDefined;
715  Kind = tgtok::Ifdef;
716  }
717 
718  // Regardless of whether we are processing tokens or not,
719  // we put the #ifdef control on stack.
720  PrepIncludeStack.back()->push_back(
721  {Kind, MacroIsDefined, SMLoc::getFromPointer(TokStart)});
722 
723  if (!prepSkipDirectiveEnd())
724  return ReturnError(CurPtr, "Only comments are supported after " +
725  IfTokName + " NAME");
726 
727  // If we were not processing tokens before this #ifdef,
728  // then just return back to the lines skipping code.
729  if (!ReturnNextLiveToken)
730  return Kind;
731 
732  // If we were processing tokens before this #ifdef,
733  // and the macro is defined, then just return the next token.
734  if (MacroIsDefined)
735  return LexToken();
736 
737  // We were processing tokens before this #ifdef, and the macro
738  // is not defined, so we have to start skipping the lines.
739  // If the skipping is successful, it will return the token following
740  // either #else or #endif corresponding to this #ifdef.
741  if (prepSkipRegion(ReturnNextLiveToken))
742  return LexToken();
743 
744  return tgtok::Error;
745  } else if (Kind == tgtok::Else) {
746  // Check if this #else is correct before calling prepSkipDirectiveEnd(),
747  // which will move CurPtr away from the beginning of #else.
748  if (PrepIncludeStack.back()->empty())
749  return ReturnError(TokStart, "#else without #ifdef or #ifndef");
750 
751  PreprocessorControlDesc IfdefEntry = PrepIncludeStack.back()->back();
752 
753  if (IfdefEntry.Kind != tgtok::Ifdef) {
754  PrintError(TokStart, "double #else");
755  return ReturnError(IfdefEntry.SrcPos, "Previous #else is here");
756  }
757 
758  // Replace the corresponding #ifdef's control with its negation
759  // on the control stack.
760  PrepIncludeStack.back()->pop_back();
761  PrepIncludeStack.back()->push_back(
762  {Kind, !IfdefEntry.IsDefined, SMLoc::getFromPointer(TokStart)});
763 
764  if (!prepSkipDirectiveEnd())
765  return ReturnError(CurPtr, "Only comments are supported after #else");
766 
767  // If we were processing tokens before this #else,
768  // we have to start skipping lines until the matching #endif.
769  if (ReturnNextLiveToken) {
770  if (prepSkipRegion(ReturnNextLiveToken))
771  return LexToken();
772 
773  return tgtok::Error;
774  }
775 
776  // Return to the lines skipping code.
777  return Kind;
778  } else if (Kind == tgtok::Endif) {
779  // Check if this #endif is correct before calling prepSkipDirectiveEnd(),
780  // which will move CurPtr away from the beginning of #endif.
781  if (PrepIncludeStack.back()->empty())
782  return ReturnError(TokStart, "#endif without #ifdef");
783 
784  auto &IfdefOrElseEntry = PrepIncludeStack.back()->back();
785 
786  if (IfdefOrElseEntry.Kind != tgtok::Ifdef &&
787  IfdefOrElseEntry.Kind != tgtok::Else) {
788  PrintFatalError("Invalid preprocessor control on the stack");
789  return tgtok::Error;
790  }
791 
792  if (!prepSkipDirectiveEnd())
793  return ReturnError(CurPtr, "Only comments are supported after #endif");
794 
795  PrepIncludeStack.back()->pop_back();
796 
797  // If we were processing tokens before this #endif, then
798  // we should continue it.
799  if (ReturnNextLiveToken) {
800  return LexToken();
801  }
802 
803  // Return to the lines skipping code.
804  return Kind;
805  } else if (Kind == tgtok::Define) {
806  StringRef MacroName = prepLexMacroName();
807  if (MacroName.empty())
808  return ReturnError(TokStart, "Expected macro name after #define");
809 
810  if (!DefinedMacros.insert(MacroName).second)
812  "Duplicate definition of macro: " + Twine(MacroName));
813 
814  if (!prepSkipDirectiveEnd())
815  return ReturnError(CurPtr,
816  "Only comments are supported after #define NAME");
817 
818  if (!ReturnNextLiveToken) {
819  PrintFatalError("#define must be ignored during the lines skipping");
820  return tgtok::Error;
821  }
822 
823  return LexToken();
824  }
825 
826  PrintFatalError("Preprocessing directive is not supported");
827  return tgtok::Error;
828 }
829 
830 bool TGLexer::prepSkipRegion(bool MustNeverBeFalse) {
831  if (!MustNeverBeFalse)
832  PrintFatalError("Invalid recursion.");
833 
834  do {
835  // Skip all symbols to the line end.
836  prepSkipToLineEnd();
837 
838  // Find the first non-whitespace symbol in the next line(s).
839  if (!prepSkipLineBegin())
840  return false;
841 
842  // If the first non-blank/comment symbol on the line is '#',
843  // it may be a start of preprocessing directive.
844  //
845  // If it is not '#' just go to the next line.
846  if (*CurPtr == '#')
847  ++CurPtr;
848  else
849  continue;
850 
851  tgtok::TokKind Kind = prepIsDirective();
852 
853  // If we did not find a preprocessing directive or it is #define,
854  // then just skip to the next line. We do not have to do anything
855  // for #define in the line-skipping mode.
856  if (Kind == tgtok::Error || Kind == tgtok::Define)
857  continue;
858 
859  tgtok::TokKind ProcessedKind = lexPreprocessor(Kind, false);
860 
861  // If lexPreprocessor() encountered an error during lexing this
862  // preprocessor idiom, then return false to the calling lexPreprocessor().
863  // This will force tgtok::Error to be returned to the tokens processing.
864  if (ProcessedKind == tgtok::Error)
865  return false;
866 
867  if (Kind != ProcessedKind)
868  PrintFatalError("prepIsDirective() and lexPreprocessor() "
869  "returned different token kinds");
870 
871  // If this preprocessing directive enables tokens processing,
872  // then return to the lexPreprocessor() and get to the next token.
873  // We can move from line-skipping mode to processing tokens only
874  // due to #else or #endif.
875  if (prepIsProcessingEnabled()) {
876  if (Kind != tgtok::Else && Kind != tgtok::Endif) {
877  PrintFatalError("Tokens processing was enabled by an unexpected "
878  "preprocessing directive");
879  return false;
880  }
881 
882  return true;
883  }
884  } while (CurPtr != CurBuf.end());
885 
886  // We have reached the end of the file, but never left the lines-skipping
887  // mode. This means there is no matching #endif.
888  prepReportPreprocessorStackError();
889  return false;
890 }
891 
892 StringRef TGLexer::prepLexMacroName() {
893  // Skip whitespaces between the preprocessing directive and the macro name.
894  while (*CurPtr == ' ' || *CurPtr == '\t')
895  ++CurPtr;
896 
897  TokStart = CurPtr;
898  // Macro names start with [a-zA-Z_].
899  if (*CurPtr != '_' && !isalpha(*CurPtr))
900  return "";
901 
902  // Match the rest of the identifier regex: [0-9a-zA-Z_]*
903  while (isalpha(*CurPtr) || isdigit(*CurPtr) || *CurPtr == '_')
904  ++CurPtr;
905 
906  return StringRef(TokStart, CurPtr - TokStart);
907 }
908 
909 bool TGLexer::prepSkipLineBegin() {
910  while (CurPtr != CurBuf.end()) {
911  switch (*CurPtr) {
912  case ' ':
913  case '\t':
914  case '\n':
915  case '\r':
916  break;
917 
918  case '/': {
919  int NextChar = peekNextChar(1);
920  if (NextChar == '*') {
921  // Skip C-style comment.
922  // Note that we do not care about skipping the C++-style comments.
923  // If the line contains "//", it may not contain any processable
924  // preprocessing directive. Just return CurPtr pointing to
925  // the first '/' in this case. We also do not care about
926  // incorrect symbols after the first '/' - we are in lines-skipping
927  // mode, so incorrect code is allowed to some extent.
928 
929  // Set TokStart to the beginning of the comment to enable proper
930  // diagnostic printing in case of error in SkipCComment().
931  TokStart = CurPtr;
932 
933  // CurPtr must point to '*' before call to SkipCComment().
934  ++CurPtr;
935  if (SkipCComment())
936  return false;
937  } else {
938  // CurPtr points to the non-whitespace '/'.
939  return true;
940  }
941 
942  // We must not increment CurPtr after the comment was lexed.
943  continue;
944  }
945 
946  default:
947  return true;
948  }
949 
950  ++CurPtr;
951  }
952 
953  // We have reached the end of the file. Return to the lines skipping
954  // code, and allow it to handle the EOF as needed.
955  return true;
956 }
957 
958 bool TGLexer::prepSkipDirectiveEnd() {
959  while (CurPtr != CurBuf.end()) {
960  switch (*CurPtr) {
961  case ' ':
962  case '\t':
963  break;
964 
965  case '\n':
966  case '\r':
967  return true;
968 
969  case '/': {
970  int NextChar = peekNextChar(1);
971  if (NextChar == '/') {
972  // Skip C++-style comment.
973  // We may just return true now, but let's skip to the line/buffer end
974  // to simplify the method specification.
975  ++CurPtr;
976  SkipBCPLComment();
977  } else if (NextChar == '*') {
978  // When we are skipping C-style comment at the end of a preprocessing
979  // directive, we can skip several lines. If any meaningful TD token
980  // follows the end of the C-style comment on the same line, it will
981  // be considered as an invalid usage of TD token.
982  // For example, we want to forbid usages like this one:
983  // #define MACRO class Class {}
984  // But with C-style comments we also disallow the following:
985  // #define MACRO /* This macro is used
986  // to ... */ class Class {}
987  // One can argue that this should be allowed, but it does not seem
988  // to be worth of the complication. Moreover, this matches
989  // the C preprocessor behavior.
990 
991  // Set TokStart to the beginning of the comment to enable proper
992  // diagnostic printer in case of error in SkipCComment().
993  TokStart = CurPtr;
994  ++CurPtr;
995  if (SkipCComment())
996  return false;
997  } else {
998  TokStart = CurPtr;
999  PrintError(CurPtr, "Unexpected character");
1000  return false;
1001  }
1002 
1003  // We must not increment CurPtr after the comment was lexed.
1004  continue;
1005  }
1006 
1007  default:
1008  // Do not allow any non-whitespaces after the directive.
1009  TokStart = CurPtr;
1010  return false;
1011  }
1012 
1013  ++CurPtr;
1014  }
1015 
1016  return true;
1017 }
1018 
1019 void TGLexer::prepSkipToLineEnd() {
1020  while (*CurPtr != '\n' && *CurPtr != '\r' && CurPtr != CurBuf.end())
1021  ++CurPtr;
1022 }
1023 
1024 bool TGLexer::prepIsProcessingEnabled() {
1025  for (const PreprocessorControlDesc &I :
1026  llvm::reverse(*PrepIncludeStack.back()))
1027  if (!I.IsDefined)
1028  return false;
1029 
1030  return true;
1031 }
1032 
1033 void TGLexer::prepReportPreprocessorStackError() {
1034  if (PrepIncludeStack.back()->empty())
1035  PrintFatalError("prepReportPreprocessorStackError() called with "
1036  "empty control stack");
1037 
1038  auto &PrepControl = PrepIncludeStack.back()->back();
1039  PrintError(CurBuf.end(), "Reached EOF without matching #endif");
1040  PrintError(PrepControl.SrcPos, "The latest preprocessor control is here");
1041 
1042  TokStart = CurPtr;
1043 }
llvm::tgtok::XFilter
@ XFilter
Definition: TGLexer.h:57
llvm::StringSwitch::Case
StringSwitch & Case(StringLiteral S, T Value)
Definition: StringSwitch.h:70
i
i
Definition: README.txt:29
MemoryBuffer.h
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
llvm::tgtok::Def
@ Def
Definition: TGLexer.h:50
llvm::pdb::PDB_BuiltinType::Char
@ Char
llvm::tgtok::XForEach
@ XForEach
Definition: TGLexer.h:57
llvm::tgtok::Field
@ Field
Definition: TGLexer.h:51
llvm::StringRef::npos
static constexpr size_t npos
Definition: StringRef.h:52
llvm::tgtok::Code
@ Code
Definition: TGLexer.h:50
llvm::tgtok::paste
@ paste
Definition: TGLexer.h:45
llvm::tgtok::XXOR
@ XXOR
Definition: TGLexer.h:55
llvm::tgtok::l_brace
@ l_brace
Definition: TGLexer.h:39
llvm::tgtok::XStrConcat
@ XStrConcat
Definition: TGLexer.h:56
llvm::tgtok::l_paren
@ l_paren
Definition: TGLexer.h:40
llvm::logicalview::LVAttributeKind::Filename
@ Filename
llvm::tgtok::VarName
@ VarName
Definition: TGLexer.h:72
llvm::tgtok::Defm
@ Defm
Definition: TGLexer.h:50
llvm::SourceMgr::getParentIncludeLoc
SMLoc getParentIncludeLoc(unsigned i) const
Definition: SourceMgr.h:137
llvm::tgtok::comma
@ comma
Definition: TGLexer.h:43
llvm::StringRef::find_first_of
size_t find_first_of(char C, size_t From=0) const
Find the first character in the string that is C, or npos if not found.
Definition: StringRef.h:381
llvm::tgtok::Bits
@ Bits
Definition: TGLexer.h:50
llvm::tgtok::XGe
@ XGe
Definition: TGLexer.h:58
llvm::tgtok::XSUB
@ XSUB
Definition: TGLexer.h:55
llvm::tgtok::l_square
@ l_square
Definition: TGLexer.h:38
llvm::tgtok::FalseVal
@ FalseVal
Definition: TGLexer.h:62
llvm::StringSet::insert
std::pair< typename Base::iterator, bool > insert(StringRef key)
Definition: StringSet.h:34
llvm::DiagnosticPredicateTy::Match
@ Match
TGLexer.h
llvm::tgtok::XHead
@ XHead
Definition: TGLexer.h:57
llvm::tgtok::Else
@ Else
Definition: TGLexer.h:76
llvm::tgtok::BinaryIntVal
@ BinaryIntVal
Definition: TGLexer.h:69
llvm::TGLexer::TGLexer
TGLexer(SourceMgr &SrcMgr, ArrayRef< std::string > Macros)
Definition: TGLexer.cpp:47
llvm::tgtok::plus
@ plus
Definition: TGLexer.h:37
llvm::TGLexer::Lex
tgtok::TokKind Lex()
Definition: TGLexer.h:107
llvm::tgtok::XMUL
@ XMUL
Definition: TGLexer.h:55
llvm::tgtok::Dag
@ Dag
Definition: TGLexer.h:50
llvm::tgtok::XFind
@ XFind
Definition: TGLexer.h:56
llvm::tgtok::Then
@ Then
Definition: TGLexer.h:52
llvm::tgtok::question
@ question
Definition: TGLexer.h:44
llvm::tgtok::XOR
@ XOR
Definition: TGLexer.h:55
llvm::SMLoc
Represents a location in source code.
Definition: SMLoc.h:23
Twine.h
llvm::X86II::PD
@ PD
Definition: X86BaseInfo.h:792
llvm::tgtok::Assert
@ Assert
Definition: TGLexer.h:50
llvm::SrcMgr
SourceMgr SrcMgr
Definition: Error.cpp:24
llvm::tgtok::XIsA
@ XIsA
Definition: TGLexer.h:58
llvm::tgtok::XCast
@ XCast
Definition: TGLexer.h:57
llvm::dwarf::Index
Index
Definition: Dwarf.h:472
llvm::tgtok::XListConcat
@ XListConcat
Definition: TGLexer.h:56
llvm::PrintFatalError
void PrintFatalError(const Twine &Msg)
Definition: Error.cpp:125
llvm::SourceMgr::getMainFileID
unsigned getMainFileID() const
Definition: SourceMgr.h:132
llvm::StringRef::data
const char * data() const
data - Get a pointer to the start of the string (which may not be null terminated).
Definition: StringRef.h:131
llvm::tgtok::If
@ If
Definition: TGLexer.h:51
llvm::MemoryBuffer::getBuffer
StringRef getBuffer() const
Definition: MemoryBuffer.h:70
llvm::tgtok::equal
@ equal
Definition: TGLexer.h:44
llvm::tgtok::XNOT
@ XNOT
Definition: TGLexer.h:55
llvm::lltok::Kind
Kind
Definition: LLToken.h:18
SourceMgr.h
llvm::tgtok::XGt
@ XGt
Definition: TGLexer.h:58
llvm::SourceMgr::getMemoryBuffer
const MemoryBuffer * getMemoryBuffer(unsigned i) const
Definition: SourceMgr.h:125
llvm::tgtok::XSRA
@ XSRA
Definition: TGLexer.h:55
llvm::tgtok::Foreach
@ Foreach
Definition: TGLexer.h:51
llvm::StringRef::empty
constexpr bool empty() const
empty - Check if the string is empty.
Definition: StringRef.h:134
llvm::tgtok::XInterleave
@ XInterleave
Definition: TGLexer.h:56
llvm::tgtok::In
@ In
Definition: TGLexer.h:51
Error.h
llvm::tgtok::Defset
@ Defset
Definition: TGLexer.h:50
llvm::tgtok::XIf
@ XIf
Definition: TGLexer.h:57
Index
uint32_t Index
Definition: ELFObjHandler.cpp:83
llvm::tgtok::XEq
@ XEq
Definition: TGLexer.h:58
llvm::StringRef::end
iterator end() const
Definition: StringRef.h:113
llvm::tgtok::Int
@ Int
Definition: TGLexer.h:51
llvm::tgtok::XDIV
@ XDIV
Definition: TGLexer.h:55
llvm::tgtok::XExists
@ XExists
Definition: TGLexer.h:59
llvm::tgtok::ElseKW
@ ElseKW
Definition: TGLexer.h:50
llvm::tgtok::r_square
@ r_square
Definition: TGLexer.h:38
I
#define I(x, y, z)
Definition: MD5.cpp:58
llvm::tgtok::Defvar
@ Defvar
Definition: TGLexer.h:50
ArrayRef.h
llvm::tgtok::XSubstr
@ XSubstr
Definition: TGLexer.h:56
llvm::tgtok::Include
@ Include
Definition: TGLexer.h:51
llvm::tgtok::r_paren
@ r_paren
Definition: TGLexer.h:40
llvm::tgtok::XConcat
@ XConcat
Definition: TGLexer.h:55
llvm::tgtok::XLe
@ XLe
Definition: TGLexer.h:58
llvm::irsymtab::storage::Word
support::ulittle32_t Word
Definition: IRSymtab.h:52
llvm::tgtok::XCond
@ XCond
Definition: TGLexer.h:58
llvm::ArrayRef< std::string >
llvm::SourceMgr::FindBufferContainingLoc
unsigned FindBufferContainingLoc(SMLoc Loc) const
Return the ID of the buffer containing the specified location.
Definition: SourceMgr.cpp:69
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
llvm::tgtok::Endif
@ Endif
Definition: TGLexer.h:76
llvm::tgtok::String
@ String
Definition: TGLexer.h:52
llvm::tgtok::XADD
@ XADD
Definition: TGLexer.h:55
llvm::SourceMgr
This owns the files read by a parser, handles include stacks, and handles diagnostic wrangling.
Definition: SourceMgr.h:31
Compiler.h
llvm::tgtok::XSRL
@ XSRL
Definition: TGLexer.h:55
llvm::tgtok::XGetDagOp
@ XGetDagOp
Definition: TGLexer.h:58
llvm::tgtok::Ifdef
@ Ifdef
Definition: TGLexer.h:76
llvm::StringSwitch::Cases
StringSwitch & Cases(StringLiteral S0, StringLiteral S1, T Value)
Definition: StringSwitch.h:91
llvm::tgtok::Ifndef
@ Ifndef
Definition: TGLexer.h:76
llvm::AMDGPU::SendMsg::Msg
const CustomOperand< const MCSubtargetInfo & > Msg[]
Definition: AMDGPUAsmUtils.cpp:39
llvm::tgtok::StrVal
@ StrVal
Definition: TGLexer.h:72
llvm::tgtok::dot
@ dot
Definition: TGLexer.h:43
llvm::tgtok::IntVal
@ IntVal
Definition: TGLexer.h:65
llvm::Twine
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:81
llvm::tgtok::r_brace
@ r_brace
Definition: TGLexer.h:39
llvm::tgtok::Eof
@ Eof
Definition: TGLexer.h:34
llvm::SMLoc::getPointer
const char * getPointer() const
Definition: SMLoc.h:34
llvm::tgtok::XAND
@ XAND
Definition: TGLexer.h:55
llvm::tgtok::Error
@ Error
Definition: TGLexer.h:34
llvm::tgtok::XListSplat
@ XListSplat
Definition: TGLexer.h:56
llvm::tgtok::XSHL
@ XSHL
Definition: TGLexer.h:56
StringSwitch.h
llvm::StringMap::count
size_type count(StringRef Key) const
count - Return 1 if the element is in the map, 0 otherwise.
Definition: StringMap.h:245
llvm::tgtok::XFoldl
@ XFoldl
Definition: TGLexer.h:57
llvm::tgtok::XSubst
@ XSubst
Definition: TGLexer.h:57
llvm::tgtok::Class
@ Class
Definition: TGLexer.h:50
llvm::SourceMgr::AddIncludeFile
unsigned AddIncludeFile(const std::string &Filename, SMLoc IncludeLoc, std::string &IncludedFile)
Search for a file with the specified name in the current directory or in one of the IncludeDirs.
Definition: SourceMgr.cpp:40
llvm::tgtok::XDag
@ XDag
Definition: TGLexer.h:58
llvm::tgtok::greater
@ greater
Definition: TGLexer.h:41
llvm::tgtok::CodeFragment
@ CodeFragment
Definition: TGLexer.h:72
llvm::tgtok::XSize
@ XSize
Definition: TGLexer.h:57
llvm::tgtok::XNe
@ XNe
Definition: TGLexer.h:58
llvm::PrintError
void PrintError(const Twine &Msg)
Definition: Error.cpp:101
llvm::tgtok::less
@ less
Definition: TGLexer.h:41
llvm::SMRange
Represents a range in source code.
Definition: SMLoc.h:48
llvm::tgtok::MultiClass
@ MultiClass
Definition: TGLexer.h:51
llvm::tgtok::TokKind
TokKind
Definition: TGLexer.h:32
llvm::PrintWarning
void PrintWarning(const Twine &Msg)
Definition: Error.cpp:89
llvm::tgtok::Bit
@ Bit
Definition: TGLexer.h:50
llvm::TGLexer::getLocRange
SMRange getLocRange() const
Definition: TGLexer.cpp:66
llvm::SMLoc::getFromPointer
static SMLoc getFromPointer(const char *Ptr)
Definition: SMLoc.h:36
llvm::reverse
auto reverse(ContainerTy &&C)
Definition: STLExtras.h:485
llvm::StringSwitch::Default
R Default(T Value)
Definition: StringSwitch.h:183
llvm::tgtok::XSetDagOp
@ XSetDagOp
Definition: TGLexer.h:58
llvm::StringSwitch
A switch()-like statement whose cases are string literals.
Definition: StringSwitch.h:45
llvm::tgtok::XLOG2
@ XLOG2
Definition: TGLexer.h:55
llvm::TGLexer::getLoc
SMLoc getLoc() const
Definition: TGLexer.cpp:62
llvm::tgtok::List
@ List
Definition: TGLexer.h:51
llvm::tgtok::XTail
@ XTail
Definition: TGLexer.h:57
llvm::tgtok::semi
@ semi
Definition: TGLexer.h:42
llvm::StringRef::begin
iterator begin() const
Definition: StringRef.h:111
llvm::tgtok::TrueVal
@ TrueVal
Definition: TGLexer.h:62
llvm::tgtok::minus
@ minus
Definition: TGLexer.h:37
llvm::tgtok::XLt
@ XLt
Definition: TGLexer.h:58
llvm::tgtok::Define
@ Define
Definition: TGLexer.h:76
llvm::tgtok::colon
@ colon
Definition: TGLexer.h:42
llvm::tgtok::dotdotdot
@ dotdotdot
Definition: TGLexer.h:46
llvm::tgtok::Id
@ Id
Definition: TGLexer.h:72
llvm::tgtok::XEmpty
@ XEmpty
Definition: TGLexer.h:57
llvm::tgtok::Let
@ Let
Definition: TGLexer.h:51