libclang: CXUnsavedFile::length should use a fixed-width type
Open
clang:as-a-library
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
`CXUnsavedFile` in `clang-c/Index.h` declares `unsigned long Length`.
```C
struct CXUnsavedFile {
const char *Filename;
const char *Contents;
unsigned long Length;
};
```
This varies across ABIs (eg. on big endian architectures), which can cause crashes or incorrect lengths.
Here is an example of a [downstream](https://bugs.openjdk.org/browse/CODETOOLS-7904079) Bug.
The fix will likely require updating the struct to use `uint64_t Length` and adjust internal uses.
The change would intentionally alter libclang's C API layout.
Contributor guide
Assessment
This issue has not been assessed yet.