[cfe-dev] header maps

Ben Langmuir blangmuir at apple.com
Wed Mar 5 14:24:25 PST 2014


On Mar 5, 2014, at 1:29 PM, Mathieu Baudet <mathieu.baudet at gmail.com> wrote:

> Hi Ben,
> 
>> Unfortunately no.  There aren't any clang tools that *produce* a header map, and I think Xcode is the only client right now.
> I was suspecting this but felt like asking anyway :)
> 
>> However, depending on what you're trying to do, you might be better off looking at the new virtual file system code that we've been adding to clang. Like header maps, the VFS will allow you to map a virtual path to a file in a different location.  It is also much easier to produce the VFS files, as there is libclang API for producing them in include/clang-c/BuildSystem.h.  Right now the best way to learn how to use the VFS is probably to look at the tests in clang/test/VFS and the libclang API code, and I'd be happy to answer any questions about it :)
> 
> Thanks, this looks very interesting! I don't think I'm going to take a
> dependence to libclang for now in my project (besides I have to
> compile with clang 3.3), but I will definitely keep an eye on this
> cool API.

This is probably moot if you’re using clang 3.3, but you can avoid the libclang dependency if you want to produce the file yourself.  There is a simple JSON-based format that you can use - we’re currently using it to test the feature.

> 
>>> How difficult/acceptable would it be to make the lookup
>>> case-sensitive? (at least for non mac users)
>>> http://clang.llvm.org/doxygen/HeaderMap_8cpp_source.html#l00229
>> 
>> The VFS supports selecting between case-sensitive and case-insensitive (this hasn't been exposed in the libclang API yet, but it would be easy to do).
> nice!
> 
>> That said, If you really want to hack it in to header maps, it wouldn't be hard - there are two places in HeaderMap.cpp that drop to lower case before doing the comparison that you would need to change.
> 
> If you allow me to use 1 bit of the "Reserved" field (and maybe
> increment the version?), I could make a patch for you -- only I would
> not know what unit-test to write. I guess that not very critical
> anyway since HeaderMap creators can detect collisions and cleanly fail
> when this happens.
> 

I think we’d like to avoid changing the header map format as far as possible.  Since you’re on clang 3.3, would you even benefit from this change?

Ben

> Cheers,
> -- Mathieu





More information about the cfe-dev mailing list