[cfe-dev] [CGCall] Mapping elements of CallArgList to parameter declarations

Alexey Samsonov vonosmas at gmail.com
Thu Aug 14 11:26:18 PDT 2014


Hi,

I need to access declarations of function parameters when I emit a call to
this function. Namely, if certain function parameters are declared to be
nonnull (by __attribute__((nonnull))), I can add corresponding attributes
to the call site and emit a runtime check verifying that call arguments are
indeed nonnull.

This turns out to be unexpectedly hard: when we emit a call
(CodeGenFunction::EmitCall), we have the following information:
  1) CGFunctionInfo, which is essentially a vector describing types/ABI
kinds of call arguments (of LLVM IR function).
  2) CallArgList, which has the same size as CGFunctionInfo and contains
RValues - actual call arguments.
  3) (optional) Decl of a callee.
However, we don't have a mapping that would tell us which elements of
CGFunctionInfo/CallArgList correspond to ParmVarDecl in a callee Decl
(there can be different kinds of implicit arguments, like "this", or VTT,
and their position in CallArgList is not trivially deducible).

Am I missing something obvious? Or this task indeed can't be done without
significant refactoring of CGCall logic? Thanks.

-- 
Alexey Samsonov
vonosmas at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20140814/eef03e46/attachment.html>


More information about the cfe-dev mailing list