r221481 - Return a DIDescriptor from CGDebugInfo::getDeclarationOrDefinition...

Eric Christopher echristo at gmail.com
Thu Nov 6 16:52:49 PST 2014


On Thu Nov 06 2014 at 3:17:40 PM Frédéric Riss <friss at apple.com> wrote:

> On Nov 6, 2014, at 2:57 PM, Eric Christopher <echristo at gmail.com> wrote:
>
> Hrm. Testcase? Where were you seeing it?
>
>
> Unfortunately there is nothing here to test, because it actually worked.
> As you know, you can wrap any DIDescriptor into any other type of
> DIDescriptor as long as you don’t access the fields or .verify() the
> result. Here the resulting DIScope was just used to pass along the DbgNode
> (look at r221466 for a tiny bit more context).
>
> I’ve noticed it while working on debug info generation for forward
> declarations (review to come soonish). getDeclarationOrDefinition takes the
> result of the DeclMap lookup and puts it into a DIScope, even if what was
> came out of the map wasn’t a DIScope (and it’s a sure thing that the
> DIGlobalVariable stored there aren’t DIScopes).
>
>
Sounds good.

Thanks!

-eric


> Fred
>
> -eric
>
> On Thu Nov 06 2014 at 1:30:34 PM Frederic Riss <friss at apple.com> wrote:
>
>> Author: friss
>> Date: Thu Nov  6 15:12:06 2014
>> New Revision: 221481
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=221481&view=rev
>> Log:
>> Return a DIDescriptor from CGDebugInfo::getDeclarationOrDefinition...
>>
>> ... instead of a DIScope that might wrap something that's not actually
>> a DIScope (eg. a DIGlobalVariable);
>>
>> Modified:
>>     cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
>>     cfe/trunk/lib/CodeGen/CGDebugInfo.h
>>
>> Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/
>> CGDebugInfo.cpp?rev=221481&r1=221480&r2=221481&view=diff
>> ============================================================
>> ==================
>> --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
>> +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Thu Nov  6 15:12:06 2014
>> @@ -2307,7 +2307,7 @@ llvm::DIType CGDebugInfo::CreateMemberTy
>>    return Ty;
>>  }
>>
>> -llvm::DIScope CGDebugInfo::getDeclarationOrDefinition(const Decl *D) {
>> +llvm::DIDescriptor CGDebugInfo::getDeclarationOrDefinition(const Decl
>> *D) {
>>    // We only need a declaration (not a definition) of the type - so use
>> whatever
>>    // we would otherwise do to get a type for a pointee. (forward
>> declarations in
>>    // limited debug info, full definitions (if the type definition is
>> available)
>> @@ -2327,7 +2327,7 @@ llvm::DIScope CGDebugInfo::getDeclaratio
>>    if (I == DeclCache.end())
>>      return llvm::DIScope();
>>    llvm::Value *V = I->second;
>> -  return llvm::DIScope(dyn_cast_or_null<llvm::MDNode>(V));
>> +  return llvm::DIDescriptor(dyn_cast_or_null<llvm::MDNode>(V));
>>  }
>>
>>  /// getFunctionDeclaration - Return debug info descriptor to describe
>> method
>> @@ -3239,7 +3239,7 @@ void CGDebugInfo::EmitUsingDecl(const Us
>>    // Emitting one decl is sufficient - debuggers can detect that this is
>> an
>>    // overloaded name & provide lookup for all the overloads.
>>    const UsingShadowDecl &USD = **UD.shadow_begin();
>> -  if (llvm::DIScope Target =
>> +  if (llvm::DIDescriptor Target =
>>            getDeclarationOrDefinition(USD.getUnderlyingDecl()))
>>      DBuilder.createImportedDeclaration(
>>          getCurrentContextDescriptor(cast<Decl>(USD.getDeclContext())),
>> Target,
>>
>> Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.h
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/
>> CGDebugInfo.h?rev=221481&r1=221480&r2=221481&view=diff
>> ============================================================
>> ==================
>> --- cfe/trunk/lib/CodeGen/CGDebugInfo.h (original)
>> +++ cfe/trunk/lib/CodeGen/CGDebugInfo.h Thu Nov  6 15:12:06 2014
>> @@ -363,9 +363,9 @@ private:
>>    llvm::DIType CreateMemberType(llvm::DIFile Unit, QualType FType,
>>                                  StringRef Name, uint64_t *Offset);
>>
>> -  /// \brief Retrieve the DIScope, if any, for the canonical form of this
>> +  /// \brief Retrieve the DIDescriptor, if any, for the canonical form
>> of this
>>    /// declaration.
>> -  llvm::DIScope getDeclarationOrDefinition(const Decl *D);
>> +  llvm::DIDescriptor getDeclarationOrDefinition(const Decl *D);
>>
>>    /// getFunctionDeclaration - Return debug info descriptor to describe
>> method
>>    /// declaration for the given method definition.
>>
>>
>> _______________________________________________
>> cfe-commits mailing list
>> cfe-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20141107/cdb3bacc/attachment.html>


More information about the cfe-commits mailing list