clang-tools  6.0.0svn
Public Member Functions | Public Attributes | List of all members
PPCallbacksTracker Class Reference

This class overrides the PPCallbacks class for tracking preprocessor activity by means of its callback functions. More...

#include <PPCallbacksTracker.h>

Inheritance diagram for PPCallbacksTracker:
Inheritance graph
[legend]
Collaboration diagram for PPCallbacksTracker:
Collaboration graph
[legend]

Public Member Functions

 PPCallbacksTracker (llvm::SmallSet< std::string, 4 > &Ignore, std::vector< CallbackCall > &CallbackCalls, clang::Preprocessor &PP)
 Note that all of the arguments are references, and owned by the caller. More...
 
 ~PPCallbacksTracker () override
 
void FileChanged (clang::SourceLocation Loc, clang::PPCallbacks::FileChangeReason Reason, clang::SrcMgr::CharacteristicKind FileType, clang::FileID PrevFID=clang::FileID()) override
 
void FileSkipped (const clang::FileEntry &SkippedFile, const clang::Token &FilenameTok, clang::SrcMgr::CharacteristicKind FileType) override
 
bool FileNotFound (llvm::StringRef FileName, llvm::SmallVectorImpl< char > &RecoveryPath) override
 
void InclusionDirective (clang::SourceLocation HashLoc, const clang::Token &IncludeTok, llvm::StringRef FileName, bool IsAngled, clang::CharSourceRange FilenameRange, const clang::FileEntry *File, llvm::StringRef SearchPath, llvm::StringRef RelativePath, const clang::Module *Imported) override
 
void moduleImport (clang::SourceLocation ImportLoc, clang::ModuleIdPath Path, const clang::Module *Imported) override
 
void EndOfMainFile () override
 
void Ident (clang::SourceLocation Loc, llvm::StringRef str) override
 
void PragmaDirective (clang::SourceLocation Loc, clang::PragmaIntroducerKind Introducer) override
 
void PragmaComment (clang::SourceLocation Loc, const clang::IdentifierInfo *Kind, llvm::StringRef Str) override
 
void PragmaDetectMismatch (clang::SourceLocation Loc, llvm::StringRef Name, llvm::StringRef Value) override
 
void PragmaDebug (clang::SourceLocation Loc, llvm::StringRef DebugType) override
 
void PragmaMessage (clang::SourceLocation Loc, llvm::StringRef Namespace, clang::PPCallbacks::PragmaMessageKind Kind, llvm::StringRef Str) override
 
void PragmaDiagnosticPush (clang::SourceLocation Loc, llvm::StringRef Namespace) override
 
void PragmaDiagnosticPop (clang::SourceLocation Loc, llvm::StringRef Namespace) override
 
void PragmaDiagnostic (clang::SourceLocation Loc, llvm::StringRef Namespace, clang::diag::Severity mapping, llvm::StringRef Str) override
 
void PragmaOpenCLExtension (clang::SourceLocation NameLoc, const clang::IdentifierInfo *Name, clang::SourceLocation StateLoc, unsigned State) override
 
void PragmaWarning (clang::SourceLocation Loc, llvm::StringRef WarningSpec, llvm::ArrayRef< int > Ids) override
 
void PragmaWarningPush (clang::SourceLocation Loc, int Level) override
 
void PragmaWarningPop (clang::SourceLocation Loc) override
 
void MacroExpands (const clang::Token &MacroNameTok, const clang::MacroDefinition &MD, clang::SourceRange Range, const clang::MacroArgs *Args) override
 
void MacroDefined (const clang::Token &MacroNameTok, const clang::MacroDirective *MD) override
 
void MacroUndefined (const clang::Token &MacroNameTok, const clang::MacroDefinition &MD, const clang::MacroDirective *Undef) override
 
void Defined (const clang::Token &MacroNameTok, const clang::MacroDefinition &MD, clang::SourceRange Range) override
 
void SourceRangeSkipped (clang::SourceRange Range, clang::SourceLocation EndifLoc) override
 
void If (clang::SourceLocation Loc, clang::SourceRange ConditionRange, ConditionValueKind ConditionValue) override
 
void Elif (clang::SourceLocation Loc, clang::SourceRange ConditionRange, ConditionValueKind ConditionValue, clang::SourceLocation IfLoc) override
 
void Ifdef (clang::SourceLocation Loc, const clang::Token &MacroNameTok, const clang::MacroDefinition &MD) override
 
void Ifndef (clang::SourceLocation Loc, const clang::Token &MacroNameTok, const clang::MacroDefinition &MD) override
 
void Else (clang::SourceLocation Loc, clang::SourceLocation IfLoc) override
 
void Endif (clang::SourceLocation Loc, clang::SourceLocation IfLoc) override
 
void beginCallback (const char *Name)
 Start a new callback. More...
 
void append (const char *Str)
 Append a string to the top trace item. More...
 
void appendArgument (const char *Name, bool Value)
 Append a bool argument to the top trace item. More...
 
void appendArgument (const char *Name, int Value)
 Append an int argument to the top trace item. More...
 
void appendArgument (const char *Name, const char *Value)
 Append a string argument to the top trace item. More...
 
void appendArgument (const char *Name, llvm::StringRef Value)
 Append a string reference object argument to the top trace item. More...
 
void appendArgument (const char *Name, const std::string &Value)
 Append a string object argument to the top trace item. More...
 
void appendArgument (const char *Name, const clang::Token &Value)
 Append a token argument to the top trace item. More...
 
void appendArgument (const char *Name, int Value, const char *const Strings[])
 Append an enum argument to the top trace item. More...
 
void appendArgument (const char *Name, clang::FileID Value)
 Append a FileID argument to the top trace item. More...
 
void appendArgument (const char *Name, const clang::FileEntry *Value)
 Append a FileEntry argument to the top trace item. More...
 
void appendArgument (const char *Name, clang::SourceLocation Value)
 Append a SourceLocation argument to the top trace item. More...
 
void appendArgument (const char *Name, clang::SourceRange Value)
 Append a SourceRange argument to the top trace item. More...
 
void appendArgument (const char *Name, clang::CharSourceRange Value)
 Append a CharSourceRange argument to the top trace item. More...
 
void appendArgument (const char *Name, clang::ModuleIdPath Value)
 Append a ModuleIdPath argument to the top trace item. More...
 
void appendArgument (const char *Name, const clang::IdentifierInfo *Value)
 Append an IdentifierInfo argument to the top trace item. More...
 
void appendArgument (const char *Name, const clang::MacroDirective *Value)
 Append a MacroDirective argument to the top trace item. More...
 
void appendArgument (const char *Name, const clang::MacroDefinition &Value)
 Append a MacroDefinition argument to the top trace item. More...
 
void appendArgument (const char *Name, const clang::MacroArgs *Value)
 Append a MacroArgs argument to the top trace item. More...
 
void appendArgument (const char *Name, const clang::Module *Value)
 Append a Module argument to the top trace item. More...
 
void appendQuotedArgument (const char *Name, const std::string &Value)
 Append a double-quoted argument to the top trace item. More...
 
void appendFilePathArgument (const char *Name, llvm::StringRef Value)
 Append a double-quoted file path argument to the top trace item. More...
 
llvm::StringRef getSourceString (clang::CharSourceRange Range)
 Get the raw source string of the range. More...
 

Public Attributes

std::vector< CallbackCall > & CallbackCalls
 Callback trace information. More...
 
llvm::SmallSet< std::string, 4 > & Ignore
 Names of callbacks to ignore. More...
 
bool DisableTrace
 Inhibit trace while this is set. More...
 
clang::Preprocessor & PP
 

Detailed Description

This class overrides the PPCallbacks class for tracking preprocessor activity by means of its callback functions.

This object is given a vector for storing the trace information, built up of CallbackCall and subordinate Argument objects for representing the callback calls and their arguments. It's a reference so the vector can exist beyond the lifetime of this object, because it's deleted by the preprocessor automatically in its destructor.

This class supports a mechanism for inhibiting trace output for specific callbacks by name, for the purpose of eliminating output for callbacks of no interest that might clutter the output.

Following the constructor and destructor function declarations, the overidden callback functions are defined. The remaining functions are helpers for recording the trace data, to reduce the coupling between it and the recorded data structure.

Definition at line 74 of file PPCallbacksTracker.h.

Constructor & Destructor Documentation

◆ PPCallbacksTracker()

PPCallbacksTracker::PPCallbacksTracker ( llvm::SmallSet< std::string, 4 > &  Ignore,
std::vector< CallbackCall > &  CallbackCalls,
clang::Preprocessor &  PP 
)

Note that all of the arguments are references, and owned by the caller.

Parameters
Ignore- Set of names of callbacks to ignore.
CallbackCalls- Trace buffer.
PP- The preprocessor. Needed for getting some argument strings.

Definition at line 92 of file PPCallbacksTracker.cpp.

◆ ~PPCallbacksTracker()

PPCallbacksTracker::~PPCallbacksTracker ( )
override

Definition at line 97 of file PPCallbacksTracker.cpp.

Member Function Documentation

◆ append()

void PPCallbacksTracker::append ( const char *  Str)

Append a string to the top trace item.

◆ appendArgument() [1/18]

void PPCallbacksTracker::appendArgument ( const char *  Name,
bool  Value 
)

◆ appendArgument() [2/18]

void PPCallbacksTracker::appendArgument ( const char *  Name,
int  Value 
)

Append an int argument to the top trace item.

Definition at line 425 of file PPCallbacksTracker.cpp.

References appendArgument().

◆ appendArgument() [3/18]

void PPCallbacksTracker::appendArgument ( const char *  Name,
const char *  Value 
)

Append a string argument to the top trace item.

Definition at line 433 of file PPCallbacksTracker.cpp.

References CallbackCalls, and DisableTrace.

◆ appendArgument() [4/18]

void PPCallbacksTracker::appendArgument ( const char *  Name,
llvm::StringRef  Value 
)

Append a string reference object argument to the top trace item.

Definition at line 440 of file PPCallbacksTracker.cpp.

References appendArgument().

◆ appendArgument() [5/18]

void PPCallbacksTracker::appendArgument ( const char *  Name,
const std::string &  Value 
)

Append a string object argument to the top trace item.

Definition at line 446 of file PPCallbacksTracker.cpp.

References appendArgument().

◆ appendArgument() [6/18]

void PPCallbacksTracker::appendArgument ( const char *  Name,
const clang::Token &  Value 
)

Append a token argument to the top trace item.

Definition at line 452 of file PPCallbacksTracker.cpp.

References appendArgument(), and PP.

◆ appendArgument() [7/18]

void PPCallbacksTracker::appendArgument ( const char *  Name,
int  Value,
const char *const  Strings[] 
)

Append an enum argument to the top trace item.

Definition at line 458 of file PPCallbacksTracker.cpp.

◆ appendArgument() [8/18]

void PPCallbacksTracker::appendArgument ( const char *  Name,
clang::FileID  Value 
)

Append a FileID argument to the top trace item.

Definition at line 464 of file PPCallbacksTracker.cpp.

References appendArgument(), appendFilePathArgument(), and PP.

◆ appendArgument() [9/18]

void PPCallbacksTracker::appendArgument ( const char *  Name,
const clang::FileEntry *  Value 
)

Append a FileEntry argument to the top trace item.

Definition at line 479 of file PPCallbacksTracker.cpp.

References appendArgument(), and appendFilePathArgument().

◆ appendArgument() [10/18]

void PPCallbacksTracker::appendArgument ( const char *  Name,
clang::SourceLocation  Value 
)

Append a SourceLocation argument to the top trace item.

Definition at line 489 of file PPCallbacksTracker.cpp.

References appendArgument(), getSourceLocationString(), and PP.

◆ appendArgument() [11/18]

void PPCallbacksTracker::appendArgument ( const char *  Name,
clang::SourceRange  Value 
)

Append a SourceRange argument to the top trace item.

Definition at line 499 of file PPCallbacksTracker.cpp.

References appendArgument(), DisableTrace, getSourceLocationString(), and PP.

◆ appendArgument() [12/18]

void PPCallbacksTracker::appendArgument ( const char *  Name,
clang::CharSourceRange  Value 
)

Append a CharSourceRange argument to the top trace item.

Definition at line 515 of file PPCallbacksTracker.cpp.

References appendArgument(), and getSourceString().

◆ appendArgument() [13/18]

void PPCallbacksTracker::appendArgument ( const char *  Name,
clang::ModuleIdPath  Value 
)

Append a ModuleIdPath argument to the top trace item.

Definition at line 525 of file PPCallbacksTracker.cpp.

References appendArgument(), DisableTrace, getSourceLocationString(), and PP.

◆ appendArgument() [14/18]

void PPCallbacksTracker::appendArgument ( const char *  Name,
const clang::IdentifierInfo *  Value 
)

Append an IdentifierInfo argument to the top trace item.

Definition at line 544 of file PPCallbacksTracker.cpp.

References appendArgument().

◆ appendArgument() [15/18]

void PPCallbacksTracker::appendArgument ( const char *  Name,
const clang::MacroDirective *  Value 
)

Append a MacroDirective argument to the top trace item.

Definition at line 554 of file PPCallbacksTracker.cpp.

References appendArgument(), and MacroDirectiveKindStrings.

◆ appendArgument() [16/18]

void PPCallbacksTracker::appendArgument ( const char *  Name,
const clang::MacroDefinition &  Value 
)

Append a MacroDefinition argument to the top trace item.

Definition at line 564 of file PPCallbacksTracker.cpp.

References appendArgument().

◆ appendArgument() [17/18]

void PPCallbacksTracker::appendArgument ( const char *  Name,
const clang::MacroArgs *  Value 
)

Append a MacroArgs argument to the top trace item.

Definition at line 583 of file PPCallbacksTracker.cpp.

References appendArgument(), and PP.

◆ appendArgument() [18/18]

void PPCallbacksTracker::appendArgument ( const char *  Name,
const clang::Module *  Value 
)

Append a Module argument to the top trace item.

Definition at line 621 of file PPCallbacksTracker.cpp.

References appendArgument().

◆ appendFilePathArgument()

void PPCallbacksTracker::appendFilePathArgument ( const char *  Name,
llvm::StringRef  Value 
)

Append a double-quoted file path argument to the top trace item.

Definition at line 640 of file PPCallbacksTracker.cpp.

References appendQuotedArgument(), and Path.

Referenced by appendArgument(), FileNotFound(), and InclusionDirective().

◆ appendQuotedArgument()

void PPCallbacksTracker::appendQuotedArgument ( const char *  Name,
const std::string &  Value 
)

Append a double-quoted argument to the top trace item.

Definition at line 631 of file PPCallbacksTracker.cpp.

References appendArgument().

Referenced by appendFilePathArgument().

◆ beginCallback()

void PPCallbacksTracker::beginCallback ( const char *  Name)

◆ Defined()

void PPCallbacksTracker::Defined ( const clang::Token &  MacroNameTok,
const clang::MacroDefinition &  MD,
clang::SourceRange  Range 
)
override

Definition at line 335 of file PPCallbacksTracker.cpp.

References appendArgument(), and beginCallback().

◆ Elif()

void PPCallbacksTracker::Elif ( clang::SourceLocation  Loc,
clang::SourceRange  ConditionRange,
ConditionValueKind  ConditionValue,
clang::SourceLocation  IfLoc 
)
override

◆ Else()

void PPCallbacksTracker::Else ( clang::SourceLocation  Loc,
clang::SourceLocation  IfLoc 
)
override

Definition at line 394 of file PPCallbacksTracker.cpp.

References appendArgument(), and beginCallback().

◆ Endif()

void PPCallbacksTracker::Endif ( clang::SourceLocation  Loc,
clang::SourceLocation  IfLoc 
)
override

Definition at line 402 of file PPCallbacksTracker.cpp.

References appendArgument(), and beginCallback().

◆ EndOfMainFile()

void PPCallbacksTracker::EndOfMainFile ( )
override

Definition at line 167 of file PPCallbacksTracker.cpp.

References beginCallback().

◆ FileChanged()

void PPCallbacksTracker::FileChanged ( clang::SourceLocation  Loc,
clang::PPCallbacks::FileChangeReason  Reason,
clang::SrcMgr::CharacteristicKind  FileType,
clang::FileID  PrevFID = clang::FileID() 
)
override

◆ FileNotFound()

bool PPCallbacksTracker::FileNotFound ( llvm::StringRef  FileName,
llvm::SmallVectorImpl< char > &  RecoveryPath 
)
override

Definition at line 127 of file PPCallbacksTracker.cpp.

References appendFilePathArgument(), and beginCallback().

◆ FileSkipped()

void PPCallbacksTracker::FileSkipped ( const clang::FileEntry &  SkippedFile,
const clang::Token &  FilenameTok,
clang::SrcMgr::CharacteristicKind  FileType 
)
override

◆ getSourceString()

llvm::StringRef PPCallbacksTracker::getSourceString ( clang::CharSourceRange  Range)

Get the raw source string of the range.

Definition at line 650 of file PPCallbacksTracker.cpp.

References PP.

Referenced by appendArgument().

◆ Ident()

void PPCallbacksTracker::Ident ( clang::SourceLocation  Loc,
llvm::StringRef  str 
)
override

Definition at line 170 of file PPCallbacksTracker.cpp.

References appendArgument(), and beginCallback().

◆ If()

void PPCallbacksTracker::If ( clang::SourceLocation  Loc,
clang::SourceRange  ConditionRange,
ConditionValueKind  ConditionValue 
)
override

◆ Ifdef()

void PPCallbacksTracker::Ifdef ( clang::SourceLocation  Loc,
const clang::Token &  MacroNameTok,
const clang::MacroDefinition &  MD 
)
override

Definition at line 374 of file PPCallbacksTracker.cpp.

References appendArgument(), and beginCallback().

◆ Ifndef()

void PPCallbacksTracker::Ifndef ( clang::SourceLocation  Loc,
const clang::Token &  MacroNameTok,
const clang::MacroDefinition &  MD 
)
override

Definition at line 384 of file PPCallbacksTracker.cpp.

References appendArgument(), and beginCallback().

◆ InclusionDirective()

void PPCallbacksTracker::InclusionDirective ( clang::SourceLocation  HashLoc,
const clang::Token &  IncludeTok,
llvm::StringRef  FileName,
bool  IsAngled,
clang::CharSourceRange  FilenameRange,
const clang::FileEntry *  File,
llvm::StringRef  SearchPath,
llvm::StringRef  RelativePath,
const clang::Module *  Imported 
)
override

◆ MacroDefined()

void PPCallbacksTracker::MacroDefined ( const clang::Token &  MacroNameTok,
const clang::MacroDirective *  MD 
)
override

Definition at line 317 of file PPCallbacksTracker.cpp.

References appendArgument(), and beginCallback().

◆ MacroExpands()

void PPCallbacksTracker::MacroExpands ( const clang::Token &  MacroNameTok,
const clang::MacroDefinition &  MD,
clang::SourceRange  Range,
const clang::MacroArgs *  Args 
)
override

Definition at line 304 of file PPCallbacksTracker.cpp.

References appendArgument(), and beginCallback().

◆ MacroUndefined()

void PPCallbacksTracker::MacroUndefined ( const clang::Token &  MacroNameTok,
const clang::MacroDefinition &  MD,
const clang::MacroDirective *  Undef 
)
override

Definition at line 325 of file PPCallbacksTracker.cpp.

References appendArgument(), and beginCallback().

◆ moduleImport()

void PPCallbacksTracker::moduleImport ( clang::SourceLocation  ImportLoc,
clang::ModuleIdPath  Path,
const clang::Module *  Imported 
)
override

Definition at line 156 of file PPCallbacksTracker.cpp.

References appendArgument(), and beginCallback().

◆ PragmaComment()

void PPCallbacksTracker::PragmaComment ( clang::SourceLocation  Loc,
const clang::IdentifierInfo *  Kind,
llvm::StringRef  Str 
)
override

Definition at line 186 of file PPCallbacksTracker.cpp.

References appendArgument(), and beginCallback().

◆ PragmaDebug()

void PPCallbacksTracker::PragmaDebug ( clang::SourceLocation  Loc,
llvm::StringRef  DebugType 
)
override

Definition at line 207 of file PPCallbacksTracker.cpp.

References appendArgument(), and beginCallback().

◆ PragmaDetectMismatch()

void PPCallbacksTracker::PragmaDetectMismatch ( clang::SourceLocation  Loc,
llvm::StringRef  Name,
llvm::StringRef  Value 
)
override

Definition at line 197 of file PPCallbacksTracker.cpp.

References appendArgument(), and beginCallback().

◆ PragmaDiagnostic()

void PPCallbacksTracker::PragmaDiagnostic ( clang::SourceLocation  Loc,
llvm::StringRef  Namespace,
clang::diag::Severity  mapping,
llvm::StringRef  Str 
)
override

Definition at line 244 of file PPCallbacksTracker.cpp.

References appendArgument(), beginCallback(), and MappingStrings.

◆ PragmaDiagnosticPop()

void PPCallbacksTracker::PragmaDiagnosticPop ( clang::SourceLocation  Loc,
llvm::StringRef  Namespace 
)
override

Definition at line 236 of file PPCallbacksTracker.cpp.

References appendArgument(), and beginCallback().

◆ PragmaDiagnosticPush()

void PPCallbacksTracker::PragmaDiagnosticPush ( clang::SourceLocation  Loc,
llvm::StringRef  Namespace 
)
override

Definition at line 227 of file PPCallbacksTracker.cpp.

References appendArgument(), and beginCallback().

◆ PragmaDirective()

void PPCallbacksTracker::PragmaDirective ( clang::SourceLocation  Loc,
clang::PragmaIntroducerKind  Introducer 
)
override

◆ PragmaMessage()

void PPCallbacksTracker::PragmaMessage ( clang::SourceLocation  Loc,
llvm::StringRef  Namespace,
clang::PPCallbacks::PragmaMessageKind  Kind,
llvm::StringRef  Str 
)
override

◆ PragmaOpenCLExtension()

void PPCallbacksTracker::PragmaOpenCLExtension ( clang::SourceLocation  NameLoc,
const clang::IdentifierInfo *  Name,
clang::SourceLocation  StateLoc,
unsigned  State 
)
override

Definition at line 257 of file PPCallbacksTracker.cpp.

References appendArgument(), and beginCallback().

◆ PragmaWarning()

void PPCallbacksTracker::PragmaWarning ( clang::SourceLocation  Loc,
llvm::StringRef  WarningSpec,
llvm::ArrayRef< int >  Ids 
)
override

Definition at line 268 of file PPCallbacksTracker.cpp.

References appendArgument(), and beginCallback().

◆ PragmaWarningPop()

void PPCallbacksTracker::PragmaWarningPop ( clang::SourceLocation  Loc)
override

Definition at line 296 of file PPCallbacksTracker.cpp.

References appendArgument(), and beginCallback().

◆ PragmaWarningPush()

void PPCallbacksTracker::PragmaWarningPush ( clang::SourceLocation  Loc,
int  Level 
)
override

Definition at line 288 of file PPCallbacksTracker.cpp.

References appendArgument(), and beginCallback().

◆ SourceRangeSkipped()

void PPCallbacksTracker::SourceRangeSkipped ( clang::SourceRange  Range,
clang::SourceLocation  EndifLoc 
)
override

Definition at line 345 of file PPCallbacksTracker.cpp.

References appendArgument(), and beginCallback().

Member Data Documentation

◆ CallbackCalls

std::vector<CallbackCall>& PPCallbacksTracker::CallbackCalls

Callback trace information.

We use a reference so the trace will be preserved for the caller after this object is destructed.

Definition at line 237 of file PPCallbacksTracker.h.

Referenced by appendArgument(), and beginCallback().

◆ DisableTrace

bool PPCallbacksTracker::DisableTrace

Inhibit trace while this is set.

Definition at line 243 of file PPCallbacksTracker.h.

Referenced by appendArgument(), and beginCallback().

◆ Ignore

llvm::SmallSet<std::string, 4>& PPCallbacksTracker::Ignore

Names of callbacks to ignore.

Definition at line 240 of file PPCallbacksTracker.h.

Referenced by beginCallback().

◆ PP

clang::Preprocessor& PPCallbacksTracker::PP

Definition at line 245 of file PPCallbacksTracker.h.

Referenced by appendArgument(), and getSourceString().


The documentation for this class was generated from the following files: