[cfe-commits] r158288 - in /cfe/trunk: include/clang/AST/ include/clang/Basic/ include/clang/Sema/ lib/AST/ lib/CodeGen/ lib/Parse/ lib/Rewrite/ lib/Sema/ lib/Serialization/ test/PCH/ test/SemaTemplate/

Richard Smith richard at metafoo.co.uk
Mon Jul 2 11:35:09 PDT 2012


On Mon, Jul 2, 2012 at 1:20 AM, Enea Zaffanella <zaffanella at cs.unipr.it>wrote:

> Hello Richard.
>
> The commit below has removed a couple of FieldDecl public methods
> (setBitWidth and removeBitWidth) that are used in one of our applications.
> I understand that you removed them because they are unused in the clang
> sources, thereby looking useless, so the questions are:
>
> 1) OK to reintroduce them? (we need to modify some AST nodes in place and
> one of the changes has to do with bitfield size expressions)
>

We generally try to keep the AST immutable, but I appreciate this is a
regression for you, so I think it's OK to add these back. I do wonder if
there's another way of approaching your use case that would remove the need
for these mutators, such as creating a new FieldDecl rather than modifying
the existing one. I assume you're aware that changing the bitwidth can have
a non-trivial effect on the semantic properties of expressions which use
the bitfield (so you probably shouldn't do this if you already have
expressions referencing the field).


> 2) is there any convention for flagging this kind of "unused" methods as
> "used", so as to avoid future removals?
>

Not that I know of. A comment would be useful.

On 06/10/2012 05:12 AM, Richard Smith wrote:
>
>> Author: rsmith
>> Date: Sat Jun  9 22:12:00 2012
>> New Revision: 158288
>>
>> URL: http://llvm.org/viewvc/llvm-**project?rev=158288&view=rev<http://llvm.org/viewvc/llvm-project?rev=158288&view=rev>
>> Log:
>> PR13064: Store whether an in-class initializer uses direct or copy
>> initialization, and use that information to produce the right kind of
>> initialization during template instantiation.
>>
>
> [...]
>
>
>  -  void setBitWidth(Expr *BW) {
>> -    assert(!InitializerOrBitWidth.**getPointer() &&
>> -           "bit width or initializer already set");
>> -    InitializerOrBitWidth.**setPointer(BW);
>> -    InitializerOrBitWidth.setInt(**1);
>> -  }
>> -  /// removeBitWidth - Remove the bitfield width from this member.
>> -  void removeBitWidth() {
>> -    assert(isBitField() && "no bit width to remove");
>> -    InitializerOrBitWidth.**setPointer(0);
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120702/70cf2750/attachment.html>


More information about the cfe-commits mailing list