Bug#828734: [iwyu] 3.8 recommends includes for things not used in file

Franz Schrober franzschrober at yahoo.de
Mon Jun 27 10:52:04 UTC 2016


Package: iwyu
Version: 3.8-1
Severity: important


It was noticed that the upgrade from 3.7 to 3.8 introduced a regression. iwyu
is now recommending includes for things which are nowhere used in a file.

First problem was that this version is not depending on libclang-common-3.8-dev
and thus didn't find some of the headers (see #722132). But it turns out that
this is not the only problems 

E.g it wants me to now include

#include <linux/compiler.h> // for __u, __read_once_size, __read_o...
#include "linux/swab.h" // for __fswab16

But these things are nowhere used in the file. The only appearances are inside
included headers.


I've tried to create a preprocessed file but it seems that iwyu doesn't report
any problems anymore when the file is already preprocessed. But I've created a
small example which shows the problem and how it related to macros. The test.c
file just uses the functionality from memops.h (this is the abstraction layer)
+ stdio.h. memops.h itself is using compiler.h. No functionality from
compiler.h is used directly in test.c


Compile with macros in memops.h:


    $ iwyu test.c -o test.o
    test.c should add these lines:
    #include "compiler.h"
    
    test.c should remove these lines:
    
    The full include-list for test.c:
    #include <stdio.h> // for printf
    #include "compiler.h"
    #include "memops.h" // for get_memory_pointer_once

And now with the same functionality but implemented as static inline function:

    $ iwyu -DIWYU_INLINE_FUNCTION_TEST test.c -o test.o
    (test.c has correct #includes/fwd-decls)

So my guess is that the handling of macros is currently broken in iwyu/clang.


Marking it as important because it has major effects on the usability of the
package. I would even go so far that it makes it unusable for many projects.

--- System information. ---
Architecture: amd64
Kernel:       Linux 4.5.0-2-amd64

Debian Release: stretch/sid
500 unstable        httpredir.debian.org 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: iwyu_braindead.tar.xz
Type: application/x-xz
Size: 804 bytes
Desc: not available
URL: <http://lists.alioth.debian.org/pipermail/pkg-llvm-team/attachments/20160627/7f31b74c/attachment.bin>


More information about the Pkg-llvm-team mailing list