r204517 - CGDebugInfo: At the end of EmitFunctionStart, Initialize PrevLoc to the

Adrian Prantl aprantl at apple.com
Fri Mar 21 15:09:34 PDT 2014


On Mar 21, 2014, at 2:46 PM, Eric Christopher <echristo at gmail.com> wrote:

> On Fri, Mar 21, 2014 at 2:40 PM, Adrian Prantl <aprantl at apple.com> wrote:
>> 
>> On Mar 21, 2014, at 2:21 PM, Eric Christopher <echristo at gmail.com> wrote:
>> 
>>>> -  // Push function on region stack.
>>>> +  // Push the function onto the lexical block stack.
>>>>  llvm::MDNode *SPN = SP;
>>>>  LexicalBlockStack.push_back(SPN);
>>>> +  // Initialize PrevLoc to the location of the function header.
>>>> +  PrevLoc = Loc;
>>>> +
>>> 
>>> No guarantees that this is a "header" in any way :) We're also not
>>> initializing it.
>> Bad wording here. I meant this to mean the header of the function as opposed to its body. No relation to header files at all :-)
>>> 
>>> Also, are you sure this is the right fix? We seem to be pretty much
>>> immediately setting PrevLoc to Loc any time we see a function. Are we
>>> missing something somewhere else?
>> Not exactly. We're invoking EmitLocation pretty soon after, but without the above change, it will early-exit before having a chance to modify PrevLoc. And this is precisely what this patch is fixing.
>> 
> 
In the testcase there is a method that has a declaration in a different file than the definition.

> How will it early exit?

Sorry. I mixed up the function here. What happens is that setLocation (invoked by EmitLocation) early-exists, before it creates a new lexical scope for the current file, and pushing it to LexicalBlockStack. So the next time EmitLocation is called it will use the top of LexicalBlockStack, which will point to the subprogram (and thus the function declaration’s file).

-- adrian



More information about the cfe-commits mailing list