clang  3.9.0
PreprocessingRecord.h
Go to the documentation of this file.
1 //===--- PreprocessingRecord.h - Record of Preprocessing --------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file defines the PreprocessingRecord class, which maintains a record
11 // of what occurred during preprocessing.
12 //
13 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_CLANG_LEX_PREPROCESSINGRECORD_H
15 #define LLVM_CLANG_LEX_PREPROCESSINGRECORD_H
16 
19 #include "clang/Lex/PPCallbacks.h"
20 #include "llvm/ADT/DenseMap.h"
21 #include "llvm/ADT/Optional.h"
22 #include "llvm/ADT/SmallVector.h"
23 #include "llvm/ADT/iterator.h"
24 #include "llvm/Support/Allocator.h"
25 #include "llvm/Support/Compiler.h"
26 #include <vector>
27 
28 namespace clang {
29  class IdentifierInfo;
30  class MacroInfo;
31  class PreprocessingRecord;
32 }
33 
34 /// \brief Allocates memory within a Clang preprocessing record.
35 void *operator new(size_t bytes, clang::PreprocessingRecord &PR,
36  unsigned alignment = 8) LLVM_NOEXCEPT;
37 
38 /// \brief Frees memory allocated in a Clang preprocessing record.
39 void operator delete(void *ptr, clang::PreprocessingRecord &PR,
40  unsigned) LLVM_NOEXCEPT;
41 
42 namespace clang {
43  class MacroDefinitionRecord;
44  class FileEntry;
45 
46  /// \brief Base class that describes a preprocessed entity, which may be a
47  /// preprocessor directive or macro expansion.
49  public:
50  /// \brief The kind of preprocessed entity an object describes.
51  enum EntityKind {
52  /// \brief Indicates a problem trying to load the preprocessed entity.
54 
55  /// \brief A macro expansion.
57 
58  /// \defgroup Preprocessing directives
59  /// @{
60 
61  /// \brief A macro definition.
63 
64  /// \brief An inclusion directive, such as \c \#include, \c
65  /// \#import, or \c \#include_next.
67 
68  /// @}
69 
72  };
73 
74  private:
75  /// \brief The kind of preprocessed entity that this object describes.
77 
78  /// \brief The source range that covers this preprocessed entity.
79  SourceRange Range;
80 
81  protected:
83  : Kind(Kind), Range(Range) { }
84 
85  friend class PreprocessingRecord;
86 
87  public:
88  /// \brief Retrieve the kind of preprocessed entity stored in this object.
89  EntityKind getKind() const { return Kind; }
90 
91  /// \brief Retrieve the source range that covers this entire preprocessed
92  /// entity.
93  SourceRange getSourceRange() const LLVM_READONLY { return Range; }
94 
95  /// \brief Returns true if there was a problem loading the preprocessed
96  /// entity.
97  bool isInvalid() const { return Kind == InvalidKind; }
98 
99  // Only allow allocation of preprocessed entities using the allocator
100  // in PreprocessingRecord or by doing a placement new.
101  void *operator new(size_t bytes, PreprocessingRecord &PR,
102  unsigned alignment = 8) LLVM_NOEXCEPT {
103  return ::operator new(bytes, PR, alignment);
104  }
105 
106  void *operator new(size_t bytes, void *mem) LLVM_NOEXCEPT { return mem; }
107 
108  void operator delete(void *ptr, PreprocessingRecord &PR,
109  unsigned alignment) LLVM_NOEXCEPT {
110  return ::operator delete(ptr, PR, alignment);
111  }
112 
113  void operator delete(void *, std::size_t) LLVM_NOEXCEPT {}
114  void operator delete(void *, void *) LLVM_NOEXCEPT {}
115 
116  private:
117  // Make vanilla 'new' and 'delete' illegal for preprocessed entities.
118  void *operator new(size_t bytes) LLVM_NOEXCEPT;
119  void operator delete(void *data) LLVM_NOEXCEPT;
120  };
121 
122  /// \brief Records the presence of a preprocessor directive.
124  public:
126  : PreprocessedEntity(Kind, Range) { }
127 
128  // Implement isa/cast/dyncast/etc.
129  static bool classof(const PreprocessedEntity *PD) {
130  return PD->getKind() >= FirstPreprocessingDirective &&
132  }
133  };
134 
135  /// \brief Record the location of a macro definition.
137  /// \brief The name of the macro being defined.
138  const IdentifierInfo *Name;
139 
140  public:
141  explicit MacroDefinitionRecord(const IdentifierInfo *Name,
142  SourceRange Range)
143  : PreprocessingDirective(MacroDefinitionKind, Range), Name(Name) {}
144 
145  /// \brief Retrieve the name of the macro being defined.
146  const IdentifierInfo *getName() const { return Name; }
147 
148  /// \brief Retrieve the location of the macro name in the definition.
150 
151  // Implement isa/cast/dyncast/etc.
152  static bool classof(const PreprocessedEntity *PE) {
153  return PE->getKind() == MacroDefinitionKind;
154  }
155  };
156 
157  /// \brief Records the location of a macro expansion.
159  /// \brief The definition of this macro or the name of the macro if it is
160  /// a builtin macro.
161  llvm::PointerUnion<IdentifierInfo *, MacroDefinitionRecord *> NameOrDef;
162 
163  public:
166  NameOrDef(BuiltinName) {}
167 
169  : PreprocessedEntity(MacroExpansionKind, Range), NameOrDef(Definition) {
170  }
171 
172  /// \brief True if it is a builtin macro.
173  bool isBuiltinMacro() const { return NameOrDef.is<IdentifierInfo *>(); }
174 
175  /// \brief The name of the macro being expanded.
176  const IdentifierInfo *getName() const {
178  return Def->getName();
179  return NameOrDef.get<IdentifierInfo *>();
180  }
181 
182  /// \brief The definition of the macro being expanded. May return null if
183  /// this is a builtin macro.
185  return NameOrDef.dyn_cast<MacroDefinitionRecord *>();
186  }
187 
188  // Implement isa/cast/dyncast/etc.
189  static bool classof(const PreprocessedEntity *PE) {
190  return PE->getKind() == MacroExpansionKind;
191  }
192  };
193 
194  /// \brief Record the location of an inclusion directive, such as an
195  /// \c \#include or \c \#import statement.
197  public:
198  /// \brief The kind of inclusion directives known to the
199  /// preprocessor.
201  /// \brief An \c \#include directive.
203  /// \brief An Objective-C \c \#import directive.
205  /// \brief A GNU \c \#include_next directive.
207  /// \brief A Clang \c \#__include_macros directive.
209  };
210 
211  private:
212  /// \brief The name of the file that was included, as written in
213  /// the source.
214  StringRef FileName;
215 
216  /// \brief Whether the file name was in quotation marks; otherwise, it was
217  /// in angle brackets.
218  unsigned InQuotes : 1;
219 
220  /// \brief The kind of inclusion directive we have.
221  ///
222  /// This is a value of type InclusionKind.
223  unsigned Kind : 2;
224 
225  /// \brief Whether the inclusion directive was automatically turned into
226  /// a module import.
227  unsigned ImportedModule : 1;
228 
229  /// \brief The file that was included.
230  const FileEntry *File;
231 
232  public:
234  InclusionKind Kind, StringRef FileName,
235  bool InQuotes, bool ImportedModule,
236  const FileEntry *File, SourceRange Range);
237 
238  /// \brief Determine what kind of inclusion directive this is.
239  InclusionKind getKind() const { return static_cast<InclusionKind>(Kind); }
240 
241  /// \brief Retrieve the included file name as it was written in the source.
242  StringRef getFileName() const { return FileName; }
243 
244  /// \brief Determine whether the included file name was written in quotes;
245  /// otherwise, it was written in angle brackets.
246  bool wasInQuotes() const { return InQuotes; }
247 
248  /// \brief Determine whether the inclusion directive was automatically
249  /// turned into a module import.
250  bool importedModule() const { return ImportedModule; }
251 
252  /// \brief Retrieve the file entry for the actual file that was included
253  /// by this directive.
254  const FileEntry *getFile() const { return File; }
255 
256  // Implement isa/cast/dyncast/etc.
257  static bool classof(const PreprocessedEntity *PE) {
258  return PE->getKind() == InclusionDirectiveKind;
259  }
260  };
261 
262  /// \brief An abstract class that should be subclassed by any external source
263  /// of preprocessing record entries.
265  public:
267 
268  /// \brief Read a preallocated preprocessed entity from the external source.
269  ///
270  /// \returns null if an error occurred that prevented the preprocessed
271  /// entity from being loaded.
272  virtual PreprocessedEntity *ReadPreprocessedEntity(unsigned Index) = 0;
273 
274  /// \brief Returns a pair of [Begin, End) indices of preallocated
275  /// preprocessed entities that \p Range encompasses.
276  virtual std::pair<unsigned, unsigned>
278 
279  /// \brief Optionally returns true or false if the preallocated preprocessed
280  /// entity with index \p Index came from file \p FID.
282  FileID FID) {
283  return None;
284  }
285  };
286 
287  /// \brief A record of the steps taken while preprocessing a source file,
288  /// including the various preprocessing directives processed, macros
289  /// expanded, etc.
291  SourceManager &SourceMgr;
292 
293  /// \brief Allocator used to store preprocessing objects.
294  llvm::BumpPtrAllocator BumpAlloc;
295 
296  /// \brief The set of preprocessed entities in this record, in order they
297  /// were seen.
298  std::vector<PreprocessedEntity *> PreprocessedEntities;
299 
300  /// \brief The set of preprocessed entities in this record that have been
301  /// loaded from external sources.
302  ///
303  /// The entries in this vector are loaded lazily from the external source,
304  /// and are referenced by the iterator using negative indices.
305  std::vector<PreprocessedEntity *> LoadedPreprocessedEntities;
306 
307  /// \brief The set of ranges that were skipped by the preprocessor,
308  std::vector<SourceRange> SkippedRanges;
309 
310  /// \brief Global (loaded or local) ID for a preprocessed entity.
311  /// Negative values are used to indicate preprocessed entities
312  /// loaded from the external source while non-negative values are used to
313  /// indicate preprocessed entities introduced by the current preprocessor.
314  /// Value -1 corresponds to element 0 in the loaded entities vector,
315  /// value -2 corresponds to element 1 in the loaded entities vector, etc.
316  /// Value 0 is an invalid value, the index to local entities is 1-based,
317  /// value 1 corresponds to element 0 in the local entities vector,
318  /// value 2 corresponds to element 1 in the local entities vector, etc.
319  class PPEntityID {
320  int ID;
321  explicit PPEntityID(int ID) : ID(ID) {}
322  friend class PreprocessingRecord;
323  public:
324  PPEntityID() : ID(0) {}
325  };
326 
327  static PPEntityID getPPEntityID(unsigned Index, bool isLoaded) {
328  return isLoaded ? PPEntityID(-int(Index)-1) : PPEntityID(Index+1);
329  }
330 
331  /// \brief Mapping from MacroInfo structures to their definitions.
332  llvm::DenseMap<const MacroInfo *, MacroDefinitionRecord *> MacroDefinitions;
333 
334  /// \brief External source of preprocessed entities.
335  ExternalPreprocessingRecordSource *ExternalSource;
336 
337  /// \brief Retrieve the preprocessed entity at the given ID.
338  PreprocessedEntity *getPreprocessedEntity(PPEntityID PPID);
339 
340  /// \brief Retrieve the loaded preprocessed entity at the given index.
341  PreprocessedEntity *getLoadedPreprocessedEntity(unsigned Index);
342 
343  /// \brief Determine the number of preprocessed entities that were
344  /// loaded (or can be loaded) from an external source.
345  unsigned getNumLoadedPreprocessedEntities() const {
346  return LoadedPreprocessedEntities.size();
347  }
348 
349  /// \brief Returns a pair of [Begin, End) indices of local preprocessed
350  /// entities that \p Range encompasses.
351  std::pair<unsigned, unsigned>
352  findLocalPreprocessedEntitiesInRange(SourceRange Range) const;
353  unsigned findBeginLocalPreprocessedEntity(SourceLocation Loc) const;
354  unsigned findEndLocalPreprocessedEntity(SourceLocation Loc) const;
355 
356  /// \brief Allocate space for a new set of loaded preprocessed entities.
357  ///
358  /// \returns The index into the set of loaded preprocessed entities, which
359  /// corresponds to the first newly-allocated entity.
360  unsigned allocateLoadedEntities(unsigned NumEntities);
361 
362  /// \brief Register a new macro definition.
363  void RegisterMacroDefinition(MacroInfo *Macro, MacroDefinitionRecord *Def);
364 
365  public:
366  /// \brief Construct a new preprocessing record.
368 
369  /// \brief Allocate memory in the preprocessing record.
370  void *Allocate(unsigned Size, unsigned Align = 8) {
371  return BumpAlloc.Allocate(Size, Align);
372  }
373 
374  /// \brief Deallocate memory in the preprocessing record.
375  void Deallocate(void *Ptr) { }
376 
377  size_t getTotalMemory() const;
378 
379  SourceManager &getSourceManager() const { return SourceMgr; }
380 
381  /// Iteration over the preprocessed entities.
382  ///
383  /// In a complete iteration, the iterator walks the range [-M, N),
384  /// where negative values are used to indicate preprocessed entities
385  /// loaded from the external source while non-negative values are used to
386  /// indicate preprocessed entities introduced by the current preprocessor.
387  /// However, to provide iteration in source order (for, e.g., chained
388  /// precompiled headers), dereferencing the iterator flips the negative
389  /// values (corresponding to loaded entities), so that position -M
390  /// corresponds to element 0 in the loaded entities vector, position -M+1
391  /// corresponds to element 1 in the loaded entities vector, etc. This
392  /// gives us a reasonably efficient, source-order walk.
393  ///
394  /// We define this as a wrapping iterator around an int. The
395  /// iterator_adaptor_base class forwards the iterator methods to basic
396  /// integer arithmetic.
397  class iterator : public llvm::iterator_adaptor_base<
398  iterator, int, std::random_access_iterator_tag,
399  PreprocessedEntity *, int, PreprocessedEntity *,
400  PreprocessedEntity *> {
401  PreprocessingRecord *Self;
402 
404  : iterator::iterator_adaptor_base(Position), Self(Self) {}
405  friend class PreprocessingRecord;
406 
407  public:
408  iterator() : iterator(nullptr, 0) {}
409 
411  bool isLoaded = this->I < 0;
412  unsigned Index = isLoaded ?
413  Self->LoadedPreprocessedEntities.size() + this->I : this->I;
414  PPEntityID ID = Self->getPPEntityID(Index, isLoaded);
415  return Self->getPreprocessedEntity(ID);
416  }
417  PreprocessedEntity *operator->() const { return **this; }
418  };
419 
420  /// \brief Begin iterator for all preprocessed entities.
422  return iterator(this, -(int)LoadedPreprocessedEntities.size());
423  }
424 
425  /// \brief End iterator for all preprocessed entities.
427  return iterator(this, PreprocessedEntities.size());
428  }
429 
430  /// \brief Begin iterator for local, non-loaded, preprocessed entities.
432  return iterator(this, 0);
433  }
434 
435  /// \brief End iterator for local, non-loaded, preprocessed entities.
437  return iterator(this, PreprocessedEntities.size());
438  }
439 
440  /// \brief iterator range for the given range of loaded
441  /// preprocessed entities.
442  llvm::iterator_range<iterator> getIteratorsForLoadedRange(unsigned start,
443  unsigned count) {
444  unsigned end = start + count;
445  assert(end <= LoadedPreprocessedEntities.size());
446  return llvm::make_range(
447  iterator(this, int(start) - LoadedPreprocessedEntities.size()),
448  iterator(this, int(end) - LoadedPreprocessedEntities.size()));
449  }
450 
451  /// \brief Returns a range of preprocessed entities that source range \p R
452  /// encompasses.
453  ///
454  /// \param R the range to look for preprocessed entities.
455  ///
456  llvm::iterator_range<iterator>
458 
459  /// \brief Returns true if the preprocessed entity that \p PPEI iterator
460  /// points to is coming from the file \p FID.
461  ///
462  /// Can be used to avoid implicit deserializations of preallocated
463  /// preprocessed entities if we only care about entities of a specific file
464  /// and not from files \#included in the range given at
465  /// \see getPreprocessedEntitiesInRange.
466  bool isEntityInFileID(iterator PPEI, FileID FID);
467 
468  /// \brief Add a new preprocessed entity to this record.
469  PPEntityID addPreprocessedEntity(PreprocessedEntity *Entity);
470 
471  /// \brief Set the external source for preprocessed entities.
473 
474  /// \brief Retrieve the external source for preprocessed entities.
476  return ExternalSource;
477  }
478 
479  /// \brief Retrieve the macro definition that corresponds to the given
480  /// \c MacroInfo.
482 
483  /// \brief Retrieve all ranges that got skipped while preprocessing.
484  const std::vector<SourceRange> &getSkippedRanges() const {
485  return SkippedRanges;
486  }
487 
488  private:
489  void MacroExpands(const Token &Id, const MacroDefinition &MD,
490  SourceRange Range, const MacroArgs *Args) override;
491  void MacroDefined(const Token &Id, const MacroDirective *MD) override;
492  void MacroUndefined(const Token &Id, const MacroDefinition &MD) override;
493  void InclusionDirective(SourceLocation HashLoc, const Token &IncludeTok,
494  StringRef FileName, bool IsAngled,
495  CharSourceRange FilenameRange,
496  const FileEntry *File, StringRef SearchPath,
497  StringRef RelativePath,
498  const Module *Imported) override;
499  void Ifdef(SourceLocation Loc, const Token &MacroNameTok,
500  const MacroDefinition &MD) override;
501  void Ifndef(SourceLocation Loc, const Token &MacroNameTok,
502  const MacroDefinition &MD) override;
503  /// \brief Hook called whenever the 'defined' operator is seen.
504  void Defined(const Token &MacroNameTok, const MacroDefinition &MD,
505  SourceRange Range) override;
506 
507  void SourceRangeSkipped(SourceRange Range) override;
508 
509  void addMacroExpansion(const Token &Id, const MacroInfo *MI,
510  SourceRange Range);
511 
512  /// \brief Cached result of the last \see getPreprocessedEntitiesInRange
513  /// query.
514  struct {
516  std::pair<int, int> Result;
517  } CachedRangeQuery;
518 
519  std::pair<int, int> getPreprocessedEntitiesInRangeSlow(SourceRange R);
520 
521  friend class ASTReader;
522  friend class ASTWriter;
523  };
524 } // end namespace clang
525 
526 inline void *operator new(size_t bytes, clang::PreprocessingRecord &PR,
527  unsigned alignment) LLVM_NOEXCEPT {
528  return PR.Allocate(bytes, alignment);
529 }
530 
531 inline void operator delete(void *ptr, clang::PreprocessingRecord &PR,
532  unsigned) LLVM_NOEXCEPT {
533  PR.Deallocate(ptr);
534 }
535 
536 #endif // LLVM_CLANG_LEX_PREPROCESSINGRECORD_H
static bool classof(const PreprocessedEntity *PE)
int Position
__SIZE_TYPE__ size_t
The unsigned integer type of the result of the sizeof operator.
Definition: opencl-c.h:53
MacroExpansion(MacroDefinitionRecord *Definition, SourceRange Range)
A description of the current definition of a macro.
Definition: MacroInfo.h:563
Indicates a problem trying to load the preprocessed entity.
Base class that describes a preprocessed entity, which may be a preprocessor directive or macro expan...
virtual PreprocessedEntity * ReadPreprocessedEntity(unsigned Index)=0
Read a preallocated preprocessed entity from the external source.
const std::vector< SourceRange > & getSkippedRanges() const
Retrieve all ranges that got skipped while preprocessing.
SourceRange getSourceRange() const LLVM_READONLY
Retrieve the source range that covers this entire preprocessed entity.
iterator local_end()
End iterator for local, non-loaded, preprocessed entities.
StringRef getFileName() const
Retrieve the included file name as it was written in the source.
bool isBuiltinMacro() const
True if it is a builtin macro.
static StringRef bytes(const std::vector< T, Allocator > &v)
Definition: ASTWriter.cpp:69
This interface provides a way to observe the actions of the preprocessor as it does its thing...
Definition: PPCallbacks.h:38
Records the presence of a preprocessor directive.
One of these records is kept for each identifier that is lexed.
Iteration over the preprocessed entities.
InclusionKind getKind() const
Determine what kind of inclusion directive this is.
Record the location of a macro definition.
Token - This structure provides full information about a lexed token.
Definition: Token.h:35
bool wasInQuotes() const
Determine whether the included file name was written in quotes; otherwise, it was written in angle br...
Describes a module or submodule.
Definition: Basic/Module.h:47
llvm::iterator_range< iterator > getPreprocessedEntitiesInRange(SourceRange R)
Returns a range of preprocessed entities that source range R encompasses.
EntityKind getKind() const
Retrieve the kind of preprocessed entity stored in this object.
A record of the steps taken while preprocessing a source file, including the various preprocessing di...
virtual std::pair< unsigned, unsigned > findPreprocessedEntitiesInRange(SourceRange Range)=0
Returns a pair of [Begin, End) indices of preallocated preprocessed entities that Range encompasses...
MacroDefinitionRecord * getDefinition() const
The definition of the macro being expanded.
MacroExpansion(IdentifierInfo *BuiltinName, SourceRange Range)
SourceManager & getSourceManager() const
detail::InMemoryDirectory::const_iterator I
const FileEntry * getFile() const
Retrieve the file entry for the actual file that was included by this directive.
Records the location of a macro expansion.
PreprocessingRecord(SourceManager &SM)
Construct a new preprocessing record.
A GNU #include_next directive.
static bool classof(const PreprocessedEntity *PE)
std::pair< int, int > Result
virtual Optional< bool > isPreprocessedEntityInFileID(unsigned Index, FileID FID)
Optionally returns true or false if the preallocated preprocessed entity with index Index came from f...
static bool classof(const PreprocessedEntity *PD)
StringRef getName() const
Return the actual identifier string.
void * Allocate(unsigned Size, unsigned Align=8)
Allocate memory in the preprocessing record.
Represents a character-granular source range.
MacroArgs - An instance of this class captures information about the formal arguments specified to a ...
Definition: MacroArgs.h:29
PreprocessedEntity * operator->() const
Defines the clang::IdentifierInfo, clang::IdentifierTable, and clang::Selector interfaces.
bool importedModule() const
Determine whether the inclusion directive was automatically turned into a module import.
const IdentifierInfo * getName() const
The name of the macro being expanded.
Record the location of an inclusion directive, such as an #include or #import statement.
InclusionKind
The kind of inclusion directives known to the preprocessor.
llvm::iterator_range< iterator > getIteratorsForLoadedRange(unsigned start, unsigned count)
iterator range for the given range of loaded preprocessed entities.
ExternalPreprocessingRecordSource * getExternalSource() const
Retrieve the external source for preprocessed entities.
InclusionDirective(PreprocessingRecord &PPRec, InclusionKind Kind, StringRef FileName, bool InQuotes, bool ImportedModule, const FileEntry *File, SourceRange Range)
const SourceManager & SM
Definition: Format.cpp:1184
EntityKind
The kind of preprocessed entity an object describes.
Encapsulates changes to the "macros namespace" (the location where the macro name became active...
Definition: MacroInfo.h:307
StringRef FileName
Definition: Format.cpp:1313
Kind
Encodes a location in the source.
void Deallocate(void *Ptr)
Deallocate memory in the preprocessing record.
const TemplateArgument * iterator
Definition: Type.h:4233
const std::string ID
PreprocessedEntity(EntityKind Kind, SourceRange Range)
Cached information about one file (either on disk or in the virtual file system). ...
Definition: FileManager.h:53
An abstract class that should be subclassed by any external source of preprocessing record entries...
MacroDefinitionRecord(const IdentifierInfo *Name, SourceRange Range)
SourceLocation getBegin() const
An inclusion directive, such as #include, #import, or #include_next.
bool isEntityInFileID(iterator PPEI, FileID FID)
Returns true if the preprocessed entity that PPEI iterator points to is coming from the file FID...
const IdentifierInfo * getName() const
Retrieve the name of the macro being defined.
A Clang #__include_macros directive.
An opaque identifier used by SourceManager which refers to a source file (MemoryBuffer) along with it...
Represents a template argument.
Definition: TemplateBase.h:40
iterator end()
End iterator for all preprocessed entities.
static bool classof(const PreprocessedEntity *PE)
Reads an AST files chain containing the contents of a translation unit.
Definition: ASTReader.h:312
Encapsulates the data about a macro definition (e.g.
Definition: MacroInfo.h:34
PPEntityID addPreprocessedEntity(PreprocessedEntity *Entity)
Add a new preprocessed entity to this record.
An Objective-C #import directive.
Defines the PPCallbacks interface.
Defines the clang::SourceLocation class and associated facilities.
PreprocessedEntity * operator*() const
iterator begin()
Begin iterator for all preprocessed entities.
PreprocessingDirective(EntityKind Kind, SourceRange Range)
Writes an AST file containing the contents of a translation unit.
Definition: ASTWriter.h:84
SourceLocation getLocation() const
Retrieve the location of the macro name in the definition.
MacroDefinitionRecord * findMacroDefinition(const MacroInfo *MI)
Retrieve the macro definition that corresponds to the given MacroInfo.
void SetExternalSource(ExternalPreprocessingRecordSource &Source)
Set the external source for preprocessed entities.
A trivial tuple used to represent a source range.
This class handles loading and caching of source files into memory.
bool isInvalid() const
Returns true if there was a problem loading the preprocessed entity.
iterator local_begin()
Begin iterator for local, non-loaded, preprocessed entities.