clang 8.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 /// Defines the PPCallbacks interface.
12 ///
13 //===----------------------------------------------------------------------===//
14
15 #ifndef LLVM_CLANG_LEX_PPCALLBACKS_H
16 #define LLVM_CLANG_LEX_PPCALLBACKS_H
17
18 #include "clang/Basic/DiagnosticIDs.h"
19 #include "clang/Basic/SourceLocation.h"
20 #include "clang/Basic/SourceManager.h"
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 /// 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
40 enum FileChangeReason {
41 EnterFile, ExitFile, SystemHeaderPragma, RenameFile
42 };
43
44 /// 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,
49 SrcMgr::CharacteristicKind FileType,
50 FileID PrevFID = FileID()) {
51 }
52
53 /// 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 /// 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 /// 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 /// \param FileType The characteristic kind, indicates whether a file or
121 /// directory holds normal user code, system code, or system code which is
122 /// implicitly 'extern "C"' in C++ mode.
123 ///
124 virtual void InclusionDirective(SourceLocation HashLoc,
125 const Token &IncludeTok,
126 StringRef FileName,
127 bool IsAngled,
128 CharSourceRange FilenameRange,
129 const FileEntry *File,
130 StringRef SearchPath,
131 StringRef RelativePath,
132 const Module *Imported,
133 SrcMgr::CharacteristicKind FileType) {
134 }
135
136 /// Callback invoked whenever there was an explicit module-import
137 /// syntax.
138 ///
139 /// \param ImportLoc The location of import directive token.
140 ///
141 /// \param Path The identifiers (and their locations) of the module
142 /// "path", e.g., "std.vector" would be split into "std" and "vector".
143 ///
144 /// \param Imported The imported module; can be null if importing failed.
145 ///
146 virtual void moduleImport(SourceLocation ImportLoc,
147 ModuleIdPath Path,
148 const Module *Imported) {
149 }
150
151 /// Callback invoked when the end of the main file is reached.
152 ///
153 /// No subsequent callbacks will be made.
154 virtual void EndOfMainFile() {
155 }
156
157 /// Callback invoked when a \#ident or \#sccs directive is read.
158 /// \param Loc The location of the directive.
159 /// \param str The text of the directive.
160 ///
161 virtual void Ident(SourceLocation Loc, StringRef str) {
162 }
163
164 /// Callback invoked when start reading any pragma directive.
165 virtual void PragmaDirective(SourceLocation Loc,
166 PragmaIntroducerKind Introducer) {
167 }
168
169 /// Callback invoked when a \#pragma comment directive is read.
170 virtual void PragmaComment(SourceLocation Loc, const IdentifierInfo *Kind,
171 StringRef Str) {
172 }
173
174 /// Callback invoked when a \#pragma detect_mismatch directive is
175 /// read.
176 virtual void PragmaDetectMismatch(SourceLocation Loc, StringRef Name,
177 StringRef Value) {
178 }
179
180 /// Callback invoked when a \#pragma clang __debug directive is read.
181 /// \param Loc The location of the debug directive.
182 /// \param DebugType The identifier following __debug.
183 virtual void PragmaDebug(SourceLocation Loc, StringRef DebugType) {
184 }
185
186 /// Determines the kind of \#pragma invoking a call to PragmaMessage.
187 enum PragmaMessageKind {
188 /// \#pragma message has been invoked.
189 PMK_Message,
190
191 /// \#pragma GCC warning has been invoked.
192 PMK_Warning,
193
194 /// \#pragma GCC error has been invoked.
195 PMK_Error
196 };
197
198 /// Callback invoked when a \#pragma message directive is read.
199 /// \param Loc The location of the message directive.
200 /// \param Namespace The namespace of the message directive.
201 /// \param Kind The type of the message directive.
202 /// \param Str The text of the message directive.
203 virtual void PragmaMessage(SourceLocation Loc, StringRef Namespace,
204 PragmaMessageKind Kind, StringRef Str) {
205 }
206
207 /// Callback invoked when a \#pragma gcc diagnostic push directive
208 /// is read.
209 virtual void PragmaDiagnosticPush(SourceLocation Loc,
210 StringRef Namespace) {
211 }
212
213 /// Callback invoked when a \#pragma gcc diagnostic pop directive
214 /// is read.
215 virtual void PragmaDiagnosticPop(SourceLocation Loc,
216 StringRef Namespace) {
217 }
218
219 /// Callback invoked when a \#pragma gcc diagnostic directive is read.
220 virtual void PragmaDiagnostic(SourceLocation Loc, StringRef Namespace,
221 diag::Severity mapping, StringRef Str) {}
222
223 /// Called when an OpenCL extension is either disabled or
224 /// enabled with a pragma.
225 virtual void PragmaOpenCLExtension(SourceLocation NameLoc,
226 const IdentifierInfo *Name,
227 SourceLocation StateLoc, unsigned State) {
228 }
229
230 /// Callback invoked when a \#pragma warning directive is read.
231 virtual void PragmaWarning(SourceLocation Loc, StringRef WarningSpec,
232 ArrayRef<int> Ids) {
233 }
234
235 /// Callback invoked when a \#pragma warning(push) directive is read.
236 virtual void PragmaWarningPush(SourceLocation Loc, int Level) {
237 }
238
239 /// Callback invoked when a \#pragma warning(pop) directive is read.
240 virtual void PragmaWarningPop(SourceLocation Loc) {
241 }
242
243 /// Callback invoked when a \#pragma clang assume_nonnull begin directive
244 /// is read.
245 virtual void PragmaAssumeNonNullBegin(SourceLocation Loc) {}
246
247 /// Callback invoked when a \#pragma clang assume_nonnull end directive
248 /// is read.
249 virtual void PragmaAssumeNonNullEnd(SourceLocation Loc) {}
250
251 /// Called by Preprocessor::HandleMacroExpandedIdentifier when a
252 /// macro invocation is found.
253 virtual void MacroExpands(const Token &MacroNameTok,
254 const MacroDefinition &MD, SourceRange Range,
255 const MacroArgs *Args) {}
256
257 /// Hook called whenever a macro definition is seen.
258 virtual void MacroDefined(const Token &MacroNameTok,
259 const MacroDirective *MD) {
260 }
261
262 /// Hook called whenever a macro \#undef is seen.
263 /// \param MacroNameTok The active Token
264 /// \param MD A MacroDefinition for the named macro.
265 /// \param Undef New MacroDirective if the macro was defined, null otherwise.
266 ///
267 /// MD is released immediately following this callback.
268 virtual void MacroUndefined(const Token &MacroNameTok,
269 const MacroDefinition &MD,
270 const MacroDirective *Undef) {
271 }
272
273 /// Hook called whenever the 'defined' operator is seen.
274 /// \param MD The MacroDirective if the name was a macro, null otherwise.
275 virtual void Defined(const Token &MacroNameTok, const MacroDefinition &MD,
276 SourceRange Range) {
277 }
278
279 /// Hook called when a '__has_include' or '__has_include_next' directive is
280 /// read.
281 virtual void HasInclude(SourceLocation Loc, StringRef FileName, bool IsAngled,
282 const FileEntry *File,
283 SrcMgr::CharacteristicKind FileType) {}
284
285 /// Hook called when a source range is skipped.
286 /// \param Range The SourceRange that was skipped. The range begins at the
287 /// \#if/\#else directive and ends after the \#endif/\#else directive.
288 /// \param EndifLoc The end location of the 'endif' token, which may precede
289 /// the range skipped by the directive (e.g excluding comments after an
290 /// 'endif').
291 virtual void SourceRangeSkipped(SourceRange Range, SourceLocation EndifLoc) {
292 }
293
294 enum ConditionValueKind {
295 CVK_NotEvaluated, CVK_False, CVK_True
296 };
297
298 /// Hook called whenever an \#if is seen.
299 /// \param Loc the source location of the directive.
300 /// \param ConditionRange The SourceRange of the expression being tested.
301 /// \param ConditionValue The evaluated value of the condition.
302 ///
303 // FIXME: better to pass in a list (or tree!) of Tokens.
304 virtual void If(SourceLocation Loc, SourceRange ConditionRange,
305 ConditionValueKind ConditionValue) {
306 }
307
308 /// Hook called whenever an \#elif is seen.
309 /// \param Loc the source location of the directive.
310 /// \param ConditionRange The SourceRange of the expression being tested.
311 /// \param ConditionValue The evaluated value of the condition.
312 /// \param IfLoc the source location of the \#if/\#ifdef/\#ifndef directive.
313 // FIXME: better to pass in a list (or tree!) of Tokens.
314 virtual void Elif(SourceLocation Loc, SourceRange ConditionRange,
315 ConditionValueKind ConditionValue, SourceLocation IfLoc) {
316 }
317
318 /// Hook called whenever an \#ifdef is seen.
319 /// \param Loc the source location of the directive.
320 /// \param MacroNameTok Information on the token being tested.
321 /// \param MD The MacroDefinition if the name was a macro, null otherwise.
322 virtual void Ifdef(SourceLocation Loc, const Token &MacroNameTok,
323 const MacroDefinition &MD) {
324 }
325
326 /// Hook called whenever an \#ifndef is seen.
327 /// \param Loc the source location of the directive.
328 /// \param MacroNameTok Information on the token being tested.
329 /// \param MD The MacroDefiniton if the name was a macro, null otherwise.
330 virtual void Ifndef(SourceLocation Loc, const Token &MacroNameTok,
331 const MacroDefinition &MD) {
332 }
333
334 /// Hook called whenever an \#else is seen.
335 /// \param Loc the source location of the directive.
336 /// \param IfLoc the source location of the \#if/\#ifdef/\#ifndef directive.
337 virtual void Else(SourceLocation Loc, SourceLocation IfLoc) {
338 }
339
340 /// Hook called whenever an \#endif is seen.
341 /// \param Loc the source location of the directive.
342 /// \param IfLoc the source location of the \#if/\#ifdef/\#ifndef directive.
343 virtual void Endif(SourceLocation Loc, SourceLocation IfLoc) {
344 }
345 };
346
347 /// Simple wrapper class for chaining callbacks.
348 class PPChainedCallbacks : public PPCallbacks {
349 virtual void anchor();
350 std::unique_ptr<PPCallbacks> First, Second;
351
352 public:
353 PPChainedCallbacks(std::unique_ptr<PPCallbacks> _First,
354 std::unique_ptr<PPCallbacks> _Second)
355 : First(std::move(_First)), Second(std::move(_Second)) {}
356
357 void FileChanged(SourceLocation Loc, FileChangeReason Reason,
358 SrcMgr::CharacteristicKind FileType,
359 FileID PrevFID) override {
360 First->FileChanged(Loc, Reason, FileType, PrevFID);
361 Second->FileChanged(Loc, Reason, FileType, PrevFID);
362 }
363
364 void FileSkipped(const FileEntry &SkippedFile,
365 const Token &FilenameTok,
366 SrcMgr::CharacteristicKind FileType) override {
367 First->FileSkipped(SkippedFile, FilenameTok, FileType);
368 Second->FileSkipped(SkippedFile, FilenameTok, FileType);
369 }
370
371 bool FileNotFound(StringRef FileName,
372 SmallVectorImpl<char> &RecoveryPath) override {
373 return First->FileNotFound(FileName, RecoveryPath) ||
374 Second->FileNotFound(FileName, RecoveryPath);
375 }
376
377 void InclusionDirective(SourceLocation HashLoc, const Token &IncludeTok,
378 StringRef FileName, bool IsAngled,
379 CharSourceRange FilenameRange, const FileEntry *File,
380 StringRef SearchPath, StringRef RelativePath,
381 const Module *Imported,
382 SrcMgr::CharacteristicKind FileType) override {
383 First->InclusionDirective(HashLoc, IncludeTok, FileName, IsAngled,
384 FilenameRange, File, SearchPath, RelativePath,
385 Imported, FileType);
386 Second->InclusionDirective(HashLoc, IncludeTok, FileName, IsAngled,
387 FilenameRange, File, SearchPath, RelativePath,
388 Imported, FileType);
389 }
390
391 void moduleImport(SourceLocation ImportLoc, ModuleIdPath Path,
392 const Module *Imported) override {
393 First->moduleImport(ImportLoc, Path, Imported);
394 Second->moduleImport(ImportLoc, Path, Imported);
395 }
396
397 void EndOfMainFile() override {
398 First->EndOfMainFile();
399 Second->EndOfMainFile();
400 }
401
402 void Ident(SourceLocation Loc, StringRef str) override {
403 First->Ident(Loc, str);
404 Second->Ident(Loc, str);
405 }
406
407 void PragmaDirective(SourceLocation Loc,
408 PragmaIntroducerKind Introducer) override {
409 First->PragmaDirective(Loc, Introducer);
410 Second->PragmaDirective(Loc, Introducer);
411 }
412
413 void PragmaComment(SourceLocation Loc, const IdentifierInfo *Kind,
414 StringRef Str) override {
415 First->PragmaComment(Loc, Kind, Str);
416 Second->PragmaComment(Loc, Kind, Str);
417 }
418
419 void PragmaDetectMismatch(SourceLocation Loc, StringRef Name,
420 StringRef Value) override {
421 First->PragmaDetectMismatch(Loc, Name, Value);
422 Second->PragmaDetectMismatch(Loc, Name, Value);
423 }
424
425 void PragmaDebug(SourceLocation Loc, StringRef DebugType) override {
426 First->PragmaDebug(Loc, DebugType);
427 Second->PragmaDebug(Loc, DebugType);
428 }
429
430 void PragmaMessage(SourceLocation Loc, StringRef Namespace,
431 PragmaMessageKind Kind, StringRef Str) override {
432 First->PragmaMessage(Loc, Namespace, Kind, Str);
433 Second->PragmaMessage(Loc, Namespace, Kind, Str);
434 }
435
436 void PragmaDiagnosticPush(SourceLocation Loc, StringRef Namespace) override {
437 First->PragmaDiagnosticPush(Loc, Namespace);
438 Second->PragmaDiagnosticPush(Loc, Namespace);
439 }
440
441 void PragmaDiagnosticPop(SourceLocation Loc, StringRef Namespace) override {
442 First->PragmaDiagnosticPop(Loc, Namespace);
443 Second->PragmaDiagnosticPop(Loc, Namespace);
444 }
445
446 void PragmaDiagnostic(SourceLocation Loc, StringRef Namespace,
447 diag::Severity mapping, StringRef Str) override {
448 First->PragmaDiagnostic(Loc, Namespace, mapping, Str);
449 Second->PragmaDiagnostic(Loc, Namespace, mapping, Str);
450 }
451
452 void HasInclude(SourceLocation Loc, StringRef FileName, bool IsAngled,
453 const FileEntry *File,
454 SrcMgr::CharacteristicKind FileType) override {
455 First->HasInclude(Loc, FileName, IsAngled, File, FileType);
456 Second->HasInclude(Loc, FileName, IsAngled, File, FileType);
457 }
458
459 void PragmaOpenCLExtension(SourceLocation NameLoc, const IdentifierInfo *Name,
460 SourceLocation StateLoc, unsigned State) override {
461 First->PragmaOpenCLExtension(NameLoc, Name, StateLoc, State);
462 Second->PragmaOpenCLExtension(NameLoc, Name, StateLoc, State);
463 }
464
465 void PragmaWarning(SourceLocation Loc, StringRef WarningSpec,
466 ArrayRef<int> Ids) override {
467 First->PragmaWarning(Loc, WarningSpec, Ids);
468 Second->PragmaWarning(Loc, WarningSpec, Ids);
469 }
470
471 void PragmaWarningPush(SourceLocation Loc, int Level) override {
472 First->PragmaWarningPush(Loc, Level);
473 Second->PragmaWarningPush(Loc, Level);
474 }
475
476 void PragmaWarningPop(SourceLocation Loc) override {
477 First->PragmaWarningPop(Loc);
478 Second->PragmaWarningPop(Loc);
479 }
480
481 void PragmaAssumeNonNullBegin(SourceLocation Loc) override {
482 First->PragmaAssumeNonNullBegin(Loc);
483 Second->PragmaAssumeNonNullBegin(Loc);
484 }
485
486 void PragmaAssumeNonNullEnd(SourceLocation Loc) override {
487 First->PragmaAssumeNonNullEnd(Loc);
488 Second->PragmaAssumeNonNullEnd(Loc);
489 }
490
491 void MacroExpands(const Token &MacroNameTok, const MacroDefinition &MD,
492 SourceRange Range, const MacroArgs *Args) override {
493 First->MacroExpands(MacroNameTok, MD, Range, Args);
494 Second->MacroExpands(MacroNameTok, MD, Range, Args);
495 }
496
497 void MacroDefined(const Token &MacroNameTok,
498 const MacroDirective *MD) override {
499 First->MacroDefined(MacroNameTok, MD);
500 Second->MacroDefined(MacroNameTok, MD);
501 }
502
503 void MacroUndefined(const Token &MacroNameTok,
504 const MacroDefinition &MD,
505 const MacroDirective *Undef) override {
506 First->MacroUndefined(MacroNameTok, MD, Undef);
507 Second->MacroUndefined(MacroNameTok, MD, Undef);
508 }
509
510 void Defined(const Token &MacroNameTok, const MacroDefinition &MD,
511 SourceRange Range) override {
512 First->Defined(MacroNameTok, MD, Range);
513 Second->Defined(MacroNameTok, MD, Range);
514 }
515
516 void SourceRangeSkipped(SourceRange Range, SourceLocation EndifLoc) override {
517 First->SourceRangeSkipped(Range, EndifLoc);
518 Second->SourceRangeSkipped(Range, EndifLoc);
519 }
520
521 /// Hook called whenever an \#if is seen.
522 void If(SourceLocation Loc, SourceRange ConditionRange,
523 ConditionValueKind ConditionValue) override {
524 First->If(Loc, ConditionRange, ConditionValue);
525 Second->If(Loc, ConditionRange, ConditionValue);
526 }
527
528 /// Hook called whenever an \#elif is seen.
529 void Elif(SourceLocation Loc, SourceRange ConditionRange,
530 ConditionValueKind ConditionValue, SourceLocation IfLoc) override {
531 First->Elif(Loc, ConditionRange, ConditionValue, IfLoc);
532 Second->Elif(Loc, ConditionRange, ConditionValue, IfLoc);
533 }
534
535 /// Hook called whenever an \#ifdef is seen.
536 void Ifdef(SourceLocation Loc, const Token &MacroNameTok,
537 const MacroDefinition &MD) override {
538 First->Ifdef(Loc, MacroNameTok, MD);
539 Second->Ifdef(Loc, MacroNameTok, MD);
540 }
541
542 /// Hook called whenever an \#ifndef is seen.
543 void Ifndef(SourceLocation Loc, const Token &MacroNameTok,
544 const MacroDefinition &MD) override {
545 First->Ifndef(Loc, MacroNameTok, MD);
546 Second->Ifndef(Loc, MacroNameTok, MD);
547 }
548
549 /// Hook called whenever an \#else is seen.
550 void Else(SourceLocation Loc, SourceLocation IfLoc) override {
551 First->Else(Loc, IfLoc);
552 Second->Else(Loc, IfLoc);
553 }
554
555 /// Hook called whenever an \#endif is seen.
556 void Endif(SourceLocation Loc, SourceLocation IfLoc) override {
557 First->Endif(Loc, IfLoc);
558 Second->Endif(Loc, IfLoc);
559 }
560 };
561
562 } // end namespace clang
563
564 #endif
clang::PPChainedCallbacks::PragmaDiagnosticPush
void PragmaDiagnosticPush(SourceLocation Loc, StringRef Namespace) override
Callback invoked when a #pragma gcc diagnostic push directive is read.
Definition: PPCallbacks.h:436
clang::PPCallbacks::Elif
virtual void Elif(SourceLocation Loc, SourceRange ConditionRange, ConditionValueKind ConditionValue, SourceLocation IfLoc)
Hook called whenever an #elif is seen.
Definition: PPCallbacks.h:314
clang::PPCallbacks::PragmaDiagnosticPop
virtual void PragmaDiagnosticPop(SourceLocation Loc, StringRef Namespace)
Callback invoked when a #pragma gcc diagnostic pop directive is read.
Definition: PPCallbacks.h:215
clang::PPChainedCallbacks::MacroUndefined
void MacroUndefined(const Token &MacroNameTok, const MacroDefinition &MD, const MacroDirective *Undef) override
Hook called whenever a macro #undef is seen.
Definition: PPCallbacks.h:503
clang::PPCallbacks::PMK_Error
#pragma GCC error has been invoked.
Definition: PPCallbacks.h:195
clang::PPCallbacks::PragmaOpenCLExtension
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:225
clang::PPCallbacks::EndOfMainFile
virtual void EndOfMainFile()
Callback invoked when the end of the main file is reached.
Definition: PPCallbacks.h:154
SourceManager.h
Defines the SourceManager interface.
clang::PPCallbacks::EnterFile
Definition: PPCallbacks.h:41
clang::PPChainedCallbacks::PragmaWarning
void PragmaWarning(SourceLocation Loc, StringRef WarningSpec, ArrayRef< int > Ids) override
Callback invoked when a #pragma warning directive is read.
Definition: PPCallbacks.h:465
clang::PPCallbacks::MacroUndefined
virtual void MacroUndefined(const Token &MacroNameTok, const MacroDefinition &MD, const MacroDirective *Undef)
Hook called whenever a macro #undef is seen.
Definition: PPCallbacks.h:268
clang::MacroDefinition
A description of the current definition of a macro.
Definition: MacroInfo.h:565
clang::PPChainedCallbacks::If
void If(SourceLocation Loc, SourceRange ConditionRange, ConditionValueKind ConditionValue) override
Hook called whenever an #if is seen.
Definition: PPCallbacks.h:522
clang::PPCallbacks::PragmaWarningPush
virtual void PragmaWarningPush(SourceLocation Loc, int Level)
Callback invoked when a #pragma warning(push) directive is read.
Definition: PPCallbacks.h:236
clang::PPCallbacks::PragmaWarningPop
virtual void PragmaWarningPop(SourceLocation Loc)
Callback invoked when a #pragma warning(pop) directive is read.
Definition: PPCallbacks.h:240
Value
Value
Definition: UninitializedValues.cpp:102
clang::PPChainedCallbacks::PragmaWarningPop
void PragmaWarningPop(SourceLocation Loc) override
Callback invoked when a #pragma warning(pop) directive is read.
Definition: PPCallbacks.h:476
clang::diag::Severity
Severity
Enum values that allow the client to map NOTEs, WARNINGs, and EXTENSIONs to either Ignore (nothing)...
Definition: DiagnosticIDs.h:80
clang::PPChainedCallbacks::Ifdef
void Ifdef(SourceLocation Loc, const Token &MacroNameTok, const MacroDefinition &MD) override
Hook called whenever an #ifdef is seen.
Definition: PPCallbacks.h:536
clang::SrcMgr::CharacteristicKind
CharacteristicKind
Indicates whether a file or directory holds normal user code, system code, or system code which is im...
Definition: SourceManager.h:78
clang::PPCallbacks::CVK_False
Definition: PPCallbacks.h:295
clang::PPCallbacks
This interface provides a way to observe the actions of the preprocessor as it does its thing...
Definition: PPCallbacks.h:36
clang::PPCallbacks::MacroDefined
virtual void MacroDefined(const Token &MacroNameTok, const MacroDirective *MD)
Hook called whenever a macro definition is seen.
Definition: PPCallbacks.h:258
clang::PPCallbacks::~PPCallbacks
virtual ~PPCallbacks()
Definition: PPLexerChange.cpp:28
clang::PPCallbacks::Else
virtual void Else(SourceLocation Loc, SourceLocation IfLoc)
Hook called whenever an #else is seen.
Definition: PPCallbacks.h:337
clang::PPCallbacks::If
virtual void If(SourceLocation Loc, SourceRange ConditionRange, ConditionValueKind ConditionValue)
Hook called whenever an #if is seen.
Definition: PPCallbacks.h:304
clang::IdentifierInfo
One of these records is kept for each identifier that is lexed.
Definition: IdentifierTable.h:58
clang::PPCallbacks::PragmaDebug
virtual void PragmaDebug(SourceLocation Loc, StringRef DebugType)
Callback invoked when a #pragma clang __debug directive is read.
Definition: PPCallbacks.h:183
State
LineState State
Definition: UnwrappedLineFormatter.cpp:877
std
Definition: Format.h:2072
clang::Token
Token - This structure provides full information about a lexed token.
Definition: Token.h:35
clang::PPCallbacks::Endif
virtual void Endif(SourceLocation Loc, SourceLocation IfLoc)
Hook called whenever an #endif is seen.
Definition: PPCallbacks.h:343
Pragma.h
clang::Module
Describes a module or submodule.
Definition: Module.h:65
llvm::SmallVectorImpl
Definition: LLVM.h:37
clang::PPChainedCallbacks::PPChainedCallbacks
PPChainedCallbacks(std::unique_ptr< PPCallbacks > _First, std::unique_ptr< PPCallbacks > _Second)
Definition: PPCallbacks.h:353
clang::ComparisonCategoryType::First
clang::PPChainedCallbacks::FileSkipped
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:364
ModuleLoader.h
llvm::ArrayRef
Definition: LLVM.h:32
clang::PragmaIntroducerKind
PragmaIntroducerKind
Describes how the pragma was introduced, e.g., with #pragma, _Pragma, or __pragma.
Definition: Pragma.h:32
clang::PPCallbacks::Defined
virtual void Defined(const Token &MacroNameTok, const MacroDefinition &MD, SourceRange Range)
Hook called whenever the &#39;defined&#39; operator is seen.
Definition: PPCallbacks.h:275
clang::PPChainedCallbacks::Ifndef
void Ifndef(SourceLocation Loc, const Token &MacroNameTok, const MacroDefinition &MD) override
Hook called whenever an #ifndef is seen.
Definition: PPCallbacks.h:543
clang::PPCallbacks::ConditionValueKind
ConditionValueKind
Definition: PPCallbacks.h:294
llvm::str
return Out str()
clang::PPCallbacks::PragmaMessageKind
PragmaMessageKind
Determines the kind of #pragma invoking a call to PragmaMessage.
Definition: PPCallbacks.h:187
clang::PPCallbacks::PragmaAssumeNonNullBegin
virtual void PragmaAssumeNonNullBegin(SourceLocation Loc)
Callback invoked when a #pragma clang assume_nonnull begin directive is read.
Definition: PPCallbacks.h:245
clang::PPCallbacks::PMK_Warning
#pragma GCC warning has been invoked.
Definition: PPCallbacks.h:192
clang::PPCallbacks::PragmaWarning
virtual void PragmaWarning(SourceLocation Loc, StringRef WarningSpec, ArrayRef< int > Ids)
Callback invoked when a #pragma warning directive is read.
Definition: PPCallbacks.h:231
clang::PPChainedCallbacks::FileNotFound
bool FileNotFound(StringRef FileName, SmallVectorImpl< char > &RecoveryPath) override
Callback invoked whenever an inclusion directive results in a file-not-found error.
Definition: PPCallbacks.h:371
clang::CharSourceRange
Represents a character-granular source range.
Definition: SourceLocation.h:236
clang::PPChainedCallbacks::Ident
void Ident(SourceLocation Loc, StringRef str) override
Callback invoked when a #ident or #sccs directive is read.
Definition: PPCallbacks.h:402
clang::PPChainedCallbacks::PragmaWarningPush
void PragmaWarningPush(SourceLocation Loc, int Level) override
Callback invoked when a #pragma warning(push) directive is read.
Definition: PPCallbacks.h:471
clang::PPChainedCallbacks::FileChanged
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:357
clang::MacroArgs
MacroArgs - An instance of this class captures information about the formal arguments specified to a ...
Definition: MacroArgs.h:30
clang::PPChainedCallbacks::Elif
void Elif(SourceLocation Loc, SourceRange ConditionRange, ConditionValueKind ConditionValue, SourceLocation IfLoc) override
Hook called whenever an #elif is seen.
Definition: PPCallbacks.h:529
clang::PPCallbacks::HasInclude
virtual void HasInclude(SourceLocation Loc, StringRef FileName, bool IsAngled, const FileEntry *File, SrcMgr::CharacteristicKind FileType)
Hook called when a &#39;__has_include&#39; or &#39;__has_include_next&#39; directive is read.
Definition: PPCallbacks.h:281
clang::PPCallbacks::FileChangeReason
FileChangeReason
Definition: PPCallbacks.h:40
clang::PPChainedCallbacks::PragmaAssumeNonNullBegin
void PragmaAssumeNonNullBegin(SourceLocation Loc) override
Callback invoked when a #pragma clang assume_nonnull begin directive is read.
Definition: PPCallbacks.h:481
clang::PPCallbacks::RenameFile
Definition: PPCallbacks.h:41
clang::PPCallbacks::FileChanged
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
clang::PPChainedCallbacks::PragmaMessage
void PragmaMessage(SourceLocation Loc, StringRef Namespace, PragmaMessageKind Kind, StringRef Str) override
Callback invoked when a #pragma message directive is read.
Definition: PPCallbacks.h:430
clang::PPCallbacks::PragmaComment
virtual void PragmaComment(SourceLocation Loc, const IdentifierInfo *Kind, StringRef Str)
Callback invoked when a #pragma comment directive is read.
Definition: PPCallbacks.h:170
clang::PPCallbacks::PragmaDirective
virtual void PragmaDirective(SourceLocation Loc, PragmaIntroducerKind Introducer)
Callback invoked when start reading any pragma directive.
Definition: PPCallbacks.h:165
clang::PPChainedCallbacks
Simple wrapper class for chaining callbacks.
Definition: PPCallbacks.h:348
clang::PPCallbacks::InclusionDirective
virtual void InclusionDirective(SourceLocation HashLoc, const Token &IncludeTok, StringRef FileName, bool IsAngled, CharSourceRange FilenameRange, const FileEntry *File, StringRef SearchPath, StringRef RelativePath, const Module *Imported, SrcMgr::CharacteristicKind FileType)
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:124
clang::MacroDirective
Encapsulates changes to the "macros namespace" (the location where the macro name became active...
Definition: MacroInfo.h:291
Kind
Kind
Definition: ChrootChecker.cpp:29
clang::PPCallbacks::Ident
virtual void Ident(SourceLocation Loc, StringRef str)
Callback invoked when a #ident or #sccs directive is read.
Definition: PPCallbacks.h:161
clang::SourceLocation
Encodes a location in the source.
Definition: SourceLocation.h:88
clang::PPChainedCallbacks::moduleImport
void moduleImport(SourceLocation ImportLoc, ModuleIdPath Path, const Module *Imported) override
Callback invoked whenever there was an explicit module-import syntax.
Definition: PPCallbacks.h:391
clang::PPCallbacks::MacroExpands
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:253
clang::PPCallbacks::PMK_Message
#pragma message has been invoked.
Definition: PPCallbacks.h:189
clang::PPChainedCallbacks::PragmaDebug
void PragmaDebug(SourceLocation Loc, StringRef DebugType) override
Callback invoked when a #pragma clang __debug directive is read.
Definition: PPCallbacks.h:425
clang::PPChainedCallbacks::PragmaAssumeNonNullEnd
void PragmaAssumeNonNullEnd(SourceLocation Loc) override
Callback invoked when a #pragma clang assume_nonnull end directive is read.
Definition: PPCallbacks.h:486
clang::FileEntry
Cached information about one file (either on disk or in the virtual file system). ...
Definition: FileManager.h:60
clang::PPCallbacks::moduleImport
virtual void moduleImport(SourceLocation ImportLoc, ModuleIdPath Path, const Module *Imported)
Callback invoked whenever there was an explicit module-import syntax.
Definition: PPCallbacks.h:146
clang::PPChainedCallbacks::InclusionDirective
void InclusionDirective(SourceLocation HashLoc, const Token &IncludeTok, StringRef FileName, bool IsAngled, CharSourceRange FilenameRange, const FileEntry *File, StringRef SearchPath, StringRef RelativePath, const Module *Imported, SrcMgr::CharacteristicKind FileType) 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:377
clang::PPCallbacks::Ifdef
virtual void Ifdef(SourceLocation Loc, const Token &MacroNameTok, const MacroDefinition &MD)
Hook called whenever an #ifdef is seen.
Definition: PPCallbacks.h:322
clang::PPChainedCallbacks::PragmaDirective
void PragmaDirective(SourceLocation Loc, PragmaIntroducerKind Introducer) override
Callback invoked when start reading any pragma directive.
Definition: PPCallbacks.h:407
clang::PPChainedCallbacks::MacroExpands
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:491
clang::PPChainedCallbacks::HasInclude
void HasInclude(SourceLocation Loc, StringRef FileName, bool IsAngled, const FileEntry *File, SrcMgr::CharacteristicKind FileType) override
Hook called when a &#39;__has_include&#39; or &#39;__has_include_next&#39; directive is read.
Definition: PPCallbacks.h:452
clang::PPCallbacks::PragmaMessage
virtual void PragmaMessage(SourceLocation Loc, StringRef Namespace, PragmaMessageKind Kind, StringRef Str)
Callback invoked when a #pragma message directive is read.
Definition: PPCallbacks.h:203
clang::PPChainedCallbacks::PragmaComment
void PragmaComment(SourceLocation Loc, const IdentifierInfo *Kind, StringRef Str) override
Callback invoked when a #pragma comment directive is read.
Definition: PPCallbacks.h:413
clang::PPChainedCallbacks::PragmaDiagnostic
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:446
clang::PPCallbacks::SystemHeaderPragma
Definition: PPCallbacks.h:41
clang::FileID
An opaque identifier used by SourceManager which refers to a source file (MemoryBuffer) along with it...
Definition: SourceLocation.h:40
clang::PPCallbacks::ExitFile
Definition: PPCallbacks.h:41
clang::PPChainedCallbacks::Defined
void Defined(const Token &MacroNameTok, const MacroDefinition &MD, SourceRange Range) override
Hook called whenever the &#39;defined&#39; operator is seen.
Definition: PPCallbacks.h:510
clang::PPChainedCallbacks::MacroDefined
void MacroDefined(const Token &MacroNameTok, const MacroDirective *MD) override
Hook called whenever a macro definition is seen.
Definition: PPCallbacks.h:497
clang
Dataflow Directional Tag Classes.
Definition: CFGReachabilityAnalysis.h:22
clang::PPChainedCallbacks::PragmaDiagnosticPop
void PragmaDiagnosticPop(SourceLocation Loc, StringRef Namespace) override
Callback invoked when a #pragma gcc diagnostic pop directive is read.
Definition: PPCallbacks.h:441
clang::PPChainedCallbacks::PragmaDetectMismatch
void PragmaDetectMismatch(SourceLocation Loc, StringRef Name, StringRef Value) override
Callback invoked when a #pragma detect_mismatch directive is read.
Definition: PPCallbacks.h:419
clang::PPCallbacks::PragmaDetectMismatch
virtual void PragmaDetectMismatch(SourceLocation Loc, StringRef Name, StringRef Value)
Callback invoked when a #pragma detect_mismatch directive is read.
Definition: PPCallbacks.h:176
clang::PPChainedCallbacks::PragmaOpenCLExtension
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:459
clang::PPChainedCallbacks::EndOfMainFile
void EndOfMainFile() override
Callback invoked when the end of the main file is reached.
Definition: PPCallbacks.h:397
clang::PPCallbacks::FileNotFound
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
clang::PPCallbacks::Ifndef
virtual void Ifndef(SourceLocation Loc, const Token &MacroNameTok, const MacroDefinition &MD)
Hook called whenever an #ifndef is seen.
Definition: PPCallbacks.h:330
clang::PPCallbacks::PragmaAssumeNonNullEnd
virtual void PragmaAssumeNonNullEnd(SourceLocation Loc)
Callback invoked when a #pragma clang assume_nonnull end directive is read.
Definition: PPCallbacks.h:249
SourceLocation.h
Defines the clang::SourceLocation class and associated facilities.
clang::PPChainedCallbacks::Endif
void Endif(SourceLocation Loc, SourceLocation IfLoc) override
Hook called whenever an #endif is seen.
Definition: PPCallbacks.h:556
clang::PPCallbacks::CVK_True
Definition: PPCallbacks.h:295
clang::PPCallbacks::PragmaDiagnosticPush
virtual void PragmaDiagnosticPush(SourceLocation Loc, StringRef Namespace)
Callback invoked when a #pragma gcc diagnostic push directive is read.
Definition: PPCallbacks.h:209
DiagnosticIDs.h
Defines the Diagnostic IDs-related interfaces.
clang::PPCallbacks::PragmaDiagnostic
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:220
clang::PPChainedCallbacks::SourceRangeSkipped
void SourceRangeSkipped(SourceRange Range, SourceLocation EndifLoc) override
Hook called when a source range is skipped.
Definition: PPCallbacks.h:516
clang::SourceRange
A trivial tuple used to represent a source range.
Definition: SourceLocation.h:198
clang::PPChainedCallbacks::Else
void Else(SourceLocation Loc, SourceLocation IfLoc) override
Hook called whenever an #else is seen.
Definition: PPCallbacks.h:550
clang::PPCallbacks::CVK_NotEvaluated
Definition: PPCallbacks.h:295
clang::prec::Level
Level
Definition: OperatorPrecedence.h:27
clang::PPCallbacks::FileSkipped
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
clang::PPCallbacks::SourceRangeSkipped
virtual void SourceRangeSkipped(SourceRange Range, SourceLocation EndifLoc)
Hook called when a source range is skipped.
Definition: PPCallbacks.h:291