clang-tools  4.0.0
ASTUtils.cpp
Go to the documentation of this file.
1 //===---------- ASTUtils.cpp - clang-tidy ---------------------------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 #include "ASTUtils.h"
11 
12 #include "clang/ASTMatchers/ASTMatchFinder.h"
13 #include "clang/ASTMatchers/ASTMatchers.h"
14 
15 namespace clang {
16 namespace tidy {
17 namespace utils {
18 using namespace ast_matchers;
19 
20 const FunctionDecl *getSurroundingFunction(ASTContext &Context,
21  const Stmt &Statement) {
22  return selectFirst<const FunctionDecl>(
23  "function", match(stmt(hasAncestor(functionDecl().bind("function"))),
24  Statement, Context));
25 }
26 } // namespace utils
27 } // namespace tidy
28 } // namespace clang
const FunctionDecl * getSurroundingFunction(ASTContext &Context, const Stmt &Statement)
Definition: ASTUtils.cpp:20
ClangTidyContext & Context
Definition: ClangTidy.cpp:87