Issue 935 in include-what-you-use: Resolution of regexp rules conflicting

0 views
Skip to first unread message

notifi...@include-what-you-use.org

unread,
Jul 15, 2021, 1:44:50 AMJul 15
to include-wh...@googlegroups.com
New issue 935 by zimin2000: Resolution of regexp rules conflicting
https://github.com/include-what-you-use/include-what-you-use/issues/935

I am using iwyu in a large codebase. We are using default mappings along with our custom mappings. One of the custom rule that we are using is hiding implementation in `-inl.h` header by exposing it `.h` counterpart:
```
{ include: ["@\"(.*)-inl.h\"", private, "@\"\\1.h\"", public ] },
```

That works fine, but for the case when both header files are in the `/internal/` folder:

```
xxx/internal/Header.h
xxx/internal/Header-inl.h
```

In this case, AFAIU, the above rule conflicts with the default treatment of the `/internal/` folder. Namely, according to a default rule files in `/internal/` assumed private, so `xxx/internal/Header.h` is declared private. However, on the other hand, the rule for `xxx/internal/Header-inl.h` declares `xxx/internal/Header.h` public.

This conflict leads to the following error:

```
xxx/iwyu_include_picker.cc:1064: Assertion failed: filepath_visibility_map_[quoted_filepath_pattern] == visibility Same file seen with two different visibilities: "xxx/internal/Header.h" Old vis: 2 New vis: 1
```

Is there a way to resolve this issue keeping both the default rules and using a regex rule for `-inl.h`?
What is the best way to resolve the issue ?

PS: I was trying to resolve the issue by updating the `-inl.h` rule and excluding the paths that has `/internal/` in the path, like the following:

```
{ include: ["@\"((?!.*/internal/).*)-inl.h\"", private, "@\"\\1.h\"", public ] },
```

But it turned out that `llvm::Regex` does not support this syntax.

notifi...@include-what-you-use.org

unread,
Jul 19, 2021, 5:15:21 PMJul 19
to include-wh...@googlegroups.com
Comment #1 on issue 935 by kimgr: Resolution of regexp rules conflicting
https://github.com/include-what-you-use/include-what-you-use/issues/935

The `internal/` special casing is a Google-ism and could be removed. I can try and work up a patch unless you beat me to it.

notifi...@include-what-you-use.org

unread,
Jul 19, 2021, 5:35:37 PMJul 19
to include-wh...@googlegroups.com
Comment #2 on issue 935 by zimin2000: Resolution of regexp rules conflicting
https://github.com/include-what-you-use/include-what-you-use/issues/935

Unfortunately, we are also following the same `internal/` approach and would like to keep it.
So, the issue is not that in either of the rules, the issue is that the rules happen to overlap and the we would like to be able to resolve this overlap somehow.

Reply all
Reply to author
Forward
0 new messages