Changeset View
Changeset View
Standalone View
Standalone View
clang/lib/Sema/DeclSpec.cpp
Show First 20 Lines • Show All 233 Lines • ▼ Show 20 Lines | DeclaratorChunk DeclaratorChunk::getFunction(bool hasProto, | ||||
// new[] a parameter array if needed. | // new[] a parameter array if needed. | ||||
if (NumParams) { | if (NumParams) { | ||||
// If the 'InlineParams' in Declarator is unused and big enough, put our | // If the 'InlineParams' in Declarator is unused and big enough, put our | ||||
// parameter list there (in an effort to avoid new/delete traffic). If it | // parameter list there (in an effort to avoid new/delete traffic). If it | ||||
// is already used (consider a function returning a function pointer) or too | // is already used (consider a function returning a function pointer) or too | ||||
// small (function with too many parameters), go to the heap. | // small (function with too many parameters), go to the heap. | ||||
if (!TheDeclarator.InlineStorageUsed && | if (!TheDeclarator.InlineStorageUsed && | ||||
NumParams <= llvm::array_lengthof(TheDeclarator.InlineParams)) { | NumParams <= std::size(TheDeclarator.InlineParams)) { | ||||
I.Fun.Params = TheDeclarator.InlineParams; | I.Fun.Params = TheDeclarator.InlineParams; | ||||
new (I.Fun.Params) ParamInfo[NumParams]; | new (I.Fun.Params) ParamInfo[NumParams]; | ||||
I.Fun.DeleteParams = false; | I.Fun.DeleteParams = false; | ||||
TheDeclarator.InlineStorageUsed = true; | TheDeclarator.InlineStorageUsed = true; | ||||
} else { | } else { | ||||
I.Fun.Params = new DeclaratorChunk::ParamInfo[NumParams]; | I.Fun.Params = new DeclaratorChunk::ParamInfo[NumParams]; | ||||
I.Fun.DeleteParams = true; | I.Fun.DeleteParams = true; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 52 Lines • ▼ Show 20 Lines | void Declarator::setDecompositionBindings( | ||||
Range.setEnd(RSquareLoc); | Range.setEnd(RSquareLoc); | ||||
// We're now past the identifier. | // We're now past the identifier. | ||||
SetIdentifier(nullptr, LSquareLoc); | SetIdentifier(nullptr, LSquareLoc); | ||||
Name.EndLocation = RSquareLoc; | Name.EndLocation = RSquareLoc; | ||||
// Allocate storage for bindings and stash them away. | // Allocate storage for bindings and stash them away. | ||||
if (Bindings.size()) { | if (Bindings.size()) { | ||||
if (!InlineStorageUsed && | if (!InlineStorageUsed && Bindings.size() <= std::size(InlineBindings)) { | ||||
Bindings.size() <= llvm::array_lengthof(InlineBindings)) { | |||||
BindingGroup.Bindings = InlineBindings; | BindingGroup.Bindings = InlineBindings; | ||||
BindingGroup.DeleteBindings = false; | BindingGroup.DeleteBindings = false; | ||||
InlineStorageUsed = true; | InlineStorageUsed = true; | ||||
} else { | } else { | ||||
BindingGroup.Bindings = | BindingGroup.Bindings = | ||||
new DecompositionDeclarator::Binding[Bindings.size()]; | new DecompositionDeclarator::Binding[Bindings.size()]; | ||||
BindingGroup.DeleteBindings = true; | BindingGroup.DeleteBindings = true; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 1,186 Lines • Show Last 20 Lines |