#include "clang/Basic/CharInfo.h"
#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/SourceManager.h"
#include "clang/Frontend/PreprocessorOutputOptions.h"
#include "clang/Frontend/Utils.h"
#include "clang/Lex/MacroInfo.h"
#include "clang/Lex/PPCallbacks.h"
#include "clang/Lex/Pragma.h"
#include "clang/Lex/Preprocessor.h"
#include "clang/Lex/TokenConcatenation.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/raw_ostream.h"
#include <cstdio>
usingnamespaceclang;
static void PrintMacroDefinition(const IdentifierInfo &II, const MacroInfo &MI,
Preprocessor &PP, raw_ostream *OS) { … }
namespace {
class PrintPPOutputPPCallbacks : public PPCallbacks { … };
}
void PrintPPOutputPPCallbacks::WriteLineInfo(unsigned LineNo,
const char *Extra,
unsigned ExtraLen) { … }
bool PrintPPOutputPPCallbacks::MoveToLine(unsigned LineNo,
bool RequireStartOfLine) { … }
void PrintPPOutputPPCallbacks::startNewLineIfNeeded() { … }
void PrintPPOutputPPCallbacks::FileChanged(SourceLocation Loc,
FileChangeReason Reason,
SrcMgr::CharacteristicKind NewFileType,
FileID PrevFID) { … }
void PrintPPOutputPPCallbacks::EmbedDirective(
SourceLocation HashLoc, StringRef FileName, bool IsAngled,
OptionalFileEntryRef File, const LexEmbedParametersResult &Params) { … }
void PrintPPOutputPPCallbacks::InclusionDirective(
SourceLocation HashLoc, const Token &IncludeTok, StringRef FileName,
bool IsAngled, CharSourceRange FilenameRange, OptionalFileEntryRef File,
StringRef SearchPath, StringRef RelativePath, const Module *SuggestedModule,
bool ModuleImported, SrcMgr::CharacteristicKind FileType) { … }
void PrintPPOutputPPCallbacks::BeginModule(const Module *M) { … }
void PrintPPOutputPPCallbacks::EndModule(const Module *M) { … }
void PrintPPOutputPPCallbacks::Ident(SourceLocation Loc, StringRef S) { … }
void PrintPPOutputPPCallbacks::MacroDefined(const Token &MacroNameTok,
const MacroDirective *MD) { … }
void PrintPPOutputPPCallbacks::MacroUndefined(const Token &MacroNameTok,
const MacroDefinition &MD,
const MacroDirective *Undef) { … }
static void outputPrintable(raw_ostream *OS, StringRef Str) { … }
void PrintPPOutputPPCallbacks::PragmaMessage(SourceLocation Loc,
StringRef Namespace,
PragmaMessageKind Kind,
StringRef Str) { … }
void PrintPPOutputPPCallbacks::PragmaDebug(SourceLocation Loc,
StringRef DebugType) { … }
void PrintPPOutputPPCallbacks::
PragmaDiagnosticPush(SourceLocation Loc, StringRef Namespace) { … }
void PrintPPOutputPPCallbacks::
PragmaDiagnosticPop(SourceLocation Loc, StringRef Namespace) { … }
void PrintPPOutputPPCallbacks::PragmaDiagnostic(SourceLocation Loc,
StringRef Namespace,
diag::Severity Map,
StringRef Str) { … }
void PrintPPOutputPPCallbacks::PragmaWarning(SourceLocation Loc,
PragmaWarningSpecifier WarningSpec,
ArrayRef<int> Ids) { … }
void PrintPPOutputPPCallbacks::PragmaWarningPush(SourceLocation Loc,
int Level) { … }
void PrintPPOutputPPCallbacks::PragmaWarningPop(SourceLocation Loc) { … }
void PrintPPOutputPPCallbacks::PragmaExecCharsetPush(SourceLocation Loc,
StringRef Str) { … }
void PrintPPOutputPPCallbacks::PragmaExecCharsetPop(SourceLocation Loc) { … }
void PrintPPOutputPPCallbacks::
PragmaAssumeNonNullBegin(SourceLocation Loc) { … }
void PrintPPOutputPPCallbacks::
PragmaAssumeNonNullEnd(SourceLocation Loc) { … }
void PrintPPOutputPPCallbacks::HandleWhitespaceBeforeTok(const Token &Tok,
bool RequireSpace,
bool RequireSameLine) { … }
void PrintPPOutputPPCallbacks::HandleNewlinesInToken(const char *TokStr,
unsigned Len) { … }
namespace {
struct UnknownPragmaHandler : public PragmaHandler { … };
}
static void PrintPreprocessedTokens(Preprocessor &PP, Token &Tok,
PrintPPOutputPPCallbacks *Callbacks) { … }
id_macro_pair;
static int MacroIDCompare(const id_macro_pair *LHS, const id_macro_pair *RHS) { … }
static void DoPrintMacros(Preprocessor &PP, raw_ostream *OS) { … }
void clang::DoPrintPreprocessedInput(Preprocessor &PP, raw_ostream *OS,
const PreprocessorOutputOptions &Opts) { … }