]> granicus.if.org Git - clang/commitdiff
Support field references to struct names and c++11 aliases from inline asm.
authorNico Weber <nicolasweber@gmx.de>
Tue, 6 May 2014 03:13:27 +0000 (03:13 +0000)
committerNico Weber <nicolasweber@gmx.de>
Tue, 6 May 2014 03:13:27 +0000 (03:13 +0000)
This is in addition to the existing support for typedefs.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@208053 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaStmtAsm.cpp
test/CodeGen/ms-inline-asm.cpp

index 1cbc901da671d8f17af5ea5d651b0349886b846e..e733fd0c334aded9eb591fbcef215313aaed96eb 100644 (file)
@@ -441,8 +441,10 @@ bool Sema::LookupInlineAsmField(StringRef Base, StringRef Member,
   NamedDecl *FoundDecl = BaseResult.getFoundDecl();
   if (VarDecl *VD = dyn_cast<VarDecl>(FoundDecl))
     RT = VD->getType()->getAs<RecordType>();
-  else if (TypedefDecl *TD = dyn_cast<TypedefDecl>(FoundDecl))
+  else if (TypedefNameDecl *TD = dyn_cast<TypedefNameDecl>(FoundDecl))
     RT = TD->getUnderlyingType()->getAs<RecordType>();
+  else if (TypeDecl *TD = dyn_cast<TypeDecl>(FoundDecl))
+    RT = TD->getTypeForDecl()->getAs<RecordType>();
   if (!RT)
     return true;
 
index b1c13e57f13cfb3b1f078847121a9e357ed6af1c..83fe1075aff78b1c89864c0e8e0bda56dd9ad086 100644 (file)
@@ -1,5 +1,5 @@
 // REQUIRES: x86-registered-target
-// RUN: %clang_cc1 -x c++ %s -triple i386-apple-darwin10 -fasm-blocks -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -x c++ %s -triple i386-apple-darwin10 -fasm-blocks -emit-llvm -o - -std=c++11 | FileCheck %s
 
 // rdar://13645930
 
@@ -111,3 +111,33 @@ void test6() {
    jmp a
   }
 }
+
+void t7_struct() {
+  struct A {
+    int a;
+    int b;
+  };
+  __asm mov eax, [eax].A.b
+  // CHECK-LABEL: define void @_Z9t7_structv
+  // CHECK: call void asm sideeffect inteldialect "mov eax, [eax].4", "~{eax},~{dirflag},~{fpsr},~{flags}"()
+}
+
+void t7_typedef() {
+  typedef struct {
+    int a;
+    int b;
+  } A;
+  __asm mov eax, [eax].A.b
+  // CHECK-LABEL: define void @_Z10t7_typedefv
+  // CHECK: call void asm sideeffect inteldialect "mov eax, [eax].4", "~{eax},~{dirflag},~{fpsr},~{flags}"()
+}
+
+void t7_using() {
+  using A = struct {
+    int a;
+    int b;
+  };
+  __asm mov eax, [eax].A.b
+  // CHECK-LABEL: define void @_Z8t7_usingv
+  // CHECK: call void asm sideeffect inteldialect "mov eax, [eax].4", "~{eax},~{dirflag},~{fpsr},~{flags}"()
+}