This source range covers the list of parameters of a function
This adds a SourceLocation trailing object to FunctionProtoType,
and the getEllipsisLoc and getParametersSourceRange methods to
Why does this omit the ellipsis? It's part of the parameter list and it seems like a strange design decision to leave that out of the source range for the parameter list.
Please don't use auto here (or below); the type is not spelled out in the initialization.
I'd like to see tests that include an ellipsis, as well as tests that use the preprocessor in creative ways. e.g.,
#define FOO int a, int b void func(FOO); void bar(float f, FOO, float g); void baz(FOO, float f); void quux(float f, FOO);
Also, tests for member functions (both static and instance functions) and parameters with leading attributes would be useful. e.g.,
void func([] int *i);
I haven't found a correct way to access the position of the ellipsis. There is no corresponding ParmVarDecl in ParamInfo.
Source locations with macros always looked inconsistent to me. For example:
#define RET int RET f(void);
Here, getReturnTypeSourceRange returns <input.cc:2:1 <Spelling=input.cc:1:13>-input.cc:2:1 <Spelling=input.cc:1:13>>, where I would expect (and I could be wrong) <input.cc:2:1 <Spelling=input.cc:1:13>-input.cc:2:3 <Spelling=input.cc:1:16>>
The same thing happens with getParametersSourceRange. Should I test the current behavior?
I added the other tests you requested.
I don't think you've missed anything; I think we need to track/dig out that information in order for this API to be usefully correct. I don't see a lot of value in getting a source range that's sometimes wrong.
I would recommend seeing if you can go back to the function type location information as-needed to figure out where the ellipsis is and include it in the range here.
I'd test current behavior.
Why a source range? The ellipsis is a single token, so a range should be unnecessary. I would just have this return FPT->getEllipsisLoc().
Can you add "excluding the parentheses" to this as well, to make it crystal clear what is covered?
Don't use auto unless the type is explicitly spelled out in the initialization (elsewhere as well).