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
2011/9/24 Vinay Sajip <vinay_sajip@yahoo.co.uk>
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
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
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