Fix TestRegisterVariables for clang/arm
authorPavel Labath <labath@google.com>
Wed, 19 Apr 2017 10:13:29 +0000 (10:13 +0000)
committerPavel Labath <labath@google.com>
Wed, 19 Apr 2017 10:13:29 +0000 (10:13 +0000)
Clang rejects __attribute__((regparm)) when targetting arm. The default
calling convention passes arguments in registers anyway, so we can just
remove them in this case.

llvm-svn: 300670

lldb/packages/Python/lldbsuite/test/lang/c/register_variables/test.c

index 476c32899edc69712852e37b2d8a336bc5d8f47e..b95253ef9eea78408ea592e29a6b44f3927d7bc6 100644 (file)
@@ -1,17 +1,26 @@
 #include <stdio.h>
 
+#if defined(__arm__) || defined(__aarch64__)
+// Clang does not accept regparm attribute on these platforms.
+// Fortunately, the default calling convention passes arguments in registers
+// anyway.
+#define REGPARM(N)
+#else
+#define REGPARM(N) __attribute__((regparm(N)))
+#endif
+
 struct bar {
   int m1;
   int m2;
 };
 
-void f1(int a, struct bar *b) __attribute__((noinline)) __attribute__((regparm(2)));
+void f1(int a, struct bar *b) __attribute__((noinline)) REGPARM(2);
 void f1(int a, struct bar *b)
 {
   b->m2 = b->m1 + a; // set breakpoint here
 }
 
-void f2(struct bar *b) __attribute__((noinline)) __attribute__((regparm(1)));
+void f2(struct bar *b) __attribute__((noinline)) REGPARM(1);
 void f2(struct bar *b)
 {
   int c = b->m2;