Static Function return variable not parsed correctly.

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

Static Function return variable not parsed correctly.

gladtbx
This post was updated on .
Hello all.

When I am using clang to process a c file, the return type of a static function cannot be recognized.
For example, I have a function:
static int32_t handle_memory_buttons (int32_t key, double* value)

I use

type_ptr = ND->getResultType().getTypePtr()


to get the return value type info.

type_ptr->isBuiltinType()


returns true. But

 

llvm::dyn_cast<BuiltinType>(type_ptr)


returns null and

llvm::cast<BuiltinType>(type_ptr)


give me error like:

current parser token 'static'

My other function:

static double execute_operator (int32_t key, double arg1, double arg2)


does not have this issue, I can get double with the dyn_cast.
I have tried to use

type_ptr = ND->getResultType().getUnqualifiedType().getTypePtr()


but still not getting the right return type.

Can anyone help?
Reply | Threaded
Open this post in threaded view
|

Re: Static Function return variable not parsed correctly.

John McCall

On Feb 4, 2013, at 2:40 PM, gladtbx <[hidden email]> wrote:

> Hello all.
>
> When I am using clang to process a c file, the return type of a static
> function cannot be recognized.
> For example, I have a function:
> static int32_t handle_memory_buttons (int32_t key, double* value)
>
> I use
>
> type_ptr = ND->getResultType().getTypePtr()
>
> to get the return value type info.
>
> type_ptr->isBuiltinType()
>
> returns true. But
>
> llvm::dyn_cast<BuiltinType>(type_ptr)
>
> returns null and

int32_t is not a BuiltinType;  it is a TypedefType whose underlying type
is a BuiltinType.

Clang does provide functions that ignore this first level of type "sugar":
  type->getAs<...>() // analogous to dyn_cast<...>
  type->castAs<...>() // analogous to cast<...>

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