On 09/26/2011 10:21 AM, Dodji Seketeli wrote:
> > + /* The cpp_reader the macro comes from. */
> > + cpp_reader *pfile;
>
> This seems to only be used to decide whether or not to increment
> location_ptr. Rather than base that decision on going all the way
> back to the CPP_OPTION, let's just pass a flag to
> macro_arg_token_iter_init and use that to decide whether or not to set
> location_ptr.
Conceptually, location_ptr is always set, barring one exception: when
the token pointing to by the iterator is empty.
Yes, I was suggesting that you change that, since it's only used by
_get_location, which can get the location from the pointer instead.
So I fail to see what would be made unreachable here.
You're right, I was misreading the code.
+ if (location)
+ {
+ if (virt_loc == 0)
+ virt_loc = result->src_loc;
+ *location = virt_loc;
+ }
+
+ out:
+ if (location != NULL)
+ {
+ if (!CPP_OPTION (pfile, track_macro_expansion)
+ && can_set
+ && pfile->context->c.macro != NULL)
+ /* We are in a macro expansion context, are not tracking
+ virtual location, but were asked to report the location
+ of the expansion point of the macro being expanded. */
+ *location = pfile->invocation_location;
+
+ *location = maybe_adjust_loc_for_trad_cpp (pfile, *location);
+ }
The out: label needs to be before the first if.
Jason