[PATCH] D139774: [libclang] Add API to set temporary directory location
Igor Kushnir via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Feb 1 07:25:31 PST 2023
vedgy added a comment.
In D139774#4096527 <https://reviews.llvm.org/D139774#4096527>, @aaron.ballman wrote:
> That sounds like a good plan to me. I wonder if we want to name it something like `clang_createIndexWithOptions` (or something generic like that), and give it a versioned structure of options along the lines of:
>
> struct CIndexOptions {
> uint32_t Size; // sizeof(struct CIndexOptions), used for option versioning
> const char *PreambleStoragePath; // This pointer can be freed after creating the index
> };
>
> and define the function to return an error if `Size < sizeof(struct CIndexOptions)`. This should allow us to add additional options to the structure without having to introduce a new constructor API each time.
Would this be the recommended usage of such an API?
1. Call `clang_createIndexWithOptions`.
2. If it returns `nullptr` index, report an error in the application (e.g. print a warning or show an error in the UI) and fall back to code paths that support older Clang versions, beginning with calling the older constructor `clang_createIndex`.
Is assigning `sizeof(CIndexOptions)` to `Size` the API user's responsibility or should libclang define an inline function `clang_initializeCIndexOptions`?
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D139774/new/
https://reviews.llvm.org/D139774
More information about the cfe-commits
mailing list