[cfe-dev] SourceLocation of FunctionDecl

Nimrod Partush nimrodpar at gmail.com
Tue Nov 2 10:50:44 PDT 2010


Yes that would be nice to have.

But i think the greater issue here is the correctness of the location
retrieval functions. GetLocStart for a FunctionDecl should retrieve the
start of the decleration, including storage class, etc. Overall, many
times I've seen these function miss the target and that's a shame.

On Tue, Nov 2, 2010 at 7:33 PM, jahanian <fjahanian at apple.com> wrote:

> Long term we need to add location for storage class in each declaration.
> Missing that, the next best thing would be to rewrite the declaration into:
>
> static int f();
> int f() {}
> I checked with Doug and he says we can get location of the type specifier.
>
> - Fariborz
>
> On Nov 2, 2010, at 9:20 AM, Nimrod Partush wrote:
>
> Actually i tried it but this approach has 2 problems:
>
> 1. I can't always be sure that there will be a previous declaration.
> 2. When i try to receive the end location of the previous entity, i get a
> location which is 2 or 3 offsets prior to the actual location. I think this
> is a bug in GetLocEnd.
>
> On Tue, Nov 2, 2010 at 6:14 PM, jahanian <fjahanian at apple.com> wrote:
>
>> Can't you do this by adding code *after* the previous declaration entity?
>>
>> - Fariborz
>>
>> On Nov 2, 2010, at 7:54 AM, Nimrod Partush wrote:
>>
>> > Hi,
>> >
>> > I want to add code just before a certain function deceleration.
>> >
>> > I do this by visiting the FunctionDecl and using it's start location for
>> InsertTextBefore.
>> >
>> > The problem is that GetLocStart returns the location of the Function's
>> name and not the entire prototype i.e. if i have this function:
>> >
>> > static int f() {
>> > }
>> >
>> > i will get the location of "f" and not the location of "static".
>> >
>> > Help?
>> >
>> > Thanks.
>> > _______________________________________________
>> > cfe-dev mailing list
>> > cfe-dev at cs.uiuc.edu
>> > http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>>
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20101102/21e6e429/attachment.html>


More information about the cfe-dev mailing list