本文整理汇总了C++中TemplateArgument类的典型用法代码示例。如果您正苦于以下问题:C++ TemplateArgument类的具体用法?C++ TemplateArgument怎么用?C++ TemplateArgument使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TemplateArgument类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: structurallyEquals
bool TemplateArgument::structurallyEquals(const TemplateArgument &Other) const {
if (getKind() != Other.getKind()) return false;
switch (getKind()) {
case Null:
case Type:
case Declaration:
case Template:
case Expression:
return TypeOrValue == Other.TypeOrValue;
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;
}
// Suppress warnings.
return false;
}
开发者ID:lgerbarg,项目名称:clang,代码行数:26,代码来源:TemplateBase.cpp
示例2: TransAssert
void ReduceClassTemplateParameter::removeOneParameterByArgExpression(
const ClassTemplatePartialSpecializationDecl *PartialD,
const TemplateArgument &Arg)
{
TransAssert((Arg.getKind() == TemplateArgument::Expression) &&
"Arg is not TemplateArgument::Expression!");
const Expr *E = Arg.getAsExpr();
TransAssert(E && "Bad Expression!");
const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E->IgnoreParenCasts());
TransAssert(DRE && "Bad DeclRefExpr!");
const NonTypeTemplateParmDecl *ParmD =
dyn_cast<NonTypeTemplateParmDecl>(DRE->getDecl());
TransAssert(ParmD && "Invalid NonTypeTemplateParmDecl!");
const TemplateParameterList *TPList = PartialD->getTemplateParameters();
unsigned Idx = 0;
for (TemplateParameterList::const_iterator I = TPList->begin(),
E = TPList->end(); I != E; ++I) {
if ((*I) == ParmD)
break;
Idx++;
}
unsigned NumParams = TPList->size();
TransAssert((Idx < NumParams) && "Cannot find valid TemplateParameter!");
(void)NumParams;
SourceRange Range = ParmD->getSourceRange();
removeParameterByRange(Range, TPList, Idx);
}
开发者ID:oriceemple,项目名称:creduce,代码行数:30,代码来源:ReduceClassTemplateParameter.cpp
示例3: switch
void ODRHash::AddTemplateArgument(TemplateArgument TA) {
const auto Kind = TA.getKind();
ID.AddInteger(Kind);
switch (Kind) {
case TemplateArgument::Null:
llvm_unreachable("Require valid TemplateArgument");
case TemplateArgument::Type:
AddQualType(TA.getAsType());
break;
case TemplateArgument::Declaration:
AddDecl(TA.getAsDecl());
break;
case TemplateArgument::NullPtr:
AddQualType(TA.getNullPtrType());
break;
case TemplateArgument::Integral:
TA.getAsIntegral().Profile(ID);
AddQualType(TA.getIntegralType());
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;
}
}
开发者ID:etejedor,项目名称:root,代码行数:33,代码来源:ODRHash.cpp
示例4: printIntegral
/// \brief Print a template integral argument value.
///
/// \param TemplArg the TemplateArgument instance to print.
///
/// \param Out the raw_ostream instance to use for printing.
///
/// \param Policy the printing policy for EnumConstantDecl printing.
static void printIntegral(const TemplateArgument &TemplArg,
raw_ostream &Out, const PrintingPolicy& Policy) {
const ::clang::Type *T = TemplArg.getIntegralType().getTypePtr();
const llvm::APSInt &Val = TemplArg.getAsIntegral();
if (const EnumType *ET = T->getAs<EnumType>()) {
for (const EnumConstantDecl* ECD : ET->getDecl()->enumerators()) {
// In Sema::CheckTemplateArugment, enum template arguments value are
// extended to the size of the integer underlying the enum type. This
// may create a size difference between the enum value and template
// argument value, requiring isSameValue here instead of operator==.
if (llvm::APSInt::isSameValue(ECD->getInitVal(), Val)) {
ECD->printQualifiedName(Out, Policy);
return;
}
}
}
if (T->isBooleanType() && !Policy.MSVCFormatting) {
Out << (Val.getBoolValue() ? "true" : "false");
} else if (T->isCharType()) {
const char Ch = Val.getZExtValue();
Out << ((Ch == '\'') ? "'\\" : "'");
Out.write_escaped(StringRef(&Ch, 1), /*UseHexEscapes=*/ true);
Out << "'";
} else {
Out << Val;
}
}
开发者ID:AntonBikineev,项目名称:clang,代码行数:36,代码来源:TemplateBase.cpp
示例5: switch
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!");
}
开发者ID:joker-eph,项目名称:clangllvm,代码行数:30,代码来源:TemplateBase.cpp
示例6: switch
bool TemplateNonTypeArgToInt::isValidTemplateArgument(
const TemplateArgument &Arg)
{
TemplateArgument::ArgKind K = Arg.getKind();
switch (K) {
case TemplateArgument::Declaration: {
return true;
}
case TemplateArgument::Expression: {
const Expr *E = Arg.getAsExpr()->IgnoreParenCasts();
if (dyn_cast<IntegerLiteral>(E) || dyn_cast<CXXBoolLiteralExpr>(E))
return false;
if (const UnaryOperator *UO = dyn_cast<UnaryOperator>(E)) {
UnaryOperator::Opcode Op = UO->getOpcode();
if((Op == UO_Minus) || (Op == UO_Plus))
return false;
}
return true;
}
default:
TransAssert(0 && "Unreachable code!");
return false;
}
TransAssert(0 && "Unreachable code!");
return false;
}
开发者ID:JIghtuse,项目名称:creduce,代码行数:29,代码来源:TemplateNonTypeArgToInt.cpp
示例7: switch
void ReduceClassTemplateParameter::removeOneParameterFromPartialDecl(
const ClassTemplatePartialSpecializationDecl *PartialD,
const TemplateArgument &Arg)
{
if (!Arg.isInstantiationDependent())
return;
TemplateArgument::ArgKind K = Arg.getKind();
switch (K) {
case TemplateArgument::Expression:
removeOneParameterByArgExpression(PartialD, Arg);
return;
case TemplateArgument::Template:
removeOneParameterByArgTemplate(PartialD, Arg);
return;
case TemplateArgument::Type:
removeOneParameterByArgType(PartialD, Arg);
return;
default:
TransAssert(0 && "Uncatched ArgKind!");
}
TransAssert(0 && "Unreachable code!");
}
开发者ID:oriceemple,项目名称:creduce,代码行数:26,代码来源:ReduceClassTemplateParameter.cpp
示例8: switch
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;
}
}
开发者ID:Teemperor,项目名称:clang-clone-finder,代码行数:35,代码来源:SelectiveStmtProfiler.cpp
示例9: SubstNonTypeTemplateParmPackExpr
SubstNonTypeTemplateParmPackExpr::
SubstNonTypeTemplateParmPackExpr(QualType T,
NonTypeTemplateParmDecl *Param,
SourceLocation NameLoc,
const TemplateArgument &ArgPack)
: Expr(SubstNonTypeTemplateParmPackExprClass, T, VK_RValue, OK_Ordinary,
true, true, true, true),
Param(Param), Arguments(ArgPack.pack_begin()),
NumArguments(ArgPack.pack_size()), NameLoc(NameLoc) { }
开发者ID:ACSOP,项目名称:android_external_clang,代码行数:9,代码来源:ExprCXX.cpp
示例10: describeTemplateParameter
static void describeTemplateParameter(raw_ostream &Out,
const TemplateArgument &TArg,
const LangOptions &LO) {
if (TArg.getKind() == TemplateArgument::ArgKind::Pack) {
describeTemplateParameters(Out, TArg.getPackAsArray(), LO);
} else {
TArg.print(PrintingPolicy(LO), Out);
}
}
开发者ID:LegalizeAdulthood,项目名称:clang,代码行数:10,代码来源:PathDiagnostic.cpp
示例11: while
Type *
TypeCheck::visit(TemplateArgumentList *ast)
{
FUNCLOG;
List<TemplateArgument*>::iterator it = ast->args.begin();
while (it != ast->args.end()) {
TemplateArgument *arg = *it;
arg->accept(this);
++it;
}
return NULL;
}
开发者ID:ktok07b6,项目名称:scc,代码行数:12,代码来源:TypeCheck.cpp
示例12: getTypeString
bool
InstantiateTemplateParam::getTemplateArgumentString(const TemplateArgument &Arg,
std::string &ArgStr,
std::string &ForwardStr)
{
ArgStr = "";
ForwardStr = "";
if (Arg.getKind() != TemplateArgument::Type)
return false;
QualType QT = Arg.getAsType();
return getTypeString(QT, ArgStr, ForwardStr);
}
开发者ID:csmith-project,项目名称:creduce,代码行数:12,代码来源:InstantiateTemplateParam.cpp
示例13: clang_Cursor_getTemplateArgumentType
CXType clang_Cursor_getTemplateArgumentType(CXCursor C, unsigned I) {
TemplateArgument TA;
if (clang_Cursor_getTemplateArgument(C, I, &TA) !=
CXGetTemplateArgumentStatus_Success) {
return cxtype::MakeCXType(QualType(), getCursorTU(C));
}
if (TA.getKind() != TemplateArgument::Type) {
return cxtype::MakeCXType(QualType(), getCursorTU(C));
}
return cxtype::MakeCXType(TA.getAsType(), getCursorTU(C));
}
开发者ID:hahnjo,项目名称:clang_trunk,代码行数:13,代码来源:CXCursor.cpp
示例14: assert
Optional<unsigned> Sema::getFullyPackExpandedSize(TemplateArgument Arg) {
assert(Arg.containsUnexpandedParameterPack());
// If this is a substituted pack, grab that pack. If not, we don't know
// the size yet.
// FIXME: We could find a size in more cases by looking for a substituted
// pack anywhere within this argument, but that's not necessary in the common
// case for 'sizeof...(A)' handling.
TemplateArgument Pack;
switch (Arg.getKind()) {
case TemplateArgument::Type:
if (auto *Subst = Arg.getAsType()->getAs<SubstTemplateTypeParmPackType>())
Pack = Subst->getArgumentPack();
else
return None;
break;
case TemplateArgument::Expression:
if (auto *Subst =
dyn_cast<SubstNonTypeTemplateParmPackExpr>(Arg.getAsExpr()))
Pack = Subst->getArgumentPack();
else if (auto *Subst = dyn_cast<FunctionParmPackExpr>(Arg.getAsExpr())) {
for (ParmVarDecl *PD : *Subst)
if (PD->isParameterPack())
return None;
return Subst->getNumExpansions();
} else
return None;
break;
case TemplateArgument::Template:
if (SubstTemplateTemplateParmPackStorage *Subst =
Arg.getAsTemplate().getAsSubstTemplateTemplateParmPack())
Pack = Subst->getArgumentPack();
else
return None;
break;
case TemplateArgument::Declaration:
case TemplateArgument::NullPtr:
case TemplateArgument::TemplateExpansion:
case TemplateArgument::Integral:
case TemplateArgument::Pack:
case TemplateArgument::Null:
return None;
}
// Check that no argument in the pack is itself a pack expansion.
for (TemplateArgument Elem : Pack.pack_elements()) {
// There's no point recursing in this case; we would have already
// expanded this pack expansion into the enclosing pack if we could.
if (Elem.isPackExpansion())
return None;
}
return Pack.pack_size();
}
开发者ID:PolyJIT,项目名称:clang,代码行数:56,代码来源:SemaTemplateVariadic.cpp
示例15: clang_Cursor_getTemplateArgumentValue
long long clang_Cursor_getTemplateArgumentValue(CXCursor C, unsigned I) {
TemplateArgument TA;
if (clang_Cursor_getTemplateArgument(C, I, &TA) !=
CXGetTemplateArgumentStatus_Success) {
assert(0 && "Unable to retrieve TemplateArgument");
return 0;
}
if (TA.getKind() != TemplateArgument::Integral) {
assert(0 && "Passed template argument is not Integral");
return 0;
}
return TA.getAsIntegral().getSExtValue();
}
开发者ID:hahnjo,项目名称:clang_trunk,代码行数:15,代码来源:CXCursor.cpp
示例16: Profile
void SubstTemplateTemplateParmPackStorage::Profile(llvm::FoldingSetNodeID &ID,
ASTContext &Context,
TemplateTemplateParmDecl *Parameter,
const TemplateArgument &ArgPack) {
ID.AddPointer(Parameter);
ArgPack.Profile(ID, Context);
}
开发者ID:,项目名称:,代码行数:7,代码来源:
示例17: printIntegral
/// \brief Print a template integral argument value.
///
/// \param TemplArg the TemplateArgument instance to print.
///
/// \param Out the raw_ostream instance to use for printing.
static void printIntegral(const TemplateArgument &TemplArg,
raw_ostream &Out) {
const ::clang::Type *T = TemplArg.getIntegralType().getTypePtr();
const llvm::APSInt &Val = TemplArg.getAsIntegral();
if (T->isBooleanType()) {
Out << (Val.getBoolValue() ? "true" : "false");
} else if (T->isCharType()) {
const char Ch = Val.getZExtValue();
Out << ((Ch == '\'') ? "'\\" : "'");
Out.write_escaped(StringRef(&Ch, 1), /*UseHexEscapes=*/ true);
Out << "'";
} else {
Out << Val;
}
}
开发者ID:joker-eph,项目名称:clangllvm,代码行数:21,代码来源:TemplateBase.cpp
示例18: switch
void TemplateArgumentListBuilder::Append(const TemplateArgument& Arg) {
switch (Arg.getKind()) {
default:
break;
case TemplateArgument::Type:
assert(Arg.getAsType().isCanonical() && "Type must be canonical!");
break;
}
assert(NumFlatArgs < MaxFlatArgs && "Argument list builder is full!");
assert(!StructuredArgs &&
"Can't append arguments when an argument pack has been added!");
if (!FlatArgs)
FlatArgs = new TemplateArgument[MaxFlatArgs];
FlatArgs[NumFlatArgs++] = Arg;
}
开发者ID:silviubaranga,项目名称:SHP,代码行数:18,代码来源:DeclTemplate.cpp
示例19: GetTemplateArgs
// Get |count| number of template arguments. Returns false if there
// are fewer than |count| arguments or any of the arguments are not
// of a valid Type structure. If |count| is non-positive, all
// arguments are collected.
bool RecordInfo::GetTemplateArgs(size_t count, TemplateArgs* output_args) {
ClassTemplateSpecializationDecl* tmpl =
dyn_cast<ClassTemplateSpecializationDecl>(record_);
if (!tmpl)
return false;
const TemplateArgumentList& args = tmpl->getTemplateArgs();
if (args.size() < count)
return false;
if (count <= 0)
count = args.size();
for (unsigned i = 0; i < count; ++i) {
TemplateArgument arg = args[i];
if (arg.getKind() == TemplateArgument::Type && !arg.getAsType().isNull()) {
output_args->push_back(arg.getAsType().getTypePtr());
} else {
return false;
}
}
return true;
}
开发者ID:shaoboyan,项目名称:chromium-crosswalk,代码行数:24,代码来源:RecordInfo.cpp
示例20: Indent
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;
}
}
开发者ID:r4start,项目名称:clang-with-ms-abi-support,代码行数:44,代码来源:ASTDumper.cpp
注:本文中的TemplateArgument类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论