felipeprov / include-what-you-use

Automatically exported from code.google.com/p/include-what-you-use
Other
0 stars 0 forks source link

iwyu suggests too much to add: shared_ptr #138

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
For the following example it suggests <memory> even though it is only used 
through the typedef.

//sharedptr_test.cc
#include "myptr.h"
int main() {
    myptr p;
    *p; //no error without this line
}
//myptr.h
#include <memory>
typedef std::shared_ptr<char> myptr;

The problem seems to be with the return type of "*p". Even though it simply 
evaluates to "char" the template expression seems to be confusing IWYU. The 
problem is with 3.4.1 and HEAD and with libstdc++ and libc++.

Originally added as further example to #111 but moved to new issue because it 
isn't the same problem

Related to #135.

Original issue reported on code.google.com by rol...@rschulz.eu on 30 May 2014 at 2:58

GoogleCodeExporter commented 8 years ago
I can reproduce this with MSVC, and I agree with your conclusion that the 
problem is in the traits-y return type. Both std::shared_ptr and 
boost::shared_ptr have a traits expression as their return type.

I haven't really understood where this is analyzed in IWYU yet. I'll try to 
come back to this.

Original comment by kim.gras...@gmail.com on 8 Feb 2015 at 9:02