r188739 - Revert "Revert "Revert "Revert "DebugInfo: Omit debug info for dynamic classes in TUs that do not have the vtable for that class""""

David Blaikie dblaikie at gmail.com
Tue Aug 20 14:55:03 PDT 2013


On Mon, Aug 19, 2013 at 9:28 PM, Eric Christopher <echristo at gmail.com> wrote:
>>    if (const RecordDecl *RD = dyn_cast<RecordDecl>(Context)) {
>>      if (!RD->isDependentType()) {
>> -      llvm::DIType Ty = getOrCreateLimitedType(
>> -          CGM.getContext().getRecordType(RD)->castAs<RecordType>(), getOrCreateMainFile());
>> +      llvm::DICompositeType T(getTypeOrNull(CGM.getContext().getRecordType(RD)));
>> +      llvm::DICompositeType Ty(getOrCreateLimitedType(
>> +          CGM.getContext().getRecordType(RD)->castAs<RecordType>(),
>> +          getOrCreateMainFile()));
>> +      if (!Ty.getTypeArray().getNumElements()) {
>> +        if (T) {
>> +          llvm::DIArray PrevMem = T.getTypeArray();
>> +          unsigned NumElements = PrevMem.getNumElements();
>> +          if (NumElements == 1 && !PrevMem.getElement(0))
>> +            NumElements = 0;
>> +          SmallVector<llvm::Value *, 16> EltTys;
>> +          EltTys.reserve(NumElements);
>> +          for (unsigned i = 0; i != NumElements; ++i)
>> +            EltTys.push_back(PrevMem.getElement(i));
>> +          llvm::DIArray Elements = DBuilder.getOrCreateArray(EltTys);
>> +          Ty.setTypeArray(Elements);
>> +        }
>> +      }
>
> This could really use some descriptive comments :)

Realized it could be simplified - so I did that (ended up rolling this
complexity into getOrCreateLimitedType & in a simpler form (simply
"Ty.setTypeArray(T.getTypeArray())") & avoiding yet another
getTypeOrNull lookup (since we were already doing one in
getOrCreateLimitedType)) in 188829.

>> -    if (const CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(D))
>> -      EltTys.push_back(CreateCXXMemberFunction(Method, Unit, RecordTy));
>> +    if (const CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(D)) {
>> +      llvm::DenseMap<const FunctionDecl *, llvm::WeakVH>::iterator MI =
>> +          SPCache.find(Method->getCanonicalDecl());
>> +      if (MI == SPCache.end())
>> +        EltTys.push_back(CreateCXXMemberFunction(Method, Unit, RecordTy));
>> +      else
>> +        EltTys.push_back(MI->second);
>> +    }
>
> Ditto here :)

Commented in r188834.



More information about the cfe-commits mailing list