Skip to content

template specialization in header is mishandled #801

@shivanshu3

Description

@shivanshu3

Given the following input, IWYU produces an incorrect output:

main.cpp:

struct Foo
{
	static constexpr int num = 10;
};

#include "NumGetter.h"

#include "IntegerWrapperFoo.h"

int dummy()
{
	NumGetter<Foo> x;
	return x.GetNum();
}

NumGetter.h:

template<typename T>
struct IntegerWrapper
{};

template<typename T>
struct NumGetter
{
	int GetNum()
	{
		return IntegerWrapper<T>::num;
	}
};

IntegerWrapperFoo.h:

template<>
struct IntegerWrapper<Foo>
{
	static constexpr int num = Foo::num;
};

IWYU output:

>include-what-you-use.exe main.cpp

main.cpp should add these lines:

main.cpp should remove these lines:
- #include "IntegerWrapperFoo.h"  // lines 8-8

The full include-list for main.cpp:
#include "NumGetter.h"  // for NumGetter
---

I am on the master branch of IWYU at commit b4838853e5c906854a616d9e975b53c164950174 from May 24 2020.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions