14#ifndef LLVM_CLANG_LEX_PREPROCESSOR_H
15#define LLVM_CLANG_LEX_PREPROCESSOR_H
37#include "llvm/ADT/APSInt.h"
38#include "llvm/ADT/ArrayRef.h"
39#include "llvm/ADT/DenseMap.h"
40#include "llvm/ADT/FoldingSet.h"
41#include "llvm/ADT/FunctionExtras.h"
42#include "llvm/ADT/PointerUnion.h"
43#include "llvm/ADT/STLExtras.h"
44#include "llvm/ADT/SmallPtrSet.h"
45#include "llvm/ADT/SmallVector.h"
46#include "llvm/ADT/StringRef.h"
47#include "llvm/ADT/TinyPtrVector.h"
48#include "llvm/ADT/iterator_range.h"
49#include "llvm/Support/Allocator.h"
50#include "llvm/Support/Casting.h"
51#include "llvm/Support/Registry.h"
52#include "llvm/Support/TrailingObjects.h"
101 assert(Kind != tok::raw_identifier &&
"Raw identifiers are not supported.");
102 assert(Kind != tok::identifier &&
103 "Identifiers should be created by TokenValue(IdentifierInfo *)");
111 return Tok.getKind() == Kind &&
112 (!II || II ==
Tok.getIdentifierInfo());
141class ModuleNameLoc final
142 : llvm::TrailingObjects<ModuleNameLoc, IdentifierLoc> {
143 friend TrailingObjects;
144 unsigned NumIdentifierLocs;
145 unsigned numTrailingObjects(OverloadToken<IdentifierLoc>)
const {
149 ModuleNameLoc(
ModuleIdPath Path) : NumIdentifierLocs(Path.size()) {
150 (void)llvm::copy(Path, getTrailingObjectsNonStrict<IdentifierLoc>());
157 return {getTrailingObjectsNonStrict<IdentifierLoc>(),
166 return Last.getLoc().getLocWithOffset(
167 Last.getIdentifierInfo()->getLength());
185 llvm::unique_function<void(
const clang::Token &)> OnToken;
199 std::unique_ptr<ScratchBuffer> ScratchBuf;
209 llvm::BumpPtrAllocator BP;
270 MaxAllowedIncludeStackDepth = 200
274 bool KeepComments : 1;
275 bool KeepMacroComments : 1;
276 bool SuppressIncludeNotFoundError : 1;
279 bool InMacroArgs : 1;
282 bool OwnsHeaderSearch : 1;
285 bool DisableMacroExpansion : 1;
289 bool MacroExpansionInDirectivesOverride : 1;
291 class ResetMacroExpansionHelper;
294 mutable bool ReadMacrosFromExternalSource : 1;
297 bool PragmasEnabled : 1;
300 bool PreprocessedOutput : 1;
303 bool ParsingIfOrElifDirective;
306 bool InMacroArgPreExpansion;
324 std::unique_ptr<Builtin::Context> BuiltinInfo;
328 std::unique_ptr<PragmaNamespace> PragmaHandlers;
332 std::unique_ptr<PragmaNamespace> PragmaHandlersBackup;
336 std::vector<CommentHandler *> CommentHandlers;
342 bool IncrementalProcessing =
false;
360 const FileEntry *CodeCompletionFile =
nullptr;
363 unsigned CodeCompletionOffset = 0;
379 llvm::DenseMap<FileID, SmallVector<const char *>> CheckPoints;
380 unsigned CheckPointCounter = 0;
383 bool RecordCheckPoints =
false;
386 bool ImportingCXXNamedModules =
false;
389 Token LastExportKeyword;
400 class StdCXXImportSeq {
405 AfterTopLevelTokenSeq = -1,
410 StdCXXImportSeq(State S) : S(S) {}
413 void handleOpenBracket() {
414 S =
static_cast<State
>(std::max<int>(S, 0) + 1);
417 void handleCloseBracket() {
418 S =
static_cast<State
>(std::max<int>(S, 1) - 1);
421 void handleCloseBrace() {
422 handleCloseBracket();
423 if (S == AtTopLevel && !AfterHeaderName)
424 S = AfterTopLevelTokenSeq;
429 S = AfterTopLevelTokenSeq;
430 AfterHeaderName =
false;
435 void handleExport() {
436 if (S == AfterTopLevelTokenSeq)
442 void handleImport() {
443 if (S == AfterTopLevelTokenSeq || S == AfterExport)
451 void handleHeaderName() {
452 if (S == AfterImportSeq)
453 AfterHeaderName =
true;
463 bool atTopLevel() {
return S <= 0; }
464 bool afterImportSeq() {
return S == AfterImportSeq; }
465 bool afterTopLevelSeq() {
return S == AfterTopLevelTokenSeq; }
472 bool AfterHeaderName =
false;
476 StdCXXImportSeq StdCXXImportSeqState = StdCXXImportSeq::AfterTopLevelTokenSeq;
481 enum GMFState :
int {
484 BeforeGMFIntroducer = -1,
485 GMFAbsentOrEnded = -2,
488 TrackGMF(GMFState S) : S(S) {}
499 void handleExport() {
501 S = GMFAbsentOrEnded;
505 void handleImport(
bool AfterTopLevelTokenSeq) {
507 if (AfterTopLevelTokenSeq && S == BeforeGMFIntroducer)
508 S = GMFAbsentOrEnded;
512 void handleModule(
bool AfterTopLevelTokenSeq) {
516 if (AfterTopLevelTokenSeq && S == BeforeGMFIntroducer)
519 S = GMFAbsentOrEnded;
526 S = GMFAbsentOrEnded;
529 bool inGMF() {
return S == GMFActive; }
537 TrackGMF TrackGMFState = TrackGMF::BeforeGMFIntroducer;
573 class ModuleDeclSeq {
574 enum ModuleDeclState :
int {
578 ImplementationCandidate,
579 NamedModuleInterface,
580 NamedModuleImplementation,
584 ModuleDeclSeq() =
default;
586 void handleExport() {
587 if (State == NotAModuleDecl)
589 else if (!isNamedModule())
593 void handleModule() {
594 if (State == FoundExport)
595 State = InterfaceCandidate;
596 else if (State == NotAModuleDecl)
597 State = ImplementationCandidate;
598 else if (!isNamedModule())
602 void handleModuleName(ModuleNameLoc *NameLoc) {
603 if (isModuleCandidate() && NameLoc)
604 Name += NameLoc->str();
605 else if (!isNamedModule())
610 if (isModuleCandidate())
612 else if (!isNamedModule())
617 if (!Name.empty() && isModuleCandidate()) {
618 if (State == InterfaceCandidate)
619 State = NamedModuleInterface;
620 else if (State == ImplementationCandidate)
621 State = NamedModuleImplementation;
623 llvm_unreachable(
"Unimaged ModuleDeclState.");
624 }
else if (!isNamedModule())
629 if (!isNamedModule())
633 bool isModuleCandidate()
const {
634 return State == InterfaceCandidate || State == ImplementationCandidate;
637 bool isNamedModule()
const {
638 return State == NamedModuleInterface ||
639 State == NamedModuleImplementation;
642 bool isNamedInterface()
const {
return State == NamedModuleInterface; }
644 bool isImplementationUnit()
const {
645 return State == NamedModuleImplementation && !getName().contains(
':');
648 bool isNotAModuleDecl()
const {
return State == NotAModuleDecl; }
650 StringRef getName()
const {
651 assert(isNamedModule() &&
"Can't get name from a non named module");
655 StringRef getPrimaryName()
const {
656 assert(isNamedModule() &&
"Can't get name from a non named module");
657 return getName().split(
':').first;
662 State = NotAModuleDecl;
666 ModuleDeclState State = NotAModuleDecl;
670 ModuleDeclSeq ModuleDeclState;
674 IdentifierLoc PragmaARCCFCodeAuditedInfo;
678 SourceLocation PragmaAssumeNonNullLoc;
686 SourceLocation PreambleRecordedPragmaAssumeNonNullLoc;
689 bool CodeCompletionReached =
false;
693 IdentifierInfo *CodeCompletionII =
nullptr;
696 SourceRange CodeCompletionTokenRange;
708 std::pair<int, bool> SkipMainFilePreamble;
712 std::string DeferredGMFInputs;
715 FileID DeferredGMFInputsFileID;
718 bool HasSynthesizedGMF =
false;
721 bool PredefinesWereReplaced =
false;
722 bool PredefinesInitialized =
false;
724 bool hasDeferredGMFInputs()
const {
return !DeferredGMFInputs.empty(); }
727 void EnterDeferredGMFInputs(SourceLocation IncludeLoc);
731 bool HasReachedMaxIncludeDepth =
false;
739 unsigned LexLevel = 0;
742 unsigned TokenCount = 0;
745 bool PreprocessToken =
false;
749 unsigned MaxTokens = 0;
750 SourceLocation MaxTokensOverrideLoc;
774 class PreambleConditionalStackStore {
782 PreambleConditionalStackStore() =
default;
784 void startRecording() { ConditionalStackState = Recording; }
785 void startReplaying() { ConditionalStackState = Replaying; }
786 bool isRecording()
const {
return ConditionalStackState == Recording; }
787 bool isReplaying()
const {
return ConditionalStackState == Replaying; }
789 ArrayRef<PPConditionalInfo> getStack()
const {
790 return ConditionalStack;
793 void doneReplaying() {
794 ConditionalStack.clear();
795 ConditionalStackState = Off;
798 void setStack(ArrayRef<PPConditionalInfo> s) {
799 if (!isRecording() && !isReplaying())
801 ConditionalStack.clear();
802 ConditionalStack.append(s.begin(), s.end());
807 bool reachedEOFWhileSkipping()
const {
return SkipInfo.has_value(); }
809 void clearSkipInfo() { SkipInfo.reset(); }
811 std::optional<PreambleSkipInfo> SkipInfo;
814 SmallVector<PPConditionalInfo, 4> ConditionalStack;
815 State ConditionalStackState = Off;
816 } PreambleConditionalStack;
822 std::unique_ptr<Lexer> CurLexer;
828 SmallVector<std::unique_ptr<Lexer>, 2> PendingDestroyLexers;
834 PreprocessorLexer *CurPPLexer =
nullptr;
846 std::unique_ptr<TokenLexer> CurTokenLexer;
850 LexerCallback CurLexerCallback = &CLK_Lexer;
854 Module *CurLexerSubmodule =
nullptr;
859 struct IncludeStackInfo {
860 LexerCallback CurLexerCallback;
862 std::unique_ptr<Lexer> TheLexer;
863 PreprocessorLexer *ThePPLexer;
864 std::unique_ptr<TokenLexer> TheTokenLexer;
869 IncludeStackInfo(LexerCallback CurLexerCallback,
Module *TheSubmodule,
870 std::unique_ptr<Lexer> &&TheLexer,
871 PreprocessorLexer *ThePPLexer,
872 std::unique_ptr<TokenLexer> &&TheTokenLexer,
874 : CurLexerCallback(std::move(CurLexerCallback)),
875 TheSubmodule(std::move(TheSubmodule)), TheLexer(std::move(TheLexer)),
876 ThePPLexer(std::move(ThePPLexer)),
877 TheTokenLexer(std::move(TheTokenLexer)),
878 TheDirLookup(std::move(TheDirLookup)) {}
880 std::vector<IncludeStackInfo> IncludeMacroStack;
884 std::unique_ptr<PPCallbacks> Callbacks;
886 struct MacroExpandsInfo {
891 MacroExpandsInfo(Token Tok, MacroDefinition MD, SourceRange Range)
892 : Tok(Tok), MD(MD), Range(Range) {}
894 SmallVector<MacroExpandsInfo, 2> DelayedMacroExpandsCallbacks;
897 struct FullModuleMacroInfo {
902 llvm::TinyPtrVector<ModuleMacro *> ActiveModuleMacros;
906 unsigned ActiveModuleMacrosGeneration = 0;
909 bool IsAmbiguous =
false;
912 llvm::TinyPtrVector<ModuleMacro *> OverriddenMacros;
914 FullModuleMacroInfo(MacroDirective *MD) : MD(MD) {}
919 mutable llvm::PointerUnion<MacroDirective *, FullModuleMacroInfo *> State;
921 FullModuleMacroInfo *getFullModuleInfo(
Preprocessor &PP,
922 const IdentifierInfo *II)
const {
923 if (II->isOutOfDate())
924 PP.updateOutOfDateIdentifier(*II);
927 if (!II->hasMacroDefinition() ||
928 (!PP.getLangOpts().Modules &&
929 !PP.getLangOpts().ModulesLocalVisibility) ||
930 !PP.CurSubmoduleState->VisibleModules.getGeneration())
933 auto *Info = dyn_cast_if_present<FullModuleMacroInfo *>(State);
935 Info =
new (PP.getPreprocessorAllocator())
940 if (PP.CurSubmoduleState->VisibleModules.getGeneration() !=
941 Info->ActiveModuleMacrosGeneration)
942 PP.updateModuleMacroInfo(II, *Info);
947 MacroState() : MacroState(
nullptr) {}
948 MacroState(MacroDirective *MD) : State(MD) {}
950 MacroState(MacroState &&O) noexcept : State(O.State) {
951 O.State = (MacroDirective *)
nullptr;
954 MacroState &operator=(MacroState &&O)
noexcept {
956 O.State = (MacroDirective *)
nullptr;
962 if (
auto *Info = dyn_cast_if_present<FullModuleMacroInfo *>(State))
963 Info->~FullModuleMacroInfo();
966 MacroDirective *getLatest()
const {
967 if (
auto *Info = dyn_cast_if_present<FullModuleMacroInfo *>(State))
972 void setLatest(MacroDirective *MD) {
973 if (
auto *Info = dyn_cast_if_present<FullModuleMacroInfo *>(State))
980 const IdentifierInfo *II)
const {
981 if (
auto *Info = getFullModuleInfo(PP, II))
982 return ModuleMacroInfo{Info->ActiveModuleMacros, Info->IsAmbiguous};
986 MacroDirective::DefInfo findDirectiveAtLoc(SourceLocation Loc,
987 SourceManager &SourceMgr)
const {
989 if (
auto *Latest = getLatest())
990 return Latest->findDirectiveAtLoc(Loc, SourceMgr);
994 void overrideActiveModuleMacros(
Preprocessor &PP, IdentifierInfo *II) {
995 if (
auto *Info = getFullModuleInfo(PP, II)) {
996 Info->OverriddenMacros.insert(Info->OverriddenMacros.end(),
997 Info->ActiveModuleMacros.begin(),
998 Info->ActiveModuleMacros.end());
999 Info->ActiveModuleMacros.clear();
1000 Info->IsAmbiguous =
false;
1004 ArrayRef<ModuleMacro*> getOverriddenMacros()
const {
1005 if (
auto *Info = dyn_cast_if_present<FullModuleMacroInfo *>(State))
1006 return Info->OverriddenMacros;
1011 ArrayRef<ModuleMacro *> Overrides) {
1012 auto *Info = dyn_cast_if_present<FullModuleMacroInfo *>(State);
1014 if (Overrides.empty())
1016 Info =
new (PP.getPreprocessorAllocator())
1020 Info->OverriddenMacros.clear();
1021 Info->OverriddenMacros.insert(Info->OverriddenMacros.end(),
1022 Overrides.begin(), Overrides.end());
1023 Info->ActiveModuleMacrosGeneration = 0;
1032 using MacroMap = llvm::DenseMap<const IdentifierInfo *, MacroState>;
1034 struct SubmoduleState;
1037 struct BuildingSubmoduleInfo {
1042 SourceLocation ImportLoc;
1048 SubmoduleState *OuterSubmoduleState;
1051 unsigned OuterPendingModuleMacroNames;
1053 BuildingSubmoduleInfo(
Module *M, SourceLocation ImportLoc,
bool IsPragma,
1054 SubmoduleState *OuterSubmoduleState,
1055 unsigned OuterPendingModuleMacroNames)
1056 : M(M), ImportLoc(ImportLoc), IsPragma(IsPragma),
1057 OuterSubmoduleState(OuterSubmoduleState),
1058 OuterPendingModuleMacroNames(OuterPendingModuleMacroNames) {}
1060 SmallVector<BuildingSubmoduleInfo, 8> BuildingSubmoduleStack;
1063 struct SubmoduleState {
1068 VisibleModuleSet VisibleModules;
1073 std::map<Module *, SubmoduleState> Submodules;
1076 SubmoduleState NullSubmoduleState;
1080 SubmoduleState *CurSubmoduleState;
1087 llvm::SmallSetVector<Module *, 2> AffectingClangModules;
1090 llvm::UniquingSet<ModuleMacro> ModuleMacros;
1093 llvm::SmallVector<IdentifierInfo *, 32> PendingModuleMacroNames;
1097 llvm::DenseMap<const IdentifierInfo *, llvm::TinyPtrVector<ModuleMacro *>>
1108 using WarnUnusedMacroLocsTy = llvm::SmallDenseSet<SourceLocation, 32>;
1109 WarnUnusedMacroLocsTy WarnUnusedMacroLocs;
1115 using MsgLocationPair = std::pair<std::string, SourceLocation>;
1117 struct MacroAnnotationInfo {
1118 SourceLocation Location;
1119 std::string Message;
1122 struct MacroAnnotations {
1123 std::optional<MacroAnnotationInfo> DeprecationInfo;
1124 std::optional<MacroAnnotationInfo> RestrictExpansionInfo;
1125 std::optional<SourceLocation> FinalAnnotationLoc;
1129 llvm::DenseMap<const IdentifierInfo *, MacroAnnotations> AnnotationInfos;
1137 llvm::DenseMap<IdentifierInfo *, std::vector<MacroInfo *>>
1138 PragmaPushMacroInfo;
1141 unsigned NumDirectives = 0;
1142 unsigned NumDefined = 0;
1143 unsigned NumUndefined = 0;
1144 unsigned NumPragma = 0;
1146 unsigned NumElse = 0;
1147 unsigned NumEndif = 0;
1148 unsigned NumEnteredSourceFiles = 0;
1149 unsigned MaxIncludeStackDepth = 0;
1150 unsigned NumMacroExpanded = 0;
1151 unsigned NumFnMacroExpanded = 0;
1152 unsigned NumBuiltinMacroExpanded = 0;
1153 unsigned NumFastMacroExpanded = 0;
1154 unsigned NumTokenPaste = 0;
1155 unsigned NumFastTokenPaste = 0;
1156 unsigned NumSkipped = 0;
1160 std::string Predefines;
1163 FileID PredefinesFileID;
1166 FileID PCHThroughHeaderFileID;
1169 bool SkippingUntilPragmaHdrStop =
false;
1172 bool SkippingUntilPCHThroughHeader =
false;
1175 bool MainFileIsPreprocessedModuleFile =
false;
1179 enum { TokenLexerCacheSize = 8 };
1180 unsigned NumCachedTokenLexers;
1181 std::unique_ptr<TokenLexer> TokenLexerCache[TokenLexerCacheSize];
1189 SmallVector<Token, 16> MacroExpandedTokens;
1190 std::vector<std::pair<TokenLexer *, size_t>> MacroExpandingLexersStack;
1197 PreprocessingRecord *Record =
nullptr;
1200 using CachedTokensTy = SmallVector<Token, 1>;
1204 CachedTokensTy CachedTokens;
1211 CachedTokensTy::size_type CachedLexPos = 0;
1218 std::vector<CachedTokensTy::size_type> BacktrackPositions;
1222 std::vector<std::pair<CachedTokensTy, CachedTokensTy::size_type>>
1223 UnannotatedBacktrackTokens;
1229 bool SkippingExcludedConditionalBlock =
false;
1235 llvm::DenseMap<const char *, unsigned> RecordedSkippedRanges;
1237 void updateOutOfDateIdentifier(
const IdentifierInfo &II)
const;
1240 Preprocessor(
const PreprocessorOptions &PPOpts, DiagnosticsEngine &diags,
1241 const LangOptions &LangOpts, SourceManager &SM,
1242 HeaderSearch &Headers, ModuleLoader &TheModuleLoader,
1243 IdentifierInfoLookup *IILookup =
nullptr,
1244 bool OwnsHeaderSearch =
false,
1256 const TargetInfo *AuxTarget =
nullptr);
1290 ExternalSource = Source;
1294 return ExternalSource;
1301 return TheModuleLoader.HadFatalFailure;
1307 return NumDirectives;
1312 return ParsingIfOrElifDirective;
1317 this->KeepComments = KeepComments | KeepMacroComments;
1318 this->KeepMacroComments = KeepMacroComments;
1327 SuppressIncludeNotFoundError = Suppress;
1331 return SuppressIncludeNotFoundError;
1337 PreprocessedOutput = IsPreprocessedOutput;
1346 return CurPPLexer == L;
1376 C = std::make_unique<PPChainedCallbacks>(std::move(
C),
1377 std::move(Callbacks));
1378 Callbacks = std::move(
C);
1391 MaxTokensOverrideLoc = Loc;
1400 OnToken = std::move(F);
1404 GetDependencyDirectives = &Get;
1423 auto I = Submodules.find(M);
1424 if (I == Submodules.end())
1426 auto J = I->second.Macros.find(II);
1427 if (J == I->second.Macros.end())
1429 auto *MD = J->second.getLatest();
1430 return MD && MD->isDefined();
1437 MacroState &S = CurSubmoduleState->Macros[II];
1438 auto *MD = S.getLatest();
1439 while (isa_and_nonnull<VisibilityMacroDirective>(MD))
1440 MD = MD->getPrevious();
1442 S.getModuleInfo(*
this, II));
1450 MacroState &S = CurSubmoduleState->Macros[II];
1452 if (
auto *MD = S.getLatest())
1465 if (!MD || MD->getDefinition().isUndefined())
1479 return MD.getMacroInfo();
1516 updateOutOfDateIdentifier(*II);
1517 auto I = LeafModuleMacros.find(II);
1518 if (I != LeafModuleMacros.end())
1525 return BuildingSubmoduleStack;
1534 llvm::iterator_range<macro_iterator>
1535 macros(
bool IncludeExternalMacros =
true)
const;
1542 if (!BuildingSubmoduleStack.empty()) {
1543 if (M != BuildingSubmoduleStack.back().M)
1544 BuildingSubmoduleStack.back().M->AffectingClangModules.push_back(M);
1546 AffectingClangModules.insert(M);
1553 return AffectingClangModules;
1559 HeaderInfo.getFileInfo(
File).IsLocallyIncluded =
true;
1560 return IncludedFiles.insert(
File).second;
1565 HeaderInfo.getFileInfo(
File);
1566 return IncludedFiles.count(
File);
1588 PredefinesWereReplaced |= PredefinesInitialized;
1589 PredefinesInitialized =
true;
1590 Predefines = std::move(P);
1596 assert(DeferredGMFInputs.empty());
1597 DeferredGMFInputs = std::move(Inputs);
1603 return &Identifiers.get(Name);
1643 CodeComplete = &Handler;
1648 return CodeComplete;
1653 CodeComplete =
nullptr;
1666 CodeCompletionII = Filter;
1673 CodeCompletionTokenRange = {Start, End};
1676 return CodeCompletionTokenRange;
1681 if (CodeCompletionII)
1682 return CodeCompletionII->getName();
1756 void EnterTokenStream(
const Token *Toks,
unsigned NumToks,
1757 bool DisableMacroExpansion,
bool OwnsTokens,
1762 bool DisableMacroExpansion,
bool IsReinject) {
1763 EnterTokenStream(Toks.release(), NumToks, DisableMacroExpansion,
true,
1769 EnterTokenStream(Toks.data(), Toks.size(), DisableMacroExpansion,
false,
1797 std::pair<CachedTokensTy::size_type, bool> LastBacktrackPos();
1799 CachedTokensTy PopUnannotatedBacktrackTokens();
1816 return !UnannotatedBacktrackTokens.empty();
1834 return MainFileIsPreprocessedModuleFile;
1841 MainFileIsPreprocessedModuleFile =
true;
1847 bool AllowMacroExpansion,
bool IsPartition);
1851 bool AllowMacroExpansion,
bool IsPartition);
1866 assert(FirstPPTokenLoc.isValid() &&
1867 "Did not see the first pp-token in the main file");
1868 return FirstPPTokenLoc;
1872 bool StopUntilEOD =
false);
1874 bool StopUntilEOD =
false);
1877 bool IncludeExports =
true);
1880 return CurSubmoduleState->VisibleModules.getImportLoc(M);
1887 const char *DiagnosticTag,
bool AllowMacroExpansion) {
1888 if (AllowMacroExpansion)
1893 AllowMacroExpansion);
1899 const char *DiagnosticTag,
1900 bool AllowMacroExpansion);
1910 while (
Result.getKind() == tok::comment);
1916 bool OldVal = DisableMacroExpansion;
1917 DisableMacroExpansion =
true;
1922 DisableMacroExpansion = OldVal;
1930 while (
Result.getKind() == tok::comment);
1940 DisableMacroExpansion =
true;
1941 MacroExpansionInDirectivesOverride =
true;
1945 DisableMacroExpansion = MacroExpansionInDirectivesOverride =
false;
1956 assert(LexLevel == 0 &&
"cannot use lookahead while lexing");
1957 if (CachedLexPos + N < CachedTokens.size())
1958 return CachedTokens[CachedLexPos+N];
1960 return PeekAhead(N+1);
1970 "Should only be called when tokens are cached for backtracking");
1971 assert(
signed(CachedLexPos) -
signed(N) >=
1972 signed(LastBacktrackPos().first) &&
1973 "Should revert tokens up to the last backtrack position, not more");
1974 assert(
signed(CachedLexPos) -
signed(N) >= 0 &&
1975 "Corrupted backtrack positions ?");
1989 auto TokCopy = std::make_unique<Token[]>(1);
1991 EnterTokenStream(std::move(TokCopy), 1,
true, IsReinject);
1993 EnterCachingLexMode();
1994 assert(IsReinject &&
"new tokens in the middle of cached stream");
1995 CachedTokens.insert(CachedTokens.begin()+CachedLexPos,
Tok);
2008 assert(
Tok.isAnnotation() &&
"Expected annotation token");
2010 AnnotatePreviousCachedTokens(
Tok);
2016 assert(CachedLexPos != 0);
2017 return CachedTokens[CachedLexPos-1].getLastLoc();
2040 assert(
Tok.isAnnotation() &&
"Expected annotation token");
2042 CachedTokens[CachedLexPos-1] =
Tok;
2047 void *AnnotationVal);
2052 return CurLexerCallback != CLK_Lexer;
2058 assert(
Tok.getIdentifierInfo() &&
"Expected identifier token");
2060 CachedTokens[CachedLexPos-1] =
Tok;
2072 IncrementalProcessing = value;
2106 return CodeCompletionFileLoc;
2116 CodeCompletionReached =
true;
2126 return PragmaARCCFCodeAuditedInfo;
2141 return PragmaAssumeNonNullLoc;
2147 PragmaAssumeNonNullLoc = Loc;
2156 return PreambleRecordedPragmaAssumeNonNullLoc;
2162 PreambleRecordedPragmaAssumeNonNullLoc = Loc;
2176 SkipMainFilePreamble.first = Bytes;
2177 SkipMainFilePreamble.second = StartOfLine;
2184 return Diags->Report(Loc, DiagID);
2188 return Diags->Report(
Tok.getLocation(), DiagID);
2192 unsigned CompatDiagID)
const {
2209 bool *invalid =
nullptr)
const {
2238 bool *
Invalid =
nullptr)
const {
2248 bool *
Invalid =
nullptr)
const;
2253 bool IgnoreWhiteSpace =
false) {
2261 bool *
Invalid =
nullptr)
const {
2262 assert((
Tok.is(tok::numeric_constant) ||
Tok.is(tok::binary_data)) &&
2263 Tok.getLength() == 1 &&
"Called on unsupported token");
2264 assert(!
Tok.needsCleaning() &&
"Token can't need cleaning with length 1");
2267 if (
const char *D =
Tok.getLiteralData())
2268 return (
Tok.getKind() == tok::binary_data) ? *D : *D -
'0';
2270 assert(
Tok.is(tok::numeric_constant) &&
"binary data with no data");
2273 return *SourceMgr.getCharacterData(
Tok.getLocation(),
Invalid) -
'0';
2351 unsigned Char)
const {
2361 ++NumFastTokenPaste;
2385 llvm::DenseMap<IdentifierInfo*,unsigned> PoisonReasons;
2399 if(II->isPoisoned()) {
2409 static_assert(
sizeof...(Ts) > 0,
2410 "requires at least one tok::TokenKind specified");
2411 auto NextTokOpt = peekNextPPToken();
2412 return NextTokOpt.has_value() ? NextTokOpt->is(Ks...) :
false;
2419 std::optional<Token> peekNextPPToken()
const;
2425 *Ident___exception_code,
2426 *Ident_GetExceptionCode;
2429 *Ident___exception_info,
2430 *Ident_GetExceptionInfo;
2433 *Ident___abnormal_termination,
2434 *Ident_AbnormalTermination;
2436 const char *getCurLexerEndPos();
2437 void diagnoseMissingHeaderInUmbrellaDir(
const Module &Mod);
2508 "FPEvalMethod should be set either from command line or from the "
2510 return CurrentFPEvalMethod;
2514 return TUFPEvalMethod;
2518 return LastFPEvalPragmaLocation;
2524 "FPEvalMethod should never be set to FEM_UnsetOnCommandLine");
2527 LastFPEvalPragmaLocation = PragmaLoc;
2528 CurrentFPEvalMethod = Val;
2529 TUFPEvalMethod = Val;
2534 "TUPEvalMethod should never be set to FEM_UnsetOnCommandLine");
2535 TUFPEvalMethod = Val;
2552 return ModuleDeclState.isNamedInterface();
2563 return ModuleDeclState.isImplementationUnit();
2569 "Import C++ named modules are only valid for C++20 modules");
2570 return ImportingCXXNamedModules;
2606 bool *IsFrameworkFound,
bool SkipCache =
false,
2607 bool OpenFile =
true,
bool CacheFailures =
true);
2627 bool *ShadowFlag =
nullptr);
2633 friend void TokenLexer::ExpandFunctionArguments();
2635 void PushIncludeMacroStack() {
2636 assert(CurLexerCallback != CLK_CachingLexer &&
2637 "cannot push a caching lexer");
2638 IncludeMacroStack.emplace_back(CurLexerCallback, CurLexerSubmodule,
2639 std::move(CurLexer), CurPPLexer,
2640 std::move(CurTokenLexer), CurDirLookup);
2641 CurPPLexer =
nullptr;
2644 void PopIncludeMacroStack() {
2646 PendingDestroyLexers.push_back(std::move(CurLexer));
2647 CurLexer = std::move(IncludeMacroStack.back().TheLexer);
2648 CurPPLexer = IncludeMacroStack.back().ThePPLexer;
2649 CurTokenLexer = std::move(IncludeMacroStack.back().TheTokenLexer);
2650 CurDirLookup = IncludeMacroStack.back().TheDirLookup;
2651 CurLexerSubmodule = IncludeMacroStack.back().TheSubmodule;
2652 CurLexerCallback = IncludeMacroStack.back().CurLexerCallback;
2653 IncludeMacroStack.pop_back();
2656 void PropagateLineStartLeadingSpaceInfo(Token &
Result);
2660 bool needModuleMacros()
const;
2664 void updateModuleMacroInfo(
const IdentifierInfo *II,
2665 FullModuleMacroInfo &Info);
2667 DefMacroDirective *AllocateDefMacroDirective(MacroInfo *MI,
2668 SourceLocation Loc);
2669 UndefMacroDirective *AllocateUndefMacroDirective(SourceLocation UndefLoc);
2670 VisibilityMacroDirective *AllocateVisibilityMacroDirective(SourceLocation Loc,
2684 bool *ShadowFlag =
nullptr);
2695 MacroInfo *ReadOptionalMacroParameterListAndBody(
2696 const Token &MacroNameTok,
bool ImmediatelyAfterHeaderGuard);
2702 bool ReadMacroParameterList(MacroInfo *MI, Token& LastTok);
2709 void SuggestTypoedDirective(
const Token &
Tok, StringRef
Directive)
const;
2719 void SkipExcludedConditionalBlock(SourceLocation HashTokenLoc,
2720 SourceLocation IfTokenLoc,
2721 bool FoundNonSkipPortion,
bool FoundElse,
2722 SourceLocation ElseLoc = SourceLocation());
2726 struct DirectiveEvalResult {
2728 std::optional<llvm::APSInt>
Value;
2734 bool IncludedUndefinedIds;
2737 SourceRange ExprRange;
2745 DirectiveEvalResult EvaluateDirectiveExpression(IdentifierLoc &IfNDefMacro,
2746 bool CheckForEoD =
true);
2755 DirectiveEvalResult EvaluateDirectiveExpression(IdentifierLoc &IfNDefMacro,
2757 bool &EvaluatedDefined,
2758 bool CheckForEoD =
true);
2769 bool EvaluateHasInclude(Token &
Tok, IdentifierInfo *II);
2774 bool EvaluateHasIncludeNext(Token &
Tok, IdentifierInfo *II);
2777 std::pair<ConstSearchDirIterator, const FileEntry *>
2778 getIncludeNextStart(
const Token &IncludeNextTok)
const;
2782 void RegisterBuiltinPragmas();
2786 IdentifierInfo *RegisterBuiltinMacro(
const char *Name) {
2792 MI->setIsBuiltinMacro();
2798 void RegisterBuiltinMacros();
2803 bool HandleMacroExpandedIdentifier(Token &Identifier,
const MacroDefinition &MD);
2810 Token *cacheMacroExpandedTokens(TokenLexer *tokLexer,
2811 ArrayRef<Token> tokens);
2813 void removeCachedMacroExpandedTokensOfLastLexer();
2817 MacroArgs *ReadMacroCallArgumentList(Token &MacroName, MacroInfo *MI,
2818 SourceLocation &MacroEnd);
2822 void ExpandBuiltinMacro(Token &
Tok);
2827 void Handle_Pragma(Token &
Tok);
2831 void HandleMicrosoft__pragma(Token &
Tok);
2835 void EnterSourceFileWithLexer(std::unique_ptr<Lexer> TheLexer,
2839 void setPredefinesFileID(FileID FID) {
2840 assert(PredefinesFileID.isInvalid() &&
"PredefinesFileID already set!");
2841 PredefinesFileID = FID;
2845 void setPCHThroughHeaderFileID(FileID FID);
2849 static bool IsFileLexer(
const Lexer* L,
const PreprocessorLexer* P) {
2850 return L ? !L->isPragmaLexer() : P !=
nullptr;
2853 static bool IsFileLexer(
const IncludeStackInfo& I) {
2854 return IsFileLexer(I.TheLexer.get(), I.ThePPLexer);
2857 bool IsFileLexer()
const {
2858 return IsFileLexer(CurLexer.get(), CurPPLexer);
2863 std::optional<CXXStandardLibraryVersionInfo> CXXStandardLibraryVersion;
2873 void CachingLex(Token &
Result);
2875 bool InCachingLexMode()
const {
return CurLexerCallback == CLK_CachingLexer; }
2877 void EnterCachingLexMode();
2878 void EnterCachingLexModeUnchecked();
2880 void ExitCachingLexMode() {
2881 if (InCachingLexMode())
2885 const Token &PeekAhead(
unsigned N);
2886 void AnnotatePreviousCachedTokens(
const Token &
Tok);
2892 void HandleLineDirective();
2893 void HandleDigitDirective(Token &
Tok);
2894 void HandleUserDiagnosticDirective(Token &
Tok,
bool isWarning);
2895 void HandleIdentSCCSDirective(Token &
Tok);
2896 void HandleMacroPublicDirective(Token &
Tok);
2897 void HandleMacroPrivateDirective();
2901 struct ImportAction {
2907 SkippedModuleImport,
2910 Module *ModuleForHeader =
nullptr;
2912 ImportAction(ActionKind AK,
Module *Mod =
nullptr)
2913 : Kind(AK), ModuleForHeader(Mod) {
2914 assert((AK == None || Mod || AK == Failure) &&
2915 "no module for module action");
2921 SourceLocation FilenameLoc, CharSourceRange FilenameRange,
2922 const Token &FilenameTok,
bool &IsFrameworkFound,
bool IsImportDecl,
2924 const FileEntry *LookupFromFile, StringRef &LookupFilename,
2925 SmallVectorImpl<char> &RelativePath, SmallVectorImpl<char> &SearchPath,
2926 ModuleMap::KnownHeader &SuggestedModule,
bool isAngled);
2928 void HandleEmbedDirective(SourceLocation HashLoc, Token &
Tok);
2929 void HandleEmbedDirectiveImpl(SourceLocation HashLoc,
2930 const LexEmbedParametersResult &Params,
2931 StringRef BinaryContents, StringRef
FileName);
2934 void HandleIncludeDirective(SourceLocation HashLoc, Token &
Tok,
2936 const FileEntry *LookupFromFile =
nullptr);
2938 HandleHeaderIncludeOrImport(SourceLocation HashLoc, Token &IncludeTok,
2939 Token &FilenameTok, SourceLocation EndLoc,
2941 const FileEntry *LookupFromFile =
nullptr);
2942 void HandleIncludeNextDirective(SourceLocation HashLoc, Token &
Tok);
2943 void HandleIncludeMacrosDirective(SourceLocation HashLoc, Token &
Tok);
2944 void HandleImportDirective(SourceLocation HashLoc, Token &
Tok);
2945 void HandleMicrosoftImportDirective(Token &
Tok);
2946 void HandleObjCImportDirective(Token &AtTok, Token &ImportTok);
2953 const TargetInfo &TargetInfo,
2954 const Module &M, DiagnosticsEngine &Diags);
2977 SourceLocation MLoc);
2980 return PreambleConditionalStack.isRecording();
2984 return PreambleConditionalStack.hasRecordedPreamble();
2988 return PreambleConditionalStack.getStack();
2992 PreambleConditionalStack.setStack(s);
2997 PreambleConditionalStack.startReplaying();
2998 PreambleConditionalStack.setStack(s);
2999 PreambleConditionalStack.SkipInfo = SkipInfo;
3003 return PreambleConditionalStack.SkipInfo;
3009 void replayPreambleConditionalStack();
3012 void HandleDefineDirective(
Token &
Tok,
bool ImmediatelyAfterHeaderGuard);
3013 void HandleUndefDirective();
3017 bool isIfndef,
bool ReadAnyTokensBeforeDirective);
3018 void HandleIfDirective(
Token &IfToken,
const Token &HashToken,
3019 bool ReadAnyTokensBeforeDirective);
3020 void HandleEndifDirective(
Token &EndifToken);
3022 void HandleElifFamilyDirective(
Token &ElifToken,
const Token &HashToken,
3059 AnnotationInfos[II].DeprecationInfo =
3060 MacroAnnotationInfo{AnnotationLoc, std::move(Msg)};
3065 AnnotationInfos[II].RestrictExpansionInfo =
3066 MacroAnnotationInfo{AnnotationLoc, std::move(Msg)};
3070 AnnotationInfos[II].FinalAnnotationLoc = AnnotationLoc;
3074 return AnnotationInfos.find(II)->second;
3078 bool IsIfnDef =
false)
const {
3081 emitMacroDeprecationWarning(Identifier);
3084 !SourceMgr.isInMainFile(Identifier.
getLocation()))
3085 emitRestrictExpansionWarning(Identifier);
3089 emitRestrictInfNaNWarning(Identifier, 0);
3091 emitRestrictInfNaNWarning(Identifier, 1);
3105 void emitMacroDeprecationWarning(
const Token &Identifier)
const;
3106 void emitRestrictExpansionWarning(
const Token &Identifier)
const;
3107 void emitFinalMacroWarning(
const Token &Identifier,
bool IsUndef)
const;
3108 void emitRestrictInfNaNWarning(
const Token &Identifier,
3109 unsigned DiagSelection)
const;
3114 bool InSafeBufferOptOutRegion =
false;
3121 using SafeBufferOptOutRegionsTy =
3126 SafeBufferOptOutRegionsTy SafeBufferOptOutMap;
3137 SafeBufferOptOutRegionsTy &
3145 const SafeBufferOptOutRegionsTy *
3153 return &Iter->getSecond();
3155 } LoadedSafeBufferOptOutMap;
3160 bool isSafeBufferOptOut(
const SourceManager&SourceMgr,
const SourceLocation &Loc)
const;
3173 const SourceLocation &Loc);
3196 const SmallVectorImpl<SourceLocation> &SrcLocSeqs);
3206 return P.CurLexer->Lex(
Result);
3209 return P.CurTokenLexer->Lex(
Result);
3216 return P.CurLexer->LexDependencyDirectiveToken(
Result);
3254extern 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.
Result
Implement __builtin_bit_cast and related operations.
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
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.
static unsigned getCompatDiagId(const LangOptions &LangOpts, unsigned CompatDiagId)
Get the appropriate diagnostic Id to use for issuing a compatibility diagnostic.
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()
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.
bool isPragmaSetPPStateMacro(IdentifierInfo *II)
Check whether this is a macro name that can be used as an argument to 'pragma clang __set_pp_state'.
void setDeferredGMFInputs(std::string Inputs)
Record implicit macro, PCH, and regular include directives to be entered before the main file or insi...
void HandlePragmaPushMacro(Token &Tok)
Handle #pragma push_macro.
void FinalizeForModelFile()
Cleanup after model file parsing.
void setStdLibCxxVersion(std::uint64_t Version)
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.
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
DiagnosticBuilder DiagCompat(SourceLocation Loc, unsigned CompatDiagID) 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.
DiagnosticBuilder DiagCompat(const Token &Tok, unsigned CompatDiagID) const
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.
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)
llvm::iterator_range< macro_iterator > macros(bool IncludeExternalMacros=true) const
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...
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.
OptionalFileEntryRef LookupEmbedFile(StringRef Filename, bool isAngled, bool OpenFile)
Given a "Filename" or <Filename> reference, look up the indicated embed resource.
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)
bool HandleModuleContextualKeyword(Token &Result)
Callback invoked when the lexer sees one of export, import or module token at the start of a line.
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.
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
void GetLineDirectiveFilenameSpelling(SourceLocation Loc, StringRef &Buffer)
Turn the specified lexer token into a fully checked and spelled filename, e.g.
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()
bool LexModuleNameContinue(Token &Tok, SourceLocation UseLoc, SmallVectorImpl< Token > &Suffix, SmallVectorImpl< IdentifierLoc > &Path, bool AllowMacroExpansion, bool IsPartition)
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)
TextEncoding & getTextEncoding()
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 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 HandlePragmaSetPPState(PragmaIntroducer Introducer, Token &Tok)
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)
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.
bool HandleModuleName(StringRef DirType, SourceLocation UseLoc, Token &Tok, SmallVectorImpl< IdentifierLoc > &Path, SmallVectorImpl< Token > &DirToks, bool AllowMacroExpansion, bool IsPartition)
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.
Top level wrappers for InstallAPI frontend operations.
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.
@ Off
Never emit colors regardless of the output stream.
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.
__builtin_elementwise_add_sat __builtin_elementwise_sub_sat uint32_t uint64_t __builtin_riscv_ssha_i32 __builtin_riscv_sshl_u32 uint64_t
int32_t uint32_t uint32_t __builtin_riscv_mhracc_i32 __builtin_riscv_mhraccu_u32 __builtin_riscv_mhraccsu_i32 __builtin_riscv_mhacc_h1_i32 __builtin_riscv_mhaccsu_h1_i32 __builtin_riscv_mulqr_i32 __builtin_riscv_mqrwacc_i64 __packed_splat4 __packed_splat2 __packed_splat8 __packed_splat4 __packed_splat2 uint8_t
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)