inline directive apparently ignored

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

inline directive apparently ignored

Vinay Sajip
Given the source

static __inline__ int F1(float x, double y);
static __attribute__((__always_inline__)) int F2(float x, double y);

The AST produced via libclang is

F1 FunctionDecl FunctionProto
x ParmDecl Float
y ParmDecl Double
F2 FunctionDecl FunctionProto
        UnexposedAttr 9  <-- the value of the AlwaysInline attribute
x ParmDecl Float
y ParmDecl Double

Is there anything special one has to do to get clang to return the __inline__
attribute?

Thanks,

Vinay Sajip

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: inline directive apparently ignored

Ruben Van Boxem
2011/9/24 Vinay Sajip <[hidden email]>
Given the source

static __inline__ int F1(float x, double y);
static __attribute__((__always_inline__)) int F2(float x, double y);

The AST produced via libclang is

F1      FunctionDecl    FunctionProto
x       ParmDecl        Float
y       ParmDecl        Double
F2      FunctionDecl    FunctionProto
       UnexposedAttr   9  <-- the value of the AlwaysInline attribute
x       ParmDecl        Float
y       ParmDecl        Double

Is there anything special one has to do to get clang to return the __inline__
attribute?

Thanks,

Vinay Sajip 

I came across a similar observation in libc++ when this attribute is used for a vararg function: GCC produces an error, Clang was silent.

If Clang ignores this attribute, it should at least say so with a warning. This can be a general: Warning: ignored unknown attribute attribute.

Ruben
 

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev


_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: inline directive apparently ignored

Vinay Sajip
Ruben Van Boxem <vanboxem.ruben@...> writes:

> I came across a similar observation in libc++ when this attribute is used for
a vararg function: GCC produces an error, Clang was silent.If Clang ignores this
attribute, it should at least say so with a warning. This can be a general:
Warning: ignored unknown attribute attribute.Ruben 

Looking into it further, I see it isn't ignored - just not exposed via libclang.
Neither, AFAICT, is the storage class for declarations :-(

Regards,

Vinay Sajip

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: inline directive apparently ignored

David Chisnall
On 25 Sep 2011, at 09:42, Vinay Sajip wrote:

> Neither, AFAICT, is the storage class for declarations :-(

This is on my to-do list to fix.  I recently had to write a little tool using libclang that checked that a set of functions didn't reference any statics or globals.  Globals are easy, because their linkage class is exposed.  Unfortunately, both static locals and variables with automatic storage have no linkage type.  The only way I found of detecting the statics was to go back to the declaration and check if any of the keyword tokens was 'static'.  This was an ugly hack to make it work - I hope to get around to exposing sane APIs in libclang for doing it properly before 3.0.

David

-- Sent from my STANTEC-ZEBRA


_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev