Skip to content

Commit

Permalink
Fix code to follow the "Don’t use else after a return" rule.
Browse files Browse the repository at this point in the history
Summary:
Fix code to follow the "Don’t use else after a return" rule.
This is a followup from rL219792.

Reviewers: alexfh

Subscribers: klimek, cfe-commits

Differential Revision: http://reviews.llvm.org/D5826

llvm-svn: 219939
  • Loading branch information
sbenzaquen committed Oct 16, 2014
1 parent 92c8c95 commit b6f73bc
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions clang/lib/ASTMatchers/ASTMatchersInternal.cpp
Expand Up @@ -232,15 +232,15 @@ bool HasNameMatcher::matchesNodeUnqualified(const NamedDecl &Node) const {
if (Node.getIdentifier()) {
// Simple name.
return Name == Node.getName();
} else if (Node.getDeclName()) {
}
if (Node.getDeclName()) {
// Name needs to be constructed.
llvm::SmallString<128> NodeName;
llvm::raw_svector_ostream OS(NodeName);
Node.printName(OS);
return Name == OS.str();
} else {
return false;
}
return false;
}

bool HasNameMatcher::matchesNodeFull(const NamedDecl &Node) const {
Expand All @@ -249,11 +249,12 @@ bool HasNameMatcher::matchesNodeFull(const NamedDecl &Node) const {
Node.printQualifiedName(OS);
const StringRef FullName = OS.str();
const StringRef Pattern = Name;
if (Pattern.startswith("::")) {

if (Pattern.startswith("::"))
return FullName == Pattern;
} else {
return FullName.endswith(("::" + Pattern).str());
}

return FullName.endswith(Pattern) &&
FullName.drop_back(Pattern.size()).endswith("::");
}

bool HasNameMatcher::matchesNode(const NamedDecl &Node) const {
Expand Down

0 comments on commit b6f73bc

Please sign in to comment.