25 #include "llvm/Support/FileSystem.h" 26 #include "llvm/Support/MemoryBuffer.h" 27 #include "llvm/Support/Path.h" 28 #include "llvm/Support/YAMLTraits.h" 29 #include "llvm/Support/raw_ostream.h" 31 #include <system_error> 33 using namespace clang;
48 GetCodeCompletionConsumer(CI));
56 std::unique_ptr<ASTConsumer>
58 return std::make_unique<ASTConsumer>();
61 void InitOnlyAction::ExecuteAction() {
68 std::unique_ptr<ASTConsumer>
70 if (std::unique_ptr<raw_ostream> OS =
76 std::unique_ptr<ASTConsumer>
84 std::unique_ptr<ASTConsumer>
89 std::unique_ptr<ASTConsumer>
94 std::unique_ptr<ASTConsumer>
97 if (!ComputeASTConsumerArguments(CI, Sysroot))
100 std::string OutputFile;
101 std::unique_ptr<raw_pwrite_stream> OS =
102 CreateOutputFile(CI, InFile, OutputFile);
110 auto Buffer = std::make_shared<PCHBuffer>();
111 std::vector<std::unique_ptr<ASTConsumer>> Consumers;
112 Consumers.push_back(std::make_unique<PCHGenerator>(
114 FrontendOpts.ModuleFileExtensions,
116 FrontendOpts.IncludeTimestamps, +CI.
getLangOpts().CacheGeneratedPCH));
118 CI, InFile, OutputFile, std::move(OS), Buffer));
120 return std::make_unique<MultiplexConsumer>(std::move(Consumers));
124 std::string &Sysroot) {
134 std::unique_ptr<llvm::raw_pwrite_stream>
136 std::string &OutputFile) {
140 std::unique_ptr<raw_pwrite_stream> OS =
162 std::unique_ptr<ASTConsumer>
165 std::unique_ptr<raw_pwrite_stream> OS = CreateOutputFile(CI, InFile);
172 auto Buffer = std::make_shared<PCHBuffer>();
173 std::vector<std::unique_ptr<ASTConsumer>> Consumers;
175 Consumers.push_back(std::make_unique<PCHGenerator>(
184 CI, InFile, OutputFile, std::move(OS), Buffer));
185 return std::make_unique<MultiplexConsumer>(std::move(Consumers));
188 bool GenerateModuleFromModuleMapAction::BeginSourceFileAction(
198 std::unique_ptr<raw_pwrite_stream>
205 if (ModuleMapFile.empty())
206 ModuleMapFile = InFile;
223 bool GenerateModuleInterfaceAction::BeginSourceFileAction(
235 std::unique_ptr<raw_pwrite_stream>
241 bool GenerateHeaderModuleAction::PrepareToExecuteAction(
252 auto Kind = Inputs[0].getKind();
256 ModuleHeaders.reserve(Inputs.size());
261 << (FIF.isFile() ? FIF.getFile()
262 : FIF.getBuffer()->getBufferIdentifier());
266 HeaderContents +=
"#include \"";
267 HeaderContents += FIF.getFile();
268 HeaderContents +=
"\"\n";
269 ModuleHeaders.push_back(FIF.getFile());
271 Buffer = llvm::MemoryBuffer::getMemBufferCopy(
281 bool GenerateHeaderModuleAction::BeginSourceFileAction(
288 for (StringRef Name : ModuleHeaders) {
292 nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr);
298 Headers.push_back({Name, &FE->getFileEntry()});
305 std::unique_ptr<raw_pwrite_stream>
314 std::unique_ptr<ASTConsumer>
316 return std::make_unique<ASTConsumer>();
319 std::unique_ptr<ASTConsumer>
322 return std::make_unique<ASTConsumer>();
325 std::unique_ptr<ASTConsumer>
327 return std::make_unique<ASTConsumer>();
334 std::unique_ptr<ASTReader> Reader(
new ASTReader(
337 Sysroot.empty() ?
"" : Sysroot.c_str(),
351 struct TemplightEntry {
355 std::string DefinitionLocation;
356 std::string PointOfInstantiation;
362 template <>
struct MappingTraits<TemplightEntry> {
363 static void mapping(IO &io, TemplightEntry &fields) {
364 io.mapRequired(
"name", fields.Name);
365 io.mapRequired(
"kind", fields.Kind);
366 io.mapRequired(
"event", fields.Event);
367 io.mapRequired(
"orig", fields.DefinitionLocation);
368 io.mapRequired(
"poi", fields.PointOfInstantiation);
384 const CodeSynthesisContext &Inst)
override {
385 displayTemplightEntry<true>(llvm::outs(), TheSema, Inst);
389 const CodeSynthesisContext &Inst)
override {
390 displayTemplightEntry<false>(llvm::outs(), TheSema, Inst);
394 static std::string
toString(CodeSynthesisContext::SynthesisKind
Kind) {
396 case CodeSynthesisContext::TemplateInstantiation:
397 return "TemplateInstantiation";
398 case CodeSynthesisContext::DefaultTemplateArgumentInstantiation:
399 return "DefaultTemplateArgumentInstantiation";
400 case CodeSynthesisContext::DefaultFunctionArgumentInstantiation:
401 return "DefaultFunctionArgumentInstantiation";
402 case CodeSynthesisContext::ExplicitTemplateArgumentSubstitution:
403 return "ExplicitTemplateArgumentSubstitution";
404 case CodeSynthesisContext::DeducedTemplateArgumentSubstitution:
405 return "DeducedTemplateArgumentSubstitution";
406 case CodeSynthesisContext::PriorTemplateArgumentSubstitution:
407 return "PriorTemplateArgumentSubstitution";
408 case CodeSynthesisContext::DefaultTemplateArgumentChecking:
409 return "DefaultTemplateArgumentChecking";
410 case CodeSynthesisContext::ExceptionSpecEvaluation:
411 return "ExceptionSpecEvaluation";
412 case CodeSynthesisContext::ExceptionSpecInstantiation:
413 return "ExceptionSpecInstantiation";
414 case CodeSynthesisContext::DeclaringSpecialMember:
415 return "DeclaringSpecialMember";
416 case CodeSynthesisContext::DeclaringImplicitEqualityComparison:
417 return "DeclaringImplicitEqualityComparison";
418 case CodeSynthesisContext::DefiningSynthesizedFunction:
419 return "DefiningSynthesizedFunction";
420 case CodeSynthesisContext::RewritingOperatorAsSpaceship:
421 return "RewritingOperatorAsSpaceship";
422 case CodeSynthesisContext::Memoization:
423 return "Memoization";
424 case CodeSynthesisContext::ConstraintsCheck:
425 return "ConstraintsCheck";
426 case CodeSynthesisContext::ConstraintSubstitution:
427 return "ConstraintSubstitution";
428 case CodeSynthesisContext::ConstraintNormalization:
429 return "ConstraintNormalization";
430 case CodeSynthesisContext::ParameterMappingSubstitution:
431 return "ParameterMappingSubstitution";
432 case CodeSynthesisContext::RequirementInstantiation:
433 return "RequirementInstantiation";
434 case CodeSynthesisContext::NestedRequirementConstraintsCheck:
435 return "NestedRequirementConstraintsCheck";
440 template <
bool BeginInstantiation>
441 static void displayTemplightEntry(llvm::raw_ostream &Out,
const Sema &TheSema,
442 const CodeSynthesisContext &Inst) {
445 llvm::raw_string_ostream OS(YAML);
446 llvm::yaml::Output YO(OS);
447 TemplightEntry Entry =
448 getTemplightEntry<BeginInstantiation>(TheSema, Inst);
449 llvm::yaml::EmptyContext Context;
450 llvm::yaml::yamlize(YO, Entry,
true, Context);
452 Out <<
"---" << YAML <<
"\n";
455 template <
bool BeginInstantiation>
456 static TemplightEntry getTemplightEntry(
const Sema &TheSema,
457 const CodeSynthesisContext &Inst) {
458 TemplightEntry Entry;
460 Entry.Event = BeginInstantiation ?
"Begin" :
"End";
461 if (
auto *NamedTemplate = dyn_cast_or_null<NamedDecl>(Inst.Entity)) {
462 llvm::raw_string_ostream OS(Entry.Name);
463 NamedTemplate->getNameForDiagnostic(OS, TheSema.
getLangOpts(),
true);
467 Entry.DefinitionLocation = std::string(DefLoc.
getFilename()) +
":" +
468 std::to_string(DefLoc.
getLine()) +
":" +
474 Entry.PointOfInstantiation = std::string(PoiLoc.
getFilename()) +
":" +
475 std::to_string(PoiLoc.
getLine()) +
":" +
483 std::unique_ptr<ASTConsumer>
485 return std::make_unique<ASTConsumer>();
495 EnsureSemaIsCreated(CI, *
this);
498 std::make_unique<DefaultTemplateInstCallback>());
506 llvm::raw_ostream &Out;
509 DumpModuleInfoListener(llvm::raw_ostream &Out) : Out(Out) { }
511 #define DUMP_BOOLEAN(Value, Text) \ 512 Out.indent(4) << Text << ": " << (Value? "Yes" : "No") << "\n" 514 bool ReadFullVersionInformation(StringRef FullVersion)
override {
519 <<
" Clang: " << FullVersion <<
"\n";
523 void ReadModuleName(StringRef ModuleName)
override {
524 Out.indent(2) <<
"Module name: " << ModuleName <<
"\n";
526 void ReadModuleMapFile(StringRef ModuleMapPath)
override {
527 Out.indent(2) <<
"Module map file: " << ModuleMapPath <<
"\n";
530 bool ReadLanguageOptions(
const LangOptions &LangOpts,
bool Complain,
531 bool AllowCompatibleDifferences)
override {
532 Out.indent(2) <<
"Language options:\n";
533 #define LANGOPT(Name, Bits, Default, Description) \ 534 DUMP_BOOLEAN(LangOpts.Name, Description); 535 #define ENUM_LANGOPT(Name, Type, Bits, Default, Description) \ 536 Out.indent(4) << Description << ": " \ 537 << static_cast<unsigned>(LangOpts.get##Name()) << "\n"; 538 #define VALUE_LANGOPT(Name, Bits, Default, Description) \ 539 Out.indent(4) << Description << ": " << LangOpts.Name << "\n"; 540 #define BENIGN_LANGOPT(Name, Bits, Default, Description) 541 #define BENIGN_ENUM_LANGOPT(Name, Type, Bits, Default, Description) 542 #include "clang/Basic/LangOptions.def" 545 Out.indent(4) <<
"Module features:\n";
547 Out.indent(6) << Feature <<
"\n";
553 bool ReadTargetOptions(
const TargetOptions &TargetOpts,
bool Complain,
554 bool AllowCompatibleDifferences)
override {
555 Out.indent(2) <<
"Target options:\n";
556 Out.indent(4) <<
" Triple: " << TargetOpts.
Triple <<
"\n";
557 Out.indent(4) <<
" CPU: " << TargetOpts.
CPU <<
"\n";
558 Out.indent(4) <<
" ABI: " << TargetOpts.
ABI <<
"\n";
561 Out.indent(4) <<
"Target features:\n";
572 bool Complain)
override {
573 Out.indent(2) <<
"Diagnostic options:\n";
574 #define DIAGOPT(Name, Bits, Default) DUMP_BOOLEAN(DiagOpts->Name, #Name); 575 #define ENUM_DIAGOPT(Name, Type, Bits, Default) \ 576 Out.indent(4) << #Name << ": " << DiagOpts->get##Name() << "\n"; 577 #define VALUE_DIAGOPT(Name, Bits, Default) \ 578 Out.indent(4) << #Name << ": " << DiagOpts->Name << "\n"; 579 #include "clang/Basic/DiagnosticOptions.def" 581 Out.indent(4) <<
"Diagnostic flags:\n";
582 for (
const std::string &
Warning : DiagOpts->Warnings)
583 Out.indent(6) <<
"-W" << Warning <<
"\n";
584 for (
const std::string &
Remark : DiagOpts->Remarks)
585 Out.indent(6) <<
"-R" << Remark <<
"\n";
591 StringRef SpecificModuleCachePath,
592 bool Complain)
override {
593 Out.indent(2) <<
"Header search options:\n";
594 Out.indent(4) <<
"System root [-isysroot=]: '" << HSOpts.
Sysroot <<
"'\n";
595 Out.indent(4) <<
"Resource dir [ -resource-dir=]: '" << HSOpts.
ResourceDir <<
"'\n";
596 Out.indent(4) <<
"Module Cache: '" << SpecificModuleCachePath <<
"'\n";
598 "Use builtin include directories [-nobuiltininc]");
600 "Use standard system include directories [-nostdinc]");
602 "Use standard C++ include directories [-nostdinc++]");
604 "Use libc++ (rather than libstdc++) [-stdlib=]");
610 std::string &SuggestedPredefines)
override {
611 Out.indent(2) <<
"Preprocessor options:\n";
613 "Uses compiler/target-specific predefines [-undef]");
615 "Uses detailed preprocessing record (for indexing)");
617 if (!PPOpts.
Macros.empty()) {
618 Out.indent(4) <<
"Predefined macros:\n";
621 for (std::vector<std::pair<std::string, bool/*isUndef*/> >::const_iterator
629 Out << I->first <<
"\n";
635 void readModuleFileExtension(
637 Out.indent(2) <<
"Module file extension '" 642 Out.write_escaped(Metadata.
UserInfo);
650 bool needsInputFileVisitation()
override {
return true; }
654 bool needsSystemInputFileVisitation()
override {
return true; }
660 bool isOverridden,
bool isExplicitModule)
override {
662 Out.indent(2) <<
"Input file: " <<
Filename;
664 if (isSystem || isOverridden || isExplicitModule) {
668 if (isOverridden || isExplicitModule)
673 if (isExplicitModule)
676 if (isExplicitModule)
677 Out <<
"ExplicitModule";
689 bool needsImportVisitation()
const override {
return true; }
693 void visitImport(StringRef ModuleName, StringRef Filename)
override {
694 Out.indent(2) <<
"Imports module '" << ModuleName
695 <<
"': " << Filename.str() <<
"\n";
710 std::unique_ptr<llvm::raw_fd_ostream> OutFile;
712 if (!OutputFileName.empty() && OutputFileName !=
"-") {
714 OutFile.reset(
new llvm::raw_fd_ostream(OutputFileName.str(), EC,
715 llvm::sys::fs::OF_Text));
717 llvm::raw_ostream &Out = OutFile.get()? *OutFile.get() : llvm::outs();
719 Out <<
"Information for module file '" <<
getCurrentFile() <<
"':\n";
722 StringRef Magic = (*Buffer)->getMemBufferRef().getBuffer();
723 bool IsRaw = (Magic.size() >= 4 && Magic[0] ==
'C' && Magic[1] ==
'P' &&
724 Magic[2] ==
'C' && Magic[3] ==
'H');
725 Out <<
" Module format: " << (IsRaw ?
"raw" :
"obj") <<
"\n";
728 DumpModuleInfoListener Listener(Out);
730 PP.getHeaderSearchInfo().getHeaderSearchOpts();
751 RawLex.LexFromRawLexer(RawTok);
754 llvm::errs() <<
"\n";
755 RawLex.LexFromRawLexer(RawTok);
767 llvm::errs() <<
"\n";
800 bool BinaryMode =
true;
801 bool InvalidFile =
false;
806 const char *cur = Buffer->getBufferStart();
807 const char *end = Buffer->getBufferEnd();
808 const char *next = (cur != end) ? cur + 1 : end;
813 if (end - cur > 256) end = cur + 256;
821 }
else if (*cur == 0x0A)
829 std::unique_ptr<raw_ostream> OS =
837 if (Input.isFile()) {
839 OS->write_escaped(Input.getFile());
843 (*OS) <<
"#pragma clang module contents\n";
878 llvm::outs().write((*Buffer)->getBufferStart(),
Preamble);
882 void DumpCompilerOptionsAction::ExecuteAction() {
884 std::unique_ptr<raw_ostream> OSP =
889 raw_ostream &OS = *OSP;
899 OS <<
"\n\"features\" : [\n";
902 #define FEATURE(Name, Predicate) \ 903 ("\t{\"" #Name "\" : " + llvm::Twine(Predicate ? "true" : "false") + "},\n") \ 905 #include "clang/Basic/Features.def" 909 OS << Str.substr(0, Str.size() - 2);
913 OS <<
"\n\"extensions\" : [\n";
916 #define EXTENSION(Name, Predicate) \ 917 ("\t{\"" #Name "\" : " + llvm::Twine(Predicate ? "true" : "false") + "},\n") \ 919 #include "clang/Basic/Features.def" 923 OS << Str.substr(0, Str.size() - 2);
941 "no errors reported for failure");
957 llvm::outs() << Output;
std::string OutputFile
The output file, if any.
SourceLocation getLocForStartOfFile(FileID FID) const
Return the source location corresponding to the first byte of the specified file. ...
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...
bool minimizeSourceToDependencyDirectives(llvm::StringRef Input, llvm::SmallVectorImpl< char > &Output, llvm::SmallVectorImpl< minimize_source_to_dependency_directives::Token > &Tokens, DiagnosticsEngine *Diags=nullptr, SourceLocation InputSourceLoc=SourceLocation())
Minimize the input down to the preprocessor directives that might have an effect on the dependencies ...
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...
bool hasErrorOccurred() const
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.
Specialize PointerLikeTypeTraits to allow LazyGenerationalUpdatePtr to be placed into a PointerUnion...
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.
DiagnosticOptions & getDiagnosticOpts()
DiagnosticBuilder Report(SourceLocation Loc, unsigned DiagID)
Issue the message to the client.
InMemoryModuleCache & getModuleCache() const
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.
static StringRef getModuleInputBufferName()
static std::string toString(const clang::SanitizerSet &Sanitizers)
Produce a string containing comma-separated names of sanitizers in Sanitizers set.
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)
StringRef getCurrentFileOrBufferName() const
PreprocessorOutputOptions & getPreprocessorOutputOpts()
SmallVector< FrontendInputFile, 0 > Inputs
The input files and their types.
std::unique_ptr< ASTConsumer > CreateASTConsumer(CompilerInstance &CI, StringRef InFile) override
Create the AST consumer object for this action, if supported.
virtual bool BeginInvocation(CompilerInstance &CI)
Callback before starting processing a single input, giving the opportunity to modify the CompilerInvo...
bool BeginInvocation(CompilerInstance &CI) override
Callback before starting processing a single input, giving the opportunity to modify the CompilerInvo...
#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...
Languages that the frontend can parse and compile.
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.
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.
Compiling a module from a list of header files.
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...
DirectoryLookup - This class represents one entry in the search list that specifies the search order ...
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.
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 PrepareToExecuteAction(CompilerInstance &CI)
Prepare to execute the action on the given CompilerInstance.
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
ASTDumpOutputFormat ASTDumpFormat
Specifies the output format of the AST.
const llvm::MemoryBuffer * getBuffer(FileID FID, SourceLocation Loc, bool *Invalid=nullptr) const
Return the buffer for the specified FileID.
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.
void ExecuteAction() override
Callback to run the program action, using the initialized compiler instance.
Reads an AST files chain containing the contents of a translation unit.
FileID getMainFileID() const
Returns the FileID of the main source file.
StringRef getCurrentFile() const
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.
FrontendOptions - Options for controlling the behavior of the frontend.
Assembly: we accept this only so that we can preprocess it.
Abstract interface for callback invocations by the ASTReader.
~SyntaxOnlyAction() override
unsigned UseTemporary
Should a temporary file be used during compilation.
std::vector< std::shared_ptr< ModuleFileExtension > > ModuleFileExtensions
The list of module file extensions.
void setSuppressAllDiagnostics(bool Val)
Suppress all diagnostics, to silence the front end when we know that we don't want any more diagnosti...
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.
LLVM IR: we accept this so that we can run the optimizer on it, and compile it to assembly or object ...
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.
This is the interface for minimizing header and source files to the minimum necessary preprocessor di...
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.
llvm::ErrorOr< std::unique_ptr< llvm::MemoryBuffer > > getBufferForFile(const FileEntry *Entry, bool isVolatile=false)
Open the specified file as a MemoryBuffer, returning a new MemoryBuffer if successful, otherwise returning null.
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.
std::unique_ptr< ASTConsumer > CreateASTDumper(std::unique_ptr< raw_ostream > OS, StringRef FilterString, bool DumpDecls, bool Deserialize, bool DumpLookups, ASTDumpOutputFormat Format)
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...