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