summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang/lib/ASTMatchers/ASTMatchersInternal.cpp15
1 files changed, 8 insertions, 7 deletions
diff --git a/clang/lib/ASTMatchers/ASTMatchersInternal.cpp b/clang/lib/ASTMatchers/ASTMatchersInternal.cpp
index b5d4b52ade2..53949d4fb1c 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 {
OpenPOWER on IntegriCloud