[cfe-dev] How to change calling convention.

Eli Friedman eli.friedman at gmail.com
Wed Jul 27 09:47:19 PDT 2011


On Wed, Jul 27, 2011 at 9:09 AM, Anderson, Todd A
<todd.a.anderson at intel.com> wrote:
> I tried creating a copy of the type using the copy constructor of FunctionType but that just gave me a bunch of compile errors about the Type constructor being private.

There are methods to build new types on ASTContext.

> Then I wanted to change the calling convention of that copied type and call setType.  I'm currently trying to construct a new FunctionType using get methods on the previous type to fill in the parts that remain constant.  The problem at the moment is that isVariadic() seems to be private but I presume that function types cannot be Variadic so I'll just pass false there and then try setType.

There are two kinds of FunctionType: FunctionProtoType and
FunctionNoProtoType.  They need to be handled slightly differently.

> What I'm trying to do is add pragmas that control the default calling convention.  If there is a way to do this all within the Lexer rather than changing it afterwards I'm all ears.

There are some existing pragmas that are a bit similar; look in
lib/Parse/ParsePragma.cpp.

-Eli




More information about the cfe-dev mailing list