r193606 - ARM: fix AST for __builtin_arm_strex call

Tim Northover tnorthover at apple.com
Tue Oct 29 05:32:58 PDT 2013


Author: tnorthover
Date: Tue Oct 29 07:32:58 2013
New Revision: 193606

URL: http://llvm.org/viewvc/llvm-project?rev=193606&view=rev
Log:
ARM: fix AST for __builtin_arm_strex call

The AST was constructed so that this builtin returned the default BoolTy and
since I'd opted for custom SemaChecking, I should have set it properly at that
point.

This caused an assertion failure when the types didn't match up with what we
generated. This makes it return an IntTy, which is as good as anything.

Added:
    cfe/trunk/test/Sema/builtins-arm-strex-rettype.c
Modified:
    cfe/trunk/lib/Sema/SemaChecking.cpp

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=193606&r1=193605&r2=193606&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Tue Oct 29 07:32:58 2013
@@ -556,8 +556,11 @@ bool Sema::CheckARMBuiltinExclusiveCall(
   ValArg = PerformCopyInitialization(Entity, SourceLocation(), ValArg);
   if (ValArg.isInvalid())
     return true;
-
   TheCall->setArg(0, ValArg.get());
+
+  // __builtin_arm_strex always returns an int. It's marked as such in the .def,
+  // but the custom checker bypasses all default analysis.
+  TheCall->setType(Context.IntTy);
   return false;
 }
 

Added: cfe/trunk/test/Sema/builtins-arm-strex-rettype.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/builtins-arm-strex-rettype.c?rev=193606&view=auto
==============================================================================
--- cfe/trunk/test/Sema/builtins-arm-strex-rettype.c (added)
+++ cfe/trunk/test/Sema/builtins-arm-strex-rettype.c Tue Oct 29 07:32:58 2013
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -triple thumbv7m-apple-darwin-eabi -ast-dump %s | FileCheck %s
+
+// CHECK: CallExpr {{.*}} 'int'
+
+void foo(int a, int *b) {
+  do {
+  } while (__builtin_arm_strex(a, b));
+}





More information about the cfe-commits mailing list