Bug 537344 - Troubles with "Name convention for function" and stream operators
Summary: Troubles with "Name convention for function" and stream operators
Status: REOPENED
Alias: None
Product: CDT
Classification: Tools
Component: cdt-codan (show other bugs)
Version: 10.4.0   Edit
Hardware: PC Windows 10
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: CDT Codan Inbox CLA
QA Contact: Elena Laskavaia CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-07-24 11:51 EDT by Harry Houdini CLA
Modified: 2021-08-16 09:01 EDT (History)
2 users (show)

See Also:


Attachments
Settings dialogs (77.07 KB, image/png)
2018-07-24 11:51 EDT, Harry Houdini CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Harry Houdini CLA 2018-07-24 11:51:07 EDT
Created attachment 275110 [details]
Settings dialogs

Hello,

In C/C++ General/Code Analysis, then Coding Style/ Name convention for function,
I customized the settings, as shown in the joined screen grab.
I added some exceptions to my rule, but for stream operators (operator<< and operator>>), these exceptions are ignored.
Comment 1 Harry Houdini CLA 2018-07-24 11:52:03 EDT
Note you can see the offening code in the lower left corner of the screen grab.
Comment 2 Nathan Ridge CLA 2018-07-24 22:35:28 EDT
Does it work if in the exception list, you add a space after "operator", as in "operator <<"?
Comment 3 Harry Houdini CLA 2018-09-06 11:38:54 EDT
It does work !!!

Thanks !
Comment 4 Harry Houdini CLA 2018-09-06 11:39:36 EDT
Well, I reopen it the issue.

The user should have to know this trick...
Comment 5 Nathan Ridge CLA 2018-09-06 17:30:45 EDT
The reason this happens is that in CDT's internal representation of the code (the index), operator names are normalized to have a space between the "operator" token and the operator symbol.

This is a formatting style used in some codebases, so we can't just change the normalized form to have no space, because then we'd just run into the opposite problem.

Rather, the Code Analysis component should take what the user inputs, and perform the normalization on it (that is, add the space if it's not present) so it matches the form stored in the index.

Harry, would you be interested in contributing a patch that does this? I'm happy to point you to the relevant code.
Comment 6 Nathan Ridge CLA 2018-09-06 17:31:47 EDT
(I fixed a similar problem with Search and Open Element a few years ago, in bug 408870.)
Comment 7 Harry Houdini CLA 2018-09-07 05:39:53 EDT
No problems with the code, but I hope I won't have troubles with the Eclipse process for contribution... I use it once to patch docs, ant it was SO heavy. :)
Comment 8 Nathan Ridge CLA 2018-09-07 10:01:14 EDT
Documentation on setting up your environment and contributing can be found here:

https://wiki.eclipse.org/Getting_started_with_CDT_development
Comment 9 Nathan Ridge CLA 2018-09-07 10:03:15 EDT
Codewise I believe you want to look at NamingConventionFunctionChecker.isFilteredArg().
Comment 10 Harry Houdini CLA 2021-08-16 09:01:59 EDT
I use now CDT 10.4.0.

I doesn't have anymore the problem with the stream operators (it may have disappeared before 10.4.0).

But I get error with any function which doesnt start with a capital letter, even if in Preferences > C/C++ > Code Analysis, "Name convention for function" is disabled (an even if it would be enabled, the severity should be Info, and not Error).