[cfe-commits] r161236 - in /cfe/trunk:

Benjamin Kramer benny.kra at gmail.com
Fri Aug 3 08:45:33 PDT 2012


On 03.08.2012, at 17:21, David Blaikie <dblaikie at gmail.com> wrote:

> On Fri, Aug 3, 2012 at 8:18 AM, Benjamin Kramer <benny.kra at gmail.com> wrote:
>> 
>> On 03.08.2012, at 16:34, David Blaikie <dblaikie at gmail.com> wrote:
>> 
>>> lib/AST/RecordLayoutBuilder.cpp
>>> 
>>> test/CodeGenCXX/cxx11-vtable-key-function.cpp
>>> MIME-Version: 1.0
>>> Content-Type: text/plain; charset="utf-8"
>>> Content-Transfer-Encoding: 7bit
>>> 
>>> Why can't the key function have a (non inline) = default definition?
>> 
>> It can.
>> 
>>> What happens if the only non inline virtual functions are = defaulted?
>> 
>> From the documentation of CXXMethodDecl::isUserProvided:
>> 
>>> True if this method is user-declared and was not deleted or defaulted on its *first declaration*
>> 
>> So this should not affect out-of-line defaulted key functions, it only prevents inline defaulted functions from being promoted to a key function.
> 
> Hmm, OK - should such definitions be considered 'inline' (since
> they're defined within the class) from both/either a standards
> perspective or a Clang-implementation-convenience perspective? Then
> this would fall out naturally from the inline check without the need
> for an isUserProvided check?
> 
> [& is there any better name for isUserProvided that might more
> accurately describe the semantics? (I still need to go back & fix some
> of the isDeleted/isDeletedAsWritten names/usages... they're also
> rather confusing in some similar ways)]
> 
> (& would it be worth having a test case to demonstrate that the out of
> line = default definition does get treated as a key function?)

Extended the test case to cover this in r161243. I'll leave decisions on changing the AST representation of inline defaulted functions to someone who is more familiar with it ;)

- Ben
> 
>> 
>> - Ben
>> 
>>> From: Benjamin Kramer
>>> Sent: 8/3/2012 1:42 AM
>>> To: cfe-commits at cs.uiuc.edu
>>> Subject: [cfe-commits] r161236 - in /cfe/trunk:
>>> lib/AST/RecordLayoutBuilder.cpp
>>> test/CodeGenCXX/cxx11-vtable-key-function.cpp
>>> Author: d0k
>>> Date: Fri Aug  3 03:39:58 2012
>>> New Revision: 161236
>>> 
>>> URL: http://llvm.org/viewvc/llvm-project?rev=161236&view=rev
>>> Log:
>>> Fix failed to generate vtables in certain cases.
>>> 
>>> By C++ standard, the vtable should be generated if the first non-inline
>>> virtual function is defined in the TU.  Current version of clang doesn't
>>> generate vtable if the first virtual function is defaulted, because the
>>> key function is regarded as the defaulted function.
>>> 
>>> Patch by Li Kan!
>>> 
>>> Added:
>>>   cfe/trunk/test/CodeGenCXX/cxx11-vtable-key-function.cpp
>>> Modified:
>>>   cfe/trunk/lib/AST/RecordLayoutBuilder.cpp
>>> 
>>> Modified: cfe/trunk/lib/AST/RecordLayoutBuilder.cpp
>>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/RecordLayoutBuilder.cpp?rev=161236&r1=161235&r2=161236&view=diff
>>> ==============================================================================
>>> --- cfe/trunk/lib/AST/RecordLayoutBuilder.cpp (original)
>>> +++ cfe/trunk/lib/AST/RecordLayoutBuilder.cpp Fri Aug  3 03:39:58 2012
>>> @@ -2351,6 +2351,9 @@
>>>    if (MD->hasInlineBody())
>>>      continue;
>>> 
>>> +    if (!MD->isUserProvided())
>>> +      continue;
>>> +
>>>    // We found it.
>>>    return MD;
>>>  }
>>> 
>>> Added: cfe/trunk/test/CodeGenCXX/cxx11-vtable-key-function.cpp
>>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/cxx11-vtable-key-function.cpp?rev=161236&view=auto
>>> ==============================================================================
>>> --- cfe/trunk/test/CodeGenCXX/cxx11-vtable-key-function.cpp (added)
>>> +++ cfe/trunk/test/CodeGenCXX/cxx11-vtable-key-function.cpp Fri Aug  3
>>> 03:39:58 2012
>>> @@ -0,0 +1,11 @@
>>> +// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o -
>>> -std=c++11 | FileCheck %s
>>> +// PR13424
>>> +
>>> +struct X {
>>> +  virtual ~X() = default;
>>> +  virtual void f();
>>> +};
>>> +
>>> +void X::f() {}
>>> +
>>> +// CHECK: @_ZTV1X = unnamed_addr constant
>>> 
>>> 
>>> _______________________________________________
>>> cfe-commits mailing list
>>> cfe-commits at cs.uiuc.edu
>>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>> 





More information about the cfe-commits mailing list