llvm / llvm/llvm-project

libclang: CXUnsavedFile::length should use a fixed-width type

Open
#160,729 1 comment 0 reactions 0 assignees View on GitHub
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.