[llvm] r217756 - Fix a non-virtual destructor warning introduced in r217747.

Hans Wennborg hans at chromium.org
Wed Sep 17 14:28:44 PDT 2014


On Tue, Sep 16, 2014 at 11:17 AM, Hans Wennborg <hans at chromium.org> wrote:
> On Tue, Sep 16, 2014 at 10:00 AM, Frédéric Riss <friss at apple.com> wrote:
>>
>> On 16 Sep 2014, at 18:52, Hans Wennborg <hans at chromium.org> wrote:
>>
>> On Mon, Sep 15, 2014 at 12:33 PM, Frédéric Riss <friss at apple.com> wrote:
>>
>>
>> On 15 Sep 2014, at 20:19, David Blaikie <dblaikie at gmail.com> wrote:
>>
>>
>>
>> On Mon, Sep 15, 2014 at 3:38 AM, Frederic Riss <friss at apple.com> wrote:
>>
>>
>> Author: friss
>> Date: Mon Sep 15 05:38:13 2014
>> New Revision: 217756
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=217756&view=rev
>> Log:
>> Fix a non-virtual destructor warning introduced in r217747.
>>
>> Modified:
>>    llvm/trunk/lib/DebugInfo/DWARFUnit.h
>>
>> Modified: llvm/trunk/lib/DebugInfo/DWARFUnit.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARFUnit.h?rev=217756&r1=217755&r2=217756&view=diff
>>
>> ==============================================================================
>> --- llvm/trunk/lib/DebugInfo/DWARFUnit.h (original)
>> +++ llvm/trunk/lib/DebugInfo/DWARFUnit.h Mon Sep 15 05:38:13 2014
>> @@ -35,6 +35,8 @@ public:
>>   /// Returns the Unit that contains the given section offset in the
>>   /// same section this Unit originated from.
>>   virtual DWARFUnit *getUnitForOffset(uint32_t Offset) const = 0;
>> +
>> +  virtual ~DWARFUnitSectionBase() {}
>>
>>
>>
>> Since these objects are never polymorphically owned, a better fix for this
>> would be to make the base dtor protected, and the derived classes final.
>> That will satisfy the warning without adding an unneeded vtable
>> entry/virtual call overhead.
>>
>>
>> I’ll do that in a followup commit tomorrow.
>>
>>
>> This is causing problems for me after r217871:
>>
>> In file included from
>> third_party/llvm/llvm/lib/DebugInfo/DWARFCompileUnit.h:13:0,
>>                 from
>> third_party/llvm/llvm/lib/DebugInfo/DWARFDebugInfoEntry.cpp:11:
>> third_party/llvm/llvm/lib/DebugInfo/DWARFUnit.h: In instantiation of
>> 'class llvm::DWARFUnitSection<llvm::DWARFCompileUnit>':
>> third_party/llvm/llvm/lib/DebugInfo/DWARFContext.h:32:38:   required from
>> here
>> third_party/llvm/llvm/lib/DebugInfo/DWARFUnit.h:45:7: error: 'class
>> llvm::DWARFUnitSection<llvm::DWARFCompileUnit>' has virtual functions
>> and accessible non-virtual destructor [-Werror=non-virtual-dtor]
>>
>>
>> With what compiler is that? I tested it with a fresh clang from master and
>> it didn’t generate the warning. clang < 3.5 is known to produce a bogus
>> warning in this case, but the build system should detect it and not pass
>> -Wnon-virtual-dtor in that case.
>>
>> I won’t have time to look at this right now, if it is a blocking you and you
>> can’t easily fix it, feel free to revert. (But I’d really like to understand
>> the issue).
>
> It's an internal build using GCC. I'm not entirely sure which version.
> I know this has come up before, so I'm trying to understand what's
> going on here and how it was fixed that time.

To follow up: we fixed this by suppressing the gcc warning.

Thanks,
Hans




More information about the llvm-commits mailing list