mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-01-10 18:11:19 +00:00
ArrayRef'ize MultiLevelTemplateArgumentList::ArgList. Patch by Faisal Vali!
llvm-svn: 181077
This commit is contained in:
parent
b4eadc34e1
commit
47752e489e
@ -40,10 +40,9 @@ namespace clang {
|
||||
/// list will contain a template argument list (int) at depth 0 and a
|
||||
/// template argument list (17) at depth 1.
|
||||
class MultiLevelTemplateArgumentList {
|
||||
public:
|
||||
typedef std::pair<const TemplateArgument *, unsigned> ArgList;
|
||||
|
||||
private:
|
||||
/// \brief The template argument list at a certain template depth
|
||||
typedef ArrayRef<TemplateArgument> ArgList;
|
||||
|
||||
/// \brief The template argument lists, stored from the innermost template
|
||||
/// argument list (first) to the outermost template argument list (last).
|
||||
SmallVector<ArgList, 4> TemplateArgumentLists;
|
||||
@ -65,8 +64,8 @@ namespace clang {
|
||||
/// \brief Retrieve the template argument at a given depth and index.
|
||||
const TemplateArgument &operator()(unsigned Depth, unsigned Index) const {
|
||||
assert(Depth < TemplateArgumentLists.size());
|
||||
assert(Index < TemplateArgumentLists[getNumLevels() - Depth - 1].second);
|
||||
return TemplateArgumentLists[getNumLevels() - Depth - 1].first[Index];
|
||||
assert(Index < TemplateArgumentLists[getNumLevels() - Depth - 1].size());
|
||||
return TemplateArgumentLists[getNumLevels() - Depth - 1][Index];
|
||||
}
|
||||
|
||||
/// \brief Determine whether there is a non-NULL template argument at the
|
||||
@ -76,7 +75,7 @@ namespace clang {
|
||||
bool hasTemplateArgument(unsigned Depth, unsigned Index) const {
|
||||
assert(Depth < TemplateArgumentLists.size());
|
||||
|
||||
if (Index >= TemplateArgumentLists[getNumLevels() - Depth - 1].second)
|
||||
if (Index >= TemplateArgumentLists[getNumLevels() - Depth - 1].size())
|
||||
return false;
|
||||
|
||||
return !(*this)(Depth, Index).isNull();
|
||||
@ -86,9 +85,9 @@ namespace clang {
|
||||
void setArgument(unsigned Depth, unsigned Index,
|
||||
TemplateArgument Arg) {
|
||||
assert(Depth < TemplateArgumentLists.size());
|
||||
assert(Index < TemplateArgumentLists[getNumLevels() - Depth - 1].second);
|
||||
assert(Index < TemplateArgumentLists[getNumLevels() - Depth - 1].size());
|
||||
const_cast<TemplateArgument&>(
|
||||
TemplateArgumentLists[getNumLevels() - Depth - 1].first[Index])
|
||||
TemplateArgumentLists[getNumLevels() - Depth - 1][Index])
|
||||
= Arg;
|
||||
}
|
||||
|
||||
|
@ -3668,14 +3668,11 @@ ExprResult Sema::BuildCXXDefaultArgExpr(SourceLocation CallLoc,
|
||||
Param);
|
||||
|
||||
// Instantiate the expression.
|
||||
MultiLevelTemplateArgumentList ArgList
|
||||
MultiLevelTemplateArgumentList MutiLevelArgList
|
||||
= getTemplateInstantiationArgs(FD, 0, /*RelativeToPrimary=*/true);
|
||||
|
||||
std::pair<const TemplateArgument *, unsigned> Innermost
|
||||
= ArgList.getInnermost();
|
||||
InstantiatingTemplate Inst(*this, CallLoc, Param,
|
||||
ArrayRef<TemplateArgument>(Innermost.first,
|
||||
Innermost.second));
|
||||
MutiLevelArgList.getInnermost());
|
||||
if (Inst)
|
||||
return ExprError();
|
||||
|
||||
@ -3687,7 +3684,7 @@ ExprResult Sema::BuildCXXDefaultArgExpr(SourceLocation CallLoc,
|
||||
// default argument expression appears.
|
||||
ContextRAII SavedContext(*this, FD);
|
||||
LocalInstantiationScope Local(*this);
|
||||
Result = SubstExpr(UninstExpr, ArgList);
|
||||
Result = SubstExpr(UninstExpr, MutiLevelArgList);
|
||||
}
|
||||
if (Result.isInvalid())
|
||||
return ExprError();
|
||||
|
@ -1152,12 +1152,11 @@ Decl *TemplateDeclInstantiator::VisitFunctionDecl(FunctionDecl *D,
|
||||
// this declaration.
|
||||
FunctionTemplateDecl *FunctionTemplate = D->getDescribedFunctionTemplate();
|
||||
if (FunctionTemplate && !TemplateParams) {
|
||||
std::pair<const TemplateArgument *, unsigned> Innermost
|
||||
= TemplateArgs.getInnermost();
|
||||
ArrayRef<TemplateArgument> Innermost = TemplateArgs.getInnermost();
|
||||
|
||||
void *InsertPos = 0;
|
||||
FunctionDecl *SpecFunc
|
||||
= FunctionTemplate->findSpecialization(Innermost.first, Innermost.second,
|
||||
= FunctionTemplate->findSpecialization(Innermost.begin(), Innermost.size(),
|
||||
InsertPos);
|
||||
|
||||
// If we already have a function template specialization, return it.
|
||||
@ -1282,12 +1281,11 @@ Decl *TemplateDeclInstantiator::VisitFunctionDecl(FunctionDecl *D,
|
||||
}
|
||||
} else if (FunctionTemplate) {
|
||||
// Record this function template specialization.
|
||||
std::pair<const TemplateArgument *, unsigned> Innermost
|
||||
= TemplateArgs.getInnermost();
|
||||
ArrayRef<TemplateArgument> Innermost = TemplateArgs.getInnermost();
|
||||
Function->setFunctionTemplateSpecialization(FunctionTemplate,
|
||||
TemplateArgumentList::CreateCopy(SemaRef.Context,
|
||||
Innermost.first,
|
||||
Innermost.second),
|
||||
Innermost.begin(),
|
||||
Innermost.size()),
|
||||
/*InsertPos=*/0);
|
||||
} else if (isFriend) {
|
||||
// Note, we need this connection even if the friend doesn't have a body.
|
||||
@ -1460,12 +1458,12 @@ TemplateDeclInstantiator::VisitCXXMethodDecl(CXXMethodDecl *D,
|
||||
// We are creating a function template specialization from a function
|
||||
// template. Check whether there is already a function template
|
||||
// specialization for this particular set of template arguments.
|
||||
std::pair<const TemplateArgument *, unsigned> Innermost
|
||||
= TemplateArgs.getInnermost();
|
||||
ArrayRef<TemplateArgument> Innermost = TemplateArgs.getInnermost();
|
||||
|
||||
void *InsertPos = 0;
|
||||
FunctionDecl *SpecFunc
|
||||
= FunctionTemplate->findSpecialization(Innermost.first, Innermost.second,
|
||||
= FunctionTemplate->findSpecialization(Innermost.begin(),
|
||||
Innermost.size(),
|
||||
InsertPos);
|
||||
|
||||
// If we already have a function template specialization, return it.
|
||||
@ -1616,12 +1614,11 @@ TemplateDeclInstantiator::VisitCXXMethodDecl(CXXMethodDecl *D,
|
||||
Method->setDescribedFunctionTemplate(FunctionTemplate);
|
||||
} else if (FunctionTemplate) {
|
||||
// Record this function template specialization.
|
||||
std::pair<const TemplateArgument *, unsigned> Innermost
|
||||
= TemplateArgs.getInnermost();
|
||||
ArrayRef<TemplateArgument> Innermost = TemplateArgs.getInnermost();
|
||||
Method->setFunctionTemplateSpecialization(FunctionTemplate,
|
||||
TemplateArgumentList::CreateCopy(SemaRef.Context,
|
||||
Innermost.first,
|
||||
Innermost.second),
|
||||
Innermost.begin(),
|
||||
Innermost.size()),
|
||||
/*InsertPos=*/0);
|
||||
} else if (!isFriend) {
|
||||
// Record that this is an instantiation of a member function.
|
||||
|
Loading…
x
Reference in New Issue
Block a user