clang  16.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 GenerateHeaderUnitAction::BeginSourceFileAction(CompilerInstance &CI) {
269  if (!CI.getLangOpts().CPlusPlusModules) {
270  CI.getDiagnostics().Report(diag::err_module_interface_requires_cpp_modules);
271  return false;
272  }
273  CI.getLangOpts().setCompilingModule(LangOptions::CMK_HeaderUnit);
275 }
276 
277 std::unique_ptr<raw_pwrite_stream>
278 GenerateHeaderUnitAction::CreateOutputFile(CompilerInstance &CI,
279  StringRef InFile) {
280  return CI.createDefaultOutputFile(/*Binary=*/true, InFile, "pcm");
281 }
282 
284 }
285 
286 std::unique_ptr<ASTConsumer>
288  return std::make_unique<ASTConsumer>();
289 }
290 
291 std::unique_ptr<ASTConsumer>
293  StringRef InFile) {
294  return std::make_unique<ASTConsumer>();
295 }
296 
297 std::unique_ptr<ASTConsumer>
299  return std::make_unique<ASTConsumer>();
300 }
301 
305  const std::string &Sysroot = CI.getHeaderSearchOpts().Sysroot;
306  std::unique_ptr<ASTReader> Reader(new ASTReader(
307  CI.getPreprocessor(), CI.getModuleCache(), &CI.getASTContext(),
309  Sysroot.empty() ? "" : Sysroot.c_str(),
311  /*AllowASTWithCompilerErrors*/ false,
312  /*AllowConfigurationMismatch*/ true,
313  /*ValidateSystemInputs*/ true));
314 
315  Reader->ReadAST(getCurrentFile(),
318  SourceLocation(),
320 }
321 
322 namespace {
323 struct TemplightEntry {
324  std::string Name;
326  std::string Event;
327  std::string DefinitionLocation;
328  std::string PointOfInstantiation;
329 };
330 } // namespace
331 
332 namespace llvm {
333 namespace yaml {
334 template <> struct MappingTraits<TemplightEntry> {
335  static void mapping(IO &io, TemplightEntry &fields) {
336  io.mapRequired("name", fields.Name);
337  io.mapRequired("kind", fields.Kind);
338  io.mapRequired("event", fields.Event);
339  io.mapRequired("orig", fields.DefinitionLocation);
340  io.mapRequired("poi", fields.PointOfInstantiation);
341  }
342 };
343 } // namespace yaml
344 } // namespace llvm
345 
346 namespace {
347 class DefaultTemplateInstCallback : public TemplateInstantiationCallback {
348  using CodeSynthesisContext = Sema::CodeSynthesisContext;
349 
350 public:
351  void initialize(const Sema &) override {}
352 
353  void finalize(const Sema &) override {}
354 
355  void atTemplateBegin(const Sema &TheSema,
356  const CodeSynthesisContext &Inst) override {
357  displayTemplightEntry<true>(llvm::outs(), TheSema, Inst);
358  }
359 
360  void atTemplateEnd(const Sema &TheSema,
361  const CodeSynthesisContext &Inst) override {
362  displayTemplightEntry<false>(llvm::outs(), TheSema, Inst);
363  }
364 
365 private:
366  static std::string toString(CodeSynthesisContext::SynthesisKind Kind) {
367  switch (Kind) {
368  case CodeSynthesisContext::TemplateInstantiation:
369  return "TemplateInstantiation";
370  case CodeSynthesisContext::DefaultTemplateArgumentInstantiation:
371  return "DefaultTemplateArgumentInstantiation";
372  case CodeSynthesisContext::DefaultFunctionArgumentInstantiation:
373  return "DefaultFunctionArgumentInstantiation";
374  case CodeSynthesisContext::ExplicitTemplateArgumentSubstitution:
375  return "ExplicitTemplateArgumentSubstitution";
376  case CodeSynthesisContext::DeducedTemplateArgumentSubstitution:
377  return "DeducedTemplateArgumentSubstitution";
378  case CodeSynthesisContext::PriorTemplateArgumentSubstitution:
379  return "PriorTemplateArgumentSubstitution";
380  case CodeSynthesisContext::DefaultTemplateArgumentChecking:
381  return "DefaultTemplateArgumentChecking";
382  case CodeSynthesisContext::ExceptionSpecEvaluation:
383  return "ExceptionSpecEvaluation";
384  case CodeSynthesisContext::ExceptionSpecInstantiation:
385  return "ExceptionSpecInstantiation";
386  case CodeSynthesisContext::DeclaringSpecialMember:
387  return "DeclaringSpecialMember";
388  case CodeSynthesisContext::DeclaringImplicitEqualityComparison:
389  return "DeclaringImplicitEqualityComparison";
390  case CodeSynthesisContext::DefiningSynthesizedFunction:
391  return "DefiningSynthesizedFunction";
392  case CodeSynthesisContext::RewritingOperatorAsSpaceship:
393  return "RewritingOperatorAsSpaceship";
394  case CodeSynthesisContext::Memoization:
395  return "Memoization";
396  case CodeSynthesisContext::ConstraintsCheck:
397  return "ConstraintsCheck";
398  case CodeSynthesisContext::ConstraintSubstitution:
399  return "ConstraintSubstitution";
400  case CodeSynthesisContext::ConstraintNormalization:
401  return "ConstraintNormalization";
402  case CodeSynthesisContext::RequirementParameterInstantiation:
403  return "RequirementParameterInstantiation";
404  case CodeSynthesisContext::ParameterMappingSubstitution:
405  return "ParameterMappingSubstitution";
406  case CodeSynthesisContext::RequirementInstantiation:
407  return "RequirementInstantiation";
408  case CodeSynthesisContext::NestedRequirementConstraintsCheck:
409  return "NestedRequirementConstraintsCheck";
410  case CodeSynthesisContext::InitializingStructuredBinding:
411  return "InitializingStructuredBinding";
412  case CodeSynthesisContext::MarkingClassDllexported:
413  return "MarkingClassDllexported";
414  case CodeSynthesisContext::BuildingBuiltinDumpStructCall:
415  return "BuildingBuiltinDumpStructCall";
416  }
417  return "";
418  }
419 
420  template <bool BeginInstantiation>
421  static void displayTemplightEntry(llvm::raw_ostream &Out, const Sema &TheSema,
422  const CodeSynthesisContext &Inst) {
423  std::string YAML;
424  {
425  llvm::raw_string_ostream OS(YAML);
426  llvm::yaml::Output YO(OS);
427  TemplightEntry Entry =
428  getTemplightEntry<BeginInstantiation>(TheSema, Inst);
429  llvm::yaml::EmptyContext Context;
430  llvm::yaml::yamlize(YO, Entry, true, Context);
431  }
432  Out << "---" << YAML << "\n";
433  }
434 
435  static void printEntryName(const Sema &TheSema, const Decl *Entity,
436  llvm::raw_string_ostream &OS) {
437  auto *NamedTemplate = cast<NamedDecl>(Entity);
438 
440  // FIXME: Also ask for FullyQualifiedNames?
441  Policy.SuppressDefaultTemplateArgs = false;
442  NamedTemplate->getNameForDiagnostic(OS, Policy, true);
443 
444  if (!OS.str().empty())
445  return;
446 
447  Decl *Ctx = Decl::castFromDeclContext(NamedTemplate->getDeclContext());
448  NamedDecl *NamedCtx = dyn_cast_or_null<NamedDecl>(Ctx);
449 
450  if (const auto *Decl = dyn_cast<TagDecl>(NamedTemplate)) {
451  if (const auto *R = dyn_cast<RecordDecl>(Decl)) {
452  if (R->isLambda()) {
453  OS << "lambda at ";
454  Decl->getLocation().print(OS, TheSema.getSourceManager());
455  return;
456  }
457  }
458  OS << "unnamed " << Decl->getKindName();
459  return;
460  }
461 
462  if (const auto *Decl = dyn_cast<ParmVarDecl>(NamedTemplate)) {
463  OS << "unnamed function parameter " << Decl->getFunctionScopeIndex()
464  << " ";
465  if (Decl->getFunctionScopeDepth() > 0)
466  OS << "(at depth " << Decl->getFunctionScopeDepth() << ") ";
467  OS << "of ";
468  NamedCtx->getNameForDiagnostic(OS, TheSema.getLangOpts(), true);
469  return;
470  }
471 
472  if (const auto *Decl = dyn_cast<TemplateTypeParmDecl>(NamedTemplate)) {
473  if (const Type *Ty = Decl->getTypeForDecl()) {
474  if (const auto *TTPT = dyn_cast_or_null<TemplateTypeParmType>(Ty)) {
475  OS << "unnamed template type parameter " << TTPT->getIndex() << " ";
476  if (TTPT->getDepth() > 0)
477  OS << "(at depth " << TTPT->getDepth() << ") ";
478  OS << "of ";
479  NamedCtx->getNameForDiagnostic(OS, TheSema.getLangOpts(), true);
480  return;
481  }
482  }
483  }
484 
485  if (const auto *Decl = dyn_cast<NonTypeTemplateParmDecl>(NamedTemplate)) {
486  OS << "unnamed template non-type parameter " << Decl->getIndex() << " ";
487  if (Decl->getDepth() > 0)
488  OS << "(at depth " << Decl->getDepth() << ") ";
489  OS << "of ";
490  NamedCtx->getNameForDiagnostic(OS, TheSema.getLangOpts(), true);
491  return;
492  }
493 
494  if (const auto *Decl = dyn_cast<TemplateTemplateParmDecl>(NamedTemplate)) {
495  OS << "unnamed template template parameter " << Decl->getIndex() << " ";
496  if (Decl->getDepth() > 0)
497  OS << "(at depth " << Decl->getDepth() << ") ";
498  OS << "of ";
499  NamedCtx->getNameForDiagnostic(OS, TheSema.getLangOpts(), true);
500  return;
501  }
502 
503  llvm_unreachable("Failed to retrieve a name for this entry!");
504  OS << "unnamed identifier";
505  }
506 
507  template <bool BeginInstantiation>
508  static TemplightEntry getTemplightEntry(const Sema &TheSema,
509  const CodeSynthesisContext &Inst) {
510  TemplightEntry Entry;
511  Entry.Kind = toString(Inst.Kind);
512  Entry.Event = BeginInstantiation ? "Begin" : "End";
513  llvm::raw_string_ostream OS(Entry.Name);
514  printEntryName(TheSema, Inst.Entity, OS);
515  const PresumedLoc DefLoc =
516  TheSema.getSourceManager().getPresumedLoc(Inst.Entity->getLocation());
517  if (!DefLoc.isInvalid())
518  Entry.DefinitionLocation = std::string(DefLoc.getFilename()) + ":" +
519  std::to_string(DefLoc.getLine()) + ":" +
520  std::to_string(DefLoc.getColumn());
521  const PresumedLoc PoiLoc =
522  TheSema.getSourceManager().getPresumedLoc(Inst.PointOfInstantiation);
523  if (!PoiLoc.isInvalid()) {
524  Entry.PointOfInstantiation = std::string(PoiLoc.getFilename()) + ":" +
525  std::to_string(PoiLoc.getLine()) + ":" +
526  std::to_string(PoiLoc.getColumn());
527  }
528  return Entry;
529  }
530 };
531 } // namespace
532 
533 std::unique_ptr<ASTConsumer>
535  return std::make_unique<ASTConsumer>();
536 }
537 
540 
541  // This part is normally done by ASTFrontEndAction, but needs to happen
542  // before Templight observers can be created
543  // FIXME: Move the truncation aspect of this into Sema, we delayed this till
544  // here so the source manager would be initialized.
545  EnsureSemaIsCreated(CI, *this);
546 
547  CI.getSema().TemplateInstCallbacks.push_back(
548  std::make_unique<DefaultTemplateInstCallback>());
550 }
551 
552 namespace {
553  /// AST reader listener that dumps module information for a module
554  /// file.
555  class DumpModuleInfoListener : public ASTReaderListener {
556  llvm::raw_ostream &Out;
557 
558  public:
559  DumpModuleInfoListener(llvm::raw_ostream &Out) : Out(Out) { }
560 
561 #define DUMP_BOOLEAN(Value, Text) \
562  Out.indent(4) << Text << ": " << (Value? "Yes" : "No") << "\n"
563 
564  bool ReadFullVersionInformation(StringRef FullVersion) override {
565  Out.indent(2)
566  << "Generated by "
567  << (FullVersion == getClangFullRepositoryVersion()? "this"
568  : "a different")
569  << " Clang: " << FullVersion << "\n";
571  }
572 
573  void ReadModuleName(StringRef ModuleName) override {
574  Out.indent(2) << "Module name: " << ModuleName << "\n";
575  }
576  void ReadModuleMapFile(StringRef ModuleMapPath) override {
577  Out.indent(2) << "Module map file: " << ModuleMapPath << "\n";
578  }
579 
580  bool ReadLanguageOptions(const LangOptions &LangOpts, bool Complain,
581  bool AllowCompatibleDifferences) override {
582  Out.indent(2) << "Language options:\n";
583 #define LANGOPT(Name, Bits, Default, Description) \
584  DUMP_BOOLEAN(LangOpts.Name, Description);
585 #define ENUM_LANGOPT(Name, Type, Bits, Default, Description) \
586  Out.indent(4) << Description << ": " \
587  << static_cast<unsigned>(LangOpts.get##Name()) << "\n";
588 #define VALUE_LANGOPT(Name, Bits, Default, Description) \
589  Out.indent(4) << Description << ": " << LangOpts.Name << "\n";
590 #define BENIGN_LANGOPT(Name, Bits, Default, Description)
591 #define BENIGN_ENUM_LANGOPT(Name, Type, Bits, Default, Description)
592 #include "clang/Basic/LangOptions.def"
593 
594  if (!LangOpts.ModuleFeatures.empty()) {
595  Out.indent(4) << "Module features:\n";
596  for (StringRef Feature : LangOpts.ModuleFeatures)
597  Out.indent(6) << Feature << "\n";
598  }
599 
600  return false;
601  }
602 
603  bool ReadTargetOptions(const TargetOptions &TargetOpts, bool Complain,
604  bool AllowCompatibleDifferences) override {
605  Out.indent(2) << "Target options:\n";
606  Out.indent(4) << " Triple: " << TargetOpts.Triple << "\n";
607  Out.indent(4) << " CPU: " << TargetOpts.CPU << "\n";
608  Out.indent(4) << " TuneCPU: " << TargetOpts.TuneCPU << "\n";
609  Out.indent(4) << " ABI: " << TargetOpts.ABI << "\n";
610 
611  if (!TargetOpts.FeaturesAsWritten.empty()) {
612  Out.indent(4) << "Target features:\n";
613  for (unsigned I = 0, N = TargetOpts.FeaturesAsWritten.size();
614  I != N; ++I) {
615  Out.indent(6) << TargetOpts.FeaturesAsWritten[I] << "\n";
616  }
617  }
618 
619  return false;
620  }
621 
622  bool ReadDiagnosticOptions(IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts,
623  bool Complain) override {
624  Out.indent(2) << "Diagnostic options:\n";
625 #define DIAGOPT(Name, Bits, Default) DUMP_BOOLEAN(DiagOpts->Name, #Name);
626 #define ENUM_DIAGOPT(Name, Type, Bits, Default) \
627  Out.indent(4) << #Name << ": " << DiagOpts->get##Name() << "\n";
628 #define VALUE_DIAGOPT(Name, Bits, Default) \
629  Out.indent(4) << #Name << ": " << DiagOpts->Name << "\n";
630 #include "clang/Basic/DiagnosticOptions.def"
631 
632  Out.indent(4) << "Diagnostic flags:\n";
633  for (const std::string &Warning : DiagOpts->Warnings)
634  Out.indent(6) << "-W" << Warning << "\n";
635  for (const std::string &Remark : DiagOpts->Remarks)
636  Out.indent(6) << "-R" << Remark << "\n";
637 
638  return false;
639  }
640 
641  bool ReadHeaderSearchOptions(const HeaderSearchOptions &HSOpts,
642  StringRef SpecificModuleCachePath,
643  bool Complain) override {
644  Out.indent(2) << "Header search options:\n";
645  Out.indent(4) << "System root [-isysroot=]: '" << HSOpts.Sysroot << "'\n";
646  Out.indent(4) << "Resource dir [ -resource-dir=]: '" << HSOpts.ResourceDir << "'\n";
647  Out.indent(4) << "Module Cache: '" << SpecificModuleCachePath << "'\n";
649  "Use builtin include directories [-nobuiltininc]");
651  "Use standard system include directories [-nostdinc]");
653  "Use standard C++ include directories [-nostdinc++]");
654  DUMP_BOOLEAN(HSOpts.UseLibcxx,
655  "Use libc++ (rather than libstdc++) [-stdlib=]");
656  return false;
657  }
658 
659  bool ReadPreprocessorOptions(const PreprocessorOptions &PPOpts,
660  bool Complain,
661  std::string &SuggestedPredefines) override {
662  Out.indent(2) << "Preprocessor options:\n";
664  "Uses compiler/target-specific predefines [-undef]");
666  "Uses detailed preprocessing record (for indexing)");
667 
668  if (!PPOpts.Macros.empty()) {
669  Out.indent(4) << "Predefined macros:\n";
670  }
671 
672  for (std::vector<std::pair<std::string, bool/*isUndef*/> >::const_iterator
673  I = PPOpts.Macros.begin(), IEnd = PPOpts.Macros.end();
674  I != IEnd; ++I) {
675  Out.indent(6);
676  if (I->second)
677  Out << "-U";
678  else
679  Out << "-D";
680  Out << I->first << "\n";
681  }
682  return false;
683  }
684 
685  /// Indicates that a particular module file extension has been read.
686  void readModuleFileExtension(
687  const ModuleFileExtensionMetadata &Metadata) override {
688  Out.indent(2) << "Module file extension '"
689  << Metadata.BlockName << "' " << Metadata.MajorVersion
690  << "." << Metadata.MinorVersion;
691  if (!Metadata.UserInfo.empty()) {
692  Out << ": ";
693  Out.write_escaped(Metadata.UserInfo);
694  }
695 
696  Out << "\n";
697  }
698 
699  /// Tells the \c ASTReaderListener that we want to receive the
700  /// input files of the AST file via \c visitInputFile.
701  bool needsInputFileVisitation() override { return true; }
702 
703  /// Tells the \c ASTReaderListener that we want to receive the
704  /// input files of the AST file via \c visitInputFile.
705  bool needsSystemInputFileVisitation() override { return true; }
706 
707  /// Indicates that the AST file contains particular input file.
708  ///
709  /// \returns true to continue receiving the next input file, false to stop.
710  bool visitInputFile(StringRef Filename, bool isSystem,
711  bool isOverridden, bool isExplicitModule) override {
712 
713  Out.indent(2) << "Input file: " << Filename;
714 
715  if (isSystem || isOverridden || isExplicitModule) {
716  Out << " [";
717  if (isSystem) {
718  Out << "System";
719  if (isOverridden || isExplicitModule)
720  Out << ", ";
721  }
722  if (isOverridden) {
723  Out << "Overridden";
724  if (isExplicitModule)
725  Out << ", ";
726  }
727  if (isExplicitModule)
728  Out << "ExplicitModule";
729 
730  Out << "]";
731  }
732 
733  Out << "\n";
734 
735  return true;
736  }
737 
738  /// Returns true if this \c ASTReaderListener wants to receive the
739  /// imports of the AST file via \c visitImport, false otherwise.
740  bool needsImportVisitation() const override { return true; }
741 
742  /// If needsImportVisitation returns \c true, this is called for each
743  /// AST file imported by this AST file.
744  void visitImport(StringRef ModuleName, StringRef Filename) override {
745  Out.indent(2) << "Imports module '" << ModuleName
746  << "': " << Filename.str() << "\n";
747  }
748 #undef DUMP_BOOLEAN
749  };
750 }
751 
753  // The Object file reader also supports raw ast files and there is no point in
754  // being strict about the module file format in -module-file-info mode.
755  CI.getHeaderSearchOpts().ModuleFormat = "obj";
756  return true;
757 }
758 
759 static StringRef ModuleKindName(Module::ModuleKind MK) {
760  switch (MK) {
762  return "Module Map Module";
764  return "Interface Unit";
766  return "Partition Interface";
768  return "Partition Implementation";
770  return "Header Unit";
772  return "Global Module Fragment";
774  return "Private Module Fragment";
775  }
776  llvm_unreachable("unknown module kind!");
777 }
778 
780  assert(isCurrentFileAST() && "dumping non-AST?");
781  // Set up the output file.
782  std::unique_ptr<llvm::raw_fd_ostream> OutFile;
784  StringRef OutputFileName = CI.getFrontendOpts().OutputFile;
785  if (!OutputFileName.empty() && OutputFileName != "-") {
786  std::error_code EC;
787  OutFile.reset(new llvm::raw_fd_ostream(OutputFileName.str(), EC,
788  llvm::sys::fs::OF_TextWithCRLF));
789  OutputStream = OutFile.get();
790  }
791  llvm::raw_ostream &Out = OutputStream ? *OutputStream : llvm::outs();
792 
793  Out << "Information for module file '" << getCurrentFile() << "':\n";
794  auto &FileMgr = CI.getFileManager();
795  auto Buffer = FileMgr.getBufferForFile(getCurrentFile());
796  StringRef Magic = (*Buffer)->getMemBufferRef().getBuffer();
797  bool IsRaw = (Magic.size() >= 4 && Magic[0] == 'C' && Magic[1] == 'P' &&
798  Magic[2] == 'C' && Magic[3] == 'H');
799  Out << " Module format: " << (IsRaw ? "raw" : "obj") << "\n";
800 
801  Preprocessor &PP = CI.getPreprocessor();
802  DumpModuleInfoListener Listener(Out);
803  HeaderSearchOptions &HSOpts = PP.getHeaderSearchInfo().getHeaderSearchOpts();
804 
805  // The FrontendAction::BeginSourceFile () method loads the AST so that much
806  // of the information is already available and modules should have been
807  // loaded.
808 
809  const LangOptions &LO = getCurrentASTUnit().getLangOpts();
810  if (LO.CPlusPlusModules && !LO.CurrentModule.empty()) {
811 
813  unsigned SubModuleCount = R->getTotalNumSubmodules();
815  Out << " ====== C++20 Module structure ======\n";
816 
817  if (MF.ModuleName != LO.CurrentModule)
818  Out << " Mismatched module names : " << MF.ModuleName << " and "
819  << LO.CurrentModule << "\n";
820 
821  struct SubModInfo {
822  unsigned Idx;
823  Module *Mod;
825  std::string &Name;
826  bool Seen;
827  };
828  std::map<std::string, SubModInfo> SubModMap;
829  auto PrintSubMapEntry = [&](std::string Name, Module::ModuleKind Kind) {
830  Out << " " << ModuleKindName(Kind) << " '" << Name << "'";
831  auto I = SubModMap.find(Name);
832  if (I == SubModMap.end())
833  Out << " was not found in the sub modules!\n";
834  else {
835  I->second.Seen = true;
836  Out << " is at index #" << I->second.Idx << "\n";
837  }
838  };
839  Module *Primary = nullptr;
840  for (unsigned Idx = 0; Idx <= SubModuleCount; ++Idx) {
841  Module *M = R->getModule(Idx);
842  if (!M)
843  continue;
844  if (M->Name == LO.CurrentModule) {
845  Primary = M;
846  Out << " " << ModuleKindName(M->Kind) << " '" << LO.CurrentModule
847  << "' is the Primary Module at index #" << Idx << "\n";
848  SubModMap.insert({M->Name, {Idx, M, M->Kind, M->Name, true}});
849  } else
850  SubModMap.insert({M->Name, {Idx, M, M->Kind, M->Name, false}});
851  }
852  if (Primary) {
853  if (!Primary->submodules().empty())
854  Out << " Sub Modules:\n";
855  for (auto *MI : Primary->submodules()) {
856  PrintSubMapEntry(MI->Name, MI->Kind);
857  }
858  if (!Primary->Imports.empty())
859  Out << " Imports:\n";
860  for (auto *IMP : Primary->Imports) {
861  PrintSubMapEntry(IMP->Name, IMP->Kind);
862  }
863  if (!Primary->Exports.empty())
864  Out << " Exports:\n";
865  for (unsigned MN = 0, N = Primary->Exports.size(); MN != N; ++MN) {
866  if (Module *M = Primary->Exports[MN].getPointer()) {
867  PrintSubMapEntry(M->Name, M->Kind);
868  }
869  }
870  }
871 
872  // Emit the macro definitions in the module file so that we can know how
873  // much definitions in the module file quickly.
874  // TODO: Emit the macro definition bodies completely.
875  if (auto FilteredMacros = llvm::make_filter_range(
876  R->getPreprocessor().macros(),
877  [](const auto &Macro) { return Macro.first->isFromAST(); });
878  !FilteredMacros.empty()) {
879  Out << " Macro Definitions:\n";
880  for (/*<IdentifierInfo *, MacroState> pair*/ const auto &Macro :
881  FilteredMacros)
882  Out << " " << Macro.first->getName() << "\n";
883  }
884 
885  // Now let's print out any modules we did not see as part of the Primary.
886  for (auto SM : SubModMap) {
887  if (!SM.second.Seen && SM.second.Mod) {
888  Out << " " << ModuleKindName(SM.second.Kind) << " '" << SM.first
889  << "' at index #" << SM.second.Idx
890  << " has no direct reference in the Primary\n";
891  }
892  }
893  Out << " ====== ======\n";
894  }
895 
896  // The reminder of the output is produced from the listener as the AST
897  // FileCcontrolBlock is (re-)parsed.
899  getCurrentFile(), FileMgr, CI.getModuleCache(),
901  /*FindModuleFileExtensions=*/true, Listener,
903 }
904 
905 //===----------------------------------------------------------------------===//
906 // Preprocessor Actions
907 //===----------------------------------------------------------------------===//
908 
912 
913  // Start lexing the specified input file.
914  llvm::MemoryBufferRef FromFile = SM.getBufferOrFake(SM.getMainFileID());
915  Lexer RawLex(SM.getMainFileID(), FromFile, SM, PP.getLangOpts());
916  RawLex.SetKeepWhitespaceMode(true);
917 
918  Token RawTok;
919  RawLex.LexFromRawLexer(RawTok);
920  while (RawTok.isNot(tok::eof)) {
921  PP.DumpToken(RawTok, true);
922  llvm::errs() << "\n";
923  RawLex.LexFromRawLexer(RawTok);
924  }
925 }
926 
929  // Start preprocessing the specified input file.
930  Token Tok;
931  PP.EnterMainSourceFile();
932  do {
933  PP.Lex(Tok);
934  PP.DumpToken(Tok, true);
935  llvm::errs() << "\n";
936  } while (Tok.isNot(tok::eof));
937 }
938 
941 
942  // Ignore unknown pragmas.
943  PP.IgnorePragmas();
944 
945  Token Tok;
946  // Start parsing the specified input file.
947  PP.EnterMainSourceFile();
948  do {
949  PP.Lex(Tok);
950  } while (Tok.isNot(tok::eof));
951 }
952 
955  // Output file may need to be set to 'Binary', to avoid converting Unix style
956  // line feeds (<LF>) to Microsoft style line feeds (<CR><LF>) on Windows.
957  //
958  // Look to see what type of line endings the file uses. If there's a
959  // CRLF, then we won't open the file up in binary mode. If there is
960  // just an LF or CR, then we will open the file up in binary mode.
961  // In this fashion, the output format should match the input format, unless
962  // the input format has inconsistent line endings.
963  //
964  // This should be a relatively fast operation since most files won't have
965  // all of their source code on a single line. However, that is still a
966  // concern, so if we scan for too long, we'll just assume the file should
967  // be opened in binary mode.
968 
969  bool BinaryMode = false;
970  if (llvm::Triple(LLVM_HOST_TRIPLE).isOSWindows()) {
971  BinaryMode = true;
972  const SourceManager &SM = CI.getSourceManager();
974  SM.getBufferOrNone(SM.getMainFileID())) {
975  const char *cur = Buffer->getBufferStart();
976  const char *end = Buffer->getBufferEnd();
977  const char *next = (cur != end) ? cur + 1 : end;
978 
979  // Limit ourselves to only scanning 256 characters into the source
980  // file. This is mostly a check in case the file has no
981  // newlines whatsoever.
982  if (end - cur > 256)
983  end = cur + 256;
984 
985  while (next < end) {
986  if (*cur == 0x0D) { // CR
987  if (*next == 0x0A) // CRLF
988  BinaryMode = false;
989 
990  break;
991  } else if (*cur == 0x0A) // LF
992  break;
993 
994  ++cur;
995  ++next;
996  }
997  }
998  }
999 
1000  std::unique_ptr<raw_ostream> OS =
1002  if (!OS) return;
1003 
1004  // If we're preprocessing a module map, start by dumping the contents of the
1005  // module itself before switching to the input buffer.
1006  auto &Input = getCurrentInput();
1007  if (Input.getKind().getFormat() == InputKind::ModuleMap) {
1008  if (Input.isFile()) {
1009  (*OS) << "# 1 \"";
1010  OS->write_escaped(Input.getFile());
1011  (*OS) << "\"\n";
1012  }
1013  getCurrentModule()->print(*OS);
1014  (*OS) << "#pragma clang module contents\n";
1015  }
1016 
1019 }
1020 
1022  switch (getCurrentFileKind().getLanguage()) {
1023  case Language::C:
1024  case Language::CXX:
1025  case Language::ObjC:
1026  case Language::ObjCXX:
1027  case Language::OpenCL:
1028  case Language::OpenCLCXX:
1029  case Language::CUDA:
1030  case Language::HIP:
1031  case Language::HLSL:
1032  break;
1033 
1034  case Language::Unknown:
1035  case Language::Asm:
1036  case Language::LLVM_IR:
1038  // We can't do anything with these.
1039  return;
1040  }
1041 
1042  // We don't expect to find any #include directives in a preprocessed input.
1043  if (getCurrentFileKind().isPreprocessed())
1044  return;
1045 
1047  auto Buffer = CI.getFileManager().getBufferForFile(getCurrentFile());
1048  if (Buffer) {
1049  unsigned Preamble =
1050  Lexer::ComputePreamble((*Buffer)->getBuffer(), CI.getLangOpts()).Size;
1051  llvm::outs().write((*Buffer)->getBufferStart(), Preamble);
1052  }
1053 }
1054 
1055 void DumpCompilerOptionsAction::ExecuteAction() {
1057  std::unique_ptr<raw_ostream> OSP =
1059  if (!OSP)
1060  return;
1061 
1062  raw_ostream &OS = *OSP;
1063  const Preprocessor &PP = CI.getPreprocessor();
1064  const LangOptions &LangOpts = PP.getLangOpts();
1065 
1066  // FIXME: Rather than manually format the JSON (which is awkward due to
1067  // needing to remove trailing commas), this should make use of a JSON library.
1068  // FIXME: Instead of printing enums as an integral value and specifying the
1069  // type as a separate field, use introspection to print the enumerator.
1070 
1071  OS << "{\n";
1072  OS << "\n\"features\" : [\n";
1073  {
1075 #define FEATURE(Name, Predicate) \
1076  ("\t{\"" #Name "\" : " + llvm::Twine(Predicate ? "true" : "false") + "},\n") \
1077  .toVector(Str);
1078 #include "clang/Basic/Features.def"
1079 #undef FEATURE
1080  // Remove the newline and comma from the last entry to ensure this remains
1081  // valid JSON.
1082  OS << Str.substr(0, Str.size() - 2);
1083  }
1084  OS << "\n],\n";
1085 
1086  OS << "\n\"extensions\" : [\n";
1087  {
1089 #define EXTENSION(Name, Predicate) \
1090  ("\t{\"" #Name "\" : " + llvm::Twine(Predicate ? "true" : "false") + "},\n") \
1091  .toVector(Str);
1092 #include "clang/Basic/Features.def"
1093 #undef EXTENSION
1094  // Remove the newline and comma from the last entry to ensure this remains
1095  // valid JSON.
1096  OS << Str.substr(0, Str.size() - 2);
1097  }
1098  OS << "\n]\n";
1099 
1100  OS << "}";
1101 }
1102 
1106  llvm::MemoryBufferRef FromFile = SM.getBufferOrFake(SM.getMainFileID());
1107 
1111  FromFile.getBuffer(), Tokens, Directives, &CI.getDiagnostics(),
1112  SM.getLocForStartOfFile(SM.getMainFileID()))) {
1113  assert(CI.getDiagnostics().hasErrorOccurred() &&
1114  "no errors reported for failure");
1115 
1116  // Preprocess the source when verifying the diagnostics to capture the
1117  // 'expected' comments.
1118  if (CI.getDiagnosticOpts().VerifyDiagnostics) {
1119  // Make sure we don't emit new diagnostics!
1122  PP.EnterMainSourceFile();
1123  Token Tok;
1124  do {
1125  PP.Lex(Tok);
1126  } while (Tok.isNot(tok::eof));
1127  }
1128  return;
1129  }
1130  printDependencyDirectivesAsSource(FromFile.getBuffer(), Directives,
1131  llvm::outs());
1132 }
1133 
1134 void GetDependenciesByModuleNameAction::ExecuteAction() {
1136  Preprocessor &PP = CI.getPreprocessor();
1138  FileID MainFileID = SM.getMainFileID();
1139  SourceLocation FileStart = SM.getLocForStartOfFile(MainFileID);
1141  IdentifierInfo *ModuleID = PP.getIdentifierInfo(ModuleName);
1142  Path.push_back(std::make_pair(ModuleID, FileStart));
1143  auto ModResult = CI.loadModule(FileStart, Path, Module::Hidden, false);
1144  PPCallbacks *CB = PP.getPPCallbacks();
1145  CB->moduleImport(SourceLocation(), Path, ModResult);
1146 }
clang::ASTUnit::getASTReader
IntrusiveRefCntPtr< ASTReader > getASTReader() const
Definition: ASTUnit.cpp:719
clang::Language::CUDA
@ CUDA
clang::scanSourceForDependencyDirectives
bool scanSourceForDependencyDirectives(StringRef Input, SmallVectorImpl< dependency_directives_scan::Token > &Tokens, SmallVectorImpl< dependency_directives_scan::Directive > &Directives, DiagnosticsEngine *Diags=nullptr, SourceLocation InputSourceLoc=SourceLocation())
Scan the input for the preprocessor directives that might have an effect on the dependencies for a co...
Definition: DependencyDirectivesScanner.cpp:841
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:434
clang::LangOptions::CMK_ModuleInterface
@ CMK_ModuleInterface
Compiling a C++ modules 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:534
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:65
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:1162
clang::Preprocessor::Lex
void Lex(Token &Result)
Lex the next token for this preprocessor.
Definition: Preprocessor.cpp:881
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:953
llvm::SmallVector
Definition: LLVM.h:38
clang::SourceLocation
Encodes a location in the source.
Definition: SourceLocation.h:86
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:2143
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:292
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:2715
clang::FrontendAction::getCurrentModule
Module * getCurrentModule() const
Definition: FrontendAction.cpp:150
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:1573
Module.h
clang::Module::Name
std::string Name
The name of this module.
Definition: Module.h:101
clang::Sema::getSourceManager
SourceManager & getSourceManager() const
Definition: Sema.h:1635
clang::Module::ModuleMapModule
@ ModuleMapModule
This is a module that was defined by a module map and built out of header files.
Definition: Module.h:109
clang::PrintDependencyDirectivesSourceMinimizerAction::ExecuteAction
void ExecuteAction() override
Callback to run the program action, using the initialized compiler instance.
Definition: FrontendActions.cpp:1103
clang::ASTReader::getPreprocessor
Preprocessor & getPreprocessor() const
Retrieve the preprocessor.
Definition: ASTReader.h:1716
llvm::Optional< llvm::MemoryBufferRef >
clang::SourceManager::getPresumedLoc
PresumedLoc getPresumedLoc(SourceLocation Loc, bool UseLineDirectives=true) const
Returns the "presumed" location of a SourceLocation specifies.
Definition: SourceManager.cpp:1521
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:9363
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:692
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:77
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:236
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:1769
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:8673
clang::HeaderSearchOptions::ModulesValidateDiagnosticOptions
unsigned ModulesValidateDiagnosticOptions
Definition: HeaderSearchOptions.h:217
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:716
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:752
llvm::yaml::MappingTraits< TemplightEntry >::mapping
static void mapping(IO &io, TemplightEntry &fields)
Definition: FrontendActions.cpp:335
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:636
clang::ParsedSourceLocation::FileName
std::string FileName
Definition: CommandLineSourceLoc.h:25
clang::Preprocessor::getLangOpts
const LangOptions & getLangOpts() const
Definition: Preprocessor.h:1065
clang::Sema::Context
ASTContext & Context
Definition: Sema.h:409
clang::Type
The base class of the type hierarchy.
Definition: Type.h:1565
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:78
clang::DumpTokensAction::ExecuteAction
void ExecuteAction() override
Callback to run the program action, using the initialized compiler instance.
Definition: FrontendActions.cpp:927
clang::DumpModuleInfoAction::ExecuteAction
void ExecuteAction() override
Implement the ExecuteAction interface by running Sema on the already-initialized AST consumer.
Definition: FrontendActions.cpp:779
clang::Sema::getLangOpts
const LangOptions & getLangOpts() const
Definition: Sema.h:1630
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::DumpRawTokensAction::ExecuteAction
void ExecuteAction() override
Callback to run the program action, using the initialized compiler instance.
Definition: FrontendActions.cpp:909
ModuleKindName
static StringRef ModuleKindName(Module::ModuleKind MK)
Definition: FrontendActions.cpp:759
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:302
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:315
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:98
clang::ASTReaderListener::ReadFullVersionInformation
virtual bool ReadFullVersionInformation(StringRef FullVersion)
Receives the full Clang version information.
Definition: ASTReader.h:121
clang::Module::Hidden
@ Hidden
All of the names in this module are hidden.
Definition: Module.h:336
clang::Module::ModulePartitionInterface
@ ModulePartitionInterface
This is a C++ 20 module partition interface.
Definition: Module.h:118
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:1713
clang::Module::Exports
SmallVector< ExportDecl, 2 > Exports
The set of export declarations.
Definition: Module.h:362
clang::Module::ModuleInterfaceUnit
@ ModuleInterfaceUnit
This is a C++20 module interface unit.
Definition: Module.h:112
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:1807
clang::threadSafety::sx::toString
std::string toString(const til::SExpr *E)
Definition: ThreadSafetyCommon.h:91
clang::DiagnosticsEngine::hasErrorOccurred
bool hasErrorOccurred() const
Definition: Diagnostic.h:838
clang::CompilerInstance::getSema
Sema & getSema() const
Definition: CompilerInstance.h:503
clang::FrontendOptions
FrontendOptions - Options for controlling the behavior of the frontend.
Definition: FrontendOptions.h:265
clang::SyntaxOnlyAction::~SyntaxOnlyAction
~SyntaxOnlyAction() override
Definition: FrontendActions.cpp:283
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:124
clang::Module::ModuleHeaderUnit
@ ModuleHeaderUnit
This is a C++ 20 header unit.
Definition: Module.h:115
clang::serialized_diags::Warning
@ Warning
Definition: SerializedDiagnostics.h:46
clang::RISCV::Policy
Policy
Definition: RISCVVIntrinsicUtils.h:96
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:440
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:324
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:108
clang::FrontendOptions::ASTDumpAll
unsigned ASTDumpAll
Whether we deserialize all decls when forming AST dumps.
Definition: FrontendOptions.h:318
clang::Sema::CodeSynthesisContext
A context in which code is being synthesized (where a source location alone is not sufficient to iden...
Definition: Sema.h:9137
clang::FrontendAction::getCompilerInstance
CompilerInstance & getCompilerInstance() const
Definition: FrontendAction.h:119
llvm::SmallString< 128 >
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:62
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:106
clang::PreprocessorOptions::UsePredefines
bool UsePredefines
Initialize the preprocessor with the compiler and target specific predefines.
Definition: PreprocessorOptions.h:73
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:1135
DependencyDirectivesScanner.h
clang::CompilerInstance::getPreprocessor
Preprocessor & getPreprocessor() const
Return the current preprocessor.
Definition: CompilerInstance.h:442
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:544
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:345
clang::FrontendOptions::ASTDumpLookups
unsigned ASTDumpLookups
Whether we include lookup table dumps in AST dumps.
Definition: FrontendOptions.h:321
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:930
clang::Module::submodules
llvm::iterator_range< submodule_iterator > submodules()
Definition: Module.h:713
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:468
clang::CompilerInstance::getModuleCache
InMemoryModuleCache & getModuleCache() const
Definition: CompilerInstance.h:817
clang::Preprocessor::getSourceManager
SourceManager & getSourceManager() const
Definition: Preprocessor.h:1069
clang::FrontendAction::getCurrentInput
const FrontendInputFile & getCurrentInput() const
Definition: FrontendAction.h:135
clang::InputKind::ModuleMap
@ ModuleMap
Definition: FrontendOptions.h:160
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:173
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::printDependencyDirectivesAsSource
void printDependencyDirectivesAsSource(StringRef Source, ArrayRef< dependency_directives_scan::Directive > Directives, llvm::raw_ostream &OS)
Print the previously scanned dependency directives as minimized source text.
Definition: DependencyDirectivesScanner.cpp:848
clang::ASTContext::getPrintingPolicy
const clang::PrintingPolicy & getPrintingPolicy() const
Definition: ASTContext.h:713
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:539
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:127
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:126
clang::Sema
Sema - This implements semantic analysis and AST building for C.
Definition: Sema.h:358
FrontendActions.h
clang::PreprocessOnlyAction::ExecuteAction
void ExecuteAction() override
Callback to run the program action, using the initialized compiler instance.
Definition: FrontendActions.cpp:939
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:1010
clang::Language::ObjC
@ ObjC
clang::PrintPreambleAction::ExecuteAction
void ExecuteAction() override
Callback to run the program action, using the initialized compiler instance.
Definition: FrontendActions.cpp:1021
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:349
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:167
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:85
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:327
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:81
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:254
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:341
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::ASTReader::readASTFileControlBlock
static bool readASTFileControlBlock(StringRef Filename, FileManager &FileMgr, const InMemoryModuleCache &ModuleCache, const PCHContainerReader &PCHContainerRdr, bool FindModuleFileExtensions, ASTReaderListener &Listener, bool ValidateDiagnosticOptions)
Read the control block for the named AST file.
Definition: ASTReader.cpp:5176
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
clang::DumpModuleInfoAction::OutputStream
llvm::raw_ostream * OutputStream
Definition: FrontendActions.h:182
ModuleFile.h
clang::Module::Kind
ModuleKind Kind
The kind of this module.
Definition: Module.h:131
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::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:538
clang::ASTReaderListener
Abstract interface for callback invocations by the ASTReader.
Definition: ASTReader.h:113
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:121
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::Preprocessor::macros
llvm::iterator_range< macro_iterator > macros(bool IncludeExternalMacros=true) const
Definition: Preprocessor.h:1324
clang::ASTFrontendAction::ExecuteAction
void ExecuteAction() override
Implement the ExecuteAction interface by running Sema on the already-initialized AST consumer.
Definition: FrontendAction.cpp:1143
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:298
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:272
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:1955
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:589
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:752
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:129
SM
#define SM(sm)
Definition: Cuda.cpp:79
clang::Preprocessor::getHeaderSearchInfo
HeaderSearch & getHeaderSearchInfo() const
Definition: Preprocessor.h:1070
DUMP_BOOLEAN
#define DUMP_BOOLEAN(Value, Text)
Definition: FrontendActions.cpp:561
clang::Decl::getLocation
SourceLocation getLocation() const
Definition: DeclBase.h:432
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:67
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::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:171
clang::Preprocessor::getIdentifierInfo
IdentifierInfo * getIdentifierInfo(StringRef Name) const
Return information about the specified preprocessor identifier token.
Definition: Preprocessor.h:1383
llvm::IntrusiveRefCntPtr
Definition: LLVM.h:47
clang::LangOptions::CMK_HeaderUnit
@ CMK_HeaderUnit
Compiling a module header unit.
Definition: LangOptions.h:114
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:1537
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:287
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