clang  15.0.0git
FrontendActions.cpp
Go to the documentation of this file.
1 //===--- FrontendActions.cpp ----------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
10 #include "clang/AST/ASTConsumer.h"
11 #include "clang/AST/Decl.h"
14 #include "clang/Basic/Module.h"
15 #include "clang/Basic/TargetInfo.h"
20 #include "clang/Frontend/Utils.h"
22 #include "clang/Lex/HeaderSearch.h"
23 #include "clang/Lex/Preprocessor.h"
29 #include "llvm/Support/ErrorHandling.h"
30 #include "llvm/Support/FileSystem.h"
31 #include "llvm/Support/MemoryBuffer.h"
32 #include "llvm/Support/Path.h"
33 #include "llvm/Support/YAMLTraits.h"
34 #include "llvm/Support/raw_ostream.h"
35 #include <memory>
36 #include <system_error>
37 
38 using namespace clang;
39 
40 namespace {
41 CodeCompleteConsumer *GetCodeCompletionConsumer(CompilerInstance &CI) {
43  : nullptr;
44 }
45 
46 void EnsureSemaIsCreated(CompilerInstance &CI, FrontendAction &Action) {
47  if (Action.hasCodeCompletionSupport() &&
50 
51  if (!CI.hasSema())
53  GetCodeCompletionConsumer(CI));
54 }
55 } // namespace
56 
57 //===----------------------------------------------------------------------===//
58 // Custom Actions
59 //===----------------------------------------------------------------------===//
60 
61 std::unique_ptr<ASTConsumer>
62 InitOnlyAction::CreateASTConsumer(CompilerInstance &CI, StringRef InFile) {
63  return std::make_unique<ASTConsumer>();
64 }
65 
66 void InitOnlyAction::ExecuteAction() {
67 }
68 
69 // Basically PreprocessOnlyAction::ExecuteAction.
70 void ReadPCHAndPreprocessAction::ExecuteAction() {
72 
73  // Ignore unknown pragmas.
74  PP.IgnorePragmas();
75 
76  Token Tok;
77  // Start parsing the specified input file.
79  do {
80  PP.Lex(Tok);
81  } while (Tok.isNot(tok::eof));
82 }
83 
84 std::unique_ptr<ASTConsumer>
85 ReadPCHAndPreprocessAction::CreateASTConsumer(CompilerInstance &CI,
86  StringRef InFile) {
87  return std::make_unique<ASTConsumer>();
88 }
89 
90 //===----------------------------------------------------------------------===//
91 // AST Consumer Actions
92 //===----------------------------------------------------------------------===//
93 
94 std::unique_ptr<ASTConsumer>
96  if (std::unique_ptr<raw_ostream> OS =
97  CI.createDefaultOutputFile(false, InFile))
98  return CreateASTPrinter(std::move(OS), CI.getFrontendOpts().ASTDumpFilter);
99  return nullptr;
100 }
101 
102 std::unique_ptr<ASTConsumer>
104  const FrontendOptions &Opts = CI.getFrontendOpts();
105  return CreateASTDumper(nullptr /*Dump to stdout.*/, Opts.ASTDumpFilter,
106  Opts.ASTDumpDecls, Opts.ASTDumpAll,
107  Opts.ASTDumpLookups, Opts.ASTDumpDeclTypes,
108  Opts.ASTDumpFormat);
109 }
110 
111 std::unique_ptr<ASTConsumer>
113  return CreateASTDeclNodeLister();
114 }
115 
116 std::unique_ptr<ASTConsumer>
118  return CreateASTViewer();
119 }
120 
121 std::unique_ptr<ASTConsumer>
123  std::string Sysroot;
124  if (!ComputeASTConsumerArguments(CI, /*ref*/ Sysroot))
125  return nullptr;
126 
127  std::string OutputFile;
128  std::unique_ptr<raw_pwrite_stream> OS =
129  CreateOutputFile(CI, InFile, /*ref*/ OutputFile);
130  if (!OS)
131  return nullptr;
132 
134  Sysroot.clear();
135 
136  const auto &FrontendOpts = CI.getFrontendOpts();
137  auto Buffer = std::make_shared<PCHBuffer>();
138  std::vector<std::unique_ptr<ASTConsumer>> Consumers;
139  Consumers.push_back(std::make_unique<PCHGenerator>(
140  CI.getPreprocessor(), CI.getModuleCache(), OutputFile, Sysroot, Buffer,
141  FrontendOpts.ModuleFileExtensions,
143  FrontendOpts.IncludeTimestamps, +CI.getLangOpts().CacheGeneratedPCH));
144  Consumers.push_back(CI.getPCHContainerWriter().CreatePCHContainerGenerator(
145  CI, std::string(InFile), OutputFile, std::move(OS), Buffer));
146 
147  return std::make_unique<MultiplexConsumer>(std::move(Consumers));
148 }
149 
151  std::string &Sysroot) {
152  Sysroot = CI.getHeaderSearchOpts().Sysroot;
153  if (CI.getFrontendOpts().RelocatablePCH && Sysroot.empty()) {
154  CI.getDiagnostics().Report(diag::err_relocatable_without_isysroot);
155  return false;
156  }
157 
158  return true;
159 }
160 
161 std::unique_ptr<llvm::raw_pwrite_stream>
163  std::string &OutputFile) {
164  // Because this is exposed via libclang we must disable RemoveFileOnSignal.
165  std::unique_ptr<raw_pwrite_stream> OS = CI.createDefaultOutputFile(
166  /*Binary=*/true, InFile, /*Extension=*/"", /*RemoveFileOnSignal=*/false);
167  if (!OS)
168  return nullptr;
169 
170  OutputFile = CI.getFrontendOpts().OutputFile;
171  return OS;
172 }
173 
175  if (getCompilerInstance().getPreprocessorOpts().AllowPCHWithCompilerErrors)
176  return false;
178 }
179 
181  CI.getLangOpts().CompilingPCH = true;
182  return true;
183 }
184 
185 std::unique_ptr<ASTConsumer>
187  StringRef InFile) {
188  std::unique_ptr<raw_pwrite_stream> OS = CreateOutputFile(CI, InFile);
189  if (!OS)
190  return nullptr;
191 
192  std::string OutputFile = CI.getFrontendOpts().OutputFile;
193  std::string Sysroot;
194 
195  auto Buffer = std::make_shared<PCHBuffer>();
196  std::vector<std::unique_ptr<ASTConsumer>> Consumers;
197 
198  Consumers.push_back(std::make_unique<PCHGenerator>(
199  CI.getPreprocessor(), CI.getModuleCache(), OutputFile, Sysroot, Buffer,
201  /*AllowASTWithErrors=*/
203  /*IncludeTimestamps=*/
205  /*ShouldCacheASTInMemory=*/
207  Consumers.push_back(CI.getPCHContainerWriter().CreatePCHContainerGenerator(
208  CI, std::string(InFile), OutputFile, std::move(OS), Buffer));
209  return std::make_unique<MultiplexConsumer>(std::move(Consumers));
210 }
211 
215 }
216 
217 bool GenerateModuleFromModuleMapAction::BeginSourceFileAction(
218  CompilerInstance &CI) {
219  if (!CI.getLangOpts().Modules) {
220  CI.getDiagnostics().Report(diag::err_module_build_requires_fmodules);
221  return false;
222  }
223 
225 }
226 
227 std::unique_ptr<raw_pwrite_stream>
228 GenerateModuleFromModuleMapAction::CreateOutputFile(CompilerInstance &CI,
229  StringRef InFile) {
230  // If no output file was provided, figure out where this module would go
231  // in the module cache.
232  if (CI.getFrontendOpts().OutputFile.empty()) {
233  StringRef ModuleMapFile = CI.getFrontendOpts().OriginalModuleMap;
234  if (ModuleMapFile.empty())
235  ModuleMapFile = InFile;
236 
240  ModuleMapFile);
241  }
242 
243  // Because this is exposed via libclang we must disable RemoveFileOnSignal.
244  return CI.createDefaultOutputFile(/*Binary=*/true, InFile, /*Extension=*/"",
245  /*RemoveFileOnSignal=*/false,
246  /*CreateMissingDirectories=*/true,
247  /*ForceUseTemporary=*/true);
248 }
249 
250 bool GenerateModuleInterfaceAction::BeginSourceFileAction(
251  CompilerInstance &CI) {
252  if (!CI.getLangOpts().ModulesTS && !CI.getLangOpts().CPlusPlusModules) {
253  CI.getDiagnostics().Report(diag::err_module_interface_requires_cpp_modules);
254  return false;
255  }
256 
257  CI.getLangOpts().setCompilingModule(LangOptions::CMK_ModuleInterface);
258 
260 }
261 
262 std::unique_ptr<raw_pwrite_stream>
263 GenerateModuleInterfaceAction::CreateOutputFile(CompilerInstance &CI,
264  StringRef InFile) {
265  return CI.createDefaultOutputFile(/*Binary=*/true, InFile, "pcm");
266 }
267 
268 bool GenerateHeaderModuleAction::PrepareToExecuteAction(
269  CompilerInstance &CI) {
270  if (!CI.getLangOpts().Modules) {
271  CI.getDiagnostics().Report(diag::err_header_module_requires_modules);
272  return false;
273  }
274 
275  auto &Inputs = CI.getFrontendOpts().Inputs;
276  if (Inputs.empty())
278 
279  auto Kind = Inputs[0].getKind();
280 
281  // Convert the header file inputs into a single module input buffer.
282  SmallString<256> HeaderContents;
283  ModuleHeaders.reserve(Inputs.size());
284  for (const FrontendInputFile &FIF : Inputs) {
285  // FIXME: We should support re-compiling from an AST file.
286  if (FIF.getKind().getFormat() != InputKind::Source || !FIF.isFile()) {
287  CI.getDiagnostics().Report(diag::err_module_header_file_not_found)
288  << (FIF.isFile() ? FIF.getFile()
289  : FIF.getBuffer().getBufferIdentifier());
290  return true;
291  }
292 
293  HeaderContents += "#include \"";
294  HeaderContents += FIF.getFile();
295  HeaderContents += "\"\n";
296  ModuleHeaders.push_back(std::string(FIF.getFile()));
297  }
298  Buffer = llvm::MemoryBuffer::getMemBufferCopy(
299  HeaderContents, Module::getModuleInputBufferName());
300 
301  // Set that buffer up as our "real" input.
302  Inputs.clear();
303  Inputs.push_back(
304  FrontendInputFile(Buffer->getMemBufferRef(), Kind, /*IsSystem*/ false));
305 
307 }
308 
309 bool GenerateHeaderModuleAction::BeginSourceFileAction(
310  CompilerInstance &CI) {
311  CI.getLangOpts().setCompilingModule(LangOptions::CMK_HeaderModule);
312 
313  // Synthesize a Module object for the given headers.
314  auto &HS = CI.getPreprocessor().getHeaderSearchInfo();
316  for (StringRef Name : ModuleHeaders) {
318  Name, SourceLocation(), /*Angled*/ false, nullptr, nullptr, None,
319  nullptr, nullptr, nullptr, nullptr, nullptr, nullptr);
320  if (!FE) {
321  CI.getDiagnostics().Report(diag::err_module_header_file_not_found)
322  << Name;
323  continue;
324  }
325  Headers.push_back(
326  {std::string(Name), std::string(Name), &FE->getFileEntry()});
327  }
329 
331 }
332 
333 std::unique_ptr<raw_pwrite_stream>
334 GenerateHeaderModuleAction::CreateOutputFile(CompilerInstance &CI,
335  StringRef InFile) {
336  return CI.createDefaultOutputFile(/*Binary=*/true, InFile, "pcm");
337 }
338 
339 bool GenerateHeaderUnitAction::BeginSourceFileAction(CompilerInstance &CI) {
340  if (!CI.getLangOpts().CPlusPlusModules) {
341  CI.getDiagnostics().Report(diag::err_module_interface_requires_cpp_modules);
342  return false;
343  }
344  CI.getLangOpts().setCompilingModule(LangOptions::CMK_HeaderUnit);
346 }
347 
348 std::unique_ptr<raw_pwrite_stream>
349 GenerateHeaderUnitAction::CreateOutputFile(CompilerInstance &CI,
350  StringRef InFile) {
351  return CI.createDefaultOutputFile(/*Binary=*/true, InFile, "pcm");
352 }
353 
355 }
356 
357 std::unique_ptr<ASTConsumer>
359  return std::make_unique<ASTConsumer>();
360 }
361 
362 std::unique_ptr<ASTConsumer>
364  StringRef InFile) {
365  return std::make_unique<ASTConsumer>();
366 }
367 
368 std::unique_ptr<ASTConsumer>
370  return std::make_unique<ASTConsumer>();
371 }
372 
376  const std::string &Sysroot = CI.getHeaderSearchOpts().Sysroot;
377  std::unique_ptr<ASTReader> Reader(new ASTReader(
378  CI.getPreprocessor(), CI.getModuleCache(), &CI.getASTContext(),
380  Sysroot.empty() ? "" : Sysroot.c_str(),
382  /*AllowASTWithCompilerErrors*/ false,
383  /*AllowConfigurationMismatch*/ true,
384  /*ValidateSystemInputs*/ true));
385 
386  Reader->ReadAST(getCurrentFile(),
389  SourceLocation(),
391 }
392 
393 namespace {
394 struct TemplightEntry {
395  std::string Name;
397  std::string Event;
398  std::string DefinitionLocation;
399  std::string PointOfInstantiation;
400 };
401 } // namespace
402 
403 namespace llvm {
404 namespace yaml {
405 template <> struct MappingTraits<TemplightEntry> {
406  static void mapping(IO &io, TemplightEntry &fields) {
407  io.mapRequired("name", fields.Name);
408  io.mapRequired("kind", fields.Kind);
409  io.mapRequired("event", fields.Event);
410  io.mapRequired("orig", fields.DefinitionLocation);
411  io.mapRequired("poi", fields.PointOfInstantiation);
412  }
413 };
414 } // namespace yaml
415 } // namespace llvm
416 
417 namespace {
418 class DefaultTemplateInstCallback : public TemplateInstantiationCallback {
419  using CodeSynthesisContext = Sema::CodeSynthesisContext;
420 
421 public:
422  void initialize(const Sema &) override {}
423 
424  void finalize(const Sema &) override {}
425 
426  void atTemplateBegin(const Sema &TheSema,
427  const CodeSynthesisContext &Inst) override {
428  displayTemplightEntry<true>(llvm::outs(), TheSema, Inst);
429  }
430 
431  void atTemplateEnd(const Sema &TheSema,
432  const CodeSynthesisContext &Inst) override {
433  displayTemplightEntry<false>(llvm::outs(), TheSema, Inst);
434  }
435 
436 private:
437  static std::string toString(CodeSynthesisContext::SynthesisKind Kind) {
438  switch (Kind) {
439  case CodeSynthesisContext::TemplateInstantiation:
440  return "TemplateInstantiation";
441  case CodeSynthesisContext::DefaultTemplateArgumentInstantiation:
442  return "DefaultTemplateArgumentInstantiation";
443  case CodeSynthesisContext::DefaultFunctionArgumentInstantiation:
444  return "DefaultFunctionArgumentInstantiation";
445  case CodeSynthesisContext::ExplicitTemplateArgumentSubstitution:
446  return "ExplicitTemplateArgumentSubstitution";
447  case CodeSynthesisContext::DeducedTemplateArgumentSubstitution:
448  return "DeducedTemplateArgumentSubstitution";
449  case CodeSynthesisContext::PriorTemplateArgumentSubstitution:
450  return "PriorTemplateArgumentSubstitution";
451  case CodeSynthesisContext::DefaultTemplateArgumentChecking:
452  return "DefaultTemplateArgumentChecking";
453  case CodeSynthesisContext::ExceptionSpecEvaluation:
454  return "ExceptionSpecEvaluation";
455  case CodeSynthesisContext::ExceptionSpecInstantiation:
456  return "ExceptionSpecInstantiation";
457  case CodeSynthesisContext::DeclaringSpecialMember:
458  return "DeclaringSpecialMember";
459  case CodeSynthesisContext::DeclaringImplicitEqualityComparison:
460  return "DeclaringImplicitEqualityComparison";
461  case CodeSynthesisContext::DefiningSynthesizedFunction:
462  return "DefiningSynthesizedFunction";
463  case CodeSynthesisContext::RewritingOperatorAsSpaceship:
464  return "RewritingOperatorAsSpaceship";
465  case CodeSynthesisContext::Memoization:
466  return "Memoization";
467  case CodeSynthesisContext::ConstraintsCheck:
468  return "ConstraintsCheck";
469  case CodeSynthesisContext::ConstraintSubstitution:
470  return "ConstraintSubstitution";
471  case CodeSynthesisContext::ConstraintNormalization:
472  return "ConstraintNormalization";
473  case CodeSynthesisContext::ParameterMappingSubstitution:
474  return "ParameterMappingSubstitution";
475  case CodeSynthesisContext::RequirementInstantiation:
476  return "RequirementInstantiation";
477  case CodeSynthesisContext::NestedRequirementConstraintsCheck:
478  return "NestedRequirementConstraintsCheck";
479  case CodeSynthesisContext::InitializingStructuredBinding:
480  return "InitializingStructuredBinding";
481  case CodeSynthesisContext::MarkingClassDllexported:
482  return "MarkingClassDllexported";
483  case CodeSynthesisContext::BuildingBuiltinDumpStructCall:
484  return "BuildingBuiltinDumpStructCall";
485  }
486  return "";
487  }
488 
489  template <bool BeginInstantiation>
490  static void displayTemplightEntry(llvm::raw_ostream &Out, const Sema &TheSema,
491  const CodeSynthesisContext &Inst) {
492  std::string YAML;
493  {
494  llvm::raw_string_ostream OS(YAML);
495  llvm::yaml::Output YO(OS);
496  TemplightEntry Entry =
497  getTemplightEntry<BeginInstantiation>(TheSema, Inst);
498  llvm::yaml::EmptyContext Context;
499  llvm::yaml::yamlize(YO, Entry, true, Context);
500  }
501  Out << "---" << YAML << "\n";
502  }
503 
504  static void printEntryName(const Sema &TheSema, const Decl *Entity,
505  llvm::raw_string_ostream &OS) {
506  auto *NamedTemplate = cast<NamedDecl>(Entity);
507 
508  PrintingPolicy Policy = TheSema.Context.getPrintingPolicy();
509  // FIXME: Also ask for FullyQualifiedNames?
510  Policy.SuppressDefaultTemplateArgs = false;
511  NamedTemplate->getNameForDiagnostic(OS, Policy, true);
512 
513  if (!OS.str().empty())
514  return;
515 
516  Decl *Ctx = Decl::castFromDeclContext(NamedTemplate->getDeclContext());
517  NamedDecl *NamedCtx = dyn_cast_or_null<NamedDecl>(Ctx);
518 
519  if (const auto *Decl = dyn_cast<TagDecl>(NamedTemplate)) {
520  if (const auto *R = dyn_cast<RecordDecl>(Decl)) {
521  if (R->isLambda()) {
522  OS << "lambda at ";
523  Decl->getLocation().print(OS, TheSema.getSourceManager());
524  return;
525  }
526  }
527  OS << "unnamed " << Decl->getKindName();
528  return;
529  }
530 
531  if (const auto *Decl = dyn_cast<ParmVarDecl>(NamedTemplate)) {
532  OS << "unnamed function parameter " << Decl->getFunctionScopeIndex()
533  << " ";
534  if (Decl->getFunctionScopeDepth() > 0)
535  OS << "(at depth " << Decl->getFunctionScopeDepth() << ") ";
536  OS << "of ";
537  NamedCtx->getNameForDiagnostic(OS, TheSema.getLangOpts(), true);
538  return;
539  }
540 
541  if (const auto *Decl = dyn_cast<TemplateTypeParmDecl>(NamedTemplate)) {
542  if (const Type *Ty = Decl->getTypeForDecl()) {
543  if (const auto *TTPT = dyn_cast_or_null<TemplateTypeParmType>(Ty)) {
544  OS << "unnamed template type parameter " << TTPT->getIndex() << " ";
545  if (TTPT->getDepth() > 0)
546  OS << "(at depth " << TTPT->getDepth() << ") ";
547  OS << "of ";
548  NamedCtx->getNameForDiagnostic(OS, TheSema.getLangOpts(), true);
549  return;
550  }
551  }
552  }
553 
554  if (const auto *Decl = dyn_cast<NonTypeTemplateParmDecl>(NamedTemplate)) {
555  OS << "unnamed template non-type parameter " << Decl->getIndex() << " ";
556  if (Decl->getDepth() > 0)
557  OS << "(at depth " << Decl->getDepth() << ") ";
558  OS << "of ";
559  NamedCtx->getNameForDiagnostic(OS, TheSema.getLangOpts(), true);
560  return;
561  }
562 
563  if (const auto *Decl = dyn_cast<TemplateTemplateParmDecl>(NamedTemplate)) {
564  OS << "unnamed template template parameter " << Decl->getIndex() << " ";
565  if (Decl->getDepth() > 0)
566  OS << "(at depth " << Decl->getDepth() << ") ";
567  OS << "of ";
568  NamedCtx->getNameForDiagnostic(OS, TheSema.getLangOpts(), true);
569  return;
570  }
571 
572  llvm_unreachable("Failed to retrieve a name for this entry!");
573  OS << "unnamed identifier";
574  }
575 
576  template <bool BeginInstantiation>
577  static TemplightEntry getTemplightEntry(const Sema &TheSema,
578  const CodeSynthesisContext &Inst) {
579  TemplightEntry Entry;
580  Entry.Kind = toString(Inst.Kind);
581  Entry.Event = BeginInstantiation ? "Begin" : "End";
582  llvm::raw_string_ostream OS(Entry.Name);
583  printEntryName(TheSema, Inst.Entity, OS);
584  const PresumedLoc DefLoc =
585  TheSema.getSourceManager().getPresumedLoc(Inst.Entity->getLocation());
586  if (!DefLoc.isInvalid())
587  Entry.DefinitionLocation = std::string(DefLoc.getFilename()) + ":" +
588  std::to_string(DefLoc.getLine()) + ":" +
589  std::to_string(DefLoc.getColumn());
590  const PresumedLoc PoiLoc =
591  TheSema.getSourceManager().getPresumedLoc(Inst.PointOfInstantiation);
592  if (!PoiLoc.isInvalid()) {
593  Entry.PointOfInstantiation = std::string(PoiLoc.getFilename()) + ":" +
594  std::to_string(PoiLoc.getLine()) + ":" +
595  std::to_string(PoiLoc.getColumn());
596  }
597  return Entry;
598  }
599 };
600 } // namespace
601 
602 std::unique_ptr<ASTConsumer>
604  return std::make_unique<ASTConsumer>();
605 }
606 
609 
610  // This part is normally done by ASTFrontEndAction, but needs to happen
611  // before Templight observers can be created
612  // FIXME: Move the truncation aspect of this into Sema, we delayed this till
613  // here so the source manager would be initialized.
614  EnsureSemaIsCreated(CI, *this);
615 
616  CI.getSema().TemplateInstCallbacks.push_back(
617  std::make_unique<DefaultTemplateInstCallback>());
619 }
620 
621 namespace {
622  /// AST reader listener that dumps module information for a module
623  /// file.
624  class DumpModuleInfoListener : public ASTReaderListener {
625  llvm::raw_ostream &Out;
626 
627  public:
628  DumpModuleInfoListener(llvm::raw_ostream &Out) : Out(Out) { }
629 
630 #define DUMP_BOOLEAN(Value, Text) \
631  Out.indent(4) << Text << ": " << (Value? "Yes" : "No") << "\n"
632 
633  bool ReadFullVersionInformation(StringRef FullVersion) override {
634  Out.indent(2)
635  << "Generated by "
636  << (FullVersion == getClangFullRepositoryVersion()? "this"
637  : "a different")
638  << " Clang: " << FullVersion << "\n";
640  }
641 
642  void ReadModuleName(StringRef ModuleName) override {
643  Out.indent(2) << "Module name: " << ModuleName << "\n";
644  }
645  void ReadModuleMapFile(StringRef ModuleMapPath) override {
646  Out.indent(2) << "Module map file: " << ModuleMapPath << "\n";
647  }
648 
649  bool ReadLanguageOptions(const LangOptions &LangOpts, bool Complain,
650  bool AllowCompatibleDifferences) override {
651  Out.indent(2) << "Language options:\n";
652 #define LANGOPT(Name, Bits, Default, Description) \
653  DUMP_BOOLEAN(LangOpts.Name, Description);
654 #define ENUM_LANGOPT(Name, Type, Bits, Default, Description) \
655  Out.indent(4) << Description << ": " \
656  << static_cast<unsigned>(LangOpts.get##Name()) << "\n";
657 #define VALUE_LANGOPT(Name, Bits, Default, Description) \
658  Out.indent(4) << Description << ": " << LangOpts.Name << "\n";
659 #define BENIGN_LANGOPT(Name, Bits, Default, Description)
660 #define BENIGN_ENUM_LANGOPT(Name, Type, Bits, Default, Description)
661 #include "clang/Basic/LangOptions.def"
662 
663  if (!LangOpts.ModuleFeatures.empty()) {
664  Out.indent(4) << "Module features:\n";
665  for (StringRef Feature : LangOpts.ModuleFeatures)
666  Out.indent(6) << Feature << "\n";
667  }
668 
669  return false;
670  }
671 
672  bool ReadTargetOptions(const TargetOptions &TargetOpts, bool Complain,
673  bool AllowCompatibleDifferences) override {
674  Out.indent(2) << "Target options:\n";
675  Out.indent(4) << " Triple: " << TargetOpts.Triple << "\n";
676  Out.indent(4) << " CPU: " << TargetOpts.CPU << "\n";
677  Out.indent(4) << " TuneCPU: " << TargetOpts.TuneCPU << "\n";
678  Out.indent(4) << " ABI: " << TargetOpts.ABI << "\n";
679 
680  if (!TargetOpts.FeaturesAsWritten.empty()) {
681  Out.indent(4) << "Target features:\n";
682  for (unsigned I = 0, N = TargetOpts.FeaturesAsWritten.size();
683  I != N; ++I) {
684  Out.indent(6) << TargetOpts.FeaturesAsWritten[I] << "\n";
685  }
686  }
687 
688  return false;
689  }
690 
691  bool ReadDiagnosticOptions(IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts,
692  bool Complain) override {
693  Out.indent(2) << "Diagnostic options:\n";
694 #define DIAGOPT(Name, Bits, Default) DUMP_BOOLEAN(DiagOpts->Name, #Name);
695 #define ENUM_DIAGOPT(Name, Type, Bits, Default) \
696  Out.indent(4) << #Name << ": " << DiagOpts->get##Name() << "\n";
697 #define VALUE_DIAGOPT(Name, Bits, Default) \
698  Out.indent(4) << #Name << ": " << DiagOpts->Name << "\n";
699 #include "clang/Basic/DiagnosticOptions.def"
700 
701  Out.indent(4) << "Diagnostic flags:\n";
702  for (const std::string &Warning : DiagOpts->Warnings)
703  Out.indent(6) << "-W" << Warning << "\n";
704  for (const std::string &Remark : DiagOpts->Remarks)
705  Out.indent(6) << "-R" << Remark << "\n";
706 
707  return false;
708  }
709 
710  bool ReadHeaderSearchOptions(const HeaderSearchOptions &HSOpts,
711  StringRef SpecificModuleCachePath,
712  bool Complain) override {
713  Out.indent(2) << "Header search options:\n";
714  Out.indent(4) << "System root [-isysroot=]: '" << HSOpts.Sysroot << "'\n";
715  Out.indent(4) << "Resource dir [ -resource-dir=]: '" << HSOpts.ResourceDir << "'\n";
716  Out.indent(4) << "Module Cache: '" << SpecificModuleCachePath << "'\n";
718  "Use builtin include directories [-nobuiltininc]");
720  "Use standard system include directories [-nostdinc]");
722  "Use standard C++ include directories [-nostdinc++]");
723  DUMP_BOOLEAN(HSOpts.UseLibcxx,
724  "Use libc++ (rather than libstdc++) [-stdlib=]");
725  return false;
726  }
727 
728  bool ReadPreprocessorOptions(const PreprocessorOptions &PPOpts,
729  bool Complain,
730  std::string &SuggestedPredefines) override {
731  Out.indent(2) << "Preprocessor options:\n";
733  "Uses compiler/target-specific predefines [-undef]");
735  "Uses detailed preprocessing record (for indexing)");
736 
737  if (!PPOpts.Macros.empty()) {
738  Out.indent(4) << "Predefined macros:\n";
739  }
740 
741  for (std::vector<std::pair<std::string, bool/*isUndef*/> >::const_iterator
742  I = PPOpts.Macros.begin(), IEnd = PPOpts.Macros.end();
743  I != IEnd; ++I) {
744  Out.indent(6);
745  if (I->second)
746  Out << "-U";
747  else
748  Out << "-D";
749  Out << I->first << "\n";
750  }
751  return false;
752  }
753 
754  /// Indicates that a particular module file extension has been read.
755  void readModuleFileExtension(
756  const ModuleFileExtensionMetadata &Metadata) override {
757  Out.indent(2) << "Module file extension '"
758  << Metadata.BlockName << "' " << Metadata.MajorVersion
759  << "." << Metadata.MinorVersion;
760  if (!Metadata.UserInfo.empty()) {
761  Out << ": ";
762  Out.write_escaped(Metadata.UserInfo);
763  }
764 
765  Out << "\n";
766  }
767 
768  /// Tells the \c ASTReaderListener that we want to receive the
769  /// input files of the AST file via \c visitInputFile.
770  bool needsInputFileVisitation() override { return true; }
771 
772  /// Tells the \c ASTReaderListener that we want to receive the
773  /// input files of the AST file via \c visitInputFile.
774  bool needsSystemInputFileVisitation() override { return true; }
775 
776  /// Indicates that the AST file contains particular input file.
777  ///
778  /// \returns true to continue receiving the next input file, false to stop.
779  bool visitInputFile(StringRef Filename, bool isSystem,
780  bool isOverridden, bool isExplicitModule) override {
781 
782  Out.indent(2) << "Input file: " << Filename;
783 
784  if (isSystem || isOverridden || isExplicitModule) {
785  Out << " [";
786  if (isSystem) {
787  Out << "System";
788  if (isOverridden || isExplicitModule)
789  Out << ", ";
790  }
791  if (isOverridden) {
792  Out << "Overridden";
793  if (isExplicitModule)
794  Out << ", ";
795  }
796  if (isExplicitModule)
797  Out << "ExplicitModule";
798 
799  Out << "]";
800  }
801 
802  Out << "\n";
803 
804  return true;
805  }
806 
807  /// Returns true if this \c ASTReaderListener wants to receive the
808  /// imports of the AST file via \c visitImport, false otherwise.
809  bool needsImportVisitation() const override { return true; }
810 
811  /// If needsImportVisitation returns \c true, this is called for each
812  /// AST file imported by this AST file.
813  void visitImport(StringRef ModuleName, StringRef Filename) override {
814  Out.indent(2) << "Imports module '" << ModuleName
815  << "': " << Filename.str() << "\n";
816  }
817 #undef DUMP_BOOLEAN
818  };
819 }
820 
822  // The Object file reader also supports raw ast files and there is no point in
823  // being strict about the module file format in -module-file-info mode.
824  CI.getHeaderSearchOpts().ModuleFormat = "obj";
825  return true;
826 }
827 
828 static StringRef ModuleKindName(Module::ModuleKind MK) {
829  switch (MK) {
831  return "Module Map Module";
833  return "Interface Unit";
835  return "Partition Interface";
837  return "Partition Implementation";
839  return "Header Unit";
841  return "Global Module Fragment";
843  return "Private Module Fragment";
844  }
845  llvm_unreachable("unknown module kind!");
846 }
847 
849  assert(isCurrentFileAST() && "dumping non-AST?");
850  // Set up the output file.
851  std::unique_ptr<llvm::raw_fd_ostream> OutFile;
852  StringRef OutputFileName = getCompilerInstance().getFrontendOpts().OutputFile;
853  if (!OutputFileName.empty() && OutputFileName != "-") {
854  std::error_code EC;
855  OutFile.reset(new llvm::raw_fd_ostream(OutputFileName.str(), EC,
856  llvm::sys::fs::OF_TextWithCRLF));
857  }
858  llvm::raw_ostream &Out = OutFile.get()? *OutFile.get() : llvm::outs();
859 
860  Out << "Information for module file '" << getCurrentFile() << "':\n";
861  auto &FileMgr = getCompilerInstance().getFileManager();
862  auto Buffer = FileMgr.getBufferForFile(getCurrentFile());
863  StringRef Magic = (*Buffer)->getMemBufferRef().getBuffer();
864  bool IsRaw = (Magic.size() >= 4 && Magic[0] == 'C' && Magic[1] == 'P' &&
865  Magic[2] == 'C' && Magic[3] == 'H');
866  Out << " Module format: " << (IsRaw ? "raw" : "obj") << "\n";
867 
869  DumpModuleInfoListener Listener(Out);
870  HeaderSearchOptions &HSOpts = PP.getHeaderSearchInfo().getHeaderSearchOpts();
871 
872  // The FrontendAction::BeginSourceFile () method loads the AST so that much
873  // of the information is already available and modules should have been
874  // loaded.
875 
876  const LangOptions &LO = getCurrentASTUnit().getLangOpts();
877  if (LO.CPlusPlusModules && !LO.CurrentModule.empty()) {
878 
880  unsigned SubModuleCount = R->getTotalNumSubmodules();
882  Out << " ====== C++20 Module structure ======\n";
883 
884  if (MF.ModuleName != LO.CurrentModule)
885  Out << " Mismatched module names : " << MF.ModuleName << " and "
886  << LO.CurrentModule << "\n";
887 
888  struct SubModInfo {
889  unsigned Idx;
890  Module *Mod;
892  std::string &Name;
893  bool Seen;
894  };
895  std::map<std::string, SubModInfo> SubModMap;
896  auto PrintSubMapEntry = [&](std::string Name, Module::ModuleKind Kind) {
897  Out << " " << ModuleKindName(Kind) << " '" << Name << "'";
898  auto I = SubModMap.find(Name);
899  if (I == SubModMap.end())
900  Out << " was not found in the sub modules!\n";
901  else {
902  I->second.Seen = true;
903  Out << " is at index #" << I->second.Idx << "\n";
904  }
905  };
906  Module *Primary = nullptr;
907  for (unsigned Idx = 0; Idx <= SubModuleCount; ++Idx) {
908  Module *M = R->getModule(Idx);
909  if (!M)
910  continue;
911  if (M->Name == LO.CurrentModule) {
912  Primary = M;
913  Out << " " << ModuleKindName(M->Kind) << " '" << LO.CurrentModule
914  << "' is the Primary Module at index #" << Idx << "\n";
915  SubModMap.insert({M->Name, {Idx, M, M->Kind, M->Name, true}});
916  } else
917  SubModMap.insert({M->Name, {Idx, M, M->Kind, M->Name, false}});
918  }
919  if (Primary) {
920  if (!Primary->submodules().empty())
921  Out << " Sub Modules:\n";
922  for (auto MI : Primary->submodules()) {
923  PrintSubMapEntry(MI->Name, MI->Kind);
924  }
925  if (!Primary->Imports.empty())
926  Out << " Imports:\n";
927  for (auto IMP : Primary->Imports) {
928  PrintSubMapEntry(IMP->Name, IMP->Kind);
929  }
930  if (!Primary->Exports.empty())
931  Out << " Exports:\n";
932  for (unsigned MN = 0, N = Primary->Exports.size(); MN != N; ++MN) {
933  if (Module *M = Primary->Exports[MN].getPointer()) {
934  PrintSubMapEntry(M->Name, M->Kind);
935  }
936  }
937  }
938  // Now let's print out any modules we did not see as part of the Primary.
939  for (auto SM : SubModMap) {
940  if (!SM.second.Seen && SM.second.Mod) {
941  Out << " " << ModuleKindName(SM.second.Kind) << " '" << SM.first
942  << "' at index #" << SM.second.Idx
943  << " has no direct reference in the Primary\n";
944  }
945  }
946  Out << " ====== ======\n";
947  }
948 
949  // The reminder of the output is produced from the listener as the AST
950  // FileCcontrolBlock is (re-)parsed.
952  getCurrentFile(), FileMgr, getCompilerInstance().getPCHContainerReader(),
953  /*FindModuleFileExtensions=*/true, Listener,
955 }
956 
957 //===----------------------------------------------------------------------===//
958 // Preprocessor Actions
959 //===----------------------------------------------------------------------===//
960 
964 
965  // Start lexing the specified input file.
966  llvm::MemoryBufferRef FromFile = SM.getBufferOrFake(SM.getMainFileID());
967  Lexer RawLex(SM.getMainFileID(), FromFile, SM, PP.getLangOpts());
968  RawLex.SetKeepWhitespaceMode(true);
969 
970  Token RawTok;
971  RawLex.LexFromRawLexer(RawTok);
972  while (RawTok.isNot(tok::eof)) {
973  PP.DumpToken(RawTok, true);
974  llvm::errs() << "\n";
975  RawLex.LexFromRawLexer(RawTok);
976  }
977 }
978 
981  // Start preprocessing the specified input file.
982  Token Tok;
983  PP.EnterMainSourceFile();
984  do {
985  PP.Lex(Tok);
986  PP.DumpToken(Tok, true);
987  llvm::errs() << "\n";
988  } while (Tok.isNot(tok::eof));
989 }
990 
993 
994  // Ignore unknown pragmas.
995  PP.IgnorePragmas();
996 
997  Token Tok;
998  // Start parsing the specified input file.
999  PP.EnterMainSourceFile();
1000  do {
1001  PP.Lex(Tok);
1002  } while (Tok.isNot(tok::eof));
1003 }
1004 
1007  // Output file may need to be set to 'Binary', to avoid converting Unix style
1008  // line feeds (<LF>) to Microsoft style line feeds (<CR><LF>) on Windows.
1009  //
1010  // Look to see what type of line endings the file uses. If there's a
1011  // CRLF, then we won't open the file up in binary mode. If there is
1012  // just an LF or CR, then we will open the file up in binary mode.
1013  // In this fashion, the output format should match the input format, unless
1014  // the input format has inconsistent line endings.
1015  //
1016  // This should be a relatively fast operation since most files won't have
1017  // all of their source code on a single line. However, that is still a
1018  // concern, so if we scan for too long, we'll just assume the file should
1019  // be opened in binary mode.
1020 
1021  bool BinaryMode = false;
1022  if (llvm::Triple(LLVM_HOST_TRIPLE).isOSWindows()) {
1023  BinaryMode = true;
1024  const SourceManager &SM = CI.getSourceManager();
1026  SM.getBufferOrNone(SM.getMainFileID())) {
1027  const char *cur = Buffer->getBufferStart();
1028  const char *end = Buffer->getBufferEnd();
1029  const char *next = (cur != end) ? cur + 1 : end;
1030 
1031  // Limit ourselves to only scanning 256 characters into the source
1032  // file. This is mostly a check in case the file has no
1033  // newlines whatsoever.
1034  if (end - cur > 256)
1035  end = cur + 256;
1036 
1037  while (next < end) {
1038  if (*cur == 0x0D) { // CR
1039  if (*next == 0x0A) // CRLF
1040  BinaryMode = false;
1041 
1042  break;
1043  } else if (*cur == 0x0A) // LF
1044  break;
1045 
1046  ++cur;
1047  ++next;
1048  }
1049  }
1050  }
1051 
1052  std::unique_ptr<raw_ostream> OS =
1054  if (!OS) return;
1055 
1056  // If we're preprocessing a module map, start by dumping the contents of the
1057  // module itself before switching to the input buffer.
1058  auto &Input = getCurrentInput();
1059  if (Input.getKind().getFormat() == InputKind::ModuleMap) {
1060  if (Input.isFile()) {
1061  (*OS) << "# 1 \"";
1062  OS->write_escaped(Input.getFile());
1063  (*OS) << "\"\n";
1064  }
1065  getCurrentModule()->print(*OS);
1066  (*OS) << "#pragma clang module contents\n";
1067  }
1068 
1071 }
1072 
1074  switch (getCurrentFileKind().getLanguage()) {
1075  case Language::C:
1076  case Language::CXX:
1077  case Language::ObjC:
1078  case Language::ObjCXX:
1079  case Language::OpenCL:
1080  case Language::OpenCLCXX:
1081  case Language::CUDA:
1082  case Language::HIP:
1083  case Language::HLSL:
1084  break;
1085 
1086  case Language::Unknown:
1087  case Language::Asm:
1088  case Language::LLVM_IR:
1090  // We can't do anything with these.
1091  return;
1092  }
1093 
1094  // We don't expect to find any #include directives in a preprocessed input.
1095  if (getCurrentFileKind().isPreprocessed())
1096  return;
1097 
1099  auto Buffer = CI.getFileManager().getBufferForFile(getCurrentFile());
1100  if (Buffer) {
1101  unsigned Preamble =
1102  Lexer::ComputePreamble((*Buffer)->getBuffer(), CI.getLangOpts()).Size;
1103  llvm::outs().write((*Buffer)->getBufferStart(), Preamble);
1104  }
1105 }
1106 
1107 void DumpCompilerOptionsAction::ExecuteAction() {
1109  std::unique_ptr<raw_ostream> OSP =
1111  if (!OSP)
1112  return;
1113 
1114  raw_ostream &OS = *OSP;
1115  const Preprocessor &PP = CI.getPreprocessor();
1116  const LangOptions &LangOpts = PP.getLangOpts();
1117 
1118  // FIXME: Rather than manually format the JSON (which is awkward due to
1119  // needing to remove trailing commas), this should make use of a JSON library.
1120  // FIXME: Instead of printing enums as an integral value and specifying the
1121  // type as a separate field, use introspection to print the enumerator.
1122 
1123  OS << "{\n";
1124  OS << "\n\"features\" : [\n";
1125  {
1127 #define FEATURE(Name, Predicate) \
1128  ("\t{\"" #Name "\" : " + llvm::Twine(Predicate ? "true" : "false") + "},\n") \
1129  .toVector(Str);
1130 #include "clang/Basic/Features.def"
1131 #undef FEATURE
1132  // Remove the newline and comma from the last entry to ensure this remains
1133  // valid JSON.
1134  OS << Str.substr(0, Str.size() - 2);
1135  }
1136  OS << "\n],\n";
1137 
1138  OS << "\n\"extensions\" : [\n";
1139  {
1141 #define EXTENSION(Name, Predicate) \
1142  ("\t{\"" #Name "\" : " + llvm::Twine(Predicate ? "true" : "false") + "},\n") \
1143  .toVector(Str);
1144 #include "clang/Basic/Features.def"
1145 #undef EXTENSION
1146  // Remove the newline and comma from the last entry to ensure this remains
1147  // valid JSON.
1148  OS << Str.substr(0, Str.size() - 2);
1149  }
1150  OS << "\n]\n";
1151 
1152  OS << "}";
1153 }
1154 
1158  llvm::MemoryBufferRef FromFile = SM.getBufferOrFake(SM.getMainFileID());
1159 
1160  llvm::SmallString<1024> Output;
1163  FromFile.getBuffer(), Output, Toks, &CI.getDiagnostics(),
1164  SM.getLocForStartOfFile(SM.getMainFileID()))) {
1165  assert(CI.getDiagnostics().hasErrorOccurred() &&
1166  "no errors reported for failure");
1167 
1168  // Preprocess the source when verifying the diagnostics to capture the
1169  // 'expected' comments.
1170  if (CI.getDiagnosticOpts().VerifyDiagnostics) {
1171  // Make sure we don't emit new diagnostics!
1174  PP.EnterMainSourceFile();
1175  Token Tok;
1176  do {
1177  PP.Lex(Tok);
1178  } while (Tok.isNot(tok::eof));
1179  }
1180  return;
1181  }
1182  llvm::outs() << Output;
1183 }
1184 
1185 void GetDependenciesByModuleNameAction::ExecuteAction() {
1187  Preprocessor &PP = CI.getPreprocessor();
1189  FileID MainFileID = SM.getMainFileID();
1190  SourceLocation FileStart = SM.getLocForStartOfFile(MainFileID);
1192  IdentifierInfo *ModuleID = PP.getIdentifierInfo(ModuleName);
1193  Path.push_back(std::make_pair(ModuleID, FileStart));
1194  auto ModResult = CI.loadModule(FileStart, Path, Module::Hidden, false);
1195  PPCallbacks *CB = PP.getPPCallbacks();
1196  CB->moduleImport(SourceLocation(), Path, ModResult);
1197 }
clang::ASTUnit::getASTReader
IntrusiveRefCntPtr< ASTReader > getASTReader() const
Definition: ASTUnit.cpp:719
clang::Language::CUDA
@ CUDA
clang::CompilerInstance::hasSema
bool hasSema() const
Definition: CompilerInstance.h:501
clang::LangOptions::CurrentModule
std::string CurrentModule
The name of the current module, of which the main source file is a part.
Definition: LangOptions.h:410
clang::LangOptions::CMK_ModuleInterface
@ CMK_ModuleInterface
Compiling a C++ modules TS module interface unit.
Definition: LangOptions.h:117
llvm
YAML serialization mapping.
Definition: Dominators.h:30
clang::CreateASTViewer
std::unique_ptr< ASTConsumer > CreateASTViewer()
Definition: ASTConsumers.cpp:215
clang::TemplightDumpAction::CreateASTConsumer
std::unique_ptr< ASTConsumer > CreateASTConsumer(CompilerInstance &CI, StringRef InFile) override
Create the AST consumer object for this action, if supported.
Definition: FrontendActions.cpp:603
clang::CompilerInstance::getPreprocessorOutputOpts
PreprocessorOutputOptions & getPreprocessorOutputOpts()
Definition: CompilerInstance.h:313
clang::initialize
void initialize(TemplateInstantiationCallbackPtrs &Callbacks, const Sema &TheSema)
Definition: TemplateInstCallback.h:43
string
string(SUBSTRING ${CMAKE_CURRENT_BINARY_DIR} 0 ${PATH_LIB_START} PATH_HEAD) string(SUBSTRING $
Definition: CMakeLists.txt:22
clang::PreprocessorOptions
PreprocessorOptions - This class is used for passing the various options used in preprocessor initial...
Definition: PreprocessorOptions.h:64
clang::PresumedLoc::getLine
unsigned getLine() const
Return the presumed line number of this location.
Definition: SourceLocation.h:337
clang::Preprocessor::getPPCallbacks
PPCallbacks * getPPCallbacks() const
Definition: Preprocessor.h:1091
clang::Preprocessor::Lex
void Lex(Token &Result)
Lex the next token for this preprocessor.
Definition: Preprocessor.cpp:892
clang::GeneratePCHAction::shouldEraseOutputFiles
bool shouldEraseOutputFiles() override
Callback at the end of processing a single input, to determine if the output files should be erased o...
Definition: FrontendActions.cpp:174
clang::PrintPreprocessedAction::ExecuteAction
void ExecuteAction() override
Callback to run the program action, using the initialized compiler instance.
Definition: FrontendActions.cpp:1005
llvm::SmallVector
Definition: LLVM.h:38
clang::SourceLocation
Encodes a location in the source.
Definition: SourceLocation.h:86
clang::minimizeSourceToDependencyDirectives
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 ...
clang::PPCallbacks
This interface provides a way to observe the actions of the preprocessor as it does its thing.
Definition: PPCallbacks.h:35
clang::NamedDecl
This represents a decl that may have a name.
Definition: Decl.h:247
clang::Preprocessor::IgnorePragmas
void IgnorePragmas()
Install empty handlers for all pragmas (making them ignored).
Definition: Pragma.cpp:2126
TargetInfo.h
clang::ASTPrintAction::CreateASTConsumer
std::unique_ptr< ASTConsumer > CreateASTConsumer(CompilerInstance &CI, StringRef InFile) override
Create the AST consumer object for this action, if supported.
Definition: FrontendActions.cpp:95
clang::DumpModuleInfoAction::CreateASTConsumer
std::unique_ptr< ASTConsumer > CreateASTConsumer(CompilerInstance &CI, StringRef InFile) override
Create the AST consumer object for this action, if supported.
Definition: FrontendActions.cpp:363
clang::HeaderSearchOptions::UseStandardSystemIncludes
unsigned UseStandardSystemIncludes
Include the system standard include search directories.
Definition: HeaderSearchOptions.h:191
clang::CompilerInstance::getLangOpts
LangOptions & getLangOpts()
Definition: CompilerInstance.h:299
clang::FrontendAction::getCurrentASTUnit
ASTUnit & getCurrentASTUnit() const
Definition: FrontendAction.h:156
Filename
StringRef Filename
Definition: Format.cpp:2551
clang::FrontendAction::getCurrentModule
Module * getCurrentModule() const
Definition: FrontendAction.cpp:144
clang::Language::OpenCLCXX
@ OpenCLCXX
clang::FrontendAction::hasCodeCompletionSupport
virtual bool hasCodeCompletionSupport() const
Does this action support use with code completion?
Definition: FrontendAction.h:200
clang::ASTReader::ARR_ConfigurationMismatch
@ ARR_ConfigurationMismatch
The client can handle an AST file that cannot load because it's compiled configuration doesn't match ...
Definition: ASTReader.h:1563
clang::FrontendInputFile
An input file for the front end.
Definition: FrontendOptions.h:221
Module.h
clang::Module::Name
std::string Name
The name of this module.
Definition: Module.h:99
clang::Sema::getSourceManager
SourceManager & getSourceManager() const
Definition: Sema.h:1612
clang::Module::ModuleMapModule
@ ModuleMapModule
This is a module that was defined by a module map and built out of header files.
Definition: Module.h:107
clang::PrintDependencyDirectivesSourceMinimizerAction::ExecuteAction
void ExecuteAction() override
Callback to run the program action, using the initialized compiler instance.
Definition: FrontendActions.cpp:1155
clang::FrontendAction::BeginInvocation
virtual bool BeginInvocation(CompilerInstance &CI)
Callback before starting processing a single input, giving the opportunity to modify the CompilerInvo...
Definition: FrontendAction.h:79
llvm::Optional< FileEntryRef >
clang::SourceManager::getPresumedLoc
PresumedLoc getPresumedLoc(SourceLocation Loc, bool UseLineDirectives=true) const
Returns the "presumed" location of a SourceLocation specifies.
Definition: SourceManager.cpp:1513
clang::Sema::TemplateInstCallbacks
std::vector< std::unique_ptr< TemplateInstantiationCallback > > TemplateInstCallbacks
The template instantiation callbacks to trace or track instantiations (objects can be chained).
Definition: Sema.h:9039
clang::DiagnosticsEngine::setSuppressAllDiagnostics
void setSuppressAllDiagnostics(bool Val)
Suppress all diagnostics, to silence the front end when we know that we don't want any more diagnosti...
Definition: Diagnostic.h:691
clang::PrintingPolicy
Describes how types, statements, expressions, and declarations should be printed.
Definition: PrettyPrinter.h:57
clang::PreprocessorOptions::DetailedRecord
bool DetailedRecord
Whether we should maintain a detailed record of all macro definitions and expansions.
Definition: PreprocessorOptions.h:76
clang::Language::Asm
@ Asm
Assembly: we accept this only so that we can preprocess it.
ASTWriter.h
clang::Lexer::LexFromRawLexer
bool LexFromRawLexer(Token &Result)
LexFromRawLexer - Lex a token from a designated raw lexer (one with no associated preprocessor object...
Definition: Lexer.h:211
clang::NamedDecl::getNameForDiagnostic
virtual void getNameForDiagnostic(raw_ostream &OS, const PrintingPolicy &Policy, bool Qualified) const
Appends a human-readable name for this declaration into the given stream.
Definition: Decl.cpp:1748
clang::Token
Token - This structure provides full information about a lexed token.
Definition: Token.h:34
clang::ASTReader::getModule
Module * getModule(unsigned ID) override
Retrieve the module that corresponds to the given module ID.
Definition: ASTReader.cpp:8657
clang::HeaderSearchOptions::ModulesValidateDiagnosticOptions
unsigned ModulesValidateDiagnosticOptions
Definition: HeaderSearchOptions.h:217
clang::InputKind::Source
@ Source
Definition: FrontendOptions.h:162
clang::CompilerInstance::getPCHContainerReader
const PCHContainerReader & getPCHContainerReader() const
Return the appropriate PCHContainerReader depending on the current CodeGenOptions.
Definition: CompilerInstance.h:542
clang::CompilerInstance::createCodeCompletionConsumer
void createCodeCompletionConsumer()
Create a code completion consumer using the invocation; note that this will cause the source manager ...
Definition: CompilerInstance.cpp:710
clang::DumpModuleInfoAction::BeginInvocation
bool BeginInvocation(CompilerInstance &CI) override
Callback before starting processing a single input, giving the opportunity to modify the CompilerInvo...
Definition: FrontendActions.cpp:821
llvm::yaml::MappingTraits< TemplightEntry >::mapping
static void mapping(IO &io, TemplightEntry &fields)
Definition: FrontendActions.cpp:406
clang::DisableValidationForModuleKind::None
@ None
Perform validation, don't disable it.
clang::SourceManager
This class handles loading and caching of source files into memory.
Definition: SourceManager.h:627
clang::FrontendOptions::Inputs
SmallVector< FrontendInputFile, 0 > Inputs
The input files and their types.
Definition: FrontendOptions.h:426
clang::ParsedSourceLocation::FileName
std::string FileName
Definition: CommandLineSourceLoc.h:25
clang::Preprocessor::getLangOpts
const LangOptions & getLangOpts() const
Definition: Preprocessor.h:994
clang::Sema::Context
ASTContext & Context
Definition: Sema.h:410
clang::Type
The base class of the type hierarchy.
Definition: Type.h:1500
Preprocessor.h
clang::HeaderSearch
Encapsulates the information needed to find the file referenced by a #include or #include_next,...
Definition: HeaderSearch.h:223
Decl.h
clang::Lexer
Lexer - This provides a simple interface that turns a text buffer into a stream of tokens.
Definition: Lexer.h:77
clang::DumpTokensAction::ExecuteAction
void ExecuteAction() override
Callback to run the program action, using the initialized compiler instance.
Definition: FrontendActions.cpp:979
clang::DumpModuleInfoAction::ExecuteAction
void ExecuteAction() override
Implement the ExecuteAction interface by running Sema on the already-initialized AST consumer.
Definition: FrontendActions.cpp:848
clang::Sema::getLangOpts
const LangOptions & getLangOpts() const
Definition: Sema.h:1607
clang::GeneratePCHAction::CreateOutputFile
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.
Definition: FrontendActions.cpp:162
clang::PrintingPolicy::SuppressDefaultTemplateArgs
unsigned SuppressDefaultTemplateArgs
When true, attempt to suppress template arguments that match the default argument for the parameter.
Definition: PrettyPrinter.h:189
clang::ModuleMap::createHeaderModule
Module * createHeaderModule(StringRef Name, ArrayRef< Module::Header > Headers)
Create a header module from the specified list of headers.
Definition: ModuleMap.cpp:884
clang::DumpRawTokensAction::ExecuteAction
void ExecuteAction() override
Callback to run the program action, using the initialized compiler instance.
Definition: FrontendActions.cpp:961
ModuleKindName
static StringRef ModuleKindName(Module::ModuleKind MK)
Definition: FrontendActions.cpp:828
clang::CompilerInstance::getFileManager
FileManager & getFileManager() const
Return the current file manager to the caller.
Definition: CompilerInstance.h:402
clang::VerifyPCHAction::ExecuteAction
void ExecuteAction() override
Implement the ExecuteAction interface by running Sema on the already-initialized AST consumer.
Definition: FrontendActions.cpp:373
clang::FrontendOptions::ASTDumpFormat
ASTDumpOutputFormat ASTDumpFormat
Specifies the output format of the AST.
Definition: FrontendOptions.h:353
clang::serialized_diags::Remark
@ Remark
Definition: SerializedDiagnostics.h:49
clang::SourceLocation::print
void print(raw_ostream &OS, const SourceManager &SM) const
Definition: SourceLocation.cpp:62
clang::Language::RenderScript
@ RenderScript
clang::FrontendOptions::ASTDumpDecls
unsigned ASTDumpDecls
Whether we include declaration dumps in AST dumps.
Definition: FrontendOptions.h:318
clang::GenerateModuleAction::shouldEraseOutputFiles
bool shouldEraseOutputFiles() override
Callback at the end of processing a single input, to determine if the output files should be erased o...
Definition: FrontendActions.cpp:212
clang::Module
Describes a module or submodule.
Definition: Module.h:96
clang::ASTReaderListener::ReadFullVersionInformation
virtual bool ReadFullVersionInformation(StringRef FullVersion)
Receives the full Clang version information.
Definition: ASTReader.h:120
clang::Module::Hidden
@ Hidden
All of the names in this module are hidden.
Definition: Module.h:331
clang::Module::ModulePartitionInterface
@ ModulePartitionInterface
This is a C++ 20 module partition interface.
Definition: Module.h:116
clang::serialization::MK_Preamble
@ MK_Preamble
File is a PCH file treated as the preamble.
Definition: ModuleFile.h:53
clang::FrontendAction::getCurrentFileOrBufferName
StringRef getCurrentFileOrBufferName() const
Definition: FrontendAction.h:144
clang::FrontendOptions::OutputFile
std::string OutputFile
The output file, if any.
Definition: FrontendOptions.h:433
clang::FrontendOptions::ASTDumpFilter
std::string ASTDumpFilter
If given, filter dumped AST Decl nodes by this substring.
Definition: FrontendOptions.h:439
clang::ASTReader::getModuleManager
ModuleManager & getModuleManager()
Retrieve the module manager.
Definition: ASTReader.h:1703
clang::Module::Exports
SmallVector< ExportDecl, 2 > Exports
The set of export declarations.
Definition: Module.h:353
clang::Module::ModuleInterfaceUnit
@ ModuleInterfaceUnit
This is a C++20 module interface unit.
Definition: Module.h:110
clang::PresumedLoc::getFilename
const char * getFilename() const
Return the presumed filename of this location.
Definition: SourceLocation.h:324
clang::HeaderSearchOptions::Sysroot
std::string Sysroot
If non-empty, the directory to use as a "virtual system root" for include paths.
Definition: HeaderSearchOptions.h:100
clang::ASTReader::getTotalNumSubmodules
unsigned getTotalNumSubmodules() const
Returns the number of submodules known.
Definition: ASTReader.h:1795
clang::threadSafety::sx::toString
std::string toString(const til::SExpr *E)
Definition: ThreadSafetyCommon.h:90
clang::DiagnosticsEngine::hasErrorOccurred
bool hasErrorOccurred() const
Definition: Diagnostic.h:837
clang::LangOptions::CMK_HeaderModule
@ CMK_HeaderModule
Compiling a module from a list of header files.
Definition: LangOptions.h:111
clang::CompilerInstance::getSema
Sema & getSema() const
Definition: CompilerInstance.h:503
clang::FrontendOptions
FrontendOptions - Options for controlling the behavior of the frontend.
Definition: FrontendOptions.h:268
clang::SyntaxOnlyAction::~SyntaxOnlyAction
~SyntaxOnlyAction() override
Definition: FrontendActions.cpp:354
Utils.h
clang::atTemplateEnd
void atTemplateEnd(TemplateInstantiationCallbackPtrs &Callbacks, const Sema &TheSema, const Sema::CodeSynthesisContext &Inst)
Definition: TemplateInstCallback.h:71
TemplateInstCallback.h
clang::Module::GlobalModuleFragment
@ GlobalModuleFragment
This is a fragment of the global module within some C++ module.
Definition: Module.h:122
clang::Module::ModuleHeaderUnit
@ ModuleHeaderUnit
This is a C++ 20 header unit.
Definition: Module.h:113
clang::serialized_diags::Warning
@ Warning
Definition: SerializedDiagnostics.h:46
clang::LangOptions::ModuleFeatures
std::vector< std::string > ModuleFeatures
The names of any features to enable in module 'requires' decls in addition to the hard-coded list in ...
Definition: LangOptions.h:416
clang::TargetOptions::ABI
std::string ABI
If given, the name of the target ABI to use.
Definition: TargetOptions.h:45
clang::FrontendOptions::ASTDumpDeclTypes
unsigned ASTDumpDeclTypes
Whether we include declaration type dumps in AST dumps.
Definition: FrontendOptions.h:327
clang::HeaderSearchOptions::ModuleFormat
std::string ModuleFormat
The module/pch container format.
Definition: HeaderSearchOptions.h:125
clang::PreprocessorOptions::AllowPCHWithCompilerErrors
bool AllowPCHWithCompilerErrors
When true, a PCH with compiler errors will not be rejected.
Definition: PreprocessorOptions.h:107
clang::FrontendOptions::ASTDumpAll
unsigned ASTDumpAll
Whether we deserialize all decls when forming AST dumps.
Definition: FrontendOptions.h:321
clang::Sema::CodeSynthesisContext
A context in which code is being synthesized (where a source location alone is not sufficient to iden...
Definition: Sema.h:8816
clang::FrontendAction::getCompilerInstance
CompilerInstance & getCompilerInstance() const
Definition: FrontendAction.h:119
llvm::SmallString
Definition: LLVM.h:37
clang::Language::C
@ C
Languages that the frontend can parse and compile.
clang::atTemplateBegin
void atTemplateBegin(TemplateInstantiationCallbackPtrs &Callbacks, const Sema &TheSema, const Sema::CodeSynthesisContext &Inst)
Definition: TemplateInstCallback.h:61
clang::PreambleBounds::Size
unsigned Size
Size of the preamble in bytes.
Definition: Lexer.h:61
clang::ModuleFileExtensionMetadata::MajorVersion
unsigned MajorVersion
The major version of the extension data.
Definition: ModuleFileExtension.h:44
clang::getClangFullRepositoryVersion
std::string getClangFullRepositoryVersion()
Retrieves the full repository version that is an amalgamation of the information in getClangRepositor...
Definition: Version.cpp:60
clang::Module::ModuleKind
ModuleKind
Definition: Module.h:104
clang::PreprocessorOptions::UsePredefines
bool UsePredefines
Initialize the preprocessor with the compiler and target specific predefines.
Definition: PreprocessorOptions.h:72
clang::CreateASTPrinter
std::unique_ptr< ASTConsumer > CreateASTPrinter(std::unique_ptr< raw_ostream > OS, StringRef FilterString)
Definition: ASTConsumers.cpp:160
clang::PresumedLoc::getColumn
unsigned getColumn() const
Return the presumed column number of this location.
Definition: SourceLocation.h:345
clang::FrontendAction::shouldEraseOutputFiles
virtual bool shouldEraseOutputFiles()
Callback at the end of processing a single input, to determine if the output files should be erased o...
Definition: FrontendAction.cpp:1112
clang::CompilerInstance::getPreprocessor
Preprocessor & getPreprocessor() const
Return the current preprocessor.
Definition: CompilerInstance.h:442
clang::ASTReader::readASTFileControlBlock
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:5182
clang::HeaderSearchOptions::UseLibcxx
unsigned UseLibcxx
Use libc++ instead of the default libstdc++.
Definition: HeaderSearchOptions.h:197
clang::FrontendAction::getTranslationUnitKind
virtual TranslationUnitKind getTranslationUnitKind()
For AST-based actions, the kind of translation unit we're handling.
Definition: FrontendAction.h:188
clang::CompilerInstance::getASTContext
ASTContext & getASTContext() const
Definition: CompilerInstance.h:462
clang::ASTUnit::getLangOpts
const LangOptions & getLangOpts() const
Definition: ASTUnit.h:461
clang::Preprocessor::EnterMainSourceFile
void EnterMainSourceFile()
Enter the specified FileID as the main source file, which implicitly adds the builtin defines etc.
Definition: Preprocessor.cpp:535
clang::GenerateModuleAction::CreateASTConsumer
std::unique_ptr< ASTConsumer > CreateASTConsumer(CompilerInstance &CI, StringRef InFile) override
Create the AST consumer object for this action, if supported.
Definition: FrontendActions.cpp:186
clang::FrontendOptions::AllowPCMWithCompilerErrors
unsigned AllowPCMWithCompilerErrors
Output (and read) PCM files regardless of compiler errors.
Definition: FrontendOptions.h:348
clang::FrontendOptions::ASTDumpLookups
unsigned ASTDumpLookups
Whether we include lookup table dumps in AST dumps.
Definition: FrontendOptions.h:324
clang::HeaderSearchOptions::UseStandardCXXIncludes
unsigned UseStandardCXXIncludes
Include the system standard C++ library include search directories.
Definition: HeaderSearchOptions.h:194
clang::Token::isNot
bool isNot(tok::TokenKind K) const
Definition: Token.h:98
clang::CompilerInstance
CompilerInstance - Helper class for managing a single instance of the Clang compiler.
Definition: CompilerInstance.h:72
clang::CompilerInstance::getPreprocessorOpts
PreprocessorOptions & getPreprocessorOpts()
Definition: CompilerInstance.h:306
clang::FrontendAction::getCurrentFileKind
InputKind getCurrentFileKind() const
Definition: FrontendAction.h:151
clang::Decl::castFromDeclContext
static Decl * castFromDeclContext(const DeclContext *)
Definition: DeclBase.cpp:914
clang::Module::submodules
llvm::iterator_range< submodule_iterator > submodules()
Definition: Module.h:684
clang::ASTDumpAction::CreateASTConsumer
std::unique_ptr< ASTConsumer > CreateASTConsumer(CompilerInstance &CI, StringRef InFile) override
Create the AST consumer object for this action, if supported.
Definition: FrontendActions.cpp:103
clang::ModuleFileExtensionMetadata::UserInfo
std::string UserInfo
A string containing additional user information that will be stored with the metadata.
Definition: ModuleFileExtension.h:51
clang::FrontendOptions::ModuleFileExtensions
std::vector< std::shared_ptr< ModuleFileExtension > > ModuleFileExtensions
The list of module file extensions.
Definition: FrontendOptions.h:464
clang::CompilerInstance::getModuleCache
InMemoryModuleCache & getModuleCache() const
Definition: CompilerInstance.h:817
clang::Preprocessor::getSourceManager
SourceManager & getSourceManager() const
Definition: Preprocessor.h:998
clang::FrontendAction::getCurrentInput
const FrontendInputFile & getCurrentInput() const
Definition: FrontendAction.h:135
clang::InputKind::ModuleMap
@ ModuleMap
Definition: FrontendOptions.h:163
clang::PresumedLoc::isInvalid
bool isInvalid() const
Return true if this object is invalid or uninitialized.
Definition: SourceLocation.h:318
clang::HeaderSearch::getCachedModuleFileName
std::string getCachedModuleFileName(Module *Module)
Retrieve the name of the cached module file that should be used to load the given module.
Definition: HeaderSearch.cpp:172
clang::GeneratePCHAction::ComputeASTConsumerArguments
static bool ComputeASTConsumerArguments(CompilerInstance &CI, std::string &Sysroot)
Compute the AST consumer arguments that will be used to create the PCHGenerator instance returned by ...
Definition: FrontendActions.cpp:150
LangStandard.h
clang::ASTViewAction::CreateASTConsumer
std::unique_ptr< ASTConsumer > CreateASTConsumer(CompilerInstance &CI, StringRef InFile) override
Create the AST consumer object for this action, if supported.
Definition: FrontendActions.cpp:117
clang::ASTContext::getPrintingPolicy
const clang::PrintingPolicy & getPrintingPolicy() const
Definition: ASTContext.h:708
clang::Language::CXX
@ CXX
clang::Language::ObjCXX
@ ObjCXX
clang::CompilerInstance::hasCodeCompletionConsumer
bool hasCodeCompletionConsumer() const
Definition: CompilerInstance.h:558
clang::Language::LLVM_IR
@ LLVM_IR
LLVM IR: we accept this so that we can run the optimizer on it, and compile it to assembly or object ...
clang::Decl
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:83
clang::FrontendAction::getCurrentFile
StringRef getCurrentFile() const
Definition: FrontendAction.h:139
HeaderSearch.h
clang::FileManager::getBufferForFile
llvm::ErrorOr< std::unique_ptr< llvm::MemoryBuffer > > getBufferForFile(const FileEntry *Entry, bool isVolatile=false, bool RequiresNullTerminator=true)
Open the specified file as a MemoryBuffer, returning a new MemoryBuffer if successful,...
Definition: FileManager.cpp:564
clang::CompilerInstance::getPCHContainerWriter
const PCHContainerWriter & getPCHContainerWriter() const
Return the appropriate PCHContainerWriter depending on the current CodeGenOptions.
Definition: CompilerInstance.h:528
clang::ASTDeclListAction::CreateASTConsumer
std::unique_ptr< ASTConsumer > CreateASTConsumer(CompilerInstance &CI, StringRef InFile) override
Create the AST consumer object for this action, if supported.
Definition: FrontendActions.cpp:112
clang::Module::PrivateModuleFragment
@ PrivateModuleFragment
This is the private module fragment within some C++ module.
Definition: Module.h:125
clang::PreprocessorOptions::PrecompiledPreambleBytes
std::pair< unsigned, bool > PrecompiledPreambleBytes
If non-zero, the implicit PCH include is actually a precompiled preamble that covers this number of b...
Definition: PreprocessorOptions.h:125
clang::Sema
Sema - This implements semantic analysis and AST building for C.
Definition: Sema.h:354
FrontendActions.h
clang::FrontendAction::PrepareToExecuteAction
virtual bool PrepareToExecuteAction(CompilerInstance &CI)
Prepare to execute the action on the given CompilerInstance.
Definition: FrontendAction.h:55
clang::PreprocessOnlyAction::ExecuteAction
void ExecuteAction() override
Callback to run the program action, using the initialized compiler instance.
Definition: FrontendActions.cpp:991
clang::Preprocessor::DumpToken
void DumpToken(const Token &Tok, bool DumpFlags=false) const
Print the token to stderr, used for debugging.
Definition: Preprocessor.cpp:234
clang::CodeCompleteConsumer
Abstract interface for a consumer of code-completion information.
Definition: CodeCompleteConsumer.h:1000
clang::Language::ObjC
@ ObjC
clang::PrintPreambleAction::ExecuteAction
void ExecuteAction() override
Callback to run the program action, using the initialized compiler instance.
Definition: FrontendActions.cpp:1073
clang::Module::Imports
llvm::SmallSetVector< Module *, 2 > Imports
The set of modules imported by this module, and on which this module depends.
Definition: Module.h:344
ASTConsumer.h
clang::serialization::ModuleManager::getPrimaryModule
ModuleFile & getPrimaryModule()
Returns the primary module associated with the manager, that is, the first module loaded.
Definition: ModuleManager.h:168
clang::ModuleFileExtensionMetadata::MinorVersion
unsigned MinorVersion
The minor version of the extension data.
Definition: ModuleFileExtension.h:47
clang::IdentifierInfo
One of these records is kept for each identifier that is lexed.
Definition: IdentifierTable.h:84
clang::CreateASTDumper
std::unique_ptr< ASTConsumer > CreateASTDumper(std::unique_ptr< raw_ostream > OS, StringRef FilterString, bool DumpDecls, bool Deserialize, bool DumpLookups, bool DumpDeclTypes, ASTDumpOutputFormat Format)
Definition: ASTConsumers.cpp:167
clang::FrontendOptions::BuildingImplicitModule
unsigned BuildingImplicitModule
Whether we are performing an implicit module build.
Definition: FrontendOptions.h:330
clang::TargetOptions::TuneCPU
std::string TuneCPU
If given, the name of the target CPU to tune code for.
Definition: TargetOptions.h:39
clang::TargetOptions::CPU
std::string CPU
If given, the name of the target CPU to generate code for.
Definition: TargetOptions.h:36
clang::LangOptions
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Definition: LangOptions.h:78
clang::DoPrintPreprocessedInput
void DoPrintPreprocessedInput(Preprocessor &PP, raw_ostream *OS, const PreprocessorOutputOptions &Opts)
DoPrintPreprocessedInput - Implement -E mode.
Definition: PrintPreprocessedOutput.cpp:959
clang::Lexer::SetKeepWhitespaceMode
void SetKeepWhitespaceMode(bool Val)
SetKeepWhitespaceMode - This method lets clients enable or disable whitespace retention mode.
Definition: Lexer.h:229
clang::serialization::ModuleFile::ModuleName
std::string ModuleName
The name of the module.
Definition: ModuleFile.h:129
clang::ObjCPropertyAttribute::Kind
Kind
Definition: DeclObjCCommon.h:22
clang::TemplateInstantiationCallback
This is a base class for callbacks that will be notified at every template instantiation.
Definition: TemplateInstCallback.h:23
clang::ASTReader
Reads an AST files chain containing the contents of a translation unit.
Definition: ASTReader.h:340
clang::TargetOptions::FeaturesAsWritten
std::vector< std::string > FeaturesAsWritten
The list of target specific features to enable or disable, as written on the command line.
Definition: TargetOptions.h:54
clang::FrontendOptions::OriginalModuleMap
std::string OriginalModuleMap
When the input is a module map, the original module map file from which that map was inferred,...
Definition: FrontendOptions.h:430
ModuleFile.h
clang::Module::Kind
ModuleKind Kind
The kind of this module.
Definition: Module.h:129
clang::FrontendAction
Abstract base class for actions which can be performed by the frontend.
Definition: FrontendAction.h:36
clang::CompilerInstance::getDiagnosticOpts
DiagnosticOptions & getDiagnosticOpts()
Definition: CompilerInstance.h:268
clang
Definition: CalledOnceCheck.h:17
clang::PCHContainerWriter::CreatePCHContainerGenerator
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...
clang::Module::getModuleInputBufferName
static StringRef getModuleInputBufferName()
Definition: Module.h:697
clang::ModuleFileExtensionMetadata::BlockName
std::string BlockName
The name used to identify this particular extension block within the resulting module file.
Definition: ModuleFileExtension.h:41
clang::CompilerInstance::createDefaultOutputFile
std::unique_ptr< raw_pwrite_stream > createDefaultOutputFile(bool Binary=true, StringRef BaseInput="", StringRef Extension="", bool RemoveFileOnSignal=true, bool CreateMissingDirectories=false, bool ForceUseTemporary=false)
Create the default output file (from the invocation's options) and add it to the list of tracked outp...
Definition: CompilerInstance.cpp:803
FrontendDiagnostic.h
clang::Module::print
void print(raw_ostream &OS, unsigned Indent=0, bool Dump=false) const
Print the module map for this module to the given stream.
Definition: Module.cpp:434
clang::FrontendAction::isCurrentFileAST
bool isCurrentFileAST() const
Definition: FrontendAction.h:130
ASTReader.h
clang::TemplightDumpAction::ExecuteAction
void ExecuteAction() override
Implement the ExecuteAction interface by running Sema on the already-initialized AST consumer.
Definition: FrontendActions.cpp:607
clang::ASTReaderListener
Abstract interface for callback invocations by the ASTReader.
Definition: ASTReader.h:112
clang::TargetOptions::Triple
std::string Triple
The name of the target triple to compile for.
Definition: TargetOptions.h:29
clang::CompilerInstance::getCodeCompletionConsumer
CodeCompleteConsumer & getCodeCompletionConsumer() const
Definition: CompilerInstance.h:560
clang::Module::ModulePartitionImplementation
@ ModulePartitionImplementation
This is a C++ 20 module partition implementation.
Definition: Module.h:119
clang::ModuleFileExtensionMetadata
Metadata for a module file extension.
Definition: ModuleFileExtension.h:36
clang::FileID
An opaque identifier used by SourceManager which refers to a source file (MemoryBuffer) along with it...
Definition: SourceLocation.h:38
clang::SrcMgr::isSystem
bool isSystem(CharacteristicKind CK)
Determine whether a file / directory characteristic is for system code.
Definition: SourceManager.h:88
clang::FrontendAction::BeginSourceFileAction
virtual bool BeginSourceFileAction(CompilerInstance &CI)
Callback at the start of processing a single input.
Definition: FrontendAction.h:85
clang::ASTFrontendAction::ExecuteAction
void ExecuteAction() override
Implement the ExecuteAction interface by running Sema on the already-initialized AST consumer.
Definition: FrontendAction.cpp:1120
clang::VerifyPCHAction::CreateASTConsumer
std::unique_ptr< ASTConsumer > CreateASTConsumer(CompilerInstance &CI, StringRef InFile) override
Create the AST consumer object for this action, if supported.
Definition: FrontendActions.cpp:369
CompilerInstance.h
clang::CompilerInstance::getFrontendOpts
FrontendOptions & getFrontendOpts()
Definition: CompilerInstance.h:282
clang::Language::Unknown
@ Unknown
clang::FrontendOptions::RelocatablePCH
unsigned RelocatablePCH
When generating PCH files, instruct the AST writer to create relocatable PCH files.
Definition: FrontendOptions.h:275
clang::CreateASTDeclNodeLister
std::unique_ptr< ASTConsumer > CreateASTDeclNodeLister()
Definition: ASTConsumers.cpp:178
clang::CompilerInstance::loadModule
ModuleLoadResult loadModule(SourceLocation ImportLoc, ModuleIdPath Path, Module::NameVisibilityKind Visibility, bool IsInclusionDirective) override
Attempt to load the given module.
Definition: CompilerInstance.cpp:1938
clang::serialization::MK_PCH
@ MK_PCH
File is a PCH file treated as such.
Definition: ModuleFile.h:50
clang::HeaderSearchOptions::ResourceDir
std::string ResourceDir
The directory which holds the compiler resource files (builtin includes, etc.).
Definition: HeaderSearchOptions.h:110
clang::TargetOptions
Options for controlling the target.
Definition: TargetOptions.h:26
clang::comments::tok::eof
@ eof
Definition: CommentLexer.h:33
clang::Lexer::ComputePreamble
static PreambleBounds ComputePreamble(StringRef Buffer, const LangOptions &LangOpts, unsigned MaxLines=0)
Compute the preamble of the given file.
Definition: Lexer.cpp:590
clang::PresumedLoc
Represents an unpacked "presumed" location which can be presented to the user.
Definition: SourceLocation.h:302
clang::Language::HIP
@ HIP
clang::CompilerInstance::getDiagnostics
DiagnosticsEngine & getDiagnostics() const
Get the current diagnostics engine.
Definition: CompilerInstance.h:334
clang::CompilerInstance::getSourceManager
SourceManager & getSourceManager() const
Return the current source manager.
Definition: CompilerInstance.h:422
FileManager.h
clang::CompilerInstance::createSema
void createSema(TranslationUnitKind TUKind, CodeCompleteConsumer *CompletionConsumer)
Create the Sema object to be used for parsing.
Definition: CompilerInstance.cpp:749
PreprocessorOptions.h
clang::HLSL
@ HLSL
Definition: LangStandard.h:63
clang::Preprocessor
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
Definition: Preprocessor.h:131
SM
#define SM(sm)
Definition: Cuda.cpp:81
clang::Preprocessor::getHeaderSearchInfo
HeaderSearch & getHeaderSearchInfo() const
Definition: Preprocessor.h:999
DUMP_BOOLEAN
#define DUMP_BOOLEAN(Value, Text)
Definition: FrontendActions.cpp:630
clang::Decl::getLocation
SourceLocation getLocation() const
Definition: DeclBase.h:425
clang::HeaderSearchOptions::UseBuiltinIncludes
unsigned UseBuiltinIncludes
Include the compiler builtin includes.
Definition: HeaderSearchOptions.h:188
clang::PreprocessorOptions::Macros
std::vector< std::pair< std::string, bool > > Macros
Definition: PreprocessorOptions.h:66
clang::finalize
void finalize(TemplateInstantiationCallbackPtrs &Callbacks, const Sema &TheSema)
Definition: TemplateInstCallback.h:52
clang::serialization::ModuleFile
Information about a module that has been loaded by the ASTReader.
Definition: ModuleFile.h:111
clang::HeaderSearch::getModuleMap
ModuleMap & getModuleMap()
Retrieve the module map.
Definition: HeaderSearch.h:777
clang::FrontendOptions::CodeCompletionAt
ParsedSourceLocation CodeCompletionAt
If given, enable code completion at the provided location.
Definition: FrontendOptions.h:442
clang::CompilerInstance::getHeaderSearchOpts
HeaderSearchOptions & getHeaderSearchOpts()
Definition: CompilerInstance.h:289
clang::PPCallbacks::moduleImport
virtual void moduleImport(SourceLocation ImportLoc, ModuleIdPath Path, const Module *Imported)
Callback invoked whenever there was an explicit module-import syntax.
Definition: PPCallbacks.h:149
clang::Preprocessor::getIdentifierInfo
IdentifierInfo * getIdentifierInfo(StringRef Name) const
Return information about the specified preprocessor identifier token.
Definition: Preprocessor.h:1290
llvm::IntrusiveRefCntPtr
Definition: LLVM.h:47
clang::LangOptions::CMK_HeaderUnit
@ CMK_HeaderUnit
Compiling a module header unit.
Definition: LangOptions.h:114
DependencyDirectivesSourceMinimizer.h
clang::ento::ObjKind::OS
@ OS
Indicates that the tracking object is a descendant of a referenced-counted OSObject,...
clang::OpenCL
@ OpenCL
clang::HeaderSearchOptions
HeaderSearchOptions - Helper class for storing options related to the initialization of the HeaderSea...
Definition: HeaderSearchOptions.h:68
clang::SkipFunctionBodiesScope::Preamble
@ Preamble
clang::DiagnosticsEngine::Report
DiagnosticBuilder Report(SourceLocation Loc, unsigned DiagID)
Issue the message to the client.
Definition: Diagnostic.h:1536
clang::GeneratePCHAction::BeginSourceFileAction
bool BeginSourceFileAction(CompilerInstance &CI) override
Callback at the start of processing a single input.
Definition: FrontendActions.cpp:180
clang::SyntaxOnlyAction::CreateASTConsumer
std::unique_ptr< ASTConsumer > CreateASTConsumer(CompilerInstance &CI, StringRef InFile) override
Create the AST consumer object for this action, if supported.
Definition: FrontendActions.cpp:358
clang::HeaderSearch::LookupFile
Optional< FileEntryRef > LookupFile(StringRef Filename, SourceLocation IncludeLoc, bool isAngled, ConstSearchDirIterator FromDir, ConstSearchDirIterator *CurDir, ArrayRef< std::pair< const FileEntry *, const DirectoryEntry * >> Includers, SmallVectorImpl< char > *SearchPath, SmallVectorImpl< char > *RelativePath, Module *RequestingModule, ModuleMap::KnownHeader *SuggestedModule, bool *IsMapped, bool *IsFrameworkFound, bool SkipCache=false, bool BuildSystemModule=false)
Given a "foo" or <foo> reference, look up the indicated file, return null on failure.
Definition: HeaderSearch.cpp:835
ASTConsumers.h
clang::GeneratePCHAction::CreateASTConsumer
std::unique_ptr< ASTConsumer > CreateASTConsumer(CompilerInstance &CI, StringRef InFile) override
Create the AST consumer object for this action, if supported.
Definition: FrontendActions.cpp:122
MultiplexConsumer.h