bool HasNameMatcher::matchesNodeFull(const NamedDecl &Node) const { llvm::SmallString<128> NodeName = StringRef("::"); llvm::raw_svector_ostream OS(NodeName); Node.printQualifiedName(OS); const StringRef FullName = OS.str(); const StringRef Pattern = Name; if (Pattern.startswith("::")) return FullName == Pattern; return FullName.endswith(Pattern) && FullName.drop_back(Pattern.size()).endswith("::"); }
void DeclPrinter::VisitOMPThreadPrivateDecl(OMPThreadPrivateDecl *D) { Out << "#pragma omp threadprivate"; if (!D->varlist_empty()) { for (OMPThreadPrivateDecl::varlist_iterator I = D->varlist_begin(), E = D->varlist_end(); I != E; ++I) { Out << (I == D->varlist_begin() ? '(' : ','); NamedDecl *ND = cast<NamedDecl>(cast<DeclRefExpr>(*I)->getDecl()); ND->printQualifiedName(Out); } Out << ")"; } }
void TemplateArgument::print(const PrintingPolicy &Policy, raw_ostream &Out) const { switch (getKind()) { case Null: Out << "<no value>"; break; case Type: { PrintingPolicy SubPolicy(Policy); SubPolicy.SuppressStrongLifetime = true; getAsType().print(Out, SubPolicy); break; } case Declaration: { NamedDecl *ND = cast<NamedDecl>(getAsDecl()); Out << '&'; if (ND->getDeclName()) { // FIXME: distinguish between pointer and reference args? ND->printQualifiedName(Out); } else { Out << "<anonymous>"; } break; } case NullPtr: Out << "nullptr"; break; case Template: getAsTemplate().print(Out, Policy); break; case TemplateExpansion: getAsTemplateOrTemplatePattern().print(Out, Policy); Out << "..."; break; case Integral: { printIntegral(*this, Out); break; } case Expression: getAsExpr()->printPretty(Out, 0, Policy); break; case Pack: Out << "<"; bool First = true; for (TemplateArgument::pack_iterator P = pack_begin(), PEnd = pack_end(); P != PEnd; ++P) { if (First) First = false; else Out << ", "; P->print(Policy, Out); } Out << ">"; break; } }
// Adapted from tools\clang\lib\AST\TemplateBase.cpp TemplateArgument::print void printTemplateArgument(raw_ostream &out, const PrintingPolicy &policy, TemplateArgument const &arg, bool qualifyNames) { switch (arg.getKind()) { case TemplateArgument::Null: out << "(no value)"; break; case TemplateArgument::Type: { PrintingPolicy SubPolicy(policy); SubPolicy.SuppressStrongLifetime = true; arg.getAsType().print(out, SubPolicy); break; } case TemplateArgument::Declaration: { NamedDecl *ND = cast<NamedDecl>(arg.getAsDecl()); out << '&'; if (ND->getDeclName()) { // FIXME: distinguish between pointer and reference args? ND->printQualifiedName(out); } else { out << "(anonymous)"; } break; } case TemplateArgument::NullPtr: out << "nullptr"; break; case TemplateArgument::Template: // Orig: arg.getAsTemplate().print(out, policy); { auto templateName = arg.getAsTemplate(); printTemplateName(out, policy, templateName, qualifyNames); break; } case TemplateArgument::TemplateExpansion: arg.getAsTemplateOrTemplatePattern().print(out, policy); out << "..."; break; case TemplateArgument::Integral: { printIntegral(arg, out, policy); break; } case TemplateArgument::Expression: arg.getAsExpr()->printPretty(out, nullptr, policy); break; case TemplateArgument::Pack: out << "<"; bool First = true; for (const auto &P : arg.pack_elements()) { if (First) First = false; else out << ", "; P.print(policy, out); } out << ">"; break; } }