void RedundantLocalVariableRule::apply(CXCursor& node, CXCursor& parentNode, ViolationSet& violationSet) { Stmt *stmt = CursorHelper::getStmt(node); Stmt *parentStmt = CursorHelper::getStmt(parentNode); if (stmt && parentStmt) { NamedDecl *returnDeclRef = extractFromReturnStmt(stmt); NamedDecl *namedDecl = extractFromDeclStmt(parentStmt); if (returnDeclRef && namedDecl && returnDeclRef->getName().equals(namedDecl->getName())) { Violation violation(node, this); violationSet.addViolation(violation); } } }
bool HasNameMatcher::matchesNodeUnqualified(const NamedDecl &Node) const { assert(UseUnqualifiedMatch); if (Node.getIdentifier()) { // Simple name. return Name == Node.getName(); } 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(); } return false; }