header maps

Hi,

Is there a recommended way to create header maps for clang?
  clang: include/clang/Lex/HeaderMap.h Source File

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

Thanks!

Hi,

Is there a recommended way to create header maps for clang?
clang: include/clang/Lex/HeaderMap.h Source File

Unfortunately no. There aren’t any clang tools that *produce* a header map, and I think Xcode is the only client right now.

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 :slight_smile:

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). 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.

Ben

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 :slight_smile:

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 :slight_smile:

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.

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.

Cheers,
-- Mathieu

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 :slight_smile:

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 :slight_smile:

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

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 :slight_smile:

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 :slight_smile:

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.

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.

Hi Mathieu,

Thanks for the interest, but we’d prefer to focus on the VFS and not change the headermap format.

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.

Thanks for the info.

I think we'd like to avoid changing the header map format as far as possible.

Sure, no problem

Since you're on clang 3.3, would you even benefit from this change?

No indeed.

-- Mathieu