diff options
Diffstat (limited to 'contrib/llvm-project/clang/lib/Basic/Module.cpp')
-rw-r--r-- | contrib/llvm-project/clang/lib/Basic/Module.cpp | 65 |
1 files changed, 35 insertions, 30 deletions
diff --git a/contrib/llvm-project/clang/lib/Basic/Module.cpp b/contrib/llvm-project/clang/lib/Basic/Module.cpp index 9c4c83486c2d..8ec68237a0fc 100644 --- a/contrib/llvm-project/clang/lib/Basic/Module.cpp +++ b/contrib/llvm-project/clang/lib/Basic/Module.cpp @@ -59,9 +59,8 @@ Module::Module(StringRef Name, SourceLocation DefinitionLoc, Module *Parent, } Module::~Module() { - for (submodule_iterator I = submodule_begin(), IEnd = submodule_end(); - I != IEnd; ++I) { - delete *I; + for (auto *Submodule : SubModules) { + delete Submodule; } } @@ -108,6 +107,9 @@ static bool hasFeature(StringRef Feature, const LangOptions &LangOpts, .Case("cplusplus11", LangOpts.CPlusPlus11) .Case("cplusplus14", LangOpts.CPlusPlus14) .Case("cplusplus17", LangOpts.CPlusPlus17) + .Case("cplusplus20", LangOpts.CPlusPlus20) + .Case("cplusplus23", LangOpts.CPlusPlus23) + .Case("cplusplus26", LangOpts.CPlusPlus26) .Case("c99", LangOpts.C99) .Case("c11", LangOpts.C11) .Case("c17", LangOpts.C17) @@ -261,26 +263,24 @@ bool Module::fullModuleNameIs(ArrayRef<StringRef> nameParts) const { return nameParts.empty(); } -Module::DirectoryName Module::getUmbrellaDir() const { - if (Header U = getUmbrellaHeader()) - return {"", "", U.Entry->getDir()}; - - return {UmbrellaAsWritten, UmbrellaRelativeToRootModuleDirectory, - Umbrella.dyn_cast<const DirectoryEntry *>()}; +OptionalDirectoryEntryRef Module::getEffectiveUmbrellaDir() const { + if (Umbrella && Umbrella.is<FileEntryRef>()) + return Umbrella.get<FileEntryRef>().getDir(); + if (Umbrella && Umbrella.is<DirectoryEntryRef>()) + return Umbrella.get<DirectoryEntryRef>(); + return std::nullopt; } -void Module::addTopHeader(const FileEntry *File) { +void Module::addTopHeader(FileEntryRef File) { assert(File); TopHeaders.insert(File); } -ArrayRef<const FileEntry *> Module::getTopHeaders(FileManager &FileMgr) { +ArrayRef<FileEntryRef> Module::getTopHeaders(FileManager &FileMgr) { if (!TopHeaderNames.empty()) { - for (std::vector<std::string>::iterator - I = TopHeaderNames.begin(), E = TopHeaderNames.end(); I != E; ++I) { - if (auto FE = FileMgr.getFile(*I)) + for (StringRef TopHeaderName : TopHeaderNames) + if (auto FE = FileMgr.getOptionalFileRef(TopHeaderName)) TopHeaders.insert(*FE); - } TopHeaderNames.clear(); } @@ -339,11 +339,9 @@ void Module::markUnavailable(bool Unimportable) { Current->IsAvailable = false; Current->IsUnimportable |= Unimportable; - for (submodule_iterator Sub = Current->submodule_begin(), - SubEnd = Current->submodule_end(); - Sub != SubEnd; ++Sub) { - if (needUpdate(*Sub)) - Stack.push_back(*Sub); + for (auto *Submodule : Current->submodules()) { + if (needUpdate(Submodule)) + Stack.push_back(Submodule); } } } @@ -483,15 +481,15 @@ void Module::print(raw_ostream &OS, unsigned Indent, bool Dump) const { OS << "\n"; } - if (Header H = getUmbrellaHeader()) { + if (std::optional<Header> H = getUmbrellaHeaderAsWritten()) { OS.indent(Indent + 2); OS << "umbrella header \""; - OS.write_escaped(H.NameAsWritten); + OS.write_escaped(H->NameAsWritten); OS << "\"\n"; - } else if (DirectoryName D = getUmbrellaDir()) { + } else if (std::optional<DirectoryName> D = getUmbrellaDirAsWritten()) { OS.indent(Indent + 2); OS << "umbrella \""; - OS.write_escaped(D.NameAsWritten); + OS.write_escaped(D->NameAsWritten); OS << "\"\n"; } @@ -523,8 +521,8 @@ void Module::print(raw_ostream &OS, unsigned Indent, bool Dump) const { OS.indent(Indent + 2); OS << K.Prefix << "header \""; OS.write_escaped(H.NameAsWritten); - OS << "\" { size " << H.Entry->getSize() - << " mtime " << H.Entry->getModificationTime() << " }\n"; + OS << "\" { size " << H.Entry.getSize() + << " mtime " << H.Entry.getModificationTime() << " }\n"; } } for (auto *Unresolved : {&UnresolvedHeaders, &MissingHeaders}) { @@ -550,14 +548,13 @@ void Module::print(raw_ostream &OS, unsigned Indent, bool Dump) const { OS << "export_as" << ExportAsModule << "\n"; } - for (submodule_const_iterator MI = submodule_begin(), MIEnd = submodule_end(); - MI != MIEnd; ++MI) + for (auto *Submodule : submodules()) // Print inferred subframework modules so that we don't need to re-infer // them (requires expensive directory iteration + stat calls) when we build // the module. Regular inferred submodules are OK, as we need to look at all // those header files anyway. - if (!(*MI)->IsInferred || (*MI)->IsFramework) - (*MI)->print(OS, Indent + 2, Dump); + if (!Submodule->IsInferred || Submodule->IsFramework) + Submodule->print(OS, Indent + 2, Dump); for (unsigned I = 0, N = Exports.size(); I != N; ++I) { OS.indent(Indent + 2); @@ -698,6 +695,14 @@ void VisibleModuleSet::setVisible(Module *M, SourceLocation Loc, VisitModule({M, nullptr}); } +void VisibleModuleSet::makeTransitiveImportsVisible(Module *M, + SourceLocation Loc, + VisibleCallback Vis, + ConflictCallback Cb) { + for (auto *I : M->Imports) + setVisible(I, Loc, Vis, Cb); +} + ASTSourceDescriptor::ASTSourceDescriptor(Module &M) : Signature(M.Signature), ClangModule(&M) { if (M.Directory) |