зеркало из https://github.com/microsoft/clang-1.git
Since integral template arguments can't have dependent types we don't need an extra pass to set the right APSInt bit width/signedness.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73580 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
cb7835f4f9
Коммит
25af1ed6ff
|
@ -53,9 +53,15 @@ DeduceNonTypeTemplateArgument(ASTContext &Context,
|
|||
"Cannot deduce non-type template argument with depth > 0");
|
||||
|
||||
if (Deduced[NTTP->getIndex()].isNull()) {
|
||||
Deduced[NTTP->getIndex()] = TemplateArgument(SourceLocation(),
|
||||
llvm::APSInt(Value),
|
||||
NTTP->getType());
|
||||
QualType T = NTTP->getType();
|
||||
|
||||
// FIXME: Make sure we didn't overflow our data type!
|
||||
unsigned AllowedBits = Context.getTypeSize(T);
|
||||
if (Value.getBitWidth() != AllowedBits)
|
||||
Value.extOrTrunc(AllowedBits);
|
||||
Value.setIsSigned(T->isSignedIntegerType());
|
||||
|
||||
Deduced[NTTP->getIndex()] = TemplateArgument(SourceLocation(), Value, T);
|
||||
return Sema::TDK_Success;
|
||||
}
|
||||
|
||||
|
@ -672,35 +678,6 @@ Sema::DeduceTemplateArguments(ClassTemplatePartialSpecializationDecl *Partial,
|
|||
/*FlattenArgs=*/true);
|
||||
Info.reset(DeducedArgumentList);
|
||||
|
||||
// Now that we have all of the deduced template arguments, take
|
||||
// another pass through them to convert any integral template
|
||||
// arguments to the appropriate type.
|
||||
for (unsigned I = 0, N = Deduced.size(); I != N; ++I) {
|
||||
TemplateArgument &Arg = Deduced[I];
|
||||
if (Arg.getKind() == TemplateArgument::Integral) {
|
||||
const NonTypeTemplateParmDecl *Parm
|
||||
= cast<NonTypeTemplateParmDecl>(Partial->getTemplateParameters()
|
||||
->getParam(I));
|
||||
QualType T = InstantiateType(Parm->getType(), *DeducedArgumentList,
|
||||
Parm->getLocation(), Parm->getDeclName());
|
||||
if (T.isNull()) {
|
||||
Info.Param = const_cast<NonTypeTemplateParmDecl*>(Parm);
|
||||
Info.FirstArg = TemplateArgument(Parm->getLocation(), Parm->getType());
|
||||
return TDK_SubstitutionFailure;
|
||||
}
|
||||
|
||||
// FIXME: Make sure we didn't overflow our data type!
|
||||
llvm::APSInt &Value = *Arg.getAsIntegral();
|
||||
unsigned AllowedBits = Context.getTypeSize(T);
|
||||
if (Value.getBitWidth() != AllowedBits)
|
||||
Value.extOrTrunc(AllowedBits);
|
||||
Value.setIsSigned(T->isSignedIntegerType());
|
||||
Arg.setIntegralType(T);
|
||||
}
|
||||
|
||||
(*DeducedArgumentList)[I] = Arg;
|
||||
}
|
||||
|
||||
// Substitute the deduced template arguments into the template
|
||||
// arguments of the class template partial specialization, and
|
||||
// verify that the instantiated template arguments are both valid
|
||||
|
|
Загрузка…
Ссылка в новой задаче