[patch] Let ms inline asm understand using statements and record names in addition to typedefs

Reid Kleckner rnk at google.com
Mon May 5 14:30:18 PDT 2014


LGTM

I looked at this once before, but I thought MSVC only supported lookup
through typedefs.  Turns out I was wrong.  MSVC doesn't accept your test
case, but they do accept:

struct A {
  int a;
  int b;
};
int foo(A *a) {
  __asm  {
    mov eax, a
    mov eax, [eax]A.b
  }
}


On Sat, May 3, 2014 at 5:26 PM, Nico Weber <thakis at chromium.org> wrote:

> Hi,
>
> while looking at something else, I learned that with -fasm-blocks,
> clang understands
>
>   typedef struct {
>     int a;
>     int b;
>   } A;
>   __asm mov eax, [eax].A.b
>
> It only supports typedefs though, not the same thing with `using A =
> struct { ... };`, and also not the direct `struct A { ... }`. This
> seems inconsistent, so the attached patch adds support for that. I
> don't know if adding such support is useful or desirable, but since I
> already wrote the 4 lines to make it work I figured I could at least
> send out the patch :-)
>
> Nico
>
> ps: Fun fact: With s/struct/class/ in the snippet above, clang does
> print "error: 'b' is a private member of 'A'" (yay!) but does so
> without a source location (boo!, but understandable I suppose.)
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140505/21207ef3/attachment.html>


More information about the cfe-commits mailing list