зеркало из https://github.com/microsoft/clang-1.git
Make TemplateArgumentListBuilder take an ASTContext (because we're probably going to need it later). Move push_back to the .cpp file. If the passed in template argument is a type, assert that it's canonical.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72918 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
e9c904b082
Коммит
9ba4164589
|
@ -577,14 +577,16 @@ public:
|
|||
class TemplateArgumentListBuilder {
|
||||
llvm::SmallVector<TemplateArgument, 16> Args;
|
||||
|
||||
ASTContext &Context;
|
||||
public:
|
||||
TemplateArgumentListBuilder(ASTContext &Context) : Context(Context) { }
|
||||
|
||||
// FIXME: Should use the index array size.
|
||||
size_t size() const { return Args.size(); }
|
||||
|
||||
size_t flatSize() const { return Args.size(); }
|
||||
|
||||
|
||||
void push_back(const TemplateArgument& Arg);
|
||||
TemplateArgument *getFlatArgumentList() { return Args.data(); }
|
||||
void push_back(const TemplateArgument& Arg) { Args.push_back(Arg); }
|
||||
};
|
||||
|
||||
/// \brief A template argument list.
|
||||
|
|
|
@ -235,6 +235,19 @@ TemplateArgument::TemplateArgument(Expr *E) : Kind(Expression) {
|
|||
StartLoc = E->getSourceRange().getBegin();
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// TemplateArgumentListBuilder Implementation
|
||||
//===----------------------------------------------------------------------===//
|
||||
void TemplateArgumentListBuilder::push_back(const TemplateArgument& Arg) {
|
||||
switch (Arg.getKind()) {
|
||||
case TemplateArgument::Type:
|
||||
assert(Arg.getAsType()->isCanonical() && "Type must be canonical!");
|
||||
break;
|
||||
}
|
||||
|
||||
Args.push_back(Arg);
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// TemplateArgumentList Implementation
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
|
|
@ -811,7 +811,7 @@ QualType Sema::CheckTemplateIdType(TemplateName Name,
|
|||
|
||||
// Check that the template argument list is well-formed for this
|
||||
// template.
|
||||
TemplateArgumentListBuilder ConvertedTemplateArgs;
|
||||
TemplateArgumentListBuilder ConvertedTemplateArgs(Context);
|
||||
if (CheckTemplateArgumentList(Template, TemplateLoc, LAngleLoc,
|
||||
TemplateArgs, NumTemplateArgs, RAngleLoc,
|
||||
ConvertedTemplateArgs))
|
||||
|
@ -2064,7 +2064,7 @@ Sema::ActOnClassTemplateSpecialization(Scope *S, unsigned TagSpec, TagKind TK,
|
|||
|
||||
// Check that the template argument list is well-formed for this
|
||||
// template.
|
||||
TemplateArgumentListBuilder ConvertedTemplateArgs;
|
||||
TemplateArgumentListBuilder ConvertedTemplateArgs(Context);
|
||||
if (CheckTemplateArgumentList(ClassTemplate, TemplateNameLoc, LAngleLoc,
|
||||
&TemplateArgs[0], TemplateArgs.size(),
|
||||
RAngleLoc, ConvertedTemplateArgs))
|
||||
|
@ -2268,7 +2268,7 @@ Sema::ActOnExplicitInstantiation(Scope *S, SourceLocation TemplateLoc,
|
|||
|
||||
// Check that the template argument list is well-formed for this
|
||||
// template.
|
||||
TemplateArgumentListBuilder ConvertedTemplateArgs;
|
||||
TemplateArgumentListBuilder ConvertedTemplateArgs(Context);
|
||||
if (CheckTemplateArgumentList(ClassTemplate, TemplateNameLoc, LAngleLoc,
|
||||
TemplateArgs.data(), TemplateArgs.size(),
|
||||
RAngleLoc, ConvertedTemplateArgs))
|
||||
|
|
|
@ -386,7 +386,7 @@ Sema::DeduceTemplateArguments(ClassTemplatePartialSpecializationDecl *Partial,
|
|||
|
||||
// FIXME: This is terrible. DeduceTemplateArguments should use a
|
||||
// TemplateArgumentListBuilder directly.
|
||||
TemplateArgumentListBuilder Builder;
|
||||
TemplateArgumentListBuilder Builder(Context);
|
||||
for (unsigned I = 0, N = Deduced.size(); I != N; ++I)
|
||||
Builder.push_back(Deduced[I]);
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче