clang  6.0.0svn
Module.cpp
Go to the documentation of this file.
1 //===--- Module.cpp - Describe a module -----------------------------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file defines the Module class, which describes a module in the source
11 // code.
12 //
13 //===----------------------------------------------------------------------===//
14 
15 #include "clang/Basic/Module.h"
16 #include "clang/Basic/CharInfo.h"
19 #include "clang/Basic/TargetInfo.h"
20 #include "llvm/ADT/ArrayRef.h"
21 #include "llvm/ADT/SmallVector.h"
22 #include "llvm/ADT/StringSwitch.h"
23 #include "llvm/Support/ErrorHandling.h"
24 #include "llvm/Support/raw_ostream.h"
25 
26 using namespace clang;
27 
28 Module::Module(StringRef Name, SourceLocation DefinitionLoc, Module *Parent,
29  bool IsFramework, bool IsExplicit, unsigned VisibilityID)
30  : Name(Name), DefinitionLoc(DefinitionLoc), Parent(Parent), Directory(),
31  Umbrella(), ASTFile(nullptr), VisibilityID(VisibilityID),
32  IsMissingRequirement(false), HasIncompatibleModuleFile(false),
33  IsAvailable(true), IsFromModuleFile(false), IsFramework(IsFramework),
34  IsExplicit(IsExplicit), IsSystem(false), IsExternC(false),
35  IsInferred(false), InferSubmodules(false), InferExplicitSubmodules(false),
36  InferExportWildcard(false), ConfigMacrosExhaustive(false),
37  NoUndeclaredIncludes(false), NameVisibility(Hidden) {
38  if (Parent) {
39  if (!Parent->isAvailable())
40  IsAvailable = false;
41  if (Parent->IsSystem)
42  IsSystem = true;
43  if (Parent->IsExternC)
44  IsExternC = true;
45  if (Parent->NoUndeclaredIncludes)
46  NoUndeclaredIncludes = true;
48 
49  Parent->SubModuleIndex[Name] = Parent->SubModules.size();
50  Parent->SubModules.push_back(this);
51  }
52 }
53 
56  I != IEnd; ++I) {
57  delete *I;
58  }
59 }
60 
61 /// \brief Determine whether a translation unit built using the current
62 /// language options has the given feature.
63 static bool hasFeature(StringRef Feature, const LangOptions &LangOpts,
64  const TargetInfo &Target) {
65  bool HasFeature = llvm::StringSwitch<bool>(Feature)
66  .Case("altivec", LangOpts.AltiVec)
67  .Case("blocks", LangOpts.Blocks)
68  .Case("coroutines", LangOpts.CoroutinesTS)
69  .Case("cplusplus", LangOpts.CPlusPlus)
70  .Case("cplusplus11", LangOpts.CPlusPlus11)
71  .Case("freestanding", LangOpts.Freestanding)
72  .Case("gnuinlineasm", LangOpts.GNUAsm)
73  .Case("objc", LangOpts.ObjC1)
74  .Case("objc_arc", LangOpts.ObjCAutoRefCount)
75  .Case("opencl", LangOpts.OpenCL)
76  .Case("tls", Target.isTLSSupported())
77  .Case("zvector", LangOpts.ZVector)
78  .Default(Target.hasFeature(Feature));
79  if (!HasFeature)
80  HasFeature = std::find(LangOpts.ModuleFeatures.begin(),
81  LangOpts.ModuleFeatures.end(),
82  Feature) != LangOpts.ModuleFeatures.end();
83  return HasFeature;
84 }
85 
86 bool Module::isAvailable(const LangOptions &LangOpts, const TargetInfo &Target,
87  Requirement &Req,
88  UnresolvedHeaderDirective &MissingHeader) const {
89  if (IsAvailable)
90  return true;
91 
92  for (const Module *Current = this; Current; Current = Current->Parent) {
93  for (unsigned I = 0, N = Current->Requirements.size(); I != N; ++I) {
94  if (hasFeature(Current->Requirements[I].first, LangOpts, Target) !=
95  Current->Requirements[I].second) {
96  Req = Current->Requirements[I];
97  return false;
98  }
99  }
100  if (!Current->MissingHeaders.empty()) {
101  MissingHeader = Current->MissingHeaders.front();
102  return false;
103  }
104  }
105 
106  llvm_unreachable("could not find a reason why module is unavailable");
107 }
108 
109 bool Module::isSubModuleOf(const Module *Other) const {
110  const Module *This = this;
111  do {
112  if (This == Other)
113  return true;
114 
115  This = This->Parent;
116  } while (This);
117 
118  return false;
119 }
120 
122  const Module *Result = this;
123  while (Result->Parent)
124  Result = Result->Parent;
125 
126  return Result;
127 }
128 
129 static StringRef getModuleNameFromComponent(
130  const std::pair<std::string, SourceLocation> &IdComponent) {
131  return IdComponent.first;
132 }
133 static StringRef getModuleNameFromComponent(StringRef R) { return R; }
134 
135 template<typename InputIter>
136 static void printModuleId(raw_ostream &OS, InputIter Begin, InputIter End,
137  bool AllowStringLiterals = true) {
138  for (InputIter It = Begin; It != End; ++It) {
139  if (It != Begin)
140  OS << ".";
141 
142  StringRef Name = getModuleNameFromComponent(*It);
143  if (!AllowStringLiterals || isValidIdentifier(Name))
144  OS << Name;
145  else {
146  OS << '"';
147  OS.write_escaped(Name);
148  OS << '"';
149  }
150  }
151 }
152 
153 template<typename Container>
154 static void printModuleId(raw_ostream &OS, const Container &C) {
155  return printModuleId(OS, C.begin(), C.end());
156 }
157 
158 std::string Module::getFullModuleName(bool AllowStringLiterals) const {
160 
161  // Build up the set of module names (from innermost to outermost).
162  for (const Module *M = this; M; M = M->Parent)
163  Names.push_back(M->Name);
164 
165  std::string Result;
166 
167  llvm::raw_string_ostream Out(Result);
168  printModuleId(Out, Names.rbegin(), Names.rend(), AllowStringLiterals);
169  Out.flush();
170 
171  return Result;
172 }
173 
175  for (const Module *M = this; M; M = M->Parent) {
176  if (nameParts.empty() || M->Name != nameParts.back())
177  return false;
178  nameParts = nameParts.drop_back();
179  }
180  return nameParts.empty();
181 }
182 
184  if (Header U = getUmbrellaHeader())
185  return {"", U.Entry->getDir()};
186 
187  return {UmbrellaAsWritten, Umbrella.dyn_cast<const DirectoryEntry *>()};
188 }
189 
191  if (!TopHeaderNames.empty()) {
192  for (std::vector<std::string>::iterator
193  I = TopHeaderNames.begin(), E = TopHeaderNames.end(); I != E; ++I) {
194  if (const FileEntry *FE = FileMgr.getFile(*I))
195  TopHeaders.insert(FE);
196  }
197  TopHeaderNames.clear();
198  }
199 
200  return llvm::makeArrayRef(TopHeaders.begin(), TopHeaders.end());
201 }
202 
203 bool Module::directlyUses(const Module *Requested) const {
204  auto *Top = getTopLevelModule();
205 
206  // A top-level module implicitly uses itself.
207  if (Requested->isSubModuleOf(Top))
208  return true;
209 
210  for (auto *Use : Top->DirectUses)
211  if (Requested->isSubModuleOf(Use))
212  return true;
213 
214  // Anyone is allowed to use our builtin stddef.h and its accompanying module.
215  if (!Requested->Parent && Requested->Name == "_Builtin_stddef_max_align_t")
216  return true;
217 
218  return false;
219 }
220 
221 void Module::addRequirement(StringRef Feature, bool RequiredState,
222  const LangOptions &LangOpts,
223  const TargetInfo &Target) {
224  Requirements.push_back(Requirement(Feature, RequiredState));
225 
226  // If this feature is currently available, we're done.
227  if (hasFeature(Feature, LangOpts, Target) == RequiredState)
228  return;
229 
230  markUnavailable(/*MissingRequirement*/true);
231 }
232 
233 void Module::markUnavailable(bool MissingRequirement) {
234  auto needUpdate = [MissingRequirement](Module *M) {
235  return M->IsAvailable || (!M->IsMissingRequirement && MissingRequirement);
236  };
237 
238  if (!needUpdate(this))
239  return;
240 
242  Stack.push_back(this);
243  while (!Stack.empty()) {
244  Module *Current = Stack.back();
245  Stack.pop_back();
246 
247  if (!needUpdate(Current))
248  continue;
249 
250  Current->IsAvailable = false;
251  Current->IsMissingRequirement |= MissingRequirement;
252  for (submodule_iterator Sub = Current->submodule_begin(),
253  SubEnd = Current->submodule_end();
254  Sub != SubEnd; ++Sub) {
255  if (needUpdate(*Sub))
256  Stack.push_back(*Sub);
257  }
258  }
259 }
260 
261 Module *Module::findSubmodule(StringRef Name) const {
262  llvm::StringMap<unsigned>::const_iterator Pos = SubModuleIndex.find(Name);
263  if (Pos == SubModuleIndex.end())
264  return nullptr;
265 
266  return SubModules[Pos->getValue()];
267 }
268 
270  // All non-explicit submodules are exported.
271  for (std::vector<Module *>::const_iterator I = SubModules.begin(),
272  E = SubModules.end();
273  I != E; ++I) {
274  Module *Mod = *I;
275  if (!Mod->IsExplicit)
276  Exported.push_back(Mod);
277  }
278 
279  // Find re-exported modules by filtering the list of imported modules.
280  bool AnyWildcard = false;
281  bool UnrestrictedWildcard = false;
282  SmallVector<Module *, 4> WildcardRestrictions;
283  for (unsigned I = 0, N = Exports.size(); I != N; ++I) {
284  Module *Mod = Exports[I].getPointer();
285  if (!Exports[I].getInt()) {
286  // Export a named module directly; no wildcards involved.
287  Exported.push_back(Mod);
288 
289  continue;
290  }
291 
292  // Wildcard export: export all of the imported modules that match
293  // the given pattern.
294  AnyWildcard = true;
295  if (UnrestrictedWildcard)
296  continue;
297 
298  if (Module *Restriction = Exports[I].getPointer())
299  WildcardRestrictions.push_back(Restriction);
300  else {
301  WildcardRestrictions.clear();
302  UnrestrictedWildcard = true;
303  }
304  }
305 
306  // If there were any wildcards, push any imported modules that were
307  // re-exported by the wildcard restriction.
308  if (!AnyWildcard)
309  return;
310 
311  for (unsigned I = 0, N = Imports.size(); I != N; ++I) {
312  Module *Mod = Imports[I];
313  bool Acceptable = UnrestrictedWildcard;
314  if (!Acceptable) {
315  // Check whether this module meets one of the restrictions.
316  for (unsigned R = 0, NR = WildcardRestrictions.size(); R != NR; ++R) {
317  Module *Restriction = WildcardRestrictions[R];
318  if (Mod == Restriction || Mod->isSubModuleOf(Restriction)) {
319  Acceptable = true;
320  break;
321  }
322  }
323  }
324 
325  if (!Acceptable)
326  continue;
327 
328  Exported.push_back(Mod);
329  }
330 }
331 
332 void Module::buildVisibleModulesCache() const {
333  assert(VisibleModulesCache.empty() && "cache does not need building");
334 
335  // This module is visible to itself.
336  VisibleModulesCache.insert(this);
337 
338  // Every imported module is visible.
339  SmallVector<Module *, 16> Stack(Imports.begin(), Imports.end());
340  while (!Stack.empty()) {
341  Module *CurrModule = Stack.pop_back_val();
342 
343  // Every module transitively exported by an imported module is visible.
344  if (VisibleModulesCache.insert(CurrModule).second)
345  CurrModule->getExportedModules(Stack);
346  }
347 }
348 
349 void Module::print(raw_ostream &OS, unsigned Indent) const {
350  OS.indent(Indent);
351  if (IsFramework)
352  OS << "framework ";
353  if (IsExplicit)
354  OS << "explicit ";
355  OS << "module ";
356  printModuleId(OS, &Name, &Name + 1);
357 
358  if (IsSystem || IsExternC) {
359  OS.indent(Indent + 2);
360  if (IsSystem)
361  OS << " [system]";
362  if (IsExternC)
363  OS << " [extern_c]";
364  }
365 
366  OS << " {\n";
367 
368  if (!Requirements.empty()) {
369  OS.indent(Indent + 2);
370  OS << "requires ";
371  for (unsigned I = 0, N = Requirements.size(); I != N; ++I) {
372  if (I)
373  OS << ", ";
374  if (!Requirements[I].second)
375  OS << "!";
376  OS << Requirements[I].first;
377  }
378  OS << "\n";
379  }
380 
381  if (Header H = getUmbrellaHeader()) {
382  OS.indent(Indent + 2);
383  OS << "umbrella header \"";
384  OS.write_escaped(H.NameAsWritten);
385  OS << "\"\n";
386  } else if (DirectoryName D = getUmbrellaDir()) {
387  OS.indent(Indent + 2);
388  OS << "umbrella \"";
389  OS.write_escaped(D.NameAsWritten);
390  OS << "\"\n";
391  }
392 
393  if (!ConfigMacros.empty() || ConfigMacrosExhaustive) {
394  OS.indent(Indent + 2);
395  OS << "config_macros ";
397  OS << "[exhaustive]";
398  for (unsigned I = 0, N = ConfigMacros.size(); I != N; ++I) {
399  if (I)
400  OS << ", ";
401  OS << ConfigMacros[I];
402  }
403  OS << "\n";
404  }
405 
406  struct {
407  StringRef Prefix;
409  } Kinds[] = {{"", HK_Normal},
410  {"textual ", HK_Textual},
411  {"private ", HK_Private},
412  {"private textual ", HK_PrivateTextual},
413  {"exclude ", HK_Excluded}};
414 
415  for (auto &K : Kinds) {
416  assert(&K == &Kinds[K.Kind] && "kinds in wrong order");
417  for (auto &H : Headers[K.Kind]) {
418  OS.indent(Indent + 2);
419  OS << K.Prefix << "header \"";
420  OS.write_escaped(H.NameAsWritten);
421  OS << "\" { size " << H.Entry->getSize()
422  << " mtime " << H.Entry->getModificationTime() << " }\n";
423  }
424  }
425  for (auto *Unresolved : {&UnresolvedHeaders, &MissingHeaders}) {
426  for (auto &U : *Unresolved) {
427  OS.indent(Indent + 2);
428  OS << Kinds[U.Kind].Prefix << "header \"";
429  OS.write_escaped(U.FileName);
430  OS << "\"";
431  if (U.Size || U.ModTime) {
432  OS << " {";
433  if (U.Size)
434  OS << " size " << *U.Size;
435  if (U.ModTime)
436  OS << " mtime " << *U.ModTime;
437  OS << " }";
438  }
439  OS << "\n";
440  }
441  }
442 
443  if (!ExportAsModule.empty()) {
444  OS.indent(Indent + 2);
445  OS << "export_as" << ExportAsModule << "\n";
446  }
447 
449  MI != MIEnd; ++MI)
450  // Print inferred subframework modules so that we don't need to re-infer
451  // them (requires expensive directory iteration + stat calls) when we build
452  // the module. Regular inferred submodules are OK, as we need to look at all
453  // those header files anyway.
454  if (!(*MI)->IsInferred || (*MI)->IsFramework)
455  (*MI)->print(OS, Indent + 2);
456 
457  for (unsigned I = 0, N = Exports.size(); I != N; ++I) {
458  OS.indent(Indent + 2);
459  OS << "export ";
460  if (Module *Restriction = Exports[I].getPointer()) {
461  OS << Restriction->getFullModuleName(true);
462  if (Exports[I].getInt())
463  OS << ".*";
464  } else {
465  OS << "*";
466  }
467  OS << "\n";
468  }
469 
470  for (unsigned I = 0, N = UnresolvedExports.size(); I != N; ++I) {
471  OS.indent(Indent + 2);
472  OS << "export ";
474  if (UnresolvedExports[I].Wildcard)
475  OS << (UnresolvedExports[I].Id.empty() ? "*" : ".*");
476  OS << "\n";
477  }
478 
479  for (unsigned I = 0, N = DirectUses.size(); I != N; ++I) {
480  OS.indent(Indent + 2);
481  OS << "use ";
482  OS << DirectUses[I]->getFullModuleName(true);
483  OS << "\n";
484  }
485 
486  for (unsigned I = 0, N = UnresolvedDirectUses.size(); I != N; ++I) {
487  OS.indent(Indent + 2);
488  OS << "use ";
490  OS << "\n";
491  }
492 
493  for (unsigned I = 0, N = LinkLibraries.size(); I != N; ++I) {
494  OS.indent(Indent + 2);
495  OS << "link ";
496  if (LinkLibraries[I].IsFramework)
497  OS << "framework ";
498  OS << "\"";
499  OS.write_escaped(LinkLibraries[I].Library);
500  OS << "\"";
501  }
502 
503  for (unsigned I = 0, N = UnresolvedConflicts.size(); I != N; ++I) {
504  OS.indent(Indent + 2);
505  OS << "conflict ";
507  OS << ", \"";
508  OS.write_escaped(UnresolvedConflicts[I].Message);
509  OS << "\"\n";
510  }
511 
512  for (unsigned I = 0, N = Conflicts.size(); I != N; ++I) {
513  OS.indent(Indent + 2);
514  OS << "conflict ";
515  OS << Conflicts[I].Other->getFullModuleName(true);
516  OS << ", \"";
517  OS.write_escaped(Conflicts[I].Message);
518  OS << "\"\n";
519  }
520 
521  if (InferSubmodules) {
522  OS.indent(Indent + 2);
524  OS << "explicit ";
525  OS << "module * {\n";
526  if (InferExportWildcard) {
527  OS.indent(Indent + 4);
528  OS << "export *\n";
529  }
530  OS.indent(Indent + 2);
531  OS << "}\n";
532  }
533 
534  OS.indent(Indent);
535  OS << "}\n";
536 }
537 
538 LLVM_DUMP_METHOD void Module::dump() const {
539  print(llvm::errs());
540 }
541 
544  assert(Loc.isValid() && "setVisible expects a valid import location");
545  if (isVisible(M))
546  return;
547 
548  ++Generation;
549 
550  struct Visiting {
551  Module *M;
552  Visiting *ExportedBy;
553  };
554 
555  std::function<void(Visiting)> VisitModule = [&](Visiting V) {
556  // Modules that aren't available cannot be made visible.
557  if (!V.M->isAvailable())
558  return;
559 
560  // Nothing to do for a module that's already visible.
561  unsigned ID = V.M->getVisibilityID();
562  if (ImportLocs.size() <= ID)
563  ImportLocs.resize(ID + 1);
564  else if (ImportLocs[ID].isValid())
565  return;
566 
567  ImportLocs[ID] = Loc;
568  Vis(M);
569 
570  // Make any exported modules visible.
572  V.M->getExportedModules(Exports);
573  for (Module *E : Exports)
574  VisitModule({E, &V});
575 
576  for (auto &C : V.M->Conflicts) {
577  if (isVisible(C.Other)) {
579  for (Visiting *I = &V; I; I = I->ExportedBy)
580  Path.push_back(I->M);
581  Cb(Path, C.Other, C.Message);
582  }
583  }
584  };
585  VisitModule({M, nullptr});
586 }
unsigned IsAvailable
Whether this module is available in the current translation unit.
Definition: Module.h:202
SmallVector< UnresolvedExportDecl, 2 > UnresolvedExports
The set of export declarations that have yet to be resolved.
Definition: Module.h:294
std::string Name
The name of this module.
Definition: Module.h:60
SmallVector< UnresolvedHeaderDirective, 1 > MissingHeaders
Headers that are mentioned in the module map file but could not be found on the file system...
Definition: Module.h:180
Implements support for file system lookup, file system caching, and directory search management...
Definition: FileManager.h:116
Defines the clang::FileManager interface and associated types.
submodule_iterator submodule_begin()
Definition: Module.h:531
unsigned IsExternC
Whether this is an &#39;extern "C"&#39; module (which implicitly puts all headers in it within an &#39;extern "C"...
Definition: Module.h:220
std::vector< UnresolvedConflict > UnresolvedConflicts
The list of conflicts for which the module-id has not yet been resolved.
Definition: Module.h:338
Module * getTopLevelModule()
Retrieve the top-level module for this (sub)module, which may be this module.
Definition: Module.h:425
Defines the clang::Module class, which describes a module in the source code.
static bool hasFeature(StringRef Feature, const LangOptions &LangOpts, const TargetInfo &Target)
Determine whether a translation unit built using the current language options has the given feature...
Definition: Module.cpp:63
unsigned IsFramework
Whether this is a framework module.
Definition: Module.h:208
void addRequirement(StringRef Feature, bool RequiredState, const LangOptions &LangOpts, const TargetInfo &Target)
Add the given feature requirement to the list of features required by this module.
Definition: Module.cpp:221
llvm::function_ref< void(Module *M)> VisibleCallback
A callback to call when a module is made visible (directly or indirectly) by a call to setVisible...
Definition: Module.h:602
ModuleKind Kind
The kind of this module.
Definition: Module.h:79
void markUnavailable(bool MissingRequirement=false)
Mark this module and all of its submodules as unavailable.
Definition: Module.cpp:233
static bool HasFeature(const Preprocessor &PP, StringRef Feature)
HasFeature - Return true if we recognize and implement the feature specified by the identifier as a s...
SmallVector< Requirement, 2 > Requirements
The set of language features required to use this module.
Definition: Module.h:190
Header getUmbrellaHeader() const
Retrieve the header that serves as the umbrella header for this module.
Definition: Module.h:458
void setVisible(Module *M, SourceLocation Loc, VisibleCallback Vis=[](Module *) {}, ConflictCallback Cb=[](ArrayRef< Module *>, Module *, StringRef) {})
Make a specific module visible.
Definition: Module.cpp:542
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Definition: LangOptions.h:48
Describes a module or submodule.
Definition: Module.h:57
unsigned InferExportWildcard
Whether, when inferring submodules, the inferr submodules should export all modules they import (e...
Definition: Module.h:237
std::string getFullModuleName(bool AllowStringLiterals=false) const
Retrieve the full name of this module, including the path from its top-level module.
Definition: Module.cpp:158
bool isSubModuleOf(const Module *Other) const
Determine whether this module is a submodule of the given other module.
Definition: Module.cpp:109
Module * Parent
The parent of this module.
Definition: Module.h:83
submodule_iterator submodule_end()
Definition: Module.h:533
std::vector< Module * >::iterator submodule_iterator
Definition: Module.h:528
std::vector< std::string > ModuleFeatures
The names of any features to enable in module &#39;requires&#39; decls in addition to the hard-coded list in ...
Definition: LangOptions.h:136
unsigned NoUndeclaredIncludes
Whether files in this module can only include non-modular headers and headers from used modules...
Definition: Module.h:248
void getExportedModules(SmallVectorImpl< Module *> &Exported) const
Appends this module&#39;s list of exported modules to Exported.
Definition: Module.cpp:269
unsigned IsSystem
Whether this is a "system" module (which assumes that all headers in it are system headers)...
Definition: Module.h:215
NodeId Parent
Definition: ASTDiff.cpp:192
const FileEntry * getFile(StringRef Filename, bool OpenFile=false, bool CacheFailure=true)
Lookup, cache, and verify the specified file (real or virtual).
Module * findSubmodule(StringRef Name) const
Find the submodule with the given name.
Definition: Module.cpp:261
static LLVM_READONLY bool isValidIdentifier(StringRef S)
Return true if this is a valid ASCII identifier.
Definition: CharInfo.h:185
llvm::SmallSetVector< Module *, 2 > Imports
The set of modules imported by this module, and on which this module depends.
Definition: Module.h:267
const DirectoryEntry * Entry
Definition: Module.h:154
Exposes information about the current target.
Definition: TargetInfo.h:55
Defines the clang::LangOptions interface.
SmallVector< ModuleId, 2 > UnresolvedDirectUses
The set of use declarations that have yet to be resolved.
Definition: Module.h:300
SourceLocation End
int Id
Definition: ASTDiff.cpp:191
unsigned ConfigMacrosExhaustive
Whether the set of configuration macros is exhaustive.
Definition: Module.h:244
void print(raw_ostream &OS, unsigned Indent=0) const
Print the module map for this module to the given stream.
Definition: Module.cpp:349
static StringRef getModuleNameFromComponent(const std::pair< std::string, SourceLocation > &IdComponent)
Definition: Module.cpp:129
SourceLocation Begin
ArrayRef< const FileEntry * > getTopHeaders(FileManager &FileMgr)
The top-level headers associated with this module.
Definition: Module.cpp:190
llvm::SmallVector< LinkLibrary, 2 > LinkLibraries
The set of libraries or frameworks to link against when an entity from this module is used...
Definition: Module.h:321
Module(StringRef Name, SourceLocation DefinitionLoc, Module *Parent, bool IsFramework, bool IsExplicit, unsigned VisibilityID)
Construct a new module or submodule.
Definition: Module.cpp:28
std::vector< Module * >::const_iterator submodule_const_iterator
Definition: Module.h:529
bool isAvailable() const
Determine whether this module is available for use within the current translation unit...
Definition: Module.h:360
Information about a header directive as found in the module map file.
Definition: Module.h:143
The result type of a method or function.
SmallVector< ExportDecl, 2 > Exports
The set of export declarations.
Definition: Module.h:276
bool fullModuleNameIs(ArrayRef< StringRef > nameParts) const
Whether the full name of this module is equal to joining nameParts with "."s.
Definition: Module.cpp:174
#define false
Definition: stdbool.h:33
Encodes a location in the source.
std::string ExportAsModule
The module through which entities defined in this module will eventually be exposed, for use in "private" modules.
Definition: Module.h:105
Information about a directory name as found in the module map file.
Definition: Module.h:152
Cached information about one file (either on disk or in the virtual file system). ...
Definition: FileManager.h:59
static void printModuleId(raw_ostream &OS, InputIter Begin, InputIter End, bool AllowStringLiterals=true)
Definition: Module.cpp:136
SmallVector< Header, 2 > Headers[5]
The headers that are part of this module.
Definition: Module.h:160
SmallVector< UnresolvedHeaderDirective, 1 > UnresolvedHeaders
Headers that are mentioned in the module map file but that we have not yet attempted to resolve to a ...
Definition: Module.h:176
Dataflow Directional Tag Classes.
bool isValid() const
Return true if this is a valid SourceLocation object.
unsigned IsMissingRequirement
Whether this module is missing a feature from Requirements.
Definition: Module.h:193
Stored information about a header directive that was found in the module map file but has not been re...
Definition: Module.h:164
llvm::PointerUnion< const DirectoryEntry *, const FileEntry * > Umbrella
The umbrella header or directory.
Definition: Module.h:95
virtual bool hasFeature(StringRef Feature) const
Determine whether the given target has the given feature.
Definition: TargetInfo.h:911
llvm::function_ref< void(ArrayRef< Module * > Path, Module *Conflict, StringRef Message)> ConflictCallback
A callback to call when a module conflict is found.
Definition: Module.h:608
std::vector< Conflict > Conflicts
The list of conflicts.
Definition: Module.h:350
SmallVector< Module *, 2 > DirectUses
The directly used modules.
Definition: Module.h:297
std::pair< std::string, bool > Requirement
An individual requirement: a feature name and a flag indicating the required state of that feature...
Definition: Module.h:184
void dump() const
Dump the contents of this module to the given output stream.
Definition: Module.cpp:538
DirectoryName getUmbrellaDir() const
Retrieve the directory for which this module serves as the umbrella.
Definition: Module.cpp:183
Cached information about one directory (either on disk or in the virtual file system).
Definition: FileManager.h:45
unsigned InferSubmodules
Whether we should infer submodules for this module based on the headers.
Definition: Module.h:229
bool isTLSSupported() const
Whether the target supports thread-local storage.
Definition: TargetInfo.h:930
bool directlyUses(const Module *Requested) const
Determine whether this module has declared its intention to directly use another module.
Definition: Module.cpp:203
Defines the clang::TargetInfo interface.
std::vector< std::string > ConfigMacros
The set of "configuration macros", which are macros that (intentionally) change how this module is bu...
Definition: Module.h:325
std::string UmbrellaAsWritten
The name of the umbrella entry, as written in the module map.
Definition: Module.h:101
#define true
Definition: stdbool.h:32
unsigned IsExplicit
Whether this is an explicit submodule.
Definition: Module.h:211
unsigned InferExplicitSubmodules
Whether, when inferring submodules, the inferred submodules should be explicit.
Definition: Module.h:233