[cfe-dev] Static Function return variable not parsed correctly.
John McCall
rjmccall at apple.com
Mon Feb 4 14:57:57 PST 2013
On Feb 4, 2013, at 2:40 PM, gladtbx <gao2 at illinois.edu> 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.
More information about the cfe-dev
mailing list