Combining floatLiteral() Node Matcher with isExpansionInFileMatching() Narrowing Matcher provides unexpected results

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

Combining floatLiteral() Node Matcher with isExpansionInFileMatching() Narrowing Matcher provides unexpected results

Richard Smith via cfe-dev
Hi,

Combining floatLiteral() Node Matcher with isExpansionInFileMatching() Narrowing Matcher provides unexpected results. 
The following matcher: floatLiteral(isExpansionInFileMatching("include/math.h"))
does not matches "M_E" which is defined in "math.h"

#include <math.h>

int consts(int n){
    double varX = M_E;
    return varX;
}

It matches a single unrelated node:
FloatingLiteral 0x562c409bdaa8 </usr/include/math.h:1184:47> 'float' 0.000000e+00

Am I doing something wrong?
Thanks

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Combining floatLiteral() Node Matcher with isExpansionInFileMatching() Narrowing Matcher provides unexpected results

Richard Smith via cfe-dev
On 09/01/2019 14:15, FarSight Studios via cfe-dev wrote:

> Hi,
>
> Combining floatLiteral() Node Matcher with isExpansionInFileMatching()
> Narrowing Matcher provides unexpected results.
> The following matcher:
> floatLiteral(isExpansionInFileMatching("include/math.h"))
> does not matches "M_E" which is defined in "math.h"
>
> #include <math.h>
>
> int consts(int n){
>      double varX = M_E;
>      return varX;
> }
>
> It matches a single unrelated node:
> FloatingLiteral 0x562c409bdaa8 </usr/include/math.h:1184:47> 'float'
> 0.000000e+00
>
> Am I doing something wrong?


M_E is a macro and that macro is expanded in your

  double varX = M_E;

line. The expansion is not in math.h. The expansion is in the main file.

  http://ec2-18-191-7-3.us-east-2.compute.amazonaws.com:10240/z/qRMj-W

By the way, we have a llvm channel on the cpplang slack
(https://cpplang.slack.com). That is a more suitable venue for your
questions. This is the development mailing list.

Thanks,

Stephen.

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Combining floatLiteral() Node Matcher with isExpansionInFileMatching() Narrowing Matcher provides unexpected results

Richard Smith via cfe-dev
> M_E is a macro and that macro is expanded in your

> double varX = M_E;

> line. The expansion is not in math.h. The expansion is in the main file.

http://ec2-18-191-7-3.us-east-2.compute.amazonaws.com:10240/z/qRMj-W

Thank you so much for the explanation


> By the way, we have a llvm channel on the cpplang slack 
> (https://cpplang.slack.com). That is a more suitable venue for your 
> questions. This is the development mailing list.

I am sorry that I posted the questions in the wrong place. I didn't know that clang has a slack channel.



On Thu, Jan 10, 2019 at 1:01 AM Stephen Kelly via cfe-dev <[hidden email]> wrote:
On 09/01/2019 14:15, FarSight Studios via cfe-dev wrote:
> Hi,
>
> Combining floatLiteral() Node Matcher with isExpansionInFileMatching()
> Narrowing Matcher provides unexpected results.
> The following matcher:
> floatLiteral(isExpansionInFileMatching("include/math.h"))
> does not matches "M_E" which is defined in "math.h"
>
> #include <math.h>
>
> int consts(int n){
>      double varX = M_E;
>      return varX;
> }
>
> It matches a single unrelated node:
> FloatingLiteral 0x562c409bdaa8 </usr/include/math.h:1184:47> 'float'
> 0.000000e+00
>
> Am I doing something wrong?


M_E is a macro and that macro is expanded in your

  double varX = M_E;

line. The expansion is not in math.h. The expansion is in the main file.

  http://ec2-18-191-7-3.us-east-2.compute.amazonaws.com:10240/z/qRMj-W

By the way, we have a llvm channel on the cpplang slack
(https://cpplang.slack.com). That is a more suitable venue for your
questions. This is the development mailing list.

Thanks,

Stephen.

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Combining floatLiteral() Node Matcher with isExpansionInFileMatching() Narrowing Matcher provides unexpected results

Richard Smith via cfe-dev
On Thu, Jan 10, 2019 at 10:07 AM FarSight Studios via cfe-dev
<[hidden email]> wrote:

>
> > M_E is a macro and that macro is expanded in your
> >
> > double varX = M_E;
> >
> > line. The expansion is not in math.h. The expansion is in the main file.
> >
> > http://ec2-18-191-7-3.us-east-2.compute.amazonaws.com:10240/z/qRMj-W
>
> Thank you so much for the explanation
You probably want to take a look at clang's PPCallbacks, they would allow you
to be informed when such macro expansion happens.

> > By the way, we have a llvm channel on the cpplang slack
> > (https://cpplang.slack.com). That is a more suitable venue for your
> > questions. This is the development mailing list.
>
> I am sorry that I posted the questions in the wrong place. I didn't know that clang has a slack channel.
This is the right place.
I'm not sure a slack channel is more official place.
There are also IRC channels (e.g. see #llvm).

Roman.

> On Thu, Jan 10, 2019 at 1:01 AM Stephen Kelly via cfe-dev <[hidden email]> wrote:
>>
>> On 09/01/2019 14:15, FarSight Studios via cfe-dev wrote:
>> > Hi,
>> >
>> > Combining floatLiteral() Node Matcher with isExpansionInFileMatching()
>> > Narrowing Matcher provides unexpected results.
>> > The following matcher:
>> > floatLiteral(isExpansionInFileMatching("include/math.h"))
>> > does not matches "M_E" which is defined in "math.h"
>> >
>> > #include <math.h>
>> >
>> > int consts(int n){
>> >      double varX = M_E;
>> >      return varX;
>> > }
>> >
>> > It matches a single unrelated node:
>> > FloatingLiteral 0x562c409bdaa8 </usr/include/math.h:1184:47> 'float'
>> > 0.000000e+00
>> >
>> > Am I doing something wrong?
>>
>>
>> M_E is a macro and that macro is expanded in your
>>
>>   double varX = M_E;
>>
>> line. The expansion is not in math.h. The expansion is in the main file.
>>
>>   http://ec2-18-191-7-3.us-east-2.compute.amazonaws.com:10240/z/qRMj-W
>>
>> By the way, we have a llvm channel on the cpplang slack
>> (https://cpplang.slack.com). That is a more suitable venue for your
>> questions. This is the development mailing list.
>>
>> Thanks,
>>
>> Stephen.
>>
>> _______________________________________________
>> cfe-dev mailing list
>> [hidden email]
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>
> _______________________________________________
> cfe-dev mailing list
> [hidden email]
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Combining floatLiteral() Node Matcher with isExpansionInFileMatching() Narrowing Matcher provides unexpected results

Richard Smith via cfe-dev
> You probably want to take a look at clang's PPCallbacks, they would allow you
> to be informed when such macro expansion happens.
Great, I will check PPCallbacks.

> This is the right place.
> I'm not sure a slack channel is more official place.
> There are also IRC channels (e.g. see #llvm).
Any additional resource is always welcome. Thank you

On Thu, Jan 10, 2019 at 7:25 PM Roman Lebedev <[hidden email]> wrote:
On Thu, Jan 10, 2019 at 10:07 AM FarSight Studios via cfe-dev
<[hidden email]> wrote:
>
> > M_E is a macro and that macro is expanded in your
> >
> > double varX = M_E;
> >
> > line. The expansion is not in math.h. The expansion is in the main file.
> >
> > http://ec2-18-191-7-3.us-east-2.compute.amazonaws.com:10240/z/qRMj-W
>
> Thank you so much for the explanation
You probably want to take a look at clang's PPCallbacks, they would allow you
to be informed when such macro expansion happens.

> > By the way, we have a llvm channel on the cpplang slack
> > (https://cpplang.slack.com). That is a more suitable venue for your
> > questions. This is the development mailing list.
>
> I am sorry that I posted the questions in the wrong place. I didn't know that clang has a slack channel.
This is the right place.
I'm not sure a slack channel is more official place.
There are also IRC channels (e.g. see #llvm).

Roman.

> On Thu, Jan 10, 2019 at 1:01 AM Stephen Kelly via cfe-dev <[hidden email]> wrote:
>>
>> On 09/01/2019 14:15, FarSight Studios via cfe-dev wrote:
>> > Hi,
>> >
>> > Combining floatLiteral() Node Matcher with isExpansionInFileMatching()
>> > Narrowing Matcher provides unexpected results.
>> > The following matcher:
>> > floatLiteral(isExpansionInFileMatching("include/math.h"))
>> > does not matches "M_E" which is defined in "math.h"
>> >
>> > #include <math.h>
>> >
>> > int consts(int n){
>> >      double varX = M_E;
>> >      return varX;
>> > }
>> >
>> > It matches a single unrelated node:
>> > FloatingLiteral 0x562c409bdaa8 </usr/include/math.h:1184:47> 'float'
>> > 0.000000e+00
>> >
>> > Am I doing something wrong?
>>
>>
>> M_E is a macro and that macro is expanded in your
>>
>>   double varX = M_E;
>>
>> line. The expansion is not in math.h. The expansion is in the main file.
>>
>>   http://ec2-18-191-7-3.us-east-2.compute.amazonaws.com:10240/z/qRMj-W
>>
>> By the way, we have a llvm channel on the cpplang slack
>> (https://cpplang.slack.com). That is a more suitable venue for your
>> questions. This is the development mailing list.
>>
>> Thanks,
>>
>> Stephen.
>>
>> _______________________________________________
>> cfe-dev mailing list
>> [hidden email]
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>
> _______________________________________________
> cfe-dev mailing list
> [hidden email]
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev