diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2022-03-20 11:40:34 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2022-05-14 11:43:05 +0000 |
commit | 349cc55c9796c4596a5b9904cd3281af295f878f (patch) | |
tree | 410c5a785075730a35f1272ca6a7adf72222ad03 /contrib/llvm-project/clang/lib/Lex/ModuleMap.cpp | |
parent | cb2ae6163174b90e999326ecec3699ee093a5d43 (diff) | |
parent | c0981da47d5696fe36474fcf86b4ce03ae3ff818 (diff) |
Merge llvm-project main llvmorg-14-init-10186-gff7f2cfa959b
This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-14-init-10186-gff7f2cfa959b.
PR: 261742
MFC after: 2 weeks
Diffstat (limited to 'contrib/llvm-project/clang/lib/Lex/ModuleMap.cpp')
-rw-r--r-- | contrib/llvm-project/clang/lib/Lex/ModuleMap.cpp | 31 |
1 files changed, 14 insertions, 17 deletions
diff --git a/contrib/llvm-project/clang/lib/Lex/ModuleMap.cpp b/contrib/llvm-project/clang/lib/Lex/ModuleMap.cpp index f9af7c2a24fb..9fa170410da3 100644 --- a/contrib/llvm-project/clang/lib/Lex/ModuleMap.cpp +++ b/contrib/llvm-project/clang/lib/Lex/ModuleMap.cpp @@ -167,8 +167,8 @@ static void appendSubframeworkPaths(Module *Mod, return; // Add Frameworks/Name.framework for each subframework. - for (unsigned I = Paths.size() - 1; I != 0; --I) - llvm::sys::path::append(Path, "Frameworks", Paths[I-1] + ".framework"); + for (StringRef Framework : llvm::drop_begin(llvm::reverse(Paths))) + llvm::sys::path::append(Path, "Frameworks", Framework + ".framework"); } Optional<FileEntryRef> ModuleMap::findHeader( @@ -338,7 +338,7 @@ static StringRef sanitizeFilenameAsIdentifier(StringRef Name, if (Name.empty()) return Name; - if (!isValidIdentifier(Name)) { + if (!isValidAsciiIdentifier(Name)) { // If we don't already have something with the form of an identifier, // create a buffer with the sanitized name. Buffer.clear(); @@ -346,7 +346,7 @@ static StringRef sanitizeFilenameAsIdentifier(StringRef Name, Buffer.push_back('_'); Buffer.reserve(Buffer.size() + Name.size()); for (unsigned I = 0, N = Name.size(); I != N; ++I) { - if (isIdentifierBody(Name[I])) + if (isAsciiIdentifierContinue(Name[I])) Buffer.push_back(Name[I]); else Buffer.push_back('_'); @@ -618,18 +618,18 @@ ModuleMap::findOrCreateModuleForHeaderInUmbrellaDir(const FileEntry *File) { // the actual header is located. bool Explicit = UmbrellaModule->InferExplicitSubmodules; - for (unsigned I = SkippedDirs.size(); I != 0; --I) { + for (const DirectoryEntry *SkippedDir : llvm::reverse(SkippedDirs)) { // Find or create the module that corresponds to this directory name. SmallString<32> NameBuf; StringRef Name = sanitizeFilenameAsIdentifier( - llvm::sys::path::stem(SkippedDirs[I-1]->getName()), NameBuf); + llvm::sys::path::stem(SkippedDir->getName()), NameBuf); Result = findOrCreateModule(Name, Result, /*IsFramework=*/false, Explicit).first; InferredModuleAllowedBy[Result] = UmbrellaModuleMap; Result->IsInferred = true; // Associate the module and the directory. - UmbrellaDirs[SkippedDirs[I-1]] = Result; + UmbrellaDirs[SkippedDir] = Result; // If inferred submodules export everything they import, add a // wildcard to the set of exports. @@ -745,12 +745,11 @@ ModuleMap::isHeaderUnavailableInModule(const FileEntry *Header, UmbrellaModule = UmbrellaModule->Parent; if (UmbrellaModule->InferSubmodules) { - for (unsigned I = SkippedDirs.size(); I != 0; --I) { + for (const DirectoryEntry *SkippedDir : llvm::reverse(SkippedDirs)) { // Find or create the module that corresponds to this directory name. SmallString<32> NameBuf; StringRef Name = sanitizeFilenameAsIdentifier( - llvm::sys::path::stem(SkippedDirs[I-1]->getName()), - NameBuf); + llvm::sys::path::stem(SkippedDir->getName()), NameBuf); Found = lookupModuleQualified(Name, Found); if (!Found) return false; @@ -989,9 +988,8 @@ Module *ModuleMap::inferFrameworkModule(const DirectoryEntry *FrameworkDir, // We're allowed to infer for this directory, but make sure it's okay // to infer this particular module. StringRef Name = llvm::sys::path::stem(FrameworkDirName); - canInfer = std::find(inferred->second.ExcludedModules.begin(), - inferred->second.ExcludedModules.end(), - Name) == inferred->second.ExcludedModules.end(); + canInfer = + !llvm::is_contained(inferred->second.ExcludedModules, Name); Attrs.IsSystem |= inferred->second.Attrs.IsSystem; Attrs.IsExternC |= inferred->second.Attrs.IsExternC; @@ -1218,9 +1216,8 @@ void ModuleMap::addHeader(Module *Mod, Module::Header Header, // FIXME: Should we diagnose if a header is listed twice in the // same module definition? auto &HeaderList = Headers[Header.Entry]; - for (auto H : HeaderList) - if (H == KH) - return; + if (llvm::is_contained(HeaderList, KH)) + return; HeaderList.push_back(KH); Mod->Headers[headerRoleToKind(Role)].push_back(Header); @@ -2174,7 +2171,7 @@ void ModuleMapParser::parseExternModuleDecl() { } if (auto File = SourceMgr.getFileManager().getFile(FileNameRef)) Map.parseModuleMapFile( - *File, /*IsSystem=*/false, + *File, IsSystem, Map.HeaderInfo.getHeaderSearchOpts().ModuleMapFileHomeIsCwd ? Directory : (*File)->getDir(), |