;
36*OS <<
"#define "<< II.
getName();
42 for(; AI+1 !=
E; ++AI) {
43*OS << (*AI)->getName();
48 if((*AI)->getName() ==
"__VA_ARGS__")
51*OS << (*AI)->getName();
66 for(
const auto&
T: MI.
tokens()) {
67 if(
T.hasLeadingSpace())
79classPrintPPOutputPPCallbacks :
public PPCallbacks{
88 boolEmittedTokensOnThisLine;
89 boolEmittedDirectiveOnThisLine;
93 boolDisableLineMarkers;
95 boolDumpIncludeDirectives;
96 boolDumpEmbedDirectives;
97 boolUseLineDirectives;
98 boolIsFirstFileEntered;
99 boolMinimizeWhitespace;
101 boolKeepSystemIncludes;
103std::unique_ptr<llvm::raw_null_ostream> NullOS;
104 unsignedNumToksToSkip;
110PrintPPOutputPPCallbacks(
Preprocessor&pp, raw_ostream *os,
boollineMarkers,
111 booldefines,
boolDumpIncludeDirectives,
112 boolDumpEmbedDirectives,
boolUseLineDirectives,
113 boolMinimizeWhitespace,
boolDirectivesOnly,
114 boolKeepSystemIncludes)
115: PP(pp),
SM(PP.getSourceManager()), ConcatInfo(PP), OS(os),
116DisableLineMarkers(lineMarkers), DumpDefines(defines),
117DumpIncludeDirectives(DumpIncludeDirectives),
118DumpEmbedDirectives(DumpEmbedDirectives),
119UseLineDirectives(UseLineDirectives),
120MinimizeWhitespace(MinimizeWhitespace), DirectivesOnly(DirectivesOnly),
121KeepSystemIncludes(KeepSystemIncludes), OrigOS(os), NumToksToSkip(0) {
123CurFilename +=
"<uninit>";
124EmittedTokensOnThisLine =
false;
125EmittedDirectiveOnThisLine =
false;
128IsFirstFileEntered =
false;
129 if(KeepSystemIncludes)
130NullOS = std::make_unique<llvm::raw_null_ostream>();
138 boolexpandEmbedContents()
const{
return!DumpEmbedDirectives; }
140 boolisMinimizeWhitespace()
const{
returnMinimizeWhitespace; }
142 voidsetEmittedTokensOnThisLine() { EmittedTokensOnThisLine =
true; }
143 boolhasEmittedTokensOnThisLine()
const{
returnEmittedTokensOnThisLine; }
145 voidsetEmittedDirectiveOnThisLine() { EmittedDirectiveOnThisLine =
true; }
146 boolhasEmittedDirectiveOnThisLine()
const{
147 returnEmittedDirectiveOnThisLine;
155 voidstartNewLineIfNeeded();
159 FileIDPrevFID)
override;
167StringRef RelativePath,
const Module*SuggestedModule,
172PragmaMessageKind Kind, StringRef Str)
override;
194 voidHandleWhitespaceBeforeTok(
const Token&Tok,
boolRequireSpace,
195 boolRequireSameLine);
209 boolMoveToLine(
const Token&Tok,
boolRequireStartOfLine) {
211 unsignedTargetLine = PLoc.
isValid() ? PLoc.
getLine() : CurLine;
214 returnMoveToLine(TargetLine, RequireStartOfLine) || IsFirstInFile;
221 unsignedTargetLine = PLoc.
isValid() ? PLoc.
getLine() : CurLine;
222 returnMoveToLine(TargetLine, RequireStartOfLine);
224 boolMoveToLine(
unsignedLineNo,
boolRequireStartOfLine);
226 boolAvoidConcat(
const Token&PrevPrevTok,
const Token&PrevTok,
228 returnConcatInfo.
AvoidConcat(PrevPrevTok, PrevTok, Tok);
230 voidWriteLineInfo(
unsignedLineNo,
const char*Extra=
nullptr,
231 unsignedExtraLen=0);
232 boolLineMarkersAreDisabled()
const{
returnDisableLineMarkers; }
233 voidHandleNewlinesInToken(
const char*TokStr,
unsignedLen);
244 voidBeginModule(
const Module*M);
245 voidEndModule(
const Module*M);
247 unsignedGetNumToksToSkip()
const{
returnNumToksToSkip; }
248 voidResetSkipToks() { NumToksToSkip = 0; }
252voidPrintPPOutputPPCallbacks::WriteLineInfo(
unsignedLineNo,
255startNewLineIfNeeded();
258 if(UseLineDirectives) {
259*OS <<
"#line"<<
' '<< LineNo <<
' '<<
'"';
260OS->write_escaped(CurFilename);
263*OS <<
'#'<<
' '<< LineNo <<
' '<<
'"';
264OS->write_escaped(CurFilename);
268OS->write(Extra, ExtraLen);
271OS->write(
" 3", 2);
273OS->write(
" 3 4", 4);
282boolPrintPPOutputPPCallbacks::MoveToLine(
unsignedLineNo,
283 boolRequireStartOfLine) {
287 boolStartedNewLine =
false;
288 if((RequireStartOfLine && EmittedTokensOnThisLine) ||
289EmittedDirectiveOnThisLine) {
291StartedNewLine =
true;
293EmittedTokensOnThisLine =
false;
294EmittedDirectiveOnThisLine =
false;
299 if(CurLine == LineNo) {
301}
else if(MinimizeWhitespace && DisableLineMarkers) {
303}
else if(!StartedNewLine && LineNo - CurLine == 1) {
308StartedNewLine =
true;
309}
else if(!DisableLineMarkers) {
310 if(LineNo - CurLine <= 8) {
311 const char*NewLines =
"\n\n\n\n\n\n\n\n";
312OS->write(NewLines, LineNo - CurLine);
315WriteLineInfo(LineNo,
nullptr, 0);
317StartedNewLine =
true;
318}
else if(EmittedTokensOnThisLine) {
322StartedNewLine =
true;
325 if(StartedNewLine) {
326EmittedTokensOnThisLine =
false;
327EmittedDirectiveOnThisLine =
false;
331 returnStartedNewLine;
334voidPrintPPOutputPPCallbacks::startNewLineIfNeeded() {
335 if(EmittedTokensOnThisLine || EmittedDirectiveOnThisLine) {
337EmittedTokensOnThisLine =
false;
338EmittedDirectiveOnThisLine =
false;
346FileChangeReason Reason,
362MoveToLine(IncludeLoc,
false);
382 if(DisableLineMarkers) {
383 if(!MinimizeWhitespace)
384startNewLineIfNeeded();
389WriteLineInfo(CurLine);
398IsFirstFileEntered =
true;
404WriteLineInfo(CurLine,
" 1", 2);
407WriteLineInfo(CurLine,
" 2", 2);
411WriteLineInfo(CurLine);
416voidPrintPPOutputPPCallbacks::EmbedDirective(
419 if(!DumpEmbedDirectives)
432MoveToLine(HashLoc,
true);
433*OS <<
"#embed "<< (IsAngled ?
'<':
'"') <<
FileName 434<< (IsAngled ?
'>':
'"');
438 for(
const Token&
T: Toks) {
439 if(
T.hasLeadingSpace())
444 boolSkipAnnotToks =
true;
446*OS <<
" if_empty(";
453SkipAnnotToks =
false;
480*OS <<
" /* clang -E -dE */";
481setEmittedDirectiveOnThisLine();
484voidPrintPPOutputPPCallbacks::InclusionDirective(
487StringRef SearchPath, StringRef RelativePath,
const Module*SuggestedModule,
491 if(DumpIncludeDirectives || (KeepSystemIncludes &&
isSystem(
FileType))) {
492MoveToLine(HashLoc,
true);
493 conststd::string TokenText = PP.
getSpelling(IncludeTok);
494assert(!TokenText.empty());
495*OS <<
"#"<< TokenText <<
" " 496<< (IsAngled ?
'<':
'"') <<
FileName<< (IsAngled ?
'>':
'"')
498<< (DumpIncludeDirectives ?
"-dI":
"-fkeep-system-includes")
500setEmittedDirectiveOnThisLine();
504 if(ModuleImported) {
506 casetok::pp_include:
508 casetok::pp_include_next:
509MoveToLine(HashLoc,
true);
510*OS <<
"#pragma clang module import " 512<<
" /* clang -E: implicit import for " 514<< (IsAngled ?
'<':
'"') <<
FileName<< (IsAngled ?
'>':
'"')
516setEmittedDirectiveOnThisLine();
519 casetok::pp___include_macros:
528llvm_unreachable(
"unknown include directive kind");
535voidPrintPPOutputPPCallbacks::BeginModule(
const Module*M) {
536startNewLineIfNeeded();
538setEmittedDirectiveOnThisLine();
542voidPrintPPOutputPPCallbacks::EndModule(
const Module*M) {
543startNewLineIfNeeded();
545setEmittedDirectiveOnThisLine();
551MoveToLine(
Loc,
true);
553OS->write(
"#ident ", strlen(
"#ident "));
554OS->write(S.begin(), S.size());
555setEmittedTokensOnThisLine();
559voidPrintPPOutputPPCallbacks::MacroDefined(
const Token&MacroNameTok,
564 if((!DumpDefines && !DirectivesOnly) ||
570 if(DirectivesOnly && !MI->
isUsed()) {
572 if(
SM.isWrittenInBuiltinFile(DefLoc) ||
573 SM.isWrittenInCommandLineFile(DefLoc))
576MoveToLine(DefLoc,
true);
578setEmittedDirectiveOnThisLine();
581voidPrintPPOutputPPCallbacks::MacroUndefined(
const Token&MacroNameTok,
586 if(!DumpDefines && !DirectivesOnly)
591setEmittedDirectiveOnThisLine();
595 for(
unsigned charChar : Str) {
596 if(
isPrintable(Char) && Char !=
'\\'&& Char !=
'"')
600<< (char)(
'0'+ ((Char >> 6) & 7))
601<< (char)(
'0'+ ((Char >> 3) & 7))
602<< (char)(
'0'+ ((Char >> 0) & 7));
608PragmaMessageKind Kind,
610MoveToLine(
Loc,
true);
616*OS <<
"message(\"";
619*OS <<
"warning \"";
628 if(Kind == PMK_Message)
630setEmittedDirectiveOnThisLine();
634StringRef DebugType) {
635MoveToLine(
Loc,
true);
637*OS <<
"#pragma clang __debug ";
640setEmittedDirectiveOnThisLine();
643voidPrintPPOutputPPCallbacks::
645MoveToLine(
Loc,
true);
646*OS <<
"#pragma "<<
Namespace<<
" diagnostic push";
647setEmittedDirectiveOnThisLine();
650voidPrintPPOutputPPCallbacks::
652MoveToLine(
Loc,
true);
653*OS <<
"#pragma "<<
Namespace<<
" diagnostic pop";
654setEmittedDirectiveOnThisLine();
661MoveToLine(
Loc,
true);
662*OS <<
"#pragma "<<
Namespace<<
" diagnostic ";
664 casediag::Severity::Remark:
667 casediag::Severity::Warning:
670 casediag::Severity::Error:
673 casediag::Severity::Ignored:
676 casediag::Severity::Fatal:
680*OS <<
" \""<< Str <<
'"';
681setEmittedDirectiveOnThisLine();
685PragmaWarningSpecifier WarningSpec,
687MoveToLine(
Loc,
true);
689*OS <<
"#pragma warning(";
690 switch(WarningSpec) {
691 casePWS_Default: *OS <<
"default";
break;
692 casePWS_Disable: *OS <<
"disable";
break;
693 casePWS_Error: *OS <<
"error";
break;
694 casePWS_Once: *OS <<
"once";
break;
695 casePWS_Suppress: *OS <<
"suppress";
break;
696 casePWS_Level1: *OS <<
'1';
break;
697 casePWS_Level2: *OS <<
'2';
break;
698 casePWS_Level3: *OS <<
'3';
break;
699 casePWS_Level4: *OS <<
'4';
break;
706setEmittedDirectiveOnThisLine();
711MoveToLine(
Loc,
true);
712*OS <<
"#pragma warning(push";
714*OS <<
", "<<
Level;
716setEmittedDirectiveOnThisLine();
720MoveToLine(
Loc,
true);
721*OS <<
"#pragma warning(pop)";
722setEmittedDirectiveOnThisLine();
727MoveToLine(
Loc,
true);
728*OS <<
"#pragma character_execution_set(push";
732setEmittedDirectiveOnThisLine();
736MoveToLine(
Loc,
true);
737*OS <<
"#pragma character_execution_set(pop)";
738setEmittedDirectiveOnThisLine();
741voidPrintPPOutputPPCallbacks::
743MoveToLine(
Loc,
true);
744*OS <<
"#pragma clang assume_nonnull begin";
745setEmittedDirectiveOnThisLine();
748voidPrintPPOutputPPCallbacks::
750MoveToLine(
Loc,
true);
751*OS <<
"#pragma clang assume_nonnull end";
752setEmittedDirectiveOnThisLine();
755voidPrintPPOutputPPCallbacks::HandleWhitespaceBeforeTok(
const Token&Tok,
757 boolRequireSameLine) {
760 if(Tok.
is(tok::eof) ||
762!Tok.
is(tok::annot_module_begin) && !Tok.
is(tok::annot_module_end) &&
763!Tok.
is(tok::annot_repl_input_end) && !Tok.
is(tok::annot_embed)))
767 if((!RequireSameLine || EmittedDirectiveOnThisLine) &&
768MoveToLine(Tok,
EmittedDirectiveOnThisLine)) {
769 if(MinimizeWhitespace) {
771 if(Tok.
is(tok::hash))
776 unsignedColNo =
SM.getExpansionColumnNumber(Tok.
getLocation());
791 if(ColNo <= 1 && Tok.
is(tok::hash))
795 for(; ColNo > 1; --ColNo)
805 if(RequireSpace || (!MinimizeWhitespace && Tok.
hasLeadingSpace()) ||
806((EmittedTokensOnThisLine || EmittedDirectiveOnThisLine) &&
807AvoidConcat(PrevPrevTok, PrevTok, Tok)))
811PrevPrevTok = PrevTok;
815voidPrintPPOutputPPCallbacks::HandleNewlinesInToken(
const char*TokStr,
817 unsignedNumNewlines = 0;
818 for(; Len; --Len, ++TokStr) {
819 if(*TokStr !=
'\n'&&
827(TokStr[1] ==
'\n'|| TokStr[1] ==
'\r') &&
828TokStr[0] != TokStr[1]) {
834 if(NumNewlines == 0)
return;
836CurLine += NumNewlines;
843PrintPPOutputPPCallbacks *Callbacks;
846 boolShouldExpandTokens;
848UnknownPragmaHandler(
const char*prefix, PrintPPOutputPPCallbacks *callbacks,
849 boolRequireTokenExpansion)
850: Prefix(prefix), Callbacks(callbacks),
851ShouldExpandTokens(RequireTokenExpansion) {}
853 Token&PragmaTok)
override{
856Callbacks->MoveToLine(PragmaTok.
getLocation(),
true);
857Callbacks->OS->write(Prefix, strlen(Prefix));
858Callbacks->setEmittedTokensOnThisLine();
860 if(ShouldExpandTokens) {
863 autoToks = std::make_unique<Token[]>(1);
865PP.EnterTokenStream(std::move(Toks),
1,
872 boolIsFirst =
true;
873 while(PragmaTok.
isNot(tok::eod)) {
874Callbacks->HandleWhitespaceBeforeTok(PragmaTok,
IsFirst,
877std::string TokSpell = PP.
getSpelling(PragmaTok);
878Callbacks->OS->write(&TokSpell[0], TokSpell.size());
879Callbacks->setEmittedTokensOnThisLine();
881 if(ShouldExpandTokens)
886Callbacks->setEmittedDirectiveOnThisLine();
893PrintPPOutputPPCallbacks *Callbacks) {
894 boolDropComments = PP.
getLangOpts().TraditionalCPP &&
897 boolIsStartOfLine =
false;
909Callbacks->HandleWhitespaceBeforeTok(Tok,
false,
912 if(DropComments && Tok.
is(tok::comment)) {
918}
else if(Tok.
is(tok::annot_repl_input_end)) {
920}
else if(Tok.
is(tok::eod)) {
927IsStartOfLine =
true;
929}
else if(Tok.
is(tok::annot_module_include)) {
933IsStartOfLine =
true;
935}
else if(Tok.
is(tok::annot_module_begin)) {
942Callbacks->BeginModule(
945IsStartOfLine =
true;
947}
else if(Tok.
is(tok::annot_module_end)) {
948Callbacks->EndModule(
951IsStartOfLine =
true;
953}
else if(Tok.
is(tok::annot_header_unit)) {
961*Callbacks->OS <<
'"';
962Callbacks->OS->write_escaped(Name);
963*Callbacks->OS <<
'"';
964}
else if(Tok.
is(tok::annot_embed)) {
969assert(Callbacks->expandEmbedContents() &&
970 "did not expect an embed annotation");
976 boolPrintComma =
false;
977 for(
auto Iter=
Data->BinaryData.begin(), End =
Data->BinaryData.end();
980*Callbacks->OS <<
", ";
981*Callbacks->OS <<
static_cast<unsigned>(*Iter);
990*Callbacks->OS << II->getName();
994}
else if(Tok.
getLength() < std::size(Buffer)) {
995 const char*TokPtr = Buffer;
997Callbacks->OS->write(TokPtr, Len);
1004 if(Tok.
getKind() == tok::comment || Tok.
getKind() == tok::unknown)
1005Callbacks->HandleNewlinesInToken(TokPtr, Len);
1006 if(Tok.
is(tok::comment) && Len >= 2 && TokPtr[0] ==
'/'&&
1007TokPtr[1] ==
'/') {
1010Callbacks->setEmittedDirectiveOnThisLine();
1014Callbacks->OS->write(S.data(), S.size());
1018 if(Tok.
getKind() == tok::comment || Tok.
getKind() == tok::unknown)
1019Callbacks->HandleNewlinesInToken(S.data(), S.size());
1020 if(Tok.
is(tok::comment) && S.size() >= 2 && S[0] ==
'/'&& S[1] ==
'/') {
1023Callbacks->setEmittedDirectiveOnThisLine();
1026Callbacks->setEmittedTokensOnThisLine();
1027IsStartOfLine =
false;
1029 if(Tok.
is(tok::eof) || Tok.
is(tok::annot_repl_input_end))
1034 for(
unsignedI = 0,
Skip= Callbacks->GetNumToksToSkip(); I <
Skip; ++I)
1036Callbacks->ResetSkipToks();
1042 returnLHS->first->getName().compare(RHS->first->getName());
1058 auto*MD = I->second.getLatest();
1059 if(MD && MD->isDefined())
1062llvm::array_pod_sort(MacrosByID.begin(), MacrosByID.end(),
MacroIDCompare);
1064 for(
unsignedi = 0, e = MacrosByID.size(); i != e; ++i) {
1080assert(Opts.
ShowMacros&&
"Not yet implemented!");
1089PrintPPOutputPPCallbacks *Callbacks =
newPrintPPOutputPPCallbacks(
1098std::unique_ptr<UnknownPragmaHandler> MicrosoftExtHandler(
1099 newUnknownPragmaHandler(
1100 "#pragma", Callbacks,
1103std::unique_ptr<UnknownPragmaHandler> GCCHandler(
newUnknownPragmaHandler(
1104 "#pragma GCC", Callbacks,
1107std::unique_ptr<UnknownPragmaHandler> ClangHandler(
newUnknownPragmaHandler(
1108 "#pragma clang", Callbacks,
1120std::unique_ptr<UnknownPragmaHandler> OpenMPHandler(
1121 newUnknownPragmaHandler(
"#pragma omp", Callbacks,
Defines the Diagnostic-related interfaces.
llvm::MachO::FileType FileType
Defines the clang::MacroInfo and clang::MacroDirective classes.
Defines the PPCallbacks interface.
Defines the clang::Preprocessor interface.
std::pair< const IdentifierInfo *, MacroInfo * > id_macro_pair
static void DoPrintMacros(Preprocessor &PP, raw_ostream *OS)
static void PrintMacroDefinition(const IdentifierInfo &II, const MacroInfo &MI, Preprocessor &PP, raw_ostream *OS)
PrintMacroDefinition - Print a macro definition in a form that will be properly accepted back as a de...
static int MacroIDCompare(const id_macro_pair *LHS, const id_macro_pair *RHS)
static void PrintPreprocessedTokens(Preprocessor &PP, Token &Tok, PrintPPOutputPPCallbacks *Callbacks)
static void outputPrintable(raw_ostream *OS, StringRef Str)
Defines the SourceManager interface.
Represents a character-granular source range.
An opaque identifier used by SourceManager which refers to a source file (MemoryBuffer) along with it...
One of these records is kept for each identifier that is lexed.
tok::PPKeywordKind getPPKeywordID() const
Return the preprocessor keyword ID for this identifier.
StringRef getName() const
Return the actual identifier string.
Record the location of an inclusion directive, such as an #include or #import statement.
A description of the current definition of a macro.
MacroInfo * getMacroInfo() const
Get the MacroInfo that should be used for this definition.
Encapsulates changes to the "macros namespace" (the location where the macro name became active,...
const MacroInfo * getMacroInfo() const
Encapsulates the data about a macro definition (e.g.
bool isUsed() const
Return false if this macro is defined in the main file and has not yet been used.
bool isFunctionLike() const
const_tokens_iterator tokens_begin() const
param_iterator param_begin() const
bool isBuiltinMacro() const
Return true if this macro requires processing before expansion.
IdentifierInfo *const * param_iterator
Parameters - The list of parameters for a function-like macro.
SourceLocation getDefinitionLoc() const
Return the location that the macro was defined at.
bool tokens_empty() const
param_iterator param_end() const
ArrayRef< Token > tokens() const
bool isGNUVarargs() const
Describes a module or submodule.
std::string getFullModuleName(bool AllowStringLiterals=false) const
Retrieve the full name of this module, including the path from its top-level module.
This interface provides a way to observe the actions of the preprocessor as it does its thing.
virtual void PragmaExecCharsetPop(SourceLocation Loc)
Callback invoked when a #pragma execution_character_set(pop) directive is read.
virtual void PragmaDiagnosticPush(SourceLocation Loc, StringRef Namespace)
Callback invoked when a #pragma gcc diagnostic push directive is read.
virtual void PragmaWarning(SourceLocation Loc, PragmaWarningSpecifier WarningSpec, ArrayRef< int > Ids)
virtual void PragmaDebug(SourceLocation Loc, StringRef DebugType)
Callback invoked when a #pragma clang __debug directive is read.
virtual void FileChanged(SourceLocation Loc, FileChangeReason Reason, SrcMgr::CharacteristicKind FileType, FileID PrevFID=FileID())
Callback invoked whenever a source file is entered or exited.
virtual void MacroUndefined(const Token &MacroNameTok, const MacroDefinition &MD, const MacroDirective *Undef)
Hook called whenever a macro #undef is seen.
virtual void MacroDefined(const Token &MacroNameTok, const MacroDirective *MD)
Hook called whenever a macro definition is seen.
virtual void PragmaDiagnostic(SourceLocation Loc, StringRef Namespace, diag::Severity mapping, StringRef Str)
Callback invoked when a #pragma gcc diagnostic directive is read.
virtual void PragmaAssumeNonNullEnd(SourceLocation Loc)
Callback invoked when a #pragma clang assume_nonnull end directive is read.
virtual void PragmaAssumeNonNullBegin(SourceLocation Loc)
Callback invoked when a #pragma clang assume_nonnull begin directive is read.
virtual void EmbedDirective(SourceLocation HashLoc, StringRef FileName, bool IsAngled, OptionalFileEntryRef File, const LexEmbedParametersResult &Params)
Callback invoked whenever an embed directive has been processed, regardless of whether the embed will...
virtual void Ident(SourceLocation Loc, StringRef str)
Callback invoked when a #ident or #sccs directive is read.
virtual void PragmaMessage(SourceLocation Loc, StringRef Namespace, PragmaMessageKind Kind, StringRef Str)
Callback invoked when a #pragma message directive is read.
virtual void PragmaExecCharsetPush(SourceLocation Loc, StringRef Str)
Callback invoked when a #pragma execution_character_set(push) directive is read.
virtual void PragmaDiagnosticPop(SourceLocation Loc, StringRef Namespace)
Callback invoked when a #pragma gcc diagnostic pop directive is read.
virtual void PragmaWarningPop(SourceLocation Loc)
Callback invoked when a #pragma warning(pop) directive is read.
virtual void PragmaWarningPush(SourceLocation Loc, int Level)
Callback invoked when a #pragma warning(push) directive is read.
PragmaHandler - Instances of this interface defined to handle the various pragmas that the language f...
virtual void HandlePragma(Preprocessor &PP, PragmaIntroducer Introducer, Token &FirstToken)=0
PreprocessorOutputOptions - Options for controlling the C preprocessor output (e.g....
unsigned UseLineDirectives
Use #line instead of GCC-style # N.
unsigned ShowMacros
Print macro definitions.
unsigned ShowIncludeDirectives
Print includes, imports etc. within preprocessed output.
unsigned ShowMacroComments
Show comments, even in macros.
unsigned ShowCPP
Print normal preprocessed output.
unsigned MinimizeWhitespace
Ignore whitespace from input.
unsigned KeepSystemIncludes
Do not expand system headers.
unsigned ShowComments
Show comments.
unsigned ShowEmbedDirectives
Print embeds, etc. within preprocessed.
unsigned ShowLineMarkers
Show #line markers.
unsigned DirectivesOnly
Process directives but do not expand macros.
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
void IgnorePragmas()
Install empty handlers for all pragmas (making them ignored).
macro_iterator macro_begin(bool IncludeExternalMacros=true) const
void Lex(Token &Result)
Lex the next token for this preprocessor.
void addPPCallbacks(std::unique_ptr< PPCallbacks > C)
void EnterMainSourceFile()
Enter the specified FileID as the main source file, which implicitly adds the builtin defines etc.
macro_iterator macro_end(bool IncludeExternalMacros=true) const
SourceManager & getSourceManager() const
bool getCommentRetentionState() const
void SetMacroExpansionOnlyInDirectives()
Disables macro expansion everywhere except for preprocessor directives.
MacroMap::const_iterator macro_iterator
void LexUnexpandedToken(Token &Result)
Just like Lex, but disables macro expansion of identifier tokens.
void AddPragmaHandler(StringRef Namespace, PragmaHandler *Handler)
Add the specified pragma handler to this preprocessor.
StringRef getSpelling(SourceLocation loc, SmallVectorImpl< char > &buffer, bool *invalid=nullptr) const
Return the 'spelling' of the token at the given location; does not go up to the spelling location or ...
const LangOptions & getLangOpts() const
void LexTokensUntilEOF(std::vector< Token > *Tokens=nullptr)
Lex all tokens for this preprocessor until (and excluding) end of file.
void SetCommentRetentionState(bool KeepComments, bool KeepMacroComments)
Control whether the preprocessor retains comments in output.
void RemovePragmaHandler(StringRef Namespace, PragmaHandler *Handler)
Remove the specific pragma handler from this preprocessor.
Represents an unpacked "presumed" location which can be presented to the user.
const char * getFilename() const
Return the presumed filename of this location.
unsigned getLine() const
Return the presumed line number of this location.
bool isInvalid() const
Return true if this object is invalid or uninitialized.
SourceLocation getIncludeLoc() const
Return the presumed include location of this location.
Encodes a location in the source.
bool isValid() const
Return true if this is a valid SourceLocation object.
This class handles loading and caching of source files into memory.
PresumedLoc getPresumedLoc(SourceLocation Loc, bool UseLineDirectives=true) const
Returns the "presumed" location of a SourceLocation specifies.
TokenConcatenation class, which answers the question of "Is it safe to emit two tokens without a whit...
bool AvoidConcat(const Token &PrevPrevTok, const Token &PrevTok, const Token &Tok) const
AvoidConcat - If printing PrevTok immediately followed by Tok would cause the two individual tokens t...
Token - This structure provides full information about a lexed token.
IdentifierInfo * getIdentifierInfo() const
bool isLiteral() const
Return true if this is a "literal", like a numeric constant, string, etc.
SourceLocation getLocation() const
Return a source location identifier for the specified offset in the current file.
unsigned getLength() const
bool is(tok::TokenKind K) const
is/isNot - Predicates to check if this token is a specific kind, as in "if (Tok.is(tok::l_brace)) {....
void * getAnnotationValue() const
tok::TokenKind getKind() const
bool isAtStartOfLine() const
isAtStartOfLine - Return true if this token is at the start of a line.
bool hasLeadingSpace() const
Return true if this token has whitespace before it.
bool isNot(tok::TokenKind K) const
bool isAnnotation() const
Return true if this is any of tok::annot_* kind tokens.
void startToken()
Reset all flags to cleared.
bool needsCleaning() const
Return true if this token has trigraphs or escaped newlines in it.
const char * getLiteralData() const
getLiteralData - For a literal token (numeric constant, string, etc), this returns a pointer to the s...
CharacteristicKind
Indicates whether a file or directory holds normal user code, system code, or system code which is im...
bool isSystem(CharacteristicKind CK)
Determine whether a file / directory characteristic is for system code.
Severity
Enum values that allow the client to map NOTEs, WARNINGs, and EXTENSIONs to either Ignore (nothing),...
The JSON file list parser is used to communicate input to InstallAPI.
LLVM_READONLY bool isPrintable(unsigned char c)
Return true if this character is an ASCII printable character; that is, a character that should take ...
void DoPrintPreprocessedInput(Preprocessor &PP, raw_ostream *OS, const PreprocessorOutputOptions &Opts)
DoPrintPreprocessedInput - Implement -E mode.
const FunctionProtoType * T
Helper class to shuttle information about #embed directives from the preprocessor to the parser throu...
std::optional< PPEmbedParameterIfEmpty > MaybeIfEmptyParam
std::optional< PPEmbedParameterOffset > MaybeOffsetParam
std::optional< PPEmbedParameterLimit > MaybeLimitParam
std::optional< PPEmbedParameterSuffix > MaybeSuffixParam
std::optional< PPEmbedParameterPrefix > MaybePrefixParam
Describes how and where the pragma was introduced.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4