[PATCH] Handle atomic types in Type::hasIntegerRepresentation()

Serge Pavlov sepavloff at gmail.com
Mon Apr 15 11:59:11 PDT 2013


sepavloff added you to the CC list for the revision "Handle atomic types in  Type::hasIntegerRepresentation()".

Hi doug.gregor,

Previous version of Type::hasIntegerRepresentation() returned 'false' for
types as '_Atomic(int)'. As a result, shift operations for atomic types
were not allowed. This fix allows handling atomic types in this function.

http://llvm-reviews.chandlerc.com/D673

Files:
  lib/AST/Type.cpp
  test/Sema/atomic-expr.c

Index: lib/AST/Type.cpp
===================================================================
--- lib/AST/Type.cpp
+++ lib/AST/Type.cpp
@@ -613,6 +613,8 @@
 }
 
 bool Type::hasIntegerRepresentation() const {
+  if (const AtomicType *Atomic = dyn_cast<AtomicType>(CanonicalType))
+    return Atomic->getValueType()->hasIntegerRepresentation();
   if (const VectorType *VT = dyn_cast<VectorType>(CanonicalType))
     return VT->getElementType()->isIntegerType();
   else
Index: test/Sema/atomic-expr.c
===================================================================
--- /dev/null
+++ test/Sema/atomic-expr.c
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only
+// expected-no-diagnostics
+
+_Atomic(unsigned int) data1;
+int _Atomic data2;
+
+// Shift operations
+
+int func_01 (int x) {
+  return data1 << x;
+}
+
+int func_02 (int x) {
+  return x << data1;
+}
+
+int func_03 (int x) {
+  return data2 << x;
+}
+
+int func_04 (int x) {
+  return x << data2;
+}
+
+int func_05 () {
+  return data2 << data1;
+}
+
+int func_06 () {
+  return data1 << data2;
+}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D673.1.patch
Type: text/x-patch
Size: 1071 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130415/621dfb7e/attachment.bin>


More information about the cfe-commits mailing list