24 #include "llvm/Support/FileSystem.h" 25 #include "llvm/Support/MemoryBuffer.h" 26 #include "llvm/Support/Path.h" 27 #include "llvm/Support/raw_ostream.h" 28 #include "llvm/Support/YAMLTraits.h" 30 #include <system_error> 32 using namespace clang;
47 GetCodeCompletionConsumer(CI));
55 std::unique_ptr<ASTConsumer>
57 return llvm::make_unique<ASTConsumer>();
60 void InitOnlyAction::ExecuteAction() {
67 std::unique_ptr<ASTConsumer>
69 if (std::unique_ptr<raw_ostream> OS =
75 std::unique_ptr<ASTConsumer>
84 std::unique_ptr<ASTConsumer>
89 std::unique_ptr<ASTConsumer>
94 std::unique_ptr<ASTConsumer>
100 std::unique_ptr<ASTConsumer>
103 if (!ComputeASTConsumerArguments(CI, Sysroot))
106 std::string OutputFile;
107 std::unique_ptr<raw_pwrite_stream> OS =
108 CreateOutputFile(CI, InFile, OutputFile);
116 auto Buffer = std::make_shared<PCHBuffer>();
117 std::vector<std::unique_ptr<ASTConsumer>> Consumers;
118 Consumers.push_back(llvm::make_unique<PCHGenerator>(
120 Buffer, FrontendOpts.ModuleFileExtensions,
122 FrontendOpts.IncludeTimestamps));
124 CI, InFile, OutputFile, std::move(OS), Buffer));
126 return llvm::make_unique<MultiplexConsumer>(std::move(Consumers));
130 std::string &Sysroot) {
140 std::unique_ptr<llvm::raw_pwrite_stream>
142 std::string &OutputFile) {
146 std::unique_ptr<raw_pwrite_stream> OS =
168 std::unique_ptr<ASTConsumer>
171 std::unique_ptr<raw_pwrite_stream> OS = CreateOutputFile(CI, InFile);
178 auto Buffer = std::make_shared<PCHBuffer>();
179 std::vector<std::unique_ptr<ASTConsumer>> Consumers;
181 Consumers.push_back(llvm::make_unique<PCHGenerator>(
188 CI, InFile, OutputFile, std::move(OS), Buffer));
189 return llvm::make_unique<MultiplexConsumer>(std::move(Consumers));
192 bool GenerateModuleFromModuleMapAction::BeginSourceFileAction(
202 std::unique_ptr<raw_pwrite_stream>
209 if (ModuleMapFile.empty())
210 ModuleMapFile = InFile;
227 bool GenerateModuleInterfaceAction::BeginSourceFileAction(
239 std::unique_ptr<raw_pwrite_stream>
248 std::unique_ptr<ASTConsumer>
250 return llvm::make_unique<ASTConsumer>();
253 std::unique_ptr<ASTConsumer>
256 return llvm::make_unique<ASTConsumer>();
259 std::unique_ptr<ASTConsumer>
261 return llvm::make_unique<ASTConsumer>();
268 std::unique_ptr<ASTReader> Reader(
new ASTReader(
271 Sysroot.empty() ?
"" : Sysroot.c_str(),
285 struct TemplightEntry {
289 std::string DefinitionLocation;
290 std::string PointOfInstantiation;
296 template <>
struct MappingTraits<TemplightEntry> {
297 static void mapping(IO &io, TemplightEntry &fields) {
298 io.mapRequired(
"name", fields.Name);
299 io.mapRequired(
"kind", fields.Kind);
300 io.mapRequired(
"event", fields.Event);
301 io.mapRequired(
"orig", fields.DefinitionLocation);
302 io.mapRequired(
"poi", fields.PointOfInstantiation);
318 const CodeSynthesisContext &Inst)
override {
319 displayTemplightEntry<true>(llvm::outs(), TheSema, Inst);
323 const CodeSynthesisContext &Inst)
override {
324 displayTemplightEntry<false>(llvm::outs(), TheSema, Inst);
328 static std::string
toString(CodeSynthesisContext::SynthesisKind
Kind) {
330 case CodeSynthesisContext::TemplateInstantiation:
331 return "TemplateInstantiation";
332 case CodeSynthesisContext::DefaultTemplateArgumentInstantiation:
333 return "DefaultTemplateArgumentInstantiation";
334 case CodeSynthesisContext::DefaultFunctionArgumentInstantiation:
335 return "DefaultFunctionArgumentInstantiation";
336 case CodeSynthesisContext::ExplicitTemplateArgumentSubstitution:
337 return "ExplicitTemplateArgumentSubstitution";
338 case CodeSynthesisContext::DeducedTemplateArgumentSubstitution:
339 return "DeducedTemplateArgumentSubstitution";
340 case CodeSynthesisContext::PriorTemplateArgumentSubstitution:
341 return "PriorTemplateArgumentSubstitution";
342 case CodeSynthesisContext::DefaultTemplateArgumentChecking:
343 return "DefaultTemplateArgumentChecking";
344 case CodeSynthesisContext::ExceptionSpecInstantiation:
345 return "ExceptionSpecInstantiation";
346 case CodeSynthesisContext::DeclaringSpecialMember:
347 return "DeclaringSpecialMember";
348 case CodeSynthesisContext::DefiningSynthesizedFunction:
349 return "DefiningSynthesizedFunction";
350 case CodeSynthesisContext::Memoization:
351 return "Memoization";
356 template <
bool BeginInstantiation>
357 static void displayTemplightEntry(llvm::raw_ostream &Out,
const Sema &TheSema,
358 const CodeSynthesisContext &Inst) {
361 llvm::raw_string_ostream OS(YAML);
362 llvm::yaml::Output YO(OS);
363 TemplightEntry Entry =
364 getTemplightEntry<BeginInstantiation>(TheSema, Inst);
365 llvm::yaml::EmptyContext Context;
366 llvm::yaml::yamlize(YO, Entry,
true, Context);
368 Out <<
"---" << YAML <<
"\n";
371 template <
bool BeginInstantiation>
372 static TemplightEntry getTemplightEntry(
const Sema &TheSema,
373 const CodeSynthesisContext &Inst) {
374 TemplightEntry Entry;
376 Entry.Event = BeginInstantiation ?
"Begin" :
"End";
377 if (
auto *NamedTemplate = dyn_cast_or_null<NamedDecl>(Inst.Entity)) {
378 llvm::raw_string_ostream OS(Entry.Name);
379 NamedTemplate->getNameForDiagnostic(OS, TheSema.
getLangOpts(),
true);
383 Entry.DefinitionLocation = std::string(DefLoc.
getFilename()) +
":" +
384 std::to_string(DefLoc.
getLine()) +
":" +
390 Entry.PointOfInstantiation = std::string(PoiLoc.
getFilename()) +
":" +
391 std::to_string(PoiLoc.
getLine()) +
":" +
399 std::unique_ptr<ASTConsumer>
401 return llvm::make_unique<ASTConsumer>();
411 EnsureSemaIsCreated(CI, *
this);
414 llvm::make_unique<DefaultTemplateInstCallback>());
422 llvm::raw_ostream &Out;
425 DumpModuleInfoListener(llvm::raw_ostream &Out) : Out(Out) { }
427 #define DUMP_BOOLEAN(Value, Text) \ 428 Out.indent(4) << Text << ": " << (Value? "Yes" : "No") << "\n" 430 bool ReadFullVersionInformation(StringRef FullVersion)
override {
435 <<
" Clang: " << FullVersion <<
"\n";
439 void ReadModuleName(StringRef ModuleName)
override {
440 Out.indent(2) <<
"Module name: " << ModuleName <<
"\n";
442 void ReadModuleMapFile(StringRef ModuleMapPath)
override {
443 Out.indent(2) <<
"Module map file: " << ModuleMapPath <<
"\n";
446 bool ReadLanguageOptions(
const LangOptions &LangOpts,
bool Complain,
447 bool AllowCompatibleDifferences)
override {
448 Out.indent(2) <<
"Language options:\n";
449 #define LANGOPT(Name, Bits, Default, Description) \ 450 DUMP_BOOLEAN(LangOpts.Name, Description); 451 #define ENUM_LANGOPT(Name, Type, Bits, Default, Description) \ 452 Out.indent(4) << Description << ": " \ 453 << static_cast<unsigned>(LangOpts.get##Name()) << "\n"; 454 #define VALUE_LANGOPT(Name, Bits, Default, Description) \ 455 Out.indent(4) << Description << ": " << LangOpts.Name << "\n"; 456 #define BENIGN_LANGOPT(Name, Bits, Default, Description) 457 #define BENIGN_ENUM_LANGOPT(Name, Type, Bits, Default, Description) 458 #include "clang/Basic/LangOptions.def" 461 Out.indent(4) <<
"Module features:\n";
463 Out.indent(6) << Feature <<
"\n";
469 bool ReadTargetOptions(
const TargetOptions &TargetOpts,
bool Complain,
470 bool AllowCompatibleDifferences)
override {
471 Out.indent(2) <<
"Target options:\n";
472 Out.indent(4) <<
" Triple: " << TargetOpts.
Triple <<
"\n";
473 Out.indent(4) <<
" CPU: " << TargetOpts.
CPU <<
"\n";
474 Out.indent(4) <<
" ABI: " << TargetOpts.
ABI <<
"\n";
477 Out.indent(4) <<
"Target features:\n";
488 bool Complain)
override {
489 Out.indent(2) <<
"Diagnostic options:\n";
490 #define DIAGOPT(Name, Bits, Default) DUMP_BOOLEAN(DiagOpts->Name, #Name); 491 #define ENUM_DIAGOPT(Name, Type, Bits, Default) \ 492 Out.indent(4) << #Name << ": " << DiagOpts->get##Name() << "\n"; 493 #define VALUE_DIAGOPT(Name, Bits, Default) \ 494 Out.indent(4) << #Name << ": " << DiagOpts->Name << "\n"; 495 #include "clang/Basic/DiagnosticOptions.def" 497 Out.indent(4) <<
"Diagnostic flags:\n";
498 for (
const std::string &
Warning : DiagOpts->Warnings)
499 Out.indent(6) <<
"-W" << Warning <<
"\n";
500 for (
const std::string &
Remark : DiagOpts->Remarks)
501 Out.indent(6) <<
"-R" << Remark <<
"\n";
507 StringRef SpecificModuleCachePath,
508 bool Complain)
override {
509 Out.indent(2) <<
"Header search options:\n";
510 Out.indent(4) <<
"System root [-isysroot=]: '" << HSOpts.
Sysroot <<
"'\n";
511 Out.indent(4) <<
"Resource dir [ -resource-dir=]: '" << HSOpts.
ResourceDir <<
"'\n";
512 Out.indent(4) <<
"Module Cache: '" << SpecificModuleCachePath <<
"'\n";
514 "Use builtin include directories [-nobuiltininc]");
516 "Use standard system include directories [-nostdinc]");
518 "Use standard C++ include directories [-nostdinc++]");
520 "Use libc++ (rather than libstdc++) [-stdlib=]");
526 std::string &SuggestedPredefines)
override {
527 Out.indent(2) <<
"Preprocessor options:\n";
529 "Uses compiler/target-specific predefines [-undef]");
531 "Uses detailed preprocessing record (for indexing)");
533 if (!PPOpts.
Macros.empty()) {
534 Out.indent(4) <<
"Predefined macros:\n";
537 for (std::vector<std::pair<std::string, bool/*isUndef*/> >::const_iterator
545 Out << I->first <<
"\n";
551 void readModuleFileExtension(
553 Out.indent(2) <<
"Module file extension '" 558 Out.write_escaped(Metadata.
UserInfo);
566 bool needsInputFileVisitation()
override {
return true; }
570 bool needsSystemInputFileVisitation()
override {
return true; }
576 bool isOverridden,
bool isExplicitModule)
override {
578 Out.indent(2) <<
"Input file: " <<
Filename;
580 if (isSystem || isOverridden || isExplicitModule) {
584 if (isOverridden || isExplicitModule)
589 if (isExplicitModule)
592 if (isExplicitModule)
593 Out <<
"ExplicitModule";
615 std::unique_ptr<llvm::raw_fd_ostream> OutFile;
617 if (!OutputFileName.empty() && OutputFileName !=
"-") {
619 OutFile.reset(
new llvm::raw_fd_ostream(OutputFileName.str(), EC,
620 llvm::sys::fs::F_Text));
622 llvm::raw_ostream &Out = OutFile.get()? *OutFile.get() : llvm::outs();
624 Out <<
"Information for module file '" <<
getCurrentFile() <<
"':\n";
627 StringRef Magic = (*Buffer)->getMemBufferRef().getBuffer();
628 bool IsRaw = (Magic.size() >= 4 && Magic[0] ==
'C' && Magic[1] ==
'P' &&
629 Magic[2] ==
'C' && Magic[3] ==
'H');
630 Out <<
" Module format: " << (IsRaw ?
"raw" :
"obj") <<
"\n";
633 DumpModuleInfoListener Listener(Out);
635 PP.getHeaderSearchInfo().getHeaderSearchOpts();
656 RawLex.LexFromRawLexer(RawTok);
659 llvm::errs() <<
"\n";
660 RawLex.LexFromRawLexer(RawTok);
672 llvm::errs() <<
"\n";
678 std::unique_ptr<raw_pwrite_stream> OS =
715 bool BinaryMode =
true;
716 bool InvalidFile =
false;
721 const char *cur = Buffer->getBufferStart();
722 const char *end = Buffer->getBufferEnd();
723 const char *next = (cur != end) ? cur + 1 : end;
728 if (end - cur > 256) end = cur + 256;
736 }
else if (*cur == 0x0A)
744 std::unique_ptr<raw_ostream> OS =
752 if (Input.isFile()) {
754 OS->write_escaped(Input.getFile());
760 (*OS) <<
"#pragma clang module contents\n";
795 llvm::outs().write((*Buffer)->getBufferStart(),
Preamble);
799 void DumpCompilerOptionsAction::ExecuteAction() {
801 std::unique_ptr<raw_ostream> OSP =
806 raw_ostream &OS = *OSP;
816 OS <<
"\n\"features\" : [\n";
819 #define FEATURE(Name, Predicate) \ 820 ("\t{\"" #Name "\" : " + llvm::Twine(Predicate ? "true" : "false") + "},\n") \ 822 #include "clang/Basic/Features.def" 826 OS << Str.substr(0, Str.size() - 2);
830 OS <<
"\n\"extensions\" : [\n";
833 #define EXTENSION(Name, Predicate) \ 834 ("\t{\"" #Name "\" : " + llvm::Twine(Predicate ? "true" : "false") + "},\n") \ 836 #include "clang/Basic/Features.def" 840 OS << Str.substr(0, Str.size() - 2);
std::string OutputFile
The output file, if any.
LangOptions & getLangOpts()
std::string OriginalModuleMap
When the input is a module map, the original module map file from which that map was inferred...
std::unique_ptr< ASTConsumer > CreateASTConsumer(CompilerInstance &CI, StringRef InFile) override
Create the AST consumer object for this action, if supported.
PreprocessorOptions & getPreprocessorOpts()
bool shouldEraseOutputFiles() override
Callback at the end of processing a single input, to determine if the output files should be erased o...
void createCodeCompletionConsumer()
Create a code completion consumer using the invocation; note that this will cause the source manager ...
std::vector< std::pair< std::string, bool > > Macros
Lexer - This provides a simple interface that turns a text buffer into a stream of tokens...
std::vector< std::unique_ptr< TemplateInstantiationCallback > > TemplateInstCallbacks
The template instantiation callbacks to trace or track instantiations (objects can be chained)...
Defines the clang::FileManager interface and associated types.
DominatorTree GraphTraits specialization so the DominatorTree can be iterable by generic graph iterat...
void ExecuteAction() override
Implement the ExecuteAction interface by running Sema on the already-initialized AST consumer...
std::unique_ptr< ASTConsumer > CreateASTConsumer(CompilerInstance &CI, StringRef InFile) override
Create the AST consumer object for this action, if supported.
void createSema(TranslationUnitKind TUKind, CodeCompleteConsumer *CompletionConsumer)
Create the Sema object to be used for parsing.
Abstract base class for actions which can be performed by the frontend.
DiagnosticBuilder Report(SourceLocation Loc, unsigned DiagID)
Issue the message to the client.
void finalize(TemplateInstantiationCallbackPtrs &Callbacks, const Sema &TheSema)
PreprocessorOptions - This class is used for passing the various options used in preprocessor initial...
std::string ASTDumpFilter
If given, filter dumped AST Decl nodes by this substring.
ASTContext & getASTContext() const
Compiling a C++ modules TS module interface unit.
void IgnorePragmas()
Install empty handlers for all pragmas (making them ignored).
Options for controlling the target.
A context in which code is being synthesized (where a source location alone is not sufficient to iden...
virtual bool hasCodeCompletionSupport() const
Does this action support use with code completion?
std::unique_ptr< ASTConsumer > CreateASTConsumer(CompilerInstance &CI, StringRef InFile) override
Create the AST consumer object for this action, if supported.
void ExecuteAction() override
Callback to run the program action, using the initialized compiler instance.
Module * getCurrentModule() const
Token - This structure provides full information about a lexed token.
The client can handle an AST file that cannot load because it's compiled configuration doesn't match ...
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
void ExecuteAction() override
Callback to run the program action, using the initialized compiler instance.
const LangOptions & getLangOpts() const
unsigned BuildingImplicitModule
Whether we are performing an implicit module build.
bool BeginSourceFileAction(CompilerInstance &CI) override
Callback at the start of processing a single input.
unsigned RelocatablePCH
When generating PCH files, instruct the AST writer to create relocatable PCH files.
static bool ComputeASTConsumerArguments(CompilerInstance &CI, std::string &Sysroot)
Compute the AST consumer arguments that will be used to create the PCHGenerator instance returned by ...
This is a base class for callbacks that will be notified at every template instantiation.
CompilerInstance & getCompilerInstance() const
const PCHContainerWriter & getPCHContainerWriter() const
Return the appropriate PCHContainerWriter depending on the current CodeGenOptions.
HeaderSearch & getHeaderSearchInfo() const
FrontendOptions & getFrontendOpts()
static void mapping(IO &io, TemplightEntry &fields)
PreprocessorOutputOptions & getPreprocessorOutputOpts()
std::unique_ptr< ASTConsumer > CreateASTConsumer(CompilerInstance &CI, StringRef InFile) override
Create the AST consumer object for this action, if supported.
void CacheTokens(Preprocessor &PP, raw_pwrite_stream *OS)
Cache tokens for use with PCH. Note that this requires a seekable stream.
bool BeginInvocation(CompilerInstance &CI) override
Callback before starting processing a single input, giving the opportunity to modify the CompilerInvo...
std::unique_ptr< ASTConsumer > CreateASTConsumer(CompilerInstance &CI, StringRef InFile) override
Create the AST consumer object for this action, if supported.
#define DUMP_BOOLEAN(Value, Text)
const LangOptions & getLangOpts() const
HeaderSearchOptions & getHeaderSearchOpts()
void ExecuteAction() override
Implement the ExecuteAction interface by running Sema on the already-initialized AST consumer...
CodeCompleteConsumer & getCodeCompletionConsumer() const
std::vector< std::string > ModuleFeatures
The names of any features to enable in module 'requires' decls in addition to the hard-coded list in ...
bool DetailedRecord
Whether we should maintain a detailed record of all macro definitions and expansions.
Sema - This implements semantic analysis and AST building for C.
std::string CurrentModule
The name of the current module, of which the main source file is a part.
virtual bool shouldEraseOutputFiles()
Callback at the end of processing a single input, to determine if the output files should be erased o...
unsigned ASTDumpAll
Whether we deserialize all decls when forming AST dumps.
std::unique_ptr< ASTConsumer > CreateASTDumper(std::unique_ptr< raw_ostream > OS, StringRef FilterString, bool DumpDecls, bool Deserialize, bool DumpLookups)
void DoPrintPreprocessedInput(Preprocessor &PP, raw_ostream *OS, const PreprocessorOutputOptions &Opts)
DoPrintPreprocessedInput - Implement -E mode.
void ExecuteAction() override
Implement the ExecuteAction interface by running Sema on the already-initialized AST consumer...
static PreambleBounds ComputePreamble(StringRef Buffer, const LangOptions &LangOpts, unsigned MaxLines=0)
Compute the preamble of the given file.
bool isInvalid() const
Return true if this object is invalid or uninitialized.
unsigned getLine() const
Return the presumed line number of this location.
void EnterMainSourceFile()
Enter the specified FileID as the main source file, which implicitly adds the builtin defines etc...
void print(raw_ostream &OS, unsigned Indent=0) const
Print the module map for this module to the given stream.
Defines the clang::Preprocessor interface.
Represents an unpacked "presumed" location which can be presented to the user.
InputKind getCurrentFileKind() const
std::unique_ptr< raw_pwrite_stream > createOutputFile(StringRef OutputPath, bool Binary, bool RemoveFileOnSignal, StringRef BaseInput, StringRef Extension, bool UseTemporary, bool CreateMissingDirectories=false)
Create a new output file and add it to the list of tracked output files, optionally deriving the outp...
bool AllowPCHWithCompilerErrors
When true, a PCH with compiler errors will not be rejected.
std::string CPU
If given, the name of the target CPU to generate code for.
SourceManager & getSourceManager() const
const char * getFilename() const
Return the presumed filename of this location.
std::unique_ptr< ASTConsumer > CreateASTConsumer(CompilerInstance &CI, StringRef InFile) override
Create the AST consumer object for this action, if supported.
void ExecuteAction() override
Callback to run the program action, using the initialized compiler instance.
llvm::MemoryBuffer * getBuffer(FileID FID, SourceLocation Loc, bool *Invalid=nullptr) const
Return the buffer for the specified FileID.
std::string ABI
If given, the name of the target ABI to use.
File is a PCH file treated as the preamble.
unsigned getColumn() const
Return the presumed column number of this location.
void ExecuteAction() override
Callback to run the program action, using the initialized compiler instance.
CompilerInstance - Helper class for managing a single instance of the Clang compiler.
Encodes a location in the source.
void atTemplateBegin(TemplateInstantiationCallbackPtrs &Callbacks, const Sema &TheSema, const Sema::CodeSynthesisContext &Inst)
File is a PCH file treated as such.
ParsedSourceLocation CodeCompletionAt
If given, enable code completion at the provided location.
virtual TranslationUnitKind getTranslationUnitKind()
For AST-based actions, the kind of translation unit we're handling.
std::string getClangFullRepositoryVersion()
Retrieves the full repository version that is an amalgamation of the information in getClangRepositor...
void Lex(Token &Result)
Lex the next token for this preprocessor.
virtual bool ReadFullVersionInformation(StringRef FullVersion)
Receives the full Clang version information.
unsigned ASTDumpLookups
Whether we include lookup table dumps in AST dumps.
std::vector< std::string > FeaturesAsWritten
The list of target specific features to enable or disable, as written on the command line...
void DumpToken(const Token &Tok, bool DumpFlags=false) const
Print the token to stderr, used for debugging.
void ExecuteAction() override
Callback to run the program action, using the initialized compiler instance.
Abstract interface for a consumer of code-completion information.
bool isNot(tok::TokenKind K) const
Dataflow Directional Tag Classes.
FileManager & getFileManager() const
Return the current file manager to the caller.
void ExecuteAction() override
Callback to run the program action, using the initialized compiler instance.
std::unique_ptr< ASTConsumer > CreateASTConsumer(CompilerInstance &CI, StringRef InFile) override
Create the AST consumer object for this action, if supported.
const FrontendInputFile & getCurrentInput() const
bool UsePredefines
Initialize the preprocessor with the compiler and target specific predefines.
Reads an AST files chain containing the contents of a translation unit.
FileID getMainFileID() const
Returns the FileID of the main source file.
llvm::ErrorOr< std::unique_ptr< llvm::MemoryBuffer > > getBufferForFile(const FileEntry *Entry, bool isVolatile=false, bool ShouldCloseOpenFile=true)
Open the specified file as a MemoryBuffer, returning a new MemoryBuffer if successful, otherwise returning null.
virtual std::unique_ptr< ASTConsumer > CreatePCHContainerGenerator(CompilerInstance &CI, const std::string &MainFileName, const std::string &OutputFileName, std::unique_ptr< llvm::raw_pwrite_stream > OS, std::shared_ptr< PCHBuffer > Buffer) const =0
Return an ASTConsumer that can be chained with a PCHGenerator that produces a wrapper file format con...
SourceManager & getSourceManager() const
Return the current source manager.
PresumedLoc getPresumedLoc(SourceLocation Loc, bool UseLineDirectives=true) const
Returns the "presumed" location of a SourceLocation specifies.
std::unique_ptr< ASTConsumer > CreateASTConsumer(CompilerInstance &CI, StringRef InFile) override
Create the AST consumer object for this action, if supported.
std::string toString(const til::SExpr *E)
Abstract interface for callback invocations by the ASTReader.
std::unique_ptr< ASTConsumer > CreateDeclContextPrinter()
~SyntaxOnlyAction() override
std::vector< std::shared_ptr< ModuleFileExtension > > ModuleFileExtensions
The list of module file extensions.
std::unique_ptr< raw_pwrite_stream > createDefaultOutputFile(bool Binary=true, StringRef BaseInput="", StringRef Extension="")
Create the default output file (from the invocation's options) and add it to the list of tracked outp...
std::unique_ptr< ASTConsumer > CreateASTViewer()
Preprocessor & getPreprocessor() const
Return the current preprocessor.
bool hasCodeCompletionConsumer() const
std::unique_ptr< ASTConsumer > CreateASTDeclNodeLister()
virtual bool BeginSourceFileAction(CompilerInstance &CI)
Callback at the start of processing a single input.
unsigned ASTDumpDecls
Whether we include declaration dumps in AST dumps.
void atTemplateEnd(TemplateInstantiationCallbackPtrs &Callbacks, const Sema &TheSema, const Sema::CodeSynthesisContext &Inst)
const PCHContainerReader & getPCHContainerReader() const
Return the appropriate PCHContainerReader depending on the current CodeGenOptions.
SourceManager & getSourceManager() const
std::unique_ptr< ASTConsumer > CreateASTConsumer(CompilerInstance &CI, StringRef InFile) override
Create the AST consumer object for this action, if supported.
std::pair< unsigned, bool > PrecompiledPreambleBytes
If non-zero, the implicit PCH include is actually a precompiled preamble that covers this number of b...
DiagnosticsEngine & getDiagnostics() const
Get the current diagnostics engine.
const StringRef getCurrentFile() const
void initialize(TemplateInstantiationCallbackPtrs &Callbacks, const Sema &TheSema)
static bool readASTFileControlBlock(StringRef Filename, FileManager &FileMgr, const PCHContainerReader &PCHContainerRdr, bool FindModuleFileExtensions, ASTReaderListener &Listener, bool ValidateDiagnosticOptions)
Read the control block for the named AST file.
std::unique_ptr< ASTConsumer > CreateASTConsumer(CompilerInstance &CI, StringRef InFile) override
Create the AST consumer object for this action, if supported.
static std::unique_ptr< llvm::raw_pwrite_stream > CreateOutputFile(CompilerInstance &CI, StringRef InFile, std::string &OutputFile)
Creates file to write the PCH into and returns a stream to write it into.
std::unique_ptr< ASTConsumer > CreateASTPrinter(std::unique_ptr< raw_ostream > OS, StringRef FilterString)
std::unique_ptr< ASTConsumer > CreateASTConsumer(CompilerInstance &CI, StringRef InFile) override
Create the AST consumer object for this action, if supported.
void SetKeepWhitespaceMode(bool Val)
SetKeepWhitespaceMode - This method lets clients enable or disable whitespace retention mode...
std::string Triple
The name of the target triple to compile for.
bool isSystem(CharacteristicKind CK)
Determine whether a file / directory characteristic is for system code.
This class handles loading and caching of source files into memory.
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
void ExecuteAction() override
Implement the ExecuteAction interface by running Sema on the already-initialized AST consumer...