//
//===----------------------------------------------------------------------===//
-#ifndef LLVM_CLANG_AST_MATCHERS_AST_MATCH_FINDER_H
-#define LLVM_CLANG_AST_MATCHERS_AST_MATCH_FINDER_H
+#ifndef LLVM_CLANG_ASTMATCHERS_ASTMATCHFINDER_H
+#define LLVM_CLANG_ASTMATCHERS_ASTMATCHFINDER_H
#include "clang/ASTMatchers/ASTMatchers.h"
MatchCallback *Action);
/// \brief Creates a clang ASTConsumer that finds all matches.
- clang::ASTConsumer *newASTConsumer();
+ std::unique_ptr<clang::ASTConsumer> newASTConsumer();
/// \brief Calls the registered callbacks on all matches on the given \p Node.
///
///
/// This is useful in combanation with \c match():
/// \code
-/// Decl *D = selectFirst<Decl>("id", match(Matcher.bind("id"),
-/// Node, Context));
+/// const Decl *D = selectFirst<Decl>("id", match(Matcher.bind("id"),
+/// Node, Context));
/// \endcode
template <typename NodeT>
-NodeT *
+const NodeT *
selectFirst(StringRef BoundTo, const SmallVectorImpl<BoundNodes> &Results) {
- for (SmallVectorImpl<BoundNodes>::const_iterator I = Results.begin(),
- E = Results.end();
- I != E; ++I) {
- if (NodeT *Node = I->getNodeAs<NodeT>(BoundTo))
+ for (const BoundNodes &N : Results) {
+ if (const NodeT *Node = N.getNodeAs<NodeT>(BoundTo))
return Node;
}
return nullptr;
} // end namespace ast_matchers
} // end namespace clang
-#endif // LLVM_CLANG_AST_MATCHERS_AST_MATCH_FINDER_H
+#endif