[cfe-dev] How to assign a Custom Diagnostic IDs in Clang Tool

Don Hinton via cfe-dev cfe-dev at lists.llvm.org
Thu Feb 1 13:58:25 PST 2018


Btw, you still need to call DiagnosticEngine::getCustomDiagID(), but you
can use your new enum to access the new id.


On Thu, Feb 1, 2018 at 1:52 PM, Don Hinton <hintonda at gmail.com> wrote:

> Are you trying to put the actual numerical value in the documentation?
> That won't work since it's based on the enum value that gets computed at
> compile time -- actually via tablegen -- and changes over time as
> diagnostics are added/removed.
>
> Tooling may already do this, but if not, just create your own enum that
> starts at the first available value, clang::diag::DIAG_UPPER_LIMIT, and go
> from there.  Then you can publish and use those enum values, e.g.,
> MyTool::Some_Diag.  Take a look at how new id numbers are generated and use
> the same technique, e.g.:
>
>   https://clang.llvm.org/doxygen/DiagnosticIDs_8cpp_source.html#l00291).
>
> If you need a string you can pass on the command line, you can create your
> own mapping.
>
> hth...
> don
>
>
> On Thu, Feb 1, 2018 at 1:12 PM, Roman Popov via cfe-dev <
> cfe-dev at lists.llvm.org> wrote:
>
>> Looks like DiagnosticEngine does not allow to be instantiated with
>> User-supplied IDs.
>> The problem is that DiagnosticIDs is not an interface to IDs database,
>> but rather a final class not designed for inheritance.
>>
>> So I don't find a way how Clang diagnostic library can be reused by 3rd
>> party tool.
>>
>> 2018-02-01 12:10 GMT-08:00 Roman Popov <ripopov at gmail.com>:
>>
>>> Hello,
>>> I want to create a fixed sets of IDs for error messages in Clang tool.
>>> So I can put them into tool documentation.
>>>
>>> Is it possible to somehow assign a fixed ID for diagnostic?
>>> DiagnosticEngine::getCustomDiagID() generates ID automatically, so I
>>> have no control on IDs.
>>>
>>> Should I probably instantiate my own DiagnosticEngine instead of using
>>> one from AstContext ?
>>>
>>> Thanks,
>>> Roman
>>>
>>
>>
>> _______________________________________________
>> cfe-dev mailing list
>> cfe-dev at lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20180201/71ddaae2/attachment.html>


More information about the cfe-dev mailing list