[cfe-commits] r140268 - in /cfe/trunk: include/clang/AST/Decl.h lib/AST/ASTImporter.cpp lib/AST/Decl.cpp lib/Sema/SemaDecl.cpp lib/Sema/SemaDeclAttr.cpp lib/Sema/SemaDeclCXX.cpp lib/Sema/SemaExpr.cpp lib/Sema/SemaExprCXX.cpp lib/Sema/SemaTemplateInstantiateDecl.cpp lib/Sema/TreeTransform.h lib/Serialization/ASTReaderDecl.cpp
David Blaikie
dblaikie at gmail.com
Wed Sep 21 11:16:56 PDT 2011
Author: dblaikie
Date: Wed Sep 21 13:16:56 2011
New Revision: 140268
URL: http://llvm.org/viewvc/llvm-project?rev=140268&view=rev
Log:
ArrayRef-ifying Function/BlockDecl's setParams
Modified:
cfe/trunk/include/clang/AST/Decl.h
cfe/trunk/lib/AST/ASTImporter.cpp
cfe/trunk/lib/AST/Decl.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaExprCXX.cpp
cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
cfe/trunk/lib/Sema/TreeTransform.h
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
Modified: cfe/trunk/include/clang/AST/Decl.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=140268&r1=140267&r2=140268&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Wed Sep 21 13:16:56 2011
@@ -20,6 +20,7 @@
#include "clang/AST/DeclarationName.h"
#include "clang/AST/ExternalASTSource.h"
#include "clang/Basic/Linkage.h"
+#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/Optional.h"
namespace clang {
@@ -1480,7 +1481,7 @@
void setInstantiationOfMemberFunction(ASTContext &C, FunctionDecl *FD,
TemplateSpecializationKind TSK);
- void setParams(ASTContext &C, ParmVarDecl **NewParamInfo, unsigned NumParams);
+ void setParams(ASTContext &C, llvm::ArrayRef<ParmVarDecl *> NewParamInfo);
protected:
FunctionDecl(Kind DK, DeclContext *DC, SourceLocation StartLoc,
@@ -1750,8 +1751,8 @@
assert(i < getNumParams() && "Illegal param #");
return ParamInfo[i];
}
- void setParams(ParmVarDecl **NewParamInfo, unsigned NumParams) {
- setParams(getASTContext(), NewParamInfo, NumParams);
+ void setParams(llvm::ArrayRef<ParmVarDecl *> NewParamInfo) {
+ setParams(getASTContext(), NewParamInfo);
}
/// getMinRequiredArguments - Returns the minimum number of arguments
@@ -2997,7 +2998,7 @@
assert(i < getNumParams() && "Illegal param #");
return ParamInfo[i];
}
- void setParams(ParmVarDecl **NewParamInfo, unsigned NumParams);
+ void setParams(llvm::ArrayRef<ParmVarDecl *> NewParamInfo);
/// hasCaptures - True if this block (or its nested blocks) captures
/// anything of local storage from its enclosing scopes.
Modified: cfe/trunk/lib/AST/ASTImporter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTImporter.cpp?rev=140268&r1=140267&r2=140268&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ASTImporter.cpp (original)
+++ cfe/trunk/lib/AST/ASTImporter.cpp Wed Sep 21 13:16:56 2011
@@ -2521,7 +2521,7 @@
Parameters[I]->setOwningFunction(ToFunction);
ToFunction->addDecl(Parameters[I]);
}
- ToFunction->setParams(Parameters.data(), Parameters.size());
+ ToFunction->setParams(Parameters);
// FIXME: Other bits to merge?
Modified: cfe/trunk/lib/AST/Decl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=140268&r1=140267&r2=140268&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Decl.cpp (original)
+++ cfe/trunk/lib/AST/Decl.cpp Wed Sep 21 13:16:56 2011
@@ -28,6 +28,8 @@
#include "clang/Basic/TargetInfo.h"
#include "llvm/Support/ErrorHandling.h"
+#include <algorithm>
+
using namespace clang;
//===----------------------------------------------------------------------===//
@@ -1688,15 +1690,14 @@
}
void FunctionDecl::setParams(ASTContext &C,
- ParmVarDecl **NewParamInfo, unsigned NumParams) {
+ llvm::ArrayRef<ParmVarDecl *> NewParamInfo) {
assert(ParamInfo == 0 && "Already has param info!");
- assert(NumParams == getNumParams() && "Parameter count mismatch!");
+ assert(NewParamInfo.size() == getNumParams() && "Parameter count mismatch!");
// Zero params -> null pointer.
- if (NumParams) {
- void *Mem = C.Allocate(sizeof(ParmVarDecl*)*NumParams);
- ParamInfo = new (Mem) ParmVarDecl*[NumParams];
- memcpy(ParamInfo, NewParamInfo, sizeof(ParmVarDecl*)*NumParams);
+ if (!NewParamInfo.empty()) {
+ ParamInfo = new (C) ParmVarDecl*[NewParamInfo.size()];
+ std::copy(NewParamInfo.begin(), NewParamInfo.end(), ParamInfo);
}
}
@@ -2430,16 +2431,14 @@
// BlockDecl Implementation
//===----------------------------------------------------------------------===//
-void BlockDecl::setParams(ParmVarDecl **NewParamInfo,
- unsigned NParms) {
+void BlockDecl::setParams(llvm::ArrayRef<ParmVarDecl *> NewParamInfo) {
assert(ParamInfo == 0 && "Already has param info!");
// Zero params -> null pointer.
- if (NParms) {
- NumParams = NParms;
- void *Mem = getASTContext().Allocate(sizeof(ParmVarDecl*)*NumParams);
- ParamInfo = new (Mem) ParmVarDecl*[NumParams];
- memcpy(ParamInfo, NewParamInfo, sizeof(ParmVarDecl*)*NumParams);
+ if (!NewParamInfo.empty()) {
+ NumParams = NewParamInfo.size();
+ ParamInfo = new (getASTContext()) ParmVarDecl*[NewParamInfo.size()];
+ std::copy(NewParamInfo.begin(), NewParamInfo.end(), ParamInfo);
}
}
Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=140268&r1=140267&r2=140268&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Wed Sep 21 13:16:56 2011
@@ -1290,7 +1290,7 @@
parm->setScopeInfo(0, i);
Params.push_back(parm);
}
- New->setParams(Params.data(), Params.size());
+ New->setParams(Params);
}
AddKnownFunctionAttributes(New);
@@ -1853,7 +1853,7 @@
Params.push_back(Param);
}
- New->setParams(Params.data(), Params.size());
+ New->setParams(Params);
}
return MergeCompatibleFunctionDecls(New, Old);
@@ -4873,7 +4873,7 @@
"Should not need args for typedef of non-prototype fn");
}
// Finally, we know we have the right number of parameters, install them.
- NewFD->setParams(Params.data(), Params.size());
+ NewFD->setParams(Params);
// Process the non-inheritable attributes on this declaration.
ProcessDeclAttributes(S, NewFD, D,
Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=140268&r1=140267&r2=140268&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Wed Sep 21 13:16:56 2011
@@ -3674,7 +3674,7 @@
Param->setScopeInfo(0, Params.size());
Params.push_back(Param);
}
- NewFD->setParams(Params.data(), Params.size());
+ NewFD->setParams(Params);
}
} else if (VarDecl *VD = dyn_cast<VarDecl>(ND)) {
NewD = VarDecl::Create(VD->getASTContext(), VD->getDeclContext(),
Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=140268&r1=140267&r2=140268&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Wed Sep 21 13:16:56 2011
@@ -6835,7 +6835,7 @@
/*TInfo=*/0, SC_None,
SC_None, /*DefaultArg=*/0));
}
- NewCtor->setParams(ParamDecls.data(), ParamDecls.size());
+ NewCtor->setParams(ParamDecls);
NewCtor->setInheritedConstructor(BaseCtor);
PushOnScopeChains(NewCtor, S, false);
@@ -7353,7 +7353,7 @@
ArgType, /*TInfo=*/0,
SC_None,
SC_None, 0);
- CopyAssignment->setParams(&FromParam, 1);
+ CopyAssignment->setParams(FromParam);
// Note that we have added this copy-assignment operator.
++ASTContext::NumImplicitCopyAssignmentOperatorsDeclared;
@@ -7768,7 +7768,7 @@
ArgType, /*TInfo=*/0,
SC_None,
SC_None, 0);
- MoveAssignment->setParams(&FromParam, 1);
+ MoveAssignment->setParams(FromParam);
// Note that we have added this copy-assignment operator.
++ASTContext::NumImplicitMoveAssignmentOperatorsDeclared;
@@ -8259,7 +8259,7 @@
ArgType, /*TInfo=*/0,
SC_None,
SC_None, 0);
- CopyConstructor->setParams(&FromParam, 1);
+ CopyConstructor->setParams(FromParam);
if (Scope *S = getScopeForContext(ClassDecl))
PushOnScopeChains(CopyConstructor, S, false);
@@ -8416,7 +8416,7 @@
ArgType, /*TInfo=*/0,
SC_None,
SC_None, 0);
- MoveConstructor->setParams(&FromParam, 1);
+ MoveConstructor->setParams(FromParam);
// C++0x [class.copy]p9:
// If the definition of a class X does not explicitly declare a move
Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=140268&r1=140267&r2=140268&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Wed Sep 21 13:16:56 2011
@@ -8710,7 +8710,7 @@
// Set the parameters on the block decl.
if (!Params.empty()) {
- CurBlock->TheDecl->setParams(Params.data(), Params.size());
+ CurBlock->TheDecl->setParams(Params);
CheckParmsForFunctionDef(CurBlock->TheDecl->param_begin(),
CurBlock->TheDecl->param_end(),
/*CheckParameterNames=*/false);
Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=140268&r1=140267&r2=140268&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Wed Sep 21 13:16:56 2011
@@ -1671,7 +1671,7 @@
SourceLocation(), 0,
Argument, /*TInfo=*/0,
SC_None, SC_None, 0);
- Alloc->setParams(&Param, 1);
+ Alloc->setParams(Param);
// FIXME: Also add this declaration to the IdentifierResolver, but
// make sure it is at the end of the chain to coincide with the
Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp?rev=140268&r1=140267&r2=140268&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp Wed Sep 21 13:16:56 2011
@@ -1112,7 +1112,7 @@
Params.push_back(Param);
}
}
- Function->setParams(Params.data(), Params.size());
+ Function->setParams(Params);
SourceLocation InstantiateAtPOI;
if (TemplateParams) {
@@ -1485,7 +1485,7 @@
// Attach the parameters
for (unsigned P = 0; P < Params.size(); ++P)
Params[P]->setOwningFunction(Method);
- Method->setParams(Params.data(), Params.size());
+ Method->setParams(Params);
if (InitMethodInstantiation(Method, D))
Method->setInvalidDecl();
Modified: cfe/trunk/lib/Sema/TreeTransform.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/TreeTransform.h?rev=140268&r1=140267&r2=140268&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/TreeTransform.h (original)
+++ cfe/trunk/lib/Sema/TreeTransform.h Wed Sep 21 13:16:56 2011
@@ -7989,7 +7989,7 @@
// Set the parameters on the block decl.
if (!params.empty())
- blockScope->TheDecl->setParams(params.data(), params.size());
+ blockScope->TheDecl->setParams(params);
// If the return type wasn't explicitly set, it will have been marked as a
// dependent type (DependentTy); clear out the return type setting so
Modified: cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderDecl.cpp?rev=140268&r1=140267&r2=140268&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTReaderDecl.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReaderDecl.cpp Wed Sep 21 13:16:56 2011
@@ -465,7 +465,7 @@
Params.reserve(NumParams);
for (unsigned I = 0; I != NumParams; ++I)
Params.push_back(ReadDeclAs<ParmVarDecl>(Record, Idx));
- FD->setParams(Reader.getContext(), Params.data(), NumParams);
+ FD->setParams(Reader.getContext(), Params);
}
void ASTDeclReader::VisitObjCMethodDecl(ObjCMethodDecl *MD) {
@@ -758,7 +758,7 @@
Params.reserve(NumParams);
for (unsigned I = 0; I != NumParams; ++I)
Params.push_back(ReadDeclAs<ParmVarDecl>(Record, Idx));
- BD->setParams(Params.data(), NumParams);
+ BD->setParams(Params);
bool capturesCXXThis = Record[Idx++];
unsigned numCaptures = Record[Idx++];
More information about the cfe-commits
mailing list