Skip to content

IWYU should not suggest adding two copies of the same header #1087

Open
@ptomato

Description

@ptomato

It can happen, when using e.g. a precompiled header, that IWYU suggests adding the same header in both quotes and angle brackets. This seems undesirable.

Minimal reproducer:

a.cpp:

#include "a.h"
void foo() {}

a.h:

#pragma once
void foo();

b.h: (the "precompiled" header)

#include <a.h>

Output:

$ include-what-you-use -I. -include b.h a.cpp

(a.h has correct #includes/fwd-decls)

a.cpp should add these lines:
#include <a.h>

a.cpp should remove these lines:

The full include-list for a.cpp:
#include <a.h>
#include "a.h"  // for foo
---

I'm guessing it's because b.h includes the header in angle brackets already, so IWYU decides it's a system header, but somehow even though it does realize "a.h" is already included (it says, for foo) it doesn't realize that <a.h> needn't be included to provide foo.

Metadata

Metadata

Assignees

No one assigned

    Labels

    angle-quote-curseMisbehavior caused by IWYU's handling of angled vs. quoted includes

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions