[gardening] C++ gardening: Terminate namespaces, fix argument names, ...

Changes:
* Terminate all namespaces with the correct closing comment.
* Make sure argument names in comments match the corresponding parameter name.
* Remove redundant get() calls on smart pointers.
* Prefer using "override" or "final" instead of "virtual". Remove "virtual" where appropriate.
This commit is contained in:
practicalswift
2016-12-17 00:32:42 +01:00
parent 2ff90611a8
commit 38be6125e5
165 changed files with 508 additions and 505 deletions

View File

@@ -66,7 +66,7 @@ namespace {
CompareSDKs,
DiagnoseSDKs,
};
}
} // end anonymous namespace
namespace options {
@@ -146,7 +146,7 @@ IgnoreRemovedDeclUSRs("ignored-usrs",
static llvm::cl::opt<std::string>
SwiftVersion("swift-version",
llvm::cl::desc("The Swift compiler version to invoke"));
}
} // namespace options
namespace {
@@ -1367,7 +1367,7 @@ public:
processDecl(VD);
}
};
} // End of anonymous namespace.
} // end anonymous namespace
namespace swift {
@@ -1501,8 +1501,8 @@ namespace swift {
return const_cast<SDKDeclAttrKind&>(seq[index]);
}
};
}
}
} // namespace json
} // namespace swift
namespace {// Anonymous namespace resumes.
@@ -1549,7 +1549,7 @@ public:
MatchedNodeListener &Listener) :
Left(Left), Right(Right), Listener(Listener) {}
virtual void match() override {
void match() override {
for (unsigned long i = 0; i < std::max(Left.size(), Right.size()); i ++) {
auto L = i < Left.size() ? Left[i] : nullptr;
auto R = i < Right.size() ? Right[i] : nullptr;
@@ -1600,7 +1600,7 @@ public:
IsFirstMatchBetter(IsFirstMatchBetter),
Listener(Listener){}
virtual void match() {
void match() override {
for (auto L : Left) {
if (auto Best = findBestMatch(L, Right)) {
MatchedRight.insert(Best.getValue());
@@ -1787,7 +1787,7 @@ public:
MatchedNodeListener &Listener) : Removed(Removed),
Added(Added), Listener(Listener) {}
virtual void match() override {
void match() override {
auto IsDecl = [](NodePtr P) { return isa<SDKNodeDecl>(P); };
for (auto R : SDKNodeVectorViewer(Removed, IsDecl)) {
for (auto A : SDKNodeVectorViewer(Added, IsDecl)) {
@@ -1957,7 +1957,7 @@ public:
SequentialRecursiveMatcher(NodePtr &Left, NodePtr &Right,
MatchedNodeListener &Listener) : Left(Left),
Right(Right), Listener(Listener) {}
virtual void match() override {
void match() override {
matchInternal(Left, Right);
}
};
@@ -1978,7 +1978,7 @@ class UpdatedNodesMap : public MatchedNodeListener {
NodePairVector MapImpl;
public:
virtual void foundMatch(NodePtr Left, NodePtr Right) {
void foundMatch(NodePtr Left, NodePtr Right) override {
assert(Left && Right && "Not update operation.");
MapImpl.push_back(std::make_pair(Left, Right));
}
@@ -2056,7 +2056,7 @@ class PrunePass : public MatchedNodeListener, public SDKTreeDiffPass {
public:
PrunePass() : UpdateMap(new UpdatedNodesMap()) {}
virtual void foundRemoveAddMatch(NodePtr Left, NodePtr Right) override {
void foundRemoveAddMatch(NodePtr Left, NodePtr Right) override {
if (!Left)
Right->annotate(NodeAnnotation::Added);
else if (!Right) {
@@ -2069,7 +2069,7 @@ public:
}
}
virtual void foundMatch(NodePtr Left, NodePtr Right) override {
void foundMatch(NodePtr Left, NodePtr Right) override {
assert(Left && Right);
Left->annotate(NodeAnnotation::Updated);
Right->annotate(NodeAnnotation::Updated);
@@ -2126,7 +2126,7 @@ public:
}
}
virtual void pass(NodePtr Left, NodePtr Right) override {
void pass(NodePtr Left, NodePtr Right) override {
foundMatch(Left, Right);
}
@@ -2143,7 +2143,7 @@ class MapUSRToNode : public SDKNodeVisitor {
friend class SDKNode; // for visit()
USRToNodeMap usrMap;
virtual void visit(NodePtr ptr) override {
void visit(NodePtr ptr) override {
if (auto D = dyn_cast<SDKNodeDecl>(ptr)) {
usrMap[D->getUsr()] = ptr;
}
@@ -2176,7 +2176,7 @@ class TypeMemberDiffFinder : public SDKNodeVisitor {
// Vector of {givenNodePtr, diffAgainstPtr}
NodePairVector TypeMemberDiffs;
virtual void visit(NodePtr node) override {
void visit(NodePtr node) override {
// Skip nodes that we don't have a correlate for
auto declNode = dyn_cast<SDKNodeDecl>(node);
if (!declNode)
@@ -2237,7 +2237,7 @@ public:
SearchVisitor(llvm::function_ref<bool(NodePtr)> Predicate) :
Predicate(Predicate) {}
virtual void visit(NodePtr Node) override {
void visit(NodePtr Node) override {
isFound |= Predicate(Node);
}
@@ -2330,7 +2330,7 @@ public:
ChangeRefinementPass(std::unique_ptr<UpdatedNodesMap> UpdateMap) :
UpdateMap(std::move(UpdateMap)) {}
virtual void pass(NodePtr Left, NodePtr Right) override {
void pass(NodePtr Left, NodePtr Right) override {
// Post-order visit is necessary since we propagate annotations bottom-up
IsVisitingLeft = true;
@@ -2339,7 +2339,7 @@ public:
SDKNode::postorderVisit(Right, *this);
}
virtual void visit(NodePtr N) override {
void visit(NodePtr N) override {
auto Node = dyn_cast<SDKNodeType>(N);
if (!Node || !Node->isAnnotatedAs(NodeAnnotation::Updated) ||
isUnhandledCase(Node))
@@ -2668,7 +2668,7 @@ class DiffItemEmitter : public SDKNodeVisitor {
return false;
}
virtual void visit(NodePtr Node) override {
void visit(NodePtr Node) override {
SDKNodeDecl *Parent = dyn_cast<SDKNodeDecl>(Node);
if (!Parent) {
if (auto TN = dyn_cast<SDKNodeType>(Node)) {
@@ -3088,7 +3088,7 @@ class NoEscapingFuncEmitter : public SDKNodeVisitor {
NoEscapeFuncParamVector &AllItems;
NoEscapingFuncEmitter(NoEscapeFuncParamVector &AllItems) : AllItems(AllItems) {}
virtual void visit(NodePtr Node) override {
void visit(NodePtr Node) override {
if (Node->getKind() != SDKNodeKind::TypeFunc)
return;
if (Node->getAs<SDKNodeTypeFunc>()->isEscaping())
@@ -3138,7 +3138,7 @@ class OverloadMemberFunctionEmitter : public SDKNodeVisitor {
std::vector<OverloadedFuncInfo> &AllItems;
virtual void visit(NodePtr Node) override {
void visit(NodePtr Node) override {
if (Node->getKind() != SDKNodeKind::Function)
return;
auto Parent = Node->getParent();
@@ -3200,7 +3200,7 @@ static StringRef constructFullTypeName(NodePtr Node) {
}
struct RenameDetectorForMemberDiff : public MatchedNodeListener {
void foundMatch(NodePtr Left, NodePtr Right) {
void foundMatch(NodePtr Left, NodePtr Right) override {
detectRename(Left, Right);
}
void workOn(NodePtr Left, NodePtr Right) {