[cfe-dev] Adding OpenCL format specifiers to printf format checking

Erik Schnetter schnetter at gmail.com
Wed Nov 27 11:09:33 PST 2013


I want to add the OpenCL format specifiers to the printf format checking in Clang (i.e. the checking performed for functions declared with attribute((format))). The major difference is that OpenCL's printf allows vector arguments, and there can be a "vector specifier" of the form "vN" specifying the vector length just before the argument type, as in "%v4lf" for type type double4. double4 is declared as

typedef double double4 attribute((ext_vector_type(4)));

I know how to implement parsing the vector specifier etc.

I don't how to match these vector types. I assume I have to modify PrintfSpecifier::getArgType in PrintfFormatString.cpp. This routine currently handles types such as ASTContext.IntTy, and I assume I should extend it to handle the respective vector types as well. How would I go about this?

- Should I extend ASTContext to provide builtin types for all OpenCL vector types?
- Should I instead create vector types corresponding to ASTContext.IntTy on the fly?
- How do I create such a vector type? Would I use ExtVectorType for this?
- Can I just create a new type, or do I need to register/delete it?
- Do you have a pointer to another place in Clang where something similar is already done?

Thanks,
-erik

-- 
Erik Schnetter <schnetter at gmail.com>
http://www.perimeterinstitute.ca/personal/eschnetter/

My email is as private as my paper mail. I therefore support encrypting
and signing email messages. Get my PGP key from http://pgp.mit.edu/.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 203 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20131127/27d17199/attachment.sig>


More information about the cfe-dev mailing list