New issue 1067 by pshrey795: fix_includes.py not removing suggested includes
https://github.com/include-what-you-use/include-what-you-use/issues/1067
Using the following source files and their corresponding headers:
**A.h**
`#include <vector>
#include <string>
class A{
public:
int a_one;
int a_two;
A();
void setZero();
};`
**A.cpp**
`#include "A.h"
A::A(){
a_one = 1;
a_two = 2;
}
void A::setZero(){
a_one = 0;
a_two = 0;
}`
**B.h**
`#include "A.h"
using namespace std;
class B{
private:
A* b_one;
int b_two;
vector<int> b_three;
public:
B();
void setZero();
int getMem(){
return b_one->a_one;
}
};`
**B.cpp**
`#include "B.h"
B::B(){
b_two = 2;
b_one = new A();
}
void B::setZero(){
b_two = 0;
b_one->setZero();
}
int main(){
}`
**C.h**
`#include "B.h"
using namespace std;
class C{
private:
B* c_one;
int c_two;
string c_three;
public:
C();
void setZero();
};`
**C.cpp**
`#include "C.h"
C::C(){
c_two = 2;
c_one = new B();
c_three = "hello";
}
void C::setZero(){
c_two = 0;
c_three = "";
c_one->setZero();
}`
I built these source files together and ran iwyu on them using CMake. The corresponding suggestion that I am getting in the file iwyu.out are:
`Warning: include-what-you-use reported diagnostics:
A.h should add these lines:
A.h should remove these lines:
- #include <string> // lines 2-2
- #include <vector> // lines 1-1
The full include-list for A.h:
---
(A.cpp has correct #includes/fwd-decls)
Warning: include-what-you-use reported diagnostics:
B.h should add these lines:
#include <iosfwd> // for std
#include <vector> // for vector
B.h should remove these lines:
The full include-list for B.h:
#include <iosfwd> // for std
#include <vector> // for vector
#include "A.h" // for A
---
(B.cpp has correct #includes/fwd-decls)
Warning: include-what-you-use reported diagnostics:
C.h should add these lines:
#include <iosfwd> // for std
#include <string> // for string
class B;
C.h should remove these lines:
- #include "B.h" // lines 1-1
The full include-list for C.h:
#include <iosfwd> // for std
#include <string> // for string
class B;
---
C.cpp should add these lines:
#include "B.h" // for B
C.cpp should remove these lines:
The full include-list for C.cpp:
#include "C.h"
#include "B.h" // for B
---
`
This is exactly what I expect to be correct. But the python script fix_includes.py is not removing the includes which are suggested above. It only adds the includes which are suggested to be inserted. Please check this. I will greatly appreciate it.