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