22
22
#include " llvm/ADT/StringRef.h"
23
23
24
24
namespace clang {
25
- class Token ;
26
- class IdentifierInfo ;
27
- class MacroDefinition ;
28
- class MacroDirective ;
29
- class MacroArgs ;
25
+ class Token ;
26
+ class IdentifierInfo ;
27
+ class MacroDefinition ;
28
+ class MacroDirective ;
29
+ class MacroArgs ;
30
30
31
31
// / This interface provides a way to observe the actions of the
32
32
// / preprocessor as it does its thing.
@@ -36,9 +36,7 @@ class PPCallbacks {
36
36
public:
37
37
virtual ~PPCallbacks ();
38
38
39
- enum FileChangeReason {
40
- EnterFile, ExitFile, SystemHeaderPragma, RenameFile
41
- };
39
+ enum FileChangeReason { EnterFile, ExitFile, SystemHeaderPragma, RenameFile };
42
40
43
41
// / Callback invoked whenever a source file is entered or exited.
44
42
// /
@@ -47,8 +45,7 @@ class PPCallbacks {
47
45
// / the file before the new one entered for \p Reason EnterFile.
48
46
virtual void FileChanged (SourceLocation Loc, FileChangeReason Reason,
49
47
SrcMgr::CharacteristicKind FileType,
50
- FileID PrevFID = FileID()) {
51
- }
48
+ FileID PrevFID = FileID()) {}
52
49
53
50
enum class LexedFileChangeReason { EnterFile, ExitFile };
54
51
@@ -192,7 +189,7 @@ class PPCallbacks {
192
189
// / \param ForPragma If entering from pragma directive.
193
190
// /
194
191
virtual void EnteredSubmodule (Module *M, SourceLocation ImportLoc,
195
- bool ForPragma) { }
192
+ bool ForPragma) {}
196
193
197
194
// / Callback invoked whenever a submodule was left.
198
195
// /
@@ -203,7 +200,7 @@ class PPCallbacks {
203
200
// / \param ForPragma If entering from pragma directive.
204
201
// /
205
202
virtual void LeftSubmodule (Module *M, SourceLocation ImportLoc,
206
- bool ForPragma) { }
203
+ bool ForPragma) {}
207
204
208
205
// / Callback invoked whenever there was an explicit module-import
209
206
// / syntax.
@@ -215,49 +212,40 @@ class PPCallbacks {
215
212
// /
216
213
// / \param Imported The imported module; can be null if importing failed.
217
214
// /
218
- virtual void moduleImport (SourceLocation ImportLoc,
219
- ModuleIdPath Path,
220
- const Module *Imported) {
221
- }
215
+ virtual void moduleImport (SourceLocation ImportLoc, ModuleIdPath Path,
216
+ const Module *Imported) {}
222
217
223
218
// / Callback invoked when the end of the main file is reached.
224
219
// /
225
220
// / No subsequent callbacks will be made.
226
- virtual void EndOfMainFile () {
227
- }
221
+ virtual void EndOfMainFile () {}
228
222
229
223
// / Callback invoked when a \#ident or \#sccs directive is read.
230
224
// / \param Loc The location of the directive.
231
225
// / \param str The text of the directive.
232
226
// /
233
- virtual void Ident (SourceLocation Loc, StringRef str) {
234
- }
227
+ virtual void Ident (SourceLocation Loc, StringRef str) {}
235
228
236
229
// / Callback invoked when start reading any pragma directive.
237
230
virtual void PragmaDirective (SourceLocation Loc,
238
- PragmaIntroducerKind Introducer) {
239
- }
231
+ PragmaIntroducerKind Introducer) {}
240
232
241
233
// / Callback invoked when a \#pragma comment directive is read.
242
234
virtual void PragmaComment (SourceLocation Loc, const IdentifierInfo *Kind,
243
- StringRef Str) {
244
- }
235
+ StringRef Str) {}
245
236
246
237
// / Callback invoked when a \#pragma mark comment is read.
247
- virtual void PragmaMark (SourceLocation Loc, StringRef Trivia) {
248
- }
238
+ virtual void PragmaMark (SourceLocation Loc, StringRef Trivia) {}
249
239
250
240
// / Callback invoked when a \#pragma detect_mismatch directive is
251
241
// / read.
252
242
virtual void PragmaDetectMismatch (SourceLocation Loc, StringRef Name,
253
- StringRef Value) {
254
- }
243
+ StringRef Value) {}
255
244
256
245
// / Callback invoked when a \#pragma clang __debug directive is read.
257
246
// / \param Loc The location of the debug directive.
258
247
// / \param DebugType The identifier following __debug.
259
- virtual void PragmaDebug (SourceLocation Loc, StringRef DebugType) {
260
- }
248
+ virtual void PragmaDebug (SourceLocation Loc, StringRef DebugType) {}
261
249
262
250
// / Determines the kind of \#pragma invoking a call to PragmaMessage.
263
251
enum PragmaMessageKind {
@@ -277,20 +265,15 @@ class PPCallbacks {
277
265
// / \param Kind The type of the message directive.
278
266
// / \param Str The text of the message directive.
279
267
virtual void PragmaMessage (SourceLocation Loc, StringRef Namespace,
280
- PragmaMessageKind Kind, StringRef Str) {
281
- }
268
+ PragmaMessageKind Kind, StringRef Str) {}
282
269
283
270
// / Callback invoked when a \#pragma gcc diagnostic push directive
284
271
// / is read.
285
- virtual void PragmaDiagnosticPush (SourceLocation Loc,
286
- StringRef Namespace) {
287
- }
272
+ virtual void PragmaDiagnosticPush (SourceLocation Loc, StringRef Namespace) {}
288
273
289
274
// / Callback invoked when a \#pragma gcc diagnostic pop directive
290
275
// / is read.
291
- virtual void PragmaDiagnosticPop (SourceLocation Loc,
292
- StringRef Namespace) {
293
- }
276
+ virtual void PragmaDiagnosticPop (SourceLocation Loc, StringRef Namespace) {}
294
277
295
278
// / Callback invoked when a \#pragma gcc diagnostic directive is read.
296
279
virtual void PragmaDiagnostic (SourceLocation Loc, StringRef Namespace,
@@ -300,8 +283,7 @@ class PPCallbacks {
300
283
// / enabled with a pragma.
301
284
virtual void PragmaOpenCLExtension (SourceLocation NameLoc,
302
285
const IdentifierInfo *Name,
303
- SourceLocation StateLoc, unsigned State) {
304
- }
286
+ SourceLocation StateLoc, unsigned State) {}
305
287
306
288
// / Callback invoked when a \#pragma warning directive is read.
307
289
enum PragmaWarningSpecifier {
@@ -320,12 +302,10 @@ class PPCallbacks {
320
302
ArrayRef<int > Ids) {}
321
303
322
304
// / Callback invoked when a \#pragma warning(push) directive is read.
323
- virtual void PragmaWarningPush (SourceLocation Loc, int Level) {
324
- }
305
+ virtual void PragmaWarningPush (SourceLocation Loc, int Level) {}
325
306
326
307
// / Callback invoked when a \#pragma warning(pop) directive is read.
327
- virtual void PragmaWarningPop (SourceLocation Loc) {
328
- }
308
+ virtual void PragmaWarningPop (SourceLocation Loc) {}
329
309
330
310
// / Callback invoked when a \#pragma execution_character_set(push) directive
331
311
// / is read.
@@ -351,8 +331,7 @@ class PPCallbacks {
351
331
352
332
// / Hook called whenever a macro definition is seen.
353
333
virtual void MacroDefined (const Token &MacroNameTok,
354
- const MacroDirective *MD) {
355
- }
334
+ const MacroDirective *MD) {}
356
335
357
336
// / Hook called whenever a macro \#undef is seen.
358
337
// / \param MacroNameTok The active Token
@@ -362,14 +341,12 @@ class PPCallbacks {
362
341
// / MD is released immediately following this callback.
363
342
virtual void MacroUndefined (const Token &MacroNameTok,
364
343
const MacroDefinition &MD,
365
- const MacroDirective *Undef) {
366
- }
344
+ const MacroDirective *Undef) {}
367
345
368
346
// / Hook called whenever the 'defined' operator is seen.
369
347
// / \param MD The MacroDirective if the name was a macro, null otherwise.
370
348
virtual void Defined (const Token &MacroNameTok, const MacroDefinition &MD,
371
- SourceRange Range) {
372
- }
349
+ SourceRange Range) {}
373
350
374
351
// / Hook called when a '__has_embed' directive is read.
375
352
virtual void HasEmbed (SourceLocation Loc, StringRef FileName, bool IsAngled,
@@ -387,12 +364,9 @@ class PPCallbacks {
387
364
// / \param EndifLoc The end location of the 'endif' token, which may precede
388
365
// / the range skipped by the directive (e.g excluding comments after an
389
366
// / 'endif').
390
- virtual void SourceRangeSkipped (SourceRange Range, SourceLocation EndifLoc) {
391
- }
367
+ virtual void SourceRangeSkipped (SourceRange Range, SourceLocation EndifLoc) {}
392
368
393
- enum ConditionValueKind {
394
- CVK_NotEvaluated, CVK_False, CVK_True
395
- };
369
+ enum ConditionValueKind { CVK_NotEvaluated, CVK_False, CVK_True };
396
370
397
371
// / Hook called whenever an \#if is seen.
398
372
// / \param Loc the source location of the directive.
@@ -401,8 +375,7 @@ class PPCallbacks {
401
375
// /
402
376
// FIXME: better to pass in a list (or tree!) of Tokens.
403
377
virtual void If (SourceLocation Loc, SourceRange ConditionRange,
404
- ConditionValueKind ConditionValue) {
405
- }
378
+ ConditionValueKind ConditionValue) {}
406
379
407
380
// / Hook called whenever an \#elif is seen.
408
381
// / \param Loc the source location of the directive.
@@ -411,68 +384,59 @@ class PPCallbacks {
411
384
// / \param IfLoc the source location of the \#if/\#ifdef/\#ifndef directive.
412
385
// FIXME: better to pass in a list (or tree!) of Tokens.
413
386
virtual void Elif (SourceLocation Loc, SourceRange ConditionRange,
414
- ConditionValueKind ConditionValue, SourceLocation IfLoc) {
415
- }
387
+ ConditionValueKind ConditionValue, SourceLocation IfLoc) {}
416
388
417
389
// / Hook called whenever an \#ifdef is seen.
418
390
// / \param Loc the source location of the directive.
419
391
// / \param MacroNameTok Information on the token being tested.
420
392
// / \param MD The MacroDefinition if the name was a macro, null otherwise.
421
393
virtual void Ifdef (SourceLocation Loc, const Token &MacroNameTok,
422
- const MacroDefinition &MD) {
423
- }
394
+ const MacroDefinition &MD) {}
424
395
425
396
// / Hook called whenever an \#elifdef branch is taken.
426
397
// / \param Loc the source location of the directive.
427
398
// / \param MacroNameTok Information on the token being tested.
428
399
// / \param MD The MacroDefinition if the name was a macro, null otherwise.
429
400
virtual void Elifdef (SourceLocation Loc, const Token &MacroNameTok,
430
- const MacroDefinition &MD) {
431
- }
401
+ const MacroDefinition &MD) {}
432
402
// / Hook called whenever an \#elifdef is skipped.
433
403
// / \param Loc the source location of the directive.
434
404
// / \param ConditionRange The SourceRange of the expression being tested.
435
405
// / \param IfLoc the source location of the \#if/\#ifdef/\#ifndef directive.
436
406
// FIXME: better to pass in a list (or tree!) of Tokens.
437
407
virtual void Elifdef (SourceLocation Loc, SourceRange ConditionRange,
438
- SourceLocation IfLoc) {
439
- }
408
+ SourceLocation IfLoc) {}
440
409
441
410
// / Hook called whenever an \#ifndef is seen.
442
411
// / \param Loc the source location of the directive.
443
412
// / \param MacroNameTok Information on the token being tested.
444
413
// / \param MD The MacroDefiniton if the name was a macro, null otherwise.
445
414
virtual void Ifndef (SourceLocation Loc, const Token &MacroNameTok,
446
- const MacroDefinition &MD) {
447
- }
415
+ const MacroDefinition &MD) {}
448
416
449
417
// / Hook called whenever an \#elifndef branch is taken.
450
418
// / \param Loc the source location of the directive.
451
419
// / \param MacroNameTok Information on the token being tested.
452
420
// / \param MD The MacroDefinition if the name was a macro, null otherwise.
453
421
virtual void Elifndef (SourceLocation Loc, const Token &MacroNameTok,
454
- const MacroDefinition &MD) {
455
- }
422
+ const MacroDefinition &MD) {}
456
423
// / Hook called whenever an \#elifndef is skipped.
457
424
// / \param Loc the source location of the directive.
458
425
// / \param ConditionRange The SourceRange of the expression being tested.
459
426
// / \param IfLoc the source location of the \#if/\#ifdef/\#ifndef directive.
460
427
// FIXME: better to pass in a list (or tree!) of Tokens.
461
428
virtual void Elifndef (SourceLocation Loc, SourceRange ConditionRange,
462
- SourceLocation IfLoc) {
463
- }
429
+ SourceLocation IfLoc) {}
464
430
465
431
// / Hook called whenever an \#else is seen.
466
432
// / \param Loc the source location of the directive.
467
433
// / \param IfLoc the source location of the \#if/\#ifdef/\#ifndef directive.
468
- virtual void Else (SourceLocation Loc, SourceLocation IfLoc) {
469
- }
434
+ virtual void Else (SourceLocation Loc, SourceLocation IfLoc) {}
470
435
471
436
// / Hook called whenever an \#endif is seen.
472
437
// / \param Loc the source location of the directive.
473
438
// / \param IfLoc the source location of the \#if/\#ifdef/\#ifndef directive.
474
- virtual void Endif (SourceLocation Loc, SourceLocation IfLoc) {
475
- }
439
+ virtual void Endif (SourceLocation Loc, SourceLocation IfLoc) {}
476
440
};
477
441
478
442
// / Simple wrapper class for chaining callbacks.
@@ -482,7 +446,7 @@ class PPChainedCallbacks : public PPCallbacks {
482
446
public:
483
447
PPChainedCallbacks (std::unique_ptr<PPCallbacks> _First,
484
448
std::unique_ptr<PPCallbacks> _Second)
485
- : First(std::move(_First)), Second(std::move(_Second)) {}
449
+ : First(std::move(_First)), Second(std::move(_Second)) {}
486
450
487
451
~PPChainedCallbacks () override ;
488
452
@@ -692,8 +656,7 @@ class PPChainedCallbacks : public PPCallbacks {
692
656
Second->MacroDefined (MacroNameTok, MD);
693
657
}
694
658
695
- void MacroUndefined (const Token &MacroNameTok,
696
- const MacroDefinition &MD,
659
+ void MacroUndefined (const Token &MacroNameTok, const MacroDefinition &MD,
697
660
const MacroDirective *Undef) override {
698
661
First->MacroUndefined (MacroNameTok, MD, Undef);
699
662
Second->MacroUndefined (MacroNameTok, MD, Undef);
@@ -759,7 +722,7 @@ class PPChainedCallbacks : public PPCallbacks {
759
722
}
760
723
// / Hook called whenever an \#elifndef is skipped.
761
724
void Elifndef (SourceLocation Loc, SourceRange ConditionRange,
762
- SourceLocation IfLoc) override {
725
+ SourceLocation IfLoc) override {
763
726
First->Elifndef (Loc, ConditionRange, IfLoc);
764
727
Second->Elifndef (Loc, ConditionRange, IfLoc);
765
728
}
@@ -777,6 +740,6 @@ class PPChainedCallbacks : public PPCallbacks {
777
740
}
778
741
};
779
742
780
- } // end namespace clang
743
+ } // end namespace clang
781
744
782
745
#endif
0 commit comments