[cfe-commits] Documenting Diagnostics [part 1]

Matthieu Monrocq matthieu.monrocq at gmail.com
Sat Mar 26 11:52:41 PDT 2011


Hello,

These two patches enrich the actual diagnostic by adding 3 fields:
- name
- brief description
- full description

This is a first step in providing self-documenting user-friendly
diagnostics, where the user can get help (both immediately and on-line)
about the meaning of a particular diagnostic.

The brief and full description are for now unused, this will come in future
patches.


The interface changes can be summed up by:

+ 2 new driver flags:

-fdiagnostics-show-name  (activated by default)
-fno-diagnostics-show-name

+ 4 new static functions in  DiagnosticIDs

const char *DiagnosticIDs::getName(unsigned DiagID)
unsigned DiagnosticIDs::getIdFromName(char const *Name)

const char *DiagnosticIDs::getBriefExplanation(unsigned DiagID)
const char *DiagnosticIDs::getFullExplanation(unsigned DiagID)


Here is an example of the new output:

$ clang++ error.cpp
error.cpp:1:5: error: second parameter of 'main' (argument array) must be of
type 'char **' [main_arg_wrong]
int main(int, char*) {
    ^
1 error generated.

$ clang++ -Wunused-parameter warning.cpp
warning.cpp:1:21: warning: unused parameter 'argv' [unused_parameter]
[-Wunused-parameter]
int main(int, char* argv[]) { // expected-warning{{unused parameter 'argv'}}
                    ^
1 warning generated.

The name of the diagnostic can be seen appearing in brackets.


The patch also includes a small test which verifies that the name is
correctly printed (and the right name, at that), located in  test/Frontend


The llvm part of this patch is simply an alteration of the TableGen utility
to introduce the new fields. The llvm and clang part are intimately tied and
should be either both applied or both avoided/rolled back.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20110326/246c1ecc/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: llvm_diagnostic_1.diff
Type: application/octet-stream
Size: 1757 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20110326/246c1ecc/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: clang_diagnostic_1.diff
Type: application/octet-stream
Size: 19432 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20110326/246c1ecc/attachment-0001.obj>


More information about the cfe-commits mailing list