yodamaster / include-what-you-use

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

mappings for libc++ are missing #141

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
IWYU doesn't come with default mappings for libc++ (the llvm stl implementation)

Example:
==> stringtest.cc <==
#include <string>
int main() {
    std::string* p = new std::string();
}

Compling as:
include-what-you-use stringtest.cc -stdlib=libc++ -I$LIBCXX/include

Gives:
stringtest.cc should add these lines:
#include "iosfwd"                       // for string
#include "new"                          // for operator new

To test this libc++ doesn't need to be compiled (nor are any dependencies 
required). LIBCXX needs to be set to the path were the source folder is (or the 
install folder if it is compiled&installed).

Original issue reported on code.google.com by rol...@rschulz.eu on 31 May 2014 at 5:36

GoogleCodeExporter commented 9 years ago
Try with -isystem$LIBCXX/include and see if it makes any difference. IWYU 
chooses quoted includes for -I paths and angled includes for -isystem paths.

I don't see why that should prefer iosfwd over string itself, though, but there 
may be something going on.

Original comment by kim.gras...@gmail.com on 3 Jun 2014 at 8:05

GoogleCodeExporter commented 9 years ago
Actually, it is weirder with libc++.  For instance, in badinc.cc IWYU 
recommends <fstream> for string and in badinc.h - <iosfwd>.  Also IWYU 
recommends <string> for basic_string.  So it's not just a case of quoted and 
angled includes.

By the way, majority of problems with libc++ are caused not by missing 
mappings, but by inline namespace __1.  All STL-specific code expects symbols 
like "std::vector", but in libc++ fully qualified name is "std::__1::vector".  
See issues #132, #133 as examples of such problems.

Original comment by vsap...@gmail.com on 3 Jun 2014 at 10:11