14 std::vector<clang::Type *> &unwrapped_types) {
15 const Type *desugared_final{type->getUnqualifiedDesugaredType()};
16 Type *curr_type{
const_cast<Type *
>(type)};
17 unwrapped_types.push_back(
const_cast<Type *
>(desugared_final));
18 while (curr_type != desugared_final) {
19 unwrapped_types.push_back(curr_type);
20 curr_type =
const_cast<Type *
>(
21 curr_type->getLocallyUnqualifiedSingleStepDesugaredType().getTypePtr());
26 const std::vector<llvm::StringRef> &names) {
27 llvm::dbgs() <<
"isInNamespace with ValueDecl\n";
39 if (
auto dc = dyn_cast<DeclContext>(fd)) {
41 auto dcc = dc->getLexicalParent();
43 if (dcc->isNamespace()) {
44 if (
const auto *nd = llvm::dyn_cast<clang::NamespaceDecl>(dcc)) {
46 std::vector<llvm::StringRef> names{
"sc_dt"};
47 auto iinfo = nd->getIdentifier();
49 for (
const auto name : names) {
50 if (iinfo->isStr(name)) {
67 const std::vector<llvm::StringRef> &names) {
74 std::vector<clang::Type *> unwrapped_types{};
77 for (
auto tap : unwrapped_types) {
78 if (tap->isBuiltinType()) {
79 llvm::dbgs() <<
"isBuiltinType\n";
83 DeclContext *dc{
nullptr};
84 if (tap->isArrayType()) {
85 auto cat1 = dyn_cast<ArrayType>(tap);
86 const Type *tp = cat1->getElementType().getTypePtr();
89 Type *unwrap_tp{
nullptr};
90 while (tp && tp != unwrap_tp) {
91 if (
auto cat2 = dyn_cast<ArrayType>(tp)) {
92 unwrap_tp =
const_cast<Type *
>(tp);
93 tp = cat2->getElementType().getTypePtr();
95 unwrap_tp =
const_cast<Type *
>(tp);
103 if (tap->isRecordType()) {
104 llvm::dbgs() <<
"isRecordType\n";
105 const RecordDecl *rdecl = tap->getAsRecordDecl();
106 dc =
const_cast<clang::DeclContext *
>(rdecl->getLexicalParent());
109 if (tap->isFunctionType()) {
110 llvm::dbgs() <<
"isFunctionType\n";
111 if (
auto rdecl = tap->getAsCXXRecordDecl()) {
112 llvm::dbgs() <<
"Got in as CXX\n";
113 dc =
const_cast<clang::DeclContext *
>(rdecl->getLexicalParent());
117 if (dc && dc->isNamespace()) {
118 llvm::dbgs() <<
"isNamespace \n";
119 if (
const auto *nd = llvm::dyn_cast<clang::NamespaceDecl>(dc)) {
120 auto iinfo = nd->getIdentifier();
121 llvm::dbgs() <<
"@@ name is " << iinfo->getName() <<
" for ";
122 for (
const auto name : names) {
123 if (iinfo->isStr(name)) {
176 if (
auto cexpr = dyn_cast<CXXOperatorCallExpr>(expr)) {
177 if (
const FunctionDecl *fd = cexpr->getDirectCallee()) {
178 auto decl_info{fd->getNameInfo()};
179 llvm::dbgs() << decl_info.getName().getAsString();
183 if (
auto cexpr = dyn_cast<CallExpr>(expr)) {
184 if (
const FunctionDecl *fd = cexpr->getDirectCallee()) {
185 auto decl_info{fd->getNameInfo()};
186 if (decl_info.getName().isIdentifier()) {
187 llvm::dbgs() << decl_info.getName().getAsString();
194 const std::vector<llvm::StringRef> &names) {
200 llvm::dbgs() <<
"2. Expr isNamespace\n";
207 if (
auto cexpr = dyn_cast<CallExpr>(expr)) {
208 const Decl *decl = cexpr->getCalleeDecl();
209 ASTContext &Context = decl->getASTContext();
211 MatchFinder finder{};
214 finder.match(*expr, Context);
215 llvm::dbgs() <<
"@@@ MATCHNAMES " << ns_matcher.getNamespaceName() <<
" "
216 << ns_matcher.getFunctionName() <<
"\n";
217 return matchNames(ns_matcher.getNamespaceName(), names);
255 if (
auto dexpr = dyn_cast<DeclRefExpr>(expr)) {
256 llvm::dbgs() <<
"@@@@ in DeclRefExpr\n";
258 dexpr->getDecl()->dump();