36#include "llvm/ADT/ArrayRef.h"
37#include "llvm/ADT/DenseMap.h"
38#include "llvm/ADT/DenseSet.h"
39#include "llvm/ADT/FoldingSet.h"
40#include "llvm/ADT/STLExtras.h"
41#include "llvm/ADT/SmallString.h"
42#include "llvm/ADT/SmallVector.h"
43#include "llvm/ADT/StringRef.h"
44#include "llvm/ADT/StringSwitch.h"
45#include "llvm/Support/Casting.h"
46#include "llvm/Support/ErrorHandling.h"
47#include "llvm/Support/Format.h"
48#include "llvm/Support/Path.h"
49#include "llvm/Support/raw_ostream.h"
68 auto Pos = CurSubmoduleState->Macros.find(II);
69 return Pos == CurSubmoduleState->Macros.end() ? nullptr
70 : Pos->second.getLatest();
74 assert(MD &&
"MacroDirective should be non-zero!");
75 assert(!MD->
getPrevious() &&
"Already attached to a MacroDirective history.");
77 MacroState &StoredMD = CurSubmoduleState->Macros[II];
78 auto *OldMD = StoredMD.getLatest();
80 StoredMD.setLatest(MD);
81 StoredMD.overrideActiveModuleMacros(*
this, II);
83 if (needModuleMacros()) {
87 PendingModuleMacroNames.push_back(II);
92 if (!MD->
isDefined() && !LeafModuleMacros.contains(II))
111 MacroState &StoredMD = CurSubmoduleState->Macros[II];
113 if (
auto *OldMD = StoredMD.getLatest()) {
119 assert(OldMD->getMacroInfo()->isBuiltinMacro() &&
120 "only built-ins should have an entry here");
121 assert(!OldMD->getPrevious() &&
"builtin should only have a single entry");
123 StoredMD.setLatest(MD);
130 if (!MD->
isDefined() && !LeafModuleMacros.contains(II))
138 llvm::FoldingSetNodeID ID;
142 if (
auto *MM = ModuleMacros.FindNodeOrInsertPos(ID, InsertPos)) {
148 ModuleMacros.InsertNode(MM, InsertPos);
152 for (
auto *O : Overrides) {
153 HidAny |= (O->NumOverriddenBy == 0);
154 ++O->NumOverriddenBy;
158 auto &LeafMacros = LeafModuleMacros[II];
160 llvm::erase_if(LeafMacros,
161 [](
ModuleMacro *MM) {
return MM->NumOverriddenBy != 0; });
165 LeafMacros.push_back(MM);
175 llvm::FoldingSetNodeID ID;
179 return ModuleMacros.FindNodeOrInsertPos(ID, InsertPos);
183 ModuleMacroInfo &Info) {
184 assert(Info.ActiveModuleMacrosGeneration !=
185 CurSubmoduleState->VisibleModules.getGeneration() &&
186 "don't need to update this macro name info");
187 Info.ActiveModuleMacrosGeneration =
188 CurSubmoduleState->VisibleModules.getGeneration();
190 auto Leaf = LeafModuleMacros.find(II);
191 if (Leaf == LeafModuleMacros.end()) {
196 Info.ActiveModuleMacros.clear();
199 llvm::DenseMap<ModuleMacro *, int> NumHiddenOverrides;
200 for (
auto *O : Info.OverriddenMacros)
201 NumHiddenOverrides[O] = -1;
205 for (
auto *LeafMM : Leaf->second) {
206 assert(LeafMM->getNumOverridingMacros() == 0 &&
"leaf macro overridden");
207 if (NumHiddenOverrides.lookup(LeafMM) == 0)
208 Worklist.push_back(LeafMM);
210 while (!Worklist.empty()) {
211 auto *MM = Worklist.pop_back_val();
212 if (CurSubmoduleState->VisibleModules.isVisible(MM->getOwningModule())) {
215 if (MM->getMacroInfo())
216 Info.ActiveModuleMacros.push_back(MM);
218 for (
auto *O : MM->overrides())
219 if ((
unsigned)++NumHiddenOverrides[O] == O->getNumOverridingMacros())
220 Worklist.push_back(O);
224 std::reverse(Info.ActiveModuleMacros.begin(), Info.ActiveModuleMacros.end());
228 bool IsSystemMacro =
true;
229 bool IsAmbiguous =
false;
230 if (
auto *MD = Info.MD) {
231 while (isa_and_nonnull<VisibilityMacroDirective>(MD))
232 MD = MD->getPrevious();
233 if (
auto *DMD = dyn_cast_or_null<DefMacroDirective>(MD)) {
238 for (
auto *Active : Info.ActiveModuleMacros) {
239 auto *NewMI = Active->getMacroInfo();
250 if (MI && NewMI != MI &&
253 IsSystemMacro &= Active->getOwningModule()->IsSystem ||
257 Info.IsAmbiguous = IsAmbiguous && !IsSystemMacro;
262 auto LeafIt = LeafModuleMacros.find(II);
263 if (LeafIt != LeafModuleMacros.end())
264 Leaf = LeafIt->second;
265 const MacroState *State =
nullptr;
266 auto Pos = CurSubmoduleState->Macros.find(II);
267 if (Pos != CurSubmoduleState->Macros.end())
268 State = &Pos->second;
270 llvm::errs() <<
"MacroState " << State <<
" " << II->
getNameStart();
271 if (State && State->isAmbiguous(*
this, II))
272 llvm::errs() <<
" ambiguous";
273 if (State && !State->getOverriddenMacros().empty()) {
274 llvm::errs() <<
" overrides";
275 for (
auto *O : State->getOverriddenMacros())
276 llvm::errs() <<
" " << O->getOwningModule()->getFullModuleName();
278 llvm::errs() <<
"\n";
281 for (
auto *MD = State ? State->getLatest() :
nullptr; MD;
282 MD = MD->getPrevious()) {
288 llvm::DenseSet<ModuleMacro*> Active;
290 State ? State->getActiveModuleMacros(*
this, II) : std::nullopt)
292 llvm::DenseSet<ModuleMacro*>
Visited;
294 while (!Worklist.empty()) {
295 auto *MM = Worklist.pop_back_val();
296 llvm::errs() <<
" ModuleMacro " << MM <<
" "
297 << MM->getOwningModule()->getFullModuleName();
298 if (!MM->getMacroInfo())
299 llvm::errs() <<
" undef";
301 if (Active.count(MM))
302 llvm::errs() <<
" active";
303 else if (!CurSubmoduleState->VisibleModules.isVisible(
304 MM->getOwningModule()))
305 llvm::errs() <<
" hidden";
306 else if (MM->getMacroInfo())
307 llvm::errs() <<
" overridden";
309 if (!MM->overrides().empty()) {
310 llvm::errs() <<
" overrides";
311 for (
auto *O : MM->overrides()) {
312 llvm::errs() <<
" " << O->getOwningModule()->getFullModuleName();
314 Worklist.push_back(O);
317 llvm::errs() <<
"\n";
318 if (
auto *MI = MM->getMacroInfo()) {
321 llvm::errs() <<
"\n";
341void Preprocessor::RegisterBuiltinMacros() {
352 Ident__has_cpp_attribute =
355 Ident__has_cpp_attribute =
nullptr;
367 Ident__identifier =
nullptr;
368 Ident__pragma =
nullptr;
376 Ident__has_constexpr_builtin =
382 Ident__has_c_attribute =
nullptr;
393 Ident__is_target_environment =
395 Ident__is_target_variant_os =
397 Ident__is_target_variant_environment =
405 Ident__MODULE__ =
nullptr;
416 if (!II)
return true;
426 if (ExpansionMI->isEnabled() &&
437 return !llvm::is_contained(MI->
params(), II);
443bool Preprocessor::isNextPPTokenLParen() {
447 Val = CurLexer->isNextPPTokenLParen();
449 Val = CurTokenLexer->isNextTokenLParen();
457 for (
const IncludeStackInfo &Entry : llvm::reverse(IncludeMacroStack)) {
459 Val = Entry.TheLexer->isNextPPTokenLParen();
461 Val = Entry.TheTokenLexer->isNextTokenLParen();
467 if (Entry.ThePPLexer)
517 Args = ReadMacroCallArgumentList(
Identifier, MI, ExpansionEnd);
524 if (!Args)
return true;
526 ++NumFnMacroExpanded;
536 SourceRange ExpansionRange(ExpandLoc, ExpansionEnd);
544 DelayedMacroExpandsCallbacks.push_back(
545 MacroExpandsInfo(
Identifier, M, ExpansionRange));
547 Callbacks->MacroExpands(
Identifier, M, ExpansionRange, Args);
548 if (!DelayedMacroExpandsCallbacks.empty()) {
549 for (
const MacroExpandsInfo &Info : DelayedMacroExpandsCallbacks) {
551 Callbacks->MacroExpands(Info.Tok, Info.MD, Info.Range,
554 DelayedMacroExpandsCallbacks.clear();
578 if (Args) Args->
destroy(*
this);
583 PropagateLineStartLeadingSpaceInfo(
Identifier);
584 ++NumFastMacroExpanded;
594 if (Args) Args->
destroy(*
this);
598 bool isAtStartOfLine =
Identifier.isAtStartOfLine();
599 bool hasLeadingSpace =
Identifier.hasLeadingSpace();
619 if (!NewMI->isEnabled() || NewMI == MI) {
630 ++NumFastMacroExpanded;
651 if (I->is(tok::l_paren)) {
652 Brackets.push_back(
Paren);
653 }
else if (I->is(tok::r_paren)) {
654 if (Brackets.empty() || Brackets.back() ==
Brace)
657 }
else if (I->is(tok::l_brace)) {
658 Brackets.push_back(
Brace);
659 }
else if (I->is(tok::r_brace)) {
660 if (Brackets.empty() || Brackets.back() ==
Paren)
665 return Brackets.empty();
699 bool FoundSeparatorToken =
false;
703 if (I->is(tok::l_brace)) {
705 }
else if (I->is(tok::r_brace)) {
707 if (
Braces == 0 && ClosingBrace ==
E && FoundSeparatorToken)
709 }
else if (I->is(tok::eof)) {
714 FoundSeparatorToken =
true;
715 I->setKind(tok::comma);
723 if (FoundSeparatorToken && ArgStartIterator->is(tok::l_brace)) {
731 if (FoundSeparatorToken) {
733 TempToken.
setKind(tok::l_paren);
734 TempToken.
setLocation(ArgStartIterator->getLocation());
736 NewTokens.push_back(TempToken);
740 NewTokens.insert(NewTokens.end(), ArgStartIterator, I);
743 if (FoundSeparatorToken) {
746 TempToken.
setKind(tok::r_paren);
749 NewTokens.push_back(TempToken);
750 ParenHints.push_back(
SourceRange(ArgStartIterator->getLocation(),
755 NewTokens.push_back(*I);
758 ArgStartIterator = I + 1;
759 FoundSeparatorToken =
false;
764 return !ParenHints.empty() && InitLists.empty();
771MacroArgs *Preprocessor::ReadMacroCallArgumentList(
Token &MacroName,
784 assert(Tok.
is(tok::l_paren) &&
"Error computing l-paren-ness?");
790 bool ContainsCodeCompletionTok =
false;
791 bool FoundElidedComma =
false;
795 unsigned NumActuals = 0;
796 while (Tok.
isNot(tok::r_paren)) {
797 if (ContainsCodeCompletionTok && Tok.
isOneOf(tok::eof, tok::eod))
800 assert(Tok.
isOneOf(tok::l_paren, tok::comma) &&
801 "only expect argument separators here");
803 size_t ArgTokenStart = ArgTokens.size();
808 unsigned NumParens = 0;
815 if (Tok.
isOneOf(tok::eof, tok::eod)) {
816 if (!ContainsCodeCompletionTok) {
817 Diag(MacroName, diag::err_unterm_macro_invoc);
825 auto Toks = std::make_unique<Token[]>(1);
827 EnterTokenStream(std::move(Toks), 1,
true,
false);
829 }
else if (Tok.
is(tok::r_paren)) {
831 if (NumParens-- == 0) {
833 if (!ArgTokens.empty() &&
834 ArgTokens.back().commaAfterElided()) {
835 FoundElidedComma =
true;
839 }
else if (Tok.
is(tok::l_paren)) {
841 }
else if (Tok.
is(tok::comma)) {
852 }
else if (NumParens == 0) {
858 if (NumFixedArgsLeft > 1)
861 }
else if (Tok.
is(tok::comment) && !KeepMacroComments) {
875 }
else if (Tok.
is(tok::code_completion)) {
876 ContainsCodeCompletionTok =
true;
885 ArgTokens.push_back(Tok);
890 if (ArgTokens.empty() && Tok.
getKind() == tok::r_paren)
895 if (!isVariadic && NumFixedArgsLeft == 0 && TooManyArgsLoc.
isInvalid()) {
896 if (ArgTokens.size() != ArgTokenStart)
897 TooManyArgsLoc = ArgTokens[ArgTokenStart].getLocation();
899 TooManyArgsLoc = ArgStartLoc;
906 ? diag::warn_cxx98_compat_empty_fnmacro_arg
907 : diag::ext_empty_fnmacro_arg);
915 ArgTokens.push_back(EOFTok);
917 if (!ContainsCodeCompletionTok && NumFixedArgsLeft != 0)
927 if (!isVariadic && NumActuals > MinArgsExpected &&
928 !ContainsCodeCompletionTok) {
931 Diag(TooManyArgsLoc, diag::err_too_many_args_in_macro_invoc);
941 unsigned FixedNumArgs = 0;
944 ParenHints, InitLists)) {
945 if (!InitLists.empty()) {
948 diag::note_init_list_at_beginning_of_macro_argument);
954 if (FixedNumArgs != MinArgsExpected)
962 ArgTokens.swap(FixedArgTokens);
963 NumActuals = FixedNumArgs;
967 bool isVarargsElided =
false;
969 if (ContainsCodeCompletionTok) {
976 for (; NumActuals < MinArgsExpected; ++NumActuals)
977 ArgTokens.push_back(EOFTok);
980 if (NumActuals < MinArgsExpected) {
982 if (NumActuals == 0 && MinArgsExpected == 1) {
989 }
else if ((FoundElidedComma || MI->
isVariadic()) &&
990 (NumActuals+1 == MinArgsExpected ||
991 (NumActuals == 0 && MinArgsExpected == 2))) {
1005 ID = diag::warn_cxx17_compat_missing_varargs_arg;
1007 ID = diag::ext_cxx_missing_varargs_arg;
1009 ID = diag::warn_c17_compat_missing_varargs_arg;
1011 ID = diag::ext_c_missing_varargs_arg;
1023 isVarargsElided =
true;
1024 }
else if (!ContainsCodeCompletionTok) {
1026 Diag(Tok, diag::err_too_few_args_in_macro_invoc);
1038 ArgTokens.push_back(Tok);
1041 if (NumActuals == 0 && MinArgsExpected == 2)
1042 ArgTokens.push_back(Tok);
1044 }
else if (NumActuals > MinArgsExpected && !MI->
isVariadic() &&
1045 !ContainsCodeCompletionTok) {
1048 Diag(MacroName, diag::err_too_many_args_in_macro_invoc);
1068 size_t newIndex = MacroExpandedTokens.size();
1069 bool cacheNeedsToGrow = tokens.size() >
1070 MacroExpandedTokens.capacity()-MacroExpandedTokens.size();
1071 MacroExpandedTokens.append(tokens.begin(), tokens.end());
1073 if (cacheNeedsToGrow) {
1076 for (
const auto &
Lexer : MacroExpandingLexersStack) {
1079 std::tie(prevLexer, tokIndex) =
Lexer;
1080 prevLexer->Tokens = MacroExpandedTokens.data() + tokIndex;
1084 MacroExpandingLexersStack.push_back(std::make_pair(tokLexer, newIndex));
1085 return MacroExpandedTokens.data() + newIndex;
1088void Preprocessor::removeCachedMacroExpandedTokensOfLastLexer() {
1089 assert(!MacroExpandingLexersStack.empty());
1090 size_t tokIndex = MacroExpandingLexersStack.back().second;
1091 assert(tokIndex < MacroExpandedTokens.size());
1093 MacroExpandedTokens.resize(tokIndex);
1094 MacroExpandingLexersStack.pop_back();
1106 TM = std::gmtime(&TT);
1108 TT = std::time(
nullptr);
1109 TM = std::localtime(&TT);
1112 static const char *
const Months[] = {
1113 "Jan",
"Feb",
"Mar",
"Apr",
"May",
"Jun",
"Jul",
"Aug",
"Sep",
"Oct",
"Nov",
"Dec"
1118 llvm::raw_svector_ostream TmpStream(TmpBuffer);
1120 TmpStream << llvm::format(
"\"%s %2d %4d\"", Months[TM->tm_mon],
1121 TM->tm_mday, TM->tm_year + 1900);
1123 TmpStream <<
"??? ?? ????";
1132 llvm::raw_svector_ostream TmpStream(TmpBuffer);
1134 TmpStream << llvm::format(
"\"%02d:%02d:%02d\"", TM->tm_hour, TM->tm_min,
1137 TmpStream <<
"??:??:??";
1151 if (Feature.starts_with(
"__") && Feature.ends_with(
"__") &&
1152 Feature.size() >= 4)
1153 Feature = Feature.substr(2, Feature.size() - 4);
1155#define FEATURE(Name, Predicate) .Case(#Name, Predicate)
1156 return llvm::StringSwitch<bool>(Feature)
1157#include "clang/Basic/Features.def"
1178 if (Extension.starts_with(
"__") && Extension.ends_with(
"__") &&
1179 Extension.size() >= 4)
1180 Extension = Extension.substr(2, Extension.size() - 4);
1184#define EXTENSION(Name, Predicate) .Case(#Name, Predicate)
1185 return llvm::StringSwitch<bool>(Extension)
1186#include "clang/Basic/Features.def"
1204 PP.
Diag(LParenLoc, diag::err_pp_directive_required) << II;
1206 assert(Tok.
is(tok::identifier));
1215 }
while (Tok.
getKind() == tok::comment);
1218 if (Tok.
isNot(tok::l_paren)) {
1221 PP.
Diag(LParenLoc, diag::err_pp_expected_after) << II << tok::l_paren;
1224 if (Tok.
isNot(tok::header_name))
1233 if (Tok.
isNot(tok::header_name)) {
1251 if (Tok.
isNot(tok::r_paren)) {
1253 << II << tok::r_paren;
1254 PP.
Diag(LParenLoc, diag::note_matching) << tok::l_paren;
1272 nullptr,
nullptr,
nullptr, &KH,
nullptr,
nullptr);
1282 return File.has_value();
1290 Diag(Tok, diag::err_pp_directive_required) << II;
1292 assert(Tok.
is(tok::identifier));
1299 if (Tok.
isNot(tok::l_paren)) {
1300 Diag(Tok, diag::err_pp_expected_after) << II << tok::l_paren;
1312 if (Tok.
isNot(tok::header_name)) {
1318 Token FilenameTok = Tok;
1320 std::optional<LexEmbedParametersResult> Params =
1322 assert((Params || Tok.
is(tok::eod)) &&
1323 "expected success or to be at the end of the directive");
1328 if (Params->UnrecognizedParams > 0)
1331 if (!Tok.
is(tok::r_paren)) {
1333 << II << tok::r_paren;
1334 Diag(LParenLoc, diag::note_matching) << tok::l_paren;
1335 if (Tok.
isNot(tok::eod))
1353 Callbacks->HasEmbed(LParenLoc,
Filename, isAngled, MaybeFileEntry);
1355 if (!MaybeFileEntry)
1358 size_t FileSize = MaybeFileEntry->
getSize();
1361 if (Params->MaybeOffsetParam) {
1362 if (Params->MaybeOffsetParam->Offset > FileSize)
1365 FileSize -= Params->MaybeOffsetParam->Offset;
1370 if (Params->MaybeLimitParam) {
1371 if (Params->MaybeLimitParam->Limit > FileSize)
1374 FileSize = Params->MaybeLimitParam->Limit;
1391 std::tie(Lookup, LookupFromFile) = getIncludeNextStart(Tok);
1403 bool &HasLexedNextTok)> Op) {
1406 if (Tok.
isNot(tok::l_paren)) {
1411 if (!Tok.
isOneOf(tok::eof, tok::eod)) {
1413 Tok.
setKind(tok::numeric_constant);
1418 unsigned ParenDepth = 1;
1420 std::optional<int>
Result;
1423 bool SuppressDiagnostic =
false;
1441 if (!SuppressDiagnostic) {
1443 SuppressDiagnostic =
true;
1451 if (!SuppressDiagnostic) {
1453 SuppressDiagnostic =
true;
1458 if (--ParenDepth > 0)
1471 if (!SuppressDiagnostic)
1474 Tok.
setKind(tok::numeric_constant);
1482 bool HasLexedNextToken =
false;
1483 Result = Op(Tok, HasLexedNextToken);
1485 if (HasLexedNextToken)
1492 if (!SuppressDiagnostic) {
1500 PP.
Diag(LParenLoc, diag::note_matching) << tok::l_paren;
1501 SuppressDiagnostic =
true;
1521 std::string ArchName = II->
getName().lower() +
"--";
1522 llvm::Triple Arch(ArchName);
1523 const llvm::Triple &TT = TI.
getTriple();
1526 if ((Arch.getSubArch() == llvm::Triple::NoSubArch ||
1527 Arch.getSubArch() == TT.getSubArch()) &&
1528 ((TT.getArch() == llvm::Triple::thumb &&
1529 Arch.getArch() == llvm::Triple::arm) ||
1530 (TT.getArch() == llvm::Triple::thumbeb &&
1531 Arch.getArch() == llvm::Triple::armeb)))
1536 return (Arch.getSubArch() == llvm::Triple::NoSubArch ||
1537 Arch.getSubArch() == TT.getSubArch()) &&
1538 Arch.getArch() == TT.getArch();
1543 StringRef VendorName = TI.
getTriple().getVendorName();
1544 if (VendorName.empty())
1545 VendorName =
"unknown";
1546 return VendorName.equals_insensitive(II->
getName());
1551 std::string OSName =
1552 (llvm::Twine(
"unknown-unknown-") + II->
getName().lower()).str();
1553 llvm::Triple OS(OSName);
1554 if (OS.getOS() == llvm::Triple::Darwin) {
1558 return TI.
getTriple().getOS() == OS.getOS();
1564 std::string EnvName = (llvm::Twine(
"---") + II->
getName().lower()).str();
1565 llvm::Triple
Env(EnvName);
1568 if (
Env.getEnvironment() == llvm::Triple::UnknownEnvironment &&
1569 EnvName !=
"---unknown")
1571 return TI.
getTriple().getEnvironment() ==
Env.getEnvironment();
1581 std::string OSName =
1582 (llvm::Twine(
"unknown-unknown-") + II->
getName().lower()).str();
1583 llvm::Triple OS(OSName);
1584 if (OS.getOS() == llvm::Triple::Darwin) {
1586 return VariantTriple->isOSDarwin();
1588 return VariantTriple->getOS() == OS.getOS();
1600 std::string EnvName = (llvm::Twine(
"---") + II->
getName().lower()).str();
1601 llvm::Triple
Env(EnvName);
1602 return VariantTriple->getEnvironment() ==
Env.getEnvironment();
1607#if defined(__sun__) && defined(__svr4__)
1611asm(
"_ZNKSt8time_putIcSt19ostreambuf_iteratorIcSt11char_traitsIcEEE3putES3_"
1612 "RSt8ios_basecPKSt2tmPKcSB_ = "
1613 "_ZNKSt8time_putIcSt19ostreambuf_iteratorIcSt11char_traitsIcEEE3putES3_"
1614 "RSt8ios_basecPK2tmPKcSB_");
1619void Preprocessor::ExpandBuiltinMacro(
Token &Tok) {
1622 assert(II &&
"Can't be a macro without id info!");
1626 if (II == Ident_Pragma)
1627 return Handle_Pragma(Tok);
1628 else if (II == Ident__pragma)
1629 return HandleMicrosoft__pragma(Tok);
1631 ++NumBuiltinMacroExpanded;
1634 llvm::raw_svector_ostream OS(TmpBuffer);
1642 if (II == Ident__LINE__) {
1662 Tok.
setKind(tok::numeric_constant);
1663 }
else if (II == Ident__FILE__ || II == Ident__BASE_FILE__ ||
1664 II == Ident__FILE_NAME__) {
1671 if (II == Ident__BASE_FILE__ && PLoc.
isValid()) {
1687 if (II == Ident__FILE_NAME__) {
1694 OS <<
'"' << FN <<
'"';
1696 Tok.
setKind(tok::string_literal);
1697 }
else if (II == Ident__DATE__) {
1701 Tok.
setKind(tok::string_literal);
1702 Tok.
setLength(strlen(
"\"Mmm dd yyyy\""));
1707 }
else if (II == Ident__TIME__) {
1711 Tok.
setKind(tok::string_literal);
1717 }
else if (II == Ident__INCLUDE_LEVEL__) {
1725 for (; PLoc.
isValid(); ++Depth)
1731 Tok.
setKind(tok::numeric_constant);
1732 }
else if (II == Ident__TIMESTAMP__) {
1737 std::stringstream TmpStream;
1738 TmpStream.imbue(std::locale(
"C"));
1741 std::tm *TM = std::gmtime(&TT);
1742 TmpStream << std::put_time(TM,
"%a %b %e %T %Y");
1751 struct tm *TM = localtime(&TT);
1752 TmpStream << std::put_time(TM,
"%a %b %e %T %Y");
1755 Result = TmpStream.str();
1757 Result =
"??? ??? ?? ??:??:?? ????";
1758 OS <<
'"' <<
Result <<
'"';
1759 Tok.
setKind(tok::string_literal);
1760 }
else if (II == Ident__FLT_EVAL_METHOD__) {
1764 Tok.
setKind(tok::numeric_constant);
1768 Diag(Tok, diag::err_illegal_use_of_flt_eval_macro);
1771 }
else if (II == Ident__COUNTER__) {
1773 OS << CounterValue++;
1774 Tok.
setKind(tok::numeric_constant);
1775 }
else if (II == Ident__has_feature) {
1777 [
this](
Token &Tok,
bool &HasLexedNextToken) ->
int {
1779 diag::err_feature_check_malformed);
1782 }
else if (II == Ident__has_extension) {
1784 [
this](
Token &Tok,
bool &HasLexedNextToken) ->
int {
1786 diag::err_feature_check_malformed);
1789 }
else if (II == Ident__has_builtin) {
1791 [
this](
Token &Tok,
bool &HasLexedNextToken) ->
int {
1793 diag::err_feature_check_malformed);
1798 case Builtin::BI__builtin_cpu_is:
1800 case Builtin::BI__builtin_cpu_init:
1802 case Builtin::BI__builtin_cpu_supports:
1804 case Builtin::BI__builtin_operator_new:
1805 case Builtin::BI__builtin_operator_delete:
1815 }
else if (II->
getTokenID() != tok::identifier ||
1824 if (II->
getName().starts_with(
"__builtin_") ||
1825 II->
getName().starts_with(
"__is_") ||
1826 II->
getName().starts_with(
"__has_"))
1828 return llvm::StringSwitch<bool>(II->
getName())
1829 .Case(
"__array_rank",
true)
1830 .Case(
"__array_extent",
true)
1831#define TRANSFORM_TYPE_TRAIT_DEF(_, Trait) .Case("__" #Trait, true)
1832#include "clang/Basic/TransformTypeTraits.def"
1835 return llvm::StringSwitch<bool>(II->
getName())
1842 .Case(
"__is_target_arch",
true)
1843 .Case(
"__is_target_vendor",
true)
1844 .Case(
"__is_target_os",
true)
1845 .Case(
"__is_target_environment",
true)
1846 .Case(
"__is_target_variant_os",
true)
1847 .Case(
"__is_target_variant_environment",
true)
1851 }
else if (II == Ident__has_constexpr_builtin) {
1853 OS, Tok, II, *
this,
false,
1854 [
this](
Token &Tok,
bool &HasLexedNextToken) ->
int {
1856 Tok, *
this, diag::err_feature_check_malformed);
1860 return BuiltinOp != 0 &&
1863 }
else if (II == Ident__is_identifier) {
1865 [](
Token &Tok,
bool &HasLexedNextToken) ->
int {
1866 return Tok.
is(tok::identifier);
1868 }
else if (II == Ident__has_attribute) {
1870 [
this](
Token &Tok,
bool &HasLexedNextToken) ->
int {
1872 diag::err_feature_check_malformed);
1877 }
else if (II == Ident__has_declspec) {
1879 [
this](
Token &Tok,
bool &HasLexedNextToken) ->
int {
1881 diag::err_feature_check_malformed);
1884 return LangOpts.DeclSpecKeyword &&
1891 }
else if (II == Ident__has_cpp_attribute ||
1892 II == Ident__has_c_attribute) {
1893 bool IsCXX = II == Ident__has_cpp_attribute;
1895 [&](
Token &Tok,
bool &HasLexedNextToken) ->
int {
1898 Tok, *
this, diag::err_feature_check_malformed);
1905 if (Tok.
isNot(tok::coloncolon))
1906 HasLexedNextToken =
true;
1912 diag::err_feature_check_malformed);
1922 }
else if (II == Ident__has_include ||
1923 II == Ident__has_include_next) {
1928 if (II == Ident__has_include)
1929 Value = EvaluateHasInclude(Tok, II);
1931 Value = EvaluateHasIncludeNext(Tok, II);
1933 if (Tok.
isNot(tok::r_paren))
1936 Tok.
setKind(tok::numeric_constant);
1937 }
else if (II == Ident__has_embed) {
1946 Tok.
setKind(tok::numeric_constant);
1947 OS << static_cast<int>(
Value);
1948 }
else if (II == Ident__has_warning) {
1951 [
this](
Token &Tok,
bool &HasLexedNextToken) ->
int {
1952 std::string WarningName;
1955 HasLexedNextToken = Tok.
is(tok::string_literal);
1962 if (WarningName.size() < 3 || WarningName[0] !=
'-' ||
1963 WarningName[1] !=
'W') {
1964 Diag(StrStartLoc, diag::warn_has_warning_invalid_option);
1975 WarningName.substr(2), Diags);
1977 }
else if (II == Ident__building_module) {
1982 [
this](
Token &Tok,
bool &HasLexedNextToken) ->
int {
1984 diag::err_expected_id_building_module);
1988 }
else if (II == Ident__MODULE__) {
1994 }
else if (II == Ident__identifier) {
2000 if (Tok.
isNot(tok::l_paren)) {
2003 << II << tok::l_paren;
2015 else if (Tok.
is(tok::string_literal) && !Tok.
hasUDSuffix()) {
2034 if (RParen.
isNot(tok::r_paren)) {
2036 << Tok.
getKind() << tok::r_paren;
2037 Diag(LParenLoc, diag::note_matching) << tok::l_paren;
2040 }
else if (II == Ident__is_target_arch) {
2042 OS, Tok, II, *
this,
false,
2043 [
this](
Token &Tok,
bool &HasLexedNextToken) ->
int {
2045 Tok, *
this, diag::err_feature_check_malformed);
2048 }
else if (II == Ident__is_target_vendor) {
2050 OS, Tok, II, *
this,
false,
2051 [
this](
Token &Tok,
bool &HasLexedNextToken) ->
int {
2053 Tok, *
this, diag::err_feature_check_malformed);
2056 }
else if (II == Ident__is_target_os) {
2058 OS, Tok, II, *
this,
false,
2059 [
this](
Token &Tok,
bool &HasLexedNextToken) ->
int {
2061 Tok, *
this, diag::err_feature_check_malformed);
2064 }
else if (II == Ident__is_target_environment) {
2066 OS, Tok, II, *
this,
false,
2067 [
this](
Token &Tok,
bool &HasLexedNextToken) ->
int {
2069 Tok, *
this, diag::err_feature_check_malformed);
2072 }
else if (II == Ident__is_target_variant_os) {
2074 OS, Tok, II, *
this,
false,
2075 [
this](
Token &Tok,
bool &HasLexedNextToken) ->
int {
2077 Tok, *
this, diag::err_feature_check_malformed);
2080 }
else if (II == Ident__is_target_variant_environment) {
2082 OS, Tok, II, *
this,
false,
2083 [
this](
Token &Tok,
bool &HasLexedNextToken) ->
int {
2085 Tok, *
this, diag::err_feature_check_malformed);
2089 llvm_unreachable(
"Unknown identifier!");
2110 llvm::sys::path::remove_dots(
Path,
false,
2111 llvm::sys::path::Style::windows_backslash);
2113 llvm::sys::path::remove_dots(
Path,
false, llvm::sys::path::Style::posix);
2123 StringRef PLFileName = llvm::sys::path::filename(PLoc.
getFilename());
2124 if (PLFileName.empty())
2126 FileName.append(PLFileName.begin(), PLFileName.end());
Defines enum values for all the target-independent builtin functions.
static bool getDiagnosticsInGroup(diag::Flavor Flavor, const WarningOption *Group, SmallVectorImpl< diag::kind > &Diags)
Return true if any diagnostics were found in this group, even if they were filtered out due to having...
Defines the clang::FileManager interface and associated types.
llvm::DenseSet< const void * > Visited
Defines the clang::IdentifierInfo, clang::IdentifierTable, and clang::Selector interfaces.
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
Defines the clang::LangOptions interface.
static DiagnosticBuilder Diag(DiagnosticsEngine *Diags, const LangOptions &Features, FullSourceLoc TokLoc, const char *TokBegin, const char *TokRangeBegin, const char *TokRangeEnd, unsigned DiagID)
Produce a diagnostic highlighting some portion of a literal.
llvm::MachO::FileType FileType
Defines the clang::MacroInfo and clang::MacroDirective classes.
Defines types useful for describing an Objective-C runtime.
static bool HasExtension(const Preprocessor &PP, StringRef Extension)
HasExtension - Return true if we recognize and implement the feature specified by the identifier,...
static bool CheckMatchedBrackets(const SmallVectorImpl< Token > &Tokens)
CheckMatchedBrackets - Returns true if the braces and parentheses in the token vector are properly ne...
static bool EvaluateHasIncludeCommon(Token &Tok, IdentifierInfo *II, Preprocessor &PP, ConstSearchDirIterator LookupFrom, const FileEntry *LookupFromFile)
EvaluateHasIncludeCommon - Process a '__has_include("path")' or '__has_include_next("path")' expressi...
static IdentifierInfo * RegisterBuiltinMacro(Preprocessor &PP, const char *Name)
RegisterBuiltinMacro - Register the specified identifier in the identifier table and mark it as a bui...
static bool GenerateNewArgTokens(Preprocessor &PP, SmallVectorImpl< Token > &OldTokens, SmallVectorImpl< Token > &NewTokens, unsigned &NumArgs, SmallVectorImpl< SourceRange > &ParenHints, SmallVectorImpl< SourceRange > &InitLists)
GenerateNewArgTokens - Returns true if OldTokens can be converted to a new vector of tokens in NewTok...
static bool isTargetVariantOS(const TargetInfo &TI, const IdentifierInfo *II)
Implements the __is_target_variant_os builtin macro.
static bool isTrivialSingleTokenExpansion(const MacroInfo *MI, const IdentifierInfo *MacroIdent, Preprocessor &PP)
isTrivialSingleTokenExpansion - Return true if MI, which has a single token in its expansion,...
static bool isTargetArch(const TargetInfo &TI, const IdentifierInfo *II)
Implements the __is_target_arch builtin macro.
static void ComputeDATE_TIME(SourceLocation &DATELoc, SourceLocation &TIMELoc, Preprocessor &PP)
ComputeDATE_TIME - Compute the current time, enter it into the specified scratch buffer,...
static bool isTargetVariantEnvironment(const TargetInfo &TI, const IdentifierInfo *II)
Implements the __is_target_variant_environment builtin macro.
static bool isTargetEnvironment(const TargetInfo &TI, const IdentifierInfo *II)
Implements the __is_target_environment builtin macro.
static bool isTargetOS(const TargetInfo &TI, const IdentifierInfo *II)
Implements the __is_target_os builtin macro.
static bool isTargetVendor(const TargetInfo &TI, const IdentifierInfo *II)
Implements the __is_target_vendor builtin macro.
static void EvaluateFeatureLikeBuiltinMacro(llvm::raw_svector_ostream &OS, Token &Tok, IdentifierInfo *II, Preprocessor &PP, bool ExpandArgs, llvm::function_ref< int(Token &Tok, bool &HasLexedNextTok)> Op)
Process single-argument builtin feature-like macros that return integer values.
static bool HasFeature(const Preprocessor &PP, StringRef Feature)
HasFeature - Return true if we recognize and implement the feature specified by the identifier as a s...
static IdentifierInfo * ExpectFeatureIdentifierInfo(Token &Tok, Preprocessor &PP, signed DiagID)
Helper function to return the IdentifierInfo structure of a Token or generate a diagnostic if none av...
Defines the PreprocessorLexer interface.
Defines the clang::Preprocessor interface.
Defines the clang::SourceLocation class and associated facilities.
Syntax
The style used to specify an attribute.
@ AS_Declspec
__declspec(...)
bool isConstantEvaluated(unsigned ID) const
Return true if this function can be constant evaluated by Clang frontend.
SourceLocation getEnd() const
virtual void CodeCompleteMacroArgument(IdentifierInfo *Macro, MacroInfo *MacroInfo, unsigned ArgumentIndex)
Callback invoked when performing code completion inside a function-like macro argument.
A little helper class used to produce diagnostics.
diag::Severity getExtensionHandlingBehavior() const
virtual void updateOutOfDateIdentifier(const IdentifierInfo &II)=0
Update an out-of-date identifier.
Cached information about one file (either on disk or in the virtual file system).
time_t getModificationTime() const
static FixItHint CreateInsertion(SourceLocation InsertionLoc, StringRef Code, bool BeforePreviousInsertions=false)
Create a code modification hint that inserts the given code string at a specific location.
One of these records is kept for each identifier that is lexed.
unsigned getBuiltinID() const
Return a value indicating whether this is a builtin function.
tok::TokenKind getTokenID() const
If this is a source-language token (e.g.
bool hadMacroDefinition() const
Returns true if this identifier was #defined to some value at any moment.
bool isFromAST() const
Return true if the identifier in its current state was loaded from an AST file.
bool hasRevertedTokenIDToIdentifier() const
True if revertTokenIDToIdentifier() was called.
const char * getNameStart() const
Return the beginning of the actual null-terminated string for this identifier.
void setHasMacroDefinition(bool Val)
bool isOutOfDate() const
Determine whether the information for this identifier is out of date with respect to the external sou...
void setChangedSinceDeserialization()
Note that this identifier has changed since it was loaded from an AST file.
StringRef getName() const
Return the actual identifier string.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
bool UseTargetPathSeparator
Indicates whether to use target's platform-specific file separator when FILE macro is used and when c...
void remapPathPrefix(SmallVectorImpl< char > &Path) const
Remap path prefix according to -fmacro-prefix-path option.
bool isCompilingModule() const
Are we compiling a module?
std::string CurrentModule
The name of the current module, of which the main source file is a part.
Lexer - This provides a simple interface that turns a text buffer into a stream of tokens.
static std::string Stringify(StringRef Str, bool Charify=false)
Stringify - Convert the specified string into a C string by i) escaping '\' and " characters and ii) ...
MacroArgs - An instance of this class captures information about the formal arguments specified to a ...
static MacroArgs * create(const MacroInfo *MI, ArrayRef< Token > UnexpArgTokens, bool VarargsElided, Preprocessor &PP)
MacroArgs ctor function - Create a new MacroArgs object with the specified macro and argument info.
void destroy(Preprocessor &PP)
destroy - Destroy and deallocate the memory for this object.
A description of the current definition of a macro.
MacroInfo * getMacroInfo() const
Get the MacroInfo that should be used for this definition.
bool isAmbiguous() const
true if the definition is ambiguous, false otherwise.
void forAllDefinitions(Fn F) const
Encapsulates changes to the "macros namespace" (the location where the macro name became active,...
const MacroDirective * getPrevious() const
Get previous definition of the macro with the same name.
void setPrevious(MacroDirective *Prev)
Set previous definition of the macro with the same name.
Encapsulates the data about a macro definition (e.g.
bool isIdenticalTo(const MacroInfo &Other, Preprocessor &PP, bool Syntactically) const
Return true if the specified macro definition is equal to this macro in spelling, arguments,...
bool isUsed() const
Return false if this macro is defined in the main file and has not yet been used.
bool isFunctionLike() const
ArrayRef< const IdentifierInfo * > params() const
unsigned getNumTokens() const
Return the number of tokens that this macro expands to.
unsigned getNumParams() const
const Token & getReplacementToken(unsigned Tok) const
bool isBuiltinMacro() const
Return true if this macro requires processing before expansion.
SourceLocation getDefinitionLoc() const
Return the location that the macro was defined at.
bool hasCommaPasting() const
bool isObjectLike() const
bool isWarnIfUnused() const
Return true if we should emit a warning if the macro is unused.
bool isEnabled() const
Return true if this macro is enabled.
void setIsUsed(bool Val)
Set the value of the IsUsed flag.
void setIsBuiltinMacro(bool Val=true)
Set or clear the isBuiltinMacro flag.
Represents a macro directive exported by a module.
static ModuleMacro * create(Preprocessor &PP, Module *OwningModule, const IdentifierInfo *II, MacroInfo *Macro, ArrayRef< ModuleMacro * > Overrides)
void Profile(llvm::FoldingSetNodeID &ID) const
Describes a module or submodule.
void ExpandedMacro()
ExpandedMacro - When a macro is expanded with this lexer as the current buffer, this method is called...
This interface provides a way to observe the actions of the preprocessor as it does its thing.
MultipleIncludeOpt MIOpt
A state machine that detects the #ifndef-wrapping a file idiom for the multiple-include optimization.
OptionalFileEntryRef getFileEntry() const
getFileEntry - Return the FileEntry corresponding to this FileID.
std::optional< uint64_t > SourceDateEpoch
If set, the UNIX timestamp specified by SOURCE_DATE_EPOCH.
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
SourceLocation getLastFPEvalPragmaLocation() const
bool FinishLexStringLiteral(Token &Result, std::string &String, const char *DiagnosticTag, bool AllowMacroExpansion)
Complete the lexing of a string literal where the first token has already been lexed (see LexStringLi...
void dumpMacroInfo(const IdentifierInfo *II)
ModuleMacro * addModuleMacro(Module *Mod, IdentifierInfo *II, MacroInfo *Macro, ArrayRef< ModuleMacro * > Overrides, bool &IsNew)
Register an exported macro for a module and identifier.
void setLoadedMacroDirective(IdentifierInfo *II, MacroDirective *ED, MacroDirective *MD)
Set a MacroDirective that was loaded from a PCH file.
OptionalFileEntryRef LookupEmbedFile(StringRef Filename, bool isAngled, bool OpenFile, const FileEntry *LookupFromFile=nullptr)
Given a "Filename" or <Filename> reference, look up the indicated embed resource.
PPCallbacks * getPPCallbacks() const
const MacroInfo * getMacroInfo(const IdentifierInfo *II) const
void CreateString(StringRef Str, Token &Tok, SourceLocation ExpansionLocStart=SourceLocation(), SourceLocation ExpansionLocEnd=SourceLocation())
Plop the specified string into a scratch buffer and set the specified token's location and length to ...
void markMacroAsUsed(MacroInfo *MI)
A macro is used, update information about macros that need unused warnings.
MacroDirective * getLocalMacroDirectiveHistory(const IdentifierInfo *II) const
Given an identifier, return the latest non-imported macro directive for that identifier.
void Lex(Token &Result)
Lex the next token for this preprocessor.
bool isParsingIfOrElifDirective() const
True if we are currently preprocessing a if or #elif directive.
void LexNonComment(Token &Result)
Lex a token.
SourceRange DiscardUntilEndOfDirective()
Read and discard all tokens remaining on the current line until the tok::eod token is found.
IdentifierInfo * getIdentifierInfo(StringRef Name) const
Return information about the specified preprocessor identifier token.
SourceLocation AdvanceToTokenCharacter(SourceLocation TokStart, unsigned Char) const
Given a location that specifies the start of a token, return a new location that specifies a characte...
static void processPathToFileName(SmallVectorImpl< char > &FileName, const PresumedLoc &PLoc, const LangOptions &LangOpts, const TargetInfo &TI)
const TargetInfo & getTargetInfo() const
bool LexHeaderName(Token &Result, bool AllowMacroExpansion=true)
Lex a token, forming a header-name token if possible.
PreprocessorOptions & getPreprocessorOpts() const
Retrieve the preprocessor options used to initialize this preprocessor.
MacroInfo * AllocateMacroInfo(SourceLocation L)
Allocate a new MacroInfo object with the provided SourceLocation.
void LexUnexpandedToken(Token &Result)
Just like Lex, but disables macro expansion of identifier tokens.
ModuleMacro * getModuleMacro(Module *Mod, const IdentifierInfo *II)
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 ...
bool GetIncludeFilenameSpelling(SourceLocation Loc, StringRef &Buffer)
Turn the specified lexer token into a fully checked and spelled filename, e.g.
PreprocessorLexer * getCurrentFileLexer() const
Return the current file lexer being lexed from.
HeaderSearch & getHeaderSearchInfo() const
void emitMacroExpansionWarnings(const Token &Identifier, bool IsIfnDef=false) const
ExternalPreprocessorSource * getExternalSource() const
OptionalFileEntryRef LookupFile(SourceLocation FilenameLoc, StringRef Filename, bool isAngled, ConstSearchDirIterator FromDir, const FileEntry *FromFile, ConstSearchDirIterator *CurDir, SmallVectorImpl< char > *SearchPath, SmallVectorImpl< char > *RelativePath, ModuleMap::KnownHeader *SuggestedModule, bool *IsMapped, bool *IsFrameworkFound, bool SkipCache=false, bool OpenFile=true, bool CacheFailures=true)
Given a "foo" or <foo> reference, look up the indicated file.
Builtin::Context & getBuiltinInfo()
LangOptions::FPEvalMethodKind getTUFPEvalMethod() const
const LangOptions & getLangOpts() const
static void processPathForFileMacro(SmallVectorImpl< char > &Path, const LangOptions &LangOpts, const TargetInfo &TI)
DefMacroDirective * appendDefMacroDirective(IdentifierInfo *II, MacroInfo *MI, SourceLocation Loc)
DiagnosticsEngine & getDiagnostics() const
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Computes the source location just past the end of the token at this source location.
std::optional< LexEmbedParametersResult > LexEmbedParameters(Token &Current, bool ForHasEmbed)
Lex the parameters for an #embed directive, returns nullopt on error.
void EnterMacro(Token &Tok, SourceLocation ILEnd, MacroInfo *Macro, MacroArgs *Args)
Add a Macro to the top of the include stack and start lexing tokens from it instead of the current bu...
DiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID) const
Forwarding function for diagnostics.
void appendMacroDirective(IdentifierInfo *II, MacroDirective *MD)
Add a directive to the macro directive history for this identifier.
Represents an unpacked "presumed" location which can be presented to the user.
const char * getFilename() const
Return the presumed filename of this location.
unsigned getLine() const
Return the presumed line number of this location.
bool isInvalid() const
Return true if this object is invalid or uninitialized.
SourceLocation getIncludeLoc() const
Return the presumed include location of this location.
Encodes a location in the source.
bool isValid() const
Return true if this is a valid SourceLocation object.
PresumedLoc getPresumedLoc(SourceLocation Loc, bool UseLineDirectives=true) const
Returns the "presumed" location of a SourceLocation specifies.
CharSourceRange getExpansionRange(SourceLocation Loc) const
Given a SourceLocation object, return the range of tokens covered by the expansion in the ultimate fi...
bool isInSystemHeader(SourceLocation Loc) const
Returns if a SourceLocation is in a system header.
const FileEntry * getFileEntryForID(FileID FID) const
Returns the FileEntry record for the provided FileID.
SourceLocation createExpansionLoc(SourceLocation SpellingLoc, SourceLocation ExpansionLocStart, SourceLocation ExpansionLocEnd, unsigned Length, bool ExpansionIsTokenRange=true, int LoadedID=0, SourceLocation::UIntTy LoadedOffset=0)
Creates an expansion SLocEntry for a macro use.
A trivial tuple used to represent a source range.
StringLiteralParser - This decodes string escape characters and performs wide string analysis and Tra...
Exposes information about the current target.
virtual bool supportsCpuSupports() const
virtual bool supportsCpuInit() const
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
const llvm::Triple * getDarwinTargetVariantTriple() const
Returns the darwin target variant triple, the variant of the deployment target for which the code is ...
virtual bool supportsCpuIs() const
TokenLexer - This implements a lexer that returns tokens from a macro body or token stream instead of...
Token - This structure provides full information about a lexed token.
IdentifierInfo * getIdentifierInfo() const
unsigned getFlags() const
Return the internal represtation of the flags.
void clearFlag(TokenFlags Flag)
Unset the specified flag.
SourceLocation getLocation() const
Return a source location identifier for the specified offset in the current file.
unsigned getLength() const
void setLength(unsigned Len)
void setKind(tok::TokenKind K)
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)) {....
tok::TokenKind getKind() const
bool isAtStartOfLine() const
isAtStartOfLine - Return true if this token is at the start of a line.
bool hasLeadingSpace() const
Return true if this token has whitespace before it.
void setLocation(SourceLocation L)
bool isOneOf(tok::TokenKind K1, tok::TokenKind K2) const
bool isNot(tok::TokenKind K) const
bool isAnnotation() const
Return true if this is any of tok::annot_* kind tokens.
bool hasUDSuffix() const
Return true if this token is a string or character literal which has a ud-suffix.
void startToken()
Reset all flags to cleared.
void setIdentifierInfo(IdentifierInfo *II)
void setFlagValue(TokenFlags Flag, bool Val)
Set a flag to either true or false.
void setFlag(TokenFlags Flag)
Set the specified flag.
Defines the clang::TargetInfo interface.
bool evaluateRequiredTargetFeatures(llvm::StringRef RequiredFatures, const llvm::StringMap< bool > &TargetFetureMap)
Returns true if the required target features of a builtin function are enabled.
CharacteristicKind
Indicates whether a file or directory holds normal user code, system code, or system code which is im...
uint32_t Literal
Literals are represented as positive integers.
@ Error
Present this diagnostic as an error.
@ WarningOrError
A diagnostic that indicates a problem or potential problem.
The JSON file list parser is used to communicate input to InstallAPI.
@ Result
The result type of a method or function.
int hasAttribute(AttributeCommonInfo::Syntax Syntax, const IdentifierInfo *Scope, const IdentifierInfo *Attr, const TargetInfo &Target, const LangOptions &LangOpts)
Return the version number associated with the attribute if we recognize and implement the attribute s...
@ Braces
New-expression has a C++11 list-initializer.