From b6f73bc5106f7c1e873316152f1373bfae2830f5 Mon Sep 17 00:00:00 2001 From: Samuel Benzaquen Date: Thu, 16 Oct 2014 17:50:19 +0000 Subject: [PATCH] =?UTF-8?q?Fix=20code=20to=20follow=20the=20"Don=E2=80=99t?= =?UTF-8?q?=20use=20else=20after=20a=20return"=20rule.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- clang/lib/ASTMatchers/ASTMatchersInternal.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/clang/lib/ASTMatchers/ASTMatchersInternal.cpp b/clang/lib/ASTMatchers/ASTMatchersInternal.cpp index b5d4b52ade22..53949d4fb1c4 100644 --- a/clang/lib/ASTMatchers/ASTMatchersInternal.cpp +++ b/clang/lib/ASTMatchers/ASTMatchersInternal.cpp @@ -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 { @@ -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 {