r248905 - Fix FunctionParmPackExpr::Create() to take a ParmVarDecl* array.
James Y Knight via cfe-commits
cfe-commits at lists.llvm.org
Wed Sep 30 07:04:24 PDT 2015
Author: jyknight
Date: Wed Sep 30 09:04:23 2015
New Revision: 248905
URL: http://llvm.org/viewvc/llvm-project?rev=248905&view=rev
Log:
Fix FunctionParmPackExpr::Create() to take a ParmVarDecl* array.
FunctionParmPackExpr actually stores an array of ParmVarDecl* (and
accessors return that). But, the FunctionParmPackExpr::Create()
constructor accepted an array of Decl *s instead.
It was easy for this mismatch to occur without any obvious sign of
something wrong, since both the store and the access used independent
'reinterpet_cast<XX>(this+1)' calls.
Modified:
cfe/trunk/include/clang/AST/ExprCXX.h
cfe/trunk/include/clang/Sema/Template.h
cfe/trunk/lib/AST/ExprCXX.cpp
cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp
Modified: cfe/trunk/include/clang/AST/ExprCXX.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ExprCXX.h?rev=248905&r1=248904&r2=248905&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/ExprCXX.h (original)
+++ cfe/trunk/include/clang/AST/ExprCXX.h Wed Sep 30 09:04:23 2015
@@ -3787,7 +3787,7 @@ class FunctionParmPackExpr : public Expr
FunctionParmPackExpr(QualType T, ParmVarDecl *ParamPack,
SourceLocation NameLoc, unsigned NumParams,
- Decl * const *Params);
+ ParmVarDecl *const *Params);
friend class ASTReader;
friend class ASTStmtReader;
@@ -3796,7 +3796,7 @@ public:
static FunctionParmPackExpr *Create(const ASTContext &Context, QualType T,
ParmVarDecl *ParamPack,
SourceLocation NameLoc,
- ArrayRef<Decl *> Params);
+ ArrayRef<ParmVarDecl *> Params);
static FunctionParmPackExpr *CreateEmpty(const ASTContext &Context,
unsigned NumParams);
Modified: cfe/trunk/include/clang/Sema/Template.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Template.h?rev=248905&r1=248904&r2=248905&view=diff
==============================================================================
--- cfe/trunk/include/clang/Sema/Template.h (original)
+++ cfe/trunk/include/clang/Sema/Template.h Wed Sep 30 09:04:23 2015
@@ -178,8 +178,8 @@ namespace clang {
class LocalInstantiationScope {
public:
/// \brief A set of declarations.
- typedef SmallVector<Decl *, 4> DeclArgumentPack;
-
+ typedef SmallVector<ParmVarDecl *, 4> DeclArgumentPack;
+
private:
/// \brief Reference to the semantic analysis that is performing
/// this template instantiation.
@@ -332,7 +332,7 @@ namespace clang {
findInstantiationOf(const Decl *D);
void InstantiatedLocal(const Decl *D, Decl *Inst);
- void InstantiatedLocalPackArg(const Decl *D, Decl *Inst);
+ void InstantiatedLocalPackArg(const Decl *D, ParmVarDecl *Inst);
void MakeInstantiatedLocalArgPack(const Decl *D);
/// \brief Note that the given parameter pack has been partially substituted
Modified: cfe/trunk/lib/AST/ExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprCXX.cpp?rev=248905&r1=248904&r2=248905&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ExprCXX.cpp (original)
+++ cfe/trunk/lib/AST/ExprCXX.cpp Wed Sep 30 09:04:23 2015
@@ -1468,19 +1468,19 @@ TemplateArgument SubstNonTypeTemplatePar
FunctionParmPackExpr::FunctionParmPackExpr(QualType T, ParmVarDecl *ParamPack,
SourceLocation NameLoc,
unsigned NumParams,
- Decl * const *Params)
- : Expr(FunctionParmPackExprClass, T, VK_LValue, OK_Ordinary,
- true, true, true, true),
- ParamPack(ParamPack), NameLoc(NameLoc), NumParameters(NumParams) {
+ ParmVarDecl *const *Params)
+ : Expr(FunctionParmPackExprClass, T, VK_LValue, OK_Ordinary, true, true,
+ true, true),
+ ParamPack(ParamPack), NameLoc(NameLoc), NumParameters(NumParams) {
if (Params)
std::uninitialized_copy(Params, Params + NumParams,
- reinterpret_cast<Decl**>(this+1));
+ reinterpret_cast<ParmVarDecl **>(this + 1));
}
FunctionParmPackExpr *
FunctionParmPackExpr::Create(const ASTContext &Context, QualType T,
ParmVarDecl *ParamPack, SourceLocation NameLoc,
- ArrayRef<Decl *> Params) {
+ ArrayRef<ParmVarDecl *> Params) {
return new (Context.Allocate(sizeof(FunctionParmPackExpr) +
sizeof(ParmVarDecl*) * Params.size()))
FunctionParmPackExpr(T, ParamPack, NameLoc, Params.size(), Params.data());
Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp?rev=248905&r1=248904&r2=248905&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp Wed Sep 30 09:04:23 2015
@@ -1231,7 +1231,7 @@ TemplateInstantiator::TransformFunctionP
// Transform each of the parameter expansions into the corresponding
// parameters in the instantiation of the function decl.
- SmallVector<Decl *, 8> Parms;
+ SmallVector<ParmVarDecl *, 8> Parms;
Parms.reserve(E->getNumExpansions());
for (FunctionParmPackExpr::iterator I = E->begin(), End = E->end();
I != End; ++I) {
@@ -2805,14 +2805,14 @@ void LocalInstantiationScope::Instantiat
#endif
Stored = Inst;
} else if (DeclArgumentPack *Pack = Stored.dyn_cast<DeclArgumentPack *>()) {
- Pack->push_back(Inst);
+ Pack->push_back(cast<ParmVarDecl>(Inst));
} else {
assert(Stored.get<Decl *>() == Inst && "Already instantiated this local");
}
}
-void LocalInstantiationScope::InstantiatedLocalPackArg(const Decl *D,
- Decl *Inst) {
+void LocalInstantiationScope::InstantiatedLocalPackArg(const Decl *D,
+ ParmVarDecl *Inst) {
D = getCanonicalParmVarDecl(D);
DeclArgumentPack *Pack = LocalDecls[D].get<DeclArgumentPack *>();
Pack->push_back(Inst);
More information about the cfe-commits
mailing list