本文整理汇总了C++中TemplateArgument::getAsDecl方法的典型用法代码示例。如果您正苦于以下问题:C++ TemplateArgument::getAsDecl方法的具体用法?C++ TemplateArgument::getAsDecl怎么用?C++ TemplateArgument::getAsDecl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TemplateArgument
的用法示例。
在下文中一共展示了TemplateArgument::getAsDecl方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: structurallyEquals
bool TemplateArgument::structurallyEquals(const TemplateArgument &Other) const {
if (getKind() != Other.getKind()) return false;
switch (getKind()) {
case Null:
case Type:
case Expression:
case Template:
case TemplateExpansion:
case NullPtr:
return TypeOrValue.V == Other.TypeOrValue.V;
case Declaration:
return getAsDecl() == Other.getAsDecl() &&
isDeclForReferenceParam() && Other.isDeclForReferenceParam();
case Integral:
return getIntegralType() == Other.getIntegralType() &&
getAsIntegral() == Other.getAsIntegral();
case Pack:
if (Args.NumArgs != Other.Args.NumArgs) return false;
for (unsigned I = 0, E = Args.NumArgs; I != E; ++I)
if (!Args.Args[I].structurallyEquals(Other.Args.Args[I]))
return false;
return true;
}
llvm_unreachable("Invalid TemplateArgument Kind!");
}
示例2: VisitTemplateArgument
void StmtProfiler::VisitTemplateArgument(const TemplateArgument &Arg) {
// Mostly repetitive with TemplateArgument::Profile!
ID.AddInteger(Arg.getKind());
switch (Arg.getKind()) {
case TemplateArgument::Null:
break;
case TemplateArgument::Type:
VisitType(Arg.getAsType());
break;
case TemplateArgument::Template:
VisitTemplateName(Arg.getAsTemplate());
break;
case TemplateArgument::Declaration:
VisitDecl(Arg.getAsDecl());
break;
case TemplateArgument::Integral:
Arg.getAsIntegral()->Profile(ID);
VisitType(Arg.getIntegralType());
break;
case TemplateArgument::Expression:
Visit(Arg.getAsExpr());
break;
case TemplateArgument::Pack:
const TemplateArgument *Pack = Arg.pack_begin();
for (unsigned i = 0, e = Arg.pack_size(); i != e; ++i)
VisitTemplateArgument(Pack[i]);
break;
}
}
示例3: AddTemplateArgument
void ODRHash::AddTemplateArgument(TemplateArgument TA) {
const auto Kind = TA.getKind();
ID.AddInteger(Kind);
switch (Kind) {
case TemplateArgument::Null:
llvm_unreachable("Expected valid TemplateArgument");
case TemplateArgument::Type:
AddQualType(TA.getAsType());
break;
case TemplateArgument::Declaration:
AddDecl(TA.getAsDecl());
break;
case TemplateArgument::NullPtr:
case TemplateArgument::Integral:
break;
case TemplateArgument::Template:
case TemplateArgument::TemplateExpansion:
AddTemplateName(TA.getAsTemplateOrTemplatePattern());
break;
case TemplateArgument::Expression:
AddStmt(TA.getAsExpr());
break;
case TemplateArgument::Pack:
ID.AddInteger(TA.pack_size());
for (auto SubTA : TA.pack_elements()) {
AddTemplateArgument(SubTA);
}
break;
}
}
示例4: dumpTemplateArgument
void ASTDumper::dumpTemplateArgument(const TemplateArgument &A, SourceRange R) {
IndentScope Indent(*this);
OS << "TemplateArgument";
if (R.isValid())
dumpSourceRange(R);
switch (A.getKind()) {
case TemplateArgument::Null:
OS << " null";
break;
case TemplateArgument::Type:
OS << " type";
dumpType(A.getAsType());
break;
case TemplateArgument::Declaration:
OS << " decl";
dumpDeclRef(A.getAsDecl());
break;
case TemplateArgument::NullPtr:
OS << " nullptr";
break;
case TemplateArgument::Integral:
OS << " integral " << A.getAsIntegral();
break;
case TemplateArgument::Template:
OS << " template ";
A.getAsTemplate().dump(OS);
break;
case TemplateArgument::TemplateExpansion:
OS << " template expansion";
A.getAsTemplateOrTemplatePattern().dump(OS);
break;
case TemplateArgument::Expression:
OS << " expr";
dumpStmt(A.getAsExpr());
break;
case TemplateArgument::Pack:
OS << " pack";
for (TemplateArgument::pack_iterator I = A.pack_begin(), E = A.pack_end();
I != E; ++I)
dumpTemplateArgument(*I);
break;
}
}
示例5: VisitTemplateArgument
void USRGenerator::VisitTemplateArgument(const TemplateArgument &Arg) {
switch (Arg.getKind()) {
case TemplateArgument::Null:
break;
case TemplateArgument::Declaration:
Visit(Arg.getAsDecl());
break;
case TemplateArgument::NullPtr:
break;
case TemplateArgument::TemplateExpansion:
Out << 'P'; // pack expansion of...
// Fall through
case TemplateArgument::Template:
VisitTemplateName(Arg.getAsTemplateOrTemplatePattern());
break;
case TemplateArgument::Expression:
// FIXME: Visit expressions.
break;
case TemplateArgument::Pack:
Out << 'p' << Arg.pack_size();
for (TemplateArgument::pack_iterator P = Arg.pack_begin(), PEnd = Arg.pack_end();
P != PEnd; ++P)
VisitTemplateArgument(*P);
break;
case TemplateArgument::Type:
VisitType(Arg.getAsType());
break;
case TemplateArgument::Integral:
Out << 'V';
VisitType(Arg.getIntegralType());
Out << Arg.getAsIntegral();
break;
}
}
示例6: VisitTemplateArgument
void USRGenerator::VisitTemplateArgument(const TemplateArgument &Arg) {
switch (Arg.getKind()) {
case TemplateArgument::Null:
break;
case TemplateArgument::Declaration:
Visit(Arg.getAsDecl());
break;
case TemplateArgument::NullPtr:
break;
case TemplateArgument::TemplateExpansion:
Out << 'P'; // pack expansion of...
LLVM_FALLTHROUGH;
case TemplateArgument::Template:
VisitTemplateName(Arg.getAsTemplateOrTemplatePattern());
break;
case TemplateArgument::Expression:
// FIXME: Visit expressions.
break;
case TemplateArgument::Pack:
Out << 'p' << Arg.pack_size();
for (const auto &P : Arg.pack_elements())
VisitTemplateArgument(P);
break;
case TemplateArgument::Type:
VisitType(Arg.getAsType());
break;
case TemplateArgument::Integral:
Out << 'V';
VisitType(Arg.getIntegralType());
Out << Arg.getAsIntegral();
break;
}
}
示例7: VisitTemplateArgument
void StmtProfiler::VisitTemplateArgument(const TemplateArgument &Arg) {
// Mostly repetitive with TemplateArgument::Profile!
ID.AddInteger(Arg.getKind());
switch (Arg.getKind()) {
case TemplateArgument::Null:
break;
case TemplateArgument::Type:
VisitType(Arg.getAsType());
break;
case TemplateArgument::Template:
case TemplateArgument::TemplateExpansion:
VisitTemplateName(Arg.getAsTemplateOrTemplatePattern());
break;
case TemplateArgument::Declaration:
VisitDecl(Arg.getAsDecl());
break;
case TemplateArgument::NullPtr:
VisitType(Arg.getNullPtrType());
break;
case TemplateArgument::Integral:
Arg.getAsIntegral().Profile(ID);
VisitType(Arg.getIntegralType());
break;
case TemplateArgument::Expression:
Visit(Arg.getAsExpr());
break;
case TemplateArgument::Pack:
for (const auto &P : Arg.pack_elements())
VisitTemplateArgument(P);
break;
}
}
示例8: PrintTemplateArgument
static void PrintTemplateArgument(std::string &Buffer,
const TemplateArgument &Arg,
const PrintingPolicy &Policy) {
switch (Arg.getKind()) {
case TemplateArgument::Null:
assert(false && "Null template argument");
break;
case TemplateArgument::Type:
Arg.getAsType().getAsStringInternal(Buffer, Policy);
break;
case TemplateArgument::Declaration:
Buffer = cast<NamedDecl>(Arg.getAsDecl())->getNameAsString();
break;
case TemplateArgument::Template: {
llvm::raw_string_ostream s(Buffer);
Arg.getAsTemplate().print(s, Policy);
break;
}
case TemplateArgument::Integral:
Buffer = Arg.getAsIntegral()->toString(10, true);
break;
case TemplateArgument::Expression: {
llvm::raw_string_ostream s(Buffer);
Arg.getAsExpr()->printPretty(s, 0, Policy);
break;
}
case TemplateArgument::Pack:
assert(0 && "FIXME: Implement!");
break;
}
}
示例9: getTemplateArgumentName
string getTemplateArgumentName(const TemplateArgument & argument)
{
string qualifiedName;
switch(argument.getKind()) {
case TemplateArgument::Null:
qualifiedName = "NULL";
break;
case TemplateArgument::Type:
qualifiedName = CppType(argument.getAsType()).getQualifiedName();
break;
case TemplateArgument::Declaration:
qualifiedName = dyn_cast<NamedDecl>(argument.getAsDecl())->getQualifiedNameAsString();
break;
case TemplateArgument::Integral:
case TemplateArgument::Expression:
qualifiedName = exprToText(argument.getAsExpr());
break;
case TemplateArgument::Template:
qualifiedName = argument.getAsTemplate().getAsTemplateDecl()->getQualifiedNameAsString();
break;
case TemplateArgument::TemplateExpansion:
break;
case TemplateArgument::Pack:
break;
}
return qualifiedName;
}
示例10: printTemplateArgument
// 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;
}
}