[cfe-dev] source location and range of function parameters

David Blaikie dblaikie at gmail.com
Sat Sep 17 00:04:33 PDT 2011


I'm attempting to improve the following diagnostic:

foo.cc:2:14: error: empty parameter list defined with a typedef of
'void' not allowed in C++void test(foo);             ^

My main intent was to add a fixit that suggests replacing 'foo' with 'void'
here. But I've come into two problems:

1) The source location of the unnamed (foo/void typed) parameter is the
closing ')' - presumably this is meant to be pointing to the name of the
variable, but that doesn't exist in this case. Should we be addressing this
in some general way (I imagine lots of diagnostics might point to parameters
& get the case of unnamed parameters wrong in the same way)?

2) I can't seem to find the source range of the entire parameter (though in
this case, I'd settle for the source range of the type if that were easier).
Using ParamVarDecl's getSourceRange to apply a replacement fixit to "void" I
get a range that is too long, like this (the ^ is corrected in this case as
I also changed the diagnostic to apply to the Param's locStart rather than
location) :

foo.cc:2:11: error: empty parameter list defined with a typedef of
'void' not allowed in C++void test(foo);          ^~~~          void

again - is this by design (in which case I'd need a local workaround/another
way to find the desired source range), or should the range incorrect in
general?

Thanks,
- David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20110917/a60dc4fe/attachment.html>


More information about the cfe-dev mailing list