[prev in list] [next in list] [prev in thread] [next in thread] 

List:       cfe-dev
Subject:    Re: [cfe-dev] How to get the type clang::Expr evaluates to?
From:       Alexander Droste via cfe-dev <cfe-dev () lists ! llvm ! org>
Date:       2015-08-26 21:47:24
Message-ID: 55DE33EC.1010003 () googlemail ! com
[Download RAW message or body]

Works, thanks a lot for pointing this out!

On 26.08.15 23:41, Gábor Horváth wrote:
> You can strip the casts (Expr::IgnoreCasts, but there are many similar
> functions, you should check them which one fits your need the best), and
> get the type of the stripped expression.
>
> On 26 August 2015 at 14:33, Alexander Droste via cfe-dev <
> cfe-dev@lists.llvm.org> wrote:
>
>> Thanks for your reply!
>>
>> clang::Expr::getType() seems to return
>> the arg type it is casted to (if possible)
>> when passed to function and not the original arg type.
>>
>> If I have a function like func(int)
>> and I pass a float func(1.1)
>> callExpr()->getArg(1)->getType()->dump()
>> gives me: BuiltinType 0x7f833183b1b0 'int'
>>
>> -Alex
>>
>> On 26.08.15 22:58, Aaron Ballman wrote:
>>
>>> On Wed, Aug 26, 2015 at 4:56 PM, Alexander Droste via cfe-dev
>>> <cfe-dev@lists.llvm.org> wrote:
>>>
>>>> Hi everyone,
>>>>
>>>> is it possible to get the type of a clang::Expr instance
>>>> the expression evaluates to?
>>>>
>>>
>>> You should be able to use clang::Expr::getType().
>>>
>>> ~Aaron
>>>
>>> I would like to use this, to find out
>>>> what kind of types arguments passed to a clang::CallExpr have.
>>>>
>>>> Sth. like this:
>>>>
>>>> int n;
>>>> function(&n);
>>>> ..
>>>> // getArg() returns Expr
>>>> callExpr()->getArg(idx)--->getTypeExprEvaluatesTo(); // -> *int
>>>>
>>>> or with multiple operands:
>>>> int n;
>>>> function(1 + n);
>>>> ..
>>>> callExpr()->getArg(idx)--->getTypeExprEvaluatesTo(); // -> int
>>>>
>>>> -Alex
>>>> _______________________________________________
>>>> cfe-dev mailing list
>>>> cfe-dev@lists.llvm.org
>>>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>>>>
>>> _______________________________________________
>> cfe-dev mailing list
>> cfe-dev@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>>
>
_______________________________________________
cfe-dev mailing list
cfe-dev@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic