;
41 boolInQuotes,
boolImportedModule,
45Kind(Kind), ImportedModule(ImportedModule),
File(
File) {
46 char*Memory = (
char*)PPRec.
Allocate(
FileName.size() + 1,
alignof(char));
49this->FileName = StringRef(Memory,
FileName.size());
56llvm::iterator_range<PreprocessingRecord::iterator>
61 if(CachedRangeQuery.Range ==
Range) {
62 returnllvm::make_range(
iterator(
this, CachedRangeQuery.Result.first),
63 iterator(
this, CachedRangeQuery.Result.second));
66std::pair<int, int> Res = getPreprocessedEntitiesInRangeSlow(
Range);
68CachedRangeQuery.Range =
Range;
69CachedRangeQuery.Result = Res;
71 returnllvm::make_range(
iterator(
this, Res.first),
85 return SM.isInFileID(
SM.getFileLoc(
Loc), FID);
99 intPos = std::distance(
iterator(
this, 0), PPEI);
101 if(
unsigned(-Pos-1) >= LoadedPreprocessedEntities.size()) {
102assert(0 &&
"Out-of bounds loaded preprocessed entity");
106 unsignedLoadedIndex = LoadedPreprocessedEntities.size()+Pos;
112 if(std::optional<bool> IsInFile =
119getLoadedPreprocessedEntity(LoadedIndex),
123 if(
unsigned(Pos) >= PreprocessedEntities.size()) {
124assert(0 &&
"Out-of bounds local preprocessed entity");
134PreprocessingRecord::getPreprocessedEntitiesInRangeSlow(
SourceRange Range) {
138std::pair<unsigned, unsigned>
139Local = findLocalPreprocessedEntitiesInRange(
Range);
143 returnstd::make_pair(Local.first, Local.second);
145std::pair<unsigned, unsigned>
149 if(Loaded.first == Loaded.second)
150 returnstd::make_pair(Local.first, Local.second);
152 unsignedTotalLoaded = LoadedPreprocessedEntities.size();
155 if(Local.first == Local.second)
156 returnstd::make_pair(
int(Loaded.first)-TotalLoaded,
157 int(Loaded.second)-TotalLoaded);
160 returnstd::make_pair(
int(Loaded.first)-TotalLoaded, Local.second);
163std::pair<unsigned, unsigned>
164PreprocessingRecord::findLocalPreprocessedEntitiesInRange(
167 returnstd::make_pair(0,0);
171 unsignedEnd = findEndLocalPreprocessedEntity(
Range.
getEnd());
172 returnstd::make_pair(
Begin, End);
177template<SourceLocation (SourceRange::*getRangeLoc)() const>
186 return SM.isBeforeInTranslationUnit(LHS, RHS);
191 return SM.isBeforeInTranslationUnit(LHS, RHS);
196 return SM.isBeforeInTranslationUnit(LHS, RHS);
201 return(
Range.*getRangeLoc)();
207unsignedPreprocessingRecord::findBeginLocalPreprocessedEntity(
212 size_tCount = PreprocessedEntities.size();
214std::vector<PreprocessedEntity *>::const_iterator
215 First= PreprocessedEntities.begin();
216std::vector<PreprocessedEntity *>::const_iterator I;
225std::advance(I,
Half);
230Count = Count -
Half- 1;
235 return First- PreprocessedEntities.begin();
239PreprocessingRecord::findEndLocalPreprocessedEntity(
SourceLocation Loc)
const{
243 autoI = llvm::upper_bound(PreprocessedEntities,
Loc,
244PPEntityComp<&SourceRange::getBegin>(SourceMgr));
245 returnI - PreprocessedEntities.begin();
248PreprocessingRecord::PPEntityID
253 if(isa<MacroDefinitionRecord>(Entity)) {
254assert((PreprocessedEntities.empty() ||
257PreprocessedEntities.back()->getSourceRange().getBegin())) &&
258 "a macro definition was encountered out-of-order");
259PreprocessedEntities.push_back(Entity);
260 returngetPPEntityID(PreprocessedEntities.size()-1,
false);
264 if(PreprocessedEntities.empty() ||
266PreprocessedEntities.back()->getSourceRange().getBegin())) {
267PreprocessedEntities.push_back(Entity);
268 returngetPPEntityID(PreprocessedEntities.size()-1,
false);
283 usingpp_iter = std::vector<PreprocessedEntity *>::iterator;
288 for(pp_iter RI = PreprocessedEntities.end(),
289 Begin= PreprocessedEntities.begin();
290RI !=
Begin&& count < 4; --RI, ++count) {
294(*I)->getSourceRange().getBegin())) {
295pp_iter insertI = PreprocessedEntities.insert(RI, Entity);
296 returngetPPEntityID(insertI - PreprocessedEntities.begin(),
303llvm::upper_bound(PreprocessedEntities, BeginLoc,
304PPEntityComp<&SourceRange::getBegin>(SourceMgr));
305pp_iter insertI = PreprocessedEntities.insert(I, Entity);
306 returngetPPEntityID(insertI - PreprocessedEntities.begin(),
313 "Preprocessing record already has an external source");
317unsignedPreprocessingRecord::allocateLoadedEntities(
unsignedNumEntities) {
318 unsigned Result= LoadedPreprocessedEntities.size();
319LoadedPreprocessedEntities.resize(LoadedPreprocessedEntities.size()
324unsignedPreprocessingRecord::allocateSkippedRanges(
unsignedNumRanges) {
325 unsigned Result= SkippedRanges.size();
326SkippedRanges.resize(SkippedRanges.size() + NumRanges);
327SkippedRangesAllLoaded =
false;
331voidPreprocessingRecord::ensureSkippedRangesLoaded() {
334 for(
unsignedIndex = 0; Index != SkippedRanges.size(); ++Index) {
338SkippedRangesAllLoaded =
true;
341voidPreprocessingRecord::RegisterMacroDefinition(
MacroInfo*Macro,
343MacroDefinitions[
Macro] = Def;
349 unsignedIndex = -PPID.ID - 1;
350assert(Index < LoadedPreprocessedEntities.size() &&
351 "Out-of bounds loaded preprocessed entity");
352 returngetLoadedPreprocessedEntity(Index);
357 unsignedIndex = PPID.ID - 1;
358assert(Index < PreprocessedEntities.size() &&
359 "Out-of bounds local preprocessed entity");
360 returnPreprocessedEntities[Index];
365PreprocessingRecord::getLoadedPreprocessedEntity(
unsignedIndex) {
366assert(Index < LoadedPreprocessedEntities.size() &&
367 "Out-of bounds loaded preprocessed entity");
381 returnMacroDefinitions.lookup(MI);
384voidPreprocessingRecord::addMacroExpansion(
const Token&
Id,
388 if(
Id.getLocation().isMacroID())
423 const Token&MacroNameTok,
431voidPreprocessingRecord::Defined(
const Token&MacroNameTok,
446voidPreprocessingRecord::MacroExpands(
const Token&
Id,
453voidPreprocessingRecord::MacroDefined(
const Token&
Id,
460MacroDefinitions[MI] = Def;
463voidPreprocessingRecord::MacroUndefined(
const Token&
Id,
469voidPreprocessingRecord::InclusionDirective(
472StringRef SearchPath, StringRef RelativePath,
const Module*SuggestedModule,
477 casetok::pp_include:
485 casetok::pp_include_next:
489 casetok::pp___include_macros:
494llvm_unreachable(
"Unknown include directive kind");
499EndLoc = FilenameRange.
getBegin();
501EndLoc = FilenameRange.
getEnd();
507*
this, Kind,
FileName, !IsAngled, ModuleImported,
File,
513 returnBumpAlloc.getTotalMemory()
514+ llvm::capacity_in_bytes(MacroDefinitions)
515+ llvm::capacity_in_bytes(PreprocessedEntities)
516+ llvm::capacity_in_bytes(LoadedPreprocessedEntities)
517+ llvm::capacity_in_bytes(SkippedRanges);
Defines the clang::IdentifierInfo, clang::IdentifierTable, and clang::Selector interfaces.
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
llvm::MachO::FileType FileType
Defines the clang::MacroInfo and clang::MacroDirective classes.
static bool isPreprocessedEntityIfInFileID(PreprocessedEntity *PPE, FileID FID, SourceManager &SM)
Defines the clang::SourceLocation class and associated facilities.
static bool isInvalid(LocType Loc, bool *Invalid)
Defines the SourceManager interface.
Defines the clang::TokenKind enum and support functions.
__DEVICE__ void * memcpy(void *__a, const void *__b, size_t __c)
Represents a character-granular source range.
SourceLocation getEnd() const
SourceLocation getBegin() const
An abstract class that should be subclassed by any external source of preprocessing record entries.
virtual ~ExternalPreprocessingRecordSource()
An opaque identifier used by SourceManager which refers to a source file (MemoryBuffer) along with it...
tok::PPKeywordKind getPPKeywordID() const
Return the preprocessor keyword ID for this identifier.
Record the location of an inclusion directive, such as an #include or #import statement.
InclusionKind
The kind of inclusion directives known to the preprocessor.
@ IncludeMacros
A Clang #__include_macros directive.
@ Import
An Objective-C #import directive.
@ IncludeNext
A GNU #include_next directive.
@ Include
An #include directive.
InclusionDirective(PreprocessingRecord &PPRec, InclusionKind Kind, StringRef FileName, bool InQuotes, bool ImportedModule, OptionalFileEntryRef File, SourceRange Range)
MacroArgs - An instance of this class captures information about the formal arguments specified to a ...
Record the location of a macro definition.
A description of the current definition of a macro.
MacroInfo * getMacroInfo() const
Get the MacroInfo that should be used for this definition.
void forAllDefinitions(Fn F) const
Encapsulates changes to the "macros namespace" (the location where the macro name became active,...
const MacroInfo * getMacroInfo() const
Records the location of a macro expansion.
Encapsulates the data about a macro definition (e.g.
SourceLocation getDefinitionEndLoc() const
Return the location of the last token in the macro.
bool isBuiltinMacro() const
Return true if this macro requires processing before expansion.
SourceLocation getDefinitionLoc() const
Return the location that the macro was defined at.
Describes a module or submodule.
Base class that describes a preprocessed entity, which may be a preprocessor directive or macro expan...
@ InvalidKind
Indicates a problem trying to load the preprocessed entity.
SourceRange getSourceRange() const LLVM_READONLY
Retrieve the source range that covers this entire preprocessed entity.
Records the presence of a preprocessor directive.
Iteration over the preprocessed entities.
A record of the steps taken while preprocessing a source file, including the various preprocessing di...
PreprocessingRecord(SourceManager &SM)
Construct a new preprocessing record.
void * Allocate(unsigned Size, unsigned Align=8)
Allocate memory in the preprocessing record.
llvm::iterator_range< iterator > getPreprocessedEntitiesInRange(SourceRange R)
Returns a range of preprocessed entities that source range R encompasses.
MacroDefinitionRecord * findMacroDefinition(const MacroInfo *MI)
Retrieve the macro definition that corresponds to the given MacroInfo.
PPEntityID addPreprocessedEntity(PreprocessedEntity *Entity)
Add a new preprocessed entity to this record.
bool isEntityInFileID(iterator PPEI, FileID FID)
Returns true if the preprocessed entity that PPEI iterator points to is coming from the file FID.
size_t getTotalMemory() const
std::pair< int, int > Result
void SetExternalSource(ExternalPreprocessingRecordSource &Source)
Set the external source for preprocessed entities.
Encodes a location in the source.
SourceLocation getLocWithOffset(IntTy Offset) const
Return a source location with the specified offset from this SourceLocation.
This class handles loading and caching of source files into memory.
bool isLocalSourceLocation(SourceLocation Loc) const
Returns true if Loc did not come from a PCH/Module.
bool isLoadedSourceLocation(SourceLocation Loc) const
Returns true if Loc came from a PCH/Module.
bool isBeforeInTranslationUnit(SourceLocation LHS, SourceLocation RHS) const
Determines the order of 2 source locations in the translation unit.
A trivial tuple used to represent a source range.
SourceLocation getEnd() const
SourceLocation getBegin() 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.
CharacteristicKind
Indicates whether a file or directory holds normal user code, system code, or system code which is im...
The JSON file list parser is used to communicate input to InstallAPI.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4