[cfe-dev] Adding new Diagnostics to Clang ?

Charles Davis cdavis at mymail.mines.edu
Sun Mar 7 14:20:47 PST 2010


Hello again, Kalyan,

On 3/7/10 2:36 PM, kalyan ponnala wrote:
> Hi,
> 
> Can someone please tell me what the purpose of the following files:
> 
>     * "*.inc"
These are the files generated from the *.td files. They're regenerated
on every build, and included just like *.h files. Since they're
regenerated, you shouldn't modify them. Your changes will be lost!
>     * "*.def"
These files--at least in the LLVM and Clang projects--have nothing to do
with Windows' DLLs, just so you know.

These are files that use macros in a massive list of something. In
typical usage, a file will define the macros the *.def files use, then
#include the file.

For example, we have include/clang/AST/TypeNodes.def, which is a list of
all the type nodes supported by the AST library. This file is included
by include/clang/AST/Type.h when it's defining the type kind
enumerators. And this is just one of the many uses of that file!
>     * "*.td"
These are TableGen sources. They're processed by the TableGen tool
(tblgen.exe on Windows). Their purpose depends on context. In the
context of diagnostics, they contain the definitions of the various
diagnostics. (Note that TableGen has to be specially taught to
understand a particular class of *.td files.)
> I am trying to dig into the Diagnostics inside Clang. I found out that
> DiagnosticKinds.def file is used to add an entry for some Diagnostics.
Not anymore. That file doesn't exist now. Instead, we have the
Diagnostic*Kinds.td files. Those are the files you want to modify.
> 
> I could not find the file's location in the Clang / LLVM
> distribution. Additionally, the "DiagnosticKinds.def" file that is
> linked from the Clang "InternalsManual.html" is broken.
Because that file does not exist anymore. That documentation is
seriously out of date, and someone needs to update it.
> 
> Can anyone please tell me where to find this file or is there a new
> approach to adding an entry for a new Diagnostics?
Again, the Diagnostic*Kinds.td files are the ones you want to modify.
The exact one you want to modify depends on which library is going to
use it. For example, if you're adding a diagnostic to be used by the
Sema library, add your new diagnostic to DiagnosticSemaKinds.td.

If you're adding a warning, and your warning belongs to a group that
doesn't exist yet, you'll also have to modify DiagnosticGroups.td to
include your new group.
> 
> thanks, 
You're welcome.

Chip



More information about the cfe-dev mailing list