[PATCH] Handle SPARC float command line parameters for SPARCv9.

Reid Kleckner rnk at google.com
Fri Jul 11 14:10:13 PDT 2014


Rebase to remove other people's recent commits

http://reviews.llvm.org/D4476

Files:
  lib/Sema/SemaExpr.cpp
  test/CodeGen/builtin-ms-noop.cpp

Index: lib/Sema/SemaExpr.cpp
===================================================================
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -13477,9 +13477,22 @@
   case BuiltinType::PseudoObject:
     return checkPseudoObjectRValue(E);
 
-  case BuiltinType::BuiltinFn:
+  case BuiltinType::BuiltinFn: {
+    // Accept __noop without parens by implicitly converting it to a call expr.
+    auto *DRE = dyn_cast<DeclRefExpr>(E->IgnoreParenImpCasts());
+    if (DRE) {
+      auto *FD = cast<FunctionDecl>(DRE->getDecl());
+      if (FD->getBuiltinID() == Builtin::BI__noop) {
+        E = ImpCastExprToType(E, Context.getPointerType(FD->getType()),
+                              CK_BuiltinFnToFnPtr).get();
+        return new (Context) CallExpr(Context, E, None, Context.IntTy,
+                                      VK_RValue, SourceLocation());
+      }
+    }
+
     Diag(E->getLocStart(), diag::err_builtin_fn_use);
     return ExprError();
+  }
 
   // Everything else should be impossible.
 #define BUILTIN_TYPE(Id, SingletonId) \
Index: test/CodeGen/builtin-ms-noop.cpp
===================================================================
--- test/CodeGen/builtin-ms-noop.cpp
+++ test/CodeGen/builtin-ms-noop.cpp
@@ -1,13 +1,30 @@
-// RUN: %clang_cc1 -fms-extensions -triple %itanium_abi_triple -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -fms-extensions -triple x86_64-unknown-unknown -emit-llvm %s -o - | FileCheck %s
 
-class A {
- public:
+struct A {
   ~A() {}
 };
 
-int f() {
-// CHECK: @_Z1fv
+extern "C" int f() {
+// CHECK: define i32 @f()
 // CHECK-NOT: call void @_ZN1AD1Ev
 // CHECK: ret i32 0
   return __noop(A());
 };
+
+extern "C" int g() {
+  return __noop;
+// CHECK: define i32 @g()
+// CHECK: ret i32 0
+}
+
+extern "C" int h() {
+  return (__noop);
+// CHECK: define i32 @h()
+// CHECK: ret i32 0
+}
+
+extern "C" int i() {
+  return __noop + 1;
+// CHECK: define i32 @i()
+// CHECK: ret i32 1
+}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D4476.11329.patch
Type: text/x-patch
Size: 1949 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140711/1583796f/attachment.bin>


More information about the cfe-commits mailing list