clang  8.0.0svn
FrontendActions.cpp
Go to the documentation of this file.
1 //===--- FrontendActions.cpp ----------------------------------------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
11 #include "clang/AST/ASTConsumer.h"
17 #include "clang/Frontend/Utils.h"
18 #include "clang/Lex/HeaderSearch.h"
19 #include "clang/Lex/Preprocessor.h"
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"
29 #include <memory>
30 #include <system_error>
31 
32 using namespace clang;
33 
34 namespace {
35 CodeCompleteConsumer *GetCodeCompletionConsumer(CompilerInstance &CI) {
37  : nullptr;
38 }
39 
40 void EnsureSemaIsCreated(CompilerInstance &CI, FrontendAction &Action) {
41  if (Action.hasCodeCompletionSupport() &&
44 
45  if (!CI.hasSema())
47  GetCodeCompletionConsumer(CI));
48 }
49 } // namespace
50 
51 //===----------------------------------------------------------------------===//
52 // Custom Actions
53 //===----------------------------------------------------------------------===//
54 
55 std::unique_ptr<ASTConsumer>
56 InitOnlyAction::CreateASTConsumer(CompilerInstance &CI, StringRef InFile) {
57  return llvm::make_unique<ASTConsumer>();
58 }
59 
60 void InitOnlyAction::ExecuteAction() {
61 }
62 
63 //===----------------------------------------------------------------------===//
64 // AST Consumer Actions
65 //===----------------------------------------------------------------------===//
66 
67 std::unique_ptr<ASTConsumer>
69  if (std::unique_ptr<raw_ostream> OS =
70  CI.createDefaultOutputFile(false, InFile))
71  return CreateASTPrinter(std::move(OS), CI.getFrontendOpts().ASTDumpFilter);
72  return nullptr;
73 }
74 
75 std::unique_ptr<ASTConsumer>
77  return CreateASTDumper(nullptr /*Dump to stdout.*/,
82 }
83 
84 std::unique_ptr<ASTConsumer>
86  return CreateASTDeclNodeLister();
87 }
88 
89 std::unique_ptr<ASTConsumer>
91  return CreateASTViewer();
92 }
93 
94 std::unique_ptr<ASTConsumer>
96  StringRef InFile) {
97  return CreateDeclContextPrinter();
98 }
99 
100 std::unique_ptr<ASTConsumer>
102  std::string Sysroot;
103  if (!ComputeASTConsumerArguments(CI, /*ref*/ Sysroot))
104  return nullptr;
105 
106  std::string OutputFile;
107  std::unique_ptr<raw_pwrite_stream> OS =
108  CreateOutputFile(CI, InFile, /*ref*/ OutputFile);
109  if (!OS)
110  return nullptr;
111 
113  Sysroot.clear();
114 
115  const auto &FrontendOpts = CI.getFrontendOpts();
116  auto Buffer = std::make_shared<PCHBuffer>();
117  std::vector<std::unique_ptr<ASTConsumer>> Consumers;
118  Consumers.push_back(llvm::make_unique<PCHGenerator>(
119  CI.getPreprocessor(), OutputFile, Sysroot,
120  Buffer, FrontendOpts.ModuleFileExtensions,
122  FrontendOpts.IncludeTimestamps));
123  Consumers.push_back(CI.getPCHContainerWriter().CreatePCHContainerGenerator(
124  CI, InFile, OutputFile, std::move(OS), Buffer));
125 
126  return llvm::make_unique<MultiplexConsumer>(std::move(Consumers));
127 }
128 
130  std::string &Sysroot) {
131  Sysroot = CI.getHeaderSearchOpts().Sysroot;
132  if (CI.getFrontendOpts().RelocatablePCH && Sysroot.empty()) {
133  CI.getDiagnostics().Report(diag::err_relocatable_without_isysroot);
134  return false;
135  }
136 
137  return true;
138 }
139 
140 std::unique_ptr<llvm::raw_pwrite_stream>
142  std::string &OutputFile) {
143  // We use createOutputFile here because this is exposed via libclang, and we
144  // must disable the RemoveFileOnSignal behavior.
145  // We use a temporary to avoid race conditions.
146  std::unique_ptr<raw_pwrite_stream> OS =
147  CI.createOutputFile(CI.getFrontendOpts().OutputFile, /*Binary=*/true,
148  /*RemoveFileOnSignal=*/false, InFile,
149  /*Extension=*/"", /*useTemporary=*/true);
150  if (!OS)
151  return nullptr;
152 
153  OutputFile = CI.getFrontendOpts().OutputFile;
154  return OS;
155 }
156 
158  if (getCompilerInstance().getPreprocessorOpts().AllowPCHWithCompilerErrors)
159  return false;
161 }
162 
164  CI.getLangOpts().CompilingPCH = true;
165  return true;
166 }
167 
168 std::unique_ptr<ASTConsumer>
170  StringRef InFile) {
171  std::unique_ptr<raw_pwrite_stream> OS = CreateOutputFile(CI, InFile);
172  if (!OS)
173  return nullptr;
174 
175  std::string OutputFile = CI.getFrontendOpts().OutputFile;
176  std::string Sysroot;
177 
178  auto Buffer = std::make_shared<PCHBuffer>();
179  std::vector<std::unique_ptr<ASTConsumer>> Consumers;
180 
181  Consumers.push_back(llvm::make_unique<PCHGenerator>(
182  CI.getPreprocessor(), OutputFile, Sysroot,
184  /*AllowASTWithErrors=*/false,
185  /*IncludeTimestamps=*/
187  Consumers.push_back(CI.getPCHContainerWriter().CreatePCHContainerGenerator(
188  CI, InFile, OutputFile, std::move(OS), Buffer));
189  return llvm::make_unique<MultiplexConsumer>(std::move(Consumers));
190 }
191 
192 bool GenerateModuleFromModuleMapAction::BeginSourceFileAction(
193  CompilerInstance &CI) {
194  if (!CI.getLangOpts().Modules) {
195  CI.getDiagnostics().Report(diag::err_module_build_requires_fmodules);
196  return false;
197  }
198 
200 }
201 
202 std::unique_ptr<raw_pwrite_stream>
203 GenerateModuleFromModuleMapAction::CreateOutputFile(CompilerInstance &CI,
204  StringRef InFile) {
205  // If no output file was provided, figure out where this module would go
206  // in the module cache.
207  if (CI.getFrontendOpts().OutputFile.empty()) {
208  StringRef ModuleMapFile = CI.getFrontendOpts().OriginalModuleMap;
209  if (ModuleMapFile.empty())
210  ModuleMapFile = InFile;
211 
215  ModuleMapFile);
216  }
217 
218  // We use createOutputFile here because this is exposed via libclang, and we
219  // must disable the RemoveFileOnSignal behavior.
220  // We use a temporary to avoid race conditions.
221  return CI.createOutputFile(CI.getFrontendOpts().OutputFile, /*Binary=*/true,
222  /*RemoveFileOnSignal=*/false, InFile,
223  /*Extension=*/"", /*useTemporary=*/true,
224  /*CreateMissingDirectories=*/true);
225 }
226 
227 bool GenerateModuleInterfaceAction::BeginSourceFileAction(
228  CompilerInstance &CI) {
229  if (!CI.getLangOpts().ModulesTS) {
230  CI.getDiagnostics().Report(diag::err_module_interface_requires_modules_ts);
231  return false;
232  }
233 
234  CI.getLangOpts().setCompilingModule(LangOptions::CMK_ModuleInterface);
235 
237 }
238 
239 std::unique_ptr<raw_pwrite_stream>
240 GenerateModuleInterfaceAction::CreateOutputFile(CompilerInstance &CI,
241  StringRef InFile) {
242  return CI.createDefaultOutputFile(/*Binary=*/true, InFile, "pcm");
243 }
244 
245 bool GenerateHeaderModuleAction::PrepareToExecuteAction(
246  CompilerInstance &CI) {
247  if (!CI.getLangOpts().Modules && !CI.getLangOpts().ModulesTS) {
248  CI.getDiagnostics().Report(diag::err_header_module_requires_modules);
249  return false;
250  }
251 
252  auto &Inputs = CI.getFrontendOpts().Inputs;
253  if (Inputs.empty())
255 
256  auto Kind = Inputs[0].getKind();
257 
258  // Convert the header file inputs into a single module input buffer.
259  SmallString<256> HeaderContents;
260  ModuleHeaders.reserve(Inputs.size());
261  for (const FrontendInputFile &FIF : Inputs) {
262  // FIXME: We should support re-compiling from an AST file.
263  if (FIF.getKind().getFormat() != InputKind::Source || !FIF.isFile()) {
264  CI.getDiagnostics().Report(diag::err_module_header_file_not_found)
265  << (FIF.isFile() ? FIF.getFile()
266  : FIF.getBuffer()->getBufferIdentifier());
267  return true;
268  }
269 
270  HeaderContents += "#include \"";
271  HeaderContents += FIF.getFile();
272  HeaderContents += "\"\n";
273  ModuleHeaders.push_back(FIF.getFile());
274  }
275  Buffer = llvm::MemoryBuffer::getMemBufferCopy(
276  HeaderContents, Module::getModuleInputBufferName());
277 
278  // Set that buffer up as our "real" input.
279  Inputs.clear();
280  Inputs.push_back(FrontendInputFile(Buffer.get(), Kind, /*IsSystem*/false));
281 
283 }
284 
285 bool GenerateHeaderModuleAction::BeginSourceFileAction(
286  CompilerInstance &CI) {
287  CI.getLangOpts().setCompilingModule(LangOptions::CMK_HeaderModule);
288 
289  // Synthesize a Module object for the given headers.
290  auto &HS = CI.getPreprocessor().getHeaderSearchInfo();
292  for (StringRef Name : ModuleHeaders) {
293  const DirectoryLookup *CurDir = nullptr;
294  const FileEntry *FE = HS.LookupFile(
295  Name, SourceLocation(), /*Angled*/ false, nullptr, CurDir,
296  None, nullptr, nullptr, nullptr, nullptr, nullptr);
297  if (!FE) {
298  CI.getDiagnostics().Report(diag::err_module_header_file_not_found)
299  << Name;
300  continue;
301  }
302  Headers.push_back({Name, FE});
303  }
304  HS.getModuleMap().createHeaderModule(CI.getLangOpts().CurrentModule, Headers);
305 
307 }
308 
309 std::unique_ptr<raw_pwrite_stream>
310 GenerateHeaderModuleAction::CreateOutputFile(CompilerInstance &CI,
311  StringRef InFile) {
312  return CI.createDefaultOutputFile(/*Binary=*/true, InFile, "pcm");
313 }
314 
316 }
317 
318 std::unique_ptr<ASTConsumer>
320  return llvm::make_unique<ASTConsumer>();
321 }
322 
323 std::unique_ptr<ASTConsumer>
325  StringRef InFile) {
326  return llvm::make_unique<ASTConsumer>();
327 }
328 
329 std::unique_ptr<ASTConsumer>
331  return llvm::make_unique<ASTConsumer>();
332 }
333 
337  const std::string &Sysroot = CI.getHeaderSearchOpts().Sysroot;
338  std::unique_ptr<ASTReader> Reader(new ASTReader(
341  Sysroot.empty() ? "" : Sysroot.c_str(),
342  /*DisableValidation*/ false,
343  /*AllowPCHWithCompilerErrors*/ false,
344  /*AllowConfigurationMismatch*/ true,
345  /*ValidateSystemInputs*/ true));
346 
347  Reader->ReadAST(getCurrentFile(),
348  Preamble ? serialization::MK_Preamble
350  SourceLocation(),
352 }
353 
354 namespace {
355 struct TemplightEntry {
356  std::string Name;
357  std::string Kind;
358  std::string Event;
359  std::string DefinitionLocation;
360  std::string PointOfInstantiation;
361 };
362 } // namespace
363 
364 namespace llvm {
365 namespace yaml {
366 template <> struct MappingTraits<TemplightEntry> {
367  static void mapping(IO &io, TemplightEntry &fields) {
368  io.mapRequired("name", fields.Name);
369  io.mapRequired("kind", fields.Kind);
370  io.mapRequired("event", fields.Event);
371  io.mapRequired("orig", fields.DefinitionLocation);
372  io.mapRequired("poi", fields.PointOfInstantiation);
373  }
374 };
375 } // namespace yaml
376 } // namespace llvm
377 
378 namespace {
379 class DefaultTemplateInstCallback : public TemplateInstantiationCallback {
380  using CodeSynthesisContext = Sema::CodeSynthesisContext;
381 
382 public:
383  void initialize(const Sema &) override {}
384 
385  void finalize(const Sema &) override {}
386 
387  void atTemplateBegin(const Sema &TheSema,
388  const CodeSynthesisContext &Inst) override {
389  displayTemplightEntry<true>(llvm::outs(), TheSema, Inst);
390  }
391 
392  void atTemplateEnd(const Sema &TheSema,
393  const CodeSynthesisContext &Inst) override {
394  displayTemplightEntry<false>(llvm::outs(), TheSema, Inst);
395  }
396 
397 private:
398  static std::string toString(CodeSynthesisContext::SynthesisKind Kind) {
399  switch (Kind) {
400  case CodeSynthesisContext::TemplateInstantiation:
401  return "TemplateInstantiation";
402  case CodeSynthesisContext::DefaultTemplateArgumentInstantiation:
403  return "DefaultTemplateArgumentInstantiation";
404  case CodeSynthesisContext::DefaultFunctionArgumentInstantiation:
405  return "DefaultFunctionArgumentInstantiation";
406  case CodeSynthesisContext::ExplicitTemplateArgumentSubstitution:
407  return "ExplicitTemplateArgumentSubstitution";
408  case CodeSynthesisContext::DeducedTemplateArgumentSubstitution:
409  return "DeducedTemplateArgumentSubstitution";
410  case CodeSynthesisContext::PriorTemplateArgumentSubstitution:
411  return "PriorTemplateArgumentSubstitution";
412  case CodeSynthesisContext::DefaultTemplateArgumentChecking:
413  return "DefaultTemplateArgumentChecking";
414  case CodeSynthesisContext::ExceptionSpecEvaluation:
415  return "ExceptionSpecEvaluation";
416  case CodeSynthesisContext::ExceptionSpecInstantiation:
417  return "ExceptionSpecInstantiation";
418  case CodeSynthesisContext::DeclaringSpecialMember:
419  return "DeclaringSpecialMember";
420  case CodeSynthesisContext::DefiningSynthesizedFunction:
421  return "DefiningSynthesizedFunction";
422  case CodeSynthesisContext::Memoization:
423  return "Memoization";
424  }
425  return "";
426  }
427 
428  template <bool BeginInstantiation>
429  static void displayTemplightEntry(llvm::raw_ostream &Out, const Sema &TheSema,
430  const CodeSynthesisContext &Inst) {
431  std::string YAML;
432  {
433  llvm::raw_string_ostream OS(YAML);
434  llvm::yaml::Output YO(OS);
435  TemplightEntry Entry =
436  getTemplightEntry<BeginInstantiation>(TheSema, Inst);
437  llvm::yaml::EmptyContext Context;
438  llvm::yaml::yamlize(YO, Entry, true, Context);
439  }
440  Out << "---" << YAML << "\n";
441  }
442 
443  template <bool BeginInstantiation>
444  static TemplightEntry getTemplightEntry(const Sema &TheSema,
445  const CodeSynthesisContext &Inst) {
446  TemplightEntry Entry;
447  Entry.Kind = toString(Inst.Kind);
448  Entry.Event = BeginInstantiation ? "Begin" : "End";
449  if (auto *NamedTemplate = dyn_cast_or_null<NamedDecl>(Inst.Entity)) {
450  llvm::raw_string_ostream OS(Entry.Name);
451  NamedTemplate->getNameForDiagnostic(OS, TheSema.getLangOpts(), true);
452  const PresumedLoc DefLoc =
453  TheSema.getSourceManager().getPresumedLoc(Inst.Entity->getLocation());
454  if(!DefLoc.isInvalid())
455  Entry.DefinitionLocation = std::string(DefLoc.getFilename()) + ":" +
456  std::to_string(DefLoc.getLine()) + ":" +
457  std::to_string(DefLoc.getColumn());
458  }
459  const PresumedLoc PoiLoc =
460  TheSema.getSourceManager().getPresumedLoc(Inst.PointOfInstantiation);
461  if (!PoiLoc.isInvalid()) {
462  Entry.PointOfInstantiation = std::string(PoiLoc.getFilename()) + ":" +
463  std::to_string(PoiLoc.getLine()) + ":" +
464  std::to_string(PoiLoc.getColumn());
465  }
466  return Entry;
467  }
468 };
469 } // namespace
470 
471 std::unique_ptr<ASTConsumer>
473  return llvm::make_unique<ASTConsumer>();
474 }
475 
478 
479  // This part is normally done by ASTFrontEndAction, but needs to happen
480  // before Templight observers can be created
481  // FIXME: Move the truncation aspect of this into Sema, we delayed this till
482  // here so the source manager would be initialized.
483  EnsureSemaIsCreated(CI, *this);
484 
485  CI.getSema().TemplateInstCallbacks.push_back(
486  llvm::make_unique<DefaultTemplateInstCallback>());
488 }
489 
490 namespace {
491  /// AST reader listener that dumps module information for a module
492  /// file.
493  class DumpModuleInfoListener : public ASTReaderListener {
494  llvm::raw_ostream &Out;
495 
496  public:
497  DumpModuleInfoListener(llvm::raw_ostream &Out) : Out(Out) { }
498 
499 #define DUMP_BOOLEAN(Value, Text) \
500  Out.indent(4) << Text << ": " << (Value? "Yes" : "No") << "\n"
501 
502  bool ReadFullVersionInformation(StringRef FullVersion) override {
503  Out.indent(2)
504  << "Generated by "
505  << (FullVersion == getClangFullRepositoryVersion()? "this"
506  : "a different")
507  << " Clang: " << FullVersion << "\n";
509  }
510 
511  void ReadModuleName(StringRef ModuleName) override {
512  Out.indent(2) << "Module name: " << ModuleName << "\n";
513  }
514  void ReadModuleMapFile(StringRef ModuleMapPath) override {
515  Out.indent(2) << "Module map file: " << ModuleMapPath << "\n";
516  }
517 
518  bool ReadLanguageOptions(const LangOptions &LangOpts, bool Complain,
519  bool AllowCompatibleDifferences) override {
520  Out.indent(2) << "Language options:\n";
521 #define LANGOPT(Name, Bits, Default, Description) \
522  DUMP_BOOLEAN(LangOpts.Name, Description);
523 #define ENUM_LANGOPT(Name, Type, Bits, Default, Description) \
524  Out.indent(4) << Description << ": " \
525  << static_cast<unsigned>(LangOpts.get##Name()) << "\n";
526 #define VALUE_LANGOPT(Name, Bits, Default, Description) \
527  Out.indent(4) << Description << ": " << LangOpts.Name << "\n";
528 #define BENIGN_LANGOPT(Name, Bits, Default, Description)
529 #define BENIGN_ENUM_LANGOPT(Name, Type, Bits, Default, Description)
530 #include "clang/Basic/LangOptions.def"
531 
532  if (!LangOpts.ModuleFeatures.empty()) {
533  Out.indent(4) << "Module features:\n";
534  for (StringRef Feature : LangOpts.ModuleFeatures)
535  Out.indent(6) << Feature << "\n";
536  }
537 
538  return false;
539  }
540 
541  bool ReadTargetOptions(const TargetOptions &TargetOpts, bool Complain,
542  bool AllowCompatibleDifferences) override {
543  Out.indent(2) << "Target options:\n";
544  Out.indent(4) << " Triple: " << TargetOpts.Triple << "\n";
545  Out.indent(4) << " CPU: " << TargetOpts.CPU << "\n";
546  Out.indent(4) << " ABI: " << TargetOpts.ABI << "\n";
547 
548  if (!TargetOpts.FeaturesAsWritten.empty()) {
549  Out.indent(4) << "Target features:\n";
550  for (unsigned I = 0, N = TargetOpts.FeaturesAsWritten.size();
551  I != N; ++I) {
552  Out.indent(6) << TargetOpts.FeaturesAsWritten[I] << "\n";
553  }
554  }
555 
556  return false;
557  }
558 
559  bool ReadDiagnosticOptions(IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts,
560  bool Complain) override {
561  Out.indent(2) << "Diagnostic options:\n";
562 #define DIAGOPT(Name, Bits, Default) DUMP_BOOLEAN(DiagOpts->Name, #Name);
563 #define ENUM_DIAGOPT(Name, Type, Bits, Default) \
564  Out.indent(4) << #Name << ": " << DiagOpts->get##Name() << "\n";
565 #define VALUE_DIAGOPT(Name, Bits, Default) \
566  Out.indent(4) << #Name << ": " << DiagOpts->Name << "\n";
567 #include "clang/Basic/DiagnosticOptions.def"
568 
569  Out.indent(4) << "Diagnostic flags:\n";
570  for (const std::string &Warning : DiagOpts->Warnings)
571  Out.indent(6) << "-W" << Warning << "\n";
572  for (const std::string &Remark : DiagOpts->Remarks)
573  Out.indent(6) << "-R" << Remark << "\n";
574 
575  return false;
576  }
577 
578  bool ReadHeaderSearchOptions(const HeaderSearchOptions &HSOpts,
579  StringRef SpecificModuleCachePath,
580  bool Complain) override {
581  Out.indent(2) << "Header search options:\n";
582  Out.indent(4) << "System root [-isysroot=]: '" << HSOpts.Sysroot << "'\n";
583  Out.indent(4) << "Resource dir [ -resource-dir=]: '" << HSOpts.ResourceDir << "'\n";
584  Out.indent(4) << "Module Cache: '" << SpecificModuleCachePath << "'\n";
586  "Use builtin include directories [-nobuiltininc]");
588  "Use standard system include directories [-nostdinc]");
590  "Use standard C++ include directories [-nostdinc++]");
591  DUMP_BOOLEAN(HSOpts.UseLibcxx,
592  "Use libc++ (rather than libstdc++) [-stdlib=]");
593  return false;
594  }
595 
596  bool ReadPreprocessorOptions(const PreprocessorOptions &PPOpts,
597  bool Complain,
598  std::string &SuggestedPredefines) override {
599  Out.indent(2) << "Preprocessor options:\n";
601  "Uses compiler/target-specific predefines [-undef]");
603  "Uses detailed preprocessing record (for indexing)");
604 
605  if (!PPOpts.Macros.empty()) {
606  Out.indent(4) << "Predefined macros:\n";
607  }
608 
609  for (std::vector<std::pair<std::string, bool/*isUndef*/> >::const_iterator
610  I = PPOpts.Macros.begin(), IEnd = PPOpts.Macros.end();
611  I != IEnd; ++I) {
612  Out.indent(6);
613  if (I->second)
614  Out << "-U";
615  else
616  Out << "-D";
617  Out << I->first << "\n";
618  }
619  return false;
620  }
621 
622  /// Indicates that a particular module file extension has been read.
623  void readModuleFileExtension(
624  const ModuleFileExtensionMetadata &Metadata) override {
625  Out.indent(2) << "Module file extension '"
626  << Metadata.BlockName << "' " << Metadata.MajorVersion
627  << "." << Metadata.MinorVersion;
628  if (!Metadata.UserInfo.empty()) {
629  Out << ": ";
630  Out.write_escaped(Metadata.UserInfo);
631  }
632 
633  Out << "\n";
634  }
635 
636  /// Tells the \c ASTReaderListener that we want to receive the
637  /// input files of the AST file via \c visitInputFile.
638  bool needsInputFileVisitation() override { return true; }
639 
640  /// Tells the \c ASTReaderListener that we want to receive the
641  /// input files of the AST file via \c visitInputFile.
642  bool needsSystemInputFileVisitation() override { return true; }
643 
644  /// Indicates that the AST file contains particular input file.
645  ///
646  /// \returns true to continue receiving the next input file, false to stop.
647  bool visitInputFile(StringRef Filename, bool isSystem,
648  bool isOverridden, bool isExplicitModule) override {
649 
650  Out.indent(2) << "Input file: " << Filename;
651 
652  if (isSystem || isOverridden || isExplicitModule) {
653  Out << " [";
654  if (isSystem) {
655  Out << "System";
656  if (isOverridden || isExplicitModule)
657  Out << ", ";
658  }
659  if (isOverridden) {
660  Out << "Overridden";
661  if (isExplicitModule)
662  Out << ", ";
663  }
664  if (isExplicitModule)
665  Out << "ExplicitModule";
666 
667  Out << "]";
668  }
669 
670  Out << "\n";
671 
672  return true;
673  }
674 
675  /// Returns true if this \c ASTReaderListener wants to receive the
676  /// imports of the AST file via \c visitImport, false otherwise.
677  bool needsImportVisitation() const override { return true; }
678 
679  /// If needsImportVisitation returns \c true, this is called for each
680  /// AST file imported by this AST file.
681  void visitImport(StringRef ModuleName, StringRef Filename) override {
682  Out.indent(2) << "Imports module '" << ModuleName
683  << "': " << Filename.str() << "\n";
684  }
685 #undef DUMP_BOOLEAN
686  };
687 }
688 
690  // The Object file reader also supports raw ast files and there is no point in
691  // being strict about the module file format in -module-file-info mode.
692  CI.getHeaderSearchOpts().ModuleFormat = "obj";
693  return true;
694 }
695 
697  // Set up the output file.
698  std::unique_ptr<llvm::raw_fd_ostream> OutFile;
699  StringRef OutputFileName = getCompilerInstance().getFrontendOpts().OutputFile;
700  if (!OutputFileName.empty() && OutputFileName != "-") {
701  std::error_code EC;
702  OutFile.reset(new llvm::raw_fd_ostream(OutputFileName.str(), EC,
703  llvm::sys::fs::F_Text));
704  }
705  llvm::raw_ostream &Out = OutFile.get()? *OutFile.get() : llvm::outs();
706 
707  Out << "Information for module file '" << getCurrentFile() << "':\n";
708  auto &FileMgr = getCompilerInstance().getFileManager();
709  auto Buffer = FileMgr.getBufferForFile(getCurrentFile());
710  StringRef Magic = (*Buffer)->getMemBufferRef().getBuffer();
711  bool IsRaw = (Magic.size() >= 4 && Magic[0] == 'C' && Magic[1] == 'P' &&
712  Magic[2] == 'C' && Magic[3] == 'H');
713  Out << " Module format: " << (IsRaw ? "raw" : "obj") << "\n";
714 
716  DumpModuleInfoListener Listener(Out);
717  HeaderSearchOptions &HSOpts =
718  PP.getHeaderSearchInfo().getHeaderSearchOpts();
720  getCurrentFile(), FileMgr, getCompilerInstance().getPCHContainerReader(),
721  /*FindModuleFileExtensions=*/true, Listener,
723 }
724 
725 //===----------------------------------------------------------------------===//
726 // Preprocessor Actions
727 //===----------------------------------------------------------------------===//
728 
732 
733  // Start lexing the specified input file.
734  const llvm::MemoryBuffer *FromFile = SM.getBuffer(SM.getMainFileID());
735  Lexer RawLex(SM.getMainFileID(), FromFile, SM, PP.getLangOpts());
736  RawLex.SetKeepWhitespaceMode(true);
737 
738  Token RawTok;
739  RawLex.LexFromRawLexer(RawTok);
740  while (RawTok.isNot(tok::eof)) {
741  PP.DumpToken(RawTok, true);
742  llvm::errs() << "\n";
743  RawLex.LexFromRawLexer(RawTok);
744  }
745 }
746 
749  // Start preprocessing the specified input file.
750  Token Tok;
751  PP.EnterMainSourceFile();
752  do {
753  PP.Lex(Tok);
754  PP.DumpToken(Tok, true);
755  llvm::errs() << "\n";
756  } while (Tok.isNot(tok::eof));
757 }
758 
761  std::unique_ptr<raw_pwrite_stream> OS =
763  if (!OS)
764  return;
765 
766  CacheTokens(CI.getPreprocessor(), OS.get());
767 }
768 
771 
772  // Ignore unknown pragmas.
773  PP.IgnorePragmas();
774 
775  Token Tok;
776  // Start parsing the specified input file.
777  PP.EnterMainSourceFile();
778  do {
779  PP.Lex(Tok);
780  } while (Tok.isNot(tok::eof));
781 }
782 
785  // Output file may need to be set to 'Binary', to avoid converting Unix style
786  // line feeds (<LF>) to Microsoft style line feeds (<CR><LF>).
787  //
788  // Look to see what type of line endings the file uses. If there's a
789  // CRLF, then we won't open the file up in binary mode. If there is
790  // just an LF or CR, then we will open the file up in binary mode.
791  // In this fashion, the output format should match the input format, unless
792  // the input format has inconsistent line endings.
793  //
794  // This should be a relatively fast operation since most files won't have
795  // all of their source code on a single line. However, that is still a
796  // concern, so if we scan for too long, we'll just assume the file should
797  // be opened in binary mode.
798  bool BinaryMode = true;
799  bool InvalidFile = false;
800  const SourceManager& SM = CI.getSourceManager();
801  const llvm::MemoryBuffer *Buffer = SM.getBuffer(SM.getMainFileID(),
802  &InvalidFile);
803  if (!InvalidFile) {
804  const char *cur = Buffer->getBufferStart();
805  const char *end = Buffer->getBufferEnd();
806  const char *next = (cur != end) ? cur + 1 : end;
807 
808  // Limit ourselves to only scanning 256 characters into the source
809  // file. This is mostly a sanity check in case the file has no
810  // newlines whatsoever.
811  if (end - cur > 256) end = cur + 256;
812 
813  while (next < end) {
814  if (*cur == 0x0D) { // CR
815  if (*next == 0x0A) // CRLF
816  BinaryMode = false;
817 
818  break;
819  } else if (*cur == 0x0A) // LF
820  break;
821 
822  ++cur;
823  ++next;
824  }
825  }
826 
827  std::unique_ptr<raw_ostream> OS =
829  if (!OS) return;
830 
831  // If we're preprocessing a module map, start by dumping the contents of the
832  // module itself before switching to the input buffer.
833  auto &Input = getCurrentInput();
834  if (Input.getKind().getFormat() == InputKind::ModuleMap) {
835  if (Input.isFile()) {
836  (*OS) << "# 1 \"";
837  OS->write_escaped(Input.getFile());
838  (*OS) << "\"\n";
839  }
840  getCurrentModule()->print(*OS);
841  (*OS) << "#pragma clang module contents\n";
842  }
843 
846 }
847 
849  switch (getCurrentFileKind().getLanguage()) {
850  case InputKind::C:
851  case InputKind::CXX:
852  case InputKind::ObjC:
853  case InputKind::ObjCXX:
854  case InputKind::OpenCL:
855  case InputKind::CUDA:
856  case InputKind::HIP:
857  break;
858 
859  case InputKind::Unknown:
860  case InputKind::Asm:
861  case InputKind::LLVM_IR:
863  // We can't do anything with these.
864  return;
865  }
866 
867  // We don't expect to find any #include directives in a preprocessed input.
868  if (getCurrentFileKind().isPreprocessed())
869  return;
870 
872  auto Buffer = CI.getFileManager().getBufferForFile(getCurrentFile());
873  if (Buffer) {
874  unsigned Preamble =
875  Lexer::ComputePreamble((*Buffer)->getBuffer(), CI.getLangOpts()).Size;
876  llvm::outs().write((*Buffer)->getBufferStart(), Preamble);
877  }
878 }
879 
880 void DumpCompilerOptionsAction::ExecuteAction() {
882  std::unique_ptr<raw_ostream> OSP =
884  if (!OSP)
885  return;
886 
887  raw_ostream &OS = *OSP;
888  const Preprocessor &PP = CI.getPreprocessor();
889  const LangOptions &LangOpts = PP.getLangOpts();
890 
891  // FIXME: Rather than manually format the JSON (which is awkward due to
892  // needing to remove trailing commas), this should make use of a JSON library.
893  // FIXME: Instead of printing enums as an integral value and specifying the
894  // type as a separate field, use introspection to print the enumerator.
895 
896  OS << "{\n";
897  OS << "\n\"features\" : [\n";
898  {
900 #define FEATURE(Name, Predicate) \
901  ("\t{\"" #Name "\" : " + llvm::Twine(Predicate ? "true" : "false") + "},\n") \
902  .toVector(Str);
903 #include "clang/Basic/Features.def"
904 #undef FEATURE
905  // Remove the newline and comma from the last entry to ensure this remains
906  // valid JSON.
907  OS << Str.substr(0, Str.size() - 2);
908  }
909  OS << "\n],\n";
910 
911  OS << "\n\"extensions\" : [\n";
912  {
914 #define EXTENSION(Name, Predicate) \
915  ("\t{\"" #Name "\" : " + llvm::Twine(Predicate ? "true" : "false") + "},\n") \
916  .toVector(Str);
917 #include "clang/Basic/Features.def"
918 #undef EXTENSION
919  // Remove the newline and comma from the last entry to ensure this remains
920  // valid JSON.
921  OS << Str.substr(0, Str.size() - 2);
922  }
923  OS << "\n]\n";
924 
925  OS << "}";
926 }
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...
Definition: Lexer.h:77
unsigned UseLibcxx
Use libc++ instead of the default libstdc++.
std::vector< std::unique_ptr< TemplateInstantiationCallback > > TemplateInstCallbacks
The template instantiation callbacks to trace or track instantiations (objects can be chained)...
Definition: Sema.h:7296
Defines the clang::FileManager interface and associated types.
DominatorTree GraphTraits specialization so the DominatorTree can be iterable by generic graph iterat...
Definition: Dominators.h:30
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.
Definition: Diagnostic.h:1294
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.
Definition: LangOptions.h:80
void IgnorePragmas()
Install empty handlers for all pragmas (making them ignored).
Definition: Pragma.cpp:1855
Options for controlling the target.
Definition: TargetOptions.h:26
A context in which code is being synthesized (where a source location alone is not sufficient to iden...
Definition: Sema.h:7123
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()
Definition: Module.h:574
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.
Definition: Token.h:35
The client can handle an AST file that cannot load because it&#39;s compiled configuration doesn&#39;t match ...
Definition: ASTReader.h:1525
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Definition: LangOptions.h:50
void ExecuteAction() override
Callback to run the program action, using the initialized compiler instance.
const LangOptions & getLangOpts() const
Definition: Preprocessor.h:827
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.
Languages that the frontend can parse and compile.
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
std::string UserInfo
A string containing additional user information that will be stored with the metadata.
const PCHContainerWriter & getPCHContainerWriter() const
Return the appropriate PCHContainerWriter depending on the current CodeGenOptions.
HeaderSearch & getHeaderSearchInfo() const
Definition: Preprocessor.h:833
std::string getCachedModuleFileName(Module *Module)
Retrieve the name of the cached module file that should be used to load the given module...
FrontendOptions & getFrontendOpts()
const FormatToken & Tok
static void mapping(IO &io, TemplightEntry &fields)
StringRef getCurrentFileOrBufferName() const
PreprocessorOutputOptions & getPreprocessorOutputOpts()
std::string ResourceDir
The directory which holds the compiler resource files (builtin includes, etc.).
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...
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
Definition: Sema.h:1212
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 &#39;requires&#39; decls in addition to the hard-coded list in ...
Definition: LangOptions.h:200
Encapsulates the information needed to find the file referenced by a #include or #include_next, (sub-)framework lookup, etc.
Definition: HeaderSearch.h:148
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.
Definition: Sema.h:277
std::string CurrentModule
The name of the current module, of which the main source file is a part.
Definition: LangOptions.h:194
StringRef Filename
Definition: Format.cpp:1602
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.
Definition: Lexer.cpp:574
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.
Definition: LangOptions.h:77
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.
Definition: Module.cpp:405
Defines the clang::Preprocessor interface.
unsigned UseBuiltinIncludes
Include the compiler builtin includes.
Represents an unpacked "presumed" location which can be presented to the user.
An input file for the front end.
InputKind getCurrentFileKind() const
const SourceManager & SM
Definition: Format.cpp:1472
unsigned MajorVersion
The major version of the extension data.
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 ...
unsigned MinorVersion
The minor version of the extension data.
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.
Definition: TargetOptions.h:36
SourceManager & getSourceManager() const
Definition: Preprocessor.h:831
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.
Kind
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.
Definition: TargetOptions.h:42
File is a PCH file treated as the preamble.
Definition: Module.h:54
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.
unsigned UseStandardSystemIncludes
Include the system standard include search directories.
void atTemplateBegin(TemplateInstantiationCallbackPtrs &Callbacks, const Sema &TheSema, const Sema::CodeSynthesisContext &Inst)
Assembly: we accept this only so that we can preprocess it.
File is a PCH file treated as such.
Definition: Module.h:51
ParsedSourceLocation CodeCompletionAt
If given, enable code completion at the provided location.
virtual TranslationUnitKind getTranslationUnitKind()
For AST-based actions, the kind of translation unit we&#39;re handling.
LLVM IR: we accept this so that we can run the optimizer on it, and compile it to assembly or object ...
std::vector< FrontendInputFile > Inputs
The input files and their types.
Cached information about one file (either on disk or in the virtual file system). ...
Definition: FileManager.h:59
std::string getClangFullRepositoryVersion()
Retrieves the full repository version that is an amalgamation of the information in getClangRepositor...
Definition: Version.cpp:90
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.
Definition: ASTReader.h:135
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...
Definition: TargetOptions.h:51
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
Definition: Token.h:96
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.
Definition: ASTReader.h:355
FileID getMainFileID() const
Returns the FileID of the main source file.
StringRef getCurrentFile() const
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 BlockName
The name used to identify this particular extension block within the resulting module file...
std::string toString(const til::SExpr *E)
Abstract interface for callback invocations by the ASTReader.
Definition: ASTReader.h:127
std::unique_ptr< ASTConsumer > CreateDeclContextPrinter()
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&#39;s options) and add it to the list of tracked outp...
std::unique_ptr< ASTConsumer > CreateASTViewer()
Metadata for a module file extension.
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
Definition: Sema.h:1217
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.
HeaderSearchOptions - Helper class for storing options related to the initialization of the HeaderSea...
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.
Definition: ASTReader.cpp:4718
std::string Sysroot
If non-empty, the directory to use as a "virtual system root" for include paths.
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.
unsigned UseStandardCXXIncludes
Include the system standard C++ library include search directories.
void SetKeepWhitespaceMode(bool Val)
SetKeepWhitespaceMode - This method lets clients enable or disable whitespace retention mode...
Definition: Lexer.h:213
std::string Triple
The name of the target triple to compile for.
Definition: TargetOptions.h:29
bool isSystem(CharacteristicKind CK)
Determine whether a file / directory characteristic is for system code.
Definition: SourceManager.h:83
This class handles loading and caching of source files into memory.
std::string ModuleFormat
The module/pch container format.
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
Definition: Preprocessor.h:127
void ExecuteAction() override
Implement the ExecuteAction interface by running Sema on the already-initialized AST consumer...