[cfe-commits] Fix for the -mms-bitfields commandline parameter

Jeremiah Zanin Jeremiah.Zanin at volition-inc.com
Tue Oct 9 08:53:43 PDT 2012

Ok, here's the updated patch.


-----Original Message-----
From: Eli Friedman [mailto:eli.friedman at gmail.com]
Sent: Monday, October 08, 2012 6:19 PM
To: Jeremiah Zanin
Cc: cfe-commits at cs.uiuc.edu
Subject: Re: [cfe-commits] Fix for the -mms-bitfields commandline parameter

On Mon, Oct 8, 2012 at 2:47 PM, Jeremiah Zanin <Jeremiah.Zanin at volition-inc.com> wrote:
> The "-mms-bitfields" commandline parameter now properly turns on the ms_struct behavior.
> I've never submitted a code change before, hopefully I did this correctly. I included the patch and a new test file.
> One result of this change is that __attribute__((ms_struct)) on an enum will produce a warning, for example:
> enum __attribute__((ms_struct)) bar {
>         BAR_A = 0,
>         BAR_B,
>         BAR_C
> };
> ms-bitfields-test.cpp:4:21: warning: 'ms_struct' attribute ignored
> enum __attribute__((ms_struct)) bar {
> Is this desired?

Yes.  Please include a testcase for that.

Please include testcases inside a patch (use "svn add").

This patch would be much simpler if you just implemented isMsStruct as:

bool RecordDecl::isMsStruct(ASTContext &Ctx) {
  return RD->hasAttr<MsStructAttr>() ||
         Ctx.getLangOpts().MSBitfields == 1; }

(Also, your current patch doesn't properly handle serialization of RecordDecls; no change is necessary if you don't add a new bit.)

+  if (RecordDecl *RD = dyn_cast<RecordDecl>(D)) {
+    RD->addAttr(::new (S.Context) MsStructAttr(Attr.getRange(), S.Context));
+    RD->setMsStruct(true);
+  }
     S.Diag(Attr.getLoc(), diag::warn_attribute_ignored) << Attr.getName();

We generally prefer brace on the same line as else.



This message, including any attachments, may contain privileged and/or confidential information. Any distribution or use of this email by anyone other than the intended recipient(s) is strictly prohibited. If you are not the intended recipient, please notify the sender immediately and delete all copies. Thank you.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mms-bitfields.patch
Type: application/octet-stream
Size: 7600 bytes
Desc: mms-bitfields.patch
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20121009/b2dc2e8b/attachment.obj>

More information about the cfe-commits mailing list