//===--- PPCallbacksTracker.h - Preprocessor tracking -----------*- C++ -*-===// // // 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 /// Classes and definitions for preprocessor tracking. /// /// The core definition is the PPCallbacksTracker class, derived from Clang's /// PPCallbacks class from the Lex library, which overrides all the callbacks /// and collects information about each callback call, saving it in a /// data structure built up of CallbackCall and Argument objects, which /// record the preprocessor callback name and arguments in high-level string /// form for later inspection. /// //===----------------------------------------------------------------------===// #ifndef PPTRACE_PPCALLBACKSTRACKER_H #define PPTRACE_PPCALLBACKSTRACKER_H #include "clang/Lex/PPCallbacks.h" #include "clang/Lex/Preprocessor.h" #include "clang/Basic/SourceManager.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/SmallSet.h" #include "llvm/ADT/StringMap.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/GlobPattern.h" #include <string> #include <vector> namespace clang { namespace pp_trace { // This struct represents one callback function argument by name and value. struct Argument { … }; /// This class represents one callback call by name and an array /// of arguments. class CallbackCall { … }; FilterType; /// 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 /// overridden 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. class PPCallbacksTracker : public PPCallbacks { … }; } // namespace pp_trace } // namespace clang #endif // PPTRACE_PPCALLBACKSTRACKER_H