Issue 1144 in include-what-you-use: More ".." in include path than folders in additional include dir (which is not absolute)

0 views
Skip to first unread message

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

unread,
Nov 21, 2022, 7:25:19 PM11/21/22
to include-wh...@googlegroups.com
New issue 1144 by honkstar1: More ".." in include path than folders in additional include dir (which is not absolute)
https://github.com/include-what-you-use/include-what-you-use/issues/1144

I've run into a problem where our response file contains relative paths and an include is looking like this "../../Foo.h"

When LLVM returns the string from clang::FileEntry::getName() it returns a combined relative include dir and include.

So in my case I have a relative include path "MyFolder"

The returned path from LLVM is "MyFolder/../../Foo.h"

This is then sent in to NormalizeFilePath (inside iwyu_path_util.cc) which tries to normalize this using llvm::sys::path::remove_dots.

The result ends up being wrong since there are more ".." than there are folders to remove.

I now bit the bullet and updated all the 34000 response files in our solution to all have absolute paths which solved my situation (they are generated so I didn't manually go through those files :-)). I wanted to report this since it was not obvious what went wrong (it silently failed and output got wrong)..

Thanks,
Henrik



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

unread,
Nov 23, 2022, 2:11:02 PM11/23/22
to include-wh...@googlegroups.com
Comment #1 on issue 1144 by kimgr: More ".." in include path than folders in additional include dir (which is not absolute)
https://github.com/include-what-you-use/include-what-you-use/issues/1144

Hmm, interesting problem. So it's two-part relative?

- `-I MyFolder` is relative to current sourcefile, say `root/abc/xyz.cc`, so resolves to `root/abc/MyFolder`
- `#include "../../Foo.h"` is relative to `./MyFolder`, and eventually resolves to `root/Foo.h`

It's one of those things where maybe it's worth considering not doing that :-)


Reply all
Reply to author
Forward
0 new messages