14#ifndef LLVM_CLANG_LEX_PREPROCESSOR_H
15#define LLVM_CLANG_LEX_PREPROCESSOR_H
36#include "llvm/ADT/APSInt.h"
37#include "llvm/ADT/ArrayRef.h"
38#include "llvm/ADT/DenseMap.h"
39#include "llvm/ADT/FoldingSet.h"
40#include "llvm/ADT/FunctionExtras.h"
41#include "llvm/ADT/PointerUnion.h"
42#include "llvm/ADT/STLExtras.h"
43#include "llvm/ADT/SmallPtrSet.h"
44#include "llvm/ADT/SmallVector.h"
45#include "llvm/ADT/StringRef.h"
46#include "llvm/ADT/TinyPtrVector.h"
47#include "llvm/ADT/iterator_range.h"
48#include "llvm/Support/Allocator.h"
49#include "llvm/Support/Casting.h"
50#include "llvm/Support/Registry.h"
51#include "llvm/Support/TrailingObjects.h"
100 assert(Kind != tok::raw_identifier &&
"Raw identifiers are not supported.");
101 assert(Kind != tok::identifier &&
102 "Identifiers should be created by TokenValue(IdentifierInfo *)");
110 return Tok.getKind() == Kind &&
111 (!II || II ==
Tok.getIdentifierInfo());
148 bool AtPhysicalStartOfLine =
false;
153 : ExportTok(
Tok), AtPhysicalStartOfLine(AtPhysicalStartOfLine) {}
155 bool isValid()
const {
return ExportTok.is(tok::kw_export); }
159 ExportTok.startToken();
160 AtPhysicalStartOfLine =
false;
164class ModuleNameLoc final
165 : llvm::TrailingObjects<ModuleNameLoc, IdentifierLoc> {
166 friend TrailingObjects;
167 unsigned NumIdentifierLocs;
168 unsigned numTrailingObjects(OverloadToken<IdentifierLoc>)
const {
172 ModuleNameLoc(
ModuleIdPath Path) : NumIdentifierLocs(Path.size()) {
173 (void)llvm::copy(Path, getTrailingObjectsNonStrict<IdentifierLoc>());
180 return {getTrailingObjectsNonStrict<IdentifierLoc>(),
189 return Last.getLoc().getLocWithOffset(
190 Last.getIdentifierInfo()->getLength());
208 llvm::unique_function<void(
const clang::Token &)> OnToken;
222 std::unique_ptr<ScratchBuffer> ScratchBuf;
231 llvm::BumpPtrAllocator BP;
288 uint32_t CounterValue = 0;
292 MaxAllowedIncludeStackDepth = 200
296 bool KeepComments : 1;
297 bool KeepMacroComments : 1;
298 bool SuppressIncludeNotFoundError : 1;
301 bool InMacroArgs : 1;
304 bool OwnsHeaderSearch : 1;
307 bool DisableMacroExpansion : 1;
311 bool MacroExpansionInDirectivesOverride : 1;
313 class ResetMacroExpansionHelper;
316 mutable bool ReadMacrosFromExternalSource : 1;
319 bool PragmasEnabled : 1;
322 bool PreprocessedOutput : 1;
325 bool ParsingIfOrElifDirective;
328 bool InMacroArgPreExpansion;
346 std::unique_ptr<Builtin::Context> BuiltinInfo;
350 std::unique_ptr<PragmaNamespace> PragmaHandlers;
354 std::unique_ptr<PragmaNamespace> PragmaHandlersBackup;
358 std::vector<CommentHandler *> CommentHandlers;
364 bool IncrementalProcessing =
false;
382 const FileEntry *CodeCompletionFile =
nullptr;
385 unsigned CodeCompletionOffset = 0;
405 llvm::DenseMap<FileID, SmallVector<const char *>> CheckPoints;
406 unsigned CheckPointCounter = 0;
409 bool IsAtImport =
false;
412 bool LastTokenWasAt =
false;
415 bool ImportingCXXNamedModules =
false;
429 class StdCXXImportSeq {
434 AfterTopLevelTokenSeq = -1,
439 StdCXXImportSeq(State S) : S(S) {}
442 void handleOpenBracket() {
443 S =
static_cast<State
>(std::max<int>(S, 0) + 1);
446 void handleCloseBracket() {
447 S =
static_cast<State
>(std::max<int>(S, 1) - 1);
450 void handleCloseBrace() {
451 handleCloseBracket();
452 if (S == AtTopLevel && !AfterHeaderName)
453 S = AfterTopLevelTokenSeq;
458 S = AfterTopLevelTokenSeq;
459 AfterHeaderName =
false;
464 void handleExport() {
465 if (S == AfterTopLevelTokenSeq)
471 void handleImport() {
472 if (S == AfterTopLevelTokenSeq || S == AfterExport)
480 void handleHeaderName() {
481 if (S == AfterImportSeq)
482 AfterHeaderName =
true;
492 bool atTopLevel() {
return S <= 0; }
493 bool afterImportSeq() {
return S == AfterImportSeq; }
494 bool afterTopLevelSeq() {
return S == AfterTopLevelTokenSeq; }
501 bool AfterHeaderName =
false;
505 StdCXXImportSeq StdCXXImportSeqState = StdCXXImportSeq::AfterTopLevelTokenSeq;
510 enum GMFState :
int {
513 BeforeGMFIntroducer = -1,
514 GMFAbsentOrEnded = -2,
517 TrackGMF(GMFState S) : S(S) {}
528 void handleExport() {
530 S = GMFAbsentOrEnded;
534 void handleImport(
bool AfterTopLevelTokenSeq) {
536 if (AfterTopLevelTokenSeq && S == BeforeGMFIntroducer)
537 S = GMFAbsentOrEnded;
541 void handleModule(
bool AfterTopLevelTokenSeq) {
545 if (AfterTopLevelTokenSeq && S == BeforeGMFIntroducer)
548 S = GMFAbsentOrEnded;
555 S = GMFAbsentOrEnded;
558 bool inGMF() {
return S == GMFActive; }
566 TrackGMF TrackGMFState = TrackGMF::BeforeGMFIntroducer;
602 class ModuleDeclSeq {
603 enum ModuleDeclState :
int {
607 ImplementationCandidate,
608 NamedModuleInterface,
609 NamedModuleImplementation,
613 ModuleDeclSeq() =
default;
615 void handleExport() {
616 if (State == NotAModuleDecl)
618 else if (!isNamedModule())
622 void handleModule() {
623 if (State == FoundExport)
624 State = InterfaceCandidate;
625 else if (State == NotAModuleDecl)
626 State = ImplementationCandidate;
627 else if (!isNamedModule())
631 void handleModuleName(ModuleNameLoc *NameLoc) {
632 if (isModuleCandidate() && NameLoc)
633 Name += NameLoc->str();
634 else if (!isNamedModule())
639 if (isModuleCandidate())
641 else if (!isNamedModule())
646 if (!Name.empty() && isModuleCandidate()) {
647 if (State == InterfaceCandidate)
648 State = NamedModuleInterface;
649 else if (State == ImplementationCandidate)
650 State = NamedModuleImplementation;
652 llvm_unreachable(
"Unimaged ModuleDeclState.");
653 }
else if (!isNamedModule())
658 if (!isNamedModule())
662 bool isModuleCandidate()
const {
663 return State == InterfaceCandidate || State == ImplementationCandidate;
666 bool isNamedModule()
const {
667 return State == NamedModuleInterface ||
668 State == NamedModuleImplementation;
671 bool isNamedInterface()
const {
return State == NamedModuleInterface; }
673 bool isImplementationUnit()
const {
674 return State == NamedModuleImplementation && !getName().contains(
':');
677 bool isNotAModuleDecl()
const {
return State == NotAModuleDecl; }
679 StringRef getName()
const {
680 assert(isNamedModule() &&
"Can't get name from a non named module");
684 StringRef getPrimaryName()
const {
685 assert(isNamedModule() &&
"Can't get name from a non named module");
686 return getName().split(
':').first;
691 State = NotAModuleDecl;
695 ModuleDeclState State = NotAModuleDecl;
699 ModuleDeclSeq ModuleDeclState;
703 IdentifierLoc PragmaARCCFCodeAuditedInfo;
707 SourceLocation PragmaAssumeNonNullLoc;
715 SourceLocation PreambleRecordedPragmaAssumeNonNullLoc;
718 bool CodeCompletionReached =
false;
722 IdentifierInfo *CodeCompletionII =
nullptr;
725 SourceRange CodeCompletionTokenRange;
737 std::pair<int, bool> SkipMainFilePreamble;
741 bool HasReachedMaxIncludeDepth =
false;
749 unsigned LexLevel = 0;
752 unsigned TokenCount = 0;
755 bool PreprocessToken =
false;
759 unsigned MaxTokens = 0;
760 SourceLocation MaxTokensOverrideLoc;
784 class PreambleConditionalStackStore {
792 PreambleConditionalStackStore() =
default;
794 void startRecording() { ConditionalStackState = Recording; }
795 void startReplaying() { ConditionalStackState = Replaying; }
796 bool isRecording()
const {
return ConditionalStackState == Recording; }
797 bool isReplaying()
const {
return ConditionalStackState == Replaying; }
799 ArrayRef<PPConditionalInfo> getStack()
const {
800 return ConditionalStack;
803 void doneReplaying() {
804 ConditionalStack.clear();
805 ConditionalStackState = Off;
808 void setStack(ArrayRef<PPConditionalInfo>
s) {
809 if (!isRecording() && !isReplaying())
811 ConditionalStack.clear();
812 ConditionalStack.append(
s.begin(),
s.end());
817 bool reachedEOFWhileSkipping()
const {
return SkipInfo.has_value(); }
819 void clearSkipInfo() { SkipInfo.reset(); }
821 std::optional<PreambleSkipInfo> SkipInfo;
824 SmallVector<PPConditionalInfo, 4> ConditionalStack;
825 State ConditionalStackState = Off;
826 } PreambleConditionalStack;
832 std::unique_ptr<Lexer> CurLexer;
838 SmallVector<std::unique_ptr<Lexer>, 2> PendingDestroyLexers;
844 PreprocessorLexer *CurPPLexer =
nullptr;
856 std::unique_ptr<TokenLexer> CurTokenLexer;
860 LexerCallback CurLexerCallback = &CLK_Lexer;
864 Module *CurLexerSubmodule =
nullptr;
869 struct IncludeStackInfo {
870 LexerCallback CurLexerCallback;
872 std::unique_ptr<Lexer> TheLexer;
873 PreprocessorLexer *ThePPLexer;
874 std::unique_ptr<TokenLexer> TheTokenLexer;
879 IncludeStackInfo(LexerCallback CurLexerCallback,
Module *TheSubmodule,
880 std::unique_ptr<Lexer> &&TheLexer,
881 PreprocessorLexer *ThePPLexer,
882 std::unique_ptr<TokenLexer> &&TheTokenLexer,
884 : CurLexerCallback(std::move(CurLexerCallback)),
885 TheSubmodule(std::move(TheSubmodule)), TheLexer(std::move(TheLexer)),
886 ThePPLexer(std::move(ThePPLexer)),
887 TheTokenLexer(std::move(TheTokenLexer)),
888 TheDirLookup(std::move(TheDirLookup)) {}
890 std::vector<IncludeStackInfo> IncludeMacroStack;
894 std::unique_ptr<PPCallbacks> Callbacks;
896 struct MacroExpandsInfo {
901 MacroExpandsInfo(Token Tok, MacroDefinition MD, SourceRange Range)
902 : Tok(Tok), MD(MD), Range(Range) {}
904 SmallVector<MacroExpandsInfo, 2> DelayedMacroExpandsCallbacks;
907 struct ModuleMacroInfo {
912 llvm::TinyPtrVector<ModuleMacro *> ActiveModuleMacros;
916 unsigned ActiveModuleMacrosGeneration = 0;
919 bool IsAmbiguous =
false;
922 llvm::TinyPtrVector<ModuleMacro *> OverriddenMacros;
924 ModuleMacroInfo(MacroDirective *MD) : MD(MD) {}
929 mutable llvm::PointerUnion<MacroDirective *, ModuleMacroInfo *> State;
932 const IdentifierInfo *II)
const {
933 if (II->isOutOfDate())
934 PP.updateOutOfDateIdentifier(*II);
937 if (!II->hasMacroDefinition() ||
938 (!PP.getLangOpts().Modules &&
939 !PP.getLangOpts().ModulesLocalVisibility) ||
940 !PP.CurSubmoduleState->VisibleModules.getGeneration())
943 auto *Info = dyn_cast_if_present<ModuleMacroInfo *>(State);
945 Info =
new (PP.getPreprocessorAllocator())
950 if (PP.CurSubmoduleState->VisibleModules.getGeneration() !=
951 Info->ActiveModuleMacrosGeneration)
952 PP.updateModuleMacroInfo(II, *Info);
957 MacroState() : MacroState(
nullptr) {}
958 MacroState(MacroDirective *MD) : State(MD) {}
960 MacroState(MacroState &&O) noexcept : State(O.State) {
961 O.State = (MacroDirective *)
nullptr;
964 MacroState &operator=(MacroState &&O)
noexcept {
966 O.State = (MacroDirective *)
nullptr;
972 if (
auto *Info = dyn_cast_if_present<ModuleMacroInfo *>(State))
973 Info->~ModuleMacroInfo();
976 MacroDirective *getLatest()
const {
977 if (
auto *Info = dyn_cast_if_present<ModuleMacroInfo *>(State))
982 void setLatest(MacroDirective *MD) {
983 if (
auto *Info = dyn_cast_if_present<ModuleMacroInfo *>(State))
989 bool isAmbiguous(
Preprocessor &PP,
const IdentifierInfo *II)
const {
990 auto *Info = getModuleInfo(PP, II);
991 return Info ? Info->IsAmbiguous :
false;
994 ArrayRef<ModuleMacro *>
995 getActiveModuleMacros(
Preprocessor &PP,
const IdentifierInfo *II)
const {
996 if (
auto *Info = getModuleInfo(PP, II))
997 return Info->ActiveModuleMacros;
1001 MacroDirective::DefInfo findDirectiveAtLoc(SourceLocation Loc,
1002 SourceManager &SourceMgr)
const {
1004 if (
auto *Latest = getLatest())
1005 return Latest->findDirectiveAtLoc(Loc, SourceMgr);
1009 void overrideActiveModuleMacros(
Preprocessor &PP, IdentifierInfo *II) {
1010 if (
auto *Info = getModuleInfo(PP, II)) {
1011 Info->OverriddenMacros.insert(Info->OverriddenMacros.end(),
1012 Info->ActiveModuleMacros.begin(),
1013 Info->ActiveModuleMacros.end());
1014 Info->ActiveModuleMacros.clear();
1015 Info->IsAmbiguous =
false;
1019 ArrayRef<ModuleMacro*> getOverriddenMacros()
const {
1020 if (
auto *Info = dyn_cast_if_present<ModuleMacroInfo *>(State))
1021 return Info->OverriddenMacros;
1026 ArrayRef<ModuleMacro *> Overrides) {
1027 auto *Info = dyn_cast_if_present<ModuleMacroInfo *>(State);
1029 if (Overrides.empty())
1031 Info =
new (PP.getPreprocessorAllocator())
1035 Info->OverriddenMacros.clear();
1036 Info->OverriddenMacros.insert(Info->OverriddenMacros.end(),
1037 Overrides.begin(), Overrides.end());
1038 Info->ActiveModuleMacrosGeneration = 0;
1047 using MacroMap = llvm::DenseMap<const IdentifierInfo *, MacroState>;
1049 struct SubmoduleState;
1052 struct BuildingSubmoduleInfo {
1057 SourceLocation ImportLoc;
1063 SubmoduleState *OuterSubmoduleState;
1066 unsigned OuterPendingModuleMacroNames;
1068 BuildingSubmoduleInfo(
Module *M, SourceLocation ImportLoc,
bool IsPragma,
1069 SubmoduleState *OuterSubmoduleState,
1070 unsigned OuterPendingModuleMacroNames)
1071 : M(M), ImportLoc(ImportLoc), IsPragma(IsPragma),
1072 OuterSubmoduleState(OuterSubmoduleState),
1073 OuterPendingModuleMacroNames(OuterPendingModuleMacroNames) {}
1075 SmallVector<BuildingSubmoduleInfo, 8> BuildingSubmoduleStack;
1078 struct SubmoduleState {
1083 VisibleModuleSet VisibleModules;
1088 std::map<Module *, SubmoduleState> Submodules;
1091 SubmoduleState NullSubmoduleState;
1095 SubmoduleState *CurSubmoduleState;
1102 llvm::SmallSetVector<Module *, 2> AffectingClangModules;
1105 llvm::FoldingSet<ModuleMacro> ModuleMacros;
1108 llvm::SmallVector<IdentifierInfo *, 32> PendingModuleMacroNames;
1112 llvm::DenseMap<const IdentifierInfo *, llvm::TinyPtrVector<ModuleMacro *>>
1123 using WarnUnusedMacroLocsTy = llvm::SmallDenseSet<SourceLocation, 32>;
1124 WarnUnusedMacroLocsTy WarnUnusedMacroLocs;
1130 using MsgLocationPair = std::pair<std::string, SourceLocation>;
1132 struct MacroAnnotationInfo {
1133 SourceLocation Location;
1134 std::string Message;
1137 struct MacroAnnotations {
1138 std::optional<MacroAnnotationInfo> DeprecationInfo;
1139 std::optional<MacroAnnotationInfo> RestrictExpansionInfo;
1140 std::optional<SourceLocation> FinalAnnotationLoc;
1144 llvm::DenseMap<const IdentifierInfo *, MacroAnnotations> AnnotationInfos;
1152 llvm::DenseMap<IdentifierInfo *, std::vector<MacroInfo *>>
1153 PragmaPushMacroInfo;
1156 unsigned NumDirectives = 0;
1157 unsigned NumDefined = 0;
1158 unsigned NumUndefined = 0;
1159 unsigned NumPragma = 0;
1161 unsigned NumElse = 0;
1162 unsigned NumEndif = 0;
1163 unsigned NumEnteredSourceFiles = 0;
1164 unsigned MaxIncludeStackDepth = 0;
1165 unsigned NumMacroExpanded = 0;
1166 unsigned NumFnMacroExpanded = 0;
1167 unsigned NumBuiltinMacroExpanded = 0;
1168 unsigned NumFastMacroExpanded = 0;
1169 unsigned NumTokenPaste = 0;
1170 unsigned NumFastTokenPaste = 0;
1171 unsigned NumSkipped = 0;
1175 std::string Predefines;
1178 FileID PredefinesFileID;
1181 FileID PCHThroughHeaderFileID;
1184 bool SkippingUntilPragmaHdrStop =
false;
1187 bool SkippingUntilPCHThroughHeader =
false;
1190 bool MainFileIsPreprocessedModuleFile =
false;
1194 enum { TokenLexerCacheSize = 8 };
1195 unsigned NumCachedTokenLexers;
1196 std::unique_ptr<TokenLexer> TokenLexerCache[TokenLexerCacheSize];
1204 SmallVector<Token, 16> MacroExpandedTokens;
1205 std::vector<std::pair<TokenLexer *, size_t>> MacroExpandingLexersStack;
1212 PreprocessingRecord *Record =
nullptr;
1215 using CachedTokensTy = SmallVector<Token, 1>;
1219 CachedTokensTy CachedTokens;
1226 CachedTokensTy::size_type CachedLexPos = 0;
1233 std::vector<CachedTokensTy::size_type> BacktrackPositions;
1237 std::vector<std::pair<CachedTokensTy, CachedTokensTy::size_type>>
1238 UnannotatedBacktrackTokens;
1244 bool SkippingExcludedConditionalBlock =
false;
1250 llvm::DenseMap<const char *, unsigned> RecordedSkippedRanges;
1252 void updateOutOfDateIdentifier(
const IdentifierInfo &II)
const;
1255 Preprocessor(
const PreprocessorOptions &PPOpts, DiagnosticsEngine &diags,
1256 const LangOptions &LangOpts, SourceManager &
SM,
1257 HeaderSearch &Headers, ModuleLoader &TheModuleLoader,
1258 IdentifierInfoLookup *IILookup =
nullptr,
1259 bool OwnsHeaderSearch =
false,
1271 const TargetInfo *AuxTarget =
nullptr);
1304 ExternalSource = Source;
1308 return ExternalSource;
1315 return TheModuleLoader.HadFatalFailure;
1321 return NumDirectives;
1326 return ParsingIfOrElifDirective;
1331 this->KeepComments = KeepComments | KeepMacroComments;
1332 this->KeepMacroComments = KeepMacroComments;
1341 SuppressIncludeNotFoundError = Suppress;
1345 return SuppressIncludeNotFoundError;
1351 PreprocessedOutput = IsPreprocessedOutput;
1360 return CurPPLexer == L;
1390 C = std::make_unique<PPChainedCallbacks>(std::move(
C),
1391 std::move(Callbacks));
1392 Callbacks = std::move(
C);
1405 MaxTokensOverrideLoc = Loc;
1414 OnToken = std::move(F);
1418 GetDependencyDirectives = &Get;
1437 auto I = Submodules.find(M);
1438 if (I == Submodules.end())
1440 auto J = I->second.Macros.find(II);
1441 if (J == I->second.Macros.end())
1443 auto *MD = J->second.getLatest();
1444 return MD && MD->isDefined();
1451 MacroState &S = CurSubmoduleState->Macros[II];
1452 auto *MD = S.getLatest();
1453 while (isa_and_nonnull<VisibilityMacroDirective>(MD))
1454 MD = MD->getPrevious();
1456 S.getActiveModuleMacros(*
this, II),
1457 S.isAmbiguous(*
this, II));
1465 MacroState &S = CurSubmoduleState->Macros[II];
1467 if (
auto *MD = S.getLatest())
1471 S.getActiveModuleMacros(*
this, II),
1472 S.isAmbiguous(*
this, II));
1482 if (!MD || MD->getDefinition().isUndefined())
1496 return MD.getMacroInfo();
1533 updateOutOfDateIdentifier(*II);
1534 auto I = LeafModuleMacros.find(II);
1535 if (I != LeafModuleMacros.end())
1542 return BuildingSubmoduleStack;
1554 llvm::iterator_range<macro_iterator>
1555 macros(
bool IncludeExternalMacros =
true)
const {
1558 return llvm::make_range(begin, end);
1566 if (!BuildingSubmoduleStack.empty()) {
1567 if (M != BuildingSubmoduleStack.back().M)
1568 BuildingSubmoduleStack.back().M->AffectingClangModules.insert(M);
1570 AffectingClangModules.insert(M);
1577 return AffectingClangModules;
1583 HeaderInfo.getFileInfo(
File).IsLocallyIncluded =
true;
1584 return IncludedFiles.insert(
File).second;
1589 HeaderInfo.getFileInfo(
File);
1590 return IncludedFiles.count(
File);
1616 return &Identifiers.get(Name);
1656 CodeComplete = &Handler;
1661 return CodeComplete;
1666 CodeComplete =
nullptr;
1679 CodeCompletionII = Filter;
1686 CodeCompletionTokenRange = {Start, End};
1689 return CodeCompletionTokenRange;
1694 if (CodeCompletionII)
1695 return CodeCompletionII->getName();
1769 void EnterTokenStream(
const Token *Toks,
unsigned NumToks,
1770 bool DisableMacroExpansion,
bool OwnsTokens,
1775 bool DisableMacroExpansion,
bool IsReinject) {
1776 EnterTokenStream(Toks.release(), NumToks, DisableMacroExpansion,
true,
1782 EnterTokenStream(Toks.data(), Toks.size(), DisableMacroExpansion,
false,
1810 std::pair<CachedTokensTy::size_type, bool> LastBacktrackPos();
1812 CachedTokensTy PopUnannotatedBacktrackTokens();
1829 return !UnannotatedBacktrackTokens.empty();
1847 return MainFileIsPreprocessedModuleFile;
1854 MainFileIsPreprocessedModuleFile =
true;
1860 bool AllowMacroExpansion =
true,
1861 bool IsPartition =
false);
1873 bool TokAtPhysicalStartOfLine);
1877 assert(FirstPPTokenLoc.isValid() &&
1878 "Did not see the first pp-token in the main file");
1879 return FirstPPTokenLoc;
1884 bool StopUntilEOD =
false);
1886 bool StopUntilEOD =
false);
1889 bool IncludeExports =
true);
1892 return CurSubmoduleState->VisibleModules.getImportLoc(M);
1899 const char *DiagnosticTag,
bool AllowMacroExpansion) {
1900 if (AllowMacroExpansion)
1905 AllowMacroExpansion);
1911 const char *DiagnosticTag,
1912 bool AllowMacroExpansion);
1922 while (
Result.getKind() == tok::comment);
1928 bool OldVal = DisableMacroExpansion;
1929 DisableMacroExpansion =
true;
1934 DisableMacroExpansion = OldVal;
1942 while (
Result.getKind() == tok::comment);
1952 DisableMacroExpansion =
true;
1953 MacroExpansionInDirectivesOverride =
true;
1957 DisableMacroExpansion = MacroExpansionInDirectivesOverride =
false;
1968 assert(LexLevel == 0 &&
"cannot use lookahead while lexing");
1969 if (CachedLexPos + N < CachedTokens.size())
1970 return CachedTokens[CachedLexPos+N];
1972 return PeekAhead(N+1);
1982 "Should only be called when tokens are cached for backtracking");
1983 assert(
signed(CachedLexPos) -
signed(N) >=
1984 signed(LastBacktrackPos().first) &&
1985 "Should revert tokens up to the last backtrack position, not more");
1986 assert(
signed(CachedLexPos) -
signed(N) >= 0 &&
1987 "Corrupted backtrack positions ?");
2001 auto TokCopy = std::make_unique<Token[]>(1);
2003 EnterTokenStream(std::move(TokCopy), 1,
true, IsReinject);
2005 EnterCachingLexMode();
2006 assert(IsReinject &&
"new tokens in the middle of cached stream");
2007 CachedTokens.insert(CachedTokens.begin()+CachedLexPos,
Tok);
2020 assert(
Tok.isAnnotation() &&
"Expected annotation token");
2022 AnnotatePreviousCachedTokens(
Tok);
2028 assert(CachedLexPos != 0);
2029 return CachedTokens[CachedLexPos-1].getLastLoc();
2052 assert(
Tok.isAnnotation() &&
"Expected annotation token");
2054 CachedTokens[CachedLexPos-1] =
Tok;
2059 void *AnnotationVal);
2064 return CurLexerCallback != CLK_Lexer;
2070 assert(
Tok.getIdentifierInfo() &&
"Expected identifier token");
2072 CachedTokens[CachedLexPos-1] =
Tok;
2084 IncrementalProcessing = value;
2118 return CodeCompletionFileLoc;
2128 CodeCompletionReached =
true;
2138 return PragmaARCCFCodeAuditedInfo;
2153 return PragmaAssumeNonNullLoc;
2159 PragmaAssumeNonNullLoc = Loc;
2168 return PreambleRecordedPragmaAssumeNonNullLoc;
2174 PreambleRecordedPragmaAssumeNonNullLoc = Loc;
2188 SkipMainFilePreamble.first = Bytes;
2189 SkipMainFilePreamble.second = StartOfLine;
2196 return Diags->Report(Loc, DiagID);
2200 return Diags->Report(
Tok.getLocation(), DiagID);
2212 bool *invalid =
nullptr)
const {
2241 bool *
Invalid =
nullptr)
const {
2251 bool *
Invalid =
nullptr)
const;
2256 bool IgnoreWhiteSpace =
false) {
2264 bool *
Invalid =
nullptr)
const {
2265 assert((
Tok.is(tok::numeric_constant) ||
Tok.is(tok::binary_data)) &&
2266 Tok.getLength() == 1 &&
"Called on unsupported token");
2267 assert(!
Tok.needsCleaning() &&
"Token can't need cleaning with length 1");
2270 if (
const char *D =
Tok.getLiteralData())
2271 return (
Tok.getKind() == tok::binary_data) ? *D : *D -
'0';
2273 assert(
Tok.is(tok::numeric_constant) &&
"binary data with no data");
2276 return *SourceMgr.getCharacterData(
Tok.getLocation(),
Invalid) -
'0';
2354 unsigned Char)
const {
2364 ++NumFastTokenPaste;
2388 llvm::DenseMap<IdentifierInfo*,unsigned> PoisonReasons;
2402 if(II->isPoisoned()) {
2412 static_assert(
sizeof...(Ts) > 0,
2413 "requires at least one tok::TokenKind specified");
2414 auto NextTokOpt = peekNextPPToken();
2415 return NextTokOpt.has_value() ? NextTokOpt->is(Ks...) :
false;
2422 std::optional<Token> peekNextPPToken()
const;
2428 *Ident___exception_code,
2429 *Ident_GetExceptionCode;
2432 *Ident___exception_info,
2433 *Ident_GetExceptionInfo;
2436 *Ident___abnormal_termination,
2437 *Ident_AbnormalTermination;
2439 const char *getCurLexerEndPos();
2440 void diagnoseMissingHeaderInUmbrellaDir(
const Module &Mod);
2511 "FPEvalMethod should be set either from command line or from the "
2513 return CurrentFPEvalMethod;
2517 return TUFPEvalMethod;
2521 return LastFPEvalPragmaLocation;
2527 "FPEvalMethod should never be set to FEM_UnsetOnCommandLine");
2530 LastFPEvalPragmaLocation = PragmaLoc;
2531 CurrentFPEvalMethod = Val;
2532 TUFPEvalMethod = Val;
2537 "TUPEvalMethod should never be set to FEM_UnsetOnCommandLine");
2538 TUFPEvalMethod = Val;
2555 return ModuleDeclState.isNamedInterface();
2566 return ModuleDeclState.isImplementationUnit();
2572 "Import C++ named modules are only valid for C++20 modules");
2573 return ImportingCXXNamedModules;
2600 bool *IsFrameworkFound,
bool SkipCache =
false,
2601 bool OpenFile =
true,
bool CacheFailures =
true);
2613 const FileEntry *LookupFromFile =
nullptr);
2623 bool *ShadowFlag =
nullptr);
2629 friend void TokenLexer::ExpandFunctionArguments();
2631 void PushIncludeMacroStack() {
2632 assert(CurLexerCallback != CLK_CachingLexer &&
2633 "cannot push a caching lexer");
2634 IncludeMacroStack.emplace_back(CurLexerCallback, CurLexerSubmodule,
2635 std::move(CurLexer), CurPPLexer,
2636 std::move(CurTokenLexer), CurDirLookup);
2637 CurPPLexer =
nullptr;
2640 void PopIncludeMacroStack() {
2642 PendingDestroyLexers.push_back(std::move(CurLexer));
2643 CurLexer = std::move(IncludeMacroStack.back().TheLexer);
2644 CurPPLexer = IncludeMacroStack.back().ThePPLexer;
2645 CurTokenLexer = std::move(IncludeMacroStack.back().TheTokenLexer);
2646 CurDirLookup = IncludeMacroStack.back().TheDirLookup;
2647 CurLexerSubmodule = IncludeMacroStack.back().TheSubmodule;
2648 CurLexerCallback = IncludeMacroStack.back().CurLexerCallback;
2649 IncludeMacroStack.pop_back();
2652 void PropagateLineStartLeadingSpaceInfo(Token &Result);
2656 bool needModuleMacros()
const;
2660 void updateModuleMacroInfo(
const IdentifierInfo *II, ModuleMacroInfo &Info);
2662 DefMacroDirective *AllocateDefMacroDirective(MacroInfo *MI,
2663 SourceLocation Loc);
2664 UndefMacroDirective *AllocateUndefMacroDirective(SourceLocation UndefLoc);
2665 VisibilityMacroDirective *AllocateVisibilityMacroDirective(SourceLocation Loc,
2679 bool *ShadowFlag =
nullptr);
2690 MacroInfo *ReadOptionalMacroParameterListAndBody(
2691 const Token &MacroNameTok,
bool ImmediatelyAfterHeaderGuard);
2697 bool ReadMacroParameterList(MacroInfo *MI, Token& LastTok);
2704 void SuggestTypoedDirective(
const Token &
Tok, StringRef
Directive)
const;
2714 void SkipExcludedConditionalBlock(SourceLocation HashTokenLoc,
2715 SourceLocation IfTokenLoc,
2716 bool FoundNonSkipPortion,
bool FoundElse,
2717 SourceLocation ElseLoc = SourceLocation());
2721 struct DirectiveEvalResult {
2723 std::optional<llvm::APSInt>
Value;
2729 bool IncludedUndefinedIds;
2732 SourceRange ExprRange;
2739 DirectiveEvalResult EvaluateDirectiveExpression(IdentifierInfo *&IfNDefMacro,
2740 bool CheckForEoD =
true);
2748 DirectiveEvalResult EvaluateDirectiveExpression(IdentifierInfo *&IfNDefMacro,
2750 bool &EvaluatedDefined,
2751 bool CheckForEoD =
true);
2762 bool EvaluateHasInclude(Token &
Tok, IdentifierInfo *II);
2767 bool EvaluateHasIncludeNext(Token &
Tok, IdentifierInfo *II);
2770 std::pair<ConstSearchDirIterator, const FileEntry *>
2771 getIncludeNextStart(
const Token &IncludeNextTok)
const;
2775 void RegisterBuiltinPragmas();
2779 IdentifierInfo *RegisterBuiltinMacro(
const char *Name) {
2785 MI->setIsBuiltinMacro();
2791 void RegisterBuiltinMacros();
2796 bool HandleMacroExpandedIdentifier(Token &Identifier,
const MacroDefinition &MD);
2803 Token *cacheMacroExpandedTokens(TokenLexer *tokLexer,
2804 ArrayRef<Token> tokens);
2806 void removeCachedMacroExpandedTokensOfLastLexer();
2810 MacroArgs *ReadMacroCallArgumentList(Token &MacroName, MacroInfo *MI,
2811 SourceLocation &MacroEnd);
2815 void ExpandBuiltinMacro(Token &
Tok);
2820 void Handle_Pragma(Token &
Tok);
2824 void HandleMicrosoft__pragma(Token &
Tok);
2831 void setPredefinesFileID(FileID FID) {
2832 assert(PredefinesFileID.isInvalid() &&
"PredefinesFileID already set!");
2833 PredefinesFileID = FID;
2837 void setPCHThroughHeaderFileID(FileID FID);
2841 static bool IsFileLexer(
const Lexer* L,
const PreprocessorLexer* P) {
2842 return L ? !L->isPragmaLexer() : P !=
nullptr;
2845 static bool IsFileLexer(
const IncludeStackInfo& I) {
2846 return IsFileLexer(I.TheLexer.get(), I.ThePPLexer);
2849 bool IsFileLexer()
const {
2850 return IsFileLexer(CurLexer.get(), CurPPLexer);
2855 std::optional<CXXStandardLibraryVersionInfo> CXXStandardLibraryVersion;
2864 void CachingLex(Token &
Result);
2866 bool InCachingLexMode()
const {
2869 return !CurPPLexer && !CurTokenLexer && !IncludeMacroStack.empty();
2872 void EnterCachingLexMode();
2873 void EnterCachingLexModeUnchecked();
2875 void ExitCachingLexMode() {
2876 if (InCachingLexMode())
2880 const Token &PeekAhead(
unsigned N);
2881 void AnnotatePreviousCachedTokens(
const Token &
Tok);
2887 void HandleLineDirective();
2888 void HandleDigitDirective(Token &
Tok);
2889 void HandleUserDiagnosticDirective(Token &
Tok,
bool isWarning);
2890 void HandleIdentSCCSDirective(Token &
Tok);
2891 void HandleMacroPublicDirective(Token &
Tok);
2892 void HandleMacroPrivateDirective();
2896 struct ImportAction {
2902 SkippedModuleImport,
2905 Module *ModuleForHeader =
nullptr;
2907 ImportAction(ActionKind AK,
Module *Mod =
nullptr)
2908 : Kind(AK), ModuleForHeader(Mod) {
2909 assert((AK == None || Mod || AK == Failure) &&
2910 "no module for module action");
2916 SourceLocation FilenameLoc, CharSourceRange FilenameRange,
2917 const Token &FilenameTok,
bool &IsFrameworkFound,
bool IsImportDecl,
2919 const FileEntry *LookupFromFile, StringRef &LookupFilename,
2920 SmallVectorImpl<char> &RelativePath, SmallVectorImpl<char> &SearchPath,
2921 ModuleMap::KnownHeader &SuggestedModule,
bool isAngled);
2923 void HandleEmbedDirective(SourceLocation HashLoc, Token &
Tok,
2924 const FileEntry *LookupFromFile =
nullptr);
2925 void HandleEmbedDirectiveImpl(SourceLocation HashLoc,
2926 const LexEmbedParametersResult &Params,
2927 StringRef BinaryContents, StringRef
FileName);
2930 void HandleIncludeDirective(SourceLocation HashLoc, Token &
Tok,
2932 const FileEntry *LookupFromFile =
nullptr);
2934 HandleHeaderIncludeOrImport(SourceLocation HashLoc, Token &IncludeTok,
2935 Token &FilenameTok, SourceLocation EndLoc,
2937 const FileEntry *LookupFromFile =
nullptr);
2938 void HandleIncludeNextDirective(SourceLocation HashLoc, Token &
Tok);
2939 void HandleIncludeMacrosDirective(SourceLocation HashLoc, Token &
Tok);
2940 void HandleImportDirective(SourceLocation HashLoc, Token &
Tok);
2941 void HandleMicrosoftImportDirective(Token &
Tok);
2948 const TargetInfo &TargetInfo,
2949 const Module &M, DiagnosticsEngine &Diags);
2972 SourceLocation MLoc);
2975 return PreambleConditionalStack.isRecording();
2979 return PreambleConditionalStack.hasRecordedPreamble();
2983 return PreambleConditionalStack.getStack();
2987 PreambleConditionalStack.setStack(
s);
2992 PreambleConditionalStack.startReplaying();
2993 PreambleConditionalStack.setStack(
s);
2994 PreambleConditionalStack.SkipInfo = SkipInfo;
2998 return PreambleConditionalStack.SkipInfo;
3004 void replayPreambleConditionalStack();
3007 void HandleDefineDirective(
Token &
Tok,
bool ImmediatelyAfterHeaderGuard);
3008 void HandleUndefDirective();
3012 bool isIfndef,
bool ReadAnyTokensBeforeDirective);
3013 void HandleIfDirective(
Token &IfToken,
const Token &HashToken,
3014 bool ReadAnyTokensBeforeDirective);
3015 void HandleEndifDirective(
Token &EndifToken);
3017 void HandleElifFamilyDirective(
Token &ElifToken,
const Token &HashToken,
3046 AnnotationInfos[II].DeprecationInfo =
3047 MacroAnnotationInfo{AnnotationLoc, std::move(Msg)};
3052 AnnotationInfos[II].RestrictExpansionInfo =
3053 MacroAnnotationInfo{AnnotationLoc, std::move(Msg)};
3057 AnnotationInfos[II].FinalAnnotationLoc = AnnotationLoc;
3061 return AnnotationInfos.find(II)->second;
3065 bool IsIfnDef =
false)
const {
3068 emitMacroDeprecationWarning(Identifier);
3071 !SourceMgr.isInMainFile(Identifier.
getLocation()))
3072 emitRestrictExpansionWarning(Identifier);
3076 emitRestrictInfNaNWarning(Identifier, 0);
3078 emitRestrictInfNaNWarning(Identifier, 1);
3092 void emitMacroDeprecationWarning(
const Token &Identifier)
const;
3093 void emitRestrictExpansionWarning(
const Token &Identifier)
const;
3094 void emitFinalMacroWarning(
const Token &Identifier,
bool IsUndef)
const;
3095 void emitRestrictInfNaNWarning(
const Token &Identifier,
3096 unsigned DiagSelection)
const;
3101 bool InSafeBufferOptOutRegion =
false;
3108 using SafeBufferOptOutRegionsTy =
3113 SafeBufferOptOutRegionsTy SafeBufferOptOutMap;
3124 SafeBufferOptOutRegionsTy &
3132 const SafeBufferOptOutRegionsTy *
3140 return &Iter->getSecond();
3142 } LoadedSafeBufferOptOutMap;
3147 bool isSafeBufferOptOut(
const SourceManager&SourceMgr,
const SourceLocation &Loc)
const;
3160 const SourceLocation &Loc);
3183 const SmallVectorImpl<SourceLocation> &SrcLocSeqs);
3193 return P.CurLexer->Lex(
Result);
3196 return P.CurTokenLexer->Lex(
Result);
3203 return P.CurLexer->LexDependencyDirectiveToken(
Result);
3206 return P.LexAfterModuleImport(
Result);
3244extern template class CLANG_TEMPLATE_ABI Registry<clang::PragmaHandler>;
Defines the Diagnostic-related interfaces.
Defines the Diagnostic IDs-related interfaces.
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.
Defines the clang::MacroInfo and clang::MacroDirective classes.
Defines the clang::Module class, which describes a module in the source code.
Defines the PPCallbacks interface.
Defines the clang::SourceLocation class and associated facilities.
Defines the SourceManager interface.
Defines the clang::TokenKind enum and support functions.
VerifyDiagnosticConsumer::Directive Directive
__device__ __2f16 float __ockl_bool s
Holds information about both target-independent and target-specific builtins, allowing easy queries b...
Callback handler that receives notifications when performing code completion within the preprocessor.
A directive for a defined macro or a macro imported from a module.
Functor that returns the dependency directives for a given file.
A little helper class used to produce diagnostics.
Concrete class used by the front-end to report problems and issues.
void setSuppressAllDiagnostics(bool Val)
Suppress all diagnostics, to silence the front end when we know that we don't want any more diagnosti...
A reference to a DirectoryEntry that includes the name of the directory as it was accessed by the Fil...
Cached information about one directory (either on disk or in the virtual file system).
Abstract base class that describes a handler that will receive source ranges for empty lines encounte...
virtual void HandleEmptyline(SourceRange Range)=0
virtual ~EmptylineHandler()
Record the previous 'export' keyword info.
Token getExportTok() const
ExportContextualKeywordInfo()=default
ExportContextualKeywordInfo(const Token &Tok, bool AtPhysicalStartOfLine)
bool isAtPhysicalStartOfLine() const
Abstract interface for external sources of preprocessor information.
A reference to a FileEntry that includes the name of the file as it was accessed by the FileManager's...
Cached information about one file (either on disk or in the virtual file system).
An opaque identifier used by SourceManager which refers to a source file (MemoryBuffer) along with it...
Implements support for file system lookup, file system caching, and directory search management.
One of these records is kept for each identifier that is lexed.
bool hadMacroDefinition() const
Returns true if this identifier was #defined to some value at any moment.
bool hasMacroDefinition() const
Return true if this identifier is #defined to some other value.
bool isDeprecatedMacro() const
bool isOutOfDate() const
Determine whether the information for this identifier is out of date with respect to the external sou...
StringRef getName() const
Return the actual identifier string.
bool isRestrictExpansion() const
A simple pair of identifier info and location.
Implements an efficient mapping from strings to IdentifierInfo nodes.
FPEvalMethodKind
Possible float expression evaluation method choices.
@ FEM_UnsetOnCommandLine
Used only for FE option processing; this is only used to indicate that the user did not specify an ex...
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
static StringRef getImmediateMacroName(SourceLocation Loc, const SourceManager &SM, const LangOptions &LangOpts)
Retrieve the name of the immediate macro expansion.
static bool isAtStartOfMacroExpansion(SourceLocation loc, const SourceManager &SM, const LangOptions &LangOpts, SourceLocation *MacroBegin=nullptr)
Returns true if the given MacroID location points at the first token of the macro expansion.
static SourceLocation AdvanceToTokenCharacter(SourceLocation TokStart, unsigned Characters, const SourceManager &SM, const LangOptions &LangOpts)
AdvanceToTokenCharacter - If the current SourceLocation specifies a location at the start of a token,...
static bool isAtEndOfMacroExpansion(SourceLocation loc, const SourceManager &SM, const LangOptions &LangOpts, SourceLocation *MacroEnd=nullptr)
Returns true if the given MacroID location points at the last token of the macro expansion.
static unsigned getSpelling(const Token &Tok, const char *&Buffer, const SourceManager &SourceMgr, const LangOptions &LangOpts, bool *Invalid=nullptr)
getSpelling - This method is used to get the spelling of a token into a preallocated buffer,...
static bool getRawToken(SourceLocation Loc, Token &Result, const SourceManager &SM, const LangOptions &LangOpts, bool IgnoreWhiteSpace=false)
Relex the token at the specified location.
static SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset, const SourceManager &SM, const LangOptions &LangOpts)
Computes the source location just past the end of the token at this source location.
MacroArgs - An instance of this class captures information about the formal arguments specified to a ...
A description of the current definition of a macro.
const DefMacroDirective * getDirective() const
Encapsulates changes to the "macros namespace" (the location where the macro name became active,...
Encapsulates the data about a macro definition (e.g.
SourceLocation getDefinitionLoc() const
Return the location that the macro was defined at.
Abstract interface for a module loader.
static std::string getFlatNameFromPath(ModuleIdPath Path)
Represents a macro directive exported by a module.
unsigned getNumIdentifierLocs() const
SourceLocation getBeginLoc() const
SourceLocation getEndLoc() const
SourceRange getRange() const
ModuleIdPath getModuleIdPath() const
Describes a module or submodule.
bool isModuleMapModule() const
Consider the following code:
This interface provides a way to observe the actions of the preprocessor as it does its thing.
PragmaHandler - Instances of this interface defined to handle the various pragmas that the language f...
PragmaNamespace - This PragmaHandler subdivides the namespace of pragmas, allowing hierarchical pragm...
A record of the steps taken while preprocessing a source file, including the various preprocessing di...
PreprocessorOptions - This class is used for passing the various options used in preprocessor initial...
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
SourceLocation getLastFPEvalPragmaLocation() const
bool isMacroDefined(const IdentifierInfo *II)
MacroDirective * getLocalMacroDirective(const IdentifierInfo *II) const
Given an identifier, return its latest non-imported MacroDirective if it is #define'd and not #undef'...
bool markIncluded(FileEntryRef File)
Mark the file as included.
void HandlePragmaPushMacro(Token &Tok)
Handle #pragma push_macro.
void FinalizeForModelFile()
Cleanup after model file parsing.
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 HandlePragmaPoison()
HandlePragmaPoison - Handle #pragma GCC poison. PoisonTok is the 'poison'.
void setCodeCompletionHandler(CodeCompletionHandler &Handler)
Set the code completion handler to the given object.
void dumpMacroInfo(const IdentifierInfo *II)
void HandlePragmaSystemHeader(Token &SysHeaderTok)
HandlePragmaSystemHeader - Implement #pragma GCC system_header.
bool creatingPCHWithThroughHeader()
True if creating a PCH with a through header.
void DumpToken(const Token &Tok, bool DumpFlags=false) const
Print the token to stderr, used for debugging.
void MaybeHandlePoisonedIdentifier(Token &Identifier)
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.
MacroDefinition getMacroDefinitionAtLoc(const IdentifierInfo *II, SourceLocation Loc)
void EnterModuleSuffixTokenStream(ArrayRef< Token > Toks)
void markClangModuleAsAffecting(Module *M)
Mark the given clang module as affecting the current clang module or translation unit.
void setPragmaARCCFCodeAuditedInfo(IdentifierInfo *Ident, SourceLocation Loc)
Set the location of the currently-active #pragma clang arc_cf_code_audited begin.
void HandlePragmaModuleBuild(Token &Tok)
void InitializeForModelFile()
Initialize the preprocessor to parse a model 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.
SourceLocation getCodeCompletionLoc() const
Returns the location of the code-completion point.
ArrayRef< ModuleMacro * > getLeafModuleMacros(const IdentifierInfo *II) const
Get the list of leaf (non-overridden) module macros for a name.
bool isIncrementalProcessingEnabled() const
Returns true if incremental processing is enabled.
void EnterToken(const Token &Tok, bool IsReinject)
Enters a token in the token stream to be lexed next.
void IgnorePragmas()
Install empty handlers for all pragmas (making them ignored).
void HandleCXXImportDirective(Token Import)
HandleCXXImportDirective - Handle the C++ modules import directives.
DefMacroDirective * appendDefMacroDirective(IdentifierInfo *II, MacroInfo *MI)
PPCallbacks * getPPCallbacks() const
bool isInNamedInterfaceUnit() const
If we are proprocessing a named interface unit.
ArrayRef< PPConditionalInfo > getPreambleConditionalStack() const
void setPreambleRecordedPragmaAssumeNonNullLoc(SourceLocation Loc)
Record the location of the unterminated #pragma clang assume_nonnull begin in the preamble.
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
ArrayRef< BuildingSubmoduleInfo > getBuildingSubmodules() const
Get the list of submodules that we're currently building.
SourceLocation getCodeCompletionFileLoc() const
Returns the start location of the file of code-completion point.
DiagnosticBuilder Diag(const Token &Tok, unsigned DiagID) const
SourceRange getCodeCompletionTokenRange() const
SourceLocation getModuleImportLoc(Module *M) const
void overrideMaxTokens(unsigned Value, SourceLocation Loc)
void setCodeCompletionTokenRange(const SourceLocation Start, const SourceLocation End)
Set the code completion token range for detecting replacement range later on.
bool isRecordingPreamble() const
void HandleSkippedDirectiveWhileUsingPCH(Token &Result, SourceLocation HashLoc)
Process directives while skipping until the through header or pragma hdrstop is found.
void setRecordedPreambleConditionalStack(ArrayRef< PPConditionalInfo > s)
void enableIncrementalProcessing(bool value=true)
Enables the incremental processing.
bool LexAfterModuleImport(Token &Result)
Lex a token following the 'import' contextual keyword.
void TypoCorrectToken(const Token &Tok)
Update the current token to represent the provided identifier, in order to cache an action performed ...
bool GetSuppressIncludeNotFoundError()
bool isMacroDefinedInLocalModule(const IdentifierInfo *II, Module *M)
Determine whether II is defined as a macro within the module M, if that is a module that we've alread...
void setPragmaAssumeNonNullLoc(SourceLocation Loc)
Set the location of the currently-active #pragma clang assume_nonnull begin.
bool isInPrimaryFile() const
Return true if we're in the top-level file, not in a #include.
macro_iterator macro_begin(bool IncludeExternalMacros=true) 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.
LangOptions::FPEvalMethodKind getCurrentFPEvalMethod() const
void EnterSubmodule(Module *M, SourceLocation ImportLoc, bool ForPragma)
bool isSafeBufferOptOut(const SourceManager &SourceMgr, const SourceLocation &Loc) const
void addMacroDeprecationMsg(const IdentifierInfo *II, std::string Msg, SourceLocation AnnotationLoc)
const char * getCheckPoint(FileID FID, const char *Start) const
Returns a pointer into the given file's buffer that's guaranteed to be between tokens.
void addRestrictExpansionMsg(const IdentifierInfo *II, std::string Msg, SourceLocation AnnotationLoc)
IdentifierInfo * LookUpIdentifierInfo(Token &Identifier) const
Given a tok::raw_identifier token, look up the identifier information for the token and install it in...
MacroDirective * getLocalMacroDirectiveHistory(const IdentifierInfo *II) const
Given an identifier, return the latest non-imported macro directive for that identifier.
void setPreprocessedOutput(bool IsPreprocessedOutput)
Sets whether the preprocessor is responsible for producing output or if it is producing tokens to be ...
void addFinalLoc(const IdentifierInfo *II, SourceLocation AnnotationLoc)
bool IsPreviousCachedToken(const Token &Tok) const
Whether Tok is the most recent token (CachedLexPos - 1) in CachedTokens.
bool SawDateOrTime() const
Returns true if the preprocessor has seen a use of DATE or TIME in the file so far.
const TargetInfo * getAuxTargetInfo() const
void CommitBacktrackedTokens()
Disable the last EnableBacktrackAtThisPos call.
void DumpMacro(const MacroInfo &MI) const
bool HandleEndOfTokenLexer(Token &Result)
Callback invoked when the current TokenLexer hits the end of its token stream.
void setDiagnostics(DiagnosticsEngine &D)
IncludedFilesSet & getIncludedFiles()
Get the set of included files.
void setCodeCompletionReached()
Note that we hit the code-completion point.
bool SetCodeCompletionPoint(FileEntryRef File, unsigned Line, unsigned Column)
Specify the point at which code-completion will be performed.
void AnnotateCachedTokens(const Token &Tok)
We notify the Preprocessor that if it is caching tokens (because backtrack is enabled) it should repl...
bool isPreprocessedOutput() const
Returns true if the preprocessor is responsible for generating output, false if it is producing token...
StringRef getNamedModuleName() const
Get the named module name we're preprocessing.
bool mightHavePendingAnnotationTokens()
Determine whether it's possible for a future call to Lex to produce an annotation token created by a ...
void Lex(Token &Result)
Lex the next token for this preprocessor.
void EnterTokenStream(ArrayRef< Token > Toks, bool DisableMacroExpansion, bool IsReinject)
const TranslationUnitKind TUKind
The kind of translation unit we are processing.
bool EnterSourceFile(FileID FID, ConstSearchDirIterator Dir, SourceLocation Loc, bool IsFirstIncludeOfFile=true)
Add a source file to the top of the include stack and start lexing tokens from it instead of the curr...
bool isParsingIfOrElifDirective() const
True if we are currently preprocessing a if or elif directive.
unsigned getNumDirectives() const
Retrieve the number of Directives that have been processed by the Preprocessor.
bool isInImplementationUnit() const
If we are implementing an implementation module unit.
void addCommentHandler(CommentHandler *Handler)
Add the specified comment handler to the preprocessor.
ModuleLoader & getModuleLoader() const
Retrieve the module loader associated with this preprocessor.
void LexNonComment(Token &Result)
Lex a token.
void removeCommentHandler(CommentHandler *Handler)
Remove the specified comment handler.
PreprocessorLexer * getCurrentLexer() const
Return the current lexer being lexed from.
bool LexOnOffSwitch(tok::OnOffSwitch &Result)
Lex an on-off-switch (C99 6.10.6p2) and verify that it is followed by EOD.
StringRef getCodeCompletionFilter()
Get the code completion token for filtering purposes.
void setMainFileDir(DirectoryEntryRef Dir)
Set the directory in which the main file should be considered to have been found, if it is not a real...
const IdentifierTable & getIdentifierTable() const
void HandlePragmaDependency(Token &DependencyTok)
HandlePragmaDependency - Handle #pragma GCC dependency "foo" blah.
void HandlePoisonedIdentifier(Token &Identifier)
Display reason for poisoned identifier.
void Backtrack()
Make Preprocessor re-lex the tokens that were lexed since EnableBacktrackAtThisPos() was previously c...
bool isCurrentLexer(const PreprocessorLexer *L) const
Return true if we are lexing directly from the specified lexer.
bool HandleIdentifier(Token &Identifier)
Callback invoked when the lexer reads an identifier and has filled in the tokens IdentifierInfo membe...
void addPPCallbacks(std::unique_ptr< PPCallbacks > C)
bool enterOrExitSafeBufferOptOutRegion(bool isEnter, const SourceLocation &Loc)
Alter the state of whether this PP currently is in a "-Wunsafe-buffer-usage" opt-out region.
void IncrementPasteCounter(bool isFast)
Increment the counters for the number of token paste operations performed.
IdentifierLoc getPragmaARCCFCodeAuditedInfo() const
The location of the currently-active #pragma clang arc_cf_code_audited begin.
void EnterMainSourceFile()
Enter the specified FileID as the main source file, which implicitly adds the builtin defines etc.
void setReplayablePreambleConditionalStack(ArrayRef< PPConditionalInfo > s, std::optional< PreambleSkipInfo > SkipInfo)
const Token & LookAhead(unsigned N)
Peeks ahead N tokens and returns that token without consuming any tokens.
friend class VAOptDefinitionContext
const MacroAnnotations & getMacroAnnotations(const IdentifierInfo *II) const
IdentifierInfo * getIdentifierInfo(StringRef Name) const
Return information about the specified preprocessor identifier token.
uint8_t getSpellingOfSingleCharacterNumericConstant(const Token &Tok, bool *Invalid=nullptr) const
Given a Token Tok that is a numeric constant with length 1, return the value of constant as an unsign...
macro_iterator macro_end(bool IncludeExternalMacros=true) const
SourceManager & getSourceManager() const
bool isBacktrackEnabled() const
True if EnableBacktrackAtThisPos() was called and caching of tokens is on.
MacroDefinition getMacroDefinition(const IdentifierInfo *II)
bool CheckMacroName(Token &MacroNameTok, MacroUse isDefineUndef, bool *ShadowFlag=nullptr)
std::optional< PreambleSkipInfo > getPreambleSkipInfo() const
void setPreprocessToken(bool Preprocess)
bool isPreprocessedModuleFile() const
Whether the main file is preprocessed module file.
void SetPoisonReason(IdentifierInfo *II, unsigned DiagID)
Specifies the reason for poisoning an identifier.
void HandlePragmaOnce(Token &OnceTok)
HandlePragmaOnce - Handle #pragma once. OnceTok is the 'once'.
SourceLocation CheckEndOfDirective(StringRef DirType, bool EnableMacros=false, SmallVectorImpl< Token > *ExtraToks=nullptr)
Ensure that the next token is a tok::eod token.
EmptylineHandler * getEmptylineHandler() const
bool getCommentRetentionState() const
bool isMacroDefined(StringRef Id)
static bool checkModuleIsAvailable(const LangOptions &LangOpts, const TargetInfo &TargetInfo, const Module &M, DiagnosticsEngine &Diags)
Check that the given module is available, producing a diagnostic if not.
Module * getCurrentModuleImplementation()
Retrieves the module whose implementation we're current compiling, if any.
void SetMacroExpansionOnlyInDirectives()
Disables macro expansion everywhere except for preprocessor directives.
bool hasRecordedPreamble() const
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...
SourceLocation getPragmaAssumeNonNullLoc() const
The location of the currently-active #pragma clang assume_nonnull begin.
MacroMap::const_iterator macro_iterator
void createPreprocessingRecord()
Create a new preprocessing record, which will keep track of all macro expansions, macro definitions,...
SourceLocation SplitToken(SourceLocation TokLoc, unsigned Length)
Split the first Length characters out of the token starting at TokLoc and return a location pointing ...
bool isUnannotatedBacktrackEnabled() const
True if EnableBacktrackAtThisPos() was called and caching of unannotated tokens is on.
void EnterTokenStream(std::unique_ptr< Token[]> Toks, unsigned NumToks, bool DisableMacroExpansion, bool IsReinject)
void RevertCachedTokens(unsigned N)
When backtracking is enabled and tokens are cached, this allows to revert a specific number of tokens...
Module * getCurrentModule()
Retrieves the module that we're currently building, if any.
std::optional< std::uint64_t > getStdLibCxxVersion()
void RemovePragmaHandler(PragmaHandler *Handler)
bool isPPInSafeBufferOptOutRegion()
unsigned getTokenCount() const
Get the number of tokens processed so far.
unsigned getMaxTokens() const
Get the max number of tokens before issuing a -Wmax-tokens warning.
SourceLocation getMaxTokensOverrideLoc() const
void makeModuleVisible(Module *M, SourceLocation Loc, bool IncludeExports=true)
bool hadModuleLoaderFatalFailure() const
static void processPathToFileName(SmallVectorImpl< char > &FileName, const PresumedLoc &PLoc, const LangOptions &LangOpts, const TargetInfo &TI)
void setCurrentFPEvalMethod(SourceLocation PragmaLoc, LangOptions::FPEvalMethodKind Val)
const TargetInfo & getTargetInfo() const
FileManager & getFileManager() const
bool LexHeaderName(Token &Result, bool AllowMacroExpansion=true)
Lex a token, forming a header-name token if possible.
std::string getSpelling(const Token &Tok, bool *Invalid=nullptr) const
Return the 'spelling' of the Tok token.
bool isPCHThroughHeader(const FileEntry *FE)
Returns true if the FileEntry is the PCH through header.
void DumpLocation(SourceLocation Loc) const
friend class VariadicMacroScopeGuard
Module * getCurrentLexerSubmodule() const
Return the submodule owning the file being lexed.
bool parseSimpleIntegerLiteral(Token &Tok, uint64_t &Value)
Parses a simple integer literal to get its numeric value.
MacroInfo * AllocateMacroInfo(SourceLocation L)
Allocate a new MacroInfo object with the provided SourceLocation.
void setDependencyDirectivesGetter(DependencyDirectivesGetter &Get)
void LexUnexpandedToken(Token &Result)
Just like Lex, but disables macro expansion of identifier tokens.
StringRef getImmediateMacroName(SourceLocation Loc)
Retrieve the name of the immediate macro expansion.
bool creatingPCHWithPragmaHdrStop()
True if creating a PCH with a pragma hdrstop.
bool alreadyIncluded(FileEntryRef File) const
Return true if this header has already been included.
llvm::iterator_range< macro_iterator > macros(bool IncludeExternalMacros=true) const
void Initialize(const TargetInfo &Target, const TargetInfo *AuxTarget=nullptr)
Initialize the preprocessor using information about the target.
FileID getPredefinesFileID() const
Returns the FileID for the preprocessor predefines.
void LexUnexpandedNonComment(Token &Result)
Like LexNonComment, but this disables macro expansion of identifier tokens.
void AddPragmaHandler(StringRef Namespace, PragmaHandler *Handler)
Add the specified pragma handler to this preprocessor.
llvm::BumpPtrAllocator & getPreprocessorAllocator()
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 HandleComment(Token &result, SourceRange Comment)
bool isCodeCompletionEnabled() const
Determine if we are performing code completion.
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
bool setDeserializedSafeBufferOptOutMap(const SmallVectorImpl< SourceLocation > &SrcLocSeqs)
void HandlePragmaPopMacro(Token &Tok)
Handle #pragma pop_macro.
void ReplaceLastTokenWithAnnotation(const Token &Tok)
Replace the last token with an annotation token.
ExternalPreprocessorSource * getExternalSource() const
bool NeedsStdLibCxxWorkaroundBefore(std::uint64_t FixedVersion)
Module * LeaveSubmodule(bool ForPragma)
const std::string & getPredefines() const
Get the predefines for this processor.
void HandleDirective(Token &Result)
Callback invoked when the lexer sees a # token at the start of a line.
SmallVector< SourceLocation, 64 > serializeSafeBufferOptOutMap() const
CodeCompletionHandler * getCodeCompletionHandler() const
Retrieve the current code-completion handler.
void recomputeCurLexerKind()
Recompute the current lexer kind based on the CurLexer/ CurTokenLexer pointers.
void EnterAnnotationToken(SourceRange Range, tok::TokenKind Kind, void *AnnotationVal)
Enter an annotation token into the token stream.
void setTokenWatcher(llvm::unique_function< void(const clang::Token &)> F)
Register a function that would be called on each token in the final expanded token stream.
MacroInfo * getMacroInfo(const IdentifierInfo *II)
void setPredefines(std::string P)
Set the predefines for this Preprocessor.
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.
IdentifierTable & getIdentifierTable()
Builtin::Context & getBuiltinInfo()
void setSkipMainFilePreamble(unsigned Bytes, bool StartOfLine)
Instruct the preprocessor to skip part of the main source file.
const PreprocessorOptions & getPreprocessorOpts() const
Retrieve the preprocessor options used to initialize this preprocessor.
void ReplacePreviousCachedToken(ArrayRef< Token > NewToks)
Replace token in CachedLexPos - 1 in CachedTokens by the tokens in NewToks.
LangOptions::FPEvalMethodKind getTUFPEvalMethod() const
const LangOptions & getLangOpts() const
bool isImportingCXXNamedModules() const
If we're importing a standard C++20 Named Modules.
void setTUFPEvalMethod(LangOptions::FPEvalMethodKind Val)
void CodeCompleteIncludedFile(llvm::StringRef Dir, bool IsAngled)
Hook used by the lexer to invoke the "included file" code completion point.
void SetSuppressIncludeNotFoundError(bool Suppress)
static void processPathForFileMacro(SmallVectorImpl< char > &Path, const LangOptions &LangOpts, const TargetInfo &TI)
llvm::DenseMap< FileID, SafeBufferOptOutRegionsTy > LoadedRegions
bool isInNamedModule() const
If we are preprocessing a named module.
void EnableBacktrackAtThisPos(bool Unannotated=false)
From the point that this method is called, and until CommitBacktrackedTokens() or Backtrack() is call...
void RemoveTopOfLexerStack()
Pop the current lexer/macro exp off the top of the lexer stack.
void PoisonSEHIdentifiers(bool Poison=true)
bool HandleModuleContextualKeyword(Token &Result, bool TokAtPhysicalStartOfLine)
Callback invoked when the lexer sees one of export, import or module token at the start of a line.
bool isAtStartOfMacroExpansion(SourceLocation loc, SourceLocation *MacroBegin=nullptr) const
Returns true if the given MacroID location points at the first token of the macro expansion.
size_t getTotalMemory() const
void setCounterValue(uint32_t V)
void setExternalSource(ExternalPreprocessorSource *Source)
void clearCodeCompletionHandler()
Clear out the code completion handler.
void AddPragmaHandler(PragmaHandler *Handler)
OptionalFileEntryRef getHeaderToIncludeForDiagnostics(SourceLocation IncLoc, SourceLocation MLoc)
We want to produce a diagnostic at location IncLoc concerning an unreachable effect at location MLoc ...
bool isCodeCompletionReached() const
Returns true if code-completion is enabled and we have hit the code-completion point.
IdentifierInfo * ParsePragmaPushOrPopMacro(Token &Tok)
ParsePragmaPushOrPopMacro - Handle parsing of pragma push_macro/pop_macro.
void LexTokensUntilEOF(std::vector< Token > *Tokens=nullptr)
Lex all tokens for this preprocessor until (and excluding) end of file.
bool getRawToken(SourceLocation Loc, Token &Result, bool IgnoreWhiteSpace=false)
Relex the token at the specified location.
bool isNextPPTokenOneOf(Ts... Ks) const
isNextPPTokenOneOf - Check whether the next pp-token is one of the specificed token kind.
bool usingPCHWithPragmaHdrStop()
True if using a PCH with a pragma hdrstop.
void CodeCompleteNaturalLanguage()
Hook used by the lexer to invoke the "natural language" code completion point.
void EndSourceFile()
Inform the preprocessor callbacks that processing is complete.
bool HandleEndOfFile(Token &Result, bool isEndOfMacro=false)
Callback invoked when the lexer hits the end of the current file.
void setPragmasEnabled(bool Enabled)
DefMacroDirective * appendDefMacroDirective(IdentifierInfo *II, MacroInfo *MI, SourceLocation Loc)
void SetCommentRetentionState(bool KeepComments, bool KeepMacroComments)
Control whether the preprocessor retains comments in output.
bool isAtEndOfMacroExpansion(SourceLocation loc, SourceLocation *MacroEnd=nullptr) const
Returns true if the given MacroID location points at the last token of the macro expansion.
SourceLocation getMainFileFirstPPTokenLoc() const
Get the start location of the first pp-token in main file.
void HandlePragmaMark(Token &MarkTok)
bool LexModuleNameContinue(Token &Tok, SourceLocation UseLoc, SmallVectorImpl< Token > &Suffix, SmallVectorImpl< IdentifierLoc > &Path, bool AllowMacroExpansion=true, bool IsPartition=false)
void CollectPPImportSuffix(SmallVectorImpl< Token > &Toks, bool StopUntilEOD=false)
Collect the tokens of a C++20 pp-import-suffix.
bool getPragmasEnabled() const
void HandlePragmaHdrstop(Token &Tok)
void SetEnableMacroExpansion()
PreprocessingRecord * getPreprocessingRecord() const
Retrieve the preprocessing record, or NULL if there is no preprocessing record.
void setEmptylineHandler(EmptylineHandler *Handler)
Set empty line handler.
DiagnosticsEngine & getDiagnostics() const
void HandleCXXModuleDirective(Token Module)
HandleCXXModuleDirective - Handle C++ module declaration directives.
SourceLocation getLastCachedTokenLocation() const
Get the location of the last cached token, suitable for setting the end location of an annotation tok...
bool hasSeenNoTrivialPPDirective() const
Whether we've seen pp-directives which may have changed the preprocessing state.
llvm::DenseSet< const FileEntry * > IncludedFilesSet
unsigned getSpelling(const Token &Tok, const char *&Buffer, bool *Invalid=nullptr) const
Get the spelling of a token into a preallocated buffer, instead of as an std::string.
SelectorTable & getSelectorTable()
void RemovePragmaHandler(StringRef Namespace, PragmaHandler *Handler)
Remove the specific pragma handler from this preprocessor.
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Computes the source location just past the end of the token at this source location.
const llvm::SmallSetVector< Module *, 2 > & getAffectingClangModules() const
Get the set of top-level clang modules that affected preprocessing, but were not imported.
std::optional< LexEmbedParametersResult > LexEmbedParameters(Token &Current, bool ForHasEmbed)
Lex the parameters for an embed directive, returns nullopt on error.
const IncludedFilesSet & getIncludedFiles() const
StringRef getLastMacroWithSpelling(SourceLocation Loc, ArrayRef< TokenValue > Tokens) const
Return the name of the macro defined before Loc that has spelling Tokens.
void HandlePragmaIncludeAlias(Token &Tok)
Module * getModuleForLocation(SourceLocation Loc, bool AllowTextual)
Find the module that owns the source or header file that Loc points to.
uint32_t getCounterValue() const
void setCodeCompletionIdentifierInfo(IdentifierInfo *Filter)
Set the code completion token for filtering purposes.
SourceLocation getPreambleRecordedPragmaAssumeNonNullLoc() const
Get the location of the recorded unterminated #pragma clang assume_nonnull begin in the preamble,...
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 SkipTokensWhileUsingPCH()
Skip tokens until after the include of the through header or until after a pragma hdrstop.
bool usingPCHWithThroughHeader()
True if using a PCH with a through header.
bool CollectPPImportSuffixAndEnterStream(SmallVectorImpl< Token > &Toks, bool StopUntilEOD=false)
void markMainFileAsPreprocessedModuleFile()
Mark the main file as a preprocessed module file, then the 'module' and 'import' directive recognitio...
bool LexStringLiteral(Token &Result, std::string &String, const char *DiagnosticTag, bool AllowMacroExpansion)
Lex a string literal, which may be the concatenation of multiple string literals and may even come fr...
void HandleMicrosoftCommentPaste(Token &Tok)
When the macro expander pastes together a comment (/##/) in Microsoft mode, this method handles updat...
Preprocessor(const PreprocessorOptions &PPOpts, DiagnosticsEngine &diags, const LangOptions &LangOpts, SourceManager &SM, HeaderSearch &Headers, ModuleLoader &TheModuleLoader, IdentifierInfoLookup *IILookup=nullptr, bool OwnsHeaderSearch=false, TranslationUnitKind TUKind=TU_Complete)
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.
ScratchBuffer - This class exposes a simple interface for the dynamic construction of tokens.
This table allows us to fully hide how we implement multi-keyword caching.
Encodes a location in the source.
This class handles loading and caching of source files into memory.
A trivial tuple used to represent a source range.
Exposes information about the current target.
TokenValue(IdentifierInfo *II)
TokenValue(tok::TokenKind Kind)
bool operator==(const Token &Tok) const
Token - This structure provides full information about a lexed token.
IdentifierInfo * getIdentifierInfo() const
SourceLocation getLocation() const
Return a source location identifier for the specified offset in the current file.
Public enums and private classes that are part of the SourceManager implementation.
TokenKind
Provides a simple uniform namespace for tokens from all C languages.
OnOffSwitch
Defines the possible values of an on-off-switch (C99 6.10.6p2).
bool isLiteral(TokenKind K)
Return true if this is a "literal" kind, like a numeric constant, string, etc.
PPKeywordKind
Provides a namespace for preprocessor keywords which start with a '#' at the beginning of the line.
bool isAnnotation(TokenKind K)
Return true if this is any of tok::annot_* kinds.
The JSON file list parser is used to communicate input to InstallAPI.
CustomizableOptional< FileEntryRef > OptionalFileEntryRef
llvm::Registry< PragmaHandler > PragmaHandlerRegistry
Registry of pragma handlers added by plugins.
ArrayRef< IdentifierLoc > ModuleIdPath
A sequence of identifier/location pairs used to describe a particular module or submodule,...
@ Conditional
A conditional (?:) operator.
detail::SearchDirIteratorImpl< true > ConstSearchDirIterator
@ Create
'create' clause, allowed on Compute and Combined constructs, plus 'data', 'enter data',...
nullptr
This class represents a compute construct, representing a 'Kind' of ‘parallel’, 'serial',...
MacroUse
Context in which macro name is used.
@ Module
Module linkage, which indicates that the entity can be referred to from other translation units withi...
@ Result
The result type of a method or function.
TranslationUnitKind
Describes the kind of translation unit being processed.
@ TU_Complete
The translation unit is a complete translation unit.
CustomizableOptional< DirectoryEntryRef > OptionalDirectoryEntryRef
U cast(CodeGen::Address addr)
Diagnostic wrappers for TextAPI types for error reporting.
Helper class to shuttle information about embed directives from the preprocessor to the parser throug...
Describes how and where the pragma was introduced.
SourceLocation IfTokenLoc
SourceLocation HashTokenLoc
PreambleSkipInfo(SourceLocation HashTokenLoc, SourceLocation IfTokenLoc, bool FoundNonSkipPortion, bool FoundElse, SourceLocation ElseLoc)