1#ifndef _CALL_EXPR_UTILS_H_
2#define _CALL_EXPR_UTILS_H_
5#define DEBUG_TYPE "CallExprUtils"
7#include "clang/AST/DeclCXX.h"
8#include "clang/AST/ExprCXX.h"
10#include "clang/ASTMatchers/ASTMatchFinder.h"
11#include "clang/ASTMatchers/ASTMatchers.h"
12#include "llvm/ADT/StringRef.h"
15using namespace clang::ast_matchers;
35 llvm::StringRef empty{
"<NULL>"};
36 if (!decl)
return empty;
37 const clang::DeclContext *dc = decl->getLexicalParent();
39 llvm::dbgs() <<
"@@@@@ Enter IF \n";
40 if (
const auto *nd = llvm::dyn_cast<clang::NamespaceDecl>(dc)) {
41 clang::IdentifierInfo *iinfo = nd->getIdentifier();
42 llvm::dbgs() <<
"@@ name is " << iinfo->getName() <<
" for ";
43 return iinfo->getName();
46 llvm::dbgs() <<
"NOT NS\n";
66 auto call_matcher = callExpr(callee(functionDecl().bind(
"ce_decl"))).bind(
"expr");
70 finder.addMatcher(call_matcher,
this);
73 virtual void run(
const MatchFinder::MatchResult &result) {
75 const_cast<clang::Expr *
>(result.Nodes.getNodeAs<clang::Expr>(
"expr"));
76 auto ce_decl =
const_cast<clang::FunctionDecl *
>(
77 result.Nodes.getNodeAs<clang::FunctionDecl>(
"ce_decl"));
79 llvm::dbgs() <<
"@@@@@@## callExpr \n";
84 if (
auto mdecl = llvm::dyn_cast<clang::CXXMethodDecl>(ce_decl)) {
86 llvm::dbgs() <<
"@@@@@ MDECL FUNC NAME " << mdecl->getNameAsString() <<
"\n";
94 llvm::dbgs() <<
"@@@@@@ NAME " <<
ns_name <<
" func_name " <<
func_name <<
"\n";
107 const std::vector<llvm::StringRef> &names);
109 const std::vector<llvm::StringRef> &names);
112 const std::vector<llvm::StringRef> &names);
117 std::vector<clang::Type *> &unwrapped_types);
122bool matchNames(llvm::StringRef str,
const std::vector<llvm::StringRef> &names);
void registerMatchers(MatchFinder &finder)
llvm::StringRef getNamespaceName()
std::string getFunctionName()
virtual void run(const MatchFinder::MatchResult &result)
void dumpExprName(const Expr *expr)
void collect_sugar(const Type *type, std::vector< clang::Type * > &unwrapped_types)
bool matchNames(StringRef str, const std::vector< llvm::StringRef > &names)
bool isInNamespace(const clang::ValueDecl *fd, const std::vector< llvm::StringRef > &names)
llvm::StringRef getClassNameFromDecl(T *decl)