pombreda / include-what-you-use

Automatically exported from code.google.com/p/include-what-you-use
Other
0 stars 1 forks source link

Add support for regex for destination in mapping #145

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
The mapping syntax supports a regex expression for the first entry of the 
mapping. It would be nice if this could be extended to also be supported for 
the 3rd entry(=2nd include). This would be useful if the same include is 
provided by a lot of other include files.

Original issue reported on code.google.com by rol...@rschulz.eu on 5 Jun 2014 at 5:03

GoogleCodeExporter commented 9 years ago
I don't understand how this would be useful, can you give a concrete example?

Original comment by kim.gras...@gmail.com on 6 Jun 2014 at 7:16

GoogleCodeExporter commented 9 years ago
We have a few basic include files, which are included by most other include 
files. We feel, like there is no real benefit of including those by all source 
headers. I wanted to add a public->public mapping from all our headers to these 
few, so that IWYU doesn't suggest these headers to be added.

Original comment by rol...@rschulz.eu on 8 Jun 2014 at 3:37

GoogleCodeExporter commented 9 years ago
Looks like you are including something you don't use.  Personally, I am 
reluctant to add to IWYU features, which make it easier to violate 
include-what-you-use rule.

Sorry for being so annoying and stubborn, but I am afraid we'll add the 
requested feature only if it conforms to include-what-you-use rule or 
represents some wide-spread practice.  Maybe I've misunderstood you, and you 
don't violate include-what-you-use rule.  Sorry for any misunderstanding and 
correct me, please, if I'm wrong.

Original comment by vsap...@gmail.com on 13 Jun 2014 at 2:12

GoogleCodeExporter commented 9 years ago
Roland,

Regardless of whether your suggestion violates include-what-you-use policy, I'm 
still not 100% sure I understand your use case. Let me suggest what I think you 
mean, and we can discuss based on that:

It sounds like instead of having the regex match any number of private files, 
and map them to a public file, you want to do regex substitution from N private 
files to N public files. Is that right?

As a concrete example:

  { "@private/(.*)\.private\.h", public, "@public/\1\.h", public }

This would map all files matching private/<name>.private.h to public/<name>.h.

It seems like a more efficient way to express mappings if they follow a common 
pattern, even if I can't think of a better example right now.

I think it should be possible and relatively easy to implement this 
(iwyu_include_picker:IncludePicker::ExpandRegexes), but I'd like to hold off 
until I understand your specific use case.

Original comment by kim.gras...@gmail.com on 22 Jun 2014 at 1:45

GoogleCodeExporter commented 9 years ago
Sorry for the late reply - was too busy with other things.

You are right that I would like this to violate include-what-you-use policy. I 
suggested to use IWYU with our software project. One criticism (the discussion 
thread is at https://gerrit.gromacs.org/#/c/3532) was that it adds some 
includes which don't seem to add any value. We see the value in IWYU policy in 
1) removing includes don't cause unrelated compile errors and 2) it shows 
dependencies. We have a couple of include files which are required by almost 
all source and header files. For those there is no value in including them in 
source files because 1) if we remove one header the dependency is still there 
from the other headers and 2) the dependency is known anyhow. Thus we think 
adding those headers just adds clutter.

In other words the use case it to tell IWYU that certain headers are provided 
by all other headers so that IWYU just ignores the IWYU policy for those few 
headers. An alternative to the regex would be that one can list headers which 
should be ignored in general (either by listing them in the imp file or with a 
pragma in that header).

Original comment by rol...@rschulz.eu on 5 Jul 2014 at 5:54