clang 24.0.0git
PPExpressions.cpp
Go to the documentation of this file.
1//===--- PPExpressions.cpp - Preprocessor Expression Evaluation -----------===//
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// This file implements the Preprocessor::EvaluateDirectiveExpression method,
10// which parses and evaluates integer constant expressions for #if directives.
11//
12//===----------------------------------------------------------------------===//
13//
14// FIXME: implement testing for #assert's.
15//
16//===----------------------------------------------------------------------===//
17
26#include "clang/Lex/MacroInfo.h"
30#include "clang/Lex/Token.h"
31#include "llvm/ADT/APSInt.h"
32#include "llvm/ADT/STLExtras.h"
33#include "llvm/ADT/StringExtras.h"
34#include "llvm/ADT/StringRef.h"
35#include "llvm/Support/ErrorHandling.h"
36#include "llvm/Support/SaveAndRestore.h"
37#include <cassert>
38
39using namespace clang;
40
41namespace {
42
43/// PPValue - Represents the value of a subexpression of a preprocessor
44/// conditional and the source range covered by it.
45class PPValue {
46 SourceRange Range;
47 IdentifierInfo *II = nullptr;
48
49public:
50 llvm::APSInt Val;
51
52 // Default ctor - Construct an 'invalid' PPValue.
53 PPValue(unsigned BitWidth) : Val(BitWidth) {}
54
55 // If this value was produced by directly evaluating an identifier, produce
56 // that identifier.
57 IdentifierInfo *getIdentifier() const { return II; }
58 void setIdentifier(IdentifierInfo *II) { this->II = II; }
59
60 unsigned getBitWidth() const { return Val.getBitWidth(); }
61 bool isUnsigned() const { return Val.isUnsigned(); }
62
63 SourceRange getRange() const { return Range; }
64
65 void setRange(SourceLocation L) { Range.setBegin(L); Range.setEnd(L); }
66 void setRange(SourceLocation B, SourceLocation E) {
67 Range.setBegin(B); Range.setEnd(E);
68 }
69 void setBegin(SourceLocation L) { Range.setBegin(L); }
70 void setEnd(SourceLocation L) { Range.setEnd(L); }
71};
72
73} // end anonymous namespace
74
75static bool EvaluateDirectiveSubExpr(PPValue &LHS, unsigned MinPrec,
76 Token &PeekTok, bool ValueLive,
77 bool &IncludedUndefinedIds,
78 Preprocessor &PP);
79
80/// DefinedTracker - This struct is used while parsing expressions to keep track
81/// of whether !defined(X) has been seen.
82///
83/// With this simple scheme, we handle the basic forms:
84/// !defined(X) and !defined X
85/// but we also trivially handle (silly) stuff like:
86/// !!!defined(X) and +!defined(X) and !+!+!defined(X) and !(defined(X)).
88 /// Each time a Value is evaluated, it returns information about whether the
89 /// parsed value is of the form defined(X), !defined(X) or is something else.
91 DefinedMacro, // defined(X)
92 NotDefinedMacro, // !defined(X)
93 Unknown // Something else.
94 } State;
95 /// TheMacro - When the state is DefinedMacro or NotDefinedMacro, this
96 /// indicates the macro that was checked.
99};
100
101/// EvaluateDefined - Process a 'defined(sym)' expression.
102static bool EvaluateDefined(PPValue &Result, Token &PeekTok, DefinedTracker &DT,
103 bool ValueLive, Preprocessor &PP) {
104 SourceLocation beginLoc(PeekTok.getLocation());
105 Result.setBegin(beginLoc);
106
107 // Get the next token, don't expand it.
108 PP.LexUnexpandedNonComment(PeekTok);
109
110 // Two options, it can either be a pp-identifier or a (.
111 SourceLocation LParenLoc;
112 if (PeekTok.is(tok::l_paren)) {
113 // Found a paren, remember we saw it and skip it.
114 LParenLoc = PeekTok.getLocation();
115 PP.LexUnexpandedNonComment(PeekTok);
116 }
117
118 if (PeekTok.is(tok::code_completion)) {
122 PP.LexUnexpandedNonComment(PeekTok);
123 }
124
125 // If we don't have a pp-identifier now, this is an error.
126 if (PP.CheckMacroName(PeekTok, MU_Other))
127 return true;
128
129 // Otherwise, we got an identifier, is it defined to something?
130 IdentifierInfo *II = PeekTok.getIdentifierInfo();
132 Result.Val = !!Macro;
133 Result.Val.setIsUnsigned(false); // Result is signed intmax_t.
135
137 PeekTok,
138 (II->getName() == "INFINITY" || II->getName() == "NAN") ? true : false);
139
140 // If there is a macro, mark it used.
141 if (Result.Val != 0 && ValueLive)
142 PP.markMacroAsUsed(Macro.getMacroInfo());
143
144 // Save macro token for callback.
145 Token macroToken(PeekTok);
146
147 // If we are in parens, ensure we have a trailing ).
148 if (LParenLoc.isValid()) {
149 // Consume identifier.
150 Result.setEnd(PeekTok.getLocation());
151 PP.LexUnexpandedNonComment(PeekTok);
152
153 if (PeekTok.isNot(tok::r_paren)) {
154 PP.Diag(PeekTok.getLocation(), diag::err_pp_expected_after)
155 << "'defined'" << tok::r_paren;
156 PP.Diag(LParenLoc, diag::note_matching) << tok::l_paren;
157 return true;
158 }
159 // Consume the ).
160 PP.LexNonComment(PeekTok);
161 Result.setEnd(PeekTok.getLocation());
162 } else {
163 // Consume identifier.
164 Result.setEnd(PeekTok.getLocation());
165 PP.LexNonComment(PeekTok);
166 }
167
168 // [cpp.cond]p4:
169 // Prior to evaluation, macro invocations in the list of preprocessing
170 // tokens that will become the controlling constant expression are replaced
171 // (except for those macro names modified by the 'defined' unary operator),
172 // just as in normal text. If the token 'defined' is generated as a result
173 // of this replacement process or use of the 'defined' unary operator does
174 // not match one of the two specified forms prior to macro replacement, the
175 // behavior is undefined.
176 // This isn't an idle threat, consider this program:
177 // #define FOO
178 // #define BAR defined(FOO)
179 // #if BAR
180 // ...
181 // #else
182 // ...
183 // #endif
184 // clang and gcc will pick the #if branch while Visual Studio will take the
185 // #else branch. Emit a warning about this undefined behavior.
186 if (beginLoc.isMacroID()) {
187 bool IsFunctionTypeMacro =
190 .getExpansion()
192 // For object-type macros, it's easy to replace
193 // #define FOO defined(BAR)
194 // with
195 // #if defined(BAR)
196 // #define FOO 1
197 // #else
198 // #define FOO 0
199 // #endif
200 // and doing so makes sense since compilers handle this differently in
201 // practice (see example further up). But for function-type macros,
202 // there is no good way to write
203 // # define FOO(x) (defined(M_ ## x) && M_ ## x)
204 // in a different way, and compilers seem to agree on how to behave here.
205 // So warn by default on object-type macros, but only warn in -pedantic
206 // mode on function-type macros.
207 if (IsFunctionTypeMacro)
208 PP.Diag(beginLoc, diag::warn_defined_in_function_type_macro);
209 else
210 PP.Diag(beginLoc, diag::warn_defined_in_object_type_macro);
211 }
212
213 // Invoke the 'defined' callback.
214 if (PPCallbacks *Callbacks = PP.getPPCallbacks()) {
215 Callbacks->Defined(macroToken, Macro,
216 SourceRange(beginLoc, PeekTok.getLocation()));
217 }
218
219 // Success, remember that we saw defined(X).
221 DT.TheMacro = II;
222 return false;
223}
224
225/// EvaluateValue - Evaluate the token PeekTok (and any others needed) and
226/// return the computed value in Result. Return true if there was an error
227/// parsing. This function also returns information about the form of the
228/// expression in DT. See above for information on what DT means.
229///
230/// If ValueLive is false, then this value is being evaluated in a context where
231/// the result is not used. As such, avoid diagnostics that relate to
232/// evaluation.
233static bool EvaluateValue(PPValue &Result, Token &PeekTok, DefinedTracker &DT,
234 bool ValueLive, Preprocessor &PP) {
236
237 Result.setIdentifier(nullptr);
238
239 if (PeekTok.is(tok::code_completion)) {
243 PP.LexNonComment(PeekTok);
244 }
245
246 switch (PeekTok.getKind()) {
247 default:
248 // If this token's spelling is a pp-identifier, check to see if it is
249 // 'defined' or if it is a macro. Note that we check here because many
250 // keywords are pp-identifiers, so we can't check the kind.
251 if (IdentifierInfo *II = PeekTok.getIdentifierInfo()) {
252 // Handle "defined X" and "defined(X)".
253 if (II->isStr("defined"))
254 return EvaluateDefined(Result, PeekTok, DT, ValueLive, PP);
255
256 if (!II->isCPlusPlusOperatorKeyword()) {
257 // If this identifier isn't 'defined' or one of the special
258 // preprocessor keywords and it wasn't macro expanded, it turns
259 // into a simple 0
260 if (ValueLive) {
261 unsigned DiagID = II->getName() == "true"
262 ? diag::warn_pp_undef_true_identifier
263 : diag::warn_pp_undef_identifier;
264 PP.Diag(PeekTok, DiagID) << II;
265
266 const DiagnosticsEngine &DiagEngine = PP.getDiagnostics();
267 // If 'Wundef' is enabled, do not emit 'undef-prefix' diagnostics.
268 if (DiagEngine.isIgnored(DiagID, PeekTok.getLocation())) {
269 const std::vector<std::string> UndefPrefixes =
271 const StringRef IdentifierName = II->getName();
272 if (llvm::any_of(UndefPrefixes,
273 [&IdentifierName](const std::string &Prefix) {
274 return IdentifierName.starts_with(Prefix);
275 }))
276 PP.Diag(PeekTok, diag::warn_pp_undef_prefix)
277 << AddFlagValue{llvm::join(UndefPrefixes, ",")} << II;
278 }
279 }
280 Result.Val = 0;
281 Result.Val.setIsUnsigned(false); // "0" is signed intmax_t 0.
282 Result.setIdentifier(II);
283 Result.setRange(PeekTok.getLocation());
284 DT.IncludedUndefinedIds = true;
285 PP.LexNonComment(PeekTok);
286 return false;
287 }
288 }
289 PP.Diag(PeekTok, diag::err_pp_expr_bad_token_start_expr);
290 return true;
291 case tok::eod:
292 case tok::r_paren:
293 // If there is no expression, report and exit.
294 PP.Diag(PeekTok, diag::err_pp_expected_value_in_expr);
295 return true;
296 case tok::numeric_constant: {
297 SmallString<64> IntegerBuffer;
298 bool NumberInvalid = false;
299 StringRef Spelling = PP.getSpelling(PeekTok, IntegerBuffer,
300 &NumberInvalid);
301 if (NumberInvalid)
302 return true; // a diagnostic was already reported
303
304 NumericLiteralParser Literal(Spelling, PeekTok.getLocation(),
305 PP.getSourceManager(), PP.getLangOpts(),
306 PP.getTargetInfo(), PP.getDiagnostics());
307 if (Literal.hadError)
308 return true; // a diagnostic was already reported.
309
310 if (Literal.isFloatingLiteral() || Literal.isImaginary) {
311 PP.Diag(PeekTok, diag::err_pp_illegal_floating_literal);
312 return true;
313 }
314 assert(Literal.isIntegerLiteral() && "Unknown ppnumber");
315
316 // Complain about, and drop, any ud-suffix.
317 if (Literal.hasUDSuffix())
318 PP.Diag(PeekTok, diag::err_pp_invalid_udl) << /*integer*/1;
319
320 // 'long long' is a C99 or C++11 feature.
321 if (!PP.getLangOpts().C99 && Literal.isLongLong) {
322 if (PP.getLangOpts().CPlusPlus)
323 PP.Diag(PeekTok,
324 PP.getLangOpts().CPlusPlus11 ?
325 diag::warn_cxx98_compat_longlong : diag::ext_cxx11_longlong);
326 else
327 PP.Diag(PeekTok, diag::ext_c99_longlong);
328 }
329
330 // 'z/uz' literals are a C++23 feature.
331 if (Literal.isSizeT) {
332 if (PP.getLangOpts().CPlusPlus) {
333 PP.DiagCompat(PeekTok, diag_compat::size_t_suffix);
334 } else {
335 PP.Diag(PeekTok, diag::err_cxx23_size_t_suffix);
336 }
337 }
338
339 // 'wb/uwb' literals are a C23 feature.
340 // '__wb/__uwb' are a C++ extension.
341 if (Literal.isBitInt)
342 PP.Diag(PeekTok, PP.getLangOpts().CPlusPlus ? diag::ext_cxx_bitint_suffix
343 : PP.getLangOpts().C23
344 ? diag::warn_c23_compat_bitint_suffix
345 : diag::ext_c23_bitint_suffix);
346
347 // Parse the integer literal into Result.
348 if (Literal.GetIntegerValue(Result.Val)) {
349 // Overflow parsing integer literal.
350 PP.Diag(PeekTok, diag::err_integer_literal_too_large) << /* Unsigned */ 1;
351 Result.Val.setIsUnsigned(true);
352 } else {
353 // Set the signedness of the result to match whether there was a U suffix
354 // or not.
355 Result.Val.setIsUnsigned(Literal.isUnsigned);
356
357 // Detect overflow based on whether the value is signed. If signed
358 // and if the value is too large, emit a warning "integer constant is so
359 // large that it is unsigned" e.g. on 12345678901234567890 where intmax_t
360 // is 64-bits.
361 if (!Literal.isUnsigned && Result.Val.isNegative()) {
362 // Octal, hexadecimal, and binary literals are implicitly unsigned if
363 // the value does not fit into a signed integer type.
364 if (ValueLive && Literal.getRadix() == 10)
365 PP.Diag(PeekTok, diag::ext_integer_literal_too_large_for_signed);
366 Result.Val.setIsUnsigned(true);
367 }
368 }
369
370 // Consume the token.
371 Result.setRange(PeekTok.getLocation());
372 PP.LexNonComment(PeekTok);
373 return false;
374 }
375 case tok::char_constant: // 'x'
376 case tok::wide_char_constant: // L'x'
377 case tok::utf8_char_constant: // u8'x'
378 case tok::utf16_char_constant: // u'x'
379 case tok::utf32_char_constant: { // U'x'
380 // Complain about, and drop, any ud-suffix.
381 if (PeekTok.hasUDSuffix())
382 PP.Diag(PeekTok, diag::err_pp_invalid_udl) << /*character*/0;
383
384 SmallString<32> CharBuffer;
385 bool CharInvalid = false;
386 StringRef ThisTok = PP.getSpelling(PeekTok, CharBuffer, &CharInvalid);
387 if (CharInvalid)
388 return true;
389
390 CharLiteralParser Literal(ThisTok.begin(), ThisTok.end(),
391 PeekTok.getLocation(), PP, PeekTok.getKind());
392 if (Literal.hadError())
393 return true; // A diagnostic was already emitted.
394
395 // Character literals are always int or wchar_t, expand to intmax_t.
396 const TargetInfo &TI = PP.getTargetInfo();
397 unsigned NumBits;
398 if (Literal.isMultiChar())
399 NumBits = TI.getIntWidth();
400 else if (Literal.isWide())
401 NumBits = TI.getWCharWidth();
402 else if (Literal.isUTF16())
403 NumBits = TI.getChar16Width();
404 else if (Literal.isUTF32())
405 NumBits = TI.getChar32Width();
406 else // char or char8_t
407 NumBits = TI.getCharWidth();
408
409 // Set the width.
410 llvm::APSInt Val(NumBits);
411 // Set the value.
412 Val = Literal.getValue();
413 // Set the signedness. UTF-16 and UTF-32 are always unsigned
414 // UTF-8 is unsigned if -fchar8_t is specified.
415 if (Literal.isWide())
416 Val.setIsUnsigned(!TargetInfo::isTypeSigned(TI.getWCharType()));
417 else if (Literal.isUTF16() || Literal.isUTF32())
418 Val.setIsUnsigned(true);
419 else if (Literal.isUTF8()) {
420 if (PP.getLangOpts().CPlusPlus)
421 Val.setIsUnsigned(
422 PP.getLangOpts().Char8 ? true : !PP.getLangOpts().CharIsSigned);
423 else
424 Val.setIsUnsigned(true);
425 } else
426 Val.setIsUnsigned(!PP.getLangOpts().CharIsSigned);
427
428 if (Result.Val.getBitWidth() > Val.getBitWidth()) {
429 Result.Val = Val.extend(Result.Val.getBitWidth());
430 } else {
431 assert(Result.Val.getBitWidth() == Val.getBitWidth() &&
432 "intmax_t smaller than char/wchar_t?");
433 Result.Val = std::move(Val);
434 }
435
436 // Consume the token.
437 Result.setRange(PeekTok.getLocation());
438 PP.LexNonComment(PeekTok);
439 return false;
440 }
441 case tok::l_paren: {
442 SourceLocation Start = PeekTok.getLocation();
443 PP.LexNonComment(PeekTok); // Eat the (.
444 // Parse the value and if there are any binary operators involved, parse
445 // them.
446 if (EvaluateValue(Result, PeekTok, DT, ValueLive, PP)) return true;
447
448 // If this is a silly value like (X), which doesn't need parens, check for
449 // !(defined X).
450 if (PeekTok.is(tok::r_paren)) {
451 // Just use DT unmodified as our result.
452 } else {
453 // Otherwise, we have something like (x+y), and we consumed '(x'.
454 if (EvaluateDirectiveSubExpr(Result, 1, PeekTok, ValueLive,
455 DT.IncludedUndefinedIds, PP))
456 return true;
457
458 if (PeekTok.isNot(tok::r_paren)) {
459 PP.Diag(PeekTok.getLocation(), diag::err_pp_expected_rparen)
460 << Result.getRange();
461 PP.Diag(Start, diag::note_matching) << tok::l_paren;
462 return true;
463 }
465 }
466 Result.setRange(Start, PeekTok.getLocation());
467 Result.setIdentifier(nullptr);
468 PP.LexNonComment(PeekTok); // Eat the ).
469 return false;
470 }
471 case tok::plus: {
472 SourceLocation Start = PeekTok.getLocation();
473 // Unary plus doesn't modify the value.
474 PP.LexNonComment(PeekTok);
475 if (EvaluateValue(Result, PeekTok, DT, ValueLive, PP)) return true;
476 Result.setBegin(Start);
477 Result.setIdentifier(nullptr);
478 return false;
479 }
480 case tok::minus: {
481 SourceLocation Loc = PeekTok.getLocation();
482 PP.LexNonComment(PeekTok);
483 if (EvaluateValue(Result, PeekTok, DT, ValueLive, PP)) return true;
484 Result.setBegin(Loc);
485 Result.setIdentifier(nullptr);
486
487 // C99 6.5.3.3p3: The sign of the result matches the sign of the operand.
488 Result.Val = -Result.Val;
489
490 // -MININT is the only thing that overflows. Unsigned never overflows.
491 bool Overflow = !Result.isUnsigned() && Result.Val.isMinSignedValue();
492
493 // If this operator is live and overflowed, report the issue.
494 if (Overflow && ValueLive)
495 PP.Diag(Loc, diag::warn_pp_expr_overflow) << Result.getRange();
496
498 return false;
499 }
500
501 case tok::tilde: {
502 SourceLocation Start = PeekTok.getLocation();
503 PP.LexNonComment(PeekTok);
504 if (EvaluateValue(Result, PeekTok, DT, ValueLive, PP)) return true;
505 Result.setBegin(Start);
506 Result.setIdentifier(nullptr);
507
508 // C99 6.5.3.3p4: The sign of the result matches the sign of the operand.
509 Result.Val = ~Result.Val;
511 return false;
512 }
513
514 case tok::exclaim: {
515 SourceLocation Start = PeekTok.getLocation();
516 PP.LexNonComment(PeekTok);
517 if (EvaluateValue(Result, PeekTok, DT, ValueLive, PP)) return true;
518 Result.setBegin(Start);
519 Result.Val = !Result.Val;
520 // C99 6.5.3.3p5: The sign of the result is 'int', aka it is signed.
521 Result.Val.setIsUnsigned(false);
522 Result.setIdentifier(nullptr);
523
528 return false;
529 }
530 case tok::kw_true:
531 case tok::kw_false:
532 Result.Val = PeekTok.getKind() == tok::kw_true;
533 Result.Val.setIsUnsigned(false); // "0" is signed intmax_t 0.
534 Result.setIdentifier(PeekTok.getIdentifierInfo());
535 Result.setRange(PeekTok.getLocation());
536 PP.LexNonComment(PeekTok);
537 return false;
538
539 // FIXME: Handle #assert
540 }
541}
542
543/// getPrecedence - Return the precedence of the specified binary operator
544/// token. This returns:
545/// ~0 - Invalid token.
546/// 14 -> 3 - various operators.
547/// 0 - 'eod' or ')'
548static unsigned getPrecedence(tok::TokenKind Kind) {
549 switch (Kind) {
550 default: return ~0U;
551 case tok::percent:
552 case tok::slash:
553 case tok::star: return 14;
554 case tok::plus:
555 case tok::minus: return 13;
556 case tok::lessless:
557 case tok::greatergreater: return 12;
558 case tok::lessequal:
559 case tok::less:
560 case tok::greaterequal:
561 case tok::greater: return 11;
562 case tok::exclaimequal:
563 case tok::equalequal: return 10;
564 case tok::amp: return 9;
565 case tok::caret: return 8;
566 case tok::pipe: return 7;
567 case tok::ampamp: return 6;
568 case tok::pipepipe: return 5;
569 case tok::question: return 4;
570 case tok::comma: return 3;
571 case tok::colon: return 2;
572 case tok::r_paren: return 0;// Lowest priority, end of expr.
573 case tok::eod: return 0;// Lowest priority, end of directive.
574 }
575}
576
577static void diagnoseUnexpectedOperator(Preprocessor &PP, PPValue &LHS,
578 Token &Tok) {
579 if (Tok.is(tok::l_paren) && LHS.getIdentifier())
580 PP.Diag(LHS.getRange().getBegin(), diag::err_pp_expr_bad_token_lparen)
581 << LHS.getIdentifier();
582 else
583 PP.Diag(Tok.getLocation(), diag::err_pp_expr_bad_token_binop)
584 << LHS.getRange();
585}
586
587/// EvaluateDirectiveSubExpr - Evaluate the subexpression whose first token is
588/// PeekTok, and whose precedence is PeekPrec. This returns the result in LHS.
589///
590/// If ValueLive is false, then this value is being evaluated in a context where
591/// the result is not used. As such, avoid diagnostics that relate to
592/// evaluation, such as division by zero warnings.
593static bool EvaluateDirectiveSubExpr(PPValue &LHS, unsigned MinPrec,
594 Token &PeekTok, bool ValueLive,
595 bool &IncludedUndefinedIds,
596 Preprocessor &PP) {
599 IncludedUndefinedIds) {
600 // The single-{file,module}-parse mode behavior kicks in as soon as single
601 // identifier is undefined. If we've already seen one, there's no point in
602 // continuing with the rest of the expression. Besides saving work, this
603 // also prevents calling undefined function-like macros.
604 PP.DiscardUntilEndOfDirective(PeekTok);
605 return true;
606 }
607
608 unsigned PeekPrec = getPrecedence(PeekTok.getKind());
609 // If this token isn't valid, report the error.
610 if (PeekPrec == ~0U) {
611 diagnoseUnexpectedOperator(PP, LHS, PeekTok);
612 return true;
613 }
614
615 while (true) {
616 // If this token has a lower precedence than we are allowed to parse, return
617 // it so that higher levels of the recursion can parse it.
618 if (PeekPrec < MinPrec)
619 return false;
620
621 tok::TokenKind Operator = PeekTok.getKind();
622
623 // If this is a short-circuiting operator, see if the RHS of the operator is
624 // dead. Note that this cannot just clobber ValueLive. Consider
625 // "0 && 1 ? 4 : 1 / 0", which is parsed as "(0 && 1) ? 4 : (1 / 0)". In
626 // this example, the RHS of the && being dead does not make the rest of the
627 // expr dead.
628 bool RHSIsLive;
629 if (Operator == tok::ampamp && LHS.Val == 0)
630 RHSIsLive = false; // RHS of "0 && x" is dead.
631 else if (Operator == tok::pipepipe && LHS.Val != 0)
632 RHSIsLive = false; // RHS of "1 || x" is dead.
633 else if (Operator == tok::question && LHS.Val == 0)
634 RHSIsLive = false; // RHS (x) of "0 ? x : y" is dead.
635 else
636 RHSIsLive = ValueLive;
637
638 // Consume the operator, remembering the operator's location for reporting.
639 SourceLocation OpLoc = PeekTok.getLocation();
640 PP.LexNonComment(PeekTok);
641
642 PPValue RHS(LHS.getBitWidth());
643 // Parse the RHS of the operator.
645 if (EvaluateValue(RHS, PeekTok, DT, RHSIsLive, PP)) return true;
646 IncludedUndefinedIds = DT.IncludedUndefinedIds;
647
648 // Remember the precedence of this operator and get the precedence of the
649 // operator immediately to the right of the RHS.
650 unsigned ThisPrec = PeekPrec;
651 PeekPrec = getPrecedence(PeekTok.getKind());
652
653 // If this token isn't valid, report the error.
654 if (PeekPrec == ~0U) {
655 diagnoseUnexpectedOperator(PP, RHS, PeekTok);
656 return true;
657 }
658
659 // Decide whether to include the next binop in this subexpression. For
660 // example, when parsing x+y*z and looking at '*', we want to recursively
661 // handle y*z as a single subexpression. We do this because the precedence
662 // of * is higher than that of +. The only strange case we have to handle
663 // here is for the ?: operator, where the precedence is actually lower than
664 // the LHS of the '?'. The grammar rule is:
665 //
666 // conditional-expression ::=
667 // logical-OR-expression ? expression : conditional-expression
668 // where 'expression' is actually comma-expression.
669 unsigned RHSPrec;
670 if (Operator == tok::question)
671 // The RHS of "?" should be maximally consumed as an expression.
672 RHSPrec = getPrecedence(tok::comma);
673 else // All others should munch while higher precedence.
674 RHSPrec = ThisPrec+1;
675
676 if (PeekPrec >= RHSPrec) {
677 if (EvaluateDirectiveSubExpr(RHS, RHSPrec, PeekTok, RHSIsLive,
678 IncludedUndefinedIds, PP))
679 return true;
680 PeekPrec = getPrecedence(PeekTok.getKind());
681 }
682 assert(PeekPrec <= ThisPrec && "Recursion didn't work!");
683
684 // Usual arithmetic conversions (C99 6.3.1.8p1): result is unsigned if
685 // either operand is unsigned.
686 llvm::APSInt Res(LHS.getBitWidth());
687 switch (Operator) {
688 case tok::question: // No UAC for x and y in "x ? y : z".
689 case tok::lessless: // Shift amount doesn't UAC with shift value.
690 case tok::greatergreater: // Shift amount doesn't UAC with shift value.
691 case tok::comma: // Comma operands are not subject to UACs.
692 case tok::pipepipe: // Logical || does not do UACs.
693 case tok::ampamp: // Logical && does not do UACs.
694 break; // No UAC
695 default:
696 Res.setIsUnsigned(LHS.isUnsigned() || RHS.isUnsigned());
697 // If this just promoted something from signed to unsigned, and if the
698 // value was negative, warn about it.
699 if (ValueLive && Res.isUnsigned()) {
700 if (!LHS.isUnsigned() && LHS.Val.isNegative())
701 PP.Diag(OpLoc, diag::warn_pp_convert_to_positive) << 0
702 << toString(LHS.Val, 10, true) + " to " +
703 toString(LHS.Val, 10, false)
704 << LHS.getRange() << RHS.getRange();
705 if (!RHS.isUnsigned() && RHS.Val.isNegative())
706 PP.Diag(OpLoc, diag::warn_pp_convert_to_positive) << 1
707 << toString(RHS.Val, 10, true) + " to " +
708 toString(RHS.Val, 10, false)
709 << LHS.getRange() << RHS.getRange();
710 }
711 LHS.Val.setIsUnsigned(Res.isUnsigned());
712 RHS.Val.setIsUnsigned(Res.isUnsigned());
713 }
714
715 bool Overflow = false;
716 switch (Operator) {
717 default: llvm_unreachable("Unknown operator token!");
718 case tok::percent:
719 if (RHS.Val != 0)
720 Res = LHS.Val % RHS.Val;
721 else if (ValueLive) {
722 PP.Diag(OpLoc, diag::err_pp_remainder_by_zero)
723 << LHS.getRange() << RHS.getRange();
724 return true;
725 }
726 break;
727 case tok::slash:
728 if (RHS.Val != 0) {
729 if (LHS.Val.isSigned())
730 Res = llvm::APSInt(LHS.Val.sdiv_ov(RHS.Val, Overflow), false);
731 else
732 Res = LHS.Val / RHS.Val;
733 } else if (ValueLive) {
734 PP.Diag(OpLoc, diag::err_pp_division_by_zero)
735 << LHS.getRange() << RHS.getRange();
736 return true;
737 }
738 break;
739
740 case tok::star:
741 if (Res.isSigned())
742 Res = llvm::APSInt(LHS.Val.smul_ov(RHS.Val, Overflow), false);
743 else
744 Res = LHS.Val * RHS.Val;
745 break;
746 case tok::lessless: {
747 // Determine whether overflow is about to happen.
748 if (LHS.isUnsigned())
749 Res = LHS.Val.ushl_ov(RHS.Val, Overflow);
750 else
751 Res = llvm::APSInt(LHS.Val.sshl_ov(RHS.Val, Overflow), false);
752 break;
753 }
754 case tok::greatergreater: {
755 // Determine whether overflow is about to happen.
756 unsigned ShAmt = static_cast<unsigned>(RHS.Val.getLimitedValue());
757 if (ShAmt >= LHS.getBitWidth()) {
758 Overflow = true;
759 ShAmt = LHS.getBitWidth()-1;
760 }
761 Res = LHS.Val >> ShAmt;
762 break;
763 }
764 case tok::plus:
765 if (LHS.isUnsigned())
766 Res = LHS.Val + RHS.Val;
767 else
768 Res = llvm::APSInt(LHS.Val.sadd_ov(RHS.Val, Overflow), false);
769 break;
770 case tok::minus:
771 if (LHS.isUnsigned())
772 Res = LHS.Val - RHS.Val;
773 else
774 Res = llvm::APSInt(LHS.Val.ssub_ov(RHS.Val, Overflow), false);
775 break;
776 case tok::lessequal:
777 Res = LHS.Val <= RHS.Val;
778 Res.setIsUnsigned(false); // C99 6.5.8p6, result is always int (signed)
779 break;
780 case tok::less:
781 Res = LHS.Val < RHS.Val;
782 Res.setIsUnsigned(false); // C99 6.5.8p6, result is always int (signed)
783 break;
784 case tok::greaterequal:
785 Res = LHS.Val >= RHS.Val;
786 Res.setIsUnsigned(false); // C99 6.5.8p6, result is always int (signed)
787 break;
788 case tok::greater:
789 Res = LHS.Val > RHS.Val;
790 Res.setIsUnsigned(false); // C99 6.5.8p6, result is always int (signed)
791 break;
792 case tok::exclaimequal:
793 Res = LHS.Val != RHS.Val;
794 Res.setIsUnsigned(false); // C99 6.5.9p3, result is always int (signed)
795 break;
796 case tok::equalequal:
797 Res = LHS.Val == RHS.Val;
798 Res.setIsUnsigned(false); // C99 6.5.9p3, result is always int (signed)
799 break;
800 case tok::amp:
801 Res = LHS.Val & RHS.Val;
802 break;
803 case tok::caret:
804 Res = LHS.Val ^ RHS.Val;
805 break;
806 case tok::pipe:
807 Res = LHS.Val | RHS.Val;
808 break;
809 case tok::ampamp:
810 Res = (LHS.Val != 0 && RHS.Val != 0);
811 Res.setIsUnsigned(false); // C99 6.5.13p3, result is always int (signed)
812 break;
813 case tok::pipepipe:
814 Res = (LHS.Val != 0 || RHS.Val != 0);
815 Res.setIsUnsigned(false); // C99 6.5.14p3, result is always int (signed)
816 break;
817 case tok::comma:
818 // Comma is invalid in pp expressions in c89/c++ mode, but is valid in C99
819 // if not being evaluated.
820 if (!PP.getLangOpts().C99 || ValueLive)
821 PP.Diag(OpLoc, diag::ext_pp_comma_expr)
822 << LHS.getRange() << RHS.getRange();
823 Res = RHS.Val; // LHS = LHS,RHS -> RHS.
824 break;
825 case tok::question: {
826 // Parse the : part of the expression.
827 if (PeekTok.isNot(tok::colon)) {
828 PP.Diag(PeekTok.getLocation(), diag::err_expected)
829 << tok::colon << LHS.getRange() << RHS.getRange();
830 PP.Diag(OpLoc, diag::note_matching) << tok::question;
831 return true;
832 }
833 // Consume the :.
834 PP.LexNonComment(PeekTok);
835
836 // Evaluate the value after the :.
837 bool AfterColonLive = ValueLive && LHS.Val == 0;
838 PPValue AfterColonVal(LHS.getBitWidth());
840 if (EvaluateValue(AfterColonVal, PeekTok, DT, AfterColonLive, PP))
841 return true;
842
843 // Parse anything after the : with the same precedence as ?. We allow
844 // things of equal precedence because ?: is right associative.
845 if (EvaluateDirectiveSubExpr(AfterColonVal, ThisPrec,
846 PeekTok, AfterColonLive,
847 IncludedUndefinedIds, PP))
848 return true;
849
850 // Now that we have the condition, the LHS and the RHS of the :, evaluate.
851 Res = LHS.Val != 0 ? RHS.Val : AfterColonVal.Val;
852 RHS.setEnd(AfterColonVal.getRange().getEnd());
853
854 // Usual arithmetic conversions (C99 6.3.1.8p1): result is unsigned if
855 // either operand is unsigned.
856 Res.setIsUnsigned(RHS.isUnsigned() || AfterColonVal.isUnsigned());
857
858 // Figure out the precedence of the token after the : part.
859 PeekPrec = getPrecedence(PeekTok.getKind());
860 break;
861 }
862 case tok::colon:
863 // Don't allow :'s to float around without being part of ?: exprs.
864 PP.Diag(OpLoc, diag::err_pp_colon_without_question)
865 << LHS.getRange() << RHS.getRange();
866 return true;
867 }
868
869 // If this operator is live and overflowed, report the issue.
870 if (Overflow && ValueLive)
871 PP.Diag(OpLoc, diag::warn_pp_expr_overflow)
872 << LHS.getRange() << RHS.getRange();
873
874 // Put the result back into 'LHS' for our next iteration.
875 LHS.Val = Res;
876 LHS.setEnd(RHS.getRange().getEnd());
877 RHS.setIdentifier(nullptr);
878 }
879}
880
881/// EvaluateDirectiveExpression - Evaluate an integer constant expression that
882/// may occur after a #if or #elif directive. If the expression is equivalent
883/// to "!defined(X)" return X in IfNDefMacro.
884Preprocessor::DirectiveEvalResult
885Preprocessor::EvaluateDirectiveExpression(IdentifierInfo *&IfNDefMacro,
886 Token &Tok, bool &EvaluatedDefined,
887 bool CheckForEoD) {
888 SaveAndRestore PPDir(ParsingIfOrElifDirective, true);
889 // Save the current state of 'DisableMacroExpansion' and reset it to false. If
890 // 'DisableMacroExpansion' is true, then we must be in a macro argument list
891 // in which case a directive is undefined behavior. We want macros to be able
892 // to recursively expand in order to get more gcc-list behavior, so we force
893 // DisableMacroExpansion to false and restore it when we're done parsing the
894 // expression.
895 bool DisableMacroExpansionAtStartOfDirective = DisableMacroExpansion;
896 DisableMacroExpansion = false;
897
898 // Peek ahead one token.
900
901 // C99 6.10.1p3 - All expressions are evaluated as intmax_t or uintmax_t.
902 unsigned BitWidth = getTargetInfo().getIntMaxTWidth();
903
904 PPValue ResVal(BitWidth);
905 DefinedTracker DT;
906 SourceLocation ExprStartLoc = SourceMgr.getExpansionLoc(Tok.getLocation());
907 if (EvaluateValue(ResVal, Tok, DT, true, *this)) {
908 // Parse error, skip the rest of the macro line.
909 if (Tok.isNot(tok::eod))
911
912 // Restore 'DisableMacroExpansion'.
913 DisableMacroExpansion = DisableMacroExpansionAtStartOfDirective;
914
915 // We cannot trust the source range from the value because there was a
916 // parse error. Track the range manually -- the end of the directive is the
917 // end of the condition range.
918 return {std::nullopt,
919 false,
921 {ExprStartLoc, Tok.getLocation()}};
922 }
923
924 EvaluatedDefined = DT.State != DefinedTracker::Unknown;
925
926 // If we are at the end of the expression after just parsing a value, there
927 // must be no (unparenthesized) binary operators involved, so we can exit
928 // directly.
929 if (Tok.is(tok::eod)) {
930 // If the expression we parsed was of the form !defined(macro), return the
931 // macro in IfNDefMacro.
933 IfNDefMacro = DT.TheMacro;
934
935 // Restore 'DisableMacroExpansion'.
936 DisableMacroExpansion = DisableMacroExpansionAtStartOfDirective;
937 bool IsNonZero = ResVal.Val != 0;
938 SourceRange ValRange = ResVal.getRange();
939 return {std::move(ResVal.Val), IsNonZero, DT.IncludedUndefinedIds,
940 ValRange};
941 }
942
943 // Otherwise, we must have a binary operator (e.g. "#if 1 < 2"), so parse the
944 // operator and the stuff after it.
945 if (EvaluateDirectiveSubExpr(ResVal, getPrecedence(tok::question),
946 Tok, true, DT.IncludedUndefinedIds, *this)) {
947 // Parse error, skip the rest of the macro line.
948 if (Tok.isNot(tok::eod))
950
951 // Restore 'DisableMacroExpansion'.
952 DisableMacroExpansion = DisableMacroExpansionAtStartOfDirective;
953 return {std::nullopt,
954 false,
956 {ExprStartLoc, Tok.getLocation()}};
957 }
958
959 if (CheckForEoD) {
960 // If we aren't at the tok::eod token, something bad happened, like an extra
961 // ')' token.
962 if (Tok.isNot(tok::eod)) {
963 Diag(Tok, diag::err_pp_expected_eol);
965 }
966 }
967
968 EvaluatedDefined = EvaluatedDefined || DT.State != DefinedTracker::Unknown;
969
970 // Restore 'DisableMacroExpansion'.
971 DisableMacroExpansion = DisableMacroExpansionAtStartOfDirective;
972 bool IsNonZero = ResVal.Val != 0;
973 SourceRange ValRange = ResVal.getRange();
974 return {std::move(ResVal.Val), IsNonZero, DT.IncludedUndefinedIds, ValRange};
975}
976
977Preprocessor::DirectiveEvalResult
978Preprocessor::EvaluateDirectiveExpression(IdentifierInfo *&IfNDefMacro,
979 bool CheckForEoD) {
980 Token Tok;
981 bool EvaluatedDefined;
982 return EvaluateDirectiveExpression(IfNDefMacro, Tok, EvaluatedDefined,
983 CheckForEoD);
984}
985
986static std::optional<CXXStandardLibraryVersionInfo>
989 MacroInfo *Macro = PP.getMacroInfo(MacroName);
990 if (!Macro || Macro->getNumTokens() != 1 || !Macro->isObjectLike())
991 return std::nullopt;
992
993 const Token &RevisionDateTok = Macro->getReplacementToken(0);
994
995 bool Invalid = false;
997 llvm::StringRef RevisionDate =
998 PP.getSpelling(RevisionDateTok, Buffer, &Invalid);
999 if (!Invalid) {
1000 std::uint64_t Value;
1001 // We don't use NumericParser to avoid diagnostics
1002 if (!RevisionDate.consumeInteger(10, Value))
1004 }
1006 0};
1007}
1008
1009std::optional<uint64_t> Preprocessor::getStdLibCxxVersion() {
1010 if (!CXXStandardLibraryVersion)
1011 CXXStandardLibraryVersion = getCXXStandardLibraryVersion(
1012 *this, Ident__GLIBCXX__, CXXStandardLibraryVersionInfo::LibStdCXX);
1013 if (!CXXStandardLibraryVersion)
1014 return std::nullopt;
1015
1016 if (CXXStandardLibraryVersion->Lib ==
1018 return CXXStandardLibraryVersion->Version;
1019 return std::nullopt;
1020}
1021
1022void Preprocessor::setStdLibCxxVersion(std::uint64_t Version) {
1023 CXXStandardLibraryVersion = {
1025 Version,
1026 };
1027}
1028
1030 assert(FixedVersion >= 2000'00'00 && FixedVersion <= 2100'00'00 &&
1031 "invalid value for __GLIBCXX__");
1032 std::optional<std::uint64_t> Ver = getStdLibCxxVersion();
1033 if (!Ver)
1034 return false;
1035 return *Ver < FixedVersion;
1036}
static bool isUnsigned(SValBuilder &SVB, NonLoc Value)
static uint32_t getBitWidth(const Expr *E)
Token Tok
The Token.
Defines the clang::IdentifierInfo, clang::IdentifierTable, and clang::Selector interfaces.
Result
Implement __builtin_bit_cast and related operations.
Defines the clang::MacroInfo and clang::MacroDirective classes.
Defines the PPCallbacks interface.
static bool EvaluateValue(PPValue &Result, Token &PeekTok, DefinedTracker &DT, bool ValueLive, Preprocessor &PP)
EvaluateValue - Evaluate the token PeekTok (and any others needed) and return the computed value in R...
static void diagnoseUnexpectedOperator(Preprocessor &PP, PPValue &LHS, Token &Tok)
static bool EvaluateDirectiveSubExpr(PPValue &LHS, unsigned MinPrec, Token &PeekTok, bool ValueLive, bool &IncludedUndefinedIds, Preprocessor &PP)
EvaluateDirectiveSubExpr - Evaluate the subexpression whose first token is PeekTok,...
static std::optional< CXXStandardLibraryVersionInfo > getCXXStandardLibraryVersion(Preprocessor &PP, IdentifierInfo *MacroName, CXXStandardLibraryVersionInfo::Library Lib)
static unsigned getPrecedence(tok::TokenKind Kind)
getPrecedence - Return the precedence of the specified binary operator token.
static bool EvaluateDefined(PPValue &Result, Token &PeekTok, DefinedTracker &DT, bool ValueLive, Preprocessor &PP)
EvaluateDefined - Process a 'defined(sym)' expression.
static StringRef getIdentifier(const Token &Tok)
Defines the clang::Preprocessor interface.
static std::string toString(const clang::SanitizerSet &Sanitizers)
Produce a string containing comma-separated names of sanitizers in Sanitizers set.
static CharSourceRange getRange(const CharSourceRange &EditRange, const SourceManager &SM, const LangOptions &LangOpts, bool IncludeMacroExpansion)
Defines the clang::SourceLocation class and associated facilities.
Defines the SourceManager interface.
Defines the clang::TokenKind enum and support functions.
CharLiteralParser - Perform interpretation and semantic analysis of a character literal.
void setBegin(SourceLocation b)
virtual void CodeCompleteMacroName(bool IsDefinition)
Callback invoked when performing code completion in a context where the name of a macro is expected.
virtual void CodeCompletePreprocessorExpression()
Callback invoked when performing code completion in a preprocessor expression, such as the condition ...
std::vector< std::string > UndefPrefixes
The list of prefixes from -Wundef-prefix=... used to generate warnings for undefined macros.
Concrete class used by the front-end to report problems and issues.
Definition Diagnostic.h:234
DiagnosticOptions & getDiagnosticOptions() const
Retrieve the diagnostic options.
Definition Diagnostic.h:615
bool isIgnored(unsigned DiagID, SourceLocation Loc) const
Determine whether the diagnostic is known to be ignored.
Definition Diagnostic.h:972
One of these records is kept for each identifier that is lexed.
bool isCPlusPlusOperatorKeyword() const
bool isStr(const char(&Str)[StrLen]) const
Return true if this is the identifier for the specified string.
StringRef getName() const
Return the actual identifier string.
A description of the current definition of a macro.
Definition MacroInfo.h:596
Encapsulates the data about a macro definition (e.g.
Definition MacroInfo.h:40
NumericLiteralParser - This performs strict semantic analysis of the content of a ppnumber,...
This interface provides a way to observe the actions of the preprocessor as it does its thing.
Definition PPCallbacks.h:37
bool SingleFileParseMode
When enabled, preprocessor is in a mode for parsing a single file only.
bool SingleModuleParseMode
When enabled, preprocessor is in a mode for parsing a single module only.
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
void setStdLibCxxVersion(std::uint64_t Version)
PPCallbacks * getPPCallbacks() const
SourceRange DiscardUntilEndOfDirective(SmallVectorImpl< Token > *DiscardedToks=nullptr)
Read and discard all tokens remaining on the current line until the tok::eod token is found.
const MacroInfo * getMacroInfo(const IdentifierInfo *II) const
DiagnosticBuilder DiagCompat(SourceLocation Loc, unsigned CompatDiagID) const
void markMacroAsUsed(MacroInfo *MI)
A macro is used, update information about macros that need unused warnings.
void setCodeCompletionReached()
Note that we hit the code-completion point.
void LexNonComment(Token &Result)
Lex a token.
SourceManager & getSourceManager() const
MacroDefinition getMacroDefinition(const IdentifierInfo *II)
bool CheckMacroName(Token &MacroNameTok, MacroUse isDefineUndef, bool *ShadowFlag=nullptr)
std::optional< std::uint64_t > getStdLibCxxVersion()
const TargetInfo & getTargetInfo() const
void LexUnexpandedNonComment(Token &Result)
Like LexNonComment, but this disables macro expansion of identifier tokens.
StringRef getSpelling(SourceLocation loc, SmallVectorImpl< char > &buffer, bool *invalid=nullptr) const
Return the 'spelling' of the token at the given location; does not go up to the spelling location or ...
void emitMacroExpansionWarnings(const Token &Identifier, bool IsIfnDef=false) const
bool NeedsStdLibCxxWorkaroundBefore(std::uint64_t FixedVersion)
CodeCompletionHandler * getCodeCompletionHandler() const
Retrieve the current code-completion handler.
const PreprocessorOptions & getPreprocessorOpts() const
Retrieve the preprocessor options used to initialize this preprocessor.
const LangOptions & getLangOpts() const
DiagnosticsEngine & getDiagnostics() const
DiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID) const
Forwarding function for diagnostics.
Encodes a location in the source.
bool isValid() const
Return true if this is a valid SourceLocation object.
FileID getFileID(SourceLocation SpellingLoc) const
Return the FileID for a SourceLocation.
const SrcMgr::SLocEntry & getSLocEntry(FileID FID, bool *Invalid=nullptr) const
A trivial tuple used to represent a source range.
const ExpansionInfo & getExpansion() const
Exposes information about the current target.
Definition TargetInfo.h:226
unsigned getChar32Width() const
getChar32Width/Align - Return the size of 'char32_t' for this target, in bits.
Definition TargetInfo.h:776
static bool isTypeSigned(IntType T)
Returns true if the type is signed; false otherwise.
unsigned getChar16Width() const
getChar16Width/Align - Return the size of 'char16_t' for this target, in bits.
Definition TargetInfo.h:771
unsigned getIntWidth() const
getIntWidth/Align - Return the size of 'signed int' and 'unsigned int' for this target,...
Definition TargetInfo.h:536
IntType getWCharType() const
Definition TargetInfo.h:424
unsigned getWCharWidth() const
getWCharWidth/Align - Return the size of 'wchar_t' for this target, in bits.
Definition TargetInfo.h:766
unsigned getIntMaxTWidth() const
Return the size of intmax_t and uintmax_t for this target, in bits.
Definition TargetInfo.h:890
unsigned getCharWidth() const
Definition TargetInfo.h:526
Token - This structure provides full information about a lexed token.
Definition Token.h:36
IdentifierInfo * getIdentifierInfo() const
Definition Token.h:197
SourceLocation getLocation() const
Return a source location identifier for the specified offset in the current file.
Definition Token.h:142
bool is(tok::TokenKind K) const
is/isNot - Predicates to check if this token is a specific kind, as in "if (Tok.is(tok::l_brace)) {....
Definition Token.h:104
tok::TokenKind getKind() const
Definition Token.h:99
bool isNot(tok::TokenKind K) const
Definition Token.h:111
bool hasUDSuffix() const
Return true if this token is a string or character literal which has a ud-suffix.
Definition Token.h:321
Defines the clang::TargetInfo interface.
TokenKind
Provides a simple uniform namespace for tokens from all C languages.
Definition TokenKinds.h:33
Top level wrappers for InstallAPI frontend operations.
DefinedTracker - This struct is used while parsing expressions to keep track of whether !...
TrackerState
Each time a Value is evaluated, it returns information about whether the parsed value is of the form ...
IdentifierInfo * TheMacro
TheMacro - When the state is DefinedMacro or NotDefinedMacro, this indicates the macro that was check...
enum DefinedTracker::TrackerState State