forked from OSchip/llvm-project
Add ArrayRef<> interface to get the parameters of a FunctionDecl/ObjCMethodDecl.
This is an alternate interface to the separate iterator interfaces provided by FunctionDecl and ObjCMethodDecl, which precede ArrayRef. Providing this new interface is more convenient for some uses, and likely the old interfaces should be removed. I have not undertaken that effort in this change because this API introduction may solicit commentary and that was a larger change than I wanted to introduce all at once to serve a direct purpose. llvm-svn: 199466
This commit is contained in:
parent
a146db3987
commit
07e4a66306
|
@ -1851,6 +1851,12 @@ public:
|
|||
setParams(getASTContext(), NewParamInfo);
|
||||
}
|
||||
|
||||
// ArrayRef iterface to parameters.
|
||||
// FIXME: Should one day replace iterator interface.
|
||||
ArrayRef<ParmVarDecl*> parameters() const {
|
||||
return llvm::makeArrayRef(ParamInfo, getNumParams());
|
||||
}
|
||||
|
||||
const ArrayRef<NamedDecl *> &getDeclsInPrototypeScope() const {
|
||||
return DeclsInPrototypeScope;
|
||||
}
|
||||
|
|
|
@ -314,8 +314,7 @@ public:
|
|||
if (hasStandardSelLocs())
|
||||
return getStandardSelectorLoc(Index, getSelector(),
|
||||
getSelLocsKind() == SelLoc_StandardWithSpace,
|
||||
llvm::makeArrayRef(const_cast<ParmVarDecl**>(getParams()),
|
||||
NumParams),
|
||||
parameters(),
|
||||
DeclEndLoc);
|
||||
return getStoredSelLocs()[Index];
|
||||
}
|
||||
|
@ -364,6 +363,13 @@ public:
|
|||
return param_begin() + getSelector().getNumArgs();
|
||||
}
|
||||
|
||||
// ArrayRef access to formal parameters. This should eventually
|
||||
// replace the iterator interface above.
|
||||
ArrayRef<ParmVarDecl*> parameters() const {
|
||||
return llvm::makeArrayRef(const_cast<ParmVarDecl**>(getParams()),
|
||||
NumParams);
|
||||
}
|
||||
|
||||
/// \brief Sets the method's parameters and selector source locations.
|
||||
/// If the method is implicit (not coming from source) \p SelLocs is
|
||||
/// ignored.
|
||||
|
|
Loading…
Reference in New Issue