Changeset View
Changeset View
Standalone View
Standalone View
clang/lib/Sema/SemaTemplate.cpp
Show First 20 Lines • Show All 92 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
// The first template argument will be reused as the template decl that | // The first template argument will be reused as the template decl that | ||||
// our synthetic template arguments will be applied to. | // our synthetic template arguments will be applied to. | ||||
return SemaRef.CheckTemplateIdType(Converted[0].getAsTemplate(), | return SemaRef.CheckTemplateIdType(Converted[0].getAsTemplate(), | ||||
TemplateLoc, SyntheticTemplateArgs); | TemplateLoc, SyntheticTemplateArgs); | ||||
} | } | ||||
case BTK__type_pack_element: | case BTK__type_pack_element: { | ||||
// Specializations of | // Specializations of | ||||
// __type_pack_element<Index, T_1, ..., T_N> | // __type_pack_element<Index, T_1, ..., T_N> | ||||
// are treated like T_Index. | // are treated like T_Index. | ||||
assert(Converted.size() == 2 && | assert(Converted.size() == 2 && | ||||
"__type_pack_element should be given an index and a parameter pack"); | "__type_pack_element should be given an index and a parameter pack"); | ||||
TemplateArgument IndexArg = Converted[0], Ts = Converted[1]; | TemplateArgument IndexArg = Converted[0], Ts = Converted[1]; | ||||
if (IndexArg.isDependent() || Ts.isDependent()) | if (IndexArg.isDependent() || Ts.isDependent()) | ||||
Show All 9 Lines | |||||
diag::err_type_pack_element_out_of_bounds); | diag::err_type_pack_element_out_of_bounds); | ||||
return QualType(); | return QualType(); | ||||
} | } | ||||
// We simply return the type at index `Index`. | // We simply return the type at index `Index`. | ||||
int64_t N = Index.getExtValue(); | int64_t N = Index.getExtValue(); | ||||
return Ts.getPackAsArray()[N].getAsType(); | return Ts.getPackAsArray()[N].getAsType(); | ||||
} | } | ||||
case BTK__decay: | |||||
assert(Converted.size() == 1 && "__decay should be given a single type"); | |||||
TemplateArgument Ty = Converted[0]; | |||||
return SemaRef.BuiltinDecay(Ty.getAsType(), TemplateArgs[0].getLocation()); | |||||
} | |||||
llvm_unreachable("unexpected BuiltinTemplateDecl!"); | llvm_unreachable("unexpected BuiltinTemplateDecl!"); | ||||
} | } | ||||
/// Determine whether this alias template is "enable_if_t". | /// Determine whether this alias template is "enable_if_t". | ||||
/// libc++ >=14 uses "__enable_if_t" in C++11 mode. | /// libc++ >=14 uses "__enable_if_t" in C++11 mode. | ||||
static bool isEnableIfAliasTemplate(TypeAliasTemplateDecl *AliasTemplate) { | static bool isEnableIfAliasTemplate(TypeAliasTemplateDecl *AliasTemplate) { | ||||
return AliasTemplate->getName().equals("enable_if_t") || | return AliasTemplate->getName().equals("enable_if_t") || | ||||
AliasTemplate->getName().equals("__enable_if_t"); | AliasTemplate->getName().equals("__enable_if_t"); | ||||
▲ Show 20 Lines • Show All 92 Lines • Show Last 20 Lines |