[cfe-dev] JSONCompilationDatabase additional keys
Tobias Grosser
tobias at grosser.es
Wed Sep 11 06:50:56 PDT 2013
On 09/11/2013 02:14 PM, Manuel Klimek wrote:
> On Wed, Sep 11, 2013 at 12:41 PM, Nicholas Gill <mythagel at gmail.com> wrote:
>
>> Hello cfe-dev,
>>
>> At present unknown keys in the compile_commands.json file will cause the
>> JSONCompilationDatabase parser to reject the file.
>>
>> 1. Would a patch to relax this constraint be accepted?
>> 2. Would other consumers of the compile_commands.json be negatively
>> impacted by unknown keys?
>>
>
> Yes. This can be rather big, and being able to quickly parse it is
> important for interactive use cases.
>
>
>> The motivating example (somewhat contrived) involves a single TU built
>> with a different environment in two different targets
>>
>> int main()
>> {
>> TYPE i = -1;
>> return i < 0;
>> }
>>
>> cc -DTYPE=int source.c -o bin1
>> cc -DTYPE=uint16_t source.c -o bin2
>>
>> So for my use case I'd like to add a (purely optional) target name to the
>> compilation database (generated via cmake) - in order to be able to provide
>> more accurate diagnostics to the user.
>>
>
> I'd say that if we really want something more elaborate, we should try to
> design it first instead of randomly allowing to add fields in ways that
> might later break.
>
> I'd be curious about other opinions though. (+Edwin, Daniel)
I am personally very much in favor of removing this restriction and in
fact I proposed it before. This does not mean I propose any extensions
today. I agree with Manuel that we should carefully design what we add.
Nevertheless, the more released clang versions we have that just abort
on additional keywords, the harder it will be to add backward compatible
extensions later on.
Cheers,
Tobias
More information about the cfe-dev
mailing list