forked from OSchip/llvm-project
[clang] Use llvm::reverse. NFCI.
This commit is contained in:
parent
b5ef56f0bc
commit
8adb6d6de2
|
@ -1663,8 +1663,7 @@ void NamedDecl::printNestedNameSpecifier(raw_ostream &OS,
|
|||
NameInScope = ND->getDeclName();
|
||||
}
|
||||
|
||||
for (unsigned I = Contexts.size(); I != 0; --I) {
|
||||
const DeclContext *DC = Contexts[I - 1];
|
||||
for (const DeclContext *DC : llvm::reverse(Contexts)) {
|
||||
if (const auto *Spec = dyn_cast<ClassTemplateSpecializationDecl>(DC)) {
|
||||
OS << Spec->getName();
|
||||
const TemplateArgumentList &TemplateArgs = Spec->getTemplateArgs();
|
||||
|
|
|
@ -568,8 +568,7 @@ EmitMaterializeTemporaryExpr(const MaterializeTemporaryExpr *M) {
|
|||
// Perform derived-to-base casts and/or field accesses, to get from the
|
||||
// temporary object we created (and, potentially, for which we extended
|
||||
// the lifetime) to the subobject we're binding the reference to.
|
||||
for (unsigned I = Adjustments.size(); I != 0; --I) {
|
||||
SubobjectAdjustment &Adjustment = Adjustments[I-1];
|
||||
for (SubobjectAdjustment &Adjustment : llvm::reverse(Adjustments)) {
|
||||
switch (Adjustment.Kind) {
|
||||
case SubobjectAdjustment::DerivedToBaseAdjustment:
|
||||
Object =
|
||||
|
|
|
@ -2293,9 +2293,9 @@ static void addLinkOptionsPostorder(CodeGenModule &CGM, Module *Mod,
|
|||
}
|
||||
|
||||
// Import this module's dependencies.
|
||||
for (unsigned I = Mod->Imports.size(); I > 0; --I) {
|
||||
if (Visited.insert(Mod->Imports[I - 1]).second)
|
||||
addLinkOptionsPostorder(CGM, Mod->Imports[I-1], Metadata, Visited);
|
||||
for (Module *Import : llvm::reverse(Mod->Imports)) {
|
||||
if (Visited.insert(Import).second)
|
||||
addLinkOptionsPostorder(CGM, Import, Metadata, Visited);
|
||||
}
|
||||
|
||||
// Add linker options to link against the libraries/frameworks
|
||||
|
@ -2308,13 +2308,12 @@ static void addLinkOptionsPostorder(CodeGenModule &CGM, Module *Mod,
|
|||
if (Mod->UseExportAsModuleLinkName)
|
||||
return;
|
||||
|
||||
for (unsigned I = Mod->LinkLibraries.size(); I > 0; --I) {
|
||||
for (const Module::LinkLibrary &LL : llvm::reverse(Mod->LinkLibraries)) {
|
||||
// Link against a framework. Frameworks are currently Darwin only, so we
|
||||
// don't to ask TargetCodeGenInfo for the spelling of the linker option.
|
||||
if (Mod->LinkLibraries[I-1].IsFramework) {
|
||||
llvm::Metadata *Args[2] = {
|
||||
llvm::MDString::get(Context, "-framework"),
|
||||
llvm::MDString::get(Context, Mod->LinkLibraries[I - 1].Library)};
|
||||
if (LL.IsFramework) {
|
||||
llvm::Metadata *Args[2] = {llvm::MDString::get(Context, "-framework"),
|
||||
llvm::MDString::get(Context, LL.Library)};
|
||||
|
||||
Metadata.push_back(llvm::MDNode::get(Context, Args));
|
||||
continue;
|
||||
|
@ -2324,13 +2323,12 @@ static void addLinkOptionsPostorder(CodeGenModule &CGM, Module *Mod,
|
|||
if (IsELF) {
|
||||
llvm::Metadata *Args[2] = {
|
||||
llvm::MDString::get(Context, "lib"),
|
||||
llvm::MDString::get(Context, Mod->LinkLibraries[I - 1].Library),
|
||||
llvm::MDString::get(Context, LL.Library),
|
||||
};
|
||||
Metadata.push_back(llvm::MDNode::get(Context, Args));
|
||||
} else {
|
||||
llvm::SmallString<24> Opt;
|
||||
CGM.getTargetCodeGenInfo().getDependentLibraryOption(
|
||||
Mod->LinkLibraries[I - 1].Library, Opt);
|
||||
CGM.getTargetCodeGenInfo().getDependentLibraryOption(LL.Library, Opt);
|
||||
auto *OptString = llvm::MDString::get(Context, Opt);
|
||||
Metadata.push_back(llvm::MDNode::get(Context, OptString));
|
||||
}
|
||||
|
|
|
@ -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(
|
||||
|
@ -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;
|
||||
|
|
|
@ -387,14 +387,13 @@ StringRef CodeCompletionTUInfo::getParentName(const DeclContext *DC) {
|
|||
SmallString<128> S;
|
||||
llvm::raw_svector_ostream OS(S);
|
||||
bool First = true;
|
||||
for (unsigned I = Contexts.size(); I != 0; --I) {
|
||||
for (const DeclContext *CurDC : llvm::reverse(Contexts)) {
|
||||
if (First)
|
||||
First = false;
|
||||
else {
|
||||
OS << "::";
|
||||
}
|
||||
|
||||
const DeclContext *CurDC = Contexts[I - 1];
|
||||
if (const auto *CatImpl = dyn_cast<ObjCCategoryImplDecl>(CurDC))
|
||||
CurDC = CatImpl->getCategoryDecl();
|
||||
|
||||
|
|
Loading…
Reference in New Issue