llvm/clang-tools-extra/pp-trace/PPCallbacksTracker.cpp

//===--- PPCallbacksTracker.cpp - Preprocessor tracker -*--*---------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
///
/// \file
/// Implementations for preprocessor tracking.
///
/// See the header for details.
///
//===----------------------------------------------------------------------===//

#include "PPCallbacksTracker.h"
#include "clang/Basic/FileManager.h"
#include "clang/Lex/MacroArgs.h"
#include "llvm/Support/raw_ostream.h"

namespace clang {
namespace pp_trace {

// Get a "file:line:column" source location string.
static std::string getSourceLocationString(Preprocessor &PP,
                                           SourceLocation Loc) {}

// Enum string tables.

// FileChangeReason strings.
static const char *const FileChangeReasonStrings[] =;

// CharacteristicKind strings.
static const char *const CharacteristicKindStrings[] =;

// MacroDirective::Kind strings.
static const char *const MacroDirectiveKindStrings[] =;

// PragmaIntroducerKind strings.
static const char *const PragmaIntroducerKindStrings[] =;

// PragmaMessageKind strings.
static const char *const PragmaMessageKindStrings[] =;

// PragmaWarningSpecifier strings.
static const char *const PragmaWarningSpecifierStrings[] =;

// ConditionValueKind strings.
static const char *const ConditionValueKindStrings[] =;

// Mapping strings.
static const char *const MappingStrings[] =;

// PPCallbacksTracker functions.

PPCallbacksTracker::PPCallbacksTracker(const FilterType &Filters,
                                       std::vector<CallbackCall> &CallbackCalls,
                                       Preprocessor &PP)
    :{}

PPCallbacksTracker::~PPCallbacksTracker() {}

// Callback functions.

// Callback invoked whenever a source file is entered or exited.
void PPCallbacksTracker::FileChanged(SourceLocation Loc,
                                     PPCallbacks::FileChangeReason Reason,
                                     SrcMgr::CharacteristicKind FileType,
                                     FileID PrevFID) {}

// Callback invoked whenever a source file is skipped as the result
// of header guard optimization.
void PPCallbacksTracker::FileSkipped(const FileEntryRef &SkippedFile,
                                     const Token &FilenameTok,
                                     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.
void PPCallbacksTracker::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) {}

// Callback invoked whenever there was an explicit module-import
// syntax.
void PPCallbacksTracker::moduleImport(SourceLocation ImportLoc,
                                      ModuleIdPath Path,
                                      const Module *Imported) {}

// Callback invoked when the end of the main file is reached.
// No subsequent callbacks will be made.
void PPCallbacksTracker::EndOfMainFile() {}

// Callback invoked when a #ident or #sccs directive is read.
void PPCallbacksTracker::Ident(SourceLocation Loc, llvm::StringRef Str) {}

// Callback invoked when start reading any pragma directive.
void PPCallbacksTracker::PragmaDirective(SourceLocation Loc,
                                         PragmaIntroducerKind Introducer) {}

// Callback invoked when a #pragma comment directive is read.
void PPCallbacksTracker::PragmaComment(SourceLocation Loc,
                                       const IdentifierInfo *Kind,
                                       llvm::StringRef Str) {}

// Callback invoked when a #pragma detect_mismatch directive is
// read.
void PPCallbacksTracker::PragmaDetectMismatch(SourceLocation Loc,
                                              llvm::StringRef Name,
                                              llvm::StringRef Value) {}

// Callback invoked when a #pragma clang __debug directive is read.
void PPCallbacksTracker::PragmaDebug(SourceLocation Loc,
                                     llvm::StringRef DebugType) {}

// Callback invoked when a #pragma message directive is read.
void PPCallbacksTracker::PragmaMessage(SourceLocation Loc,
                                       llvm::StringRef Namespace,
                                       PPCallbacks::PragmaMessageKind Kind,
                                       llvm::StringRef Str) {}

// Callback invoked when a #pragma gcc diagnostic push directive
// is read.
void PPCallbacksTracker::PragmaDiagnosticPush(SourceLocation Loc,
                                              llvm::StringRef Namespace) {}

// Callback invoked when a #pragma gcc diagnostic pop directive
// is read.
void PPCallbacksTracker::PragmaDiagnosticPop(SourceLocation Loc,
                                             llvm::StringRef Namespace) {}

// Callback invoked when a #pragma gcc diagnostic directive is read.
void PPCallbacksTracker::PragmaDiagnostic(SourceLocation Loc,
                                          llvm::StringRef Namespace,
                                          diag::Severity Mapping,
                                          llvm::StringRef Str) {}

// Called when an OpenCL extension is either disabled or
// enabled with a pragma.
void PPCallbacksTracker::PragmaOpenCLExtension(SourceLocation NameLoc,
                                               const IdentifierInfo *Name,
                                               SourceLocation StateLoc,
                                               unsigned State) {}

// Callback invoked when a #pragma warning directive is read.
void PPCallbacksTracker::PragmaWarning(SourceLocation Loc,
                                       PragmaWarningSpecifier WarningSpec,
                                       llvm::ArrayRef<int> Ids) {}

// Callback invoked when a #pragma warning(push) directive is read.
void PPCallbacksTracker::PragmaWarningPush(SourceLocation Loc, int Level) {}

// Callback invoked when a #pragma warning(pop) directive is read.
void PPCallbacksTracker::PragmaWarningPop(SourceLocation Loc) {}

// Callback invoked when a #pragma execution_character_set(push) directive
// is read.
void PPCallbacksTracker::PragmaExecCharsetPush(SourceLocation Loc,
                                               StringRef Str) {}

// Callback invoked when a #pragma execution_character_set(pop) directive
// is read.
void PPCallbacksTracker::PragmaExecCharsetPop(SourceLocation Loc) {}

// Called by Preprocessor::HandleMacroExpandedIdentifier when a
// macro invocation is found.
void PPCallbacksTracker::MacroExpands(const Token &MacroNameTok,
                                      const MacroDefinition &MacroDefinition,
                                      SourceRange Range,
                                      const MacroArgs *Args) {}

// Hook called whenever a macro definition is seen.
void PPCallbacksTracker::MacroDefined(const Token &MacroNameTok,
                                      const MacroDirective *MacroDirective) {}

// Hook called whenever a macro #undef is seen.
void PPCallbacksTracker::MacroUndefined(const Token &MacroNameTok,
                                        const MacroDefinition &MacroDefinition,
                                        const MacroDirective *Undef) {}

// Hook called whenever the 'defined' operator is seen.
void PPCallbacksTracker::Defined(const Token &MacroNameTok,
                                 const MacroDefinition &MacroDefinition,
                                 SourceRange Range) {}

// Hook called when a source range is skipped.
void PPCallbacksTracker::SourceRangeSkipped(SourceRange Range,
                                            SourceLocation EndifLoc) {}

// Hook called whenever an #if is seen.
void PPCallbacksTracker::If(SourceLocation Loc, SourceRange ConditionRange,
                            ConditionValueKind ConditionValue) {}

// Hook called whenever an #elif is seen.
void PPCallbacksTracker::Elif(SourceLocation Loc, SourceRange ConditionRange,
                              ConditionValueKind ConditionValue,
                              SourceLocation IfLoc) {}

// Hook called whenever an #ifdef is seen.
void PPCallbacksTracker::Ifdef(SourceLocation Loc, const Token &MacroNameTok,
                               const MacroDefinition &MacroDefinition) {}

// Hook called whenever an #ifndef is seen.
void PPCallbacksTracker::Ifndef(SourceLocation Loc, const Token &MacroNameTok,
                                const MacroDefinition &MacroDefinition) {}

// Hook called whenever an #else is seen.
void PPCallbacksTracker::Else(SourceLocation Loc, SourceLocation IfLoc) {}

// Hook called whenever an #endif is seen.
void PPCallbacksTracker::Endif(SourceLocation Loc, SourceLocation IfLoc) {}

// Helper functions.

// Start a new callback.
void PPCallbacksTracker::beginCallback(const char *Name) {}

// Append a bool argument to the top trace item.
void PPCallbacksTracker::appendArgument(const char *Name, bool Value) {}

// Append an int argument to the top trace item.
void PPCallbacksTracker::appendArgument(const char *Name, int Value) {}

// Append a string argument to the top trace item.
void PPCallbacksTracker::appendArgument(const char *Name, const char *Value) {}

// Append a string object argument to the top trace item.
void PPCallbacksTracker::appendArgument(const char *Name,
                                        llvm::StringRef Value) {}

// Append a string object argument to the top trace item.
void PPCallbacksTracker::appendArgument(const char *Name,
                                        const std::string &Value) {}

// Append a token argument to the top trace item.
void PPCallbacksTracker::appendArgument(const char *Name, const Token &Value) {}

// Append an enum argument to the top trace item.
void PPCallbacksTracker::appendArgument(const char *Name, int Value,
                                        const char *const Strings[]) {}

// Append a FileID argument to the top trace item.
void PPCallbacksTracker::appendArgument(const char *Name, FileID Value) {}

// Append a FileEntry argument to the top trace item.
void PPCallbacksTracker::appendArgument(const char *Name,
                                        OptionalFileEntryRef Value) {}

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

// Append a SourceLocation argument to the top trace item.
void PPCallbacksTracker::appendArgument(const char *Name,
                                        SourceLocation Value) {}

// Append a SourceRange argument to the top trace item.
void PPCallbacksTracker::appendArgument(const char *Name, SourceRange Value) {}

// Append a CharSourceRange argument to the top trace item.
void PPCallbacksTracker::appendArgument(const char *Name,
                                        CharSourceRange Value) {}

// Append a SourceLocation argument to the top trace item.
void PPCallbacksTracker::appendArgument(const char *Name, ModuleIdPath Value) {}

// Append an IdentifierInfo argument to the top trace item.
void PPCallbacksTracker::appendArgument(const char *Name,
                                        const IdentifierInfo *Value) {}

// Append a MacroDirective argument to the top trace item.
void PPCallbacksTracker::appendArgument(const char *Name,
                                        const MacroDirective *Value) {}

// Append a MacroDefinition argument to the top trace item.
void PPCallbacksTracker::appendArgument(const char *Name,
                                        const MacroDefinition &Value) {}

// Append a MacroArgs argument to the top trace item.
void PPCallbacksTracker::appendArgument(const char *Name,
                                        const MacroArgs *Value) {}

// Append a Module argument to the top trace item.
void PPCallbacksTracker::appendArgument(const char *Name, const Module *Value) {}

// Append a double-quoted argument to the top trace item.
void PPCallbacksTracker::appendQuotedArgument(const char *Name,
                                              const std::string &Value) {}

// Append a double-quoted file path argument to the top trace item.
void PPCallbacksTracker::appendFilePathArgument(const char *Name,
                                                llvm::StringRef Value) {}

// Get the raw source string of the range.
llvm::StringRef PPCallbacksTracker::getSourceString(CharSourceRange Range) {}

} // namespace pp_trace
} // namespace clang