clang  5.0.0
PPCallbacks.h
Go to the documentation of this file.
1 //===--- PPCallbacks.h - Callbacks for Preprocessor actions -----*- 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 /// \file
11 /// \brief Defines the PPCallbacks interface.
12 ///
13 //===----------------------------------------------------------------------===//
14 
15 #ifndef LLVM_CLANG_LEX_PPCALLBACKS_H
16 #define LLVM_CLANG_LEX_PPCALLBACKS_H
17 
21 #include "clang/Lex/ModuleLoader.h"
22 #include "clang/Lex/Pragma.h"
23 #include "llvm/ADT/StringRef.h"
24 
25 namespace clang {
26  class Token;
27  class IdentifierInfo;
28  class MacroDefinition;
29  class MacroDirective;
30  class MacroArgs;
31 
32 /// \brief This interface provides a way to observe the actions of the
33 /// preprocessor as it does its thing.
34 ///
35 /// Clients can define their hooks here to implement preprocessor level tools.
36 class PPCallbacks {
37 public:
38  virtual ~PPCallbacks();
39 
42  };
43 
44  /// \brief Callback invoked whenever a source file is entered or exited.
45  ///
46  /// \param Loc Indicates the new location.
47  /// \param PrevFID the file that was exited if \p Reason is ExitFile.
48  virtual void FileChanged(SourceLocation Loc, FileChangeReason Reason,
50  FileID PrevFID = FileID()) {
51  }
52 
53  /// \brief Callback invoked whenever a source file is skipped as the result
54  /// of header guard optimization.
55  ///
56  /// \param SkippedFile The file that is skipped instead of entering \#include
57  ///
58  /// \param FilenameTok The file name token in \#include "FileName" directive
59  /// or macro expanded file name token from \#include MACRO(PARAMS) directive.
60  /// Note that FilenameTok contains corresponding quotes/angles symbols.
61  virtual void FileSkipped(const FileEntry &SkippedFile,
62  const Token &FilenameTok,
63  SrcMgr::CharacteristicKind FileType) {
64  }
65 
66  /// \brief Callback invoked whenever an inclusion directive results in a
67  /// file-not-found error.
68  ///
69  /// \param FileName The name of the file being included, as written in the
70  /// source code.
71  ///
72  /// \param RecoveryPath If this client indicates that it can recover from
73  /// this missing file, the client should set this as an additional header
74  /// search patch.
75  ///
76  /// \returns true to indicate that the preprocessor should attempt to recover
77  /// by adding \p RecoveryPath as a header search path.
78  virtual bool FileNotFound(StringRef FileName,
79  SmallVectorImpl<char> &RecoveryPath) {
80  return false;
81  }
82 
83  /// \brief Callback invoked whenever an inclusion directive of
84  /// any kind (\c \#include, \c \#import, etc.) has been processed, regardless
85  /// of whether the inclusion will actually result in an inclusion.
86  ///
87  /// \param HashLoc The location of the '#' that starts the inclusion
88  /// directive.
89  ///
90  /// \param IncludeTok The token that indicates the kind of inclusion
91  /// directive, e.g., 'include' or 'import'.
92  ///
93  /// \param FileName The name of the file being included, as written in the
94  /// source code.
95  ///
96  /// \param IsAngled Whether the file name was enclosed in angle brackets;
97  /// otherwise, it was enclosed in quotes.
98  ///
99  /// \param FilenameRange The character range of the quotes or angle brackets
100  /// for the written file name.
101  ///
102  /// \param File The actual file that may be included by this inclusion
103  /// directive.
104  ///
105  /// \param SearchPath Contains the search path which was used to find the file
106  /// in the file system. If the file was found via an absolute include path,
107  /// SearchPath will be empty. For framework includes, the SearchPath and
108  /// RelativePath will be split up. For example, if an include of "Some/Some.h"
109  /// is found via the framework path
110  /// "path/to/Frameworks/Some.framework/Headers/Some.h", SearchPath will be
111  /// "path/to/Frameworks/Some.framework/Headers" and RelativePath will be
112  /// "Some.h".
113  ///
114  /// \param RelativePath The path relative to SearchPath, at which the include
115  /// file was found. This is equal to FileName except for framework includes.
116  ///
117  /// \param Imported The module, whenever an inclusion directive was
118  /// automatically turned into a module import or null otherwise.
119  ///
120  virtual void InclusionDirective(SourceLocation HashLoc,
121  const Token &IncludeTok,
122  StringRef FileName,
123  bool IsAngled,
124  CharSourceRange FilenameRange,
125  const FileEntry *File,
126  StringRef SearchPath,
127  StringRef RelativePath,
128  const Module *Imported) {
129  }
130 
131  /// \brief Callback invoked whenever there was an explicit module-import
132  /// syntax.
133  ///
134  /// \param ImportLoc The location of import directive token.
135  ///
136  /// \param Path The identifiers (and their locations) of the module
137  /// "path", e.g., "std.vector" would be split into "std" and "vector".
138  ///
139  /// \param Imported The imported module; can be null if importing failed.
140  ///
141  virtual void moduleImport(SourceLocation ImportLoc,
142  ModuleIdPath Path,
143  const Module *Imported) {
144  }
145 
146  /// \brief Callback invoked when the end of the main file is reached.
147  ///
148  /// No subsequent callbacks will be made.
149  virtual void EndOfMainFile() {
150  }
151 
152  /// \brief Callback invoked when a \#ident or \#sccs directive is read.
153  /// \param Loc The location of the directive.
154  /// \param str The text of the directive.
155  ///
156  virtual void Ident(SourceLocation Loc, StringRef str) {
157  }
158 
159  /// \brief Callback invoked when start reading any pragma directive.
160  virtual void PragmaDirective(SourceLocation Loc,
161  PragmaIntroducerKind Introducer) {
162  }
163 
164  /// \brief Callback invoked when a \#pragma comment directive is read.
166  StringRef Str) {
167  }
168 
169  /// \brief Callback invoked when a \#pragma detect_mismatch directive is
170  /// read.
171  virtual void PragmaDetectMismatch(SourceLocation Loc, StringRef Name,
172  StringRef Value) {
173  }
174 
175  /// \brief Callback invoked when a \#pragma clang __debug directive is read.
176  /// \param Loc The location of the debug directive.
177  /// \param DebugType The identifier following __debug.
178  virtual void PragmaDebug(SourceLocation Loc, StringRef DebugType) {
179  }
180 
181  /// \brief Determines the kind of \#pragma invoking a call to PragmaMessage.
183  /// \brief \#pragma message has been invoked.
185 
186  /// \brief \#pragma GCC warning has been invoked.
188 
189  /// \brief \#pragma GCC error has been invoked.
191  };
192 
193  /// \brief Callback invoked when a \#pragma message directive is read.
194  /// \param Loc The location of the message directive.
195  /// \param Namespace The namespace of the message directive.
196  /// \param Kind The type of the message directive.
197  /// \param Str The text of the message directive.
198  virtual void PragmaMessage(SourceLocation Loc, StringRef Namespace,
199  PragmaMessageKind Kind, StringRef Str) {
200  }
201 
202  /// \brief Callback invoked when a \#pragma gcc diagnostic push directive
203  /// is read.
205  StringRef Namespace) {
206  }
207 
208  /// \brief Callback invoked when a \#pragma gcc diagnostic pop directive
209  /// is read.
211  StringRef Namespace) {
212  }
213 
214  /// \brief Callback invoked when a \#pragma gcc diagnostic directive is read.
215  virtual void PragmaDiagnostic(SourceLocation Loc, StringRef Namespace,
216  diag::Severity mapping, StringRef Str) {}
217 
218  /// \brief Called when an OpenCL extension is either disabled or
219  /// enabled with a pragma.
220  virtual void PragmaOpenCLExtension(SourceLocation NameLoc,
221  const IdentifierInfo *Name,
222  SourceLocation StateLoc, unsigned State) {
223  }
224 
225  /// \brief Callback invoked when a \#pragma warning directive is read.
226  virtual void PragmaWarning(SourceLocation Loc, StringRef WarningSpec,
227  ArrayRef<int> Ids) {
228  }
229 
230  /// \brief Callback invoked when a \#pragma warning(push) directive is read.
231  virtual void PragmaWarningPush(SourceLocation Loc, int Level) {
232  }
233 
234  /// \brief Callback invoked when a \#pragma warning(pop) directive is read.
235  virtual void PragmaWarningPop(SourceLocation Loc) {
236  }
237 
238  /// \brief Called by Preprocessor::HandleMacroExpandedIdentifier when a
239  /// macro invocation is found.
240  virtual void MacroExpands(const Token &MacroNameTok,
241  const MacroDefinition &MD, SourceRange Range,
242  const MacroArgs *Args) {}
243 
244  /// \brief Hook called whenever a macro definition is seen.
245  virtual void MacroDefined(const Token &MacroNameTok,
246  const MacroDirective *MD) {
247  }
248 
249  /// \brief Hook called whenever a macro \#undef is seen.
250  /// \param MacroNameTok The active Token
251  /// \param MD A MacroDefinition for the named macro.
252  /// \param Undef New MacroDirective if the macro was defined, null otherwise.
253  ///
254  /// MD is released immediately following this callback.
255  virtual void MacroUndefined(const Token &MacroNameTok,
256  const MacroDefinition &MD,
257  const MacroDirective *Undef) {
258  }
259 
260  /// \brief Hook called whenever the 'defined' operator is seen.
261  /// \param MD The MacroDirective if the name was a macro, null otherwise.
262  virtual void Defined(const Token &MacroNameTok, const MacroDefinition &MD,
263  SourceRange Range) {
264  }
265 
266  /// \brief Hook called when a source range is skipped.
267  /// \param Range The SourceRange that was skipped. The range begins at the
268  /// \#if/\#else directive and ends after the \#endif/\#else directive.
269  virtual void SourceRangeSkipped(SourceRange Range) {
270  }
271 
274  };
275 
276  /// \brief Hook called whenever an \#if is seen.
277  /// \param Loc the source location of the directive.
278  /// \param ConditionRange The SourceRange of the expression being tested.
279  /// \param ConditionValue The evaluated value of the condition.
280  ///
281  // FIXME: better to pass in a list (or tree!) of Tokens.
282  virtual void If(SourceLocation Loc, SourceRange ConditionRange,
283  ConditionValueKind ConditionValue) {
284  }
285 
286  /// \brief Hook called whenever an \#elif is seen.
287  /// \param Loc the source location of the directive.
288  /// \param ConditionRange The SourceRange of the expression being tested.
289  /// \param ConditionValue The evaluated value of the condition.
290  /// \param IfLoc the source location of the \#if/\#ifdef/\#ifndef directive.
291  // FIXME: better to pass in a list (or tree!) of Tokens.
292  virtual void Elif(SourceLocation Loc, SourceRange ConditionRange,
293  ConditionValueKind ConditionValue, SourceLocation IfLoc) {
294  }
295 
296  /// \brief Hook called whenever an \#ifdef is seen.
297  /// \param Loc the source location of the directive.
298  /// \param MacroNameTok Information on the token being tested.
299  /// \param MD The MacroDefinition if the name was a macro, null otherwise.
300  virtual void Ifdef(SourceLocation Loc, const Token &MacroNameTok,
301  const MacroDefinition &MD) {
302  }
303 
304  /// \brief Hook called whenever an \#ifndef is seen.
305  /// \param Loc the source location of the directive.
306  /// \param MacroNameTok Information on the token being tested.
307  /// \param MD The MacroDefiniton if the name was a macro, null otherwise.
308  virtual void Ifndef(SourceLocation Loc, const Token &MacroNameTok,
309  const MacroDefinition &MD) {
310  }
311 
312  /// \brief Hook called whenever an \#else is seen.
313  /// \param Loc the source location of the directive.
314  /// \param IfLoc the source location of the \#if/\#ifdef/\#ifndef directive.
315  virtual void Else(SourceLocation Loc, SourceLocation IfLoc) {
316  }
317 
318  /// \brief Hook called whenever an \#endif is seen.
319  /// \param Loc the source location of the directive.
320  /// \param IfLoc the source location of the \#if/\#ifdef/\#ifndef directive.
321  virtual void Endif(SourceLocation Loc, SourceLocation IfLoc) {
322  }
323 };
324 
325 /// \brief Simple wrapper class for chaining callbacks.
327  virtual void anchor();
328  std::unique_ptr<PPCallbacks> First, Second;
329 
330 public:
331  PPChainedCallbacks(std::unique_ptr<PPCallbacks> _First,
332  std::unique_ptr<PPCallbacks> _Second)
333  : First(std::move(_First)), Second(std::move(_Second)) {}
334 
337  FileID PrevFID) override {
338  First->FileChanged(Loc, Reason, FileType, PrevFID);
339  Second->FileChanged(Loc, Reason, FileType, PrevFID);
340  }
341 
342  void FileSkipped(const FileEntry &SkippedFile,
343  const Token &FilenameTok,
344  SrcMgr::CharacteristicKind FileType) override {
345  First->FileSkipped(SkippedFile, FilenameTok, FileType);
346  Second->FileSkipped(SkippedFile, FilenameTok, FileType);
347  }
348 
349  bool FileNotFound(StringRef FileName,
350  SmallVectorImpl<char> &RecoveryPath) override {
351  return First->FileNotFound(FileName, RecoveryPath) ||
352  Second->FileNotFound(FileName, RecoveryPath);
353  }
354 
355  void InclusionDirective(SourceLocation HashLoc, const Token &IncludeTok,
356  StringRef FileName, bool IsAngled,
357  CharSourceRange FilenameRange, const FileEntry *File,
358  StringRef SearchPath, StringRef RelativePath,
359  const Module *Imported) override {
360  First->InclusionDirective(HashLoc, IncludeTok, FileName, IsAngled,
361  FilenameRange, File, SearchPath, RelativePath,
362  Imported);
363  Second->InclusionDirective(HashLoc, IncludeTok, FileName, IsAngled,
364  FilenameRange, File, SearchPath, RelativePath,
365  Imported);
366  }
367 
369  const Module *Imported) override {
370  First->moduleImport(ImportLoc, Path, Imported);
371  Second->moduleImport(ImportLoc, Path, Imported);
372  }
373 
374  void EndOfMainFile() override {
375  First->EndOfMainFile();
376  Second->EndOfMainFile();
377  }
378 
379  void Ident(SourceLocation Loc, StringRef str) override {
380  First->Ident(Loc, str);
381  Second->Ident(Loc, str);
382  }
383 
385  StringRef Str) override {
386  First->PragmaComment(Loc, Kind, Str);
387  Second->PragmaComment(Loc, Kind, Str);
388  }
389 
391  StringRef Value) override {
392  First->PragmaDetectMismatch(Loc, Name, Value);
393  Second->PragmaDetectMismatch(Loc, Name, Value);
394  }
395 
396  void PragmaMessage(SourceLocation Loc, StringRef Namespace,
397  PragmaMessageKind Kind, StringRef Str) override {
398  First->PragmaMessage(Loc, Namespace, Kind, Str);
399  Second->PragmaMessage(Loc, Namespace, Kind, Str);
400  }
401 
402  void PragmaDiagnosticPush(SourceLocation Loc, StringRef Namespace) override {
403  First->PragmaDiagnosticPush(Loc, Namespace);
404  Second->PragmaDiagnosticPush(Loc, Namespace);
405  }
406 
407  void PragmaDiagnosticPop(SourceLocation Loc, StringRef Namespace) override {
408  First->PragmaDiagnosticPop(Loc, Namespace);
409  Second->PragmaDiagnosticPop(Loc, Namespace);
410  }
411 
412  void PragmaDiagnostic(SourceLocation Loc, StringRef Namespace,
413  diag::Severity mapping, StringRef Str) override {
414  First->PragmaDiagnostic(Loc, Namespace, mapping, Str);
415  Second->PragmaDiagnostic(Loc, Namespace, mapping, Str);
416  }
417 
419  SourceLocation StateLoc, unsigned State) override {
420  First->PragmaOpenCLExtension(NameLoc, Name, StateLoc, State);
421  Second->PragmaOpenCLExtension(NameLoc, Name, StateLoc, State);
422  }
423 
424  void PragmaWarning(SourceLocation Loc, StringRef WarningSpec,
425  ArrayRef<int> Ids) override {
426  First->PragmaWarning(Loc, WarningSpec, Ids);
427  Second->PragmaWarning(Loc, WarningSpec, Ids);
428  }
429 
430  void PragmaWarningPush(SourceLocation Loc, int Level) override {
431  First->PragmaWarningPush(Loc, Level);
432  Second->PragmaWarningPush(Loc, Level);
433  }
434 
435  void PragmaWarningPop(SourceLocation Loc) override {
436  First->PragmaWarningPop(Loc);
437  Second->PragmaWarningPop(Loc);
438  }
439 
440  void MacroExpands(const Token &MacroNameTok, const MacroDefinition &MD,
441  SourceRange Range, const MacroArgs *Args) override {
442  First->MacroExpands(MacroNameTok, MD, Range, Args);
443  Second->MacroExpands(MacroNameTok, MD, Range, Args);
444  }
445 
446  void MacroDefined(const Token &MacroNameTok,
447  const MacroDirective *MD) override {
448  First->MacroDefined(MacroNameTok, MD);
449  Second->MacroDefined(MacroNameTok, MD);
450  }
451 
452  void MacroUndefined(const Token &MacroNameTok,
453  const MacroDefinition &MD,
454  const MacroDirective *Undef) override {
455  First->MacroUndefined(MacroNameTok, MD, Undef);
456  Second->MacroUndefined(MacroNameTok, MD, Undef);
457  }
458 
459  void Defined(const Token &MacroNameTok, const MacroDefinition &MD,
460  SourceRange Range) override {
461  First->Defined(MacroNameTok, MD, Range);
462  Second->Defined(MacroNameTok, MD, Range);
463  }
464 
465  void SourceRangeSkipped(SourceRange Range) override {
466  First->SourceRangeSkipped(Range);
467  Second->SourceRangeSkipped(Range);
468  }
469 
470  /// \brief Hook called whenever an \#if is seen.
471  void If(SourceLocation Loc, SourceRange ConditionRange,
472  ConditionValueKind ConditionValue) override {
473  First->If(Loc, ConditionRange, ConditionValue);
474  Second->If(Loc, ConditionRange, ConditionValue);
475  }
476 
477  /// \brief Hook called whenever an \#elif is seen.
478  void Elif(SourceLocation Loc, SourceRange ConditionRange,
479  ConditionValueKind ConditionValue, SourceLocation IfLoc) override {
480  First->Elif(Loc, ConditionRange, ConditionValue, IfLoc);
481  Second->Elif(Loc, ConditionRange, ConditionValue, IfLoc);
482  }
483 
484  /// \brief Hook called whenever an \#ifdef is seen.
485  void Ifdef(SourceLocation Loc, const Token &MacroNameTok,
486  const MacroDefinition &MD) override {
487  First->Ifdef(Loc, MacroNameTok, MD);
488  Second->Ifdef(Loc, MacroNameTok, MD);
489  }
490 
491  /// \brief Hook called whenever an \#ifndef is seen.
492  void Ifndef(SourceLocation Loc, const Token &MacroNameTok,
493  const MacroDefinition &MD) override {
494  First->Ifndef(Loc, MacroNameTok, MD);
495  Second->Ifndef(Loc, MacroNameTok, MD);
496  }
497 
498  /// \brief Hook called whenever an \#else is seen.
499  void Else(SourceLocation Loc, SourceLocation IfLoc) override {
500  First->Else(Loc, IfLoc);
501  Second->Else(Loc, IfLoc);
502  }
503 
504  /// \brief Hook called whenever an \#endif is seen.
505  void Endif(SourceLocation Loc, SourceLocation IfLoc) override {
506  First->Endif(Loc, IfLoc);
507  Second->Endif(Loc, IfLoc);
508  }
509 };
510 
511 } // end namespace clang
512 
513 #endif
void PragmaDiagnosticPush(SourceLocation Loc, StringRef Namespace) override
Callback invoked when a #pragma gcc diagnostic push directive is read.
Definition: PPCallbacks.h:402
virtual void Elif(SourceLocation Loc, SourceRange ConditionRange, ConditionValueKind ConditionValue, SourceLocation IfLoc)
Hook called whenever an #elif is seen.
Definition: PPCallbacks.h:292
virtual void PragmaDiagnosticPop(SourceLocation Loc, StringRef Namespace)
Callback invoked when a #pragma gcc diagnostic pop directive is read.
Definition: PPCallbacks.h:210
void MacroUndefined(const Token &MacroNameTok, const MacroDefinition &MD, const MacroDirective *Undef) override
Hook called whenever a macro #undef is seen.
Definition: PPCallbacks.h:452
#pragma GCC error has been invoked.
Definition: PPCallbacks.h:190
virtual void PragmaOpenCLExtension(SourceLocation NameLoc, const IdentifierInfo *Name, SourceLocation StateLoc, unsigned State)
Called when an OpenCL extension is either disabled or enabled with a pragma.
Definition: PPCallbacks.h:220
virtual void EndOfMainFile()
Callback invoked when the end of the main file is reached.
Definition: PPCallbacks.h:149
Defines the SourceManager interface.
void SourceRangeSkipped(SourceRange Range) override
Hook called when a source range is skipped.
Definition: PPCallbacks.h:465
void PragmaWarning(SourceLocation Loc, StringRef WarningSpec, ArrayRef< int > Ids) override
Callback invoked when a #pragma warning directive is read.
Definition: PPCallbacks.h:424
virtual void MacroUndefined(const Token &MacroNameTok, const MacroDefinition &MD, const MacroDirective *Undef)
Hook called whenever a macro #undef is seen.
Definition: PPCallbacks.h:255
A description of the current definition of a macro.
Definition: MacroInfo.h:542
void If(SourceLocation Loc, SourceRange ConditionRange, ConditionValueKind ConditionValue) override
Hook called whenever an #if is seen.
Definition: PPCallbacks.h:471
virtual void PragmaWarningPush(SourceLocation Loc, int Level)
Callback invoked when a #pragma warning(push) directive is read.
Definition: PPCallbacks.h:231
virtual void PragmaWarningPop(SourceLocation Loc)
Callback invoked when a #pragma warning(pop) directive is read.
Definition: PPCallbacks.h:235
void PragmaWarningPop(SourceLocation Loc) override
Callback invoked when a #pragma warning(pop) directive is read.
Definition: PPCallbacks.h:435
Severity
Enum values that allow the client to map NOTEs, WARNINGs, and EXTENSIONs to either Ignore (nothing)...
Definition: DiagnosticIDs.h:63
void Ifdef(SourceLocation Loc, const Token &MacroNameTok, const MacroDefinition &MD) override
Hook called whenever an #ifdef is seen.
Definition: PPCallbacks.h:485
CharacteristicKind
Indicates whether a file or directory holds normal user code, system code, or system code which is im...
Definition: SourceManager.h:82
This interface provides a way to observe the actions of the preprocessor as it does its thing...
Definition: PPCallbacks.h:36
virtual void MacroDefined(const Token &MacroNameTok, const MacroDirective *MD)
Hook called whenever a macro definition is seen.
Definition: PPCallbacks.h:245
virtual void Else(SourceLocation Loc, SourceLocation IfLoc)
Hook called whenever an #else is seen.
Definition: PPCallbacks.h:315
virtual void If(SourceLocation Loc, SourceRange ConditionRange, ConditionValueKind ConditionValue)
Hook called whenever an #if is seen.
Definition: PPCallbacks.h:282
One of these records is kept for each identifier that is lexed.
virtual void PragmaDebug(SourceLocation Loc, StringRef DebugType)
Callback invoked when a #pragma clang __debug directive is read.
Definition: PPCallbacks.h:178
LineState State
Token - This structure provides full information about a lexed token.
Definition: Token.h:35
virtual void Endif(SourceLocation Loc, SourceLocation IfLoc)
Hook called whenever an #endif is seen.
Definition: PPCallbacks.h:321
Describes a module or submodule.
Definition: Module.h:57
PPChainedCallbacks(std::unique_ptr< PPCallbacks > _First, std::unique_ptr< PPCallbacks > _Second)
Definition: PPCallbacks.h:331
void FileSkipped(const FileEntry &SkippedFile, const Token &FilenameTok, SrcMgr::CharacteristicKind FileType) override
Callback invoked whenever a source file is skipped as the result of header guard optimization.
Definition: PPCallbacks.h:342
virtual void SourceRangeSkipped(SourceRange Range)
Hook called when a source range is skipped.
Definition: PPCallbacks.h:269
PragmaIntroducerKind
Describes how the pragma was introduced, e.g., with #pragma, _Pragma, or __pragma.
Definition: Pragma.h:32
virtual void Defined(const Token &MacroNameTok, const MacroDefinition &MD, SourceRange Range)
Hook called whenever the 'defined' operator is seen.
Definition: PPCallbacks.h:262
void Ifndef(SourceLocation Loc, const Token &MacroNameTok, const MacroDefinition &MD) override
Hook called whenever an #ifndef is seen.
Definition: PPCallbacks.h:492
void InclusionDirective(SourceLocation HashLoc, const Token &IncludeTok, StringRef FileName, bool IsAngled, CharSourceRange FilenameRange, const FileEntry *File, StringRef SearchPath, StringRef RelativePath, const Module *Imported) override
Callback invoked whenever an inclusion directive of any kind (#include, #import, etc.) has been processed, regardless of whether the inclusion will actually result in an inclusion.
Definition: PPCallbacks.h:355
PragmaMessageKind
Determines the kind of #pragma invoking a call to PragmaMessage.
Definition: PPCallbacks.h:182
#pragma GCC warning has been invoked.
Definition: PPCallbacks.h:187
virtual void PragmaWarning(SourceLocation Loc, StringRef WarningSpec, ArrayRef< int > Ids)
Callback invoked when a #pragma warning directive is read.
Definition: PPCallbacks.h:226
bool FileNotFound(StringRef FileName, SmallVectorImpl< char > &RecoveryPath) override
Callback invoked whenever an inclusion directive results in a file-not-found error.
Definition: PPCallbacks.h:349
Represents a character-granular source range.
void Ident(SourceLocation Loc, StringRef str) override
Callback invoked when a #ident or #sccs directive is read.
Definition: PPCallbacks.h:379
void PragmaWarningPush(SourceLocation Loc, int Level) override
Callback invoked when a #pragma warning(push) directive is read.
Definition: PPCallbacks.h:430
void FileChanged(SourceLocation Loc, FileChangeReason Reason, SrcMgr::CharacteristicKind FileType, FileID PrevFID) override
Callback invoked whenever a source file is entered or exited.
Definition: PPCallbacks.h:335
MacroArgs - An instance of this class captures information about the formal arguments specified to a ...
Definition: MacroArgs.h:29
void Elif(SourceLocation Loc, SourceRange ConditionRange, ConditionValueKind ConditionValue, SourceLocation IfLoc) override
Hook called whenever an #elif is seen.
Definition: PPCallbacks.h:478
FormatToken * Token
virtual void FileChanged(SourceLocation Loc, FileChangeReason Reason, SrcMgr::CharacteristicKind FileType, FileID PrevFID=FileID())
Callback invoked whenever a source file is entered or exited.
Definition: PPCallbacks.h:48
void PragmaMessage(SourceLocation Loc, StringRef Namespace, PragmaMessageKind Kind, StringRef Str) override
Callback invoked when a #pragma message directive is read.
Definition: PPCallbacks.h:396
virtual void PragmaComment(SourceLocation Loc, const IdentifierInfo *Kind, StringRef Str)
Callback invoked when a #pragma comment directive is read.
Definition: PPCallbacks.h:165
virtual void PragmaDirective(SourceLocation Loc, PragmaIntroducerKind Introducer)
Callback invoked when start reading any pragma directive.
Definition: PPCallbacks.h:160
Simple wrapper class for chaining callbacks.
Definition: PPCallbacks.h:326
Encapsulates changes to the "macros namespace" (the location where the macro name became active...
Definition: MacroInfo.h:286
StringRef FileName
Definition: Format.cpp:1465
Kind
virtual void Ident(SourceLocation Loc, StringRef str)
Callback invoked when a #ident or #sccs directive is read.
Definition: PPCallbacks.h:156
Encodes a location in the source.
void moduleImport(SourceLocation ImportLoc, ModuleIdPath Path, const Module *Imported) override
Callback invoked whenever there was an explicit module-import syntax.
Definition: PPCallbacks.h:368
virtual void MacroExpands(const Token &MacroNameTok, const MacroDefinition &MD, SourceRange Range, const MacroArgs *Args)
Called by Preprocessor::HandleMacroExpandedIdentifier when a macro invocation is found.
Definition: PPCallbacks.h:240
#pragma message has been invoked.
Definition: PPCallbacks.h:184
Cached information about one file (either on disk or in the virtual file system). ...
Definition: FileManager.h:59
virtual void moduleImport(SourceLocation ImportLoc, ModuleIdPath Path, const Module *Imported)
Callback invoked whenever there was an explicit module-import syntax.
Definition: PPCallbacks.h:141
virtual void Ifdef(SourceLocation Loc, const Token &MacroNameTok, const MacroDefinition &MD)
Hook called whenever an #ifdef is seen.
Definition: PPCallbacks.h:300
void MacroExpands(const Token &MacroNameTok, const MacroDefinition &MD, SourceRange Range, const MacroArgs *Args) override
Called by Preprocessor::HandleMacroExpandedIdentifier when a macro invocation is found.
Definition: PPCallbacks.h:440
virtual void PragmaMessage(SourceLocation Loc, StringRef Namespace, PragmaMessageKind Kind, StringRef Str)
Callback invoked when a #pragma message directive is read.
Definition: PPCallbacks.h:198
void PragmaComment(SourceLocation Loc, const IdentifierInfo *Kind, StringRef Str) override
Callback invoked when a #pragma comment directive is read.
Definition: PPCallbacks.h:384
void PragmaDiagnostic(SourceLocation Loc, StringRef Namespace, diag::Severity mapping, StringRef Str) override
Callback invoked when a #pragma gcc diagnostic directive is read.
Definition: PPCallbacks.h:412
An opaque identifier used by SourceManager which refers to a source file (MemoryBuffer) along with it...
void Defined(const Token &MacroNameTok, const MacroDefinition &MD, SourceRange Range) override
Hook called whenever the 'defined' operator is seen.
Definition: PPCallbacks.h:459
void MacroDefined(const Token &MacroNameTok, const MacroDirective *MD) override
Hook called whenever a macro definition is seen.
Definition: PPCallbacks.h:446
void PragmaDiagnosticPop(SourceLocation Loc, StringRef Namespace) override
Callback invoked when a #pragma gcc diagnostic pop directive is read.
Definition: PPCallbacks.h:407
StringRef Name
Definition: USRFinder.cpp:123
void PragmaDetectMismatch(SourceLocation Loc, StringRef Name, StringRef Value) override
Callback invoked when a #pragma detect_mismatch directive is read.
Definition: PPCallbacks.h:390
virtual void PragmaDetectMismatch(SourceLocation Loc, StringRef Name, StringRef Value)
Callback invoked when a #pragma detect_mismatch directive is read.
Definition: PPCallbacks.h:171
void PragmaOpenCLExtension(SourceLocation NameLoc, const IdentifierInfo *Name, SourceLocation StateLoc, unsigned State) override
Called when an OpenCL extension is either disabled or enabled with a pragma.
Definition: PPCallbacks.h:418
void EndOfMainFile() override
Callback invoked when the end of the main file is reached.
Definition: PPCallbacks.h:374
virtual bool FileNotFound(StringRef FileName, SmallVectorImpl< char > &RecoveryPath)
Callback invoked whenever an inclusion directive results in a file-not-found error.
Definition: PPCallbacks.h:78
virtual void Ifndef(SourceLocation Loc, const Token &MacroNameTok, const MacroDefinition &MD)
Hook called whenever an #ifndef is seen.
Definition: PPCallbacks.h:308
Defines the clang::SourceLocation class and associated facilities.
void Endif(SourceLocation Loc, SourceLocation IfLoc) override
Hook called whenever an #endif is seen.
Definition: PPCallbacks.h:505
virtual void InclusionDirective(SourceLocation HashLoc, const Token &IncludeTok, StringRef FileName, bool IsAngled, CharSourceRange FilenameRange, const FileEntry *File, StringRef SearchPath, StringRef RelativePath, const Module *Imported)
Callback invoked whenever an inclusion directive of any kind (#include, #import, etc.) has been processed, regardless of whether the inclusion will actually result in an inclusion.
Definition: PPCallbacks.h:120
virtual void PragmaDiagnosticPush(SourceLocation Loc, StringRef Namespace)
Callback invoked when a #pragma gcc diagnostic push directive is read.
Definition: PPCallbacks.h:204
Defines the Diagnostic IDs-related interfaces.
virtual void PragmaDiagnostic(SourceLocation Loc, StringRef Namespace, diag::Severity mapping, StringRef Str)
Callback invoked when a #pragma gcc diagnostic directive is read.
Definition: PPCallbacks.h:215
A trivial tuple used to represent a source range.
void Else(SourceLocation Loc, SourceLocation IfLoc) override
Hook called whenever an #else is seen.
Definition: PPCallbacks.h:499
virtual void FileSkipped(const FileEntry &SkippedFile, const Token &FilenameTok, SrcMgr::CharacteristicKind FileType)
Callback invoked whenever a source file is skipped as the result of header guard optimization.
Definition: PPCallbacks.h:61