[PATCH] D19244: Extend checking of va_start builtin

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 18 15:52:36 PDT 2016

aaron.ballman created this revision.
aaron.ballman added reviewers: rsmith, dblaikie.
aaron.ballman added a subscriber: cfe-commits.
Herald added a subscriber: aemerson.

The va_start macro currently diagnoses passing a reference as the second argument (the one representing the parameter before the ellipsis) because this is undefined behavior in C++. This patch extends the checking to cover additional cases of undefined behavior in both C and C++. The C11 Standard, states, in part:

If the parameter parmN is declared with the register storage class, with a function or array type, or with a type that is not compatible with the type that results after application of the default argument promotions, the behavior is undefined.

(This is picked up by reference in C++ under [support.runtime]p3.)

This patch adds a check for default argument promotions as well as parameters declared with the register storage class. This helps cover some more of the CERT secure coding rule EXP58-CPP. Pass an object of the correct type to va_start (https://www.securecoding.cert.org/confluence/display/cplusplus/EXP58-CPP.+Pass+an+object+of+the+correct+type+to+va_start).



-------------- next part --------------
A non-text attachment was scrubbed...
Name: D19244.54129.patch
Type: text/x-patch
Size: 4794 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160418/aaa88b96/attachment.bin>

More information about the cfe-commits mailing list