Skip to content

Fix miscellaneous warnings generated by top-of-tree clang #29312

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 24 additions & 24 deletions lib/AST/FineGrainedDependenciesSourceFileDepGraphConstructor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -577,11 +577,11 @@ class SourceFileDepGraphConstructor {

SourceFileDeclFinder declFinder(SF, includePrivateDeps);
std::vector<std::pair<std::string, bool>> topLevelDepends;
for (const auto p: SF->getReferencedNameTracker()->getTopLevelNames())
for (const auto &p: SF->getReferencedNameTracker()->getTopLevelNames())
topLevelDepends.push_back(std::make_pair(p.getFirst().userFacingName(), p.getSecond()));

std::vector<std::pair<std::string, bool>> dynamicLookupDepends;
for (const auto p: SF->getReferencedNameTracker()->getDynamicLookupNames())
for (const auto &p: SF->getReferencedNameTracker()->getDynamicLookupNames())
dynamicLookupDepends.push_back(std::make_pair(p.getFirst().userFacingName(), p.getSecond()));

std::vector<std::pair<std::tuple<std::string, std::string, bool>, bool>> memberDepends;
Expand All @@ -594,27 +594,27 @@ class SourceFileDepGraphConstructor {
declIsPrivate(p.getFirst().first)),
p.getSecond()));

return SourceFileDepGraphConstructor(
swiftDeps,
includePrivateDeps,
hadCompilationError,

getInterfaceHash(SF),
topLevelDepends,
memberDepends,
dynamicLookupDepends,
depTracker.getDependencies(),

namesForProvidersOfAGivenType<NodeKind::topLevel>(declFinder.precedenceGroups),
namesForProvidersOfAGivenType<NodeKind::topLevel>(declFinder.memberOperatorDecls),
namesForProvidersOfAGivenType<NodeKind::topLevel>(declFinder.operators),
namesForProvidersOfAGivenType<NodeKind::topLevel>(declFinder.topNominals),
namesForProvidersOfAGivenType<NodeKind::topLevel>(declFinder.topValues),
namesForProvidersOfAGivenType<NodeKind::nominal>(declFinder.allNominals),
namesForProvidersOfAGivenType<NodeKind::potentialMember>(declFinder.potentialMemberHolders),
namesForProvidersOfAGivenType<NodeKind::member>(declFinder.valuesInExtensions),
namesForProvidersOfAGivenType<NodeKind::dynamicLookup>(declFinder.classMembers)
);
return SourceFileDepGraphConstructor(
swiftDeps,
includePrivateDeps,
hadCompilationError,

getInterfaceHash(SF),
topLevelDepends,
memberDepends,
dynamicLookupDepends,
depTracker.getDependencies(),

namesForProvidersOfAGivenType<NodeKind::topLevel>(declFinder.precedenceGroups),
namesForProvidersOfAGivenType<NodeKind::topLevel>(declFinder.memberOperatorDecls),
namesForProvidersOfAGivenType<NodeKind::topLevel>(declFinder.operators),
namesForProvidersOfAGivenType<NodeKind::topLevel>(declFinder.topNominals),
namesForProvidersOfAGivenType<NodeKind::topLevel>(declFinder.topValues),
namesForProvidersOfAGivenType<NodeKind::nominal>(declFinder.allNominals),
namesForProvidersOfAGivenType<NodeKind::potentialMember>(declFinder.potentialMemberHolders),
namesForProvidersOfAGivenType<NodeKind::member>(declFinder.valuesInExtensions),
namesForProvidersOfAGivenType<NodeKind::dynamicLookup>(declFinder.classMembers)
);
}
// clang-format on

Expand Down Expand Up @@ -652,7 +652,7 @@ class SourceFileDepGraphConstructor {
static std::vector<ContextNameFingerprint>
namesForProvidersOfAGivenType(std::vector<ContentsT> &contentsVec) {
std::vector<ContextNameFingerprint> result;
for (const auto declOrPair : contentsVec)
for (const auto &declOrPair : contentsVec)
result.push_back(ContextNameFingerprint(
DependencyKey::computeContextForProvidedEntity<kind>(declOrPair),
DependencyKey::computeNameForProvidedEntity<kind>(declOrPair),
Expand Down
2 changes: 1 addition & 1 deletion lib/Driver/FineGrainedDependencyDriverGraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ void ModuleDepGraph::verifyExternalDependencyUniqueness(
void ModuleDepGraph::verifyCanFindEachJob() const {
FrontendStatsTracer tracer(stats,
"fine-grained-dependencies-verifyCanFindEachJob");
for (const auto p : jobsBySwiftDeps) {
for (const auto &p : jobsBySwiftDeps) {
getJob(p.first);
}
}
Expand Down
4 changes: 2 additions & 2 deletions lib/Driver/ParseableOutput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ class DetailedCommandBasedMessage : public CommandBasedMessage {
if (const auto *BJAction = dyn_cast<BackendJobAction>(&Cmd.getSource())) {
Inputs.push_back(CommandInput(OutFiles[BJAction->getInputIndex()]));
} else {
for (const std::string &FileName : OutFiles) {
for (const std::string FileName : OutFiles) {
Inputs.push_back(CommandInput(FileName));
}
}
Expand All @@ -134,7 +134,7 @@ class DetailedCommandBasedMessage : public CommandBasedMessage {
// TODO: set up Outputs appropriately.
file_types::ID PrimaryOutputType = Cmd.getOutput().getPrimaryOutputType();
if (PrimaryOutputType != file_types::TY_Nothing) {
for (const std::string &OutputFileName : Cmd.getOutput().
for (const std::string OutputFileName : Cmd.getOutput().
getPrimaryOutputFilenames()) {
Outputs.push_back(OutputPair(PrimaryOutputType, OutputFileName));
}
Expand Down
2 changes: 1 addition & 1 deletion lib/IDE/CodeCompletion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1307,7 +1307,7 @@ class CodeCompletionCallbacksImpl : public CodeCompletionCallbacks {
Component->getLoc() });
if (auto Module = Context.getLoadedModule(AccessPath))
ParsedTypeLoc.setType(ModuleType::get(Module));
return true;
return true;
}
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/IRGen/GenProto.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2717,7 +2717,7 @@ void NecessaryBindings::addTypeMetadata(CanType type) {
return;
}
if (auto fn = dyn_cast<FunctionType>(type)) {
for (const auto &elt : fn.getParams())
for (const auto elt : fn.getParams())
addTypeMetadata(elt.getPlainType());
addTypeMetadata(fn.getResult());
return;
Expand Down
2 changes: 1 addition & 1 deletion lib/IRGen/MetadataPath.h
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ class MetadataPath {
/// Return an abstract measurement of the cost of this path.
OperationCost cost() const {
auto cost = OperationCost::Free;
for (const Component &component : Path)
for (const Component component : Path)
cost += component.cost();
return cost;
}
Expand Down
6 changes: 3 additions & 3 deletions lib/SIL/DynamicCasts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1161,9 +1161,9 @@ bool swift::canUseScalarCheckedCastInstructions(SILModule &M,
if (!objectType.isAnyClassReferenceType())
return false;

auto super = archetype->getSuperclass();
if (super.isNull())
return false;
auto super = archetype->getSuperclass();
if (super.isNull())
return false;

// A base class constraint that isn't NSError rules out the archetype being
// bound to NSError.
Expand Down
1 change: 0 additions & 1 deletion lib/SILOptimizer/Mandatory/DIMemoryUseCollector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,6 @@ SILValue DIMemoryObjectInfo::emitElementAddressForDestroy(
// If we have a class, we can use a borrow directly and avoid ref
// count traffic.
if (isa<ClassDecl>(NTD) && Ptr->getType().isAddress()) {
SILValue Original = Ptr;
SILValue Borrowed = Ptr = B.createLoadBorrow(Loc, Ptr);
EndScopeList.emplace_back(Borrowed, EndScopeKind::Borrow);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/SILOptimizer/Mandatory/MandatoryInlining.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,7 @@ getCalleeFunction(SILFunction *F, FullApplySite AI, bool &IsThick,
FullArgs.clear();

// First grab our basic arguments from our apply.
for (const auto &Arg : AI.getArguments())
for (const auto Arg : AI.getArguments())
FullArgs.push_back(Arg);

// Then grab a first approximation of our apply by stripping off all copy
Expand Down
4 changes: 2 additions & 2 deletions lib/SILOptimizer/SILCombiner/SILCombinerMiscVisitors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1284,9 +1284,9 @@ SILInstruction *SILCombiner::visitCondBranchInst(CondBranchInst *CBI) {
X->getType() ==
SILType::getBuiltinIntegerType(1, CBI->getModule().getASTContext())) {
SmallVector<SILValue, 4> OrigTrueArgs, OrigFalseArgs;
for (const auto &Op : CBI->getTrueArgs())
for (const auto Op : CBI->getTrueArgs())
OrigTrueArgs.push_back(Op);
for (const auto &Op : CBI->getFalseArgs())
for (const auto Op : CBI->getFalseArgs())
OrigFalseArgs.push_back(Op);
return Builder.createCondBranch(CBI->getLoc(), X,
CBI->getFalseBB(), OrigFalseArgs,
Expand Down
2 changes: 1 addition & 1 deletion lib/SILOptimizer/UtilityPasses/SerializeSILPass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ static bool hasOpaqueArchetypeOperand(TypeExpansionContext context,
static bool hasOpaqueArchetypeResult(TypeExpansionContext context,
SILInstruction &inst) {
// Check the results for opaque types.
for (const auto &res : inst.getResults())
for (const auto res : inst.getResults())
if (opaqueArchetypeWouldChange(context, res->getType().getASTType()))
return true;
return false;
Expand Down
2 changes: 1 addition & 1 deletion lib/SILOptimizer/Utils/SILInliner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ SILInliner::inlineFullApply(FullApplySite apply,
SILOptFunctionBuilder &funcBuilder) {
assert(apply.canOptimize());
SmallVector<SILValue, 8> appliedArgs;
for (const auto &arg : apply.getArguments())
for (const auto arg : apply.getArguments())
appliedArgs.push_back(arg);

SILFunction *caller = apply.getFunction();
Expand Down
2 changes: 1 addition & 1 deletion stdlib/public/Reflection/TypeRefBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ void ClosureContextInfo::dump(FILE *file) const {

void TypeRefBuilder::dumpCaptureSection(FILE *file) {
for (const auto &sections : ReflectionInfos) {
for (const auto &descriptor : sections.Capture) {
for (const auto descriptor : sections.Capture) {
auto info = getClosureContextInfo(descriptor);
info.dump(file);
}
Expand Down