[cfe-dev] [-Wdocumentation][RFC] \param with multiple identifiers
Bruno Ricci via cfe-dev
cfe-dev at lists.llvm.org
Sun Aug 25 12:25:31 PDT 2019
> 1.
> I can change ParamIndex to a SmallVector and change the AST output to
> [in] explicitly Param="x,y,z" ParamIndex=1 ParamIndex=2 ParamIndex=3
> I wonder whether that would make the users of the AST output happy.
> Suddenly there can be multiple ParamIndex 'fields'.
Note however that AST classes are allocated with a BumpPtrAllocator, and
that therefore their destructor is not executed. They should therefore be
trivially destructible. This is not currently enforced but I have put two
patches for review (D66646 and D66722) which enforce this with a static_assert.
What you can do instead is either:
1) If you need to have the flexibility to change the size of the array,
or if 2) is too complicated, just store a pointer to the array and
allocate the array with the allocator (for an example see
FunctionDecl::setParams).
2) Or if the number of elements in the array is fixed and known when
the AST node is created, store them just after the node in memory
with llvm::TrailingObjects (plenty of examples, just grep for TrailingObjects).
This is especially easy if the class is a leaf class.
Bruno
More information about the cfe-dev
mailing list