forked from OSchip/llvm-project
Make the TemplateArgumentList take a TemplateArgumentListBuilder.
llvm-svn: 72917
This commit is contained in:
parent
1b28c3efe2
commit
c8e7113a9f
|
@ -605,9 +605,8 @@ class TemplateArgumentList {
|
|||
|
||||
public:
|
||||
TemplateArgumentList(ASTContext &Context,
|
||||
TemplateArgument *TemplateArgs,
|
||||
unsigned NumTemplateArgs,
|
||||
bool CopyArgs);
|
||||
TemplateArgumentListBuilder &Builder,
|
||||
bool CopyArgs, bool FlattenArgs);
|
||||
|
||||
~TemplateArgumentList();
|
||||
|
||||
|
|
|
@ -239,25 +239,25 @@ TemplateArgument::TemplateArgument(Expr *E) : Kind(Expression) {
|
|||
// TemplateArgumentList Implementation
|
||||
//===----------------------------------------------------------------------===//
|
||||
TemplateArgumentList::TemplateArgumentList(ASTContext &Context,
|
||||
TemplateArgument *TemplateArgs,
|
||||
unsigned NumTemplateArgs,
|
||||
bool CopyArgs)
|
||||
: NumArguments(NumTemplateArgs) {
|
||||
TemplateArgumentListBuilder &Builder,
|
||||
bool CopyArgs, bool FlattenArgs)
|
||||
: NumArguments(Builder.flatSize()) {
|
||||
if (!CopyArgs) {
|
||||
Arguments.setPointer(TemplateArgs);
|
||||
Arguments.setPointer(Builder.getFlatArgumentList());
|
||||
Arguments.setInt(1);
|
||||
return;
|
||||
}
|
||||
|
||||
unsigned Size = sizeof(TemplateArgument) * NumTemplateArgs;
|
||||
|
||||
unsigned Size = sizeof(TemplateArgument) * Builder.flatSize();
|
||||
unsigned Align = llvm::AlignOf<TemplateArgument>::Alignment;
|
||||
void *Mem = Context.Allocate(Size, Align);
|
||||
Arguments.setPointer((TemplateArgument *)Mem);
|
||||
Arguments.setInt(0);
|
||||
|
||||
TemplateArgument *Args = (TemplateArgument *)Mem;
|
||||
for (unsigned I = 0; I != NumTemplateArgs; ++I)
|
||||
new (Args + I) TemplateArgument(TemplateArgs[I]);
|
||||
for (unsigned I = 0; I != NumArguments; ++I)
|
||||
new (Args + I) TemplateArgument(Builder.getFlatArgumentList()[I]);
|
||||
}
|
||||
|
||||
TemplateArgumentList::~TemplateArgumentList() {
|
||||
|
@ -279,8 +279,7 @@ ClassTemplateSpecializationDecl(ASTContext &Context, Kind DK,
|
|||
// class template specializations?
|
||||
SpecializedTemplate->getIdentifier()),
|
||||
SpecializedTemplate(SpecializedTemplate),
|
||||
TemplateArgs(Context, Builder.getFlatArgumentList(), Builder.flatSize(),
|
||||
/*CopyArgs=*/true),
|
||||
TemplateArgs(Context, Builder, /*CopyArgs=*/true, /*FlattenArgs=*/true),
|
||||
SpecializationKind(TSK_Undeclared) {
|
||||
}
|
||||
|
||||
|
|
|
@ -1007,10 +1007,9 @@ bool Sema::CheckTemplateArgumentList(TemplateDecl *Template,
|
|||
Converted.flatSize(),
|
||||
SourceRange(TemplateLoc, RAngleLoc));
|
||||
|
||||
TemplateArgumentList TemplateArgs(Context,
|
||||
Converted.getFlatArgumentList(),
|
||||
Converted.flatSize(),
|
||||
/*CopyArgs=*/false);
|
||||
TemplateArgumentList TemplateArgs(Context, Converted,
|
||||
/*CopyArgs=*/false,
|
||||
/*FlattenArgs=*/false);
|
||||
ArgType = InstantiateType(ArgType, TemplateArgs,
|
||||
TTP->getDefaultArgumentLoc(),
|
||||
TTP->getDeclName());
|
||||
|
@ -1079,10 +1078,9 @@ bool Sema::CheckTemplateArgumentList(TemplateDecl *Template,
|
|||
Converted.flatSize(),
|
||||
SourceRange(TemplateLoc, RAngleLoc));
|
||||
|
||||
TemplateArgumentList TemplateArgs(Context,
|
||||
Converted.getFlatArgumentList(),
|
||||
Converted.flatSize(),
|
||||
/*CopyArgs=*/false);
|
||||
TemplateArgumentList TemplateArgs(Context, Converted,
|
||||
/*CopyArgs=*/false,
|
||||
/*FlattenArgs=*/false);
|
||||
NTTPType = InstantiateType(NTTPType, TemplateArgs,
|
||||
NTTP->getLocation(),
|
||||
NTTP->getDeclName());
|
||||
|
|
|
@ -384,6 +384,12 @@ Sema::DeduceTemplateArguments(ClassTemplatePartialSpecializationDecl *Partial,
|
|||
}
|
||||
}
|
||||
|
||||
return new (Context) TemplateArgumentList(Context, Deduced.data(),
|
||||
Deduced.size(), /*CopyArgs=*/true);
|
||||
// FIXME: This is terrible. DeduceTemplateArguments should use a
|
||||
// TemplateArgumentListBuilder directly.
|
||||
TemplateArgumentListBuilder Builder;
|
||||
for (unsigned I = 0, N = Deduced.size(); I != N; ++I)
|
||||
Builder.push_back(Deduced[I]);
|
||||
|
||||
return new (Context) TemplateArgumentList(Context, Builder, /*CopyArgs=*/true,
|
||||
/*FlattenArgs=*/true);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue