clang-tools 23.0.0git
PPCallbacksTracker.cpp
Go to the documentation of this file.
1//===--- PPCallbacksTracker.cpp - Preprocessor tracker -*--*---------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8///
9/// \file
10/// Implementations for preprocessor tracking.
11///
12/// See the header for details.
13///
14//===----------------------------------------------------------------------===//
15
16#include "PPCallbacksTracker.h"
17#include "clang/Basic/FileManager.h"
18#include "clang/Lex/MacroArgs.h"
19#include "llvm/Support/raw_ostream.h"
20
21namespace clang {
22namespace pp_trace {
23
24// Get a "file:line:column" source location string.
25static std::string getSourceLocationString(Preprocessor &PP,
26 SourceLocation Loc) {
27 if (Loc.isInvalid())
28 return std::string("(none)");
29
30 if (Loc.isFileID()) {
31 PresumedLoc PLoc = PP.getSourceManager().getPresumedLoc(Loc);
32
33 if (PLoc.isInvalid()) {
34 return std::string("(invalid)");
35 }
36
37 std::string Str;
38 llvm::raw_string_ostream SS(Str);
39
40 // The macro expansion and spelling pos is identical for file locs.
41 SS << "\"" << PLoc.getFilename() << ':' << PLoc.getLine() << ':'
42 << PLoc.getColumn() << "\"";
43
44 std::string Result = SS.str();
45
46 // YAML treats backslash as escape, so use forward slashes.
47 llvm::replace(Result, '\\', '/');
48
49 return Result;
50 }
51
52 return std::string("(nonfile)");
53}
54
55// Enum string tables.
56
57// FileChangeReason strings.
58static const char *const FileChangeReasonStrings[] = {
59 "EnterFile", "ExitFile", "SystemHeaderPragma", "RenameFile"
60};
61
62// CharacteristicKind strings.
63static const char *const CharacteristicKindStrings[] = {
64 "C_User", "C_System", "C_ExternCSystem", "C_User_ModuleMap",
65 "C_System_ModuleMap"};
66
67// MacroDirective::Kind strings.
68static const char *const MacroDirectiveKindStrings[] = {
69 "MD_Define","MD_Undefine", "MD_Visibility"
70};
71
72// PragmaIntroducerKind strings.
73static const char *const PragmaIntroducerKindStrings[] = { "PIK_HashPragma",
74 "PIK__Pragma",
75 "PIK___pragma" };
76
77// PragmaMessageKind strings.
78static const char *const PragmaMessageKindStrings[] = {
79 "PMK_Message", "PMK_Warning", "PMK_Error"
80};
81
82// PragmaWarningSpecifier strings.
83static const char *const PragmaWarningSpecifierStrings[] = {
84 "PWS_Default", "PWS_Disable", "PWS_Error", "PWS_Once", "PWS_Suppress",
85 "PWS_Level1", "PWS_Level2", "PWS_Level3", "PWS_Level4",
86};
87
88// ConditionValueKind strings.
89static const char *const ConditionValueKindStrings[] = {
90 "CVK_NotEvaluated", "CVK_False", "CVK_True"
91};
92
93// Mapping strings.
94static const char *const MappingStrings[] = { "0", "MAP_IGNORE",
95 "MAP_REMARK", "MAP_WARNING",
96 "MAP_ERROR", "MAP_FATAL" };
97
98// PPCallbacksTracker functions.
99
101 std::vector<CallbackCall> &CallbackCalls,
102 Preprocessor &PP)
104
106
107// Callback functions.
108
109// Callback invoked whenever a source file is entered or exited.
110void PPCallbacksTracker::FileChanged(SourceLocation Loc,
111 PPCallbacks::FileChangeReason Reason,
112 SrcMgr::CharacteristicKind FileType,
113 FileID PrevFID) {
114 beginCallback("FileChanged");
115 appendArgument("Loc", Loc);
116 appendArgument("Reason", Reason, FileChangeReasonStrings);
117 appendArgument("FileType", FileType, CharacteristicKindStrings);
118 appendArgument("PrevFID", PrevFID);
119}
120
121// Callback invoked whenever a source file is skipped as the result
122// of header guard optimization.
123void PPCallbacksTracker::FileSkipped(const FileEntryRef &SkippedFile,
124 const Token &FilenameTok,
125 SrcMgr::CharacteristicKind FileType) {
126 beginCallback("FileSkipped");
127 appendArgument("ParentFile", SkippedFile);
128 appendArgument("FilenameTok", FilenameTok);
129 appendArgument("FileType", FileType, CharacteristicKindStrings);
130}
131
132// Callback invoked whenever an inclusion directive of
133// any kind (#include, #import, etc.) has been processed, regardless
134// of whether the inclusion will actually result in an inclusion.
136 SourceLocation HashLoc, const Token &IncludeTok, llvm::StringRef FileName,
137 bool IsAngled, CharSourceRange FilenameRange, OptionalFileEntryRef File,
138 llvm::StringRef SearchPath, llvm::StringRef RelativePath,
139 const Module *SuggestedModule, bool ModuleImported,
140 SrcMgr::CharacteristicKind FileType) {
141 beginCallback("InclusionDirective");
142 appendArgument("HashLoc", HashLoc);
143 appendArgument("IncludeTok", IncludeTok);
144 appendFilePathArgument("FileName", FileName);
145 appendArgument("IsAngled", IsAngled);
146 appendArgument("FilenameRange", FilenameRange);
147 appendArgument("File", File);
148 appendFilePathArgument("SearchPath", SearchPath);
149 appendFilePathArgument("RelativePath", RelativePath);
150 appendArgument("SuggestedModule", SuggestedModule);
151 appendArgument("ModuleImported", ModuleImported);
152}
153
154// Callback invoked whenever there was an explicit module-import
155// syntax.
156void PPCallbacksTracker::moduleImport(SourceLocation ImportLoc,
157 ModuleIdPath Path,
158 const Module *Imported) {
159 beginCallback("moduleImport");
160 appendArgument("ImportLoc", ImportLoc);
161 appendArgument("Path", Path);
162 appendArgument("Imported", Imported);
163}
164
165// Callback invoked when the end of the main file is reached.
166// No subsequent callbacks will be made.
168
169// Callback invoked when a #ident or #sccs directive is read.
170void PPCallbacksTracker::Ident(SourceLocation Loc, llvm::StringRef Str) {
171 beginCallback("Ident");
172 appendArgument("Loc", Loc);
173 appendArgument("Str", Str);
174}
175
176// Callback invoked when start reading any pragma directive.
178 PragmaIntroducerKind Introducer) {
179 beginCallback("PragmaDirective");
180 appendArgument("Loc", Loc);
181 appendArgument("Introducer", Introducer, PragmaIntroducerKindStrings);
182}
183
184// Callback invoked when a #pragma comment directive is read.
185void PPCallbacksTracker::PragmaComment(SourceLocation Loc,
186 const IdentifierInfo *Kind,
187 llvm::StringRef Str) {
188 beginCallback("PragmaComment");
189 appendArgument("Loc", Loc);
190 appendArgument("Kind", Kind);
191 appendArgument("Str", Str);
192}
193
194// Callback invoked when a #pragma detect_mismatch directive is
195// read.
197 llvm::StringRef Name,
198 llvm::StringRef Value) {
199 beginCallback("PragmaDetectMismatch");
200 appendArgument("Loc", Loc);
201 appendArgument("Name", Name);
202 appendArgument("Value", Value);
203}
204
205// Callback invoked when a #pragma clang __debug directive is read.
206void PPCallbacksTracker::PragmaDebug(SourceLocation Loc,
207 llvm::StringRef DebugType) {
208 beginCallback("PragmaDebug");
209 appendArgument("Loc", Loc);
210 appendArgument("DebugType", DebugType);
211}
212
213// Callback invoked when a #pragma message directive is read.
214void PPCallbacksTracker::PragmaMessage(SourceLocation Loc,
215 llvm::StringRef Namespace,
216 PPCallbacks::PragmaMessageKind Kind,
217 llvm::StringRef Str) {
218 beginCallback("PragmaMessage");
219 appendArgument("Loc", Loc);
220 appendArgument("Namespace", Namespace);
222 appendArgument("Str", Str);
223}
224
225// Callback invoked when a #pragma gcc diagnostic push directive
226// is read.
228 llvm::StringRef Namespace) {
229 beginCallback("PragmaDiagnosticPush");
230 appendArgument("Loc", Loc);
231 appendArgument("Namespace", Namespace);
232}
233
234// Callback invoked when a #pragma gcc diagnostic pop directive
235// is read.
237 llvm::StringRef Namespace) {
238 beginCallback("PragmaDiagnosticPop");
239 appendArgument("Loc", Loc);
240 appendArgument("Namespace", Namespace);
241}
242
243// Callback invoked when a #pragma gcc diagnostic directive is read.
245 llvm::StringRef Namespace,
246 diag::Severity Mapping,
247 llvm::StringRef Str) {
248 beginCallback("PragmaDiagnostic");
249 appendArgument("Loc", Loc);
250 appendArgument("Namespace", Namespace);
251 appendArgument("Mapping", (unsigned)Mapping, MappingStrings);
252 appendArgument("Str", Str);
253}
254
255// Called when an OpenCL extension is either disabled or
256// enabled with a pragma.
258 const IdentifierInfo *Name,
259 SourceLocation StateLoc,
260 unsigned State) {
261 beginCallback("PragmaOpenCLExtension");
262 appendArgument("NameLoc", NameLoc);
263 appendArgument("Name", Name);
264 appendArgument("StateLoc", StateLoc);
265 appendArgument("State", (int)State);
266}
267
268// Callback invoked when a #pragma warning directive is read.
269void PPCallbacksTracker::PragmaWarning(SourceLocation Loc,
270 PragmaWarningSpecifier WarningSpec,
271 llvm::ArrayRef<int> Ids) {
272 beginCallback("PragmaWarning");
273 appendArgument("Loc", Loc);
274 appendArgument("WarningSpec", WarningSpec, PragmaWarningSpecifierStrings);
275
276 std::string Str;
277 llvm::raw_string_ostream SS(Str);
278 SS << "[";
279 for (int i = 0, e = Ids.size(); i != e; ++i) {
280 if (i)
281 SS << ", ";
282 SS << Ids[i];
283 }
284 SS << "]";
285 appendArgument("Ids", SS.str());
286}
287
288// Callback invoked when a #pragma warning(push) directive is read.
289void PPCallbacksTracker::PragmaWarningPush(SourceLocation Loc, int Level) {
290 beginCallback("PragmaWarningPush");
291 appendArgument("Loc", Loc);
292 appendArgument("Level", Level);
293}
294
295// Callback invoked when a #pragma warning(pop) directive is read.
296void PPCallbacksTracker::PragmaWarningPop(SourceLocation Loc) {
297 beginCallback("PragmaWarningPop");
298 appendArgument("Loc", Loc);
299}
300
301// Callback invoked when a #pragma execution_character_set(push) directive
302// is read.
304 StringRef Str) {
305 beginCallback("PragmaExecCharsetPush");
306 appendArgument("Loc", Loc);
307 appendArgument("Charset", Str);
308}
309
310// Callback invoked when a #pragma execution_character_set(pop) directive
311// is read.
313 beginCallback("PragmaExecCharsetPop");
314 appendArgument("Loc", Loc);
315}
316
317// Called by Preprocessor::HandleMacroExpandedIdentifier when a
318// macro invocation is found.
319void PPCallbacksTracker::MacroExpands(const Token &MacroNameTok,
320 const MacroDefinition &MacroDefinition,
321 SourceRange Range,
322 const MacroArgs *Args) {
323 beginCallback("MacroExpands");
324 appendArgument("MacroNameTok", MacroNameTok);
325 appendArgument("MacroDefinition", MacroDefinition);
326 appendArgument("Range", Range);
327 appendArgument("Args", Args);
328}
329
330// Hook called whenever a macro definition is seen.
331void PPCallbacksTracker::MacroDefined(const Token &MacroNameTok,
332 const MacroDirective *MacroDirective) {
333 beginCallback("MacroDefined");
334 appendArgument("MacroNameTok", MacroNameTok);
335 appendArgument("MacroDirective", MacroDirective);
336}
337
338// Hook called whenever a macro #undef is seen.
339void PPCallbacksTracker::MacroUndefined(const Token &MacroNameTok,
340 const MacroDefinition &MacroDefinition,
341 const MacroDirective *Undef) {
342 beginCallback("MacroUndefined");
343 appendArgument("MacroNameTok", MacroNameTok);
344 appendArgument("MacroDefinition", MacroDefinition);
345}
346
347// Hook called whenever the 'defined' operator is seen.
348void PPCallbacksTracker::Defined(const Token &MacroNameTok,
349 const MacroDefinition &MacroDefinition,
350 SourceRange Range) {
351 beginCallback("Defined");
352 appendArgument("MacroNameTok", MacroNameTok);
353 appendArgument("MacroDefinition", MacroDefinition);
354 appendArgument("Range", Range);
355}
356
357// Hook called when a source range is skipped.
359 SourceLocation EndifLoc) {
360 beginCallback("SourceRangeSkipped");
361 appendArgument("Range", SourceRange(Range.getBegin(), EndifLoc));
362}
363
364// Hook called whenever an #if is seen.
365void PPCallbacksTracker::If(SourceLocation Loc, SourceRange ConditionRange,
366 ConditionValueKind ConditionValue) {
367 beginCallback("If");
368 appendArgument("Loc", Loc);
369 appendArgument("ConditionRange", ConditionRange);
370 appendArgument("ConditionValue", ConditionValue, ConditionValueKindStrings);
371}
372
373// Hook called whenever an #elif is seen.
374void PPCallbacksTracker::Elif(SourceLocation Loc, SourceRange ConditionRange,
375 ConditionValueKind ConditionValue,
376 SourceLocation IfLoc) {
377 beginCallback("Elif");
378 appendArgument("Loc", Loc);
379 appendArgument("ConditionRange", ConditionRange);
380 appendArgument("ConditionValue", ConditionValue, ConditionValueKindStrings);
381 appendArgument("IfLoc", IfLoc);
382}
383
384// Hook called whenever an #ifdef is seen.
385void PPCallbacksTracker::Ifdef(SourceLocation Loc, const Token &MacroNameTok,
386 const MacroDefinition &MacroDefinition) {
387 beginCallback("Ifdef");
388 appendArgument("Loc", Loc);
389 appendArgument("MacroNameTok", MacroNameTok);
390 appendArgument("MacroDefinition", MacroDefinition);
391}
392
393// Hook called whenever an #ifndef is seen.
394void PPCallbacksTracker::Ifndef(SourceLocation Loc, const Token &MacroNameTok,
395 const MacroDefinition &MacroDefinition) {
396 beginCallback("Ifndef");
397 appendArgument("Loc", Loc);
398 appendArgument("MacroNameTok", MacroNameTok);
399 appendArgument("MacroDefinition", MacroDefinition);
400}
401
402// Hook called whenever an #else is seen.
403void PPCallbacksTracker::Else(SourceLocation Loc, SourceLocation IfLoc) {
404 beginCallback("Else");
405 appendArgument("Loc", Loc);
406 appendArgument("IfLoc", IfLoc);
407}
408
409// Hook called whenever an #endif is seen.
410void PPCallbacksTracker::Endif(SourceLocation Loc, SourceLocation IfLoc) {
411 beginCallback("Endif");
412 appendArgument("Loc", Loc);
413 appendArgument("IfLoc", IfLoc);
414}
415
416// Helper functions.
417
418// Start a new callback.
419void PPCallbacksTracker::beginCallback(const char *Name) {
420 auto R = CallbackIsEnabled.try_emplace(Name, false);
421 if (R.second) {
422 llvm::StringRef N(Name);
423 for (const std::pair<llvm::GlobPattern, bool> &Filter : Filters)
424 if (Filter.first.match(N))
425 R.first->second = Filter.second;
426 }
427 DisableTrace = !R.first->second;
428 if (DisableTrace)
429 return;
430 CallbackCalls.push_back(CallbackCall(Name));
431}
432
433// Append a bool argument to the top trace item.
434void PPCallbacksTracker::appendArgument(const char *Name, bool Value) {
435 appendArgument(Name, (Value ? "true" : "false"));
436}
437
438// Append an int argument to the top trace item.
439void PPCallbacksTracker::appendArgument(const char *Name, int Value) {
440 std::string Str;
441 llvm::raw_string_ostream SS(Str);
442 SS << Value;
443 appendArgument(Name, SS.str());
444}
445
446// Append a string argument to the top trace item.
447void PPCallbacksTracker::appendArgument(const char *Name, const char *Value) {
448 if (DisableTrace)
449 return;
450 CallbackCalls.back().Arguments.push_back(Argument{Name, Value});
451}
452
453// Append a string object argument to the top trace item.
455 llvm::StringRef Value) {
456 appendArgument(Name, Value.str());
457}
458
459// Append a string object argument to the top trace item.
461 const std::string &Value) {
462 appendArgument(Name, Value.c_str());
463}
464
465// Append a token argument to the top trace item.
466void PPCallbacksTracker::appendArgument(const char *Name, const Token &Value) {
467 appendArgument(Name, PP.getSpelling(Value));
468}
469
470// Append an enum argument to the top trace item.
471void PPCallbacksTracker::appendArgument(const char *Name, int Value,
472 const char *const Strings[]) {
473 appendArgument(Name, Strings[Value]);
474}
475
476// Append a FileID argument to the top trace item.
477void PPCallbacksTracker::appendArgument(const char *Name, FileID Value) {
478 if (Value.isInvalid()) {
479 appendArgument(Name, "(invalid)");
480 return;
481 }
482 OptionalFileEntryRef FileEntry =
483 PP.getSourceManager().getFileEntryRefForID(Value);
484 if (!FileEntry) {
485 appendArgument(Name, "(getFileEntryForID failed)");
486 return;
487 }
488 appendFilePathArgument(Name, FileEntry->getName());
489}
490
491// Append a FileEntry argument to the top trace item.
493 OptionalFileEntryRef Value) {
494 if (!Value) {
495 appendArgument(Name, "(null)");
496 return;
497 }
498 appendArgument(Name, *Value);
499}
500
501void PPCallbacksTracker::appendArgument(const char *Name, FileEntryRef Value) {
502 appendFilePathArgument(Name, Value.getName());
503}
504
505// Append a SourceLocation argument to the top trace item.
507 SourceLocation Value) {
508 if (Value.isInvalid()) {
509 appendArgument(Name, "(invalid)");
510 return;
511 }
512 appendArgument(Name, getSourceLocationString(PP, Value).c_str());
513}
514
515// Append a SourceRange argument to the top trace item.
516void PPCallbacksTracker::appendArgument(const char *Name, SourceRange Value) {
517 if (DisableTrace)
518 return;
519 if (Value.isInvalid()) {
520 appendArgument(Name, "(invalid)");
521 return;
522 }
523 std::string Str;
524 llvm::raw_string_ostream SS(Str);
525 SS << "[" << getSourceLocationString(PP, Value.getBegin()) << ", "
526 << getSourceLocationString(PP, Value.getEnd()) << "]";
527 appendArgument(Name, SS.str());
528}
529
530// Append a CharSourceRange argument to the top trace item.
532 CharSourceRange Value) {
533 if (Value.isInvalid()) {
534 appendArgument(Name, "(invalid)");
535 return;
536 }
537 appendArgument(Name, getSourceString(Value).str().c_str());
538}
539
540// Append a SourceLocation argument to the top trace item.
541void PPCallbacksTracker::appendArgument(const char *Name, ModuleIdPath Value) {
542 if (DisableTrace)
543 return;
544 std::string Str;
545 llvm::raw_string_ostream SS(Str);
546 SS << "[";
547 for (int I = 0, E = Value.size(); I != E; ++I) {
548 if (I)
549 SS << ", ";
550 SS << "{"
551 << "Name: " << Value[I].getIdentifierInfo()->getName() << ", "
552 << "Loc: " << getSourceLocationString(PP, Value[I].getLoc()) << "}";
553 }
554 SS << "]";
555 appendArgument(Name, SS.str());
556}
557
558// Append an IdentifierInfo argument to the top trace item.
560 const IdentifierInfo *Value) {
561 if (!Value) {
562 appendArgument(Name, "(null)");
563 return;
564 }
565 appendArgument(Name, Value->getName().str().c_str());
566}
567
568// Append a MacroDirective argument to the top trace item.
570 const MacroDirective *Value) {
571 if (!Value) {
572 appendArgument(Name, "(null)");
573 return;
574 }
575 appendArgument(Name, MacroDirectiveKindStrings[Value->getKind()]);
576}
577
578// Append a MacroDefinition argument to the top trace item.
580 const MacroDefinition &Value) {
581 std::string Str;
582 llvm::raw_string_ostream SS(Str);
583 SS << "[";
584 bool Any = false;
585 if (Value.getLocalDirective()) {
586 SS << "(local)";
587 Any = true;
588 }
589 for (auto *MM : Value.getModuleMacros()) {
590 if (Any) SS << ", ";
591 SS << MM->getOwningModule()->getFullModuleName();
592 }
593 SS << "]";
594 appendArgument(Name, SS.str());
595}
596
597// Append a MacroArgs argument to the top trace item.
599 const MacroArgs *Value) {
600 if (!Value) {
601 appendArgument(Name, "(null)");
602 return;
603 }
604 std::string Str;
605 llvm::raw_string_ostream SS(Str);
606 SS << "[";
607
608 // Each argument is a series of contiguous Tokens, terminated by a eof.
609 // Go through each argument printing tokens until we reach eof.
610 for (unsigned I = 0; I < Value->getNumMacroArguments(); ++I) {
611 const Token *Current = Value->getUnexpArgument(I);
612 if (I)
613 SS << ", ";
614 bool First = true;
615 while (Current->isNot(tok::eof)) {
616 if (!First)
617 SS << " ";
618 // We need to be careful here because the arguments might not be legal in
619 // YAML, so we use the token name for anything but identifiers and
620 // numeric literals.
621 if (Current->isAnyIdentifier() || Current->is(tok::numeric_constant)) {
622 SS << PP.getSpelling(*Current);
623 } else {
624 SS << "<" << Current->getName() << ">";
625 }
626 ++Current;
627 First = false;
628 }
629 }
630 SS << "]";
631 appendArgument(Name, SS.str());
632}
633
634// Append a Module argument to the top trace item.
635void PPCallbacksTracker::appendArgument(const char *Name, const Module *Value) {
636 if (!Value) {
637 appendArgument(Name, "(null)");
638 return;
639 }
640 appendArgument(Name, Value->Name.c_str());
641}
642
643// Append a double-quoted argument to the top trace item.
645 const std::string &Value) {
646 std::string Str;
647 llvm::raw_string_ostream SS(Str);
648 SS << "\"" << Value << "\"";
649 appendArgument(Name, SS.str());
650}
651
652// Append a double-quoted file path argument to the top trace item.
654 llvm::StringRef Value) {
655 std::string Path(Value);
656 // YAML treats backslash as escape, so use forward slashes.
657 llvm::replace(Path, '\\', '/');
658 appendQuotedArgument(Name, Path);
659}
660
661// Get the raw source string of the range.
662llvm::StringRef PPCallbacksTracker::getSourceString(CharSourceRange Range) {
663 const char *B = PP.getSourceManager().getCharacterData(Range.getBegin());
664 const char *E = PP.getSourceManager().getCharacterData(Range.getEnd());
665 return llvm::StringRef(B, E - B);
666}
667
668} // namespace pp_trace
669} // namespace clang
Classes and definitions for preprocessor tracking.
This class represents one callback call by name and an array of arguments.
void beginCallback(const char *Name)
Start a new callback.
void SourceRangeSkipped(SourceRange Range, SourceLocation EndifLoc) override
void PragmaComment(SourceLocation Loc, const IdentifierInfo *Kind, llvm::StringRef Str) override
void FileSkipped(const FileEntryRef &SkippedFile, const Token &FilenameTok, SrcMgr::CharacteristicKind FileType) override
void MacroUndefined(const Token &MacroNameTok, const MacroDefinition &MD, const MacroDirective *Undef) override
void Ifdef(SourceLocation Loc, const Token &MacroNameTok, const MacroDefinition &MD) override
void Elif(SourceLocation Loc, SourceRange ConditionRange, ConditionValueKind ConditionValue, SourceLocation IfLoc) override
void MacroDefined(const Token &MacroNameTok, const MacroDirective *MD) override
void If(SourceLocation Loc, SourceRange ConditionRange, ConditionValueKind ConditionValue) override
void PragmaDiagnostic(SourceLocation Loc, llvm::StringRef Namespace, diag::Severity mapping, llvm::StringRef Str) override
void Ident(SourceLocation Loc, llvm::StringRef str) override
llvm::StringMap< bool > CallbackIsEnabled
void appendQuotedArgument(const char *Name, const std::string &Value)
Append a double-quoted argument to the top trace item.
void PragmaDirective(SourceLocation Loc, PragmaIntroducerKind Introducer) override
void PragmaDiagnosticPop(SourceLocation Loc, llvm::StringRef Namespace) override
void PragmaDetectMismatch(SourceLocation Loc, llvm::StringRef Name, llvm::StringRef Value) override
void PragmaWarningPop(SourceLocation Loc) override
void Ifndef(SourceLocation Loc, const Token &MacroNameTok, const MacroDefinition &MD) override
void InclusionDirective(SourceLocation HashLoc, const Token &IncludeTok, llvm::StringRef FileName, bool IsAngled, CharSourceRange FilenameRange, OptionalFileEntryRef File, llvm::StringRef SearchPath, llvm::StringRef RelativePath, const Module *SuggestedModule, bool ModuleImported, SrcMgr::CharacteristicKind FileType) override
void PragmaMessage(SourceLocation Loc, llvm::StringRef Namespace, PPCallbacks::PragmaMessageKind Kind, llvm::StringRef Str) override
void Endif(SourceLocation Loc, SourceLocation IfLoc) override
void PragmaDebug(SourceLocation Loc, llvm::StringRef DebugType) override
std::vector< CallbackCall > & CallbackCalls
Callback trace information.
void MacroExpands(const Token &MacroNameTok, const MacroDefinition &MD, SourceRange Range, const MacroArgs *Args) override
void PragmaWarning(SourceLocation Loc, PragmaWarningSpecifier WarningSpec, llvm::ArrayRef< int > Ids) override
llvm::StringRef getSourceString(CharSourceRange Range)
Get the raw source string of the range.
bool DisableTrace
Inhibit trace while this is set.
PPCallbacksTracker(const FilterType &Filters, std::vector< CallbackCall > &CallbackCalls, Preprocessor &PP)
Note that all of the arguments are references, and owned by the caller.
void PragmaExecCharsetPush(SourceLocation Loc, StringRef Str) override
void Defined(const Token &MacroNameTok, const MacroDefinition &MD, SourceRange Range) override
void PragmaWarningPush(SourceLocation Loc, int Level) override
void Else(SourceLocation Loc, SourceLocation IfLoc) override
void PragmaExecCharsetPop(SourceLocation Loc) override
void FileChanged(SourceLocation Loc, PPCallbacks::FileChangeReason Reason, SrcMgr::CharacteristicKind FileType, FileID PrevFID=FileID()) override
void moduleImport(SourceLocation ImportLoc, ModuleIdPath Path, const Module *Imported) override
void PragmaDiagnosticPush(SourceLocation Loc, llvm::StringRef Namespace) override
void appendArgument(const char *Name, bool Value)
Append a bool argument to the top trace item.
void PragmaOpenCLExtension(SourceLocation NameLoc, const IdentifierInfo *Name, SourceLocation StateLoc, unsigned State) override
void appendFilePathArgument(const char *Name, llvm::StringRef Value)
Append a double-quoted file path argument to the top trace item.
static const char *const PragmaIntroducerKindStrings[]
static const char *const PragmaMessageKindStrings[]
static const char *const CharacteristicKindStrings[]
static const char *const ConditionValueKindStrings[]
static const char *const PragmaWarningSpecifierStrings[]
static const char *const FileChangeReasonStrings[]
static const char *const MacroDirectiveKindStrings[]
static const char *const MappingStrings[]
static std::string getSourceLocationString(Preprocessor &PP, SourceLocation Loc)
std::vector< std::pair< llvm::GlobPattern, bool > > FilterType
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//