r245923 - [X86] Expose the various _rot intrinsics on non-MS platforms

2015-08-25 Thread Michael Kuperstein via cfe-commits
Author: mkuper
Date: Tue Aug 25 02:21:33 2015
New Revision: 245923

URL: http://llvm.org/viewvc/llvm-project?rev=245923&view=rev
Log:
[X86] Expose the various _rot intrinsics on non-MS platforms

_rotl, _rotwl and _lrotl (and their right-shift counterparts) are official x86
intrinsics, and should be supported regardless of environment. This is in 
contrast
to _rotl8, _rotl16, and _rotl64 which are MS-specific.

Note that the MS documentation for _lrotl is different from the Intel 
documentation. Intel explicitly documents it as a 64-bit rotate, while for MS,
since sizeof(unsigned long) for MSVC is always 4, a 32-bit rotate is implied.

Differential Revision: http://reviews.llvm.org/D12271

Added:
cfe/trunk/test/CodeGen/x86-rot-intrinsics.c   (with props)
Modified:
cfe/trunk/lib/Headers/Intrin.h
cfe/trunk/lib/Headers/immintrin.h

Modified: cfe/trunk/lib/Headers/Intrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/Intrin.h?rev=245923&r1=245922&r2=245923&view=diff
==
--- cfe/trunk/lib/Headers/Intrin.h (original)
+++ cfe/trunk/lib/Headers/Intrin.h Tue Aug 25 02:21:33 2015
@@ -463,26 +463,6 @@ _rotr16(unsigned short _Value, unsigned
   _Shift &= 0xf;
   return _Shift ? (_Value >> _Shift) | (_Value << (16 - _Shift)) : _Value;
 }
-static __inline__ unsigned int __DEFAULT_FN_ATTRS
-_rotl(unsigned int _Value, int _Shift) {
-  _Shift &= 0x1f;
-  return _Shift ? (_Value << _Shift) | (_Value >> (32 - _Shift)) : _Value;
-}
-static __inline__ unsigned int __DEFAULT_FN_ATTRS
-_rotr(unsigned int _Value, int _Shift) {
-  _Shift &= 0x1f;
-  return _Shift ? (_Value >> _Shift) | (_Value << (32 - _Shift)) : _Value;
-}
-static __inline__ unsigned long __DEFAULT_FN_ATTRS
-_lrotl(unsigned long _Value, int _Shift) {
-  _Shift &= 0x1f;
-  return _Shift ? (_Value << _Shift) | (_Value >> (32 - _Shift)) : _Value;
-}
-static __inline__ unsigned long __DEFAULT_FN_ATTRS
-_lrotr(unsigned long _Value, int _Shift) {
-  _Shift &= 0x1f;
-  return _Shift ? (_Value >> _Shift) | (_Value << (32 - _Shift)) : _Value;
-}
 static
 __inline__ unsigned __int64 __DEFAULT_FN_ATTRS
 _rotl64(unsigned __int64 _Value, int _Shift) {

Modified: cfe/trunk/lib/Headers/immintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/immintrin.h?rev=245923&r1=245922&r2=245923&view=diff
==
--- cfe/trunk/lib/Headers/immintrin.h (original)
+++ cfe/trunk/lib/Headers/immintrin.h Tue Aug 25 02:21:33 2015
@@ -148,4 +148,58 @@ _writegsbase_u64(unsigned long long __V)
  * whereas others are also available at all times. */
 #include 
 
+static __inline__ unsigned short __attribute__((__always_inline__, 
__nodebug__))
+_rotwl(unsigned short _Value, int _Shift) {
+  _Shift &= 0xf;
+  return _Shift ? (_Value << _Shift) | (_Value >> (16 - _Shift)) : _Value;
+}
+
+static __inline__ unsigned short __attribute__((__always_inline__, 
__nodebug__))
+_rotwr(unsigned short _Value, int _Shift) {
+  _Shift &= 0xf;
+  return _Shift ? (_Value >> _Shift) | (_Value << (16 - _Shift)) : _Value;
+}
+
+static __inline__ unsigned int __attribute__((__always_inline__, __nodebug__))
+_rotl(unsigned int _Value, int _Shift) {
+  _Shift &= 0x1f;
+  return _Shift ? (_Value << _Shift) | (_Value >> (32 - _Shift)) : _Value;
+}
+
+static __inline__ unsigned int __attribute__((__always_inline__, __nodebug__))
+_rotr(unsigned int _Value, int _Shift) {
+  _Shift &= 0x1f;
+  return _Shift ? (_Value >> _Shift) | (_Value << (32 - _Shift)) : _Value;
+}
+
+/* 
+ * MS defines _lrotl/_lrotr in a slightly incompatible way, since 
+ * unsigned long is always 32-bit in MSVC. 
+ */
+#ifdef _MSC_VER
+static __inline__ unsigned long __attribute__((__always_inline__, __nodebug__))
+_lrotl(unsigned long _Value, int _Shift) {
+  _Shift &= 0x1f;
+  return _Shift ? (_Value << _Shift) | (_Value >> (32 - _Shift)) : _Value;
+}
+
+static __inline__ unsigned long __attribute__((__always_inline__, __nodebug__))
+_lrotr(unsigned long _Value, int _Shift) {
+  _Shift &= 0x1f;
+  return _Shift ? (_Value >> _Shift) | (_Value << (32 - _Shift)) : _Value;
+}
+#else
+static __inline__ unsigned long __attribute__((__always_inline__, __nodebug__))
+_lrotl(unsigned long _Value, int _Shift) {
+  _Shift &= 0x3f;
+  return _Shift ? (_Value << _Shift) | (_Value >> (64 - _Shift)) : _Value;
+}
+
+static __inline__ unsigned long __attribute__((__always_inline__, __nodebug__))
+_lrotr(unsigned long _Value, int _Shift) {
+  _Shift &= 0x3f;
+  return _Shift ? (_Value >> _Shift) | (_Value << (64 - _Shift)) : _Value;
+}
+#endif
+
 #endif /* __IMMINTRIN_H */

Added: cfe/trunk/test/CodeGen/x86-rot-intrinsics.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/x86-rot-intrinsics.c?rev=245923&view=auto
==
--- cfe/trunk/test/CodeGen/x86-rot-intrinsics.c (added)
+++ cfe/trunk/test

Re: [PATCH] D12271: [X86] Expose the various _rot intrinsics on non-MS platforms

2015-08-25 Thread Michael Kuperstein via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL245923: [X86] Expose the various _rot intrinsics on non-MS 
platforms (authored by mkuper).

Changed prior to commit:
  http://reviews.llvm.org/D12271?vs=32925&id=33050#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D12271

Files:
  cfe/trunk/lib/Headers/Intrin.h
  cfe/trunk/lib/Headers/immintrin.h
  cfe/trunk/test/CodeGen/x86-rot-intrinsics.c

Index: cfe/trunk/test/CodeGen/x86-rot-intrinsics.c
===
--- cfe/trunk/test/CodeGen/x86-rot-intrinsics.c
+++ cfe/trunk/test/CodeGen/x86-rot-intrinsics.c
@@ -0,0 +1,89 @@
+// RUN: %clang_cc1 %s -triple=i686-pc-linux -emit-llvm -o - | FileCheck %s 
+// RUN: %clang_cc1 -ffreestanding -fms-extensions -fms-compatibility -fms-compatibility-version=17.00 \
+// RUN:-triple i686--windows -emit-llvm %s -o - \ 
+// RUN:   | FileCheck %s -check-prefix CHECK  -check-prefix MSC
+
+// Don't include mm_malloc.h, it's system specific.
+#define __MM_MALLOC_H
+
+#ifdef _MSC_VER
+#include 
+#else
+#include 
+#endif
+
+#ifdef _MSC_VER
+unsigned char test_rotl8(unsigned char v, unsigned char s) {
+  //MSC-LABEL: test_rotl8
+  //MSC-NOT: call
+  return _rotl8(v, s);
+}
+
+unsigned char test_rotr8(unsigned char v, unsigned char s) {
+  //MSC-LABEL: test_rotr8
+  //MSC-NOT: call
+  return _rotr8(v, s);
+}
+
+unsigned short test_rotl16(unsigned short v, unsigned char s) {
+  //MSC-LABEL: test_rotl16
+  //MSC-NOT: call
+  return _rotl16(v, s);
+}
+
+unsigned short test_rotr16(unsigned short v, unsigned char s) {
+  //MSC-LABEL: test_rotr16
+  //MSC-NOT: call
+  return _rotr16(v, s);
+}
+
+unsigned __int64 test_rotl64(unsigned __int64 v, int s) {
+  //MSC-LABEL: test_rotl64
+  //MSC-NOT: call
+  return _rotl64(v, s);
+}
+
+unsigned __int64 test_rotr64(unsigned __int64 v, int s) {
+  //MSC-LABEL: test_rotr64
+  //MSC-NOT: call
+  return _rotr64(v, s);
+}
+#endif
+
+unsigned short test_rotwl(unsigned short v, unsigned short s) {
+  //CHECK-LABEL: test_rotwl
+  //CHECK-NOT: call
+  return _rotwl(v, s);
+}
+
+unsigned short test_rotwr(unsigned short v, unsigned short s) {
+  //CHECK-LABEL: test_rotwr
+  //CHECK-NOT: call
+  return _rotwr(v, s);
+}
+
+unsigned int test_rotl(unsigned int v, int s) {
+  //CHECK-LABEL: test_rotl
+  //CHECK-NOT: call
+  return _rotl(v, s);
+}
+
+unsigned int test_rotr(unsigned int v, int s) {
+  //CHECK-LABEL: test_rotr
+  //CHECK-NOT: call
+  return _rotr(v, s);
+}
+
+unsigned long test_lrotl(unsigned long v, int s) {
+  //CHECK-LABEL: test_lrotl
+  //CHECK-NOT: call
+  return _lrotl(v, s);
+}
+
+unsigned long test_lrotr(unsigned long v, int s) {
+  //CHECK-LABEL: test_lrotr
+  //CHECK-NOT: call
+  return _lrotr(v, s);
+}
+
+//CHECK-LABEL: attributes
Index: cfe/trunk/lib/Headers/immintrin.h
===
--- cfe/trunk/lib/Headers/immintrin.h
+++ cfe/trunk/lib/Headers/immintrin.h
@@ -148,4 +148,58 @@
  * whereas others are also available at all times. */
 #include 
 
+static __inline__ unsigned short __attribute__((__always_inline__, __nodebug__))
+_rotwl(unsigned short _Value, int _Shift) {
+  _Shift &= 0xf;
+  return _Shift ? (_Value << _Shift) | (_Value >> (16 - _Shift)) : _Value;
+}
+
+static __inline__ unsigned short __attribute__((__always_inline__, __nodebug__))
+_rotwr(unsigned short _Value, int _Shift) {
+  _Shift &= 0xf;
+  return _Shift ? (_Value >> _Shift) | (_Value << (16 - _Shift)) : _Value;
+}
+
+static __inline__ unsigned int __attribute__((__always_inline__, __nodebug__))
+_rotl(unsigned int _Value, int _Shift) {
+  _Shift &= 0x1f;
+  return _Shift ? (_Value << _Shift) | (_Value >> (32 - _Shift)) : _Value;
+}
+
+static __inline__ unsigned int __attribute__((__always_inline__, __nodebug__))
+_rotr(unsigned int _Value, int _Shift) {
+  _Shift &= 0x1f;
+  return _Shift ? (_Value >> _Shift) | (_Value << (32 - _Shift)) : _Value;
+}
+
+/* 
+ * MS defines _lrotl/_lrotr in a slightly incompatible way, since 
+ * unsigned long is always 32-bit in MSVC. 
+ */
+#ifdef _MSC_VER
+static __inline__ unsigned long __attribute__((__always_inline__, __nodebug__))
+_lrotl(unsigned long _Value, int _Shift) {
+  _Shift &= 0x1f;
+  return _Shift ? (_Value << _Shift) | (_Value >> (32 - _Shift)) : _Value;
+}
+
+static __inline__ unsigned long __attribute__((__always_inline__, __nodebug__))
+_lrotr(unsigned long _Value, int _Shift) {
+  _Shift &= 0x1f;
+  return _Shift ? (_Value >> _Shift) | (_Value << (32 - _Shift)) : _Value;
+}
+#else
+static __inline__ unsigned long __attribute__((__always_inline__, __nodebug__))
+_lrotl(unsigned long _Value, int _Shift) {
+  _Shift &= 0x3f;
+  return _Shift ? (_Value << _Shift) | (_Value >> (64 - _Shift)) : _Value;
+}
+
+static __inline__ unsigned long __attribute__((__always_inline__, __nodebug__))
+_lrotr(unsigned long _Value, int _Shift) {
+  _Shift &= 0x3f;
+  return _Shift ? (_Value >> _Shift) | (_Value << (64 - 

[clang-tools-extra] r245926 - Tests no longer need the 'REQUIRES: SHELL' line.

2015-08-25 Thread Angel Garcia Gomez via cfe-commits
Author: angelgarcia
Date: Tue Aug 25 03:39:34 2015
New Revision: 245926

URL: http://llvm.org/viewvc/llvm-project?rev=245926&view=rev
Log:
Tests no longer need the 'REQUIRES: SHELL' line.

Summary: Update python script, so that it doesn't print that line in new tests.

Reviewers: alexfh

Subscribers: klimek, cfe-commits

Differential Revision: http://reviews.llvm.org/D12281

Modified:
clang-tools-extra/trunk/clang-tidy/add_new_check.py

Modified: clang-tools-extra/trunk/clang-tidy/add_new_check.py
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/add_new_check.py?rev=245926&r1=245925&r2=245926&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/add_new_check.py (original)
+++ clang-tools-extra/trunk/clang-tidy/add_new_check.py Tue Aug 25 03:39:34 2015
@@ -184,7 +184,6 @@ def write_test(module_path, module, chec
   with open(filename, 'w') as f:
 f.write(
 """// RUN: %%python %%S/check_clang_tidy.py %%s %(check_name_dashes)s %%t
-// REQUIRES: shell
 
 // FIXME: Add something that triggers the check here.
 void f();


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D12244: Implement ACLE 2.0 macros of chapters 6.4 and 6.5 for [ARM] and [Aarch64] targets

2015-08-25 Thread Alexandros Lamprineas via cfe-commits
labrinea updated this revision to Diff 33054.
labrinea added a comment.

_ARM_FP16_FORMAT_IEEE and _ARM_FP16_ARGS should be defined unconditionally. 
When hardware does not support them library calls are emitted.


http://reviews.llvm.org/D12244

Files:
  lib/Basic/Targets.cpp
  test/Preprocessor/aarch64-target-features.c
  test/Preprocessor/arm-acle-6.4.c
  test/Preprocessor/arm-acle-6.5.c
  test/Preprocessor/arm-target-features.c

Index: test/Preprocessor/arm-target-features.c
===
--- test/Preprocessor/arm-target-features.c
+++ test/Preprocessor/arm-target-features.c
@@ -5,6 +5,8 @@
 // CHECK: __ARM_FEATURE_CRC32 1
 // CHECK: __ARM_FEATURE_DIRECTED_ROUNDING 1
 // CHECK: __ARM_FEATURE_NUMERIC_MAXMIN 1
+// CHECK: __ARM_FP16_ARGS 1
+// CHECK: __ARM_FP16_FORMAT_IEEE 1
 
 // RUN: %clang -target armv7a-none-linux-gnu -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-V7 %s
 // CHECK-V7: __ARMEL__ 1
Index: test/Preprocessor/arm-acle-6.5.c
===
--- test/Preprocessor/arm-acle-6.5.c
+++ test/Preprocessor/arm-acle-6.5.c
@@ -1,22 +1,92 @@
-// RUN: %clang -target arm-eabi -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-DEFAULT
+// RUN: %clang -target arm-eabi -mfpu=none -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-NO-FP
+// RUN: %clang -target armv4-eabi -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-NO-FP
+// RUN: %clang -target armv5-eabi -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-NO-FP
+// RUN: %clang -target armv6m-eabi -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-NO-FP
+// RUN: %clang -target armv7r-eabi -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-NO-FP
+// RUN: %clang -target armv7m-eabi -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-NO-FP
 
-// CHECK-DEFAULT-NOT: __ARM_FP
+// CHECK-NO-FP-NOT: __ARM_FP 0x{{.*}}
+
+// RUN: %clang -target arm-eabi -mfpu=vfpv3xd -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-SP
+// RUN: %clang -target arm-eabi -mfpu=vfpv3xd-fp16 -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-SP
+// RUN: %clang -target arm-eabi -mfpu=fpv4-sp-d16 -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-SP
+// RUN: %clang -target arm-eabi -mfpu=fpv5-sp-d16 -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-SP
+
+// CHECK-SP: __ARM_FP 0x4
 
 // RUN: %clang -target arm-eabi -mfpu=vfp -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-SP-DP
-// RUN: %clang -target arm-eabi -mfpu=vfp3 -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-SP-DP
+// RUN: %clang -target arm-eabi -mfpu=vfpv2 -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-SP-DP
+// RUN: %clang -target arm-eabi -mfpu=vfpv3 -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-SP-DP
 // RUN: %clang -target arm-eabi -mfpu=vfp3-d16 -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-SP-DP
 // RUN: %clang -target arm-eabi -mfpu=neon -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-SP-DP
-// RUN: %clang -target arm-eabi -mfpu=vfp3 -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-SP-DP
-// RUN: %clang -target armv7-eabi -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-SP-DP
+// RUN: %clang -target armv6-eabi -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-SP-DP
+// RUN: %clang -target armv7a-eabi -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-SP-DP
 
-// CHECK-SP-DP: __ARM_FP 0xC
+// CHECK-SP-DP: __ARM_FP 0xC
 
+// RUN: %clang -target arm-eabi -mfpu=vfpv3-fp16 -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-SP-DP-HP
+// RUN: %clang -target arm-eabi -mfpu=vfpv3-d16-fp16 -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-SP-DP-HP
 // RUN: %clang -target arm-eabi -mfpu=vfpv4 -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-SP-DP-HP
 // RUN: %clang -target arm-eabi -mfpu=vfpv4-d16 -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-SP-DP-HP
+// RUN: %clang -target arm-eabi -mfpu=fpv5-d16 -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-SP-DP-HP
 // RUN: %clang -target arm-eabi -mfpu=fp-armv8 -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-SP-DP-HP
+// RUN: %clang -target arm-eabi -mfpu=neon-fp16 -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-SP-DP-HP
+// RUN: %clang -target arm-eabi -mfpu=neon-vfpv4 -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-SP-DP-HP
 // RUN: %clang -target arm-eabi -mfpu=neon-fp-armv8 -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-SP-DP-HP
 // RUN: %clang -target arm-eabi -mfpu=crypto-neon-fp-armv8 -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-SP-DP-HP
 // RUN: %clang -target armv8-eabi -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-SP-DP-HP
 
 // CHECK-SP-DP-HP: __ARM_FP 0xE
 
+// RUN: %clang -target armv4-eabi -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-NO-FMA
+// RUN: %clang -target armv5-eabi -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-NO-FMA
+// RUN: %clang -target a

Re: [PATCH] D12287: Add replace-auto_ptr check.

2015-08-25 Thread Angel Garcia via cfe-commits
angelgarcia updated this revision to Diff 33055.
angelgarcia added a comment.

Add check description.


http://reviews.llvm.org/D12287

Files:
  clang-tidy/modernize/CMakeLists.txt
  clang-tidy/modernize/ModernizeTidyModule.cpp
  clang-tidy/modernize/ReplaceAutoPtrCheck.cpp
  clang-tidy/modernize/ReplaceAutoPtrCheck.h
  test/clang-tidy/Inputs/modernize-replace-auto-ptr/
  test/clang-tidy/Inputs/modernize-replace-auto-ptr/memory.h
  test/clang-tidy/modernize-replace-auto-ptr.cpp

Index: test/clang-tidy/modernize-replace-auto-ptr.cpp
===
--- /dev/null
+++ test/clang-tidy/modernize-replace-auto-ptr.cpp
@@ -0,0 +1,304 @@
+// RUN: %python %S/check_clang_tidy.py %s modernize-replace-auto-ptr %t -- \
+// RUN:   -std=c++11 -I %S/Inputs/modernize-replace-auto-ptr
+
+// CHECK-FIXES: #include 
+
+#include "memory.h"
+
+// Instrumentation for auto_ptr_ref test.
+struct Base {};
+struct Derived : Base {};
+std::auto_ptr create_derived_ptr();
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: auto_ptr is deprecated, use unique_ptr instead
+// CHECK-FIXES: std::unique_ptr create_derived_ptr();
+
+
+// Test function return values (declaration)
+std::auto_ptr f_5();
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: auto_ptr is deprecated, use unique_ptr instead
+// CHECK-FIXES: std::unique_ptr f_5()
+
+
+// Test function parameters.
+void f_6(std::auto_ptr);
+// CHECK-MESSAGES: :[[@LINE-1]]:15: warning: auto_ptr is deprecated, use unique_ptr instead
+// CHECK-FIXES: void f_6(std::unique_ptr);
+void f_7(const std::auto_ptr &);
+// CHECK-MESSAGES: :[[@LINE-1]]:21: warning: auto_ptr is deprecated, use unique_ptr instead
+// CHECK-FIXES: void f_7(const std::unique_ptr &);
+
+
+// Test on record type fields.
+struct A {
+  std::auto_ptr field;
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: auto_ptr is deprecated, use unique_ptr instead
+  // CHECK-FIXES: std::unique_ptr field;
+
+  typedef std::auto_ptr int_ptr_type;
+  // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: auto_ptr is deprecated, use unique_ptr instead
+  // CHECK-FIXES: typedef std::unique_ptr int_ptr_type;
+};
+
+
+// FIXME: Test template WITH instantiation.
+template  struct B {
+  typedef typename std::auto_ptr created_type;
+  // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: auto_ptr is deprecated, use unique_ptr instead
+  // CHECK-FIXES: typedef typename std::unique_ptr created_type;
+
+  created_type create() { return std::auto_ptr(new T()); }
+  // CHECK-MESSAGES: :[[@LINE-1]]:39: warning: auto_ptr is deprecated, use unique_ptr instead
+  // CHECK-FIXES: created_type create() { return std::unique_ptr(new T()); }
+};
+
+
+// Test 'using' in a namespace (declaration)
+namespace ns_1 {
+// Test multiple using declarations.
+  using std::auto_ptr;
+  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: auto_ptr is deprecated, use unique_ptr instead
+  // CHECK-FIXES: using std::unique_ptr;
+  using std::auto_ptr;
+  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: auto_ptr is deprecated, use unique_ptr instead
+  // CHECK-FIXES: using std::unique_ptr;
+}
+
+
+namespace ns_2 {
+template  struct auto_ptr {};
+}
+
+void f_1() {
+  std::auto_ptr a;
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: auto_ptr is deprecated, use unique_ptr instead
+  // CHECK-FIXES: std::unique_ptr a;
+
+  // Check that spaces aren't modified unnecessarily.
+  std:: auto_ptr  b;
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: auto_ptr is deprecated, use unique_ptr instead
+  // CHECK-FIXES: std:: unique_ptr  b;
+  std :: auto_ptr < char > c(new char());
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: auto_ptr is deprecated, use unique_ptr instead
+  // CHECK-FIXES: std :: unique_ptr < char > c(new char());
+
+  // Test construction from a temporary.
+  std::auto_ptr d = std::auto_ptr();
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: auto_ptr is deprecated, use unique_ptr instead
+  // CHECK-MESSAGES: :[[@LINE-2]]:32: warning: auto_ptr is deprecated, use unique_ptr instead
+  // CHECK-FIXES: std::unique_ptr d = std::unique_ptr();
+
+  typedef std::auto_ptr int_ptr_t;
+  // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: auto_ptr is deprecated, use unique_ptr instead
+  // CHECK-FIXES: typedef std::unique_ptr int_ptr_t;
+  int_ptr_t e(new int());
+
+  // Test pointers.
+  std::auto_ptr *f;
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: auto_ptr is deprecated, use unique_ptr instead
+  // CHECK-FIXES: std::unique_ptr *f;
+
+  // Test 'static' declarations.
+  static std::auto_ptr g;
+  // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: auto_ptr is deprecated, use unique_ptr instead
+  // CHECK-FIXES: static std::unique_ptr g;
+
+  // Test with cv-qualifiers.
+  const std::auto_ptr h;
+  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: auto_ptr is deprecated, use unique_ptr instead
+  // CHECK-FIXES: const std::unique_ptr h;
+  volatile std::auto_ptr i;
+  // CHECK-MESSAGES: :[[@LINE-1]]:17: warning: auto_ptr is deprecated, use unique_ptr instead
+  // CHECK-FIXES: volatile st

Re: r245923 - [X86] Expose the various _rot intrinsics on non-MS platforms

2015-08-25 Thread İsmail Dönmez via cfe-commits
Hi,

On Tue, Aug 25, 2015 at 10:21 AM, Michael Kuperstein via cfe-commits
 wrote:
> Author: mkuper
> Date: Tue Aug 25 02:21:33 2015
> New Revision: 245923
>
> URL: http://llvm.org/viewvc/llvm-project?rev=245923&view=rev
> Log:
> [X86] Expose the various _rot intrinsics on non-MS platforms
>
> _rotl, _rotwl and _lrotl (and their right-shift counterparts) are official x86
> intrinsics, and should be supported regardless of environment. This is in 
> contrast
> to _rotl8, _rotl16, and _rotl64 which are MS-specific.
>
> Note that the MS documentation for _lrotl is different from the Intel
> documentation. Intel explicitly documents it as a 64-bit rotate, while for MS,
> since sizeof(unsigned long) for MSVC is always 4, a 32-bit rotate is implied.
>
> Differential Revision: http://reviews.llvm.org/D12271
>
> Added:
> cfe/trunk/test/CodeGen/x86-rot-intrinsics.c   (with props)
> Modified:
> cfe/trunk/lib/Headers/Intrin.h
> cfe/trunk/lib/Headers/immintrin.h

This seems to break clang + mingw-w64 :

λ echo "#include " | clang -x c -target x86_64-w64-mingw32
--sysroot C:/mingw-w64-6.0.0 -
In file included from :1:
In file included from
C:/mingw-w64-6.0.0\x86_64-w64-mingw32\include\winsock2.h:23:
In file included from
C:/mingw-w64-6.0.0\x86_64-w64-mingw32\include\windows.h:69:
In file included from C:/mingw-w64-6.0.0\x86_64-w64-mingw32\include\windef.h:8:
In file included from
C:/mingw-w64-6.0.0\x86_64-w64-mingw32\include\minwindef.h:163:
In file included from
C:/mingw-w64-6.0.0\x86_64-w64-mingw32\include\winnt.h:1516:
In file included from C:\Program
Files\LLVM\bin\..\lib\clang\3.8.0\include\x86intrin.h:29:
C:\Program Files\LLVM\bin\..\lib\clang\3.8.0\include\immintrin.h:164:1:
error: static declaration of '_rotl' follows non-static declaration
_rotl(unsigned int _Value, int _Shift) {
^
C:/mingw-w64-6.0.0\x86_64-w64-mingw32\include\stdlib.h:581:24: note:
previous declaration is here
  unsigned int __cdecl _rotl(unsigned int _Val,int _Shift);
   ^
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


RE: r245923 - [X86] Expose the various _rot intrinsics on non-MS platforms

2015-08-25 Thread Kuperstein, Michael M via cfe-commits
Argh.
I'll revert, and figure out what to do with it later.
Sorry about the breakage.

Michael

-Original Message-
From: İsmail Dönmez [mailto:ism...@i10z.com] 
Sent: Tuesday, August 25, 2015 14:17
To: Kuperstein, Michael M
Cc: cfe-commits@lists.llvm.org
Subject: Re: r245923 - [X86] Expose the various _rot intrinsics on non-MS 
platforms

Hi,

On Tue, Aug 25, 2015 at 10:21 AM, Michael Kuperstein via cfe-commits 
 wrote:
> Author: mkuper
> Date: Tue Aug 25 02:21:33 2015
> New Revision: 245923
>
> URL: http://llvm.org/viewvc/llvm-project?rev=245923&view=rev
> Log:
> [X86] Expose the various _rot intrinsics on non-MS platforms
>
> _rotl, _rotwl and _lrotl (and their right-shift counterparts) are 
> official x86 intrinsics, and should be supported regardless of 
> environment. This is in contrast to _rotl8, _rotl16, and _rotl64 which are 
> MS-specific.
>
> Note that the MS documentation for _lrotl is different from the Intel 
> documentation. Intel explicitly documents it as a 64-bit rotate, while 
> for MS, since sizeof(unsigned long) for MSVC is always 4, a 32-bit rotate is 
> implied.
>
> Differential Revision: http://reviews.llvm.org/D12271
>
> Added:
> cfe/trunk/test/CodeGen/x86-rot-intrinsics.c   (with props)
> Modified:
> cfe/trunk/lib/Headers/Intrin.h
> cfe/trunk/lib/Headers/immintrin.h

This seems to break clang + mingw-w64 :

λ echo "#include " | clang -x c -target x86_64-w64-mingw32 
--sysroot C:/mingw-w64-6.0.0 - In file included from :1:
In file included from
C:/mingw-w64-6.0.0\x86_64-w64-mingw32\include\winsock2.h:23:
In file included from
C:/mingw-w64-6.0.0\x86_64-w64-mingw32\include\windows.h:69:
In file included from C:/mingw-w64-6.0.0\x86_64-w64-mingw32\include\windef.h:8:
In file included from
C:/mingw-w64-6.0.0\x86_64-w64-mingw32\include\minwindef.h:163:
In file included from
C:/mingw-w64-6.0.0\x86_64-w64-mingw32\include\winnt.h:1516:
In file included from C:\Program
Files\LLVM\bin\..\lib\clang\3.8.0\include\x86intrin.h:29:
C:\Program Files\LLVM\bin\..\lib\clang\3.8.0\include\immintrin.h:164:1:
error: static declaration of '_rotl' follows non-static declaration 
_rotl(unsigned int _Value, int _Shift) { ^
C:/mingw-w64-6.0.0\x86_64-w64-mingw32\include\stdlib.h:581:24: note:
previous declaration is here
  unsigned int __cdecl _rotl(unsigned int _Val,int _Shift);
   ^
-
Intel Israel (74) Limited

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D12134: [DEBUG INFO] Source correlation for lambda captured values.

2015-08-25 Thread Bataev, Alexey via cfe-commits
Yes, you're right, and it will be 13, 14, 15. It is implemented already 
and this patch does not break this.


Best regards,
Alexey Bataev
=
Software Engineer
Intel Compiler Team

25.08.2015 9:00, Eric Christopher пишет:

echristo added a comment.

How about:

13. [apple,
14. banana,
15. cherry]{
16. printf("apple = %d\n",apple);
17. printf("banana = %d\n",banana);
18. printf("cherry = %d\n",cherry);

Should be 13, 14, 15 yes?

-eric


http://reviews.llvm.org/D12134





___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D12134: [DEBUG INFO] Source correlation for lambda captured values.

2015-08-25 Thread Alexey Bataev via cfe-commits
ABataev added a subscriber: ABataev.
ABataev added a comment.

Yes, you're right, and it will be 13, 14, 15. It is implemented already 
and this patch does not break this.

Best regards,

Alexey Bataev
=

Software Engineer
Intel Compiler Team

25.08.2015 9:00, Eric Christopher пишет:

> echristo added a comment.

> 

> How about:

> 

> 13. [apple,

> 14. banana,

> 15. cherry]{

> 16. printf("apple = %d\n",apple);

> 17. printf("banana = %d\n",banana);

> 18. printf("cherry = %d\n",cherry);

> 

>   Should be 13, 14, 15 yes?

> 

>   -eric

> 

> http://reviews.llvm.org/D12134



http://reviews.llvm.org/D12134



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r245929 - Revert r245923 since it breaks mingw.

2015-08-25 Thread Michael Kuperstein via cfe-commits
Author: mkuper
Date: Tue Aug 25 06:42:31 2015
New Revision: 245929

URL: http://llvm.org/viewvc/llvm-project?rev=245929&view=rev
Log:
Revert r245923 since it breaks mingw.

Removed:
cfe/trunk/test/CodeGen/x86-rot-intrinsics.c
Modified:
cfe/trunk/lib/Headers/Intrin.h
cfe/trunk/lib/Headers/immintrin.h

Modified: cfe/trunk/lib/Headers/Intrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/Intrin.h?rev=245929&r1=245928&r2=245929&view=diff
==
--- cfe/trunk/lib/Headers/Intrin.h (original)
+++ cfe/trunk/lib/Headers/Intrin.h Tue Aug 25 06:42:31 2015
@@ -463,6 +463,26 @@ _rotr16(unsigned short _Value, unsigned
   _Shift &= 0xf;
   return _Shift ? (_Value >> _Shift) | (_Value << (16 - _Shift)) : _Value;
 }
+static __inline__ unsigned int __DEFAULT_FN_ATTRS
+_rotl(unsigned int _Value, int _Shift) {
+  _Shift &= 0x1f;
+  return _Shift ? (_Value << _Shift) | (_Value >> (32 - _Shift)) : _Value;
+}
+static __inline__ unsigned int __DEFAULT_FN_ATTRS
+_rotr(unsigned int _Value, int _Shift) {
+  _Shift &= 0x1f;
+  return _Shift ? (_Value >> _Shift) | (_Value << (32 - _Shift)) : _Value;
+}
+static __inline__ unsigned long __DEFAULT_FN_ATTRS
+_lrotl(unsigned long _Value, int _Shift) {
+  _Shift &= 0x1f;
+  return _Shift ? (_Value << _Shift) | (_Value >> (32 - _Shift)) : _Value;
+}
+static __inline__ unsigned long __DEFAULT_FN_ATTRS
+_lrotr(unsigned long _Value, int _Shift) {
+  _Shift &= 0x1f;
+  return _Shift ? (_Value >> _Shift) | (_Value << (32 - _Shift)) : _Value;
+}
 static
 __inline__ unsigned __int64 __DEFAULT_FN_ATTRS
 _rotl64(unsigned __int64 _Value, int _Shift) {

Modified: cfe/trunk/lib/Headers/immintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/immintrin.h?rev=245929&r1=245928&r2=245929&view=diff
==
--- cfe/trunk/lib/Headers/immintrin.h (original)
+++ cfe/trunk/lib/Headers/immintrin.h Tue Aug 25 06:42:31 2015
@@ -148,58 +148,4 @@ _writegsbase_u64(unsigned long long __V)
  * whereas others are also available at all times. */
 #include 
 
-static __inline__ unsigned short __attribute__((__always_inline__, 
__nodebug__))
-_rotwl(unsigned short _Value, int _Shift) {
-  _Shift &= 0xf;
-  return _Shift ? (_Value << _Shift) | (_Value >> (16 - _Shift)) : _Value;
-}
-
-static __inline__ unsigned short __attribute__((__always_inline__, 
__nodebug__))
-_rotwr(unsigned short _Value, int _Shift) {
-  _Shift &= 0xf;
-  return _Shift ? (_Value >> _Shift) | (_Value << (16 - _Shift)) : _Value;
-}
-
-static __inline__ unsigned int __attribute__((__always_inline__, __nodebug__))
-_rotl(unsigned int _Value, int _Shift) {
-  _Shift &= 0x1f;
-  return _Shift ? (_Value << _Shift) | (_Value >> (32 - _Shift)) : _Value;
-}
-
-static __inline__ unsigned int __attribute__((__always_inline__, __nodebug__))
-_rotr(unsigned int _Value, int _Shift) {
-  _Shift &= 0x1f;
-  return _Shift ? (_Value >> _Shift) | (_Value << (32 - _Shift)) : _Value;
-}
-
-/* 
- * MS defines _lrotl/_lrotr in a slightly incompatible way, since 
- * unsigned long is always 32-bit in MSVC. 
- */
-#ifdef _MSC_VER
-static __inline__ unsigned long __attribute__((__always_inline__, __nodebug__))
-_lrotl(unsigned long _Value, int _Shift) {
-  _Shift &= 0x1f;
-  return _Shift ? (_Value << _Shift) | (_Value >> (32 - _Shift)) : _Value;
-}
-
-static __inline__ unsigned long __attribute__((__always_inline__, __nodebug__))
-_lrotr(unsigned long _Value, int _Shift) {
-  _Shift &= 0x1f;
-  return _Shift ? (_Value >> _Shift) | (_Value << (32 - _Shift)) : _Value;
-}
-#else
-static __inline__ unsigned long __attribute__((__always_inline__, __nodebug__))
-_lrotl(unsigned long _Value, int _Shift) {
-  _Shift &= 0x3f;
-  return _Shift ? (_Value << _Shift) | (_Value >> (64 - _Shift)) : _Value;
-}
-
-static __inline__ unsigned long __attribute__((__always_inline__, __nodebug__))
-_lrotr(unsigned long _Value, int _Shift) {
-  _Shift &= 0x3f;
-  return _Shift ? (_Value >> _Shift) | (_Value << (64 - _Shift)) : _Value;
-}
-#endif
-
 #endif /* __IMMINTRIN_H */

Removed: cfe/trunk/test/CodeGen/x86-rot-intrinsics.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/x86-rot-intrinsics.c?rev=245928&view=auto
==
--- cfe/trunk/test/CodeGen/x86-rot-intrinsics.c (original)
+++ cfe/trunk/test/CodeGen/x86-rot-intrinsics.c (removed)
@@ -1,89 +0,0 @@
-// RUN: %clang_cc1 %s -triple=i686-pc-linux -emit-llvm -o - | FileCheck %s 
-// RUN: %clang_cc1 -ffreestanding -fms-extensions -fms-compatibility 
-fms-compatibility-version=17.00 \
-// RUN:-triple i686--windows -emit-llvm %s -o - \ 
-// RUN:   | FileCheck %s -check-prefix CHECK  -check-prefix MSC
-
-// Don't include mm_malloc.h, it's system specific.
-#define __MM_MALLOC_H
-
-#ifdef _MSC_VER
-#include 
-#else
-#include 
-#endif
-
-#ifdef _MSC_VER
-unsigned ch

Re: [PATCH] D12301: [PATCH] New checker for UB in handler of a function-try-block

2015-08-25 Thread Aaron Ballman via cfe-commits
On Mon, Aug 24, 2015 at 7:42 PM, Richard Smith  wrote:
> On Mon, Aug 24, 2015 at 3:36 PM, Aaron Ballman 
> wrote:
>>
>> On Mon, Aug 24, 2015 at 6:29 PM, Richard Smith 
>> wrote:
>> > On Mon, Aug 24, 2015 at 3:23 PM, Aaron Ballman 
>> > wrote:
>> >>
>> >> aaron.ballman created this revision.
>> >> aaron.ballman added reviewers: alexfh, rsmith.
>> >> aaron.ballman added a subscriber: cfe-commits.
>> >>
>> >> Per [except.handle]p10, the handler for a constructor or destructor
>> >> function-try-block cannot refer to a non-static member of the object
>> >> under
>> >> construction. This patch adds a new clang-tidy check that warns the
>> >> user
>> >> when they've hit this undefined behavior.
>> >>
>> >> Due to how infrequent function-try-blocks appear on constructors and
>> >> destructors in the wild compared to how often member expressions are
>> >> encountered, I felt this was more appropriate as a clang-tidy check
>> >> than as
>> >> a semantic warning. I was concerned with efficiency of checking whether
>> >> an
>> >> arbitrary member expression was referring to the object under
>> >> construction/destruction within the function-try-block catch handler
>> >> scope.
>> >
>> >
>> > Seems like this would be very cheap to check in the case where the
>> > object
>> > expression is an implicit or explicit CXXThisExpr. It'd be good to have
>> > a
>> > frontend warning for that case.
>>
>> Are you thinking the check would likely in BuildMemberReferenceExpr()
>> and I would just have to look at the current scope to determine
>> whether it's a function-try-block catch handler?
>
>
> Yes, somewhere around there. You might need to wire a Scope* though a couple
> of layers though.
>
>>
>> When I looked into
>> doing a frontend warning for this, I seemed to struggle with figuring
>> out specifically that I was in the catch handler of a
>> function-try-block of a constructor or destructor.
>
>
> Looks like there's no better method than walking up the Scope stack until
> you hit a scope with the FnTryCatchScope flag (or leave the function),
> currently.

That only tells you that you're in a function-try-block, not that
you're within the handler of a function-try-block, doesn't it? So to
implement this, it seems like I'd have to:

1) Thread a Scope * through to BuildMemberReferenceExpr()
2) Update the Scope class to have both FnTryScope, FnCatchScope, and
FnTryCatchScope (that's a bitwise OR of FnTryScope and FnCatchScope)
3) Update the parser to create the proper Scope type for a
function-try-block's handler
4) Implement the actual warning

I *think* that should about cover it.

~Aaron
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D12287: Add replace-auto_ptr check.

2015-08-25 Thread Alexander Kornienko via cfe-commits
alexfh accepted this revision.
alexfh added a comment.
This revision is now accepted and ready to land.

Looks good with one nit.

Thank you!



Comment at: test/clang-tidy/modernize-replace-auto-ptr.cpp:12
@@ +11,3 @@
+std::auto_ptr create_derived_ptr();
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: auto_ptr is deprecated, use 
unique_ptr instead
+// CHECK-FIXES: std::unique_ptr create_derived_ptr();

Please use the full message including the [check-name] once. Please also 
truncate all other patterns after `deprecated,` to make them fit 80 columns.


http://reviews.llvm.org/D12287



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D12287: Add replace-auto_ptr check.

2015-08-25 Thread Angel Garcia via cfe-commits
angelgarcia updated this revision to Diff 33066.
angelgarcia added a comment.

Use the full message once in the test, and truncate all the other patterns.


http://reviews.llvm.org/D12287

Files:
  clang-tidy/modernize/CMakeLists.txt
  clang-tidy/modernize/ModernizeTidyModule.cpp
  clang-tidy/modernize/ReplaceAutoPtrCheck.cpp
  clang-tidy/modernize/ReplaceAutoPtrCheck.h
  test/clang-tidy/Inputs/modernize-replace-auto-ptr/
  test/clang-tidy/Inputs/modernize-replace-auto-ptr/memory.h
  test/clang-tidy/modernize-replace-auto-ptr.cpp

Index: test/clang-tidy/modernize-replace-auto-ptr.cpp
===
--- /dev/null
+++ test/clang-tidy/modernize-replace-auto-ptr.cpp
@@ -0,0 +1,304 @@
+// RUN: %python %S/check_clang_tidy.py %s modernize-replace-auto-ptr %t -- \
+// RUN:   -std=c++11 -I %S/Inputs/modernize-replace-auto-ptr
+
+// CHECK-FIXES: #include 
+
+#include "memory.h"
+
+// Instrumentation for auto_ptr_ref test.
+struct Base {};
+struct Derived : Base {};
+std::auto_ptr create_derived_ptr();
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: auto_ptr is deprecated, use unique_ptr instead [modernize-replace-auto-ptr]
+// CHECK-FIXES: std::unique_ptr create_derived_ptr();
+
+
+// Test function return values (declaration)
+std::auto_ptr f_5();
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: auto_ptr is deprecated
+// CHECK-FIXES: std::unique_ptr f_5()
+
+
+// Test function parameters.
+void f_6(std::auto_ptr);
+// CHECK-MESSAGES: :[[@LINE-1]]:15: warning: auto_ptr is deprecated
+// CHECK-FIXES: void f_6(std::unique_ptr);
+void f_7(const std::auto_ptr &);
+// CHECK-MESSAGES: :[[@LINE-1]]:21: warning: auto_ptr is deprecated
+// CHECK-FIXES: void f_7(const std::unique_ptr &);
+
+
+// Test on record type fields.
+struct A {
+  std::auto_ptr field;
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: auto_ptr is deprecated
+  // CHECK-FIXES: std::unique_ptr field;
+
+  typedef std::auto_ptr int_ptr_type;
+  // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: auto_ptr is deprecated
+  // CHECK-FIXES: typedef std::unique_ptr int_ptr_type;
+};
+
+
+// FIXME: Test template WITH instantiation.
+template  struct B {
+  typedef typename std::auto_ptr created_type;
+  // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: auto_ptr is deprecated
+  // CHECK-FIXES: typedef typename std::unique_ptr created_type;
+
+  created_type create() { return std::auto_ptr(new T()); }
+  // CHECK-MESSAGES: :[[@LINE-1]]:39: warning: auto_ptr is deprecated
+  // CHECK-FIXES: created_type create() { return std::unique_ptr(new T()); }
+};
+
+
+// Test 'using' in a namespace (declaration)
+namespace ns_1 {
+// Test multiple using declarations.
+  using std::auto_ptr;
+  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: auto_ptr is deprecated
+  // CHECK-FIXES: using std::unique_ptr;
+  using std::auto_ptr;
+  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: auto_ptr is deprecated
+  // CHECK-FIXES: using std::unique_ptr;
+}
+
+
+namespace ns_2 {
+template  struct auto_ptr {};
+}
+
+void f_1() {
+  std::auto_ptr a;
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: auto_ptr is deprecated
+  // CHECK-FIXES: std::unique_ptr a;
+
+  // Check that spaces aren't modified unnecessarily.
+  std:: auto_ptr  b;
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: auto_ptr is deprecated
+  // CHECK-FIXES: std:: unique_ptr  b;
+  std :: auto_ptr < char > c(new char());
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: auto_ptr is deprecated
+  // CHECK-FIXES: std :: unique_ptr < char > c(new char());
+
+  // Test construction from a temporary.
+  std::auto_ptr d = std::auto_ptr();
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: auto_ptr is deprecated
+  // CHECK-MESSAGES: :[[@LINE-2]]:32: warning: auto_ptr is deprecated
+  // CHECK-FIXES: std::unique_ptr d = std::unique_ptr();
+
+  typedef std::auto_ptr int_ptr_t;
+  // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: auto_ptr is deprecated
+  // CHECK-FIXES: typedef std::unique_ptr int_ptr_t;
+  int_ptr_t e(new int());
+
+  // Test pointers.
+  std::auto_ptr *f;
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: auto_ptr is deprecated
+  // CHECK-FIXES: std::unique_ptr *f;
+
+  // Test 'static' declarations.
+  static std::auto_ptr g;
+  // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: auto_ptr is deprecated
+  // CHECK-FIXES: static std::unique_ptr g;
+
+  // Test with cv-qualifiers.
+  const std::auto_ptr h;
+  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: auto_ptr is deprecated
+  // CHECK-FIXES: const std::unique_ptr h;
+  volatile std::auto_ptr i;
+  // CHECK-MESSAGES: :[[@LINE-1]]:17: warning: auto_ptr is deprecated
+  // CHECK-FIXES: volatile std::unique_ptr i;
+  const volatile std::auto_ptr j;
+  // CHECK-MESSAGES: :[[@LINE-1]]:23: warning: auto_ptr is deprecated
+  // CHECK-FIXES: const volatile std::unique_ptr j;
+
+  // Test auto and initializer-list.
+  auto k = std::auto_ptr{};
+  // CHECK-MESSAGES: :[[@LINE-1]]:17: warning: auto_ptr is deprecated
+  // CHECK-FIXES: auto k = std::unique_ptr{};
+  std::aut

[clang-tools-extra] r245933 - Add replace-auto_ptr check.

2015-08-25 Thread Angel Garcia Gomez via cfe-commits
Author: angelgarcia
Date: Tue Aug 25 08:03:43 2015
New Revision: 245933

URL: http://llvm.org/viewvc/llvm-project?rev=245933&view=rev
Log:
Add replace-auto_ptr check.

Summary: Migrate replace-auto_ptr check from clang-modernize to modernize 
module in clang-tidy.

Reviewers: alexfh

Subscribers: klimek, cfe-commits

Differential Revision: http://reviews.llvm.org/D12287

Added:
clang-tools-extra/trunk/clang-tidy/modernize/ReplaceAutoPtrCheck.cpp
clang-tools-extra/trunk/clang-tidy/modernize/ReplaceAutoPtrCheck.h
clang-tools-extra/trunk/test/clang-tidy/Inputs/modernize-replace-auto-ptr/

clang-tools-extra/trunk/test/clang-tidy/Inputs/modernize-replace-auto-ptr/memory.h
clang-tools-extra/trunk/test/clang-tidy/modernize-replace-auto-ptr.cpp
Modified:
clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt
clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp

Modified: clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt?rev=245933&r1=245932&r2=245933&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt Tue Aug 25 
08:03:43 2015
@@ -5,6 +5,7 @@ add_clang_library(clangTidyModernizeModu
   LoopConvertUtils.cpp
   ModernizeTidyModule.cpp
   PassByValueCheck.cpp
+  ReplaceAutoPtrCheck.cpp
   UseAutoCheck.cpp
   UseNullptrCheck.cpp
 

Modified: clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp?rev=245933&r1=245932&r2=245933&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp Tue 
Aug 25 08:03:43 2015
@@ -12,6 +12,7 @@
 #include "../ClangTidyModuleRegistry.h"
 #include "LoopConvertCheck.h"
 #include "PassByValueCheck.h"
+#include "ReplaceAutoPtrCheck.h"
 #include "UseAutoCheck.h"
 #include "UseNullptrCheck.h"
 
@@ -26,6 +27,8 @@ public:
   void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
 CheckFactories.registerCheck("modernize-loop-convert");
 CheckFactories.registerCheck("modernize-pass-by-value");
+CheckFactories.registerCheck(
+"modernize-replace-auto-ptr");
 CheckFactories.registerCheck("modernize-use-auto");
 CheckFactories.registerCheck("modernize-use-nullptr");
   }
@@ -35,6 +38,7 @@ public:
 auto &Opts = Options.CheckOptions;
 Opts["modernize-loop-convert.MinConfidence"] = "reasonable";
 Opts["modernize-pass-by-value.IncludeStyle"] = "llvm"; // Also: "google".
+Opts["modernize-replace-auto-ptr.IncludeStyle"] = "llvm"; // Also: 
"google".
 
 // Comma-separated list of macros that behave like NULL.
 Opts["modernize-use-nullptr.NullMacros"] = "NULL";

Added: clang-tools-extra/trunk/clang-tidy/modernize/ReplaceAutoPtrCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/ReplaceAutoPtrCheck.cpp?rev=245933&view=auto
==
--- clang-tools-extra/trunk/clang-tidy/modernize/ReplaceAutoPtrCheck.cpp (added)
+++ clang-tools-extra/trunk/clang-tidy/modernize/ReplaceAutoPtrCheck.cpp Tue 
Aug 25 08:03:43 2015
@@ -0,0 +1,262 @@
+//===--- ReplaceAutoPtrCheck.cpp - 
clang-tidy--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "ReplaceAutoPtrCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Frontend/CompilerInstance.h"
+#include "clang/Lex/Lexer.h"
+#include "clang/Lex/Preprocessor.h"
+
+using namespace clang;
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace modernize {
+
+const char AutoPtrTokenId[] = "AutoPrTokenId";
+const char AutoPtrOwnershipTransferId[] = "AutoPtrOwnershipTransferId";
+
+/// \brief Matches expressions that are lvalues.
+///
+/// In the following example, a[0] matches expr(isLValue()):
+/// \code
+///   std::string a[2];
+///   std::string b;
+///   b = a[0];
+///   b = "this string won't match";
+/// \endcode
+AST_MATCHER(Expr, isLValue) { return Node.getValueKind() == VK_LValue; }
+
+/// Matches declarations whose declaration context is the C++ standard library
+/// namespace std.
+///
+/// Note that inline namespaces are silently ignored during the lookup since
+/// both libstdc++ and libc++ are known to use them fo

Re: [PATCH] D11361: [OpenMP] Target directive host codegen

2015-08-25 Thread Alexey Bataev via cfe-commits
ABataev added a comment.

Samuel, Yes, I thought about different files and different classes. Runtime for 
offloading codegen is not a part of libomp and it would be good to have 
separate runtime handler class for target codegen also. We need to think about 
it in future.



Comment at: lib/CodeGen/CGOpenMPRuntime.h:188-203
@@ -179,2 +187,18 @@
   };
+
+  /// \brief Values for bit flags used to specify the mapping type for
+  /// offloading.
+  enum OpenMPOffloadMappingFlags {
+/// \brief Allocate memory on the device and move data from host to device.
+OMP_MAP_TO = 0x01,
+/// \brief Allocate memory on the device and move data from device to host.
+OMP_MAP_FROM = 0x02,
+  };
+
+  enum OpenMPOffloadingReservedDeviceIDs {
+/// \brief Device ID if the device was not defined, runtime should get it
+/// from environment variables in the spec.
+OMP_DEVICEID_UNDEF = -1,
+  };
+
   CodeGenModule &CGM;

Move them to .cpp file.


Comment at: lib/CodeGen/CGOpenMPRuntime.h:761
@@ -714,2 +760,2 @@
 
 #endif

sfantao wrote:
> Unlike the other enums, more than one map types need to be combined. E.g., 
> to/from are two different enums. Once the map clause and 4.1 get to be 
> support, we will have more combinations. I see two options here: add enums 
> for all combinations or use a typedef each time an ineger refer to map types, 
> so the code is more readable. Let me know your thoughts. 
Yes, I think we need to add separate enums for different combination in 
Basic/OpenMPKinds.{def, h} for AST. In runtime support library we can represent 
these combinations as a bit-or of single mapping types.



http://reviews.llvm.org/D11361



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D12301: [PATCH] New checker for UB in handler of a function-try-block

2015-08-25 Thread Aaron Ballman via cfe-commits
On Tue, Aug 25, 2015 at 8:05 AM, Aaron Ballman  wrote:
> On Mon, Aug 24, 2015 at 7:42 PM, Richard Smith  wrote:
>> On Mon, Aug 24, 2015 at 3:36 PM, Aaron Ballman 
>> wrote:
>>>
>>> On Mon, Aug 24, 2015 at 6:29 PM, Richard Smith 
>>> wrote:
>>> > On Mon, Aug 24, 2015 at 3:23 PM, Aaron Ballman 
>>> > wrote:
>>> >>
>>> >> aaron.ballman created this revision.
>>> >> aaron.ballman added reviewers: alexfh, rsmith.
>>> >> aaron.ballman added a subscriber: cfe-commits.
>>> >>
>>> >> Per [except.handle]p10, the handler for a constructor or destructor
>>> >> function-try-block cannot refer to a non-static member of the object
>>> >> under
>>> >> construction. This patch adds a new clang-tidy check that warns the
>>> >> user
>>> >> when they've hit this undefined behavior.
>>> >>
>>> >> Due to how infrequent function-try-blocks appear on constructors and
>>> >> destructors in the wild compared to how often member expressions are
>>> >> encountered, I felt this was more appropriate as a clang-tidy check
>>> >> than as
>>> >> a semantic warning. I was concerned with efficiency of checking whether
>>> >> an
>>> >> arbitrary member expression was referring to the object under
>>> >> construction/destruction within the function-try-block catch handler
>>> >> scope.
>>> >
>>> >
>>> > Seems like this would be very cheap to check in the case where the
>>> > object
>>> > expression is an implicit or explicit CXXThisExpr. It'd be good to have
>>> > a
>>> > frontend warning for that case.
>>>
>>> Are you thinking the check would likely in BuildMemberReferenceExpr()
>>> and I would just have to look at the current scope to determine
>>> whether it's a function-try-block catch handler?
>>
>>
>> Yes, somewhere around there. You might need to wire a Scope* though a couple
>> of layers though.
>>
>>>
>>> When I looked into
>>> doing a frontend warning for this, I seemed to struggle with figuring
>>> out specifically that I was in the catch handler of a
>>> function-try-block of a constructor or destructor.
>>
>>
>> Looks like there's no better method than walking up the Scope stack until
>> you hit a scope with the FnTryCatchScope flag (or leave the function),
>> currently.
>
> That only tells you that you're in a function-try-block, not that
> you're within the handler of a function-try-block, doesn't it? So to
> implement this, it seems like I'd have to:
>
> 1) Thread a Scope * through to BuildMemberReferenceExpr()
> 2) Update the Scope class to have both FnTryScope, FnCatchScope, and
> FnTryCatchScope (that's a bitwise OR of FnTryScope and FnCatchScope)

Ah, perhaps I don't have to do this step. It seems that I should be
able to look for FnTryCatchScope & TryScope to determine if it is a
function-try-block try scope or not.

~Aaron

> 3) Update the parser to create the proper Scope type for a
> function-try-block's handler
> 4) Implement the actual warning
>
> I *think* that should about cover it.
>
> ~Aaron
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r245934 - clang-format: Add space before member function reference qualifiers.

2015-08-25 Thread Daniel Jasper via cfe-commits
Author: djasper
Date: Tue Aug 25 08:40:51 2015
New Revision: 245934

URL: http://llvm.org/viewvc/llvm-project?rev=245934&view=rev
Log:
clang-format: Add space before member function reference qualifiers.

Before:
  SomeType MemberFunction(const Deleted &)&;

After:
  SomeType MemberFunction(const Deleted &) &;

Seems to be much more common.

Modified:
cfe/trunk/lib/Format/TokenAnnotator.cpp
cfe/trunk/unittests/Format/FormatTest.cpp

Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=245934&r1=245933&r2=245934&view=diff
==
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Tue Aug 25 08:40:51 2015
@@ -1050,7 +1050,8 @@ private:
 PreviousNotConst->MatchingParen->Previous->is(tok::kw_decltype))
   return true;
 
-return (!IsPPKeyword && PreviousNotConst->is(tok::identifier)) ||
+return (!IsPPKeyword &&
+PreviousNotConst->isOneOf(tok::identifier, tok::kw_auto)) ||
PreviousNotConst->is(TT_PointerOrReference) ||
PreviousNotConst->isSimpleTypeSpecifier();
   }
@@ -1842,11 +1843,10 @@ bool TokenAnnotator::spaceRequiredBetwee
   if (Left.is(tok::l_square) && Right.is(tok::amp))
 return false;
   if (Right.is(TT_PointerOrReference))
-return !(Left.is(tok::r_paren) && Left.MatchingParen &&
- (Left.MatchingParen->is(TT_OverloadedOperatorLParen) ||
-  (Left.MatchingParen->Previous &&
-   Left.MatchingParen->Previous->is(
-   TT_FunctionDeclarationName &&
+return (Left.is(tok::r_paren) && Left.MatchingParen &&
+(Left.MatchingParen->is(TT_OverloadedOperatorLParen) ||
+ (Left.MatchingParen->Previous &&
+  Left.MatchingParen->Previous->is(TT_FunctionDeclarationName 
||
(Left.Tok.isLiteral() ||
 (!Left.isOneOf(TT_PointerOrReference, tok::l_paren) &&
  (Style.PointerAlignment != FormatStyle::PAS_Left ||

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=245934&r1=245933&r2=245934&view=diff
==
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Tue Aug 25 08:40:51 2015
@@ -5320,36 +5320,39 @@ TEST_F(FormatTest, UnderstandsOverloaded
 }
 
 TEST_F(FormatTest, UnderstandsFunctionRefQualification) {
-  verifyFormat("Deleted &operator=(const Deleted &)& = default;");
-  verifyFormat("Deleted &operator=(const Deleted &)&& = delete;");
-  verifyFormat("SomeType MemberFunction(const Deleted &)& = delete;");
-  verifyFormat("SomeType MemberFunction(const Deleted &)&& = delete;");
-  verifyFormat("Deleted &operator=(const Deleted &)&;");
-  verifyFormat("Deleted &operator=(const Deleted &)&&;");
-  verifyFormat("SomeType MemberFunction(const Deleted &)&;");
-  verifyFormat("SomeType MemberFunction(const Deleted &)&&;");
-  verifyFormat("SomeType MemberFunction(const Deleted &)&& {}");
-  verifyFormat("SomeType MemberFunction(const Deleted &)&& final {}");
-  verifyFormat("SomeType MemberFunction(const Deleted &)&& override {}");
-
-  verifyGoogleFormat("Deleted& operator=(const Deleted&)& = default;");
-  verifyGoogleFormat("SomeType MemberFunction(const Deleted&)& = delete;");
-  verifyGoogleFormat("Deleted& operator=(const Deleted&)&;");
-  verifyGoogleFormat("SomeType MemberFunction(const Deleted&)&;");
+  verifyFormat("Deleted &operator=(const Deleted &) & = default;");
+  verifyFormat("Deleted &operator=(const Deleted &) && = delete;");
+  verifyFormat("SomeType MemberFunction(const Deleted &) & = delete;");
+  verifyFormat("SomeType MemberFunction(const Deleted &) && = delete;");
+  verifyFormat("Deleted &operator=(const Deleted &) &;");
+  verifyFormat("Deleted &operator=(const Deleted &) &&;");
+  verifyFormat("SomeType MemberFunction(const Deleted &) &;");
+  verifyFormat("SomeType MemberFunction(const Deleted &) &&;");
+  verifyFormat("SomeType MemberFunction(const Deleted &) && {}");
+  verifyFormat("SomeType MemberFunction(const Deleted &) && final {}");
+  verifyFormat("SomeType MemberFunction(const Deleted &) && override {}");
+
+  FormatStyle AlignLeft = getLLVMStyle();
+  AlignLeft.PointerAlignment = FormatStyle::PAS_Left;
+  verifyFormat("Deleted& operator=(const Deleted&) & = default;", AlignLeft);
+  verifyFormat("SomeType MemberFunction(const Deleted&) & = delete;",
+   AlignLeft);
+  verifyFormat("Deleted& operator=(const Deleted&) &;", AlignLeft);
+  verifyFormat("SomeType MemberFunction(const Deleted&) &;", AlignLeft);
 
   FormatStyle Spaces = getLLVMStyle();
   Spaces.SpacesInCStyleCastParentheses = true;
-  verifyFormat("Deleted &operator=(const Deleted &)& = default;", Spaces

r245935 - Extract handling of user defined features into a function so we can

2015-08-25 Thread Eric Christopher via cfe-commits
Author: echristo
Date: Tue Aug 25 08:45:24 2015
New Revision: 245935

URL: http://llvm.org/viewvc/llvm-project?rev=245935&view=rev
Log:
Extract handling of user defined features into a function so we can
specialize it on the targets.

Modified:
cfe/trunk/include/clang/Basic/TargetInfo.h
cfe/trunk/lib/Basic/Targets.cpp

Modified: cfe/trunk/include/clang/Basic/TargetInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TargetInfo.h?rev=245935&r1=245934&r2=245935&view=diff
==
--- cfe/trunk/include/clang/Basic/TargetInfo.h (original)
+++ cfe/trunk/include/clang/Basic/TargetInfo.h Tue Aug 25 08:45:24 2015
@@ -797,6 +797,22 @@ public:
 Features[Name] = Enabled;
   }
 
+  /// \brief Add user defined features to the feature set while
+  /// possibly diagnosing incompatibilities.
+  ///
+  /// \return False on error.
+  virtual bool handleUserFeatures(llvm::StringMap &Features,
+ std::vector &UserFeatures,
+ DiagnosticsEngine &Diags) {
+for (const auto &F : UserFeatures) {
+  const char *Name = F.c_str();
+  // Apply the feature via the target.
+  bool Enabled = Name[0] == '+';
+  setFeatureEnabled(Features, Name + 1, Enabled);
+}
+return true;
+  }
+
   /// \brief Perform initialization based on the user configured
   /// set of features (e.g., +sse4).
   ///

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=245935&r1=245934&r2=245935&view=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Tue Aug 25 08:45:24 2015
@@ -7565,12 +7565,8 @@ TargetInfo::CreateTargetInfo(Diagnostics
   Target->initDefaultFeatures(Features);
 
   // Apply the user specified deltas.
-  for (const auto &F : Opts->FeaturesAsWritten) {
-const char *Name = F.c_str();
-// Apply the feature via the target.
-bool Enabled = Name[0] == '+';
-Target->setFeatureEnabled(Features, Name + 1, Enabled);
-  }
+  if (!Target->handleUserFeatures(Features, Opts->FeaturesAsWritten, Diags))
+  return nullptr;
 
   // Add the features to the compile options.
   //


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r245936 - Rewrite the PPC target feature handling to more resemble other targets.

2015-08-25 Thread Eric Christopher via cfe-commits
Author: echristo
Date: Tue Aug 25 08:45:28 2015
New Revision: 245936

URL: http://llvm.org/viewvc/llvm-project?rev=245936&view=rev
Log:
Rewrite the PPC target feature handling to more resemble other targets.

This involved specializing handleUserFeatures so that we could perform
diagnostics on -only- user supplied features and migrating the rest of
the initialization functions to set features based on enabling and disabling
full feature sets. No functional change intended.

Modified:
cfe/trunk/lib/Basic/Targets.cpp

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=245936&r1=245935&r2=245936&view=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Tue Aug 25 08:45:28 2015
@@ -867,6 +867,9 @@ public:
 
   bool handleTargetFeatures(std::vector &Features,
 DiagnosticsEngine &Diags) override;
+  bool handleUserFeatures(llvm::StringMap &Features,
+  std::vector &UserFeatures,
+  DiagnosticsEngine &Diags) override;
   bool hasFeature(StringRef Feature) const override;
   void setFeatureEnabled(llvm::StringMap &Features, StringRef Name,
  bool Enabled) const override;
@@ -1071,26 +1074,41 @@ bool PPCTargetInfo::handleTargetFeatures
 // all.
   }
 
+  return true;
+}
+
+bool PPCTargetInfo::handleUserFeatures(llvm::StringMap &Features,
+   std::vector &UserFeatures,
+   DiagnosticsEngine &Diags) {
+
   // Handle explicit options being passed to the compiler here: if we've
   // explicitly turned off vsx and turned on power8-vector or direct-move then
   // go ahead and error since the customer has expressed a somewhat 
incompatible
   // set of options.
-  if (std::find(Features.begin(), Features.end(), "-vsx") != Features.end()) {
-if (std::find(Features.begin(), Features.end(), "+power8-vector") !=
-Features.end()) {
+  if (std::find(UserFeatures.begin(), UserFeatures.end(), "-vsx") !=
+  UserFeatures.end()) {
+if (std::find(UserFeatures.begin(), UserFeatures.end(), "+power8-vector") 
!=
+UserFeatures.end()) {
   Diags.Report(diag::err_opt_not_valid_with_opt) << "-mpower8-vector"
  << "-mno-vsx";
   return false;
 }
 
-if (std::find(Features.begin(), Features.end(), "+direct-move") !=
-Features.end()) {
+if (std::find(UserFeatures.begin(), UserFeatures.end(), "+direct-move") !=
+UserFeatures.end()) {
   Diags.Report(diag::err_opt_not_valid_with_opt) << "-mdirect-move"
  << "-mno-vsx";
   return false;
 }
   }
 
+  for (const auto &F : UserFeatures) {
+const char *Name = F.c_str();
+// Apply the feature via the target.
+bool Enabled = Name[0] == '+';
+setFeatureEnabled(Features, Name + 1, Enabled);
+  }
+
   return true;
 }
 
@@ -1332,37 +1350,29 @@ bool PPCTargetInfo::hasFeature(StringRef
 .Default(false);
 }
 
-/*  There is no clear way for the target to know which of the features in the
-final feature vector came from defaults and which are actually specified by
-the user. To that end, we use the fact that this function is not called on
-default features - only user specified ones. By the first time this
-function is called, the default features are populated.
-We then keep track of the features that the user specified so that we
-can ensure we do not override a user's request (only defaults).
-For example:
--mcpu=pwr8 -mno-vsx (should disable vsx and everything that depends on it)
--mcpu=pwr8 -mdirect-move -mno-vsx (should actually be diagnosed)
-
-NOTE: Do not call this from PPCTargetInfo::initDefaultFeatures
-*/
 void PPCTargetInfo::setFeatureEnabled(llvm::StringMap &Features,
   StringRef Name, bool Enabled) const {
-  static llvm::StringMap ExplicitFeatures;
-  ExplicitFeatures[Name] = Enabled;
-
-  // At this point, -mno-vsx turns off the dependent features but we respect
-  // the user's requests.
-  if (!Enabled && Name == "vsx") {
-Features["direct-move"] = ExplicitFeatures["direct-move"];
-Features["power8-vector"] = ExplicitFeatures["power8-vector"];
-  }
-  if ((Enabled && Name == "power8-vector") ||
-  (Enabled && Name == "direct-move")) {
-if (ExplicitFeatures.find("vsx") == ExplicitFeatures.end()) {
-  Features["vsx"] = true;
+  // If we're enabling direct-move or power8-vector go ahead and enable vsx
+  // as well. Do the inverse if we're disabling vsx. We'll diagnose any user
+  // incompatible options.
+  if (Enabled) {
+if (Name == "vsx") {
+ Features[Name] = true;
+} else if (Name == "direct-move") {
+  Features[Name] = Features["v

Re: r245843 - clang-format: Make formatting of member function reference qualifiers

2015-08-25 Thread Daniel Jasper via cfe-commits
Changed in r245934.

On Mon, Aug 24, 2015 at 5:48 PM, Daniel Jasper  wrote:

>
>
> On Mon, Aug 24, 2015 at 5:46 PM, David Blaikie  wrote:
>
>>
>>
>> On Mon, Aug 24, 2015 at 7:28 AM, Daniel Jasper via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> Author: djasper
>>> Date: Mon Aug 24 09:28:08 2015
>>> New Revision: 245843
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=245843&view=rev
>>> Log:
>>> clang-format: Make formatting of member function reference qualifiers
>>> more consistent.
>>>
>>> Before:
>>>   SomeType MemberFunction(const Deleted &)&&;
>>>   SomeType MemberFunction(const Deleted &) && { ... }
>>>
>>> After:
>>>   SomeType MemberFunction(const Deleted &)&&;
>>>   SomeType MemberFunction(const Deleted &)&& { ... }
>>>
>>
>> I don't think that's the way most people write them - at least I tend to
>> write them with a space after the ')'? (for both rvalue and lvalue ref)
>> same way I would with 'const'.
>>
>> Any sense of how this is usually done (across LLVM or other codebases)?
>>
>
> You are probably right. But making this consistent is a good step either
> way ;-). I'll follow up with another commit ..
>
>
>>
>>
>>>
>>> Modified:
>>> cfe/trunk/lib/Format/FormatToken.h
>>> cfe/trunk/lib/Format/TokenAnnotator.cpp
>>> cfe/trunk/unittests/Format/FormatTest.cpp
>>>
>>> Modified: cfe/trunk/lib/Format/FormatToken.h
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/FormatToken.h?rev=245843&r1=245842&r2=245843&view=diff
>>>
>>> ==
>>> --- cfe/trunk/lib/Format/FormatToken.h (original)
>>> +++ cfe/trunk/lib/Format/FormatToken.h Mon Aug 24 09:28:08 2015
>>> @@ -525,6 +525,8 @@ private:
>>>  /// properly supported by Clang's lexer.
>>>  struct AdditionalKeywords {
>>>AdditionalKeywords(IdentifierTable &IdentTable) {
>>> +kw_final = &IdentTable.get("final");
>>> +kw_override = &IdentTable.get("override");
>>>  kw_in = &IdentTable.get("in");
>>>  kw_CF_ENUM = &IdentTable.get("CF_ENUM");
>>>  kw_CF_OPTIONS = &IdentTable.get("CF_OPTIONS");
>>> @@ -538,7 +540,6 @@ struct AdditionalKeywords {
>>>
>>>  kw_abstract = &IdentTable.get("abstract");
>>>  kw_extends = &IdentTable.get("extends");
>>> -kw_final = &IdentTable.get("final");
>>>  kw_implements = &IdentTable.get("implements");
>>>  kw_instanceof = &IdentTable.get("instanceof");
>>>  kw_interface = &IdentTable.get("interface");
>>> @@ -562,6 +563,8 @@ struct AdditionalKeywords {
>>>}
>>>
>>>// Context sensitive keywords.
>>> +  IdentifierInfo *kw_final;
>>> +  IdentifierInfo *kw_override;
>>>IdentifierInfo *kw_in;
>>>IdentifierInfo *kw_CF_ENUM;
>>>IdentifierInfo *kw_CF_OPTIONS;
>>> @@ -578,7 +581,6 @@ struct AdditionalKeywords {
>>>// Java keywords.
>>>IdentifierInfo *kw_abstract;
>>>IdentifierInfo *kw_extends;
>>> -  IdentifierInfo *kw_final;
>>>IdentifierInfo *kw_implements;
>>>IdentifierInfo *kw_instanceof;
>>>IdentifierInfo *kw_interface;
>>>
>>> Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=245843&r1=245842&r2=245843&view=diff
>>>
>>> ==
>>> --- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
>>> +++ cfe/trunk/lib/Format/TokenAnnotator.cpp Mon Aug 24 09:28:08 2015
>>> @@ -1139,9 +1139,11 @@ private:
>>>return TT_UnaryOperator;
>>>
>>>  const FormatToken *NextToken = Tok.getNextNonComment();
>>> -if (!NextToken || NextToken->is(tok::arrow) ||
>>> +if (!NextToken ||
>>> +NextToken->isOneOf(tok::arrow, Keywords.kw_final,
>>> +   Keywords.kw_override) ||
>>>  (NextToken->is(tok::l_brace) &&
>>> !NextToken->getNextNonComment()))
>>> -  return TT_Unknown;
>>> +  return TT_PointerOrReference;
>>>
>>>  if (PrevToken->is(tok::coloncolon))
>>>return TT_PointerOrReference;
>>> @@ -1855,7 +1857,9 @@ bool TokenAnnotator::spaceRequiredBetwee
>>>  !Line.IsMultiVariableDeclStmt)))
>>>  return true;
>>>if (Left.is(TT_PointerOrReference))
>>> -return Right.Tok.isLiteral() || Right.is(TT_BlockComment) ||
>>> +return Right.Tok.isLiteral() ||
>>> +   Right.isOneOf(TT_BlockComment, Keywords.kw_final,
>>> + Keywords.kw_override) ||
>>> (Right.is(tok::l_brace) && Right.BlockKind == BK_Block) ||
>>> (!Right.isOneOf(TT_PointerOrReference,
>>> TT_ArraySubscriptLSquare,
>>> tok::l_paren) &&
>>>
>>> Modified: cfe/trunk/unittests/Format/FormatTest.cpp
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=245843&r1=245842&r2=245843&view=diff
>>>
>>> ==
>>> --- cfe/trunk/unittests/Format/FormatTest

r245937 - [OPENMP 4.0] Initial support for array sections.

2015-08-25 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Tue Aug 25 09:24:04 2015
New Revision: 245937

URL: http://llvm.org/viewvc/llvm-project?rev=245937&view=rev
Log:
[OPENMP 4.0] Initial support for array sections.

Adds parsing/sema analysis/serialization/deserialization for array sections in 
OpenMP constructs (introduced in OpenMP 4.0).
Currently it is allowed to use array sections only in OpenMP clauses that 
accepts list of expressions.
Differential Revision: http://reviews.llvm.org/D10732

Added:
cfe/trunk/include/clang/AST/ExprOpenMP.h   (with props)
Modified:
cfe/trunk/include/clang-c/Index.h
cfe/trunk/include/clang/AST/ASTContext.h
cfe/trunk/include/clang/AST/BuiltinTypes.def
cfe/trunk/include/clang/AST/DataRecursiveASTVisitor.h
cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
cfe/trunk/include/clang/AST/StmtVisitor.h
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Basic/StmtNodes.td
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/include/clang/Serialization/ASTBitCodes.h
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/AST/Expr.cpp
cfe/trunk/lib/AST/ExprClassification.cpp
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/lib/AST/ItaniumMangle.cpp
cfe/trunk/lib/AST/NSAPI.cpp
cfe/trunk/lib/AST/Stmt.cpp
cfe/trunk/lib/AST/StmtPrinter.cpp
cfe/trunk/lib/AST/StmtProfile.cpp
cfe/trunk/lib/AST/Type.cpp
cfe/trunk/lib/AST/TypeLoc.cpp
cfe/trunk/lib/Parse/ParseExpr.cpp
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/lib/Sema/SemaExceptionSpec.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/lib/Sema/TreeTransform.h
cfe/trunk/lib/Serialization/ASTCommon.cpp
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/lib/Serialization/ASTReaderStmt.cpp
cfe/trunk/lib/Serialization/ASTWriterStmt.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/IdenticalExprChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
cfe/trunk/test/OpenMP/task_ast_print.cpp
cfe/trunk/test/OpenMP/task_depend_messages.cpp
cfe/trunk/tools/libclang/CIndex.cpp
cfe/trunk/tools/libclang/CXCursor.cpp

Modified: cfe/trunk/include/clang-c/Index.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/Index.h?rev=245937&r1=245936&r2=245937&view=diff
==
--- cfe/trunk/include/clang-c/Index.h (original)
+++ cfe/trunk/include/clang-c/Index.h Tue Aug 25 09:24:04 2015
@@ -1982,7 +1982,11 @@ enum CXCursorKind {
*/
   CXCursor_ObjCSelfExpr  = 146,
 
-  CXCursor_LastExpr  = CXCursor_ObjCSelfExpr,
+  /** \brief OpenMP 4.0 [2.4, Array Section].
+   */
+  CXCursor_OMPArraySectionExpr   = 147,
+
+  CXCursor_LastExpr  = CXCursor_OMPArraySectionExpr,
 
   /* Statements */
   CXCursor_FirstStmt = 200,

Modified: cfe/trunk/include/clang/AST/ASTContext.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=245937&r1=245936&r2=245937&view=diff
==
--- cfe/trunk/include/clang/AST/ASTContext.h (original)
+++ cfe/trunk/include/clang/AST/ASTContext.h Tue Aug 25 09:24:04 2015
@@ -842,6 +842,7 @@ public:
   CanQualType OCLImage2dTy, OCLImage2dArrayTy;
   CanQualType OCLImage3dTy;
   CanQualType OCLSamplerTy, OCLEventTy;
+  CanQualType OMPArraySectionTy;
 
   // Types for deductions in C++0x [stmt.ranged]'s desugaring. Built on demand.
   mutable QualType AutoDeductTy; // Deduction against 'auto'.

Modified: cfe/trunk/include/clang/AST/BuiltinTypes.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/BuiltinTypes.def?rev=245937&r1=245936&r2=245937&view=diff
==
--- cfe/trunk/include/clang/AST/BuiltinTypes.def (original)
+++ cfe/trunk/include/clang/AST/BuiltinTypes.def Tue Aug 25 09:24:04 2015
@@ -227,8 +227,11 @@ PLACEHOLDER_TYPE(BuiltinFn, BuiltinFnTy)
 // context.
 PLACEHOLDER_TYPE(ARCUnbridgedCast, ARCUnbridgedCastTy)
 
+// A placeholder type for OpenMP array sections.
+PLACEHOLDER_TYPE(OMPArraySection, OMPArraySectionTy)
+
 #ifdef LAST_BUILTIN_TYPE
-LAST_BUILTIN_TYPE(ARCUnbridgedCast)
+LAST_BUILTIN_TYPE(OMPArraySection)
 #undef LAST_BUILTIN_TYPE
 #endif
 

Modified: cfe/trunk/include/clang/AST/DataRecursiveASTVisitor.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DataRecursiveASTVisitor.h?rev=245937&r1=245936&r2=245937&view=diff
==
--- cfe/trunk/include/clang/AST/DataRecursiveASTVisitor.h (original)
+++ cfe/trunk/include/clang/AST/DataRecursiveASTVisitor.h Tue Aug 25 09:24:04 
2015
@@ -24,6 +24,7 @@
 #include "clang/AST/Expr.h"
 #include "clang/AST/ExprCXX.h"
 #include

Re: [PATCH] D10732: [OPENMP 4.0] Initial support for array sections.

2015-08-25 Thread Alexey Bataev via cfe-commits
This revision was automatically updated to reflect the committed changes.
ABataev marked an inline comment as done.
Closed by commit rL245937: [OPENMP 4.0] Initial support for array sections. 
(authored by ABataev).

Changed prior to commit:
  http://reviews.llvm.org/D10732?vs=32974&id=33077#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D10732

Files:
  cfe/trunk/include/clang-c/Index.h
  cfe/trunk/include/clang/AST/ASTContext.h
  cfe/trunk/include/clang/AST/BuiltinTypes.def
  cfe/trunk/include/clang/AST/DataRecursiveASTVisitor.h
  cfe/trunk/include/clang/AST/ExprOpenMP.h
  cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
  cfe/trunk/include/clang/AST/StmtVisitor.h
  cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
  cfe/trunk/include/clang/Basic/StmtNodes.td
  cfe/trunk/include/clang/Sema/Sema.h
  cfe/trunk/include/clang/Serialization/ASTBitCodes.h
  cfe/trunk/lib/AST/ASTContext.cpp
  cfe/trunk/lib/AST/Expr.cpp
  cfe/trunk/lib/AST/ExprClassification.cpp
  cfe/trunk/lib/AST/ExprConstant.cpp
  cfe/trunk/lib/AST/ItaniumMangle.cpp
  cfe/trunk/lib/AST/NSAPI.cpp
  cfe/trunk/lib/AST/Stmt.cpp
  cfe/trunk/lib/AST/StmtPrinter.cpp
  cfe/trunk/lib/AST/StmtProfile.cpp
  cfe/trunk/lib/AST/Type.cpp
  cfe/trunk/lib/AST/TypeLoc.cpp
  cfe/trunk/lib/Parse/ParseExpr.cpp
  cfe/trunk/lib/Sema/SemaChecking.cpp
  cfe/trunk/lib/Sema/SemaExceptionSpec.cpp
  cfe/trunk/lib/Sema/SemaExpr.cpp
  cfe/trunk/lib/Sema/SemaOpenMP.cpp
  cfe/trunk/lib/Sema/TreeTransform.h
  cfe/trunk/lib/Serialization/ASTCommon.cpp
  cfe/trunk/lib/Serialization/ASTReader.cpp
  cfe/trunk/lib/Serialization/ASTReaderStmt.cpp
  cfe/trunk/lib/Serialization/ASTWriterStmt.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/IdenticalExprChecker.cpp
  cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
  cfe/trunk/test/OpenMP/task_ast_print.cpp
  cfe/trunk/test/OpenMP/task_depend_messages.cpp
  cfe/trunk/tools/libclang/CIndex.cpp
  cfe/trunk/tools/libclang/CXCursor.cpp

Index: cfe/trunk/include/clang-c/Index.h
===
--- cfe/trunk/include/clang-c/Index.h
+++ cfe/trunk/include/clang-c/Index.h
@@ -1982,7 +1982,11 @@
*/
   CXCursor_ObjCSelfExpr  = 146,
 
-  CXCursor_LastExpr  = CXCursor_ObjCSelfExpr,
+  /** \brief OpenMP 4.0 [2.4, Array Section].
+   */
+  CXCursor_OMPArraySectionExpr   = 147,
+
+  CXCursor_LastExpr  = CXCursor_OMPArraySectionExpr,
 
   /* Statements */
   CXCursor_FirstStmt = 200,
Index: cfe/trunk/include/clang/AST/ExprOpenMP.h
===
--- cfe/trunk/include/clang/AST/ExprOpenMP.h
+++ cfe/trunk/include/clang/AST/ExprOpenMP.h
@@ -0,0 +1,126 @@
+//===--- ExprOpenMP.h - Classes for representing expressions *- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+//  This file defines the Expr interface and subclasses.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_AST_EXPROPENMP_H
+#define LLVM_CLANG_AST_EXPROPENMP_H
+
+#include "clang/AST/Expr.h"
+
+namespace clang {
+/// \brief OpenMP 4.0 [2.4, Array Sections].
+/// To specify an array section in an OpenMP construct, array subscript
+/// expressions are extended with the following syntax:
+/// \code
+/// [ lower-bound : length ]
+/// [ lower-bound : ]
+/// [ : length ]
+/// [ : ]
+/// \endcode
+/// The array section must be a subset of the original array.
+/// Array sections are allowed on multidimensional arrays. Base language array
+/// subscript expressions can be used to specify length-one dimensions of
+/// multidimensional array sections.
+/// The lower-bound and length are integral type expressions. When evaluated
+/// they represent a set of integer values as follows:
+/// \code
+/// { lower-bound, lower-bound + 1, lower-bound + 2,... , lower-bound + length -
+/// 1 }
+/// \endcode
+/// The lower-bound and length must evaluate to non-negative integers.
+/// When the size of the array dimension is not known, the length must be
+/// specified explicitly.
+/// When the length is absent, it defaults to the size of the array dimension
+/// minus the lower-bound.
+/// When the lower-bound is absent it defaults to 0.
+class OMPArraySectionExpr : public Expr {
+  enum { BASE, LOWER_BOUND, LENGTH, END_EXPR };
+  Stmt *SubExprs[END_EXPR];
+  SourceLocation ColonLoc;
+  SourceLocation RBracketLoc;
+
+public:
+  OMPArraySectionExpr(Expr *Base, Expr *LowerBound, Expr *Length, QualType Type,
+  ExprValueKind VK, ExprObjectKind OK,
+  SourceLocation ColonLoc, SourceLocation RBracketLoc)
+  : Expr(
+O

Re: [PATCH] D12301: [PATCH] New checker for UB in handler of a function-try-block

2015-08-25 Thread Aaron Ballman via cfe-commits
aaron.ballman updated this revision to Diff 33078.
aaron.ballman added a comment.

This patch completely reworks the way the warning is implemented by moving it 
into the frontend instead of clang-tidy.


http://reviews.llvm.org/D12301

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/Sema.h
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaDeclCXX.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaExprCXX.cpp
  lib/Sema/SemaExprMember.cpp
  lib/Sema/SemaOverload.cpp
  lib/Sema/TreeTransform.h
  test/SemaCXX/cdtor-fn-try-block.cpp

Index: test/SemaCXX/cdtor-fn-try-block.cpp
===
--- test/SemaCXX/cdtor-fn-try-block.cpp
+++ test/SemaCXX/cdtor-fn-try-block.cpp
@@ -0,0 +1,97 @@
+// RUN: %clang_cc1 -fsyntax-only -fcxx-exceptions -verify %s -std=c++14
+
+int FileScope;
+
+struct A {
+  int I;
+  void f();
+  A() try {
+  } catch (...) {
+I = 12; // expected-warning {{cannot refer to a non-static member from the handler of a constructor function try block}}
+f(); // expected-warning {{cannot refer to a non-static member from the handler of a constructor function try block}}
+
+FileScope = 12; // ok
+A a;
+a.I = 12; // ok
+  }
+};
+
+struct B {
+  int I;
+  void f();
+};
+
+struct C : B {
+  C() try {
+  } catch (...) {
+I = 12; // expected-warning {{cannot refer to a non-static member from the handler of a constructor function try block}}
+f(); // expected-warning {{cannot refer to a non-static member from the handler of a constructor function try block}}
+  }
+};
+
+struct D {
+  static int I;
+  static void f();
+
+  D() try {
+  } catch (...) {
+I = 12; // ok
+f(); // ok
+  }
+};
+int D::I;
+
+struct E {
+  int I;
+  void f();
+  static int J;
+  static void g();
+
+  ~E() try {
+  } catch (...) {
+I = 12; // expected-warning {{cannot refer to a non-static member from the handler of a destructor function try block}}
+f(); // expected-warning {{cannot refer to a non-static member from the handler of a destructor function try block}}
+
+J = 12; // ok
+g(); // ok
+  }
+};
+int E::J;
+
+struct F {
+  static int I;
+  static void f();
+};
+int F::I;
+
+struct G : F {
+  G() try {
+  } catch (...) {
+I = 12; // ok
+f(); // ok
+  }
+};
+
+struct H {
+  struct A {};
+  enum {
+E
+  };
+
+  H() try {
+  } catch (...) {
+H::A a; // ok
+int I = E; // ok
+  }
+};
+
+struct I {
+  int J;
+
+  I() {
+try { // not a function-try-block
+} catch (...) {
+  J = 12; // ok
+	}
+  }
+};
\ No newline at end of file
Index: lib/Sema/TreeTransform.h
===
--- lib/Sema/TreeTransform.h
+++ lib/Sema/TreeTransform.h
@@ -1955,7 +1955,8 @@
 return getSema().BuildMemberReferenceExpr(Base, BaseType, OpLoc, isArrow,
   SS, TemplateKWLoc,
   FirstQualifierInScope,
-  R, ExplicitTemplateArgs);
+  R, ExplicitTemplateArgs,
+  /*S*/nullptr);
   }
 
   /// \brief Build a new binary operator expression.
@@ -2021,7 +2022,8 @@
   SS, SourceLocation(),
   /*FirstQualifierInScope*/ nullptr,
   NameInfo,
-  /* TemplateArgs */ nullptr);
+  /* TemplateArgs */ nullptr,
+  /*S*/ nullptr);
   }
 
   /// \brief Build a new initializer list expression.
@@ -2469,7 +2471,7 @@
 TemplateArgs);
 
 return getSema().BuildQualifiedDeclarationNameExpr(
-SS, NameInfo, IsAddressOfOperand, RecoveryTSI);
+SS, NameInfo, IsAddressOfOperand, /*S*/nullptr, RecoveryTSI);
   }
 
   /// \brief Build a new template-id expression.
@@ -2563,7 +2565,7 @@
 SS, TemplateKWLoc,
 FirstQualifierInScope,
 MemberNameInfo,
-TemplateArgs);
+TemplateArgs, /*S*/nullptr);
   }
 
   /// \brief Build a new member reference expression.
@@ -2585,7 +2587,7 @@
 OperatorLoc, IsArrow,
 SS, TemplateKWLoc,
 FirstQualifierInScope,
-R, TemplateArgs);
+R, TemplateArgs, /*S*/nullptr);
   }
 
   /// \brief Build a new noexcept expression.
@@ -2725,7 +2727,8 @@
   SS, SourceLocati

[PATCH] D12321: Avoid LoopConvertCheck replacements in template instantiations.

2015-08-25 Thread Angel Garcia via cfe-commits
angelgarcia created this revision.
angelgarcia added a reviewer: alexfh.
angelgarcia added subscribers: cfe-commits, klimek.

Prevent LoopConvertCheck from doing replacements in template instantiations, 
and add a test.

http://reviews.llvm.org/D12321

Files:
  clang-tidy/modernize/LoopConvertCheck.cpp
  test/clang-tidy/modernize-loop-convert-extra.cpp

Index: test/clang-tidy/modernize-loop-convert-extra.cpp
===
--- test/clang-tidy/modernize-loop-convert-extra.cpp
+++ test/clang-tidy/modernize-loop-convert-extra.cpp
@@ -626,3 +626,19 @@
 }
 
 } // namespace Macros
+
+namespace Templates {
+
+template 
+void set_union(Container &container) {
+  for (typename Container::const_iterator SI = container.begin(),
+   SE = container.end(); SI != SE; ++SI) {
+  }
+}
+
+void template_instantiation() {
+  S a;
+  set_union(a);
+}
+
+} // namespace Templates
Index: clang-tidy/modernize/LoopConvertCheck.cpp
===
--- clang-tidy/modernize/LoopConvertCheck.cpp
+++ clang-tidy/modernize/LoopConvertCheck.cpp
@@ -70,6 +70,7 @@
   expr(hasType(isInteger())).bind(ConditionBoundName);
 
   return forStmt(
+ unless(isInTemplateInstantiation()),
  hasLoopInit(declStmt(hasSingleDecl(InitToZeroMatcher))),
  hasCondition(anyOf(
  binaryOperator(hasOperatorName("<"),
@@ -159,6 +160,7 @@
   .bind(DerefByRefResultName)));
 
   return forStmt(
+ unless(isInTemplateInstantiation()),
  hasLoopInit(anyOf(declStmt(declCountIs(2),
 containsDeclaration(0, 
InitDeclMatcher),
 containsDeclaration(1, 
EndDeclMatcher)),
@@ -258,6 +260,7 @@
  EndInitMatcher));
 
   return forStmt(
+ unless(isInTemplateInstantiation()),
  hasLoopInit(
  anyOf(declStmt(declCountIs(2),
 containsDeclaration(0, InitToZeroMatcher),


Index: test/clang-tidy/modernize-loop-convert-extra.cpp
===
--- test/clang-tidy/modernize-loop-convert-extra.cpp
+++ test/clang-tidy/modernize-loop-convert-extra.cpp
@@ -626,3 +626,19 @@
 }
 
 } // namespace Macros
+
+namespace Templates {
+
+template 
+void set_union(Container &container) {
+  for (typename Container::const_iterator SI = container.begin(),
+   SE = container.end(); SI != SE; ++SI) {
+  }
+}
+
+void template_instantiation() {
+  S a;
+  set_union(a);
+}
+
+} // namespace Templates
Index: clang-tidy/modernize/LoopConvertCheck.cpp
===
--- clang-tidy/modernize/LoopConvertCheck.cpp
+++ clang-tidy/modernize/LoopConvertCheck.cpp
@@ -70,6 +70,7 @@
   expr(hasType(isInteger())).bind(ConditionBoundName);
 
   return forStmt(
+ unless(isInTemplateInstantiation()),
  hasLoopInit(declStmt(hasSingleDecl(InitToZeroMatcher))),
  hasCondition(anyOf(
  binaryOperator(hasOperatorName("<"),
@@ -159,6 +160,7 @@
   .bind(DerefByRefResultName)));
 
   return forStmt(
+ unless(isInTemplateInstantiation()),
  hasLoopInit(anyOf(declStmt(declCountIs(2),
 containsDeclaration(0, InitDeclMatcher),
 containsDeclaration(1, EndDeclMatcher)),
@@ -258,6 +260,7 @@
  EndInitMatcher));
 
   return forStmt(
+ unless(isInTemplateInstantiation()),
  hasLoopInit(
  anyOf(declStmt(declCountIs(2),
 containsDeclaration(0, InitToZeroMatcher),
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D12321: Avoid LoopConvertCheck replacements in template instantiations.

2015-08-25 Thread Alexander Kornienko via cfe-commits
alexfh accepted this revision.
alexfh added a comment.
This revision is now accepted and ready to land.

Looks good with a comment.



Comment at: test/clang-tidy/modernize-loop-convert-extra.cpp:636
@@ +635,3 @@
+   SE = container.end(); SI != SE; ++SI) {
+  }
+}

Please add a test to ensure that loops over non-dependent container types in 
templates are still converted.


http://reviews.llvm.org/D12321



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D12134: [DEBUG INFO] Source correlation for lambda captured values.

2015-08-25 Thread David Blaikie via cfe-commits
Looks like the initial mail didn't hit the mailing list? Does someone want
to restart this review and/or forward that initial mail with the
patch/description/etc?

On Mon, Aug 24, 2015 at 11:00 PM, Eric Christopher via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> echristo added a comment.
>
> How about:
>
> 13. [apple,
> 14. banana,
> 15. cherry]{
> 16. printf("apple = %d\n",apple);
> 17. printf("banana = %d\n",banana);
> 18. printf("cherry = %d\n",cherry);
>
> Should be 13, 14, 15 yes?
>
> -eric
>
>
> http://reviews.llvm.org/D12134
>
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D12134: [DEBUG INFO] Source correlation for lambda captured values.

2015-08-25 Thread David Blaikie via cfe-commits
Hmm, my mistake, it did - my mail client's just not threaded it together
for some reason. :/

On Tue, Aug 25, 2015 at 8:06 AM, David Blaikie  wrote:

> Looks like the initial mail didn't hit the mailing list? Does someone want
> to restart this review and/or forward that initial mail with the
> patch/description/etc?
>
> On Mon, Aug 24, 2015 at 11:00 PM, Eric Christopher via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> echristo added a comment.
>>
>> How about:
>>
>> 13. [apple,
>> 14. banana,
>> 15. cherry]{
>> 16. printf("apple = %d\n",apple);
>> 17. printf("banana = %d\n",banana);
>> 18. printf("cherry = %d\n",cherry);
>>
>> Should be 13, 14, 15 yes?
>>
>> -eric
>>
>>
>> http://reviews.llvm.org/D12134
>>
>>
>>
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D12134: Improve debug info for implicitly captured vars in lambdas

2015-08-25 Thread David Blaikie via cfe-commits
On Tue, Aug 18, 2015 at 9:05 PM, Alexey Bataev via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> ABataev created this revision.
> ABataev added reviewers: echristo, rjmccall, rsmith.
> ABataev added a subscriber: cfe-commits.
>
> When variables are implicitly captured in lambdas, debug info generated
> for captured variables points to location where they are used first.  This
> patch makes debug info to point to capture default location.
>

Not sure if this is the right tradeoff, or if it is, perhaps we should
reconsider how our diagnostics work too?

Currently if you, say, capture a variable by value and that variable
doesn't have an accessible copy ctor, the diagnostic points to the first
use. Should we change that too?


>
> http://reviews.llvm.org/D12134
>
> Files:
>   lib/Sema/SemaLambda.cpp
>   test/CodeGenCXX/debug-lambda-expressions.cpp
>
> Index: lib/Sema/SemaLambda.cpp
> ===
> --- lib/Sema/SemaLambda.cpp
> +++ lib/Sema/SemaLambda.cpp
> @@ -1377,10 +1377,10 @@
>  }
>
>  static ExprResult performLambdaVarCaptureInitialization(
> -Sema &S, LambdaScopeInfo::Capture &Capture,
> -FieldDecl *Field,
> +Sema &S, LambdaScopeInfo::Capture &Capture, FieldDecl *Field,
>  SmallVectorImpl &ArrayIndexVars,
> -SmallVectorImpl &ArrayIndexStarts) {
> +SmallVectorImpl &ArrayIndexStarts, bool ImplicitCapture,
> +SourceLocation CaptureDefaultLoc) {
>assert(Capture.isVariableCapture() && "not a variable capture");
>
>auto *Var = Capture.getVariable();
> @@ -1399,7 +1399,10 @@
>//   An entity captured by a lambda-expression is odr-used (3.2) in
>//   the scope containing the lambda-expression.
>ExprResult RefResult = S.BuildDeclarationNameExpr(
> -  CXXScopeSpec(), DeclarationNameInfo(Var->getDeclName(), Loc), Var);
> +  CXXScopeSpec(),
> +  DeclarationNameInfo(Var->getDeclName(),
> +  ImplicitCapture ? CaptureDefaultLoc : Loc),
> +  Var);
>if (RefResult.isInvalid())
>  return ExprError();
>Expr *Ref = RefResult.get();
> @@ -1561,7 +1564,8 @@
>Expr *Init = From.getInitExpr();
>if (!Init) {
>  auto InitResult = performLambdaVarCaptureInitialization(
> -*this, From, *CurField, ArrayIndexVars, ArrayIndexStarts);
> +*this, From, *CurField, ArrayIndexVars, ArrayIndexStarts,
> +CaptureDefault != LCD_None, CaptureDefaultLoc);
>  if (InitResult.isInvalid())
>return ExprError();
>  Init = InitResult.get();
> Index: test/CodeGenCXX/debug-lambda-expressions.cpp
> ===
> --- test/CodeGenCXX/debug-lambda-expressions.cpp
> +++ test/CodeGenCXX/debug-lambda-expressions.cpp
> @@ -14,6 +14,19 @@
>  struct D { D(); D(const D&); int x; };
>  int d(int x) { D y[10]; return [x,y] { return y[x].x; }(); }
>
> +// CHECK-LABEL: foo
> +int foo(int x) {
> +// CHECK: [[X:%.+]] = alloca i32,
> +// CHECK: call void @llvm.dbg.declare(
> +// CHECK: [[X_REF:%.+]] = getelementptr inbounds %{{.+}}, %{{.+}}*
> %{{.+}}, i32 0, i32 0, !dbg ![[DBG_FOO:[0-9]+]]
> +// CHECK: [[X_VAL:%.+]] = load i32, i32* [[X]], align 4, !dbg ![[DBG_FOO]]
> +// CHECK: store i32 [[X_VAL]], i32* [[X_REF]], align 4, !dbg ![[DBG_FOO]]
> +// CHECK: call i32 @{{.+}}, !dbg ![[DBG_FOO]]
> +  return [=] {
> +return x;
> +  }();
> +}
> +
>  // Randomness for file. -- 6
>  // CHECK: [[FILE:.*]] = !DIFile(filename:
> "{{.*}}debug-lambda-expressions.cpp",
>
> @@ -100,3 +113,5 @@
>  // CHECK-SAME:  line: [[VAR_LINE]],
>  // CHECK-SAME:  elements: ![[VAR_ARGS:[0-9]+]]
>  // CHECK: ![[VAR_ARGS]] = !{!{{[0-9]+}}}
> +
> +// CHECK: [[DBG_FOO:![0-9]+]] = !DILocation(line: 25,
>
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r245939 - Fix possible crash on null base or type for array elements.

2015-08-25 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Tue Aug 25 10:15:12 2015
New Revision: 245939

URL: http://llvm.org/viewvc/llvm-project?rev=245939&view=rev
Log:
Fix possible crash on null base or type for array elements.


Modified:
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/OpenMP/task_depend_messages.cpp

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=245939&r1=245938&r2=245939&view=diff
==
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Tue Aug 25 10:15:12 2015
@@ -3932,7 +3932,8 @@ static bool checkArithmeticOnObjCPointer
 ExprResult
 Sema::ActOnArraySubscriptExpr(Scope *S, Expr *base, SourceLocation lbLoc,
   Expr *idx, SourceLocation rbLoc) {
-  if (base->getType()->isSpecificPlaceholderType(BuiltinType::OMPArraySection))
+  if (base && !base->getType().isNull() &&
+  base->getType()->isSpecificPlaceholderType(BuiltinType::OMPArraySection))
 return ActOnOMPArraySectionExpr(base, lbLoc, idx, SourceLocation(),
 /*Length=*/nullptr, rbLoc);
 

Modified: cfe/trunk/test/OpenMP/task_depend_messages.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/task_depend_messages.cpp?rev=245939&r1=245938&r2=245939&view=diff
==
--- cfe/trunk/test/OpenMP/task_depend_messages.cpp (original)
+++ cfe/trunk/test/OpenMP/task_depend_messages.cpp Tue Aug 25 10:15:12 2015
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 -o - %s
+// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 -o - -std=c++11 %s
 
 void foo() {
 }
@@ -18,6 +18,7 @@ int main(int argc, char **argv, char *en
   vector vec;
   typedef float V __attribute__((vector_size(16)));
   V a;
+  auto arr = x; // expected-error {{use of undeclared identifier 'x'}}
 
   #pragma omp task depend // expected-error {{expected '(' after 'depend'}}
   #pragma omp task depend ( // expected-error {{expected 'in', 'out' or 
'inout' in OpenMP clause 'depend'}} expected-error {{expected ')'}} 
expected-note {{to match this '('}} expected-warning {{missing ':' after 
dependency type - ignoring}}
@@ -48,6 +49,7 @@ int main(int argc, char **argv, char *en
   #pragma omp task depend(in:argv[0:][:]) // expected-error {{section length 
is unspecified and cannot be inferred because subscripted value is not an 
array}}
   #pragma omp task depend(in:env[0:][:]) // expected-error {{section length is 
unspecified and cannot be inferred because subscripted value is an array of 
unknown bound}}
   #pragma omp task depend(in : argv[ : argc][1 : argc - 1])
+  #pragma omp task depend(in : arr[0])
   foo();
 
   return 0;


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D12321: Avoid LoopConvertCheck replacements in template instantiations.

2015-08-25 Thread Angel Garcia via cfe-commits
angelgarcia updated this revision to Diff 33081.
angelgarcia added a comment.

Add test.


http://reviews.llvm.org/D12321

Files:
  clang-tidy/modernize/LoopConvertCheck.cpp
  test/clang-tidy/modernize-loop-convert-extra.cpp

Index: test/clang-tidy/modernize-loop-convert-extra.cpp
===
--- test/clang-tidy/modernize-loop-convert-extra.cpp
+++ test/clang-tidy/modernize-loop-convert-extra.cpp
@@ -626,3 +626,24 @@
 }
 
 } // namespace Macros
+
+namespace Templates {
+
+template 
+void set_union(Container &container) {
+  for (typename Container::const_iterator SI = container.begin(),
+   SE = container.end(); SI != SE; ++SI) {
+  }
+  S s;
+  for (S::iterator SI = s.begin(), SE = s.end(); SI != SE; ++SI) {
+  }
+  // CHECK-MESSAGES: :[[@LINE-2]]:3: warning: use range-based for loop instead
+  // CHECK-FIXES: for (auto & elem : s) {
+}
+
+void template_instantiation() {
+  S a;
+  set_union(a);
+}
+
+} // namespace Templates
Index: clang-tidy/modernize/LoopConvertCheck.cpp
===
--- clang-tidy/modernize/LoopConvertCheck.cpp
+++ clang-tidy/modernize/LoopConvertCheck.cpp
@@ -70,6 +70,7 @@
   expr(hasType(isInteger())).bind(ConditionBoundName);
 
   return forStmt(
+ unless(isInTemplateInstantiation()),
  hasLoopInit(declStmt(hasSingleDecl(InitToZeroMatcher))),
  hasCondition(anyOf(
  binaryOperator(hasOperatorName("<"),
@@ -159,6 +160,7 @@
   .bind(DerefByRefResultName)));
 
   return forStmt(
+ unless(isInTemplateInstantiation()),
  hasLoopInit(anyOf(declStmt(declCountIs(2),
 containsDeclaration(0, 
InitDeclMatcher),
 containsDeclaration(1, 
EndDeclMatcher)),
@@ -258,6 +260,7 @@
  EndInitMatcher));
 
   return forStmt(
+ unless(isInTemplateInstantiation()),
  hasLoopInit(
  anyOf(declStmt(declCountIs(2),
 containsDeclaration(0, InitToZeroMatcher),


Index: test/clang-tidy/modernize-loop-convert-extra.cpp
===
--- test/clang-tidy/modernize-loop-convert-extra.cpp
+++ test/clang-tidy/modernize-loop-convert-extra.cpp
@@ -626,3 +626,24 @@
 }
 
 } // namespace Macros
+
+namespace Templates {
+
+template 
+void set_union(Container &container) {
+  for (typename Container::const_iterator SI = container.begin(),
+   SE = container.end(); SI != SE; ++SI) {
+  }
+  S s;
+  for (S::iterator SI = s.begin(), SE = s.end(); SI != SE; ++SI) {
+  }
+  // CHECK-MESSAGES: :[[@LINE-2]]:3: warning: use range-based for loop instead
+  // CHECK-FIXES: for (auto & elem : s) {
+}
+
+void template_instantiation() {
+  S a;
+  set_union(a);
+}
+
+} // namespace Templates
Index: clang-tidy/modernize/LoopConvertCheck.cpp
===
--- clang-tidy/modernize/LoopConvertCheck.cpp
+++ clang-tidy/modernize/LoopConvertCheck.cpp
@@ -70,6 +70,7 @@
   expr(hasType(isInteger())).bind(ConditionBoundName);
 
   return forStmt(
+ unless(isInTemplateInstantiation()),
  hasLoopInit(declStmt(hasSingleDecl(InitToZeroMatcher))),
  hasCondition(anyOf(
  binaryOperator(hasOperatorName("<"),
@@ -159,6 +160,7 @@
   .bind(DerefByRefResultName)));
 
   return forStmt(
+ unless(isInTemplateInstantiation()),
  hasLoopInit(anyOf(declStmt(declCountIs(2),
 containsDeclaration(0, InitDeclMatcher),
 containsDeclaration(1, EndDeclMatcher)),
@@ -258,6 +260,7 @@
  EndInitMatcher));
 
   return forStmt(
+ unless(isInTemplateInstantiation()),
  hasLoopInit(
  anyOf(declStmt(declCountIs(2),
 containsDeclaration(0, InitToZeroMatcher),
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D12134: Improve debug info for implicitly captured vars in lambdas

2015-08-25 Thread Bataev, Alexey via cfe-commits
I though about this. I think it will be more convenient for user to see 
the diagnostic on the first use of the variable rather than on '=' or 
'&' symbol.


Best regards,
Alexey Bataev
=
Software Engineer
Intel Compiler Team

25.08.2015 18:07, David Blaikie пишет:



On Tue, Aug 18, 2015 at 9:05 PM, Alexey Bataev via cfe-commits 
mailto:cfe-commits@lists.llvm.org>> wrote:


ABataev created this revision.
ABataev added reviewers: echristo, rjmccall, rsmith.
ABataev added a subscriber: cfe-commits.

When variables are implicitly captured in lambdas, debug info
generated for captured variables points to location where they are
used first.  This patch makes debug info to point to capture
default location.


Not sure if this is the right tradeoff, or if it is, perhaps we should 
reconsider how our diagnostics work too?


Currently if you, say, capture a variable by value and that variable 
doesn't have an accessible copy ctor, the diagnostic points to the 
first use. Should we change that too?



http://reviews.llvm.org/D12134

Files:
  lib/Sema/SemaLambda.cpp
  test/CodeGenCXX/debug-lambda-expressions.cpp

Index: lib/Sema/SemaLambda.cpp
===
--- lib/Sema/SemaLambda.cpp
+++ lib/Sema/SemaLambda.cpp
@@ -1377,10 +1377,10 @@
 }

 static ExprResult performLambdaVarCaptureInitialization(
-Sema &S, LambdaScopeInfo::Capture &Capture,
-FieldDecl *Field,
+Sema &S, LambdaScopeInfo::Capture &Capture, FieldDecl *Field,
 SmallVectorImpl &ArrayIndexVars,
-SmallVectorImpl &ArrayIndexStarts) {
+SmallVectorImpl &ArrayIndexStarts, bool
ImplicitCapture,
+SourceLocation CaptureDefaultLoc) {
   assert(Capture.isVariableCapture() && "not a variable capture");

   auto *Var = Capture.getVariable();
@@ -1399,7 +1399,10 @@
   //   An entity captured by a lambda-expression is odr-used (3.2) in
   //   the scope containing the lambda-expression.
   ExprResult RefResult = S.BuildDeclarationNameExpr(
-  CXXScopeSpec(), DeclarationNameInfo(Var->getDeclName(),
Loc), Var);
+  CXXScopeSpec(),
+  DeclarationNameInfo(Var->getDeclName(),
+  ImplicitCapture ? CaptureDefaultLoc : Loc),
+  Var);
   if (RefResult.isInvalid())
 return ExprError();
   Expr *Ref = RefResult.get();
@@ -1561,7 +1564,8 @@
   Expr *Init = From.getInitExpr();
   if (!Init) {
 auto InitResult = performLambdaVarCaptureInitialization(
-*this, From, *CurField, ArrayIndexVars,
ArrayIndexStarts);
+*this, From, *CurField, ArrayIndexVars, ArrayIndexStarts,
+CaptureDefault != LCD_None, CaptureDefaultLoc);
 if (InitResult.isInvalid())
   return ExprError();
 Init = InitResult.get();
Index: test/CodeGenCXX/debug-lambda-expressions.cpp
===
--- test/CodeGenCXX/debug-lambda-expressions.cpp
+++ test/CodeGenCXX/debug-lambda-expressions.cpp
@@ -14,6 +14,19 @@
 struct D { D(); D(const D&); int x; };
 int d(int x) { D y[10]; return [x,y] { return y[x].x; }(); }

+// CHECK-LABEL: foo
+int foo(int x) {
+// CHECK: [[X:%.+]] = alloca i32,
+// CHECK: call void @llvm.dbg.declare(
+// CHECK: [[X_REF:%.+]] = getelementptr inbounds %{{.+}},
%{{.+}}* %{{.+}}, i32 0, i32 0, !dbg ![[DBG_FOO:[0-9]+]]
+// CHECK: [[X_VAL:%.+]] = load i32, i32* [[X]], align 4, !dbg
![[DBG_FOO]]
+// CHECK: store i32 [[X_VAL]], i32* [[X_REF]], align 4, !dbg
![[DBG_FOO]]
+// CHECK: call i32 @{{.+}}, !dbg ![[DBG_FOO]]
+  return [=] {
+return x;
+  }();
+}
+
 // Randomness for file. -- 6
 // CHECK: [[FILE:.*]] = !DIFile(filename:
"{{.*}}debug-lambda-expressions.cpp",

@@ -100,3 +113,5 @@
 // CHECK-SAME:  line: [[VAR_LINE]],
 // CHECK-SAME:  elements:
![[VAR_ARGS:[0-9]+]]
 // CHECK: ![[VAR_ARGS]] = !{!{{[0-9]+}}}
+
+// CHECK: [[DBG_FOO:![0-9]+]] = !DILocation(line: 25,



___
cfe-commits mailing list
cfe-commits@lists.llvm.org 
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits




___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D12134: Improve debug info for implicitly captured vars in lambdas

2015-08-25 Thread David Blaikie via cfe-commits
On Tue, Aug 25, 2015 at 8:18 AM, Bataev, Alexey 
wrote:

> I though about this. I think it will be more convenient for user to see
> the diagnostic on the first use of the variable rather than on '=' or '&'
> symbol.
>

Why the difference between the diagnostic & the debug info, then?


>
> Best regards,
> Alexey Bataev
> =
> Software Engineer
> Intel Compiler Team
>
> 25.08.2015 18:07, David Blaikie пишет:
>
>>
>>
>> On Tue, Aug 18, 2015 at 9:05 PM, Alexey Bataev via cfe-commits <
>> cfe-commits@lists.llvm.org > wrote:
>>
>> ABataev created this revision.
>> ABataev added reviewers: echristo, rjmccall, rsmith.
>> ABataev added a subscriber: cfe-commits.
>>
>> When variables are implicitly captured in lambdas, debug info
>> generated for captured variables points to location where they are
>> used first.  This patch makes debug info to point to capture
>> default location.
>>
>>
>> Not sure if this is the right tradeoff, or if it is, perhaps we should
>> reconsider how our diagnostics work too?
>>
>> Currently if you, say, capture a variable by value and that variable
>> doesn't have an accessible copy ctor, the diagnostic points to the first
>> use. Should we change that too?
>>
>>
>> http://reviews.llvm.org/D12134
>>
>> Files:
>>   lib/Sema/SemaLambda.cpp
>>   test/CodeGenCXX/debug-lambda-expressions.cpp
>>
>> Index: lib/Sema/SemaLambda.cpp
>> ===
>> --- lib/Sema/SemaLambda.cpp
>> +++ lib/Sema/SemaLambda.cpp
>> @@ -1377,10 +1377,10 @@
>>  }
>>
>>  static ExprResult performLambdaVarCaptureInitialization(
>> -Sema &S, LambdaScopeInfo::Capture &Capture,
>> -FieldDecl *Field,
>> +Sema &S, LambdaScopeInfo::Capture &Capture, FieldDecl *Field,
>>  SmallVectorImpl &ArrayIndexVars,
>> -SmallVectorImpl &ArrayIndexStarts) {
>> +SmallVectorImpl &ArrayIndexStarts, bool
>> ImplicitCapture,
>> +SourceLocation CaptureDefaultLoc) {
>>assert(Capture.isVariableCapture() && "not a variable capture");
>>
>>auto *Var = Capture.getVariable();
>> @@ -1399,7 +1399,10 @@
>>//   An entity captured by a lambda-expression is odr-used (3.2) in
>>//   the scope containing the lambda-expression.
>>ExprResult RefResult = S.BuildDeclarationNameExpr(
>> -  CXXScopeSpec(), DeclarationNameInfo(Var->getDeclName(),
>> Loc), Var);
>> +  CXXScopeSpec(),
>> +  DeclarationNameInfo(Var->getDeclName(),
>> +  ImplicitCapture ? CaptureDefaultLoc : Loc),
>> +  Var);
>>if (RefResult.isInvalid())
>>  return ExprError();
>>Expr *Ref = RefResult.get();
>> @@ -1561,7 +1564,8 @@
>>Expr *Init = From.getInitExpr();
>>if (!Init) {
>>  auto InitResult = performLambdaVarCaptureInitialization(
>> -*this, From, *CurField, ArrayIndexVars,
>> ArrayIndexStarts);
>> +*this, From, *CurField, ArrayIndexVars, ArrayIndexStarts,
>> +CaptureDefault != LCD_None, CaptureDefaultLoc);
>>  if (InitResult.isInvalid())
>>return ExprError();
>>  Init = InitResult.get();
>> Index: test/CodeGenCXX/debug-lambda-expressions.cpp
>> ===
>> --- test/CodeGenCXX/debug-lambda-expressions.cpp
>> +++ test/CodeGenCXX/debug-lambda-expressions.cpp
>> @@ -14,6 +14,19 @@
>>  struct D { D(); D(const D&); int x; };
>>  int d(int x) { D y[10]; return [x,y] { return y[x].x; }(); }
>>
>> +// CHECK-LABEL: foo
>> +int foo(int x) {
>> +// CHECK: [[X:%.+]] = alloca i32,
>> +// CHECK: call void @llvm.dbg.declare(
>> +// CHECK: [[X_REF:%.+]] = getelementptr inbounds %{{.+}},
>> %{{.+}}* %{{.+}}, i32 0, i32 0, !dbg ![[DBG_FOO:[0-9]+]]
>> +// CHECK: [[X_VAL:%.+]] = load i32, i32* [[X]], align 4, !dbg
>> ![[DBG_FOO]]
>> +// CHECK: store i32 [[X_VAL]], i32* [[X_REF]], align 4, !dbg
>> ![[DBG_FOO]]
>> +// CHECK: call i32 @{{.+}}, !dbg ![[DBG_FOO]]
>> +  return [=] {
>> +return x;
>> +  }();
>> +}
>> +
>>  // Randomness for file. -- 6
>>  // CHECK: [[FILE:.*]] = !DIFile(filename:
>> "{{.*}}debug-lambda-expressions.cpp",
>>
>> @@ -100,3 +113,5 @@
>>  // CHECK-SAME:  line: [[VAR_LINE]],
>>  // CHECK-SAME:  elements:
>> ![[VAR_ARGS:[0-9]+]]
>>  // CHECK: ![[VAR_ARGS]] = !{!{{[0-9]+}}}
>> +
>> +// CHECK: [[DBG_FOO:![0-9]+]] = !DILocation(line: 25,
>>
>>
>>
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org 
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>

r245941 - Convert SampleProfile pass into a Module pass.

2015-08-25 Thread Diego Novillo via cfe-commits
Author: dnovillo
Date: Tue Aug 25 10:25:13 2015
New Revision: 245941

URL: http://llvm.org/viewvc/llvm-project?rev=245941&view=rev
Log:
Convert SampleProfile pass into a Module pass.

Eventually, we will need sample profiles to be incorporated into the
inliner's cost models.  To do this, we need the sample profile pass to
be a module pass.

This patch makes no functional changes beyond the mechanical adjustments
needed to run SampleProfile as a module pass.

Modified:
cfe/trunk/lib/CodeGen/BackendUtil.cpp

Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=245941&r1=245940&r2=245941&view=diff
==
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Tue Aug 25 10:25:13 2015
@@ -166,14 +166,6 @@ static void addObjCARCOptPass(const Pass
 PM.add(createObjCARCOptPass());
 }
 
-static void addSampleProfileLoaderPass(const PassManagerBuilder &Builder,
-   legacy::PassManagerBase &PM) {
-  const PassManagerBuilderWrapper &BuilderWrapper =
-  static_cast(Builder);
-  const CodeGenOptions &CGOpts = BuilderWrapper.getCGOpts();
-  PM.add(createSampleProfileLoaderPass(CGOpts.SampleProfileFile));
-}
-
 static void addAddDiscriminatorsPass(const PassManagerBuilder &Builder,
  legacy::PassManagerBase &PM) {
   PM.add(createAddDiscriminatorsPass());
@@ -301,10 +293,6 @@ void EmitAssemblyHelper::CreatePasses()
   PMBuilder.addExtension(PassManagerBuilder::EP_EarlyAsPossible,
  addAddDiscriminatorsPass);
 
-  if (!CodeGenOpts.SampleProfileFile.empty())
-PMBuilder.addExtension(PassManagerBuilder::EP_EarlyAsPossible,
-   addSampleProfileLoaderPass);
-
   // In ObjC ARC mode, add the main ARC optimization passes.
   if (LangOpts.ObjCAutoRefCount) {
 PMBuilder.addExtension(PassManagerBuilder::EP_EarlyAsPossible,
@@ -423,6 +411,9 @@ void EmitAssemblyHelper::CreatePasses()
 MPM->add(createInstrProfilingPass(Options));
   }
 
+  if (!CodeGenOpts.SampleProfileFile.empty())
+MPM->add(createSampleProfileLoaderPass(CodeGenOpts.SampleProfileFile));
+
   PMBuilder.populateModulePassManager(*MPM);
 }
 


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D12321: Avoid LoopConvertCheck replacements in template instantiations.

2015-08-25 Thread Alexander Kornienko via cfe-commits
alexfh added a comment.

Thanks! Still looks good.


http://reviews.llvm.org/D12321



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r245942 - Avoid LoopConvertCheck replacements in template instantiations.

2015-08-25 Thread Angel Garcia Gomez via cfe-commits
Author: angelgarcia
Date: Tue Aug 25 10:44:00 2015
New Revision: 245942

URL: http://llvm.org/viewvc/llvm-project?rev=245942&view=rev
Log:
Avoid LoopConvertCheck replacements in template instantiations.

Summary: Prevent LoopConvertCheck from doing replacements in template 
instantiations, and add a test.

Reviewers: alexfh

Subscribers: klimek, cfe-commits

Differential Revision: http://reviews.llvm.org/D12321

Modified:
clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp
clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-extra.cpp

Modified: clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp?rev=245942&r1=245941&r2=245942&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp Tue Aug 
25 10:44:00 2015
@@ -70,6 +70,7 @@ StatementMatcher makeArrayLoopMatcher()
   expr(hasType(isInteger())).bind(ConditionBoundName);
 
   return forStmt(
+ unless(isInTemplateInstantiation()),
  hasLoopInit(declStmt(hasSingleDecl(InitToZeroMatcher))),
  hasCondition(anyOf(
  binaryOperator(hasOperatorName("<"),
@@ -159,6 +160,7 @@ StatementMatcher makeIteratorLoopMatcher
   .bind(DerefByRefResultName)));
 
   return forStmt(
+ unless(isInTemplateInstantiation()),
  hasLoopInit(anyOf(declStmt(declCountIs(2),
 containsDeclaration(0, 
InitDeclMatcher),
 containsDeclaration(1, 
EndDeclMatcher)),
@@ -258,6 +260,7 @@ StatementMatcher makePseudoArrayLoopMatc
  EndInitMatcher));
 
   return forStmt(
+ unless(isInTemplateInstantiation()),
  hasLoopInit(
  anyOf(declStmt(declCountIs(2),
 containsDeclaration(0, InitToZeroMatcher),

Modified: 
clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-extra.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-extra.cpp?rev=245942&r1=245941&r2=245942&view=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-extra.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-extra.cpp 
Tue Aug 25 10:44:00 2015
@@ -626,3 +626,24 @@ void messing_with_macros() {
 }
 
 } // namespace Macros
+
+namespace Templates {
+
+template 
+void set_union(Container &container) {
+  for (typename Container::const_iterator SI = container.begin(),
+   SE = container.end(); SI != SE; ++SI) {
+  }
+  S s;
+  for (S::iterator SI = s.begin(), SE = s.end(); SI != SE; ++SI) {
+  }
+  // CHECK-MESSAGES: :[[@LINE-2]]:3: warning: use range-based for loop instead
+  // CHECK-FIXES: for (auto & elem : s) {
+}
+
+void template_instantiation() {
+  S a;
+  set_union(a);
+}
+
+} // namespace Templates


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D12134: Improve debug info for implicitly captured vars in lambdas

2015-08-25 Thread David Blaikie via cfe-commits
On Tue, Aug 25, 2015 at 8:44 AM, Bataev, Alexey 
wrote:

> Debug info points to the real place where it is captured, while
> diagnostics points to the first use of implicitly captured variable.


Right, but I'm trying to understand the justification for why that's the
right thing to do. Why the debug info user would want a different
experience than the compiler diagnostic consumer would want.

- David


>
>
> Best regards,
> Alexey Bataev
> =
> Software Engineer
> Intel Compiler Team
>
> 25.08.2015 18:22, David Blaikie пишет:
>
>>
>>
>> On Tue, Aug 25, 2015 at 8:18 AM, Bataev, Alexey > > wrote:
>>
>> I though about this. I think it will be more convenient for user
>> to see the diagnostic on the first use of the variable rather than
>> on '=' or '&' symbol.
>>
>>
>> Why the difference between the diagnostic & the debug info, then?
>>
>>
>> Best regards,
>> Alexey Bataev
>> =
>> Software Engineer
>> Intel Compiler Team
>>
>> 25.08.2015 18 :07, David Blaikie пишет:
>>
>>
>>
>> On Tue, Aug 18, 2015 at 9:05 PM, Alexey Bataev via cfe-commits
>> > 
>> >
>> >> wrote:
>>
>> ABataev created this revision.
>> ABataev added reviewers: echristo, rjmccall, rsmith.
>> ABataev added a subscriber: cfe-commits.
>>
>> When variables are implicitly captured in lambdas, debug info
>> generated for captured variables points to location where
>> they are
>> used first.  This patch makes debug info to point to capture
>> default location.
>>
>>
>> Not sure if this is the right tradeoff, or if it is, perhaps
>> we should reconsider how our diagnostics work too?
>>
>> Currently if you, say, capture a variable by value and that
>> variable doesn't have an accessible copy ctor, the diagnostic
>> points to the first use. Should we change that too?
>>
>>
>> http://reviews.llvm.org/D12134
>>
>> Files:
>>   lib/Sema/SemaLambda.cpp
>>   test/CodeGenCXX/debug-lambda-expressions.cpp
>>
>> Index: lib/Sema/SemaLambda.cpp
>>
>> ===
>> --- lib/Sema/SemaLambda.cpp
>> +++ lib/Sema/SemaLambda.cpp
>> @@ -1377,10 +1377,10 @@
>>  }
>>
>>  static ExprResult performLambdaVarCaptureInitialization(
>> -Sema &S, LambdaScopeInfo::Capture &Capture,
>> -FieldDecl *Field,
>> +Sema &S, LambdaScopeInfo::Capture &Capture, FieldDecl
>> *Field,
>>  SmallVectorImpl &ArrayIndexVars,
>> -SmallVectorImpl &ArrayIndexStarts) {
>> +SmallVectorImpl &ArrayIndexStarts, bool
>> ImplicitCapture,
>> +SourceLocation CaptureDefaultLoc) {
>>assert(Capture.isVariableCapture() && "not a variable
>> capture");
>>
>>auto *Var = Capture.getVariable();
>> @@ -1399,7 +1399,10 @@
>>//   An entity captured by a lambda-expression is
>> odr-used (3.2) in
>>//   the scope containing the lambda-expression.
>>ExprResult RefResult = S.BuildDeclarationNameExpr(
>> -  CXXScopeSpec(), DeclarationNameInfo(Var->getDeclName(),
>> Loc), Var);
>> +  CXXScopeSpec(),
>> + DeclarationNameInfo(Var->getDeclName(),
>> +  ImplicitCapture ?
>> CaptureDefaultLoc : Loc),
>> +  Var);
>>if (RefResult.isInvalid())
>>  return ExprError();
>>Expr *Ref = RefResult.get();
>> @@ -1561,7 +1564,8 @@
>>Expr *Init = From.getInitExpr();
>>if (!Init) {
>>  auto InitResult =
>> performLambdaVarCaptureInitialization(
>> -*this, From, *CurField, ArrayIndexVars,
>> ArrayIndexStarts);
>> +*this, From, *CurField, ArrayIndexVars,
>> ArrayIndexStarts,
>> +CaptureDefault != LCD_None, CaptureDefaultLoc);
>>  if (InitResult.isInvalid())
>>return ExprError();
>>  Init = InitResult.get();
>> Index: test/CodeGenCXX/debug-lambda-expressions.cpp
>>
>> ===
>> --- test/CodeGenCXX/debug-lambda-expressions.cpp
>> +++ test/CodeGenCXX/debug-lambda-expressions.cpp
>> @@ -14,6 +14,19 @@
>>  struct D { D(); D(const D&); int x; };
>>  int d(int x) { D y

Re: [PATCH] D12134: Improve debug info for implicitly captured vars in lambdas

2015-08-25 Thread Bataev, Alexey via cfe-commits
Debug info points to the real place where it is captured, while 
diagnostics points to the first use of implicitly captured variable.


Best regards,
Alexey Bataev
=
Software Engineer
Intel Compiler Team

25.08.2015 18:22, David Blaikie пишет:



On Tue, Aug 25, 2015 at 8:18 AM, Bataev, Alexey > wrote:


I though about this. I think it will be more convenient for user
to see the diagnostic on the first use of the variable rather than
on '=' or '&' symbol.


Why the difference between the diagnostic & the debug info, then?


Best regards,
Alexey Bataev
=
Software Engineer
Intel Compiler Team

25.08.2015 18 :07, David Blaikie пишет:



On Tue, Aug 18, 2015 at 9:05 PM, Alexey Bataev via cfe-commits
mailto:cfe-commits@lists.llvm.org>
>> wrote:

ABataev created this revision.
ABataev added reviewers: echristo, rjmccall, rsmith.
ABataev added a subscriber: cfe-commits.

When variables are implicitly captured in lambdas, debug info
generated for captured variables points to location where
they are
used first.  This patch makes debug info to point to capture
default location.


Not sure if this is the right tradeoff, or if it is, perhaps
we should reconsider how our diagnostics work too?

Currently if you, say, capture a variable by value and that
variable doesn't have an accessible copy ctor, the diagnostic
points to the first use. Should we change that too?


http://reviews.llvm.org/D12134

Files:
  lib/Sema/SemaLambda.cpp
  test/CodeGenCXX/debug-lambda-expressions.cpp

Index: lib/Sema/SemaLambda.cpp
===
--- lib/Sema/SemaLambda.cpp
+++ lib/Sema/SemaLambda.cpp
@@ -1377,10 +1377,10 @@
 }

 static ExprResult performLambdaVarCaptureInitialization(
-Sema &S, LambdaScopeInfo::Capture &Capture,
-FieldDecl *Field,
+Sema &S, LambdaScopeInfo::Capture &Capture, FieldDecl
*Field,
 SmallVectorImpl &ArrayIndexVars,
-SmallVectorImpl &ArrayIndexStarts) {
+SmallVectorImpl &ArrayIndexStarts, bool
ImplicitCapture,
+SourceLocation CaptureDefaultLoc) {
   assert(Capture.isVariableCapture() && "not a variable
capture");

   auto *Var = Capture.getVariable();
@@ -1399,7 +1399,10 @@
   //   An entity captured by a lambda-expression is
odr-used (3.2) in
   //   the scope containing the lambda-expression.
   ExprResult RefResult = S.BuildDeclarationNameExpr(
-  CXXScopeSpec(), DeclarationNameInfo(Var->getDeclName(),
Loc), Var);
+  CXXScopeSpec(),
+ DeclarationNameInfo(Var->getDeclName(),
+  ImplicitCapture ?
CaptureDefaultLoc : Loc),
+  Var);
   if (RefResult.isInvalid())
 return ExprError();
   Expr *Ref = RefResult.get();
@@ -1561,7 +1564,8 @@
   Expr *Init = From.getInitExpr();
   if (!Init) {
 auto InitResult =
performLambdaVarCaptureInitialization(
-*this, From, *CurField, ArrayIndexVars,
ArrayIndexStarts);
+*this, From, *CurField, ArrayIndexVars,
ArrayIndexStarts,
+CaptureDefault != LCD_None, CaptureDefaultLoc);
 if (InitResult.isInvalid())
   return ExprError();
 Init = InitResult.get();
Index: test/CodeGenCXX/debug-lambda-expressions.cpp
===
--- test/CodeGenCXX/debug-lambda-expressions.cpp
+++ test/CodeGenCXX/debug-lambda-expressions.cpp
@@ -14,6 +14,19 @@
 struct D { D(); D(const D&); int x; };
 int d(int x) { D y[10]; return [x,y] { return y[x].x; }(); }

+// CHECK-LABEL: foo
+int foo(int x) {
+// CHECK: [[X:%.+]] = alloca i32,
+// CHECK: call void @llvm.dbg.declare(
+// CHECK: [[X_REF:%.+]] = getelementptr inbounds %{{.+}},
%{{.+}}* %{{.+}}, i32 0, i32 0, !dbg ![[DBG_FOO:[0-9]+]]
+// CHECK: [[X_VAL:%.+]] = load i32, i32* [[X]], align 4, !dbg
![[DBG_FOO]]
+// CHECK: store i32 [[X_VAL]], i32* [[X_REF]], align 4, !dbg
![[DBG_FOO]]
+// CHECK: call i32 @{{.+}}, !dbg ![[DB

Re: [PATCH] D12134: Improve debug info for implicitly captured vars in lambdas

2015-08-25 Thread Eric Christopher via cfe-commits
Yeah. I can't see a difference here being useful, and more likely harmful.

On Tue, Aug 25, 2015, 8:48 AM David Blaikie  wrote:

> On Tue, Aug 25, 2015 at 8:44 AM, Bataev, Alexey 
> wrote:
>
>> Debug info points to the real place where it is captured, while
>> diagnostics points to the first use of implicitly captured variable.
>
>
> Right, but I'm trying to understand the justification for why that's the
> right thing to do. Why the debug info user would want a different
> experience than the compiler diagnostic consumer would want.
>
>
> - David
>
>
>>
>>
>> Best regards,
>> Alexey Bataev
>> =
>> Software Engineer
>> Intel Compiler Team
>>
>> 25.08.2015 18:22, David Blaikie пишет:
>>
>>>
>>>
>>> On Tue, Aug 25, 2015 at 8:18 AM, Bataev, Alexey >> > wrote:
>>>
>>> I though about this. I think it will be more convenient for user
>>> to see the diagnostic on the first use of the variable rather than
>>> on '=' or '&' symbol.
>>>
>>>
>>> Why the difference between the diagnostic & the debug info, then?
>>>
>>>
>>> Best regards,
>>> Alexey Bataev
>>> =
>>> Software Engineer
>>> Intel Compiler Team
>>>
>>> 25.08.2015 18 :07, David Blaikie пишет:
>>>
>>>
>>>
>>> On Tue, Aug 18, 2015 at 9:05 PM, Alexey Bataev via cfe-commits
>>> >> 
>>> >>
>>> >> wrote:
>>>
>>> ABataev created this revision.
>>> ABataev added reviewers: echristo, rjmccall, rsmith.
>>> ABataev added a subscriber: cfe-commits.
>>>
>>> When variables are implicitly captured in lambdas, debug info
>>> generated for captured variables points to location where
>>> they are
>>> used first.  This patch makes debug info to point to capture
>>> default location.
>>>
>>>
>>> Not sure if this is the right tradeoff, or if it is, perhaps
>>> we should reconsider how our diagnostics work too?
>>>
>>> Currently if you, say, capture a variable by value and that
>>> variable doesn't have an accessible copy ctor, the diagnostic
>>> points to the first use. Should we change that too?
>>>
>>>
>>> http://reviews.llvm.org/D12134
>>>
>>> Files:
>>>   lib/Sema/SemaLambda.cpp
>>>   test/CodeGenCXX/debug-lambda-expressions.cpp
>>>
>>> Index: lib/Sema/SemaLambda.cpp
>>>
>>> ===
>>> --- lib/Sema/SemaLambda.cpp
>>> +++ lib/Sema/SemaLambda.cpp
>>> @@ -1377,10 +1377,10 @@
>>>  }
>>>
>>>  static ExprResult performLambdaVarCaptureInitialization(
>>> -Sema &S, LambdaScopeInfo::Capture &Capture,
>>> -FieldDecl *Field,
>>> +Sema &S, LambdaScopeInfo::Capture &Capture, FieldDecl
>>> *Field,
>>>  SmallVectorImpl &ArrayIndexVars,
>>> -SmallVectorImpl &ArrayIndexStarts) {
>>> +SmallVectorImpl &ArrayIndexStarts, bool
>>> ImplicitCapture,
>>> +SourceLocation CaptureDefaultLoc) {
>>>assert(Capture.isVariableCapture() && "not a variable
>>> capture");
>>>
>>>auto *Var = Capture.getVariable();
>>> @@ -1399,7 +1399,10 @@
>>>//   An entity captured by a lambda-expression is
>>> odr-used (3.2) in
>>>//   the scope containing the lambda-expression.
>>>ExprResult RefResult = S.BuildDeclarationNameExpr(
>>> -  CXXScopeSpec(),
>>> DeclarationNameInfo(Var->getDeclName(),
>>> Loc), Var);
>>> +  CXXScopeSpec(),
>>> + DeclarationNameInfo(Var->getDeclName(),
>>> +  ImplicitCapture ?
>>> CaptureDefaultLoc : Loc),
>>> +  Var);
>>>if (RefResult.isInvalid())
>>>  return ExprError();
>>>Expr *Ref = RefResult.get();
>>> @@ -1561,7 +1564,8 @@
>>>Expr *Init = From.getInitExpr();
>>>if (!Init) {
>>>  auto InitResult =
>>> performLambdaVarCaptureInitialization(
>>> -*this, From, *CurField, ArrayIndexVars,
>>> ArrayIndexStarts);
>>> +*this, From, *CurField, ArrayIndexVars,
>>> ArrayIndexStarts,
>>> +CaptureDefault != LCD_None, CaptureDefaultLoc);
>>>  if (InitResult.isInvalid())
>>>return ExprError();
>>>  Init = InitResult.get();
>>> Index: test/CodeGenCXX/debug-lambda-expressions.cpp
>>>
>>> ==

Re: [PATCH] D11297: PR17829: Functions declared extern "C" with a name matching a mangled C++ function are allowed

2015-08-25 Thread Andrey Bokhanko via cfe-commits
andreybokhanko updated this revision to Diff 33083.
andreybokhanko added a comment.

John,

I implemented precisely what you described (or so I believe :-))

Patch is updated; please re-review.

This patch implements support for functions, but not variables yet -- the patch 
is big enough already, so variables will come next.

Note that the biggest change in CodeGenModule.cpp is just moving of several 
static functions to another part of the file (to make them accessible earlier).

Yours,
Andrey


http://reviews.llvm.org/D11297

Files:
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/CodeGen/CGCXX.cpp
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/CodeGenModule.h
  lib/CodeGen/ItaniumCXXABI.cpp
  test/CodeGenCXX/duplicate-mangled-name.cpp

Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -237,6 +237,20 @@
   }
 }
 
+void CodeGenModule::addGlobalValReplacement(llvm::GlobalValue *GV, llvm::Constant *C) {
+  GlobalValReplacements.push_back(std::make_pair(GV, C));
+}
+
+void CodeGenModule::applyGlobalValReplacements() {
+  for (auto &I : GlobalValReplacements) {
+llvm::GlobalValue *GV = I.first;
+llvm::Constant *C = I.second;
+
+GV->replaceAllUsesWith(C);
+GV->eraseFromParent();
+  }
+}
+
 // This is only used in aliases that we created and we know they have a
 // linear structure.
 static const llvm::GlobalObject *getAliasedGlobal(const llvm::GlobalAlias &GA) {
@@ -339,6 +353,7 @@
 
 void CodeGenModule::Release() {
   EmitDeferred();
+  applyGlobalValReplacements();
   applyReplacements();
   checkAliases();
   EmitCXXGlobalInitFunc();
@@ -1108,8 +1123,19 @@
 llvm::GlobalValue *GV = G.GV;
 G.GV = nullptr;
 
-assert(!GV || GV == GetGlobalValue(getMangledName(D)));
-if (!GV)
+// Name of this global value is taken => it will be replaced, so no need to
+// emit it.
+if (GV && GV != GetGlobalValue(getMangledName(D)))
+  continue;
+
+// We should call GetAddrOfGlobal with IsForDefinition set to true in order
+// to get GlobalValue with exactly the type we need, not something that
+// might had been created for another decl with the same mangled name but
+// different type.
+// FIXME: Support for variables is not implemented yet.
+if (isa(D.getDecl()))
+  GV = cast(GetAddrOfGlobal(D, /*IsForDefinition=*/true));
+else
   GV = GetGlobalValue(getMangledName(D));
 
 // Check to see if we've already emitted this.  This is necessary
@@ -1541,6 +1567,140 @@
   llvm_unreachable("Invalid argument to EmitGlobalDefinition()");
 }
 
+/// Replace the uses of a function that was declared with a non-proto type.
+/// We want to silently drop extra arguments from call sites
+static void replaceUsesOfNonProtoConstant(llvm::Constant *old,
+  llvm::Function *newFn) {
+  // Fast path.
+  if (old->use_empty()) return;
+
+  llvm::Type *newRetTy = newFn->getReturnType();
+  SmallVector newArgs;
+
+  for (llvm::Value::use_iterator ui = old->use_begin(), ue = old->use_end();
+ ui != ue; ) {
+llvm::Value::use_iterator use = ui++; // Increment before the use is erased.
+llvm::User *user = use->getUser();
+
+// Recognize and replace uses of bitcasts.  Most calls to
+// unprototyped functions will use bitcasts.
+if (auto *bitcast = dyn_cast(user)) {
+  if (bitcast->getOpcode() == llvm::Instruction::BitCast)
+replaceUsesOfNonProtoConstant(bitcast, newFn);
+  continue;
+}
+
+// Recognize calls to the function.
+llvm::CallSite callSite(user);
+if (!callSite) continue;
+if (!callSite.isCallee(&*use)) continue;
+
+// If the return types don't match exactly, then we can't
+// transform this call unless it's dead.
+if (callSite->getType() != newRetTy && !callSite->use_empty())
+  continue;
+
+// Get the call site's attribute list.
+SmallVector newAttrs;
+llvm::AttributeSet oldAttrs = callSite.getAttributes();
+
+// Collect any return attributes from the call.
+if (oldAttrs.hasAttributes(llvm::AttributeSet::ReturnIndex))
+  newAttrs.push_back(
+llvm::AttributeSet::get(newFn->getContext(),
+oldAttrs.getRetAttributes()));
+
+// If the function was passed too few arguments, don't transform.
+unsigned newNumArgs = newFn->arg_size();
+if (callSite.arg_size() < newNumArgs) continue;
+
+// If extra arguments were passed, we silently drop them.
+// If any of the types mismatch, we don't transform.
+unsigned argNo = 0;
+bool dontTransform = false;
+for (llvm::Function::arg_iterator ai = newFn->arg_begin(),
+   ae = newFn->arg_end(); ai != ae; ++ai, ++argNo) {
+  if (callSite.getArgument(argNo)->getType() != ai->getType()) {
+dontTransform = true;
+break;
+  }
+
+   

Re: [PATCH] D12137: Fix 4 typos in test/CodeGenCXX/

2015-08-25 Thread Reid Kleckner via cfe-commits
rnk closed this revision.
rnk added a comment.

Looks like this landed as r245817.


http://reviews.llvm.org/D12137



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r245949 - [Static Analyzer] Fixed a typo in a diagnostic message.

2015-08-25 Thread Gabor Horvath via cfe-commits
Author: xazax
Date: Tue Aug 25 11:27:03 2015
New Revision: 245949

URL: http://llvm.org/viewvc/llvm-project?rev=245949&view=rev
Log:
[Static Analyzer] Fixed a typo in a diagnostic message.

Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/ObjCGenericsChecker.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/ObjCGenericsChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/ObjCGenericsChecker.cpp?rev=245949&r1=245948&r2=245949&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/ObjCGenericsChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/ObjCGenericsChecker.cpp Tue Aug 25 
11:27:03 2015
@@ -128,7 +128,7 @@ PathDiagnosticPiece *ObjCGenericsChecker
   llvm::raw_svector_ostream OS(Buf);
   OS << "Type '";
   QualType::print(*TrackedType, Qualifiers(), OS, LangOpts, llvm::Twine());
-  OS << "' is infered from ";
+  OS << "' is inferred from ";
 
   if (const auto *ExplicitCast = dyn_cast(S)) {
 OS << "explicit cast (from '";


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r245951 - [Static Analyzer] Fix tests to reflect the change in the diagnostic message.

2015-08-25 Thread Gabor Horvath via cfe-commits
Author: xazax
Date: Tue Aug 25 11:38:05 2015
New Revision: 245951

URL: http://llvm.org/viewvc/llvm-project?rev=245951&view=rev
Log:
[Static Analyzer] Fix tests to reflect the change in the diagnostic message.

Modified:
cfe/trunk/test/Analysis/generics.m

Modified: cfe/trunk/test/Analysis/generics.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/generics.m?rev=245951&r1=245950&r2=245951&view=diff
==
--- cfe/trunk/test/Analysis/generics.m (original)
+++ cfe/trunk/test/Analysis/generics.m Tue Aug 25 11:38:05 2015
@@ -313,9 +313,9 @@ void testMistmatchedTypeCast(MutableArra
 // CHECK:  
 // CHECK:  depth0
 // CHECK:  extended_message
-// CHECK:  Type 'NSArray *' is infered 
from implicit cast (from 'NSArray *' to 
'NSArray *')
+// CHECK:  Type 'NSArray *' is 
inferred from implicit cast (from 'NSArray *' to 
'NSArray *')
 // CHECK:  message
-// CHECK:  Type 'NSArray *' is infered 
from implicit cast (from 'NSArray *' to 
'NSArray *')
+// CHECK:  Type 'NSArray *' is 
inferred from implicit cast (from 'NSArray *' to 
'NSArray *')
 // CHECK: 
 // CHECK: 
 // CHECK:  kindcontrol
@@ -457,9 +457,9 @@ void testMistmatchedTypeCast(MutableArra
 // CHECK:  
 // CHECK:  depth0
 // CHECK:  extended_message
-// CHECK:  Type 'NSArray *' is infered 
from implicit cast (from 'NSArray *' to 
'NSArray *')
+// CHECK:  Type 'NSArray *' is 
inferred from implicit cast (from 'NSArray *' to 
'NSArray *')
 // CHECK:  message
-// CHECK:  Type 'NSArray *' is infered 
from implicit cast (from 'NSArray *' to 
'NSArray *')
+// CHECK:  Type 'NSArray *' is 
inferred from implicit cast (from 'NSArray *' to 
'NSArray *')
 // CHECK: 
 // CHECK: 
 // CHECK:  kindcontrol
@@ -567,9 +567,9 @@ void testMistmatchedTypeCast(MutableArra
 // CHECK:  
 // CHECK:  depth0
 // CHECK:  extended_message
-// CHECK:  Type 'NSArray *' is infered 
from implicit cast (from 'NSArray *' to 
'NSArray *')
+// CHECK:  Type 'NSArray *' is 
inferred from implicit cast (from 'NSArray *' to 
'NSArray *')
 // CHECK:  message
-// CHECK:  Type 'NSArray *' is infered 
from implicit cast (from 'NSArray *' to 
'NSArray *')
+// CHECK:  Type 'NSArray *' is 
inferred from implicit cast (from 'NSArray *' to 
'NSArray *')
 // CHECK: 
 // CHECK: 
 // CHECK:  kindcontrol
@@ -822,9 +822,9 @@ void testMistmatchedTypeCast(MutableArra
 // CHECK:  
 // CHECK:  depth1
 // CHECK:  extended_message
-// CHECK:  Type 'NSArray *' is infered 
from implicit cast (from 'NSArray *' to 'NSArray *')
+// CHECK:  Type 'NSArray *' is 
inferred from implicit cast (from 'NSArray *' to 
'NSArray *')
 // CHECK:  message
-// CHECK:  Type 'NSArray *' is infered 
from implicit cast (from 'NSArray *' to 'NSArray *')
+// CHECK:  Type 'NSArray *' is 
inferred from implicit cast (from 'NSArray *' to 
'NSArray *')
 // CHECK: 
 // CHECK: 
 // CHECK:  kindcontrol
@@ -961,9 +961,9 @@ void testMistmatchedTypeCast(MutableArra
 // CHECK:  
 // CHECK:  depth0
 // CHECK:  extended_message
-// CHECK:  Type 'NSArray *' is infered 
from implicit cast (from 'NSArray *' to 'NSArray *')
+// CHECK:  Type 'NSArray *' is 
inferred from implicit cast (from 'NSArray *' to 
'NSArray *')
 // CHECK:  message
-// CHECK:  Type 'NSArray *' is infered 
from implicit cast (from 'NSArray *' to 'NSArray *')
+// CHECK:  Type 'NSArray *' is 
inferred from implicit cast (from 'NSArray *' to 
'NSArray *')
 // CHECK: 
 // CHECK: 
 // CHECK:  kindcontrol
@@ -1071,9 +1071,9 @@ void testMistmatchedTypeCast(MutableArra
 // CHECK:  
 // CHECK:  depth0
 // CHECK:  extended_message
-// CHECK:  Type 'NSArray *' is infered 
from implicit cast (from 'NSArray *' to 'NSArray *')
+// CHECK:  Type 'NSArray *' is 
inferred from implicit cast (from 'NSArray *' to 
'NSArray *')
 // CHECK:  message
-// CHECK:  Type 'NSArray *' is infered 
from implicit cast (from 'NSArray *' to 'NSArray *')
+// CHECK:  Type 'NSArray *' is 
inferred from implicit cast (from 'NSArray *' to 
'NSArray *')
 // CHECK: 
 // CHECK: 
 // CHECK:  kindcontrol
@@ -1215,9 +1215,9 @@ void testMistmatchedTypeCast(MutableArra
 // CHECK:  
 // CHECK:  depth0
 // C

r245953 - [Sema] Handle leading and trailing __ for GNU attributes

2015-08-25 Thread David Majnemer via cfe-commits
Author: majnemer
Date: Tue Aug 25 11:44:38 2015
New Revision: 245953

URL: http://llvm.org/viewvc/llvm-project?rev=245953&view=rev
Log:
[Sema] Handle leading and trailing __ for GNU attributes

GNU attributes can have a leading and trailing __ appended/prepended to
the attribute name.  While the parser and AttributeList::getKind did the
right thing, AttributeList::getAttributeSpellingListIndex did not.

This fixes PR24565.

Modified:
cfe/trunk/lib/Sema/AttributeList.cpp
cfe/trunk/test/SemaCXX/attr-print.cpp

Modified: cfe/trunk/lib/Sema/AttributeList.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/AttributeList.cpp?rev=245953&r1=245952&r2=245953&view=diff
==
--- cfe/trunk/lib/Sema/AttributeList.cpp (original)
+++ cfe/trunk/lib/Sema/AttributeList.cpp Tue Aug 25 11:44:38 2015
@@ -109,6 +109,19 @@ void AttributePool::takePool(AttributeLi
 
 #include "clang/Sema/AttrParsedAttrKinds.inc"
 
+static StringRef normalizeAttrName(StringRef AttrName, StringRef ScopeName,
+   AttributeList::Syntax SyntaxUsed) {
+  // Normalize the attribute name, __foo__ becomes foo. This is only allowable
+  // for GNU attributes.
+  bool IsGNU = SyntaxUsed == AttributeList::AS_GNU ||
+   (SyntaxUsed == AttributeList::AS_CXX11 && ScopeName == "gnu");
+  if (IsGNU && AttrName.size() >= 4 && AttrName.startswith("__") &&
+  AttrName.endswith("__"))
+AttrName = AttrName.slice(2, AttrName.size() - 2);
+
+  return AttrName;
+}
+
 AttributeList::Kind AttributeList::getKind(const IdentifierInfo *Name,
const IdentifierInfo *ScopeName,
Syntax SyntaxUsed) {
@@ -118,13 +131,7 @@ AttributeList::Kind AttributeList::getKi
   if (ScopeName)
 FullName += ScopeName->getName();
 
-  // Normalize the attribute name, __foo__ becomes foo. This is only allowable
-  // for GNU attributes.
-  bool IsGNU = SyntaxUsed == AS_GNU || (SyntaxUsed == AS_CXX11 &&
-FullName == "gnu");
-  if (IsGNU && AttrName.size() >= 4 && AttrName.startswith("__") &&
-  AttrName.endswith("__"))
-AttrName = AttrName.slice(2, AttrName.size() - 2);
+  AttrName = normalizeAttrName(AttrName, FullName, SyntaxUsed);
 
   // Ensure that in the case of C++11 attributes, we look for '::foo' if it is
   // unscoped.
@@ -138,8 +145,9 @@ AttributeList::Kind AttributeList::getKi
 unsigned AttributeList::getAttributeSpellingListIndex() const {
   // Both variables will be used in tablegen generated
   // attribute spell list index matching code.
-  StringRef Name = AttrName->getName();
   StringRef Scope = ScopeName ? ScopeName->getName() : "";
+  StringRef Name = normalizeAttrName(AttrName->getName(), Scope,
+ (AttributeList::Syntax)SyntaxUsed);
 
 #include "clang/Sema/AttrSpellingListIndex.inc"
 

Modified: cfe/trunk/test/SemaCXX/attr-print.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/attr-print.cpp?rev=245953&r1=245952&r2=245953&view=diff
==
--- cfe/trunk/test/SemaCXX/attr-print.cpp (original)
+++ cfe/trunk/test/SemaCXX/attr-print.cpp Tue Aug 25 11:44:38 2015
@@ -26,6 +26,9 @@ int small __attribute__((mode(byte)));
 // CHECK: int v __attribute__((visibility("hidden")));
 int v __attribute__((visibility("hidden")));
 
+// CHECK: char *PR24565() __attribute__((malloc))
+char *PR24565() __attribute__((__malloc__));
+
 // CHECK: class __attribute__((consumable("unknown"))) AttrTester1
 class __attribute__((consumable(unknown))) AttrTester1 {
   // CHECK: void callableWhen() __attribute__((callable_when("unconsumed", 
"consumed")));


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D12123: [analyzer] Skip Pre/Post handlers for ObjC calls when receiver is nil.

2015-08-25 Thread Gábor Horváth via cfe-commits
xazax.hun accepted this revision.
xazax.hun added a comment.
This revision is now accepted and ready to land.

Looks good to me.


http://reviews.llvm.org/D12123



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D11737: Add -linker (and -linker=) alias for -fuse-ld=

2015-08-25 Thread Filipe Cabecinhas via cfe-commits
filcab updated this revision to Diff 33085.
filcab marked 3 inline comments as done.
filcab added a comment.

Addressed comments.


http://reviews.llvm.org/D11737

Files:
  include/clang/Driver/Options.td
  test/Driver/fuse-ld.c

Index: test/Driver/fuse-ld.c
===
--- test/Driver/fuse-ld.c
+++ test/Driver/fuse-ld.c
@@ -24,6 +24,13 @@
 // RUN:   | FileCheck %s -check-prefix=CHECK-FREEBSD-PLIB
 // CHECK-FREEBSD-PLIB: error: invalid linker name
 
+// -linker= is an alias to fuse-ld. Don't need to retry all combinations
+// RUN: %clang %s -### -linker=gold \
+// RUN: --sysroot=%S/Inputs/basic_freebsd_tree \
+// RUN: -target x86_64-unknown-freebsd \
+// RUN: -B%S/Inputs/basic_freebsd_tree/usr/bin 2>&1 \
+// RUN:   | FileCheck %s -check-prefix=CHECK-FREEBSD-LINKEREQ-GOLD
+// CHECK-FREEBSD-LINKEREQ-GOLD: 
Inputs/basic_freebsd_tree/usr/bin{{/|\\+}}ld.gold
 
 
 // RUN: %clang %s -### \
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -1849,7 +1849,8 @@
 
 def fprofile_dir : Joined<["-"], "fprofile-dir=">, 
Group;
 
-def fuse_ld_EQ : Joined<["-"], "fuse-ld=">, Group;
+def fuse_ld_EQ : Joined<["-"], "fuse-ld=">, HelpText<"Use linker ">, 
Group;
+def linker_EQ : Joined<["-"], "linker=">, Alias, 
MetaVarName<"">;
 
 defm align_functions : BooleanFFlag<"align-functions">, 
Group;
 def falign_functions_EQ : Joined<["-"], "falign-functions=">, 
Group;


Index: test/Driver/fuse-ld.c
===
--- test/Driver/fuse-ld.c
+++ test/Driver/fuse-ld.c
@@ -24,6 +24,13 @@
 // RUN:   | FileCheck %s -check-prefix=CHECK-FREEBSD-PLIB
 // CHECK-FREEBSD-PLIB: error: invalid linker name
 
+// -linker= is an alias to fuse-ld. Don't need to retry all combinations
+// RUN: %clang %s -### -linker=gold \
+// RUN: --sysroot=%S/Inputs/basic_freebsd_tree \
+// RUN: -target x86_64-unknown-freebsd \
+// RUN: -B%S/Inputs/basic_freebsd_tree/usr/bin 2>&1 \
+// RUN:   | FileCheck %s -check-prefix=CHECK-FREEBSD-LINKEREQ-GOLD
+// CHECK-FREEBSD-LINKEREQ-GOLD: Inputs/basic_freebsd_tree/usr/bin{{/|\\+}}ld.gold
 
 
 // RUN: %clang %s -### \
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -1849,7 +1849,8 @@
 
 def fprofile_dir : Joined<["-"], "fprofile-dir=">, Group;
 
-def fuse_ld_EQ : Joined<["-"], "fuse-ld=">, Group;
+def fuse_ld_EQ : Joined<["-"], "fuse-ld=">, HelpText<"Use linker ">, Group;
+def linker_EQ : Joined<["-"], "linker=">, Alias, MetaVarName<"">;
 
 defm align_functions : BooleanFFlag<"align-functions">, Group;
 def falign_functions_EQ : Joined<["-"], "falign-functions=">, Group;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D11737: Add -linker (and -linker=) alias for -fuse-ld=

2015-08-25 Thread Filipe Cabecinhas via cfe-commits
Hi Richard,

We wouldn't be able to link with libs matching "libinker=*.{dylib,so,...}",
I guess. If that is a big problem and you'd prefer that we keep this as a
private patch, let me know.

Thank you,

  Filipe

On Mon, Aug 24, 2015 at 6:45 PM, Richard Smith 
wrote:

> On Mon, Aug 24, 2015 at 5:50 PM, Eric Christopher via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> echristo added inline comments.
>>
>> 
>> Comment at: include/clang/Driver/Options.td:1853
>> @@ -1853,1 +1852,3 @@
>> +def fuse_ld_EQ : Joined<["-"], "fuse-ld=">, HelpText<"Use linker
>> ">, Group;
>> +def linker_EQ : Joined<["-"], "linker=">, Alias,
>> MetaVarName<"">;
>>
>> 
>> thakis wrote:
>> > Any reason to have another alias for this at all? Does gcc understand
>> this spelling? If not, could you limit this flag to PS4 targets? (I'm
>> guessing you need it for PS4 targets for some reason.)
>> Any reason? (And I'm not sure how to limit it btw on target).
>
>
> -l already has a meaning; adding a different flag starting with -l is a
> bad idea.
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Implict casts disappeared from syntactic init list expressions in C++

2015-08-25 Thread Abramo Bagnara via cfe-commits
Comparing the result of InitListExpr::getSyntacticForm between r224986
and r245836 I've discovered that integer to char implicit cast for
integer literal 3 is no longer added to AST for C++ (while it is present
in C).

This is the source used to test:

char v[10] = { 3 };

Taken in account that:

- implicit cast (and other conversions, constructor calls, etc.) are
very important also for who need to visit the syntactic form (obvious in
*both* C and C++)

- to generate that for the syntactic form permit to increase the
efficiency and the sharing when using designated range extensions (as
the conversion chain don't need to be replicated for each entry)

I think it is a regression. Am I missing something?

-- 
Abramo Bagnara

BUGSENG srl - http://bugseng.com
mailto:abramo.bagn...@bugseng.com
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D12134: Improve debug info for implicitly captured vars in lambdas

2015-08-25 Thread Bataev, Alexey via cfe-commits
Guys, talking about implicitly captured variables we have to deal with 2 
locations: 1) point of real capturing (it is the point of '=' or '&' 
symbols in lambda capture-list); 2) a point of first use of variable 
inside lambda's body.
When we're talking about diagnostic for implicitly captured variables we 
have to deal with the second point, not the first one, because of 
usability. I don't think that the "diagnostic consumer" would be happy 
to see a message like "unnamed variable cannot be implicitly captured in 
a lambda expression" pointing to '=' or '&'. Here we have to emit the 
diagnostic at the point of the very first use of the variable we're 
going to capture to make diagnostic more user-friendly. But actual point 
of capturing is still a point, where we have '=' or '&' symbols in 
capture-list.


Best regards,
Alexey Bataev
=
Software Engineer
Intel Compiler Team

25.08.2015 19:00, Eric Christopher пишет:


Yeah. I can't see a difference here being useful, and more likely harmful.


On Tue, Aug 25, 2015, 8:48 AM David Blaikie > wrote:


On Tue, Aug 25, 2015 at 8:44 AM, Bataev, Alexey
mailto:a.bat...@hotmail.com>> wrote:

Debug info points to the real place where it is captured,
while diagnostics points to the first use of implicitly
captured variable.


Right, but I'm trying to understand the justification for why
that's the right thing to do. Why the debug info user would want a
different experience than the compiler diagnostic consumer would want.


- David



Best regards,
Alexey Bataev
=
Software Engineer
Intel Compiler Team

25.08.2015 18 :22, David Blaikie пишет:



On Tue, Aug 25, 2015 at 8:18 AM, Bataev, Alexey
mailto:a.bat...@hotmail.com>
>> wrote:

I though about this. I think it will be more
convenient for user
to see the diagnostic on the first use of the variable
rather than
on '=' or '&' symbol.


Why the difference between the diagnostic & the debug
info, then?


Best regards,
Alexey Bataev
=
Software Engineer
Intel Compiler Team

25.08.2015 18 
:07, David Blaikie пишет:



On Tue, Aug 18, 2015 at 9:05 PM, Alexey Bataev via
cfe-commits
mailto:cfe-commits@lists.llvm.org>
>




Re: [PATCH] D11737: Add -linker (and -linker=) alias for -fuse-ld=

2015-08-25 Thread Richard Smith via cfe-commits
On Aug 25, 2015 10:26 AM, "Filipe Cabecinhas" <
filcab+llvm.phabrica...@gmail.com> wrote:
>
> Hi Richard,
>
> We wouldn't be able to link with libs matching
"libinker=*.{dylib,so,...}", I guess. If that is a big problem and you'd
prefer that we keep this as a private patch, let me know.

I don't think it's a big problem, more just a "try to pick better flag
names in future" comment :) It sounds like you guys have existing systems
that depend on this name, so while I'm not really overjoyed about this,
accepting it for compatibility seems OK.

Can we produce an accompanying "deprecated" warning suggesting use of the
other name?

> Thank you,
>
>   Filipe
>
>
> On Mon, Aug 24, 2015 at 6:45 PM, Richard Smith 
wrote:
>>
>> On Mon, Aug 24, 2015 at 5:50 PM, Eric Christopher via cfe-commits <
cfe-commits@lists.llvm.org> wrote:
>>>
>>> echristo added inline comments.
>>>
>>> 
>>> Comment at: include/clang/Driver/Options.td:1853
>>> @@ -1853,1 +1852,3 @@
>>> +def fuse_ld_EQ : Joined<["-"], "fuse-ld=">, HelpText<"Use linker
">, Group;
>>> +def linker_EQ : Joined<["-"], "linker=">, Alias,
MetaVarName<"">;
>>>
>>> 
>>> thakis wrote:
>>> > Any reason to have another alias for this at all? Does gcc understand
this spelling? If not, could you limit this flag to PS4 targets? (I'm
guessing you need it for PS4 targets for some reason.)
>>> Any reason? (And I'm not sure how to limit it btw on target).
>>
>>
>> -l already has a meaning; adding a different flag starting with -l is a
bad idea.
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D11789: Modify DeclaratorChuck::getFunction to be passed an Exception Specification SourceRange

2015-08-25 Thread Nathan Wilson via cfe-commits
nwilson added a comment.

Ping


http://reviews.llvm.org/D11789



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D11789: Modify DeclaratorChuck::getFunction to be passed an Exception Specification SourceRange

2015-08-25 Thread Nathan Wilson via cfe-commits
nwilson updated this revision to Diff 33093.

http://reviews.llvm.org/D11789

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/DeclSpec.h
  lib/Parse/ParseDecl.cpp
  lib/Parse/ParseExpr.cpp
  lib/Parse/ParseExprCXX.cpp
  lib/Sema/DeclSpec.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaType.cpp
  test/SemaCXX/cxx-concept-declaration.cpp

Index: test/SemaCXX/cxx-concept-declaration.cpp
===
--- test/SemaCXX/cxx-concept-declaration.cpp
+++ test/SemaCXX/cxx-concept-declaration.cpp
@@ -1,11 +1,14 @@
-// RUN:  %clang_cc1 -std=c++14 -fconcepts-ts -x c++ -verify %s
+// RUN:  %clang_cc1 -std=c++14 -fconcepts-ts -fcxx-exceptions -x c++ -verify %s
 
 namespace A {
   template concept bool C1() { return true; }
 
   template concept bool C2 = true;
 }
 
+template concept bool C3() { return (throw 0, true); }
+static_assert(noexcept(C3()), "function concept should be treated as if noexcept(true) specified");
+
 template concept bool D1(); // expected-error {{function concept declaration must be a definition}}
 
 struct B {
@@ -23,6 +26,9 @@
 template
 concept bool D6; // expected-error {{variable concept declaration must be initialized}}
 
+template
+concept bool D7() throw(int) { return true; } // expected-error {{function concept cannot have exception specification}}
+
 // Tag
 concept class CC1 {}; // expected-error {{'concept' can only appear on the definition of a function template or variable template}}
 concept struct CS1 {}; // expected-error {{'concept' can only appear on the definition of a function template or variable template}}
Index: lib/Sema/SemaType.cpp
===
--- lib/Sema/SemaType.cpp
+++ lib/Sema/SemaType.cpp
@@ -700,7 +700,7 @@
   /*VolatileQualifierLoc=*/NoLoc,
   /*RestrictQualifierLoc=*/NoLoc,
   /*MutableLoc=*/NoLoc, EST_None,
-  /*ESpecLoc=*/NoLoc,
+  /*ESpecRange=*/SourceRange(),
   /*Exceptions=*/nullptr,
   /*ExceptionRanges=*/nullptr,
   /*NumExceptions=*/0,
@@ -3833,9 +3833,10 @@
   // Exception specs are not allowed in typedefs. Complain, but add it
   // anyway.
   if (IsTypedefName && FTI.getExceptionSpecType())
-S.Diag(FTI.getExceptionSpecLoc(), diag::err_exception_spec_in_typedef)
-  << (D.getContext() == Declarator::AliasDeclContext ||
-  D.getContext() == Declarator::AliasTemplateContext);
+S.Diag(FTI.getExceptionSpecLocBeg(),
+   diag::err_exception_spec_in_typedef)
+<< (D.getContext() == Declarator::AliasDeclContext ||
+D.getContext() == Declarator::AliasTemplateContext);
 
   // If we see "T var();" or "T var(T());" at block scope, it is probably
   // an attempt to initialize a variable, not a function declaration.
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -7476,6 +7476,22 @@
 NewFD->setInvalidDecl();
   }
 
+  // C++ Concepts TS [dcl.spec.concept]p1: [...] A function concept shall
+  // have no exception-specification and is treated as if it were specified
+  // with noexcept(true) (15.4). [...]
+  if (const FunctionProtoType *FPT = R->getAs()) {
+if (FPT->hasExceptionSpec()) {
+  SourceRange Range;
+  if (D.isFunctionDeclarator())
+Range = D.getFunctionTypeInfo().getExceptionSpecRange();
+  Diag(NewFD->getLocation(), diag::err_function_concept_exception_spec)
+  << FixItHint::CreateRemoval(Range);
+  NewFD->setInvalidDecl();
+} else {
+  Context.adjustExceptionSpec(NewFD, EST_BasicNoexcept);
+}
+  }
+
   // C++ Concepts TS [dcl.spec.concept]p2: Every concept definition is
   // implicity defined to be a constexpr declaration (implicitly inline)
   NewFD->setImplicitlyInline();
@@ -11123,7 +11139,7 @@
  /*RestrictQualifierLoc=*/NoLoc,
  /*MutableLoc=*/NoLoc,
  EST_None,
- /*ESpecLoc=*/NoLoc,
+ /*ESpecRange=*/SourceRange(),
  /*Exceptions=*/nullptr,
  /*ExceptionRanges=*/nullptr,
  /*NumExceptions=*/0,
Index: lib/Sema/DeclSpec.cpp
===
--- lib/Sema/DeclSpec.cpp
+++ lib/Sema/DeclSpec.cpp
@@ -177,7 +177,7 @@
  SourceLocation MutableLoc,
  ExceptionSpecificationType
  ESpecType,
- SourceLocation

[PATCH] D12326: [Modules] Emit warning if module cannot instantiate static class member.

2015-08-25 Thread Serge Pavlov via cfe-commits
sepavloff created this revision.
sepavloff added a subscriber: cfe-commits.

Instantiation of static class members can be not obvious in some cases. Using
modules can cause problems even more difficult to diagnose. PR24425 describes
one of such cases. As a way to assist a user, compiler could issue warnings if
code that is potentially erroneous. This patch implements a warning if a static
class member is used in a module, but cannot be instantiated there.

http://reviews.llvm.org/D12326

Files:
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaDecl.cpp
  test/Modules/Inputs/module-inst.cpp
  test/Modules/Inputs/module-inst/a.h
  test/Modules/Inputs/module-inst/module.modulemap

Index: test/Modules/Inputs/module-inst/module.modulemap
===
--- /dev/null
+++ test/Modules/Inputs/module-inst/module.modulemap
@@ -0,0 +1,3 @@
+module a {
+  header "a.h"
+}
Index: test/Modules/Inputs/module-inst/a.h
===
--- /dev/null
+++ test/Modules/Inputs/module-inst/a.h
@@ -0,0 +1,9 @@
+template  struct Foo_0 {
+  static char s_bar_0;
+};
+template  struct Foo {
+  static char s_bar; // expected-warning{{specialization of the template must be provided somewhere in the application}}
+};
+char baz() {
+  return Foo::s_bar;
+}
Index: test/Modules/Inputs/module-inst.cpp
===
--- /dev/null
+++ test/Modules/Inputs/module-inst.cpp
@@ -0,0 +1,10 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -I%S/Inputs/module-inst %s | FileCheck %s
+
+#include "a.h"
+// CHECK: warning: specialization of the template must be provided somewhere in the application
+// CHECK:   static char s_bar;
+
+template  char Foo::s_bar;
+
+// CHECK: 1 warning generated.
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -24,6 +24,7 @@
 #include "clang/AST/DeclTemplate.h"
 #include "clang/AST/EvaluatedExprVisitor.h"
 #include "clang/AST/ExprCXX.h"
+#include "clang/AST/RecursiveASTVisitor.h"
 #include "clang/AST/StmtCXX.h"
 #include "clang/Basic/Builtins.h"
 #include "clang/Basic/PartialDiagnostic.h"
@@ -43,6 +44,7 @@
 #include "clang/Sema/Scope.h"
 #include "clang/Sema/ScopeInfo.h"
 #include "clang/Sema/Template.h"
+#include "llvm/ADT/SmallPtrSet.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/Triple.h"
 #include 
@@ -14321,6 +14323,44 @@
   }
 }
 
+namespace {
+
+/// \brief Visitor that processes declarations that are instantiated from
+/// templates.
+///
+class InstantiationScanner : public RecursiveASTVisitor {
+  Sema &SemaRef;
+  llvm::SmallPtrSet seen;
+public:
+  InstantiationScanner(Sema &S) : SemaRef(S) { }
+
+  bool VisitDeclRefExpr(DeclRefExpr *E) {
+ValueDecl *D = E->getDecl();
+if (seen.count(D))
+  return true;
+if (VarDecl *VD = dyn_cast(D)) {
+  if (VD->getDeclContext()->isRecord()) {
+if (isa(VD->getDeclContext())) {
+  // Reference to static class member instantiation
+  seen.insert(D);
+  bool HasDefinition = false;
+  for (auto *R : VD->redecls()) {
+if (R->getDefinition()) {
+  HasDefinition = true;
+  break;
+}
+  }
+  if (!HasDefinition)
+SemaRef.Diag(VD->getLocation(), diag::warn_module_external_spec);
+}
+  }
+}
+return true;
+  }
+};
+
+}
+
 DeclResult Sema::ActOnModuleImport(SourceLocation AtLoc, 
SourceLocation ImportLoc, 
ModuleIdPath Path) {
@@ -14401,6 +14441,8 @@
 
 void Sema::ActOnModuleEnd(SourceLocation DirectiveLoc, Module *Mod) {
   checkModuleImportContext(*this, Mod, DirectiveLoc, CurContext);
+  InstantiationScanner Scanner(*this);
+  Scanner.TraverseDecl(getASTContext().getTranslationUnitDecl());
 
   if (getLangOpts().ModulesLocalVisibility) {
 VisibleModules = std::move(VisibleModulesStack.back());
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -7741,6 +7741,9 @@
   "import of module '%0' appears within same top-level module '%1'">;
 def err_module_import_in_implementation : Error<
   "@import of module '%0' in implementation of '%1'; use #import">;
+def warn_module_external_spec : Warning<
+  "specialization of the template must be provided somewhere in the application">,
+  InGroup;
 }
 
 let CategoryName = "Documentation Issue" in {
Index: include/clang/Basic/DiagnosticGroups.td
===
--- include/clang/Basic/DiagnosticGroups.td
+++ include/clang/Basic/DiagnosticGroups.td

Re: [PATCH] D12299: [libcxx] ABI-Breaking Fix for ALL undefined behavior in .

2015-08-25 Thread Andreas Jacobs via cfe-commits
awi added a subscriber: awi.
awi added a comment.

Hello,
I like your patch very much. I looks similar to my patch from January, so I am 
confident it solves my problem, but it does so a little more elegantly at some 
places.
I tried it with my two sources files main.cpp and main2.cpp. While main.cpp 
works with or without your patch, main2.cpp fails with the current svn head, 
but succeeds with your patch.
After that I executed the libc++ test suite, using `-std=c++1y` as the language 
version. Here, a couple of tests failed to compile. This is not as bad as it 
may sound, though, because I could fix it by adding some missing calls to your 
new `__list_node_base` functions `__as_base()` and `__as_node()`:

  --- include/list  2015-08-25 20:35:00.769897378 +0200
  +++ include/list.corr 2015-08-25 20:10:38.0 +0200
  @@ -1362,9 +1362,9 @@
   __node_alloc_traits::construct(__na, 
_VSTD::addressof(__hold->__value_), __x);
   ++__ds;
   #if _LIBCPP_DEBUG_LEVEL >= 2
  -__r = iterator(__hold.get(), this);
  +__r = iterator(__hold.get()->__as_base(), this);
   #else
  -__r = iterator(__hold.get());
  +__r = iterator(__hold.get()->__as_base());
   #endif
   __hold.release();
   iterator __e = __r;
  @@ -1376,7 +1376,7 @@
   {
   __hold.reset(__node_alloc_traits::allocate(__na, 1));
   __node_alloc_traits::construct(__na, 
_VSTD::addressof(__hold->__value_), __x);
  -__e.__ptr_->__next_ = __hold.get();
  +__e.__ptr_->__next_ = __hold.get()->__as_base();
   __hold->__prev_ = __e.__ptr_;
   __hold.release();
   }
  @@ -1388,7 +1388,7 @@
   {
   __node_alloc_traits::destroy(__na, _VSTD::addressof(*__e));
   __node_base_pointer __prev = __e.__ptr_->__prev_;
  -__node_alloc_traits::deallocate(__na, __e.__ptr_, 1);
  +__node_alloc_traits::deallocate(__na, 
__e.__ptr_->__as_node(), 1);
   if (__prev == 0)
   break;
   #if _LIBCPP_DEBUG_LEVEL >= 2


http://reviews.llvm.org/D12299



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r245965 - Revert r245879. Speculative, might have caused crbug.com/524604

2015-08-25 Thread Nico Weber via cfe-commits
Author: nico
Date: Tue Aug 25 13:43:32 2015
New Revision: 245965

URL: http://llvm.org/viewvc/llvm-project?rev=245965&view=rev
Log:
Revert r245879. Speculative, might have caused crbug.com/524604

Modified:
cfe/trunk/lib/CodeGen/CGCall.cpp
cfe/trunk/lib/CodeGen/CGCall.h
cfe/trunk/test/CodeGenCXX/microsoft-abi-arg-order.cpp
cfe/trunk/test/CodeGenCXX/microsoft-abi-eh-cleanups.cpp

Modified: cfe/trunk/lib/CodeGen/CGCall.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=245965&r1=245964&r2=245965&view=diff
==
--- cfe/trunk/lib/CodeGen/CGCall.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCall.cpp Tue Aug 25 13:43:32 2015
@@ -2782,11 +2782,21 @@ void CallArgList::allocateArgumentMemory
   // alloca and store lazily on the first cleanup emission.
   StackBaseMem = CGF.CreateTempAlloca(CGF.Int8PtrTy, "inalloca.spmem");
   CGF.Builder.CreateStore(StackBase, StackBaseMem);
-  CGF.pushStackRestore(NormalCleanup, StackBaseMem);
+  CGF.pushStackRestore(EHCleanup, StackBaseMem);
   StackCleanup = CGF.EHStack.getInnermostEHScope();
   assert(StackCleanup.isValid());
 }
 
+void CallArgList::freeArgumentMemory(CodeGenFunction &CGF) const {
+  if (StackBase) {
+CGF.DeactivateCleanupBlock(StackCleanup, StackBase);
+llvm::Value *F = CGF.CGM.getIntrinsic(llvm::Intrinsic::stackrestore);
+// We could load StackBase from StackBaseMem, but in the non-exceptional
+// case we can skip it.
+CGF.Builder.CreateCall(F, StackBase);
+  }
+}
+
 void CodeGenFunction::EmitNonNullArgCheck(RValue RV, QualType ArgType,
   SourceLocation ArgLoc,
   const FunctionDecl *FD,
@@ -3523,6 +3533,10 @@ RValue CodeGenFunction::EmitCall(const C
   if (CallArgs.hasWritebacks())
 emitWritebacks(*this, CallArgs);
 
+  // The stack cleanup for inalloca arguments has to run out of the normal
+  // lexical order, so deactivate it and run it manually here.
+  CallArgs.freeArgumentMemory(*this);
+
   RValue Ret = [&] {
 switch (RetAI.getKind()) {
 case ABIArgInfo::InAlloca:

Modified: cfe/trunk/lib/CodeGen/CGCall.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.h?rev=245965&r1=245964&r2=245965&view=diff
==
--- cfe/trunk/lib/CodeGen/CGCall.h (original)
+++ cfe/trunk/lib/CodeGen/CGCall.h Tue Aug 25 13:43:32 2015
@@ -120,6 +120,7 @@ namespace CodeGen {
 
 void allocateArgumentMemory(CodeGenFunction &CGF);
 llvm::Instruction *getStackBase() const { return StackBase; }
+void freeArgumentMemory(CodeGenFunction &CGF) const;
 
 /// \brief Returns if we're using an inalloca struct to pass arguments in
 /// memory.

Modified: cfe/trunk/test/CodeGenCXX/microsoft-abi-arg-order.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/microsoft-abi-arg-order.cpp?rev=245965&r1=245964&r2=245965&view=diff
==
--- cfe/trunk/test/CodeGenCXX/microsoft-abi-arg-order.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/microsoft-abi-arg-order.cpp Tue Aug 25 13:43:32 
2015
@@ -42,12 +42,12 @@ void call_foo() {
 // X86: call i8* @llvm.stacksave()
 // X86: %[[argmem:[^ ]*]] = alloca inalloca [[argmem_ty]]
 // X86: %[[arg3:[^ ]*]] = getelementptr inbounds [[argmem_ty]], [[argmem_ty]]* 
%[[argmem]], i32 0, i32 2
-// X86: call x86_thiscallcc %struct.A* @"\01??0A@@QAE@H@Z"(%struct.A* 
%[[arg3]], i32 3)
+// X86: invoke x86_thiscallcc %struct.A* @"\01??0A@@QAE@H@Z"(%struct.A* 
%[[arg3]], i32 3)
 // X86: %[[arg2:[^ ]*]] = getelementptr inbounds [[argmem_ty]], [[argmem_ty]]* 
%[[argmem]], i32 0, i32 1
 // X86: invoke x86_thiscallcc %struct.A* @"\01??0A@@QAE@H@Z"(%struct.A* 
%[[arg2]], i32 2)
 // X86: %[[arg1:[^ ]*]] = getelementptr inbounds [[argmem_ty]], [[argmem_ty]]* 
%[[argmem]], i32 0, i32 0
 // X86: invoke x86_thiscallcc %struct.A* @"\01??0A@@QAE@H@Z"(%struct.A* 
%[[arg1]], i32 1)
-// X86: call void @"\01?foo@@YAXUA@@00@Z"([[argmem_ty]]* inalloca %[[argmem]])
+// X86: invoke void @"\01?foo@@YAXUA@@00@Z"([[argmem_ty]]* inalloca 
%[[argmem]])
 // X86: call void @llvm.stackrestore
 // X86: ret void
 //

Modified: cfe/trunk/test/CodeGenCXX/microsoft-abi-eh-cleanups.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/microsoft-abi-eh-cleanups.cpp?rev=245965&r1=245964&r2=245965&view=diff
==
--- cfe/trunk/test/CodeGenCXX/microsoft-abi-eh-cleanups.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/microsoft-abi-eh-cleanups.cpp Tue Aug 25 13:43:32 
2015
@@ -17,17 +17,18 @@ void HasEHCleanup() {
 // WIN32-LABEL: define void @"\01?HasEHCleanup@@YAXXZ"() {{.*}} {
 // WIN32:   %[[base:.*]] = call i8* @llvm.stacksave()
 //If this call throws, we have to restore the stack.
-// WIN32: 

Re: [PATCH] D12209: [libcxx] Remove installation rules on Darwin when it would overwrite the system installation.

2015-08-25 Thread Jonathan Roelofs via cfe-commits
jroelofs accepted this revision.
This revision is now accepted and ready to land.


Comment at: CMakeLists.txt:105
@@ +104,3 @@
+if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin" AND NOT 
LIBCXX_OVERRIDE_DARWIN_INSTALL)
+  if ("${CMAKE_INSTALL_PREFIX}" STREQUAL "/usr")
+message(WARNING "Disabling libc++ install rules because installation would 
"

I would check for "/usr/" too.


http://reviews.llvm.org/D12209



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D11297: PR17829: Functions declared extern "C" with a name matching a mangled C++ function are allowed

2015-08-25 Thread John McCall via cfe-commits
rjmccall added a comment.

This looks generally like what I'm looking for, thanks!  Some comments.



Comment at: lib/CodeGen/CodeGenModule.cpp:1129
@@ +1128,3 @@
+if (GV && GV != GetGlobalValue(getMangledName(D)))
+  continue;
+

This is a pretty expensive extra check, and I think it only kicks in on invalid 
code where we've got multiple definitions of a function.  Can we just eliminate 
it?  It's not really a problem to emit the second function definition as long 
as we're not trying to emit it into the same llvm::Function.


Comment at: lib/CodeGen/CodeGenModule.cpp:1573
@@ +1572,3 @@
+static void replaceUsesOfNonProtoConstant(llvm::Constant *old,
+  llvm::Function *newFn) {
+  // Fast path.

Instead of moving this function in this patch, just add a forward declaration.  
If you want to move it, you can do that in a separate patch that only moves the 
function.


Comment at: lib/CodeGen/CodeGenModule.h:349
@@ +348,3 @@
+  llvm::SmallVector, 8>
+GlobalValReplacements;
+

Missing a period in the comment.


Comment at: lib/CodeGen/CodeGenModule.h:354
@@ +353,3 @@
+  /// call).
+  llvm::DenseSet ExplicitDefinitions;
+

I don't think this is necessary.  I don't believe we ever need to emit a 
(mangled) function for definition between starting to emit another function and 
adding its entry block, or between starting to emit a global variable and 
finishing its constant initializer.  So you should be able to just check 
whether the existing llvm::GlobalValue is a definition.

I don't think avoiding emitting the diagnostic multiple times for different 
globals is necessary, or even a good idea.


http://reviews.llvm.org/D11297



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D12209: [libcxx] Remove installation rules on Darwin when it would overwrite the system installation.

2015-08-25 Thread Eric Fiselier via cfe-commits
EricWF added inline comments.


Comment at: CMakeLists.txt:105
@@ +104,3 @@
+if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin" AND NOT 
LIBCXX_OVERRIDE_DARWIN_INSTALL)
+  if ("${CMAKE_INSTALL_PREFIX}" STREQUAL "/usr")
+message(WARNING "Disabling libc++ install rules because installation would 
"

jroelofs wrote:
> I would check for "/usr/" too.
CMake canonicalizes `CMAKE_INSTALL_PREFIX` which includes removing the trailing 
slash. I tested this before submitting the patch.


http://reviews.llvm.org/D12209



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D12209: [libcxx] Remove installation rules on Darwin when it would overwrite the system installation.

2015-08-25 Thread Jonathan Roelofs via cfe-commits
jroelofs added a comment.

Ah, I only tested it by editing the CMakeCache.txt manually... ship it!


http://reviews.llvm.org/D12209



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D12022: Refactored dtor sanitizing into EHScopeStack

2015-08-25 Thread Naomi Musgrave via cfe-commits
nmusgrave updated this revision to Diff 33100.
nmusgrave marked an inline comment as done.
nmusgrave added a comment.

- Check flags before dtor sanitizing


http://reviews.llvm.org/D12022

Files:
  lib/CodeGen/CGCXX.cpp
  lib/CodeGen/CGClass.cpp
  lib/CodeGen/CodeGenModule.h
  test/CodeGenCXX/sanitize-dtor-nontrivial-virtual-base.cpp
  test/CodeGenCXX/sanitize-dtor-repress-aliasing.cpp

Index: test/CodeGenCXX/sanitize-dtor-repress-aliasing.cpp
===
--- /dev/null
+++ test/CodeGenCXX/sanitize-dtor-repress-aliasing.cpp
@@ -0,0 +1,30 @@
+// Test -fsanitize-memory-use-after-dtor
+// RUN: %clang_cc1 -fsanitize=memory -O1 -fsanitize-memory-use-after-dtor -std=c++11 -triple=x86_64-pc-linux -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -fsanitize=memory -O2 -fsanitize-memory-use-after-dtor -std=c++11 -triple=x86_64-pc-linux -emit-llvm -o - %s | FileCheck %s
+
+template 
+class Vector {
+public:
+  int size;
+  ~Vector() {}
+};
+
+// Virtual function table for the derived class only contains
+// its own destructors, with no aliasing to base class dtors.
+struct Base {
+  Vector v;
+  int x;
+  Base() { x = 5; }
+  virtual ~Base() {}
+};
+
+struct Derived : public Base {
+  int z;
+  Derived() { z = 10; }
+  ~Derived() {}
+};
+
+Derived d;
+
+// Definition of virtual function table
+// CHECK: @_ZTV7Derived = {{.*}}(void (%struct.Derived*)* @_ZN7DerivedD1Ev to i8*){{.*}}(void (%struct.Derived*)* @_ZN7DerivedD0Ev to i8*)
Index: test/CodeGenCXX/sanitize-dtor-nontrivial-virtual-base.cpp
===
--- /dev/null
+++ test/CodeGenCXX/sanitize-dtor-nontrivial-virtual-base.cpp
@@ -0,0 +1,82 @@
+// RUN: %clang_cc1 -fsanitize=memory -O0 -fsanitize-memory-use-after-dtor -std=c++11 -triple=x86_64-pc-linux -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -fsanitize=memory -O1 -fsanitize-memory-use-after-dtor -std=c++11 -triple=x86_64-pc-linux -emit-llvm -o - %s | FileCheck %s
+
+template 
+class Vector {
+public:
+  int size;
+  ~Vector() {
+size += 1;
+  }
+};
+
+struct Base {
+  int b1;
+  double b2;
+  Base() {
+b1 = 5;
+b2 = 10.989;
+  }
+  virtual ~Base() {}
+};
+
+struct VirtualBase {
+  int vb1;
+  int vb2;
+  VirtualBase() {
+vb1 = 10;
+vb2 = 11;
+  }
+  virtual ~VirtualBase() {}
+};
+
+struct Derived : public Base, public virtual VirtualBase {
+  int d1;
+  Vector v;
+  int d2;
+  Derived() {
+d1 = 10;
+  }
+  ~Derived() {}
+};
+
+Derived d;
+
+// Destruction order:
+// Derived: int, Vector, Base, VirtualBase
+
+// CHECK-LABEL: define {{.*}}ZN7DerivedD1Ev
+// CHECK: call void {{.*}}ZN11VirtualBaseD2Ev
+// CHECK: ret void
+
+// CHECK-LABEL: define {{.*}}ZN7DerivedD0Ev
+// CHECK: ret void
+
+// CHECK-LABEL: define {{.*}}ZN11VirtualBaseD1Ev
+// CHECK: ret void
+
+// CHECK-LABEL: define {{.*}}ZN11VirtualBaseD0Ev
+// CHECK: ret void
+
+// poison 2 ints
+// CHECK-LABEL: define {{.*}}ZN11VirtualBaseD2Ev
+// CHECK: call void {{.*}}sanitizer_dtor_callback({{.*}}, i64 8)
+// CHECK: ret void
+
+// poison int and double
+// CHECK-LABEL: define {{.*}}ZN4BaseD2Ev
+// CHECK: call void {{.*}}sanitizer_dtor_callback({{.*}}, i64 16)
+// CHECK: ret void
+
+// poison int, ignore vector, poison int
+// CHECK-LABEL: define {{.*}}ZN7DerivedD2Ev
+// CHECK: call void {{.*}}ZN6VectorIiED1Ev
+// CHECK: call void {{.*}}sanitizer_dtor_callback({{.*}}, i64 4)
+// CHECK: call void {{.*}}sanitizer_dtor_callback({{.*}}, i64 4)
+// CHECK: call void {{.*}}ZN4BaseD2Ev
+// CHECK: ret void
+
+// poison int
+// CHECK-LABEL: define {{.*}}ZN6VectorIiED2Ev
+// CHECK: call void {{.*}}sanitizer_dtor_callback({{.*}}, i64 4)
+// CHECK: ret void
Index: lib/CodeGen/CodeGenModule.h
===
--- lib/CodeGen/CodeGenModule.h
+++ lib/CodeGen/CodeGenModule.h
@@ -1098,6 +1098,13 @@
   /// are emitted lazily.
   void EmitGlobal(GlobalDecl D);
 
+  bool
+  HasTrivialDestructorBody(ASTContext &Context,
+   const CXXRecordDecl *BaseClassDecl,
+   const CXXRecordDecl *MostDerivedClassDecl);
+  bool
+  FieldHasTrivialDestructorBody(ASTContext &Context, const FieldDecl *Field);
+
   bool TryEmitDefinitionAsAlias(GlobalDecl Alias, GlobalDecl Target,
 bool InEveryTU);
   bool TryEmitBaseDestructorAsAlias(const CXXDestructorDecl *D);
Index: lib/CodeGen/CGClass.cpp
===
--- lib/CodeGen/CGClass.cpp
+++ lib/CodeGen/CGClass.cpp
@@ -1286,11 +1286,7 @@
   CM.finish();
 }
 
-static bool
-FieldHasTrivialDestructorBody(ASTContext &Context, const FieldDecl *Field);
-
-static bool
-HasTrivialDestructorBody(ASTContext &Context,
+bool CodeGenModule::HasTrivialDestructorBody(ASTContext &Context,
  const CXXRecordDecl *BaseClassDecl,
  const CXXRecordDecl *MostDerivedClassDecl)
 {
@@ -1332,10 +1328,1

Re: [PATCH] D12312: Emiting invariant.group.barrier and adding -fstrict-vptrs

2015-08-25 Thread John McCall via cfe-commits
rjmccall added a comment.

You should add a test that actually checks that your feature works.



Comment at: lib/CodeGen/CGClass.cpp:1279
@@ +1278,3 @@
+  if (CGM.getCodeGenOpts().StrictVPtrs && BaseVPtrsInitialized)
+CXXThisValue = Builder.CreateInvariantGroupBarrier(LoadCXXThis());
+

Should this just be in InitializeVTablePointers?


http://reviews.llvm.org/D12312



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D12169: Relax constexpr rules to improve __builtin_object_size's accuracy

2015-08-25 Thread George Burgess IV via cfe-commits
george.burgess.iv updated this revision to Diff 33104.
george.burgess.iv added a comment.

Talked with Richard, and we both agree that adding 4 EvaluationModes is too 
much for the use case. So, we decided to add a flag to LValue to denote that 
the LValueBase is invalid. This allows us to get by with just 2 new 
EvaluationModes, which is much more acceptable.

LValueBases can only be invalid if you're using one of the shiny new 
EvaluationModes.


http://reviews.llvm.org/D12169

Files:
  lib/AST/ExprConstant.cpp
  test/CodeGen/object-size.c

Index: test/CodeGen/object-size.c
===
--- test/CodeGen/object-size.c
+++ test/CodeGen/object-size.c
@@ -161,6 +161,15 @@
   gi = __builtin_object_size(&foo.a, 2);
   // CHECK: store i32 4
   gi = __builtin_object_size(&foo.a, 3);
+
+  // CHECK: store i32 4
+  gi = __builtin_object_size(&foo.b, 0);
+  // CHECK: store i32 4
+  gi = __builtin_object_size(&foo.b, 1);
+  // CHECK: store i32 4
+  gi = __builtin_object_size(&foo.b, 2);
+  // CHECK: store i32 4
+  gi = __builtin_object_size(&foo.b, 3);
 }
 
 // CHECK: @test20
@@ -221,25 +230,59 @@
   gi = __builtin_object_size(&t[9].t[10], 2);
   // CHECK: store i32 0
   gi = __builtin_object_size(&t[9].t[10], 3);
+
+  // CHECK: store i32 0
+  gi = __builtin_object_size((char*)&t[0] + sizeof(t), 0);
+  // CHECK: store i32 0
+  gi = __builtin_object_size((char*)&t[0] + sizeof(t), 1);
+  // CHECK: store i32 0
+  gi = __builtin_object_size((char*)&t[0] + sizeof(t), 2);
+  // CHECK: store i32 0
+  gi = __builtin_object_size((char*)&t[0] + sizeof(t), 3);
+
+  // CHECK: store i32 0
+  gi = __builtin_object_size((char*)&t[9].t[0] + 10*sizeof(t[0].t), 0);
+  // CHECK: store i32 0
+  gi = __builtin_object_size((char*)&t[9].t[0] + 10*sizeof(t[0].t), 1);
+  // CHECK: store i32 0
+  gi = __builtin_object_size((char*)&t[9].t[0] + 10*sizeof(t[0].t), 2);
+  // CHECK: store i32 0
+  gi = __builtin_object_size((char*)&t[9].t[0] + 10*sizeof(t[0].t), 3);
 }
 
-struct Test23Ty { int t[10]; };
+struct Test23Ty { int a; int t[10]; };
 
 // CHECK: @test23
-void test23(struct Test22Ty *p) {
+void test23(struct Test23Ty *p) {
   // CHECK: call i64 @llvm.objectsize.i64.p0i8(i8* %{{.*}}, i1 false)
   gi = __builtin_object_size(p, 0);
   // CHECK: call i64 @llvm.objectsize.i64.p0i8(i8* %{{.*}}, i1 false)
   gi = __builtin_object_size(p, 1);
   // CHECK: call i64 @llvm.objectsize.i64.p0i8(i8* %{{.*}}, i1 true)
   gi = __builtin_object_size(p, 2);
-
   // Note: this is currently fixed at 0 because LLVM doesn't have sufficient
   // data to correctly handle type=3
   // CHECK: store i32 0
   gi = __builtin_object_size(p, 3);
-}
 
+  // CHECK: call i64 @llvm.objectsize.i64.p0i8(i8* %{{.*}}, i1 false)
+  gi = __builtin_object_size(&p->a, 0);
+  // CHECK: store i32 4
+  gi = __builtin_object_size(&p->a, 1);
+  // CHECK: call i64 @llvm.objectsize.i64.p0i8(i8* %{{.*}}, i1 true)
+  gi = __builtin_object_size(&p->a, 2);
+  // CHECK: store i32 4
+  gi = __builtin_object_size(&p->a, 3);
+
+  // CHECK: call i64 @llvm.objectsize.i64.p0i8(i8* %{{.*}}, i1 false)
+  gi = __builtin_object_size(&p->t[5], 0);
+  // CHECK: store i32 20
+  gi = __builtin_object_size(&p->t[5], 1);
+  // CHECK: call i64 @llvm.objectsize.i64.p0i8(i8* %{{.*}}, i1 true)
+  gi = __builtin_object_size(&p->t[5], 2);
+  // CHECK: store i32 20
+  gi = __builtin_object_size(&p->t[5], 3);
+}
 
 // PR24493 -- ICE if __builtin_object_size called with NULL and (Type & 1) != 0
 // CHECK @test24
@@ -280,3 +323,72 @@
   // CHECK: store i32 0
   gi = __builtin_object_size((void*)0 + 0x1000, 3);
 }
+
+// CHECK: @test26
+void test26(struct Test23Ty *p) {
+  struct { int t[10]; } t[10];
+
+  // CHECK: store i32 356
+  gi = __builtin_object_size((char*)&t[1].t[1], 0);
+  // CHECK: store i32 36
+  gi = __builtin_object_size((char*)&t[1].t[1], 1);
+  // CHECK: store i32 356
+  gi = __builtin_object_size((char*)&t[1].t[1], 2);
+  // CHECK: store i32 36
+  gi = __builtin_object_size((char*)&t[1].t[1], 3);
+}
+
+// CHECK: @test27
+void test27() {
+  struct { int t[10]; } t[10];
+
+  // CHECK: store i32 359
+  gi = __builtin_object_size((char*)&t[1].t[0]+1, 0);
+  // CHECK: store i32 39
+  gi = __builtin_object_size((char*)&t[1].t[0]+1, 1);
+  // CHECK: store i32 359
+  gi = __builtin_object_size((char*)&t[1].t[0]+1, 2);
+  // CHECK: store i32 39
+  gi = __builtin_object_size((char*)&t[1].t[0]+1, 3);
+}
+
+// CHECK: @test28
+void test28() {
+  struct { int v[10]; } t[10];
+
+  // CHECK: store i32 356
+  gi = __builtin_object_size(&t[0].v[11], 0);
+  // CHECK: store i32 0
+  gi = __builtin_object_size(&t[0].v[12], 1);
+  // CHECK: store i32 348
+  gi = __builtin_object_size(&t[0].v[13], 2);
+  // CHECK: store i32 0
+  gi = __builtin_object_size(&t[0].v[14], 3);
+}
+
+struct Test29IncompleteTy;
+
+// CHECK: @test29
+void test29(struct Test29IncompleteTy *t) {
+  // CHECK: call i64 @llvm.objectsize.i64.p0i8(i8* %{{.*}}, i1 false)
+  gi = __builtin_object_size(

Re: [PATCH] D11361: [OpenMP] Target directive host codegen

2015-08-25 Thread Samuel Antao via cfe-commits
sfantao updated this revision to Diff 33111.
sfantao added a comment.

Move map type and device id enums from CGOpenMPRuntime.h to CGOpenMPRuntime.cpp.


http://reviews.llvm.org/D11361

Files:
  lib/CodeGen/CGOpenMPRuntime.cpp
  lib/CodeGen/CGOpenMPRuntime.h
  lib/CodeGen/CGStmtOpenMP.cpp
  test/OpenMP/target_codegen.cpp

Index: test/OpenMP/target_codegen.cpp
===
--- /dev/null
+++ test/OpenMP/target_codegen.cpp
@@ -0,0 +1,754 @@
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -x c++ -triple powerpc64le-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple i386-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -x c++ -triple i386-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
+// expected-no-diagnostics
+// REQUIRES: powerpc-registered-target
+#ifndef HEADER
+#define HEADER
+
+// CHECK-DAG: [[TT:%.+]] = type { i64, i8 }
+// CHECK-DAG: [[S1:%.+]] = type { double }
+
+// We have 8 target regions, but only 7 that actually will generate offloading
+// code, only 6 will have mapped arguments, and only 4 have all-constant map
+// sizes.
+
+// CHECK-DAG: [[SIZET2:@.+]] = private unnamed_addr constant [1 x i{{32|64}}] [i[[SZ:32|64]] 2]
+// CHECK-DAG: [[MAPT2:@.+]] = private unnamed_addr constant [1 x i32] [i32 3]
+// CHECK-DAG: [[SIZET3:@.+]] = private unnamed_addr constant [2 x i[[SZ]]] [i[[SZ]] 4, i[[SZ]] 2]
+// CHECK-DAG: [[MAPT3:@.+]] = private unnamed_addr constant [2 x i32] [i32 3, i32 3]
+// CHECK-DAG: [[MAPT4:@.+]] = private unnamed_addr constant [9 x i32] [i32 3, i32 3, i32 1, i32 3, i32 3, i32 1, i32 1, i32 3, i32 3]
+// CHECK-DAG: [[SIZET5:@.+]] = private unnamed_addr constant [3 x i[[SZ]]] [i[[SZ]] 4, i[[SZ]] 2, i[[SZ]] 40]
+// CHECK-DAG: [[MAPT5:@.+]] = private unnamed_addr constant [3 x i32] [i32 3, i32 3, i32 3]
+// CHECK-DAG: [[SIZET6:@.+]] = private unnamed_addr constant [4 x i[[SZ]]] [i[[SZ]] 4, i[[SZ]] 2, i[[SZ]] 1, i[[SZ]] 40]
+// CHECK-DAG: [[MAPT6:@.+]] = private unnamed_addr constant [4 x i32] [i32 3, i32 3, i32 3, i32 3]
+// CHECK-DAG: [[MAPT7:@.+]] = private unnamed_addr constant [5 x i32] [i32 3, i32 3, i32 1, i32 1, i32 3]
+// CHECK-DAG: @{{.*}} = private constant i8 0
+// CHECK-DAG: @{{.*}} = private constant i8 0
+// CHECK-DAG: @{{.*}} = private constant i8 0
+// CHECK-DAG: @{{.*}} = private constant i8 0
+// CHECK-DAG: @{{.*}} = private constant i8 0
+// CHECK-DAG: @{{.*}} = private constant i8 0
+// CHECK-DAG: @{{.*}} = private constant i8 0
+
+template
+struct TT{
+  tx X;
+  ty Y;
+};
+
+// CHECK: define {{.*}}[[FOO:@.+]](
+int foo(int n) {
+  int a = 0;
+  short aa = 0;
+  float b[10];
+  float bn[n];
+  double c[5][10];
+  double cn[5][n];
+  TT d;
+
+  // CHECK:   br label %[[TRY:[^,]+]]
+  // CHECK:   [[TRY]]
+  // CHECK:   [[RET:%.+]] = call i32 @__tgt_target(i32 -1, i8* @{{[^,]+}}, i32 0, i8** null, i8** null, i[[SZ]]* null, i32* null)
+  // CHECK-NEXT:  [[ERROR:%.+]] = icmp ne i32 [[RET]], 0
+  // CHECK-NEXT:  br i1 [[ERROR]], label %[[FAIL:[^,]+]], label %[[END:[^,]+]]
+  // CHECK:   [[FAIL]]
+  // CHECK:   call void [[HVT0:@.+]]()
+  // CHECK-NEXT:  br label %[[END]]
+  // CHECK:   [[END]]
+  #pragma omp target
+  {
+  }
+
+  // CHECK:   call void [[HVT1:@.+]](i32* {{[^,]+}})
+  #pragma omp target if(0)
+  {
+a += 1;
+  }
+
+  // CHECK:   br label %[[TRY:[^,]+]]
+  // CHECK:   [[TRY]]
+  // CHECK-DAG:   [[RET:%.+]] = call i32 @__tgt_target(i32 -1, i8* @{{[^,]+}}, i32 1, i8** [[BP:%[^,]+]], i8** [[P:%[^,]+]], i[[SZ]]* getelementptr inbounds ([1 x i[[SZ]]], [1 x i[[SZ]]]* [[SIZET2]], i32 0, i32 0), i32* getelementptr inbounds ([1 x i32], [1 x i32]* [[MAPT2]], i32 0, i32 0))
+  // CHECK-DAG:   [[BP]] = getelementptr inbounds [1 x i8*], [1 x i8*]* [[BPR:%[^,]+]], i32 0, i32 0
+  // CHECK-DAG:   [[P]] = getelementptr inbounds [1 x i8*], [1 x i8*]* [[PR:%[^,]+]], i32 0, i32 0
+  // CHECK-DAG:   [[BPADDR0:%.+]] = getelementptr inbounds [1 x i8*], [1 x i8*]* [[BPR]], i32 0, i32 [[IDX0:[0-9]+]]
+  // CHECK-DAG:   [[PADDR0:%.+]] = getelementptr inbounds [1 x i8*], [1 x i8*]* [[PR]], i32 0, i32 [[IDX0]]
+  // CHECK-DAG:   store i8* [[BP0:%[^,]+]], i8** [[BPADDR0]]
+  // CHECK-DAG:   store i8* [[P0:%[^,]+]], i8** [[PADDR0]]
+  // CHECK-DAG:   [[BP0]] = bitcast i16* %{{.+}} to i8*
+  // CHECK-DAG:   [[P0]] = bitcast i16* %{{.+}} to i8*
+
+  // CHECK:   [[ERROR:%.+]] = icmp ne i32 [[RET]], 0
+  // CHECK-NEXT:  br i1 [[ERROR]], label %[[FAIL:[^,]+]], label %[[END:[^,]+]]
+  // CHECK:   [[FAIL]]
+  // CHECK:   call void [[HVT2:@.+]](i16* {{[^

Re: [PATCH] D12022: Refactored dtor sanitizing into EHScopeStack

2015-08-25 Thread Evgeniy Stepanov via cfe-commits
eugenis added inline comments.


Comment at: lib/CodeGen/CGCXX.cpp:31
@@ -30,1 +30,3 @@
 
+static bool HasTrivialField(CodeGenModule &CGM, const CXXDestructorDecl *D) {
+  for (const auto *Field : D->getParent()->fields())

I think this should be called "HasFieldWithTrivialDestructor".
Also, pass D->getParent() to this function instead of D.


http://reviews.llvm.org/D12022



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D11361: [OpenMP] Target directive host codegen

2015-08-25 Thread Samuel Antao via cfe-commits
sfantao added a comment.

Thanks for the review!

In http://reviews.llvm.org/D11361#232045, @ABataev wrote:

> Samuel, Yes, I thought about different files and different classes. Runtime 
> for offloading codegen is not a part of libomp and it would be good to have 
> separate runtime handler class for target codegen also. We need to think 
> about it in future.


Sure, we can definitely do something like that in the future if we detect a 
clear place to separate. I guess that when we do that, the design of the 
offloading-unrelated lib has to change a little. There are things like the 
capture statement info that may make sense to share between the two 
implementation.



Comment at: lib/CodeGen/CGOpenMPRuntime.h:188-203
@@ -179,2 +187,18 @@
   };
+
+  /// \brief Values for bit flags used to specify the mapping type for
+  /// offloading.
+  enum OpenMPOffloadMappingFlags {
+/// \brief Allocate memory on the device and move data from host to device.
+OMP_MAP_TO = 0x01,
+/// \brief Allocate memory on the device and move data from device to host.
+OMP_MAP_FROM = 0x02,
+  };
+
+  enum OpenMPOffloadingReservedDeviceIDs {
+/// \brief Device ID if the device was not defined, runtime should get it
+/// from environment variables in the spec.
+OMP_DEVICEID_UNDEF = -1,
+  };
+
   CodeGenModule &CGM;

ABataev wrote:
> Move them to .cpp file.
Done!


Comment at: lib/CodeGen/CGOpenMPRuntime.h:761
@@ -714,2 +760,2 @@
 
 #endif

ABataev wrote:
> sfantao wrote:
> > Unlike the other enums, more than one map types need to be combined. E.g., 
> > to/from are two different enums. Once the map clause and 4.1 get to be 
> > support, we will have more combinations. I see two options here: add enums 
> > for all combinations or use a typedef each time an ineger refer to map 
> > types, so the code is more readable. Let me know your thoughts. 
> Yes, I think we need to add separate enums for different combination in 
> Basic/OpenMPKinds.{def, h} for AST. In runtime support library we can 
> represent these combinations as a bit-or of single mapping types.
> 
Ok, I see, it makes sense to do that from the AST for the map clause SEMA. I'm 
keeping the bit-or in the runtime library call codegen as you say.


http://reviews.llvm.org/D11361



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D11737: Add -linker (and -linker=) alias for -fuse-ld=

2015-08-25 Thread Filipe Cabecinhas via cfe-commits
Hi Richard,

On Tue, Aug 25, 2015 at 11:01 AM, Richard Smith 
wrote:

> On Aug 25, 2015 10:26 AM, "Filipe Cabecinhas" <
> filcab+llvm.phabrica...@gmail.com> wrote:
> >
> > Hi Richard,
> >
> > We wouldn't be able to link with libs matching
> "libinker=*.{dylib,so,...}", I guess. If that is a big problem and you'd
> prefer that we keep this as a private patch, let me know.
>
> I don't think it's a big problem, more just a "try to pick better flag
> names in future" comment :) It sounds like you guys have existing systems
> that depend on this name, so while I'm not really overjoyed about this,
> accepting it for compatibility seems OK.
>
Thanks.

> Can we produce an accompanying "deprecated" warning suggesting use of the
> other name?
>
Not on our side. If you still want the warning, I'd prefer to just keep the
flag private than to have the option+warning upstream (basically just for
PS4 toolchain use) and have a private patch to remove the warning anyway.

Let me know what you think,

  Filipe

> Thank you,
> >
> >   Filipe
> >
> >
> > On Mon, Aug 24, 2015 at 6:45 PM, Richard Smith 
> wrote:
> >>
> >> On Mon, Aug 24, 2015 at 5:50 PM, Eric Christopher via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
> >>>
> >>> echristo added inline comments.
> >>>
> >>> 
> >>> Comment at: include/clang/Driver/Options.td:1853
> >>> @@ -1853,1 +1852,3 @@
> >>> +def fuse_ld_EQ : Joined<["-"], "fuse-ld=">, HelpText<"Use linker
> ">, Group;
> >>> +def linker_EQ : Joined<["-"], "linker=">, Alias,
> MetaVarName<"">;
> >>>
> >>> 
> >>> thakis wrote:
> >>> > Any reason to have another alias for this at all? Does gcc
> understand this spelling? If not, could you limit this flag to PS4 targets?
> (I'm guessing you need it for PS4 targets for some reason.)
> >>> Any reason? (And I'm not sure how to limit it btw on target).
> >>
> >>
> >> -l already has a meaning; adding a different flag starting with -l is a
> bad idea.
> >
> >
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D12022: Refactored dtor sanitizing into EHScopeStack

2015-08-25 Thread Naomi Musgrave via cfe-commits
nmusgrave updated this revision to Diff 33115.
nmusgrave added a comment.

- Simplify parameters, rename function, for examining fields of class to 
destroy.


http://reviews.llvm.org/D12022

Files:
  lib/CodeGen/CGCXX.cpp
  lib/CodeGen/CGClass.cpp
  lib/CodeGen/CodeGenModule.h
  test/CodeGenCXX/sanitize-dtor-nontrivial-virtual-base.cpp
  test/CodeGenCXX/sanitize-dtor-repress-aliasing.cpp

Index: test/CodeGenCXX/sanitize-dtor-repress-aliasing.cpp
===
--- /dev/null
+++ test/CodeGenCXX/sanitize-dtor-repress-aliasing.cpp
@@ -0,0 +1,30 @@
+// Test -fsanitize-memory-use-after-dtor
+// RUN: %clang_cc1 -fsanitize=memory -O1 -fsanitize-memory-use-after-dtor -std=c++11 -triple=x86_64-pc-linux -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -fsanitize=memory -O2 -fsanitize-memory-use-after-dtor -std=c++11 -triple=x86_64-pc-linux -emit-llvm -o - %s | FileCheck %s
+
+template 
+class Vector {
+public:
+  int size;
+  ~Vector() {}
+};
+
+// Virtual function table for the derived class only contains
+// its own destructors, with no aliasing to base class dtors.
+struct Base {
+  Vector v;
+  int x;
+  Base() { x = 5; }
+  virtual ~Base() {}
+};
+
+struct Derived : public Base {
+  int z;
+  Derived() { z = 10; }
+  ~Derived() {}
+};
+
+Derived d;
+
+// Definition of virtual function table
+// CHECK: @_ZTV7Derived = {{.*}}(void (%struct.Derived*)* @_ZN7DerivedD1Ev to i8*){{.*}}(void (%struct.Derived*)* @_ZN7DerivedD0Ev to i8*)
Index: test/CodeGenCXX/sanitize-dtor-nontrivial-virtual-base.cpp
===
--- /dev/null
+++ test/CodeGenCXX/sanitize-dtor-nontrivial-virtual-base.cpp
@@ -0,0 +1,82 @@
+// RUN: %clang_cc1 -fsanitize=memory -O0 -fsanitize-memory-use-after-dtor -std=c++11 -triple=x86_64-pc-linux -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -fsanitize=memory -O1 -fsanitize-memory-use-after-dtor -std=c++11 -triple=x86_64-pc-linux -emit-llvm -o - %s | FileCheck %s
+
+template 
+class Vector {
+public:
+  int size;
+  ~Vector() {
+size += 1;
+  }
+};
+
+struct Base {
+  int b1;
+  double b2;
+  Base() {
+b1 = 5;
+b2 = 10.989;
+  }
+  virtual ~Base() {}
+};
+
+struct VirtualBase {
+  int vb1;
+  int vb2;
+  VirtualBase() {
+vb1 = 10;
+vb2 = 11;
+  }
+  virtual ~VirtualBase() {}
+};
+
+struct Derived : public Base, public virtual VirtualBase {
+  int d1;
+  Vector v;
+  int d2;
+  Derived() {
+d1 = 10;
+  }
+  ~Derived() {}
+};
+
+Derived d;
+
+// Destruction order:
+// Derived: int, Vector, Base, VirtualBase
+
+// CHECK-LABEL: define {{.*}}ZN7DerivedD1Ev
+// CHECK: call void {{.*}}ZN11VirtualBaseD2Ev
+// CHECK: ret void
+
+// CHECK-LABEL: define {{.*}}ZN7DerivedD0Ev
+// CHECK: ret void
+
+// CHECK-LABEL: define {{.*}}ZN11VirtualBaseD1Ev
+// CHECK: ret void
+
+// CHECK-LABEL: define {{.*}}ZN11VirtualBaseD0Ev
+// CHECK: ret void
+
+// poison 2 ints
+// CHECK-LABEL: define {{.*}}ZN11VirtualBaseD2Ev
+// CHECK: call void {{.*}}sanitizer_dtor_callback({{.*}}, i64 8)
+// CHECK: ret void
+
+// poison int and double
+// CHECK-LABEL: define {{.*}}ZN4BaseD2Ev
+// CHECK: call void {{.*}}sanitizer_dtor_callback({{.*}}, i64 16)
+// CHECK: ret void
+
+// poison int, ignore vector, poison int
+// CHECK-LABEL: define {{.*}}ZN7DerivedD2Ev
+// CHECK: call void {{.*}}ZN6VectorIiED1Ev
+// CHECK: call void {{.*}}sanitizer_dtor_callback({{.*}}, i64 4)
+// CHECK: call void {{.*}}sanitizer_dtor_callback({{.*}}, i64 4)
+// CHECK: call void {{.*}}ZN4BaseD2Ev
+// CHECK: ret void
+
+// poison int
+// CHECK-LABEL: define {{.*}}ZN6VectorIiED2Ev
+// CHECK: call void {{.*}}sanitizer_dtor_callback({{.*}}, i64 4)
+// CHECK: ret void
Index: lib/CodeGen/CodeGenModule.h
===
--- lib/CodeGen/CodeGenModule.h
+++ lib/CodeGen/CodeGenModule.h
@@ -1098,6 +1098,13 @@
   /// are emitted lazily.
   void EmitGlobal(GlobalDecl D);
 
+  bool
+  HasTrivialDestructorBody(ASTContext &Context,
+   const CXXRecordDecl *BaseClassDecl,
+   const CXXRecordDecl *MostDerivedClassDecl);
+  bool
+  FieldHasTrivialDestructorBody(ASTContext &Context, const FieldDecl *Field);
+
   bool TryEmitDefinitionAsAlias(GlobalDecl Alias, GlobalDecl Target,
 bool InEveryTU);
   bool TryEmitBaseDestructorAsAlias(const CXXDestructorDecl *D);
Index: lib/CodeGen/CGClass.cpp
===
--- lib/CodeGen/CGClass.cpp
+++ lib/CodeGen/CGClass.cpp
@@ -1286,11 +1286,7 @@
   CM.finish();
 }
 
-static bool
-FieldHasTrivialDestructorBody(ASTContext &Context, const FieldDecl *Field);
-
-static bool
-HasTrivialDestructorBody(ASTContext &Context,
+bool CodeGenModule::HasTrivialDestructorBody(ASTContext &Context,
  const CXXRecordDecl *BaseClassDecl,
  const CXXRecordDecl *MostDerivedClassDecl)
 {
@@ -1332,10 +1328

Re: [PATCH] D8774: [analyzer] Prevent ccc/c++-analyzer from hanging on Windows.

2015-08-25 Thread Антон Ярцев via cfe-commits
ayartsev closed this revision.
ayartsev added a comment.

Committed as r241201


http://reviews.llvm.org/D8774



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D9357: [analyzer] Support spaces in compiler path and arguments.

2015-08-25 Thread Антон Ярцев via cfe-commits
ayartsev closed this revision.
ayartsev added a comment.

Merged with http://reviews.llvm.org/D8774.


http://reviews.llvm.org/D9357



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D12272: [X86] Remove unnecessary MMX declarations from Intrin.h

2015-08-25 Thread Simon Pilgrim via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL245975: [X86] Remove unnecessary MMX declarations from 
Intrin.h (authored by RKSimon).

Changed prior to commit:
  http://reviews.llvm.org/D12272?vs=32926&id=33124#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D12272

Files:
  cfe/trunk/lib/Headers/Intrin.h
  cfe/trunk/test/CodeGen/mmx-builtins.c

Index: cfe/trunk/test/CodeGen/mmx-builtins.c
===
--- cfe/trunk/test/CodeGen/mmx-builtins.c
+++ cfe/trunk/test/CodeGen/mmx-builtins.c
@@ -451,3 +451,13 @@
   // CHECK: pcmpgtd
   return _mm_cmpgt_pi32(a, b);
 }
+
+__m64 test90(int a) {
+  // CHECK: movd
+  return _m_from_int(a);
+}
+
+int test91(__m64 a) {
+  // CHECK: movd
+  return _m_to_int(a);
+}
Index: cfe/trunk/lib/Headers/Intrin.h
===
--- cfe/trunk/lib/Headers/Intrin.h
+++ cfe/trunk/lib/Headers/Intrin.h
@@ -49,10 +49,7 @@
 #if defined(__MMX__)
 /* And the random ones that aren't in those files. */
 __m64 _m_from_float(float);
-__m64 _m_from_int(int _l);
-void _m_prefetch(void *);
 float _m_to_float(__m64);
-int _m_to_int(__m64 _M);
 #endif
 
 /* Other assorted instruction intrinsics. */


Index: cfe/trunk/test/CodeGen/mmx-builtins.c
===
--- cfe/trunk/test/CodeGen/mmx-builtins.c
+++ cfe/trunk/test/CodeGen/mmx-builtins.c
@@ -451,3 +451,13 @@
   // CHECK: pcmpgtd
   return _mm_cmpgt_pi32(a, b);
 }
+
+__m64 test90(int a) {
+  // CHECK: movd
+  return _m_from_int(a);
+}
+
+int test91(__m64 a) {
+  // CHECK: movd
+  return _m_to_int(a);
+}
Index: cfe/trunk/lib/Headers/Intrin.h
===
--- cfe/trunk/lib/Headers/Intrin.h
+++ cfe/trunk/lib/Headers/Intrin.h
@@ -49,10 +49,7 @@
 #if defined(__MMX__)
 /* And the random ones that aren't in those files. */
 __m64 _m_from_float(float);
-__m64 _m_from_int(int _l);
-void _m_prefetch(void *);
 float _m_to_float(__m64);
-int _m_to_int(__m64 _M);
 #endif
 
 /* Other assorted instruction intrinsics. */
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r245975 - [X86] Remove unnecessary MMX declarations from Intrin.h

2015-08-25 Thread Simon Pilgrim via cfe-commits
Author: rksimon
Date: Tue Aug 25 16:27:46 2015
New Revision: 245975

URL: http://llvm.org/viewvc/llvm-project?rev=245975&view=rev
Log:
[X86] Remove unnecessary MMX declarations from Intrin.h

As discussed in PR23648 - the intrinsics _m_from_int, _m_to_int and _m_prefetch 
are defined in mmintrin.h and prfchwintrin.h so we don't need to in Intrin.h

Added tests for _m_from_int and _m_to_int

D11338 already added a test for _m_prefetch

Differential Revision: http://reviews.llvm.org/D12272

Modified:
cfe/trunk/lib/Headers/Intrin.h
cfe/trunk/test/CodeGen/mmx-builtins.c

Modified: cfe/trunk/lib/Headers/Intrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/Intrin.h?rev=245975&r1=245974&r2=245975&view=diff
==
--- cfe/trunk/lib/Headers/Intrin.h (original)
+++ cfe/trunk/lib/Headers/Intrin.h Tue Aug 25 16:27:46 2015
@@ -49,10 +49,7 @@ extern "C" {
 #if defined(__MMX__)
 /* And the random ones that aren't in those files. */
 __m64 _m_from_float(float);
-__m64 _m_from_int(int _l);
-void _m_prefetch(void *);
 float _m_to_float(__m64);
-int _m_to_int(__m64 _M);
 #endif
 
 /* Other assorted instruction intrinsics. */

Modified: cfe/trunk/test/CodeGen/mmx-builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/mmx-builtins.c?rev=245975&r1=245974&r2=245975&view=diff
==
--- cfe/trunk/test/CodeGen/mmx-builtins.c (original)
+++ cfe/trunk/test/CodeGen/mmx-builtins.c Tue Aug 25 16:27:46 2015
@@ -451,3 +451,13 @@ __m64 test89(__m64 a, __m64 b) {
   // CHECK: pcmpgtd
   return _mm_cmpgt_pi32(a, b);
 }
+
+__m64 test90(int a) {
+  // CHECK: movd
+  return _m_from_int(a);
+}
+
+int test91(__m64 a) {
+  // CHECK: movd
+  return _m_to_int(a);
+}


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D12340: [X86] Remove unnecessary 3DNow declarations from Intrin.h

2015-08-25 Thread Simon Pilgrim via cfe-commits
RKSimon created this revision.
RKSimon added reviewers: echristo, mkuper, silvas, craig.topper.
RKSimon added a subscriber: cfe-commits.
RKSimon set the repository for this revision to rL LLVM.

Follow up to D12272

This adds the missing 3dnow intrinsics _m_to_float / _m_from_float and removes 
their unnecesary declarations from Intrin.h. These are really just wrappers to 
existing MMX instructions (they are moved to/from the MMX register as i32 as 
3dnow doesn't provide float specific instructions). 

Final part to resolve PR23648

Repository:
  rL LLVM

http://reviews.llvm.org/D12340

Files:
  lib/Headers/Intrin.h
  lib/Headers/mm3dnow.h
  test/CodeGen/3dnow-builtins.c

Index: test/CodeGen/3dnow-builtins.c
===
--- test/CodeGen/3dnow-builtins.c
+++ test/CodeGen/3dnow-builtins.c
@@ -5,6 +5,18 @@
 
 #include 
 
+__m64 test_m_from_float(float f) {
+  // CHECK-LABEL: define i64 @test_m_from_float
+  // CHECK: insertelement <2 x i32> 
+  return _m_from_float(f);
+}
+
+float test_m_to_float(__m64 m) {
+  // CHECK-LABEL: define float @test_m_to_float
+  // CHECK: extractelement <2 x i32>
+  return _m_to_float(m);
+}
+
 __m64 test_m_pavgusb(__m64 m1, __m64 m2) {
   // CHECK-LABEL: define i64 @test_m_pavgusb
   // CHECK: @llvm.x86.3dnow.pavgusb
Index: lib/Headers/mm3dnow.h
===
--- lib/Headers/mm3dnow.h
+++ lib/Headers/mm3dnow.h
@@ -37,6 +37,20 @@
   __builtin_ia32_femms();
 }
 
+static __inline__ float __DEFAULT_FN_ATTRS
+_m_to_float(__m64 __m) {
+  union { int __i; float __f; } __t;
+  __t.__i = __builtin_ia32_vec_ext_v2si((__v2si)__m, 0);
+  return __t.__f;
+}
+
+static __inline__ __m64 __DEFAULT_FN_ATTRS
+_m_from_float(float __f) {
+  union { int __i; float __f; } __t;
+  __t.__f = __f;
+  return (__m64)__builtin_ia32_vec_init_v2si(__t.__i, 0);
+}
+
 static __inline__ __m64 __DEFAULT_FN_ATTRS
 _m_pavgusb(__m64 __m1, __m64 __m2) {
   return (__m64)__builtin_ia32_pavgusb((__v8qi)__m1, (__v8qi)__m2);
Index: lib/Headers/Intrin.h
===
--- lib/Headers/Intrin.h
+++ lib/Headers/Intrin.h
@@ -46,12 +46,6 @@
 extern "C" {
 #endif
 
-#if defined(__MMX__)
-/* And the random ones that aren't in those files. */
-__m64 _m_from_float(float);
-float _m_to_float(__m64);
-#endif
-
 /* Other assorted instruction intrinsics. */
 void __addfsbyte(unsigned long, unsigned char);
 void __addfsdword(unsigned long, unsigned long);


Index: test/CodeGen/3dnow-builtins.c
===
--- test/CodeGen/3dnow-builtins.c
+++ test/CodeGen/3dnow-builtins.c
@@ -5,6 +5,18 @@
 
 #include 
 
+__m64 test_m_from_float(float f) {
+  // CHECK-LABEL: define i64 @test_m_from_float
+  // CHECK: insertelement <2 x i32> 
+  return _m_from_float(f);
+}
+
+float test_m_to_float(__m64 m) {
+  // CHECK-LABEL: define float @test_m_to_float
+  // CHECK: extractelement <2 x i32>
+  return _m_to_float(m);
+}
+
 __m64 test_m_pavgusb(__m64 m1, __m64 m2) {
   // CHECK-LABEL: define i64 @test_m_pavgusb
   // CHECK: @llvm.x86.3dnow.pavgusb
Index: lib/Headers/mm3dnow.h
===
--- lib/Headers/mm3dnow.h
+++ lib/Headers/mm3dnow.h
@@ -37,6 +37,20 @@
   __builtin_ia32_femms();
 }
 
+static __inline__ float __DEFAULT_FN_ATTRS
+_m_to_float(__m64 __m) {
+  union { int __i; float __f; } __t;
+  __t.__i = __builtin_ia32_vec_ext_v2si((__v2si)__m, 0);
+  return __t.__f;
+}
+
+static __inline__ __m64 __DEFAULT_FN_ATTRS
+_m_from_float(float __f) {
+  union { int __i; float __f; } __t;
+  __t.__f = __f;
+  return (__m64)__builtin_ia32_vec_init_v2si(__t.__i, 0);
+}
+
 static __inline__ __m64 __DEFAULT_FN_ATTRS
 _m_pavgusb(__m64 __m1, __m64 __m2) {
   return (__m64)__builtin_ia32_pavgusb((__v8qi)__m1, (__v8qi)__m2);
Index: lib/Headers/Intrin.h
===
--- lib/Headers/Intrin.h
+++ lib/Headers/Intrin.h
@@ -46,12 +46,6 @@
 extern "C" {
 #endif
 
-#if defined(__MMX__)
-/* And the random ones that aren't in those files. */
-__m64 _m_from_float(float);
-float _m_to_float(__m64);
-#endif
-
 /* Other assorted instruction intrinsics. */
 void __addfsbyte(unsigned long, unsigned char);
 void __addfsdword(unsigned long, unsigned long);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D11737: Add -linker (and -linker=) alias for -fuse-ld=

2015-08-25 Thread Richard Smith via cfe-commits
On Tue, Aug 25, 2015 at 1:39 PM, Filipe Cabecinhas <
filcab+llvm.phabrica...@gmail.com> wrote:

> Hi Richard,
>
> On Tue, Aug 25, 2015 at 11:01 AM, Richard Smith 
> wrote:
>
>> On Aug 25, 2015 10:26 AM, "Filipe Cabecinhas" <
>> filcab+llvm.phabrica...@gmail.com> wrote:
>> >
>> > Hi Richard,
>> >
>> > We wouldn't be able to link with libs matching
>> "libinker=*.{dylib,so,...}", I guess. If that is a big problem and you'd
>> prefer that we keep this as a private patch, let me know.
>>
>> I don't think it's a big problem, more just a "try to pick better flag
>> names in future" comment :) It sounds like you guys have existing systems
>> that depend on this name, so while I'm not really overjoyed about this,
>> accepting it for compatibility seems OK.
>>
> Thanks.
>
>> Can we produce an accompanying "deprecated" warning suggesting use of the
>> other name?
>>
> Not on our side. If you still want the warning, I'd prefer to just keep
> the flag private than to have the option+warning upstream (basically just
> for PS4 toolchain use) and have a private patch to remove the warning
> anyway.
>
> Let me know what you think,
>

What do you see as the future of this flag? If this is something you will
need to keep around essentially forever, then we should just take this
change into upstream clang. In that case, the patch LGTM.

If this is something you need for short-term compatibility until the
projects using it switch to -fuse-ld= or become obsolescent, then it makes
less sense to take it as an upstream change (if we accept it upstream
without a deprecated warning, it's likely that some other projects will
start to rely on it, which makes it harder to eventually remove).

  Filipe
>
> > Thank you,
>> >
>> >   Filipe
>> >
>> >
>> > On Mon, Aug 24, 2015 at 6:45 PM, Richard Smith 
>> wrote:
>> >>
>> >> On Mon, Aug 24, 2015 at 5:50 PM, Eric Christopher via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>> >>>
>> >>> echristo added inline comments.
>> >>>
>> >>> 
>> >>> Comment at: include/clang/Driver/Options.td:1853
>> >>> @@ -1853,1 +1852,3 @@
>> >>> +def fuse_ld_EQ : Joined<["-"], "fuse-ld=">, HelpText<"Use linker
>> ">, Group;
>> >>> +def linker_EQ : Joined<["-"], "linker=">, Alias,
>> MetaVarName<"">;
>> >>>
>> >>> 
>> >>> thakis wrote:
>> >>> > Any reason to have another alias for this at all? Does gcc
>> understand this spelling? If not, could you limit this flag to PS4 targets?
>> (I'm guessing you need it for PS4 targets for some reason.)
>> >>> Any reason? (And I'm not sure how to limit it btw on target).
>> >>
>> >>
>> >> -l already has a meaning; adding a different flag starting with -l is
>> a bad idea.
>> >
>> >
>>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D11789: Modify DeclaratorChuck::getFunction to be passed an Exception Specification SourceRange

2015-08-25 Thread Richard Smith via cfe-commits
rsmith accepted this revision.
rsmith added a comment.
This revision is now accepted and ready to land.

LGTM, sorry for the delay.


http://reviews.llvm.org/D11789



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D9040: [analyzer] Make realloc(ptr, 0) handling equivalent to malloc(0).

2015-08-25 Thread Антон Ярцев via cfe-commits
ayartsev updated this revision to Diff 33134.

http://reviews.llvm.org/D9040

Files:
  lib/StaticAnalyzer/Checkers/MallocChecker.cpp
  test/Analysis/malloc.c

Index: test/Analysis/malloc.c
===
--- test/Analysis/malloc.c
+++ test/Analysis/malloc.c
@@ -263,21 +263,21 @@
 
 void CheckUseZeroAllocated7() {
   int *p = realloc(0, 0);
-  *p = 1; //TODO: warn about use of zero-allocated memory
+  *p = 1; // expected-warning {{Use of zero-allocated memory}}
   free(p);
 }
 
 void CheckUseZeroAllocated8() {
   int *p = malloc(8);
   int *q = realloc(p, 0);
-  *q = 1; //TODO: warn about use of zero-allocated memory
+  *q = 1; // expected-warning {{Use of zero-allocated memory}}
   free(q);
 }
 
 void CheckUseZeroAllocated9() {
   int *p = realloc(0, 0);
   int *q = realloc(p, 0);
-  *q = 1; //TODO: warn about use of zero-allocated memory
+  *q = 1; // expected-warning {{Use of zero-allocated memory}}
   free(q);
 }
 
@@ -307,6 +307,34 @@
   free(p);
 }
 
+void CheckUseZeroReallocatedPathNoWarn(_Bool b) {
+  int s = 0;
+  if (b)
+s= 10;
+
+  char *p = malloc(8);
+  char *q = realloc(p, s);
+
+  if (b)
+*q = 1; // no warning
+
+  free(q);
+}
+
+void CheckUseZeroReallocatedPathWarn(_Bool b) {
+  int s = 10;
+  if (b)
+s= 0;
+
+  char *p = malloc(8);
+  char *q = realloc(p, s);
+
+  if (b)
+*q = 1; // expected-warning {{Use of zero-allocated memory}}
+
+  free(q);
+}
+
 // This case tests that storing malloc'ed memory to a static variable which is
 // then returned is not leaked.  In the absence of known contracts for functions
 // or inter-procedural analysis, this is a conservative answer.
Index: lib/StaticAnalyzer/Checkers/MallocChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/MallocChecker.cpp
+++ lib/StaticAnalyzer/Checkers/MallocChecker.cpp
@@ -152,6 +152,18 @@
   }
 };
 
+/// \class ReallocSizeZero
+/// \brief Is a flag, indicates zero-size reallocation if attached. Used to 
+/// catch references to zero-allocated memory returned by 'realloc(ptr, 0)'.
+struct ReallocSizeZero {
+  void Profile(llvm::FoldingSetNodeID &ID) const {
+ID.AddString("ReallocSizeZero");
+  };
+  bool operator==(const ReallocSizeZero &X) const {
+return true;
+  }
+};
+
 typedef std::pair LeakInfo;
 
 class MallocChecker : public Checkerget(Sym);
-if (!RS)
-  return State; // TODO: change to assert(RS); after realloc() will 
-// guarantee have a RegionState attached.
-
-if (!RS->isAllocated())
-  return State;
-
-return TrueState->set(Sym,
-   RefState::getAllocatedOfSizeZero(RS));
+if (RS) {
+  if (RS->isAllocated())
+return TrueState->set(Sym,
+  RefState::getAllocatedOfSizeZero(RS));
+  else
+return State;
+} else {
+  // Case of zero-size realloc. Historically 'realloc(ptr, 0)' is treated as
+  // 'free(ptr)' and the returned value from 'realloc(ptr, 0)' is not
+  // tracked. Here we add ReallocSizeZeroFlag mark to catch references
+  // to zero-allocated memory.
+  return TrueState->set(Sym, ReallocSizeZero());
+}
   }
 
   // Assume the value is non-zero going forward.
@@ -1487,6 +1504,9 @@
 Optional
 MallocChecker::getCheckIfTracked(CheckerContext &C, SymbolRef Sym,
  bool IsALeakCheck) const {
+  if (C.getState()->get(Sym))
+return CK_MallocChecker;
+
   const RefState *RS = C.getState()->get(Sym);
   assert(RS);
   return getCheckIfTracked(RS->getAllocationFamily(), IsALeakCheck);
@@ -1929,7 +1949,7 @@
   }
 
   if (PrtIsNull && SizeIsZero)
-return nullptr;
+return State;
 
   // Get the from and to pointer symbols as in toPtr = realloc(fromPtr, size).
   assert(!PrtIsNull);
@@ -2291,10 +2311,14 @@
 void MallocChecker::checkUseZeroAllocated(SymbolRef Sym, CheckerContext &C,
   const Stmt *S) const {
   assert(Sym);
-  const RefState *RS = C.getState()->get(Sym);
 
-  if (RS && RS->isAllocatedOfSizeZero())
-ReportUseZeroAllocated(C, RS->getStmt()->getSourceRange(), Sym);
+  if (const RefState *RS = C.getState()->get(Sym)) {
+if (RS->isAllocatedOfSizeZero())
+  ReportUseZeroAllocated(C, RS->getStmt()->getSourceRange(), Sym);
+  }
+  else if (C.getState()->get(Sym)) {
+ReportUseZeroAllocated(C, S->getSourceRange(), Sym);
+  }
 }
 
 bool MallocChecker::checkDoubleDelete(SymbolRef Sym, CheckerContext &C) const {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D9040: [analyzer] Make realloc(ptr, 0) handling equivalent to malloc(0).

2015-08-25 Thread Антон Ярцев via cfe-commits
ayartsev added a comment.

Please review!



Comment at: lib/StaticAnalyzer/Checkers/MallocChecker.cpp:158
@@ +157,3 @@
+/// zero-allocated memory returned by 'realloc(ptr, 0)'.
+struct ReallocSizeZero {
+  void Profile(llvm::FoldingSetNodeID &ID) const {

zaks.anna wrote:
> This struct does not contain any fields. What's its purpose?
This struct is a flag that if attached indicates a zero-size reallocation. 
Improved class description in the updated patch.


Comment at: lib/StaticAnalyzer/Checkers/MallocChecker.cpp:524
@@ -511,2 +523,3 @@
 REGISTER_MAP_WITH_PROGRAMSTATE(ReallocPairs, SymbolRef, ReallocPair)
+REGISTER_MAP_WITH_PROGRAMSTATE(ReallocSizeZeroFlag, SymbolRef, ReallocSizeZero)
 

zaks.anna wrote:
> Maybe you should use a set of SymbolRefs instead?
This may produce false-positives as you explained me in D8273. Here is a 
modified example from D8273:

```
  if (b)
s= 10;
  else
s = 0;
  int *p = malloc(8);
  int *q = realloc(p, s);
  if (b)
*q = 1;
```
If the checker explores "realloc(p, s)" along the "s=0" path and add it to the 
set we'll get a false-positive along the "s=10" path later.

Included corresponding tests to the updated patch.


http://reviews.llvm.org/D9040



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r245979 - Clarify the error message when the reason the conversion is not viable is because the returned value does not match the function return type.

2015-08-25 Thread Nick Lewycky via cfe-commits
Author: nicholas
Date: Tue Aug 25 17:18:46 2015
New Revision: 245979

URL: http://llvm.org/viewvc/llvm-project?rev=245979&view=rev
Log:
Clarify the error message when the reason the conversion is not viable is 
because the returned value does not match the function return type.

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaInit.cpp
cfe/trunk/lib/Sema/SemaOverload.cpp

cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p3-generic-lambda-1y.cpp
cfe/trunk/test/CXX/expr/expr.prim/expr.prim.lambda/templates.cpp
cfe/trunk/test/SemaCXX/rval-references.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=245979&r1=245978&r2=245979&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue Aug 25 17:18:46 
2015
@@ -5792,7 +5792,8 @@ def err_typecheck_bool_condition : Error
 def err_typecheck_ambiguous_condition : Error<
   "conversion %diff{from $ to $|between types}0,1 is ambiguous">;
 def err_typecheck_nonviable_condition : Error<
-  "no viable conversion%diff{ from $ to $|}0,1">;
+  "no viable conversion%select{%diff{ from $ to $|}1,2|"
+  "%diff{ from returned value of type $ to function return type $|}1,2}0">;
 def err_typecheck_nonviable_condition_incomplete : Error<
   "no viable conversion%diff{ from $ to incomplete type $|}0,1">;
 def err_typecheck_deleted_function : Error<

Modified: cfe/trunk/lib/Sema/SemaInit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaInit.cpp?rev=245979&r1=245978&r2=245979&view=diff
==
--- cfe/trunk/lib/Sema/SemaInit.cpp (original)
+++ cfe/trunk/lib/Sema/SemaInit.cpp Tue Aug 25 17:18:46 2015
@@ -6946,6 +6946,7 @@ bool InitializationSequence::Diagnose(Se
   diag::err_typecheck_nonviable_condition_incomplete,
Args[0]->getType(), Args[0]->getSourceRange()))
 S.Diag(Kind.getLocation(), diag::err_typecheck_nonviable_condition)
+  << (Entity.getKind() == InitializedEntity::EK_Result)
   << Args[0]->getType() << Args[0]->getSourceRange()
   << DestType.getNonReferenceType();
 

Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=245979&r1=245978&r2=245979&view=diff
==
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Tue Aug 25 17:18:46 2015
@@ -3212,7 +3212,7 @@ Sema::DiagnoseMultipleUserDefinedConvers
  
diag::err_typecheck_nonviable_condition_incomplete,
  From->getType(), From->getSourceRange()))
   Diag(From->getLocStart(), diag::err_typecheck_nonviable_condition)
-  << From->getType() << From->getSourceRange() << ToType;
+  << false << From->getType() << From->getSourceRange() << ToType;
   } else
 return false;
   CandidateSet.NoteCandidates(*this, OCD_AllCandidates, From);

Modified: 
cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p3-generic-lambda-1y.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p3-generic-lambda-1y.cpp?rev=245979&r1=245978&r2=245979&view=diff
==
--- 
cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p3-generic-lambda-1y.cpp
 (original)
+++ 
cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p3-generic-lambda-1y.cpp
 Tue Aug 25 17:18:46 2015
@@ -49,7 +49,7 @@ int main()
   static double dfi(int i) { return i + 3.14; }
   static Local localfi(int) { return Local{}; }
 };
-auto l4 = [](auto (*fp)(int)) -> int { return fp(3); }; 
//expected-error{{no viable conversion from 'Local' to 'int'}} 
+auto l4 = [](auto (*fp)(int)) -> int { return fp(3); }; 
//expected-error{{no viable conversion from returned value of type 'Local' to 
function return type 'int'}} 
 l4(&Local::ifi);
 l4(&Local::cfi);
 l4(&Local::dfi);

Modified: cfe/trunk/test/CXX/expr/expr.prim/expr.prim.lambda/templates.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/expr/expr.prim/expr.prim.lambda/templates.cpp?rev=245979&r1=245978&r2=245979&view=diff
==
--- cfe/trunk/test/CXX/expr/expr.prim/expr.prim.lambda/templates.cpp (original)
+++ cfe/trunk/test/CXX/expr/expr.prim/expr.prim.lambda/templates.cpp Tue Aug 25 
17:18:46 2015
@@ -38,7 +38,7 @@ template X captures(X, X);
 template
 int infer_result(T x, T y) {
   auto lambda = [=](bo

r245985 - Make sure that we evaluate __attribute__((enable_if)) on a method with no overloads. Patch by Ettore Speziale!

2015-08-25 Thread Nick Lewycky via cfe-commits
Author: nicholas
Date: Tue Aug 25 17:33:16 2015
New Revision: 245985

URL: http://llvm.org/viewvc/llvm-project?rev=245985&view=rev
Log:
Make sure that we evaluate __attribute__((enable_if)) on a method with no 
overloads. Patch by Ettore Speziale!

Modified:
cfe/trunk/lib/Sema/SemaOverload.cpp
cfe/trunk/test/SemaCXX/enable_if.cpp

Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=245985&r1=245984&r2=245985&view=diff
==
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Tue Aug 25 17:33:16 2015
@@ -5826,10 +5826,11 @@ EnableIfAttr *Sema::CheckEnableIf(Functi
 
   SFINAETrap Trap(*this);
 
-  // Convert the arguments.
   SmallVector ConvertedArgs;
   bool InitializationFailed = false;
   bool ContainsValueDependentExpr = false;
+
+  // Convert the arguments.
   for (unsigned i = 0, e = Args.size(); i != e; ++i) {
 if (i == 0 && !MissingImplicitThis && isa(Function) &&
 !cast(Function)->isStatic() &&
@@ -5863,6 +5864,28 @@ EnableIfAttr *Sema::CheckEnableIf(Functi
   if (InitializationFailed || Trap.hasErrorOccurred())
 return cast(Attrs[0]);
 
+  // Push default arguments if needed.
+  if (!Function->isVariadic() && Args.size() < Function->getNumParams()) {
+for (unsigned i = Args.size(), e = Function->getNumParams(); i != e; ++i) {
+  ParmVarDecl *P = Function->getParamDecl(i);
+  ExprResult R = PerformCopyInitialization(
+  InitializedEntity::InitializeParameter(Context,
+ Function->getParamDecl(i)),
+  SourceLocation(),
+  P->hasUninstantiatedDefaultArg() ? P->getUninstantiatedDefaultArg()
+   : P->getDefaultArg());
+  if (R.isInvalid()) {
+InitializationFailed = true;
+break;
+  }
+  ContainsValueDependentExpr |= R.get()->isValueDependent();
+  ConvertedArgs.push_back(R.get());
+}
+
+if (InitializationFailed || Trap.hasErrorOccurred())
+  return cast(Attrs[0]);
+  }
+
   for (AttrVec::iterator I = Attrs.begin(); I != E; ++I) {
 APValue Result;
 EnableIfAttr *EIA = cast(*I);
@@ -11604,6 +11627,16 @@ Sema::BuildCallToMemberFunction(Scope *S
 FoundDecl = MemExpr->getFoundDecl();
 Qualifier = MemExpr->getQualifier();
 UnbridgedCasts.restore();
+
+if (const EnableIfAttr *Attr = CheckEnableIf(Method, Args, true)) {
+  Diag(MemExprE->getLocStart(),
+   diag::err_ovl_no_viable_member_function_in_call)
+  << Method << Method->getSourceRange();
+  Diag(Method->getLocation(),
+   diag::note_ovl_candidate_disabled_by_enable_if_attr)
+  << Attr->getCond()->getSourceRange() << Attr->getMessage();
+  return ExprError();
+}
   } else {
 UnresolvedMemberExpr *UnresExpr = cast(NakedMemExpr);
 Qualifier = UnresExpr->getQualifier();

Modified: cfe/trunk/test/SemaCXX/enable_if.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/enable_if.cpp?rev=245985&r1=245984&r2=245985&view=diff
==
--- cfe/trunk/test/SemaCXX/enable_if.cpp (original)
+++ cfe/trunk/test/SemaCXX/enable_if.cpp Tue Aug 25 17:33:16 2015
@@ -11,6 +11,10 @@ struct X {
   void f(int n) __attribute__((enable_if(n == 0, "chosen when 'n' is zero")));
   void f(int n) __attribute__((enable_if(n == 1, "chosen when 'n' is one")));  
// expected-note{{member declaration nearly matches}} expected-note{{candidate 
disabled: chosen when 'n' is one}}
 
+  void g(int n) __attribute__((enable_if(n == 0, "chosen when 'n' is zero"))); 
 // expected-note{{candidate disabled: chosen when 'n' is zero}}
+
+  void h(int n, int m = 0) __attribute((enable_if(m == 0, "chosen when 'm' is 
zero")));  // expected-note{{candidate disabled: chosen when 'm' is zero}}
+
   static void s(int n) __attribute__((enable_if(n == 0, "chosen when 'n' is 
zero")));  // expected-note2{{candidate disabled: chosen when 'n' is zero}}
 
   void conflict(int n) __attribute__((enable_if(n+n == 10, "chosen when 'n' is 
five")));  // expected-note{{candidate function}}
@@ -40,6 +44,15 @@ void deprec2(int i) __attribute__((enabl
 void overloaded(int);
 void overloaded(long);
 
+struct Int {
+  constexpr Int(int i) : i(i) { }
+  constexpr operator int() const { return i; }
+  int i;
+};
+
+void default_argument(int n, int m = 0) __attribute__((enable_if(m == 0, 
"chosen when 'm' is zero")));  // expected-note{{candidate disabled: chosen 
when 'm' is zero}}
+void default_argument_promotion(int n, int m = Int(0)) 
__attribute__((enable_if(m == 0, "chosen when 'm' is zero")));  // 
expected-note{{candidate disabled: chosen when 'm' is zero}}
+
 struct Nothing { };
 template void typedep(T t) __attribute__((enable_if(t, "")));  // 
expected-note{{candidate disabled:}}  

Re: r245914 - Reimplement the PPC explicit option checking to be a bit more obvious

2015-08-25 Thread Hal Finkel via cfe-commits
Hi Eric,

Can you please update the test case for this change?

Thanks again,
Hal

- Original Message -
> From: "Eric Christopher via cfe-commits" 
> To: cfe-commits@lists.llvm.org
> Sent: Monday, August 24, 2015 7:59:11 PM
> Subject: r245914 - Reimplement the PPC explicit option checking to be a bit 
> more obvious
> 
> Author: echristo
> Date: Mon Aug 24 19:59:11 2015
> New Revision: 245914
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=245914&view=rev
> Log:
> Reimplement the PPC explicit option checking to be a bit more obvious
> that we're looking for conflicting options and give an explanation.
> 
> Modified:
> cfe/trunk/lib/Basic/Targets.cpp
> 
> Modified: cfe/trunk/lib/Basic/Targets.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=245914&r1=245913&r2=245914&view=diff
> ==
> --- cfe/trunk/lib/Basic/Targets.cpp (original)
> +++ cfe/trunk/lib/Basic/Targets.cpp Mon Aug 24 19:59:11 2015
> @@ -1070,14 +1070,25 @@ bool PPCTargetInfo::handleTargetFeatures
>  // TODO: Finish this list and add an assert that we've handled
>  them
>  // all.
>}
> -  if (!HasVSX && (HasP8Vector || HasDirectMove)) {
> -if (HasP8Vector)
> -  Diags.Report(diag::err_opt_not_valid_with_opt) <<
> "-mpower8-vector" <<
> -"-mno-vsx";
> -else if (HasDirectMove)
> -  Diags.Report(diag::err_opt_not_valid_with_opt) <<
> "-mdirect-move" <<
> -"-mno-vsx";
> -return false;
> +
> +  // Handle explicit options being passed to the compiler here: if
> we've
> +  // explicitly turned off vsx and turned on power8-vector or
> direct-move then
> +  // go ahead and error since the customer has expressed a somewhat
> incompatible
> +  // set of options.
> +  if (std::find(Features.begin(), Features.end(), "-vsx") !=
> Features.end()) {
> +if (std::find(Features.begin(), Features.end(),
> "+power8-vector") !=
> +Features.end()) {
> +  Diags.Report(diag::err_opt_not_valid_with_opt) <<
> "-mpower8-vector"
> + << "-mno-vsx";
> +  return false;
> +}
> +
> +if (std::find(Features.begin(), Features.end(), "+direct-move")
> !=
> +Features.end()) {
> +  Diags.Report(diag::err_opt_not_valid_with_opt) <<
> "-mdirect-move"
> + << "-mno-vsx";
> +  return false;
> +}
>}
>  
>return true;
> 
> 
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
> 

-- 
Hal Finkel
Assistant Computational Scientist
Leadership Computing Facility
Argonne National Laboratory
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r245914 - Reimplement the PPC explicit option checking to be a bit more obvious

2015-08-25 Thread Eric Christopher via cfe-commits
On Tue, Aug 25, 2015 at 3:51 PM Hal Finkel  wrote:

> Hi Eric,
>
> Can you please update the test case for this change?
>
>
Hmm? The testcases are pretty exhaustive and should be checking exactly
what's here. (i.e. I don't expect a functional change).

-eric


> Thanks again,
> Hal
>
> - Original Message -
> > From: "Eric Christopher via cfe-commits" 
> > To: cfe-commits@lists.llvm.org
> > Sent: Monday, August 24, 2015 7:59:11 PM
> > Subject: r245914 - Reimplement the PPC explicit option checking to be a
> bit more obvious
> >
> > Author: echristo
> > Date: Mon Aug 24 19:59:11 2015
> > New Revision: 245914
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=245914&view=rev
> > Log:
> > Reimplement the PPC explicit option checking to be a bit more obvious
> > that we're looking for conflicting options and give an explanation.
> >
> > Modified:
> > cfe/trunk/lib/Basic/Targets.cpp
> >
> > Modified: cfe/trunk/lib/Basic/Targets.cpp
> > URL:
> >
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=245914&r1=245913&r2=245914&view=diff
> >
> ==
> > --- cfe/trunk/lib/Basic/Targets.cpp (original)
> > +++ cfe/trunk/lib/Basic/Targets.cpp Mon Aug 24 19:59:11 2015
> > @@ -1070,14 +1070,25 @@ bool PPCTargetInfo::handleTargetFeatures
> >  // TODO: Finish this list and add an assert that we've handled
> >  them
> >  // all.
> >}
> > -  if (!HasVSX && (HasP8Vector || HasDirectMove)) {
> > -if (HasP8Vector)
> > -  Diags.Report(diag::err_opt_not_valid_with_opt) <<
> > "-mpower8-vector" <<
> > -"-mno-vsx";
> > -else if (HasDirectMove)
> > -  Diags.Report(diag::err_opt_not_valid_with_opt) <<
> > "-mdirect-move" <<
> > -"-mno-vsx";
> > -return false;
> > +
> > +  // Handle explicit options being passed to the compiler here: if
> > we've
> > +  // explicitly turned off vsx and turned on power8-vector or
> > direct-move then
> > +  // go ahead and error since the customer has expressed a somewhat
> > incompatible
> > +  // set of options.
> > +  if (std::find(Features.begin(), Features.end(), "-vsx") !=
> > Features.end()) {
> > +if (std::find(Features.begin(), Features.end(),
> > "+power8-vector") !=
> > +Features.end()) {
> > +  Diags.Report(diag::err_opt_not_valid_with_opt) <<
> > "-mpower8-vector"
> > + << "-mno-vsx";
> > +  return false;
> > +}
> > +
> > +if (std::find(Features.begin(), Features.end(), "+direct-move")
> > !=
> > +Features.end()) {
> > +  Diags.Report(diag::err_opt_not_valid_with_opt) <<
> > "-mdirect-move"
> > + << "-mno-vsx";
> > +  return false;
> > +}
> >}
> >
> >return true;
> >
> >
> > ___
> > cfe-commits mailing list
> > cfe-commits@lists.llvm.org
> > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
> >
>
> --
> Hal Finkel
> Assistant Computational Scientist
> Leadership Computing Facility
> Argonne National Laboratory
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r245914 - Reimplement the PPC explicit option checking to be a bit more obvious

2015-08-25 Thread Hal Finkel via cfe-commits
- Original Message -
> From: "Eric Christopher" 
> To: "Hal Finkel" 
> Cc: cfe-commits@lists.llvm.org
> Sent: Tuesday, August 25, 2015 5:51:50 PM
> Subject: Re: r245914 - Reimplement the PPC explicit option checking to be a 
> bit more obvious
> 
> On Tue, Aug 25, 2015 at 3:51 PM Hal Finkel < hfin...@anl.gov > wrote:
> 
> 
> Hi Eric,
> 
> Can you please update the test case for this change?
> 
> Hmm? The testcases are pretty exhaustive and should be checking
> exactly what's here. (i.e. I don't expect a functional change).
> 

Ah, okay. For some reason I thought there might have been a functional change. 
Nevermind ;)

 -Hal

> 
> -eric
> 
> 
> Thanks again,
> Hal
> 
> - Original Message -
> > From: "Eric Christopher via cfe-commits" <
> > cfe-commits@lists.llvm.org >
> > To: cfe-commits@lists.llvm.org
> > Sent: Monday, August 24, 2015 7:59:11 PM
> > Subject: r245914 - Reimplement the PPC explicit option checking to
> > be a bit more obvious
> > 
> > Author: echristo
> > Date: Mon Aug 24 19:59:11 2015
> > New Revision: 245914
> > 
> > URL: http://llvm.org/viewvc/llvm-project?rev=245914&view=rev
> > Log:
> > Reimplement the PPC explicit option checking to be a bit more
> > obvious
> > that we're looking for conflicting options and give an explanation.
> > 
> > Modified:
> > cfe/trunk/lib/Basic/Targets.cpp
> > 
> > Modified: cfe/trunk/lib/Basic/Targets.cpp
> > URL:
> > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=245914&r1=245913&r2=245914&view=diff
> > ==
> > --- cfe/trunk/lib/Basic/Targets.cpp (original)
> > +++ cfe/trunk/lib/Basic/Targets.cpp Mon Aug 24 19:59:11 2015
> > @@ -1070,14 +1070,25 @@ bool PPCTargetInfo::handleTargetFeatures
> > // TODO: Finish this list and add an assert that we've handled
> > them
> > // all.
> > }
> > - if (!HasVSX && (HasP8Vector || HasDirectMove)) {
> > - if (HasP8Vector)
> > - Diags.Report(diag::err_opt_not_valid_with_opt) <<
> > "-mpower8-vector" <<
> > - "-mno-vsx";
> > - else if (HasDirectMove)
> > - Diags.Report(diag::err_opt_not_valid_with_opt) <<
> > "-mdirect-move" <<
> > - "-mno-vsx";
> > - return false;
> > +
> > + // Handle explicit options being passed to the compiler here: if
> > we've
> > + // explicitly turned off vsx and turned on power8-vector or
> > direct-move then
> > + // go ahead and error since the customer has expressed a somewhat
> > incompatible
> > + // set of options.
> > + if (std::find(Features.begin(), Features.end(), "-vsx") !=
> > Features.end()) {
> > + if (std::find(Features.begin(), Features.end(),
> > "+power8-vector") !=
> > + Features.end()) {
> > + Diags.Report(diag::err_opt_not_valid_with_opt) <<
> > "-mpower8-vector"
> > + << "-mno-vsx";
> > + return false;
> > + }
> > +
> > + if (std::find(Features.begin(), Features.end(), "+direct-move")
> > !=
> > + Features.end()) {
> > + Diags.Report(diag::err_opt_not_valid_with_opt) <<
> > "-mdirect-move"
> > + << "-mno-vsx";
> > + return false;
> > + }
> > }
> > 
> > return true;
> > 
> > 
> > ___
> > cfe-commits mailing list
> > cfe-commits@lists.llvm.org
> > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
> > 
> 
> --
> Hal Finkel
> Assistant Computational Scientist
> Leadership Computing Facility
> Argonne National Laboratory
> 

-- 
Hal Finkel
Assistant Computational Scientist
Leadership Computing Facility
Argonne National Laboratory
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D12344: ARM: Error out if float-ab=hard and abi=apcs-gnu on macho platforms

2015-08-25 Thread Akira Hatanaka via cfe-commits
ahatanak created this revision.
ahatanak added a reviewer: vsk.
ahatanak added a subscriber: cfe-commits.
Herald added subscribers: rengolin, aemerson.

This patch corrects http://reviews.llvm.org/D12155, which didn't take into 
account the fact that aapcs ABI can be selected on darwin platforms. The new 
patch errors out only when the ABI is APCS and the float-abi is hard.

http://reviews.llvm.org/D12344

Files:
  lib/Driver/Tools.cpp
  test/Driver/arm-float-abi.c

Index: test/Driver/arm-float-abi.c
===
--- /dev/null
+++ test/Driver/arm-float-abi.c
@@ -0,0 +1,6 @@
+// RUN: not %clang %s -target armv7-apple-ios -mfloat-abi=hard 2>&1 | 
FileCheck -check-prefix=ARMV7-ERROR %s
+// RUN: %clang %s -target armv7-apple-ios -mfloat-abi=softfp -### 2>&1 | 
FileCheck -check-prefix=NOERROR %s
+// RUN: %clang %s -arch armv7 -target thumbv7-apple-darwin-eabi 
-mfloat-abi=hard -### 2>&1 | FileCheck -check-prefix=NOERROR %s
+
+// ARMV7-ERROR: unsupported option '-mfloat-abi=hard' for target 'thumbv7'
+// NOERROR-NOT: unsupported option
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -563,6 +563,13 @@
 D.Diag(diag::err_drv_clang_unsupported) << A->getAsString(Args);
 }
 
+static bool useAAPCSForMachO(const llvm::Triple &T) {
+  // The backend is hardwired to assume AAPCS for M-class processors, ensure
+  // the frontend matches that.
+  return T.getEnvironment() == llvm::Triple::EABI ||
+ T.getOS() == llvm::Triple::UnknownOS || isARMMProfile(T);
+}
+
 // Select the float ABI as determined by -msoft-float, -mhard-float, and
 // -mfloat-abi=.
 StringRef tools::arm::getARMFloatABI(const Driver &D, const ArgList &Args,
@@ -582,6 +589,13 @@
 FloatABI = "soft";
   }
 }
+
+// It is incorrect to select hard float ABI on MachO platforms if the ABI 
is
+// "apcs-gnu".
+if (Triple.isOSBinFormatMachO() && !useAAPCSForMachO(Triple) &&
+FloatABI == "hard")
+  D.Diag(diag::err_drv_unsupported_opt_for_target) << A->getAsString(Args)
+   << Triple.getArchName();
   }
 
   // If unspecified, choose the default based on the platform.
@@ -856,10 +870,7 @@
   if (Arg *A = Args.getLastArg(options::OPT_mabi_EQ)) {
 ABIName = A->getValue();
   } else if (Triple.isOSBinFormatMachO()) {
-// The backend is hardwired to assume AAPCS for M-class processors, ensure
-// the frontend matches that.
-if (Triple.getEnvironment() == llvm::Triple::EABI ||
-Triple.getOS() == llvm::Triple::UnknownOS || isARMMProfile(Triple)) {
+if (useAAPCSForMachO(Triple)) {
   ABIName = "aapcs";
 } else {
   ABIName = "apcs-gnu";


Index: test/Driver/arm-float-abi.c
===
--- /dev/null
+++ test/Driver/arm-float-abi.c
@@ -0,0 +1,6 @@
+// RUN: not %clang %s -target armv7-apple-ios -mfloat-abi=hard 2>&1 | FileCheck -check-prefix=ARMV7-ERROR %s
+// RUN: %clang %s -target armv7-apple-ios -mfloat-abi=softfp -### 2>&1 | FileCheck -check-prefix=NOERROR %s
+// RUN: %clang %s -arch armv7 -target thumbv7-apple-darwin-eabi -mfloat-abi=hard -### 2>&1 | FileCheck -check-prefix=NOERROR %s
+
+// ARMV7-ERROR: unsupported option '-mfloat-abi=hard' for target 'thumbv7'
+// NOERROR-NOT: unsupported option
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -563,6 +563,13 @@
 D.Diag(diag::err_drv_clang_unsupported) << A->getAsString(Args);
 }
 
+static bool useAAPCSForMachO(const llvm::Triple &T) {
+  // The backend is hardwired to assume AAPCS for M-class processors, ensure
+  // the frontend matches that.
+  return T.getEnvironment() == llvm::Triple::EABI ||
+ T.getOS() == llvm::Triple::UnknownOS || isARMMProfile(T);
+}
+
 // Select the float ABI as determined by -msoft-float, -mhard-float, and
 // -mfloat-abi=.
 StringRef tools::arm::getARMFloatABI(const Driver &D, const ArgList &Args,
@@ -582,6 +589,13 @@
 FloatABI = "soft";
   }
 }
+
+// It is incorrect to select hard float ABI on MachO platforms if the ABI is
+// "apcs-gnu".
+if (Triple.isOSBinFormatMachO() && !useAAPCSForMachO(Triple) &&
+FloatABI == "hard")
+  D.Diag(diag::err_drv_unsupported_opt_for_target) << A->getAsString(Args)
+   << Triple.getArchName();
   }
 
   // If unspecified, choose the default based on the platform.
@@ -856,10 +870,7 @@
   if (Arg *A = Args.getLastArg(options::OPT_mabi_EQ)) {
 ABIName = A->getValue();
   } else if (Triple.isOSBinFormatMachO()) {
-// The backend is hardwired to assume AAPCS for M-class processors, ensure
-// the frontend matches that.
-if (Triple.getEnvironment() == llvm::Triple::EABI ||
-Triple.getOS() == 

r245987 - [Headers][X86] Add -O0 assembly tests for avx2 intrinsics.

2015-08-25 Thread Ahmed Bougacha via cfe-commits
Author: ab
Date: Tue Aug 25 18:09:05 2015
New Revision: 245987

URL: http://llvm.org/viewvc/llvm-project?rev=245987&view=rev
Log:
[Headers][X86] Add -O0 assembly tests for avx2 intrinsics.

We agreed for r245605 that, as long as we don't affect -O0 codegen
too much, it's OK to use native constructs rather than intrinsics.
Let's test that, starting with AVX2 here.

See PR24580.

Differential Revision: http://reviews.llvm.org/D12212

Modified:
cfe/trunk/test/CodeGen/avx2-builtins.c

Modified: cfe/trunk/test/CodeGen/avx2-builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/avx2-builtins.c?rev=245987&r1=245986&r2=245987&view=diff
==
--- cfe/trunk/test/CodeGen/avx2-builtins.c (original)
+++ cfe/trunk/test/CodeGen/avx2-builtins.c Tue Aug 25 18:09:05 2015
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 %s -O0 -triple=x86_64-apple-darwin -target-feature +avx2 
-emit-llvm -o - -Werror | FileCheck %s
+// RUN: %clang_cc1 %s -O0 -triple=x86_64-apple-darwin -target-feature +avx2 -S 
-o - -Werror | FileCheck %s --check-prefix=CHECK-ASM
 
 // Don't include mm_malloc.h, it's system specific.
 #define __MM_MALLOC_H
@@ -7,172 +8,210 @@
 
 __m256i test_mm256_mpsadbw_epu8(__m256i x, __m256i y) {
   // CHECK: @llvm.x86.avx2.mpsadbw({{.*}}, {{.*}}, i8 3)
+  // CHECK-ASM: vmpsadbw $3, %ymm{{.*}}
   return _mm256_mpsadbw_epu8(x, y, 3);
 }
 
 __m256i test_mm256_sad_epu8(__m256i x, __m256i y) {
   // CHECK: @llvm.x86.avx2.psad.bw
+  // CHECK-ASM: vpsadbw %ymm{{.*}}
   return _mm256_sad_epu8(x, y);
 }
 
 __m256i test_mm256_abs_epi8(__m256i a) {
   // CHECK: @llvm.x86.avx2.pabs.b
+  // CHECK-ASM: vpabsb %ymm{{.*}}
   return _mm256_abs_epi8(a);
 }
 
 __m256i test_mm256_abs_epi16(__m256i a) {
   // CHECK: @llvm.x86.avx2.pabs.w
+  // CHECK-ASM: vpabsw %ymm{{.*}}
   return _mm256_abs_epi16(a);
 }
 
 __m256i test_mm256_abs_epi32(__m256i a) {
   // CHECK: @llvm.x86.avx2.pabs.d
+  // CHECK-ASM: vpabsd %ymm{{.*}}
   return _mm256_abs_epi32(a);
 }
 
 __m256i test_mm256_packs_epi16(__m256i a, __m256i b) {
   // CHECK: @llvm.x86.avx2.packsswb
+  // CHECK-ASM: vpacksswb %ymm{{.*}}
   return _mm256_packs_epi16(a, b);
 }
 
 __m256i test_mm256_packs_epi32(__m256i a, __m256i b) {
   // CHECK: @llvm.x86.avx2.packssdw
+  // CHECK-ASM: vpackssdw %ymm{{.*}}
   return _mm256_packs_epi32(a, b);
 }
 
 __m256i test_mm256_packs_epu16(__m256i a, __m256i b) {
   // CHECK: @llvm.x86.avx2.packuswb
+  // CHECK-ASM: vpackuswb %ymm{{.*}}
   return _mm256_packus_epi16(a, b);
 }
 
 __m256i test_mm256_packs_epu32(__m256i a, __m256i b) {
   // CHECK: @llvm.x86.avx2.packusdw
+  // CHECK-ASM: vpackusdw %ymm{{.*}}
   return _mm256_packus_epi32(a, b);
 }
 
 __m256i test_mm256_add_epi8(__m256i a, __m256i b) {
   // CHECK: add <32 x i8>
+  // CHECK-ASM: vpaddb %ymm{{.*}}
   return _mm256_add_epi8(a, b);
 }
 
 __m256i test_mm256_add_epi16(__m256i a, __m256i b) {
   // CHECK: add <16 x i16>
+  // CHECK-ASM: vpaddw %ymm{{.*}}
   return _mm256_add_epi16(a, b);
 }
 
 __m256i test_mm256_add_epi32(__m256i a, __m256i b) {
   // CHECK: add <8 x i32>
+  // CHECK-ASM: vpaddd %ymm{{.*}}
   return _mm256_add_epi32(a, b);
 }
 
 __m256i test_mm256_add_epi64(__m256i a, __m256i b) {
   // CHECK: add <4 x i64>
+  // CHECK-ASM: vpaddq {{.*}}, %ymm{{.*}}
   return _mm256_add_epi64(a, b);
 }
 
 __m256i test_mm256_adds_epi8(__m256i a, __m256i b) {
   // CHECK: @llvm.x86.avx2.padds.b
+  // CHECK-ASM: vpaddsb %ymm{{.*}}
   return _mm256_adds_epi8(a, b);
 }
 
 __m256i test_mm256_adds_epi16(__m256i a, __m256i b) {
   // CHECK: @llvm.x86.avx2.padds.w
+  // CHECK-ASM: vpaddsw %ymm{{.*}}
   return _mm256_adds_epi16(a, b);
 }
 
 __m256i test_mm256_adds_epu8(__m256i a, __m256i b) {
   // CHECK: @llvm.x86.avx2.paddus.b
+  // CHECK-ASM: vpaddusb %ymm{{.*}}
   return _mm256_adds_epu8(a, b);
 }
 
 __m256i test_mm256_adds_epu16(__m256i a, __m256i b) {
   // CHECK: @llvm.x86.avx2.paddus.w
+  // CHECK-ASM: vpaddusw %ymm{{.*}}
   return _mm256_adds_epu16(a, b);
 }
 
 __m256i test_mm256_alignr_epi8(__m256i a, __m256i b) {
   // CHECK: shufflevector <32 x i8> %{{.*}}, <32 x i8> %{{.*}}, <32 x i32> 

+  // CHECK-ASM: vpalignr $2, %ymm{{.*}}
   return _mm256_alignr_epi8(a, b, 2);
 }
 
 __m256i test2_mm256_alignr_epi8(__m256i a, __m256i b) {
   // CHECK: shufflevector <32 x i8> %{{.*}}, <32 x i8> zeroinitializer, <32 x 
i32> 
+  // CHECK-ASM: vpsrldq $1, %ymm{{.*}}
   return _mm256_alignr_epi8(a, b, 17);
 }
 
 __m256i test_mm256_sub_epi8(__m256i a, __m256i b) {
   // CHECK: sub <32 x i8>
+  // CHECK-ASM: vpsubb %ymm{{.*}}
   return _mm256_sub_epi8(a, b);
 }
 
 __m256i test_mm256_sub_epi16(__m256i a, __m256i b) {
   // CHECK: sub <16 x i16>
+  // CHECK-ASM: vpsubw %ymm{{.*}}
   return _mm256_sub_epi16(a, b);
 }
 
 __m256i test_mm256_sub_epi32(__m256i a, __m256i b) {
   // CHECK: sub <8 x i32>
+  // CHECK-ASM: vpsubd %ymm{{.*}}
   return _mm256_sub_epi32(a, b);
 }
 
 __m256i test_mm256_sub_epi64(__m256i a, __m256i b) {
   // CHECK

Re: [PATCH] D12212: [Headers][X86] Add -O0 assembly tests for intrinsics.

2015-08-25 Thread Ahmed Bougacha via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL245987: [Headers][X86] Add -O0 assembly tests for avx2 
intrinsics. (authored by ab).

Changed prior to commit:
  http://reviews.llvm.org/D12212?vs=32732&id=33147#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D12212

Files:
  cfe/trunk/test/CodeGen/avx2-builtins.c

Index: cfe/trunk/test/CodeGen/avx2-builtins.c
===
--- cfe/trunk/test/CodeGen/avx2-builtins.c
+++ cfe/trunk/test/CodeGen/avx2-builtins.c
@@ -1,178 +1,217 @@
 // RUN: %clang_cc1 %s -O0 -triple=x86_64-apple-darwin -target-feature +avx2 -emit-llvm -o - -Werror | FileCheck %s
+// RUN: %clang_cc1 %s -O0 -triple=x86_64-apple-darwin -target-feature +avx2 -S -o - -Werror | FileCheck %s --check-prefix=CHECK-ASM
 
 // Don't include mm_malloc.h, it's system specific.
 #define __MM_MALLOC_H
 
 #include 
 
 __m256i test_mm256_mpsadbw_epu8(__m256i x, __m256i y) {
   // CHECK: @llvm.x86.avx2.mpsadbw({{.*}}, {{.*}}, i8 3)
+  // CHECK-ASM: vmpsadbw $3, %ymm{{.*}}
   return _mm256_mpsadbw_epu8(x, y, 3);
 }
 
 __m256i test_mm256_sad_epu8(__m256i x, __m256i y) {
   // CHECK: @llvm.x86.avx2.psad.bw
+  // CHECK-ASM: vpsadbw %ymm{{.*}}
   return _mm256_sad_epu8(x, y);
 }
 
 __m256i test_mm256_abs_epi8(__m256i a) {
   // CHECK: @llvm.x86.avx2.pabs.b
+  // CHECK-ASM: vpabsb %ymm{{.*}}
   return _mm256_abs_epi8(a);
 }
 
 __m256i test_mm256_abs_epi16(__m256i a) {
   // CHECK: @llvm.x86.avx2.pabs.w
+  // CHECK-ASM: vpabsw %ymm{{.*}}
   return _mm256_abs_epi16(a);
 }
 
 __m256i test_mm256_abs_epi32(__m256i a) {
   // CHECK: @llvm.x86.avx2.pabs.d
+  // CHECK-ASM: vpabsd %ymm{{.*}}
   return _mm256_abs_epi32(a);
 }
 
 __m256i test_mm256_packs_epi16(__m256i a, __m256i b) {
   // CHECK: @llvm.x86.avx2.packsswb
+  // CHECK-ASM: vpacksswb %ymm{{.*}}
   return _mm256_packs_epi16(a, b);
 }
 
 __m256i test_mm256_packs_epi32(__m256i a, __m256i b) {
   // CHECK: @llvm.x86.avx2.packssdw
+  // CHECK-ASM: vpackssdw %ymm{{.*}}
   return _mm256_packs_epi32(a, b);
 }
 
 __m256i test_mm256_packs_epu16(__m256i a, __m256i b) {
   // CHECK: @llvm.x86.avx2.packuswb
+  // CHECK-ASM: vpackuswb %ymm{{.*}}
   return _mm256_packus_epi16(a, b);
 }
 
 __m256i test_mm256_packs_epu32(__m256i a, __m256i b) {
   // CHECK: @llvm.x86.avx2.packusdw
+  // CHECK-ASM: vpackusdw %ymm{{.*}}
   return _mm256_packus_epi32(a, b);
 }
 
 __m256i test_mm256_add_epi8(__m256i a, __m256i b) {
   // CHECK: add <32 x i8>
+  // CHECK-ASM: vpaddb %ymm{{.*}}
   return _mm256_add_epi8(a, b);
 }
 
 __m256i test_mm256_add_epi16(__m256i a, __m256i b) {
   // CHECK: add <16 x i16>
+  // CHECK-ASM: vpaddw %ymm{{.*}}
   return _mm256_add_epi16(a, b);
 }
 
 __m256i test_mm256_add_epi32(__m256i a, __m256i b) {
   // CHECK: add <8 x i32>
+  // CHECK-ASM: vpaddd %ymm{{.*}}
   return _mm256_add_epi32(a, b);
 }
 
 __m256i test_mm256_add_epi64(__m256i a, __m256i b) {
   // CHECK: add <4 x i64>
+  // CHECK-ASM: vpaddq {{.*}}, %ymm{{.*}}
   return _mm256_add_epi64(a, b);
 }
 
 __m256i test_mm256_adds_epi8(__m256i a, __m256i b) {
   // CHECK: @llvm.x86.avx2.padds.b
+  // CHECK-ASM: vpaddsb %ymm{{.*}}
   return _mm256_adds_epi8(a, b);
 }
 
 __m256i test_mm256_adds_epi16(__m256i a, __m256i b) {
   // CHECK: @llvm.x86.avx2.padds.w
+  // CHECK-ASM: vpaddsw %ymm{{.*}}
   return _mm256_adds_epi16(a, b);
 }
 
 __m256i test_mm256_adds_epu8(__m256i a, __m256i b) {
   // CHECK: @llvm.x86.avx2.paddus.b
+  // CHECK-ASM: vpaddusb %ymm{{.*}}
   return _mm256_adds_epu8(a, b);
 }
 
 __m256i test_mm256_adds_epu16(__m256i a, __m256i b) {
   // CHECK: @llvm.x86.avx2.paddus.w
+  // CHECK-ASM: vpaddusw %ymm{{.*}}
   return _mm256_adds_epu16(a, b);
 }
 
 __m256i test_mm256_alignr_epi8(__m256i a, __m256i b) {
   // CHECK: shufflevector <32 x i8> %{{.*}}, <32 x i8> %{{.*}}, <32 x i32> 
+  // CHECK-ASM: vpalignr $2, %ymm{{.*}}
   return _mm256_alignr_epi8(a, b, 2);
 }
 
 __m256i test2_mm256_alignr_epi8(__m256i a, __m256i b) {
   // CHECK: shufflevector <32 x i8> %{{.*}}, <32 x i8> zeroinitializer, <32 x i32> 
+  // CHECK-ASM: vpsrldq $1, %ymm{{.*}}
   return _mm256_alignr_epi8(a, b, 17);
 }
 
 __m256i test_mm256_sub_epi8(__m256i a, __m256i b) {
   // CHECK: sub <32 x i8>
+  // CHECK-ASM: vpsubb %ymm{{.*}}
   return _mm256_sub_epi8(a, b);
 }
 
 __m256i test_mm256_sub_epi16(__m256i a, __m256i b) {
   // CHECK: sub <16 x i16>
+  // CHECK-ASM: vpsubw %ymm{{.*}}
   return _mm256_sub_epi16(a, b);
 }
 
 __m256i test_mm256_sub_epi32(__m256i a, __m256i b) {
   // CHECK: sub <8 x i32>
+  // CHECK-ASM: vpsubd %ymm{{.*}}
   return _mm256_sub_epi32(a, b);
 }
 
 __m256i test_mm256_sub_epi64(__m256i a, __m256i b) {
   // CHECK: sub <4 x i64>
+  // CHECK-ASM: vpsubq {{.*}}, %ymm{{.*}}
   return _mm256_sub_epi64(a, b);
 }
 
 __m256i test_mm256_subs_epi8(__m256i a, __m256i b) {
   // CHECK: @llvm.x86.avx2.psubs.b
+  // CHECK-ASM: vpsubsb %ymm{{.*}}
   return _mm256_subs_epi8(a, b);
 }
 
 __m256i test_mm256_subs_epi16(__m256i a,

Re: [PATCH] D12212: [Headers][X86] Add -O0 assembly tests for intrinsics.

2015-08-25 Thread Ahmed Bougacha via cfe-commits
ab added a comment.

Thanks Simon!  Replaced the FIXMEs with proper tests and committed.

Whenever I have time I'll have a look at the others, filed PR24580.


Repository:
  rL LLVM

http://reviews.llvm.org/D12212



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D11468: [Static Analyzer] The first implementation of nullability checker.

2015-08-25 Thread Gábor Horváth via cfe-commits
xazax.hun updated this revision to Diff 33151.
xazax.hun marked 30 inline comments as done.
xazax.hun added a comment.

Addressed the comments.
Added some more tests.
Added a design document.


http://reviews.llvm.org/D11468

Files:
  docs/analyzer/nullability.rst
  lib/StaticAnalyzer/Checkers/CMakeLists.txt
  lib/StaticAnalyzer/Checkers/Checkers.td
  lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
  test/Analysis/nullability.mm

Index: test/Analysis/nullability.mm
===
--- /dev/null
+++ test/Analysis/nullability.mm
@@ -0,0 +1,181 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,alpha.core.nullability -verify %s
+
+#define nil 0
+#define BOOL int
+
+@protocol NSObject
++ (id)alloc;
+- (id)init;
+@end
+
+@protocol NSCopying
+@end
+
+__attribute__((objc_root_class))
+@interface
+NSObject
+@end
+
+@interface NSString : NSObject
+- (BOOL)isEqualToString : (NSString *_Nonnull)aString;
+- (NSString *)stringByAppendingString:(NSString *_Nonnull)aString;
+@end
+
+@interface TestObject : NSObject
+- (int *_Nonnull)returnsNonnull;
+- (int *_Nullable)returnsNullable;
+- (int *)returnsUnspecified;
+- (void)takesNonnull:(int *_Nonnull)p;
+- (void)takesNullable:(int *_Nullable)p;
+- (void)takesUnspecified:(int *)p;
+@property(readonly, strong) NSString *stuff;
+@end
+
+TestObject * getUnspecifiedTestObject();
+TestObject *_Nonnull getNonnullTestObject();
+TestObject *_Nullable getNullableTestObject();
+
+int getRandom();
+
+typedef struct Dummy { int val; } Dummy;
+
+void takesNullable(Dummy *_Nullable);
+void takesNonnull(Dummy *_Nonnull);
+void takesUnspecified(Dummy *);
+
+Dummy *_Nullable returnsNullable();
+Dummy *_Nonnull returnsNonnull();
+Dummy *returnsUnspecified();
+int *_Nullable returnsNullableInt();
+
+template  T *eraseNullab(T *p) { return p; }
+
+void testBasicRules() {
+  Dummy *p = returnsNullable();
+  int *ptr = returnsNullableInt();
+  // Make every dereference a different path to avoid sinks after errors.
+  switch (getRandom()) {
+  case 0: {
+Dummy &r = *p; // expected-warning {{}}
+  } break;
+  case 1: {
+int b = p->val; // expected-warning {{}}
+  } break;
+  case 2: {
+int stuff = *ptr; // expected-warning {{}}
+  } break;
+  case 3:
+takesNonnull(p); // expected-warning {{}}
+break;
+  case 4: {
+Dummy d;
+takesNullable(&d);
+Dummy dd(d);
+break;
+  }
+  // Here the copy constructor is called, so a reference is initialized with the
+  // value of p. No ImplicitNullDereference event will be dispatched for this
+  // case. A followup patch is expected to fix this in NonNullParamChecker.
+  default: { Dummy d = *p; } break; // No warning.
+  }
+  if (p) {
+takesNonnull(p);
+if (getRandom()) {
+  Dummy &r = *p;
+} else {
+  int b = p->val;
+}
+  }
+  Dummy *q = 0;
+  if (getRandom()) {
+takesNullable(q);
+takesNonnull(q); // expected-warning {{}}
+  }
+  Dummy a;
+  Dummy *_Nonnull nonnull = &a;
+  nonnull = q; // expected-warning {{}}
+  q = &a;
+  takesNullable(q);
+  takesNonnull(q);
+}
+
+void testMultiParamChecking(Dummy *_Nonnull a, Dummy *_Nullable b,
+Dummy *_Nonnull c);
+
+void testArgumentTracking(Dummy *_Nonnull nonnull, Dummy *_Nullable nullable) {
+  Dummy *p = nullable;
+  Dummy *q = nonnull;
+  switch(getRandom()) {
+  case 1: nonnull = p; break; // expected-warning {{}}
+  case 2: p = 0; break;
+  case 3: q = p; break;
+  case 4: testMultiParamChecking(nonnull, nullable, nonnull); break;
+  case 5: testMultiParamChecking(nonnull, nonnull, nonnull); break;
+  case 6: testMultiParamChecking(nonnull, nullable, nullable); break; // expected-warning {{}}
+  case 7: testMultiParamChecking(nullable, nullable, nonnull); // expected-warning {{}}
+  case 8: testMultiParamChecking(nullable, nullable, nullable); // expected-warning {{}}
+  case 9: testMultiParamChecking((Dummy *_Nonnull)0, nullable, nonnull); break;
+  }
+}
+
+Dummy *_Nonnull testNullableReturn(Dummy *_Nullable a) {
+  Dummy *p = a;
+  return p; // expected-warning {{}}
+}
+
+Dummy *_Nonnull testNullReturn() {
+  Dummy *p = 0;
+  return p; // expected-warning {{}}
+}
+
+void testObjCMessageResultNullability() {
+  // The expected result: the most nullable of self and method return type.
+  TestObject *o = getUnspecifiedTestObject();
+  int *shouldBeNullable = [eraseNullab(getNullableTestObject()) returnsNonnull];
+  switch (getRandom()) {
+  case 0:
+// The core analyzer assumes that the receiver is non-null after a message
+// send. This is to avoid some false positives, and increase performance
+// but it also reduces the coverage and makes this checker unable to reason
+// about the nullness of the receiver. 
+[o takesNonnull:shouldBeNullable]; // No warning expected.
+break;
+  case 1:
+shouldBeNullable =
+[eraseNullab(getNullableTestObject()) returnsUnspecified];
+[o takesNonnull:shouldBeNullable]; // No warning exp

r245992 - [Headers] Require x86-registered for r245987 codegen tests.

2015-08-25 Thread Ahmed Bougacha via cfe-commits
Author: ab
Date: Tue Aug 25 18:42:55 2015
New Revision: 245992

URL: http://llvm.org/viewvc/llvm-project?rev=245992&view=rev
Log:
[Headers] Require x86-registered for r245987 codegen tests.

Modified:
cfe/trunk/test/CodeGen/avx2-builtins.c

Modified: cfe/trunk/test/CodeGen/avx2-builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/avx2-builtins.c?rev=245992&r1=245991&r2=245992&view=diff
==
--- cfe/trunk/test/CodeGen/avx2-builtins.c (original)
+++ cfe/trunk/test/CodeGen/avx2-builtins.c Tue Aug 25 18:42:55 2015
@@ -1,6 +1,8 @@
 // RUN: %clang_cc1 %s -O0 -triple=x86_64-apple-darwin -target-feature +avx2 
-emit-llvm -o - -Werror | FileCheck %s
 // RUN: %clang_cc1 %s -O0 -triple=x86_64-apple-darwin -target-feature +avx2 -S 
-o - -Werror | FileCheck %s --check-prefix=CHECK-ASM
 
+// REQUIRES: x86-registered-target
+
 // Don't include mm_malloc.h, it's system specific.
 #define __MM_MALLOC_H
 


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D12344: ARM: Error out if float-ab=hard and abi=apcs-gnu on macho platforms

2015-08-25 Thread Vedant Kumar via cfe-commits
vsk added a comment.

Yep, this looks fine. Out of curiosity, what happens if we permit the MachO + 
!useAAPCS + FloatABI=hard case?


http://reviews.llvm.org/D12344



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D11832: [Patch] [Analyzer] false positive: Potential leak connected with memcpy (PR 22954)

2015-08-25 Thread Devin Coughlin via cfe-commits
dcoughlin added a comment.

Thanks for adding handling of the symbolic cases! Some more comments inline.



Comment at: lib/StaticAnalyzer/Checkers/CStringChecker.cpp:825
@@ -816,1 +824,3 @@
 
+ProgramStateRef CStringChecker::IsFirstBufInBound(CheckerContext &C,
+  ProgramStateRef state,

It seems odd that you return a ProgramStateRef here but don't use it in the 
only caller of this function. Could you just return a boolean instead? 
Alternatively, if you really want to add the assumption that the buffer is 
valid to the post-state, then you should thread the state returned from the 
call to this function through the rest of CStringChecker::InvalidateBuffer.


Comment at: lib/StaticAnalyzer/Checkers/CStringChecker.cpp:840
@@ +839,3 @@
+  Optional Length = LengthVal.getAs();
+  if (!Length)
+return state;

You have a lot of early returns of the form:

  if (!Foo)
return state;

that don't seem to be exercised in your tests. Can these actually trigger? If 
so, you should add tests for these cases. If not, maybe 
asserts/cast()/castAs() would be more appropriate.

Also: should these early returns return state? Or should they return null?




Comment at: lib/StaticAnalyzer/Checkers/CStringChecker.cpp:851
@@ +850,3 @@
+  SVal BufStart = svalBuilder.evalCast(BufVal, PtrTy, FirstBuf->getType());
+  if (Optional BufLoc = BufStart.getAs()) {
+

Can you rewrite this if/else to avoid the indentation? (See 
http://llvm.org/docs/CodingStandards.html#don-t-use-else-after-a-return).


Comment at: lib/StaticAnalyzer/Checkers/CStringChecker.cpp:866
@@ +865,3 @@
+assert(ER->getValueType() == C.getASTContext().CharTy &&
+   "CheckLocation should only be called with char* ElementRegions");
+

"CheckLocation" is copy pasta here.


Comment at: lib/StaticAnalyzer/Core/RegionStore.cpp:1115
@@ +1114,3 @@
+  // or have a symbolic offset.
+  if (SuperR) {
+if (const ClusterBindings *C = B.lookup(SuperR)) {

This nesting is getting pretty deep. Can you invert some guards and change to 
goto/continue where appropriate.

For example:
  if (!SuperR)
goto conjure_default;

and

  const ClusterBindings *C = B.lookup(SuperR)
  if (!C)
continue;


Comment at: lib/StaticAnalyzer/Core/RegionStore.cpp:1125
@@ +1124,3 @@
+ ((*ROffset >= LowerOffset && *ROffset < UpperOffset) ||
+  (LowerOffset == UpperOffset && *ROffset == LowerOffset {
+  B = B.removeBinding(I.getKey());

Please add a comment here to say that this is to handle arrays of 0 elements 
and arrays of 0-sized elements.


Comment at: lib/StaticAnalyzer/Core/RegionStore.cpp:1132
@@ +1131,3 @@
+  if (R)
+if (const SymbolicRegion *SR = dyn_cast(R))
+  VisitBinding(V);

If you are not going to use the result, you can use isa(R) here 
instead of dyn_cast.


Comment at: test/Analysis/pr22954.c:476
@@ +475,3 @@
+  clang_analyzer_eval(m->s3[3] == 1); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(m->s3[i] == 1); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(l->s1[0] == 1); // expected-warning{{UNKNOWN}}

Should this test m->s3[j] as well?


Comment at: test/Analysis/pr22954.c:498
@@ +497,3 @@
+}
+
+

Can you also add a test where the size argument to memcpy is the result of 
sizeof()?


http://reviews.llvm.org/D11832



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D10599: [OPENMP 4.0] Initial support for '#pragma omp declare simd' directive.

2015-08-25 Thread Richard Smith via cfe-commits
rsmith added inline comments.


Comment at: include/clang/Basic/Attr.td:2074-2078
@@ +2073,7 @@
+  let Documentation = [OMPDeclareSimdDocs];
+  let AdditionalMembers = [{
+  void printPrettyPragma(raw_ostream &OS, const PrintingPolicy &Policy) const {
+OS << "\n";
+  }
+  }];
+}

What's this for?


Comment at: include/clang/Basic/DiagnosticParseKinds.td:996-999
@@ -995,2 +995,6 @@
   "expected identifier specifying the name of the 'omp critical' directive">;
+def err_omp_single_decl_in_declare_simd : Error<
+  "single declaration is expected with 'declare simd' directive">;
+def err_omp_decl_in_declare_simd : Error<
+  "function declaration is expected with 'declare simd' directive">;
 

with -> after, in both diagnstics.


Comment at: include/clang/Basic/DiagnosticSemaKinds.td:7661
@@ -7660,1 +7660,3 @@
+def err_omp_function_expected : Error<
+  "'#pragma omp declare simd' can be applied to functions only">;
 def err_omp_wrong_cancel_region : Error<

can be applied to functions only -> can only be applied to functions


Comment at: lib/AST/DeclPrinter.cpp:214
@@ +213,3 @@
+  default:
+if (!PrintPragmas)
+  A->printPretty(Out, Policy);

It looks like we would no longer print attributes with pragma spelling for 
non-function declarations after this change (but I don't think we have any such 
pragmas at the moment). I don't want to ask you to write a bunch more code here 
that you can't test, but can you add a FIXME somewhere in here to add calls to 
print pragmas in more places?


Comment at: lib/Parse/ParseOpenMP.cpp:133
@@ +132,3 @@
+  << getOpenMPDirectiveName(OMPD_declare_simd);
+  SkipUntil(tok::annot_pragma_openmp_end, StopBeforeMatch);
+}

You should bail out if you don't actually find your desired token. If you carry 
on without checking, your `ConsumeToken` call might consume the `tok::eof` 
token or some similar bad thing.


Comment at: lib/Parse/ParseOpenMP.cpp:144-145
@@ +143,4 @@
+  // Here we expect to see some function declaration.
+  while (Tok.isNot(tok::r_brace) && !isEofOrEom() &&
+ (!Ptr || Ptr.get().isNull())) {
+if (AS == AS_none) {

I find this loop slightly surprising: the cases where Parse*Declaration return 
a null `DeclGroupPtrTy` are when they parsed some declaration-like entity (such 
as a declaration-like pragma) but didn't create some declaration to represent 
it.

Do you really want to allow such things between your pragma and its associated 
function? As an extreme case, you'd accept things like this:

  #pragma omp declare simd
  #pragma pack (...)
  ;
  public:
  __if_exists(foo) {
int n;
  }
  int the_simd_function();


Comment at: lib/Parse/ParseOpenMP.cpp:145
@@ +144,3 @@
+  while (Tok.isNot(tok::r_brace) && !isEofOrEom() &&
+ (!Ptr || Ptr.get().isNull())) {
+if (AS == AS_none) {

Do you really need to check both `!Ptr` and `Ptr.get().isNull()` here? 
Generally, the parser shouldn't really be calling `get()` on an `OpaquePtr` -- 
these pointers are supposed to be opaque to the parser.


Comment at: lib/Parse/ParseOpenMP.cpp:160
@@ +159,3 @@
+Diag(Loc, diag::err_omp_decl_in_declare_simd);
+  return DeclGroupPtrTy();
+}

The only way you could get here without being at EOF or EOM would be if you hit 
an unexpected right-brace. Shouldn't you diagnose that? For instance, it looks 
like you won't diagnose this case:

  namespace N {
#pragma omp declare simd
  }


Comment at: lib/Parse/ParseOpenMP.cpp:162-168
@@ +161,9 @@
+}
+if (!Ptr.get().isSingleDecl())
+  Diag(Loc, diag::err_omp_single_decl_in_declare_simd);
+
+if (Ptr.get().isSingleDecl())
+  return Actions.ActOnOpenMPDeclareSimdDirective(Ptr.get().getSingleDecl(),
+ Loc);
+return Ptr;
+  }

I would suggest that you instead call `ActOnOpenMPDeclareSimdDirective` 
unconditionally, pass in `Ptr` rather than its contained declaration, and check 
for a single declaration in `Sema` -- this seems much more of a semantic check 
than a syntactic one.


http://reviews.llvm.org/D10599



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D12352: Clang part -- Changing @llvm.objectsize(i8*, i1) to @llvm.objectsize(i8*, i8)

2015-08-25 Thread George Burgess IV via cfe-commits
george.burgess.iv created this revision.
george.burgess.iv added a reviewer: rsmith.
george.burgess.iv added a subscriber: cfe-commits.

Modify clang to emit `@llvm.objectsize(i8*, i8)` instead of 
`@llvm.objectsize(i8*, i1)`

Accompanying LLVM patch: http://reviews.llvm.org/D12351

http://reviews.llvm.org/D12352

Files:
  lib/AST/ExprConstant.cpp
  lib/CodeGen/CGBuiltin.cpp
  lib/CodeGen/CGExpr.cpp
  test/CodeGen/catch-undef-behavior.c
  test/CodeGen/object-size.c
  test/CodeGen/sanitize-recover.c

Index: test/CodeGen/sanitize-recover.c
===
--- test/CodeGen/sanitize-recover.c
+++ test/CodeGen/sanitize-recover.c
@@ -21,7 +21,7 @@
   u.i=1;
   // PARTIAL:  %[[CHECK0:.*]] = icmp ne {{.*}}* %[[PTR:.*]], null
 
-  // PARTIAL:  %[[SIZE:.*]] = call i64 @llvm.objectsize.i64.p0i8(i8* {{.*}}, i1 false)
+  // PARTIAL:  %[[SIZE:.*]] = call i64 @llvm.objectsize.i64.p0i8(i8* {{.*}}, i8 0)
   // PARTIAL-NEXT: %[[CHECK1:.*]] = icmp uge i64 %[[SIZE]], 4
 
   // PARTIAL:  %[[MISALIGN:.*]] = and i64 {{.*}}, 3
Index: test/CodeGen/object-size.c
===
--- test/CodeGen/object-size.c
+++ test/CodeGen/object-size.c
@@ -40,7 +40,7 @@
 // CHECK-LABEL: define void @test5
 void test5() {
   // CHECK: = load i8*, i8** @gp
-  // CHECK-NEXT:= call i64 @llvm.objectsize.i64.p0i8(i8* %{{.*}}, i1 false)
+  // CHECK-NEXT:= call i64 @llvm.objectsize.i64.p0i8(i8* %{{.*}}, i8 0)
   strcpy(gp, "Hi there");
 }
 
@@ -227,56 +227,47 @@
 
 // CHECK: @test23
 void test23(struct Test22Ty *p) {
-  // CHECK: call i64 @llvm.objectsize.i64.p0i8(i8* %{{.*}}, i1 false)
+  // CHECK: call i64 @llvm.objectsize.i64.p0i8(i8* %{{.*}}, i8 0)
   gi = __builtin_object_size(p, 0);
-  // CHECK: call i64 @llvm.objectsize.i64.p0i8(i8* %{{.*}}, i1 false)
+  // CHECK: call i64 @llvm.objectsize.i64.p0i8(i8* %{{.*}}, i8 1)
   gi = __builtin_object_size(p, 1);
-  // CHECK: call i64 @llvm.objectsize.i64.p0i8(i8* %{{.*}}, i1 true)
+  // CHECK: call i64 @llvm.objectsize.i64.p0i8(i8* %{{.*}}, i8 2)
   gi = __builtin_object_size(p, 2);
-
-  // Note: this is currently fixed at 0 because LLVM doesn't have sufficient
-  // data to correctly handle type=3
-  // CHECK: store i32 0
+  // CHECK: call i64 @llvm.objectsize.i64.p0i8(i8* %{{.*}}, i8 3)
   gi = __builtin_object_size(p, 3);
 }
 
 
 // PR24493 -- ICE if __builtin_object_size called with NULL and (Type & 1) != 0
 // CHECK @test24
 void test24() {
-  // CHECK: call i64 @llvm.objectsize.i64.p0i8(i8* {{.*}}, i1 false)
+  // CHECK: call i64 @llvm.objectsize.i64.p0i8(i8* {{.*}}, i8 0)
   gi = __builtin_object_size((void*)0, 0);
-  // CHECK: call i64 @llvm.objectsize.i64.p0i8(i8* {{.*}}, i1 false)
+  // CHECK: call i64 @llvm.objectsize.i64.p0i8(i8* {{.*}}, i8 1)
   gi = __builtin_object_size((void*)0, 1);
-  // CHECK: call i64 @llvm.objectsize.i64.p0i8(i8* {{.*}}, i1 true)
+  // CHECK: call i64 @llvm.objectsize.i64.p0i8(i8* {{.*}}, i8 2)
   gi = __builtin_object_size((void*)0, 2);
-  // Note: Currently fixed at zero because LLVM can't handle type=3 correctly.
-  // Hopefully will be lowered properly in the future.
-  // CHECK: store i32 0
+  // CHECK: call i64 @llvm.objectsize.i64.p0i8(i8* {{.*}}, i8 3)
   gi = __builtin_object_size((void*)0, 3);
 }
 
 // CHECK @test25
 void test25() {
-  // CHECK: call i64 @llvm.objectsize.i64.p0i8(i8* {{.*}}, i1 false)
+  // CHECK: call i64 @llvm.objectsize.i64.p0i8(i8* {{.*}}, i8 0)
   gi = __builtin_object_size((void*)0x1000, 0);
-  // CHECK: call i64 @llvm.objectsize.i64.p0i8(i8* {{.*}}, i1 false)
+  // CHECK: call i64 @llvm.objectsize.i64.p0i8(i8* {{.*}}, i8 1)
   gi = __builtin_object_size((void*)0x1000, 1);
-  // CHECK: call i64 @llvm.objectsize.i64.p0i8(i8* {{.*}}, i1 true)
+  // CHECK: call i64 @llvm.objectsize.i64.p0i8(i8* {{.*}}, i8 2)
   gi = __builtin_object_size((void*)0x1000, 2);
-  // Note: Currently fixed at zero because LLVM can't handle type=3 correctly.
-  // Hopefully will be lowered properly in the future.
-  // CHECK: store i32 0
+  // CHECK: call i64 @llvm.objectsize.i64.p0i8(i8* {{.*}}, i8 3)
   gi = __builtin_object_size((void*)0x1000, 3);
 
-  // CHECK: call i64 @llvm.objectsize.i64.p0i8(i8* {{.*}}, i1 false)
+  // CHECK: call i64 @llvm.objectsize.i64.p0i8(i8* {{.*}}, i8 0)
   gi = __builtin_object_size((void*)0 + 0x1000, 0);
-  // CHECK: call i64 @llvm.objectsize.i64.p0i8(i8* {{.*}}, i1 false)
+  // CHECK: call i64 @llvm.objectsize.i64.p0i8(i8* {{.*}}, i8 1)
   gi = __builtin_object_size((void*)0 + 0x1000, 1);
-  // CHECK: call i64 @llvm.objectsize.i64.p0i8(i8* {{.*}}, i1 true)
+  // CHECK: call i64 @llvm.objectsize.i64.p0i8(i8* {{.*}}, i8 2)
   gi = __builtin_object_size((void*)0 + 0x1000, 2);
-  // Note: Currently fixed at zero because LLVM can't handle type=3 correctly.
-  // Hopefully will be lowered properly in the future.
-  // CHECK: store i32 0
+  // CHECK: call i64 @llvm.objectsize.i64.p0i8(i8* {{.*}}, i8 3)
   gi = __b

Re: [PATCH] D4447: [libcxx] Fixes libc++ bug #19921 - Remove additional overloads for std::complex

2015-08-25 Thread Eric Fiselier via cfe-commits
EricWF added a comment.

Ping @mclow.lists. This is one of the first patches I submitted but I abandoned 
it due to ABI concerns. However I now believe that this patch does not break 
the ABI.


http://reviews.llvm.org/D4447



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r246003 - Add missing newline.

2015-08-25 Thread Ted Kremenek via cfe-commits
Author: kremenek
Date: Tue Aug 25 22:11:31 2015
New Revision: 246003

URL: http://llvm.org/viewvc/llvm-project?rev=246003&view=rev
Log:
Add missing newline.

Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp?rev=246003&r1=246002&r2=246003&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp Tue Aug 25 
22:11:31 2015
@@ -592,4 +592,4 @@ void ento::registerNonLocalizedStringChe
 
 void ento::registerEmptyLocalizationContextChecker(CheckerManager &mgr) {
   mgr.registerChecker();
-}
\ No newline at end of file
+}


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D11857: CFI: Introduce -fsanitize=cfi-icall flag.

2015-08-25 Thread Peter Collingbourne via cfe-commits
pcc updated this revision to Diff 33175.
pcc added a comment.

- Add apology for lack of documentation


http://reviews.llvm.org/D11857

Files:
  docs/ControlFlowIntegrity.rst
  docs/ControlFlowIntegrityDesign.rst
  include/clang/AST/Mangle.h
  include/clang/Basic/Sanitizers.def
  lib/AST/ItaniumMangle.cpp
  lib/AST/MicrosoftMangle.cpp
  lib/CodeGen/CGClass.cpp
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CGVTables.cpp
  lib/CodeGen/CodeGenModule.cpp
  lib/Driver/ToolChain.cpp
  lib/Driver/ToolChains.cpp
  test/CodeGen/cfi-icall.c
  test/CodeGenCXX/cfi-cast.cpp
  test/CodeGenCXX/cfi-icall.cpp
  test/CodeGenCXX/cfi-ms-rtti.cpp
  test/CodeGenCXX/cfi-nvcall.cpp
  test/CodeGenCXX/cfi-vcall.cpp
  test/Driver/fsanitize.c

Index: test/Driver/fsanitize.c
===
--- test/Driver/fsanitize.c
+++ test/Driver/fsanitize.c
@@ -234,15 +234,18 @@
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=cfi-unrelated-cast -flto -c %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-CFI-UCAST
 // RUN: %clang -target x86_64-linux-gnu -flto -fsanitize=cfi-nvcall -c %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-CFI-NVCALL
 // RUN: %clang -target x86_64-linux-gnu -flto -fsanitize=cfi-vcall -c %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-CFI-VCALL
-// CHECK-CFI: -emit-llvm-bc{{.*}}-fsanitize=cfi-derived-cast,cfi-unrelated-cast,cfi-nvcall,cfi-vcall
+// CHECK-CFI: -emit-llvm-bc{{.*}}-fsanitize=cfi-derived-cast,cfi-icall,cfi-unrelated-cast,cfi-nvcall,cfi-vcall
 // CHECK-CFI-DCAST: -emit-llvm-bc{{.*}}-fsanitize=cfi-derived-cast
 // CHECK-CFI-UCAST: -emit-llvm-bc{{.*}}-fsanitize=cfi-unrelated-cast
 // CHECK-CFI-NVCALL: -emit-llvm-bc{{.*}}-fsanitize=cfi-nvcall
 // CHECK-CFI-VCALL: -emit-llvm-bc{{.*}}-fsanitize=cfi-vcall
 
 // RUN: %clang -target x86_64-linux-gnu -flto -fsanitize=cfi-derived-cast -fno-lto -c %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-CFI-NOLTO
 // CHECK-CFI-NOLTO: '-fsanitize=cfi-derived-cast' only allowed with '-flto'
 
+// RUN: %clang -target mips-unknown-linux -fsanitize=cfi-icall %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-CFI-ICALL-MIPS
+// CHECK-CFI-ICALL-MIPS: unsupported option '-fsanitize=cfi-icall' for target 'mips-unknown-linux'
+
 // RUN: %clang -target x86_64-linux-gnu -fsanitize-trap=address -c %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ASAN-TRAP
 // CHECK-ASAN-TRAP: error: unsupported argument 'address' to option '-fsanitize-trap'
 
Index: test/CodeGenCXX/cfi-vcall.cpp
===
--- test/CodeGenCXX/cfi-vcall.cpp
+++ test/CodeGenCXX/cfi-vcall.cpp
@@ -60,8 +60,8 @@
 // ITANIUM: define void @_Z2afP1A
 // MS: define void @"\01?af@@YAXPEAUA@@@Z"
 void af(A *a) {
-  // ITANIUM: [[P:%[^ ]*]] = call i1 @llvm.bitset.test(i8* [[VT:%[^ ]*]], metadata !"1A")
-  // MS: [[P:%[^ ]*]] = call i1 @llvm.bitset.test(i8* [[VT:%[^ ]*]], metadata !"A@@")
+  // ITANIUM: [[P:%[^ ]*]] = call i1 @llvm.bitset.test(i8* [[VT:%[^ ]*]], metadata !"_ZTS1A")
+  // MS: [[P:%[^ ]*]] = call i1 @llvm.bitset.test(i8* [[VT:%[^ ]*]], metadata !"?AUA@@")
   // CHECK-NEXT: br i1 [[P]], label %[[CONTBB:[^ ,]*]], label %[[TRAPBB:[^ ,]*]]
   // CHECK-NEXT: {{^$}}
 
@@ -82,24 +82,24 @@
 // ITANIUM: define internal void @_Z3df1PN12_GLOBAL__N_11DE
 // MS: define internal void @"\01?df1@@YAXPEAUD@?A@@@Z"
 void df1(D *d) {
-  // ITANIUM: {{%[^ ]*}} = call i1 @llvm.bitset.test(i8* {{%[^ ]*}}, metadata !"[{{.*}}cfi-vcall.cpp]N12_GLOBAL__N_11DE")
-  // MS: {{%[^ ]*}} = call i1 @llvm.bitset.test(i8* {{%[^ ]*}}, metadata !"A@@")
+  // ITANIUM: {{%[^ ]*}} = call i1 @llvm.bitset.test(i8* {{%[^ ]*}}, metadata ![[DTYPE:[0-9]+]])
+  // MS: {{%[^ ]*}} = call i1 @llvm.bitset.test(i8* {{%[^ ]*}}, metadata !"?AUA@@")
   d->f();
 }
 
 // ITANIUM: define internal void @_Z3dg1PN12_GLOBAL__N_11DE
 // MS: define internal void @"\01?dg1@@YAXPEAUD@?A@@@Z"
 void dg1(D *d) {
-  // ITANIUM: {{%[^ ]*}} = call i1 @llvm.bitset.test(i8* {{%[^ ]*}}, metadata !"1B")
-  // MS: {{%[^ ]*}} = call i1 @llvm.bitset.test(i8* {{%[^ ]*}}, metadata !"B@@")
+  // ITANIUM: {{%[^ ]*}} = call i1 @llvm.bitset.test(i8* {{%[^ ]*}}, metadata !"_ZTS1B")
+  // MS: {{%[^ ]*}} = call i1 @llvm.bitset.test(i8* {{%[^ ]*}}, metadata !"?AUB@@")
   d->g();
 }
 
 // ITANIUM: define internal void @_Z3dh1PN12_GLOBAL__N_11DE
 // MS: define internal void @"\01?dh1@@YAXPEAUD@?A@@@Z"
 void dh1(D *d) {
-  // ITANIUM: {{%[^ ]*}} = call i1 @llvm.bitset.test(i8* {{%[^ ]*}}, metadata !"[{{.*}}cfi-vcall.cpp]N12_GLOBAL__N_11DE")
-  // MS: {{%[^ ]*}} = call i1 @llvm.bitset.test(i8* {{%[^ ]*}}, metadata !"[{{.*}}cfi-vcall.cpp]D@?A@@")
+  // ITANIUM: {{%[^ ]*}} = call i1 @llvm.bitset.test(i8* {{%[^ ]*}}, metadata ![[DTYPE]])
+  // MS: {{%[^ ]*}} = call i1 @llvm.bitset.test(i8* {{%[^ ]*}}, metadata ![[DTYPE:[0-9]+]])
   d->h();
 }
 
@@ -150,8 +150,8 @@
 // ITANIUM: define void @_ZN5test21fEPNS_1DE
 // MS: define void @"\01?f@test2@@YAXPEAUD@1@@Z"
 void f(D *d) {
-  // ITANIUM: {{%[^ ]*}} = call i1 @llvm

Re: [PATCH] D11789: Modify DeclaratorChuck::getFunction to be passed an Exception Specification SourceRange

2015-08-25 Thread Nathan Wilson via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL246005: Modify DeclaratorChuck::getFunction to be passed an 
Exception Specification… (authored by nwilson).

Changed prior to commit:
  http://reviews.llvm.org/D11789?vs=33093&id=33177#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D11789

Files:
  cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
  cfe/trunk/include/clang/Sema/DeclSpec.h
  cfe/trunk/lib/Parse/ParseDecl.cpp
  cfe/trunk/lib/Parse/ParseExpr.cpp
  cfe/trunk/lib/Parse/ParseExprCXX.cpp
  cfe/trunk/lib/Sema/DeclSpec.cpp
  cfe/trunk/lib/Sema/SemaDecl.cpp
  cfe/trunk/lib/Sema/SemaType.cpp
  cfe/trunk/test/SemaCXX/cxx-concept-declaration.cpp

Index: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
@@ -1977,6 +1977,8 @@
   "function concept declaration must be a definition">;
 def err_var_concept_not_initialized : Error<
   "variable concept declaration must be initialized">;
+def err_function_concept_exception_spec : Error<
+  "function concept cannot have exception specification">;
 
 // C++11 char16_t/char32_t
 def warn_cxx98_compat_unicode_type : Warning<
Index: cfe/trunk/include/clang/Sema/DeclSpec.h
===
--- cfe/trunk/include/clang/Sema/DeclSpec.h
+++ cfe/trunk/include/clang/Sema/DeclSpec.h
@@ -1255,8 +1255,11 @@
 /// any.
 unsigned MutableLoc;
 
-/// \brief The location of the keyword introducing the spec, if any.
-unsigned ExceptionSpecLoc;
+/// \brief The beginning location of the exception specification, if any.
+unsigned ExceptionSpecLocBeg;
+
+/// \brief The end location of the exception specification, if any.
+unsigned ExceptionSpecLocEnd;
 
 /// Params - This is a pointer to a new[]'d array of ParamInfo objects that
 /// describe the parameters specified by this function declarator.  null if
@@ -1323,8 +1326,16 @@
   return SourceLocation::getFromRawEncoding(RParenLoc);
 }
 
-SourceLocation getExceptionSpecLoc() const {
-  return SourceLocation::getFromRawEncoding(ExceptionSpecLoc);
+SourceLocation getExceptionSpecLocBeg() const {
+  return SourceLocation::getFromRawEncoding(ExceptionSpecLocBeg);
+}
+
+SourceLocation getExceptionSpecLocEnd() const {
+  return SourceLocation::getFromRawEncoding(ExceptionSpecLocEnd);
+}
+
+SourceRange getExceptionSpecRange() const {
+  return SourceRange(getExceptionSpecLocBeg(), getExceptionSpecLocEnd());
 }
 
 /// \brief Retrieve the location of the ref-qualifier, if any.
@@ -1496,7 +1507,7 @@
  SourceLocation RestrictQualifierLoc,
  SourceLocation MutableLoc,
  ExceptionSpecificationType ESpecType,
- SourceLocation ESpecLoc,
+ SourceRange ESpecRange,
  ParsedType *Exceptions,
  SourceRange *ExceptionRanges,
  unsigned NumExceptions,
Index: cfe/trunk/test/SemaCXX/cxx-concept-declaration.cpp
===
--- cfe/trunk/test/SemaCXX/cxx-concept-declaration.cpp
+++ cfe/trunk/test/SemaCXX/cxx-concept-declaration.cpp
@@ -1,11 +1,14 @@
-// RUN:  %clang_cc1 -std=c++14 -fconcepts-ts -x c++ -verify %s
+// RUN:  %clang_cc1 -std=c++14 -fconcepts-ts -fcxx-exceptions -x c++ -verify %s
 
 namespace A {
   template concept bool C1() { return true; }
 
   template concept bool C2 = true;
 }
 
+template concept bool C3() { return (throw 0, true); }
+static_assert(noexcept(C3()), "function concept should be treated as if noexcept(true) specified");
+
 template concept bool D1(); // expected-error {{function concept declaration must be a definition}}
 
 struct B {
@@ -23,6 +26,9 @@
 template
 concept bool D6; // expected-error {{variable concept declaration must be initialized}}
 
+template
+concept bool D7() throw(int) { return true; } // expected-error {{function concept cannot have exception specification}}
+
 // Tag
 concept class CC1 {}; // expected-error {{'concept' can only appear on the definition of a function template or variable template}}
 concept struct CS1 {}; // expected-error {{'concept' can only appear on the definition of a function template or variable template}}
Index: cfe/trunk/lib/Sema/SemaType.cpp
===
--- cfe/trunk/lib/Sema/SemaType.cpp
+++ cfe/trunk/lib/Sema/SemaType.cpp
@@ -700,7 +700,7 @@
   /*VolatileQualifierLoc=*/NoLoc,
   /*RestrictQualifierLoc=*/NoLoc,
   /*MutableLoc=*/NoLoc, EST_None,
-  /*ESpecLoc=*/NoLoc,
+  /*ESpecRange=*/SourceR

r246005 - Modify DeclaratorChuck::getFunction to be passed an Exception Specification SourceRange

2015-08-25 Thread Nathan Wilson via cfe-commits
Author: nwilson
Date: Tue Aug 25 23:19:36 2015
New Revision: 246005

URL: http://llvm.org/viewvc/llvm-project?rev=246005&view=rev
Log:
Modify DeclaratorChuck::getFunction to be passed an Exception Specification 
SourceRange

Summary:
- Store the exception specification range's begin and end SourceLocation in 
DeclaratorChuck::FunctionTypeInfo. These SourceLocations can be used in a 
FixItHint Range.
- Add diagnostic; function concept having an exception specification.


Reviewers: hubert.reinterpretcast, fraggamuffin, faisalv, aaron.ballman, rsmith

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D11789

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Sema/DeclSpec.h
cfe/trunk/lib/Parse/ParseDecl.cpp
cfe/trunk/lib/Parse/ParseExpr.cpp
cfe/trunk/lib/Parse/ParseExprCXX.cpp
cfe/trunk/lib/Sema/DeclSpec.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/test/SemaCXX/cxx-concept-declaration.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=246005&r1=246004&r2=246005&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue Aug 25 23:19:36 
2015
@@ -1977,6 +1977,8 @@ def err_function_concept_not_defined : E
   "function concept declaration must be a definition">;
 def err_var_concept_not_initialized : Error<
   "variable concept declaration must be initialized">;
+def err_function_concept_exception_spec : Error<
+  "function concept cannot have exception specification">;
 
 // C++11 char16_t/char32_t
 def warn_cxx98_compat_unicode_type : Warning<

Modified: cfe/trunk/include/clang/Sema/DeclSpec.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/DeclSpec.h?rev=246005&r1=246004&r2=246005&view=diff
==
--- cfe/trunk/include/clang/Sema/DeclSpec.h (original)
+++ cfe/trunk/include/clang/Sema/DeclSpec.h Tue Aug 25 23:19:36 2015
@@ -1255,8 +1255,11 @@ struct DeclaratorChunk {
 /// any.
 unsigned MutableLoc;
 
-/// \brief The location of the keyword introducing the spec, if any.
-unsigned ExceptionSpecLoc;
+/// \brief The beginning location of the exception specification, if any.
+unsigned ExceptionSpecLocBeg;
+
+/// \brief The end location of the exception specification, if any.
+unsigned ExceptionSpecLocEnd;
 
 /// Params - This is a pointer to a new[]'d array of ParamInfo objects that
 /// describe the parameters specified by this function declarator.  null if
@@ -1323,8 +1326,16 @@ struct DeclaratorChunk {
   return SourceLocation::getFromRawEncoding(RParenLoc);
 }
 
-SourceLocation getExceptionSpecLoc() const {
-  return SourceLocation::getFromRawEncoding(ExceptionSpecLoc);
+SourceLocation getExceptionSpecLocBeg() const {
+  return SourceLocation::getFromRawEncoding(ExceptionSpecLocBeg);
+}
+
+SourceLocation getExceptionSpecLocEnd() const {
+  return SourceLocation::getFromRawEncoding(ExceptionSpecLocEnd);
+}
+
+SourceRange getExceptionSpecRange() const {
+  return SourceRange(getExceptionSpecLocBeg(), getExceptionSpecLocEnd());
 }
 
 /// \brief Retrieve the location of the ref-qualifier, if any.
@@ -1496,7 +1507,7 @@ struct DeclaratorChunk {
  SourceLocation RestrictQualifierLoc,
  SourceLocation MutableLoc,
  ExceptionSpecificationType ESpecType,
- SourceLocation ESpecLoc,
+ SourceRange ESpecRange,
  ParsedType *Exceptions,
  SourceRange *ExceptionRanges,
  unsigned NumExceptions,

Modified: cfe/trunk/lib/Parse/ParseDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=246005&r1=246004&r2=246005&view=diff
==
--- cfe/trunk/lib/Parse/ParseDecl.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDecl.cpp Tue Aug 25 23:19:36 2015
@@ -5620,7 +5620,7 @@ void Parser::ParseFunctionDeclarator(Dec
  VolatileQualifierLoc,
  RestrictQualifierLoc,
  /*MutableLoc=*/SourceLocation(),
- ESpecType, ESpecRange.getBegin(),
+ ESpecType, ESpecRange,
  DynamicExceptions.data(),

r246006 - Update file comment to more accurately describe what's implemented.

2015-08-25 Thread Eric Christopher via cfe-commits
Author: echristo
Date: Tue Aug 25 23:23:11 2015
New Revision: 246006

URL: http://llvm.org/viewvc/llvm-project?rev=246006&view=rev
Log:
Update file comment to more accurately describe what's implemented.

Modified:
cfe/trunk/lib/Basic/Targets.cpp

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=246006&r1=246005&r2=246006&view=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Tue Aug 25 23:23:11 2015
@@ -1,4 +1,4 @@
-//===--- Targets.cpp - Implement -arch option and targets 
-===//
+//===--- Targets.cpp - Implement target feature support 
---===//
 //
 // The LLVM Compiler Infrastructure
 //


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D12354: [libcxx] Add global assertion handler for debug mode.

2015-08-25 Thread Eric Fiselier via cfe-commits
EricWF created this revision.
EricWF added a reviewer: mclow.lists.
EricWF added a subscriber: cfe-commits.

This patch adds a global assertion handler that is called when _LIBCPP_ASSERT 
fails. This allows us to test debug mode features without _LIBCPP_ASSERT always 
calling `abort()`.

This patch also fixes PR17147 and uses the new assertion handlers in the tests. 
(see https://llvm.org/bugs/show_bug.cgi?id=17147)

http://reviews.llvm.org/D12354

Files:
  include/__debug
  include/algorithm
  src/debug.cpp
  test/libcxx/algorithms/debug_less.pass.cpp
  test/support/debug_mode.h

Index: test/support/debug_mode.h
===
--- /dev/null
+++ test/support/debug_mode.h
@@ -0,0 +1,34 @@
+#ifndef SUPPORT_DEBUG_MODE_H
+#define SUPPORT_DEBUG_MODE_H
+
+#ifndef _LIBCPP_DEBUG
+#error _LIBCPP_DEBUG must be defined before including the header
+#endif
+#ifdef _LIBCPP_CONFIG
+#error debug_mode.h must be included before any libc++ files
+#endif
+
+#include <__debug>
+#include 
+
+typedef std::__debug_assertion_handler_t DebugHandlerT;
+typedef std::__debug_assertion_info DebugInfo;
+
+inline DebugHandlerT getDebugHandler(DebugHandlerT new_h = nullptr) {
+return std::__debug_assertion_handler(new_h);
+}
+
+void exitZeroHandler(DebugInfo const&) {
+std::exit(0);
+}
+
+struct DebugException {
+DebugInfo info;
+DebugException(DebugInfo xinfo) : info(xinfo) {}
+};
+
+inline void throwingDebugHandler(DebugInfo const& info) {
+throw DebugException(info);
+}
+
+#endif // SUPPORT_DEBUG_MODE_H
Index: test/libcxx/algorithms/debug_less.pass.cpp
===
--- /dev/null
+++ test/libcxx/algorithms/debug_less.pass.cpp
@@ -0,0 +1,164 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// 
+
+// template  struct __debug_less
+
+// __debug_less checks that a comparator actually provides a strict-weak ordering.
+
+#define _LIBCPP_DEBUG 0
+#include "debug_mode.h"
+
+#include 
+#include 
+
+template 
+struct MyType {
+int value;
+explicit MyType(int xvalue = 0) : value(xvalue) {}
+};
+
+template 
+bool operator<(MyType const& LHS, MyType const& RHS) {
+return LHS.value < RHS.value;
+}
+
+struct CompareBase {
+static int called;
+static void reset() {
+called = 0;
+}
+};
+
+int CompareBase::called = 0;
+
+template 
+struct GoodComparator : public CompareBase {
+bool operator()(ValueType const& lhs, ValueType const& rhs) const {
+++CompareBase::called;
+return lhs < rhs;
+}
+};
+
+template 
+struct BadComparator : public CompareBase {
+bool operator()(ValueType const&, ValueType const&) const {
+++CompareBase::called;
+return true;
+}
+};
+
+template 
+struct TwoWayHomoComparator : public CompareBase {
+bool operator()(T1 const& lhs, T2 const& rhs) const {
+++CompareBase::called;
+return lhs < rhs;
+}
+
+bool operator()(T2 const& lhs, T1 const& rhs) const {
+++CompareBase::called;
+return lhs < rhs;
+}
+};
+
+template 
+struct OneWayHomoComparator : public CompareBase {
+bool operator()(T1 const& lhs, T2 const& rhs) const {
+++CompareBase::called;
+return lhs < rhs;
+}
+};
+
+using std::__debug_less;
+
+typedef MyType<0> MT0;
+typedef MyType<1> MT1;
+
+void test_passing() {
+int& called = CompareBase::called;
+called = 0;
+MT0 one(1);
+MT0 two(2);
+MT1 three(3);
+MT1 four(4);
+
+{
+typedef GoodComparator C;
+typedef __debug_less D;
+
+C c;
+D d(c);
+
+assert(d(one, two) == true);
+assert(called == 2);
+called = 0;
+
+assert(d(one, one) == false);
+assert(called == 1);
+called = 0;
+
+assert(d(two, one) == false);
+assert(called == 1);
+called = 0;
+}
+{
+typedef TwoWayHomoComparator C;
+typedef __debug_less D;
+C c;
+D d(c);
+
+assert(d(one, three) == true);
+assert(called == 2);
+called = 0;
+
+assert(d(three, one) == false);
+assert(called == 1);
+called = 0;
+}
+{
+typedef OneWayHomoComparator C;
+typedef __debug_less D;
+C c;
+D d(c);
+
+assert(d(one, three) == true);
+assert(called == 1);
+called = 0;
+}
+}
+
+void test_failing() {
+int& called = CompareBase::called;
+called = 0;
+MT0 one(1);
+MT0 two(2);
+
+{
+typedef BadComparator C;
+typedef __debug_less D;
+C c;
+D d(c);
+
+try {
+d(one, 

r246014 - [Sema] Don't assume CallExpr::getDirectCallee will succeed

2015-08-25 Thread David Majnemer via cfe-commits
Author: majnemer
Date: Wed Aug 26 00:13:19 2015
New Revision: 246014

URL: http://llvm.org/viewvc/llvm-project?rev=246014&view=rev
Log:
[Sema] Don't assume CallExpr::getDirectCallee will succeed

We tried to provide a very nice diagnostic when diagnosing an assignment
to a const int & produced by a function call.  However, we cannot always
determine what function was called.

This fixes PR24568.

Modified:
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/SemaCXX/err_typecheck_assign_const.cpp

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=246014&r1=246013&r2=246014&view=diff
==
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Wed Aug 26 00:13:19 2015
@@ -9316,7 +9316,7 @@ static void DiagnoseConstAssignment(Sema
   if (const CallExpr *CE = dyn_cast(E)) {
 // Function calls
 const FunctionDecl *FD = CE->getDirectCallee();
-if (!IsTypeModifiable(FD->getReturnType(), IsDereference)) {
+if (FD && !IsTypeModifiable(FD->getReturnType(), IsDereference)) {
   if (!DiagnosticEmitted) {
 S.Diag(Loc, diag::err_typecheck_assign_const) << ExprRange
   << ConstFunction << FD;

Modified: cfe/trunk/test/SemaCXX/err_typecheck_assign_const.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/err_typecheck_assign_const.cpp?rev=246014&r1=246013&r2=246014&view=diff
==
--- cfe/trunk/test/SemaCXX/err_typecheck_assign_const.cpp (original)
+++ cfe/trunk/test/SemaCXX/err_typecheck_assign_const.cpp Wed Aug 26 00:13:19 
2015
@@ -122,3 +122,10 @@ void test12(H h) {
   h.a = 1;  // expected-error {{cannot assign to non-static data member 'a' 
with const-qualified type 'const int'}}
   h.b = 2;  // expected-error {{cannot assign to non-static data member 'b' 
with const-qualified type 'const int &'}}
 }
+
+void test() {
+  typedef const int &Func();
+
+  Func &bar();
+  bar()() = 0; // expected-error {{read-only variable is not assignable}}
+}


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D12354: [libcxx] Add global assertion handler for debug mode.

2015-08-25 Thread Eric Fiselier via cfe-commits
EricWF updated this revision to Diff 33179.
EricWF added a comment.

Remove all functions in the dylib and make them inline.


http://reviews.llvm.org/D12354

Files:
  include/__debug
  include/algorithm
  include/regex
  src/debug.cpp
  test/libcxx/algorithms/debug_less.pass.cpp
  test/support/debug_mode.h

Index: test/support/debug_mode.h
===
--- /dev/null
+++ test/support/debug_mode.h
@@ -0,0 +1,34 @@
+#ifndef SUPPORT_DEBUG_MODE_H
+#define SUPPORT_DEBUG_MODE_H
+
+#ifndef _LIBCPP_DEBUG
+#error _LIBCPP_DEBUG must be defined before including the header
+#endif
+#ifdef _LIBCPP_CONFIG
+#error debug_mode.h must be included before any libc++ files
+#endif
+
+#include <__debug>
+#include 
+
+typedef std::__debug_assertion_handler_t DebugHandlerT;
+typedef std::__debug_assertion_info DebugInfo;
+
+inline DebugHandlerT getDebugHandler(DebugHandlerT new_h = nullptr) {
+return std::__debug_assertion_handler(new_h);
+}
+
+void exitZeroHandler(DebugInfo const&) {
+std::exit(0);
+}
+
+struct DebugException {
+DebugInfo info;
+DebugException(DebugInfo xinfo) : info(xinfo) {}
+};
+
+inline void throwingDebugHandler(DebugInfo const& info) {
+throw DebugException(info);
+}
+
+#endif // SUPPORT_DEBUG_MODE_H
Index: test/libcxx/algorithms/debug_less.pass.cpp
===
--- /dev/null
+++ test/libcxx/algorithms/debug_less.pass.cpp
@@ -0,0 +1,164 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// 
+
+// template  struct __debug_less
+
+// __debug_less checks that a comparator actually provides a strict-weak ordering.
+
+#define _LIBCPP_DEBUG 0
+#include "debug_mode.h"
+
+#include 
+#include 
+
+template 
+struct MyType {
+int value;
+explicit MyType(int xvalue = 0) : value(xvalue) {}
+};
+
+template 
+bool operator<(MyType const& LHS, MyType const& RHS) {
+return LHS.value < RHS.value;
+}
+
+struct CompareBase {
+static int called;
+static void reset() {
+called = 0;
+}
+};
+
+int CompareBase::called = 0;
+
+template 
+struct GoodComparator : public CompareBase {
+bool operator()(ValueType const& lhs, ValueType const& rhs) const {
+++CompareBase::called;
+return lhs < rhs;
+}
+};
+
+template 
+struct BadComparator : public CompareBase {
+bool operator()(ValueType const&, ValueType const&) const {
+++CompareBase::called;
+return true;
+}
+};
+
+template 
+struct TwoWayHomoComparator : public CompareBase {
+bool operator()(T1 const& lhs, T2 const& rhs) const {
+++CompareBase::called;
+return lhs < rhs;
+}
+
+bool operator()(T2 const& lhs, T1 const& rhs) const {
+++CompareBase::called;
+return lhs < rhs;
+}
+};
+
+template 
+struct OneWayHomoComparator : public CompareBase {
+bool operator()(T1 const& lhs, T2 const& rhs) const {
+++CompareBase::called;
+return lhs < rhs;
+}
+};
+
+using std::__debug_less;
+
+typedef MyType<0> MT0;
+typedef MyType<1> MT1;
+
+void test_passing() {
+int& called = CompareBase::called;
+called = 0;
+MT0 one(1);
+MT0 two(2);
+MT1 three(3);
+MT1 four(4);
+
+{
+typedef GoodComparator C;
+typedef __debug_less D;
+
+C c;
+D d(c);
+
+assert(d(one, two) == true);
+assert(called == 2);
+called = 0;
+
+assert(d(one, one) == false);
+assert(called == 1);
+called = 0;
+
+assert(d(two, one) == false);
+assert(called == 1);
+called = 0;
+}
+{
+typedef TwoWayHomoComparator C;
+typedef __debug_less D;
+C c;
+D d(c);
+
+assert(d(one, three) == true);
+assert(called == 2);
+called = 0;
+
+assert(d(three, one) == false);
+assert(called == 1);
+called = 0;
+}
+{
+typedef OneWayHomoComparator C;
+typedef __debug_less D;
+C c;
+D d(c);
+
+assert(d(one, three) == true);
+assert(called == 1);
+called = 0;
+}
+}
+
+void test_failing() {
+int& called = CompareBase::called;
+called = 0;
+MT0 one(1);
+MT0 two(2);
+
+{
+typedef BadComparator C;
+typedef __debug_less D;
+C c;
+D d(c);
+
+try {
+d(one, two);
+assert(false);
+} catch (DebugException const&) {
+}
+
+assert(called == 2);
+called = 0;
+}
+}
+
+int main() {
+getDebugHandler(&throwingDebugHandler);
+test_passing();
+test_failing();
+}
\ No newline at end o

Re: [PATCH] D12354: [libcxx] Add global assertion handler for debug mode.

2015-08-25 Thread Eric Fiselier via cfe-commits
EricWF updated this revision to Diff 33180.
EricWF added a comment.

Cleanup the diff and remove extra changes.


http://reviews.llvm.org/D12354

Files:
  include/__debug
  include/algorithm
  test/libcxx/algorithms/debug_less.pass.cpp
  test/support/debug_mode.h

Index: test/support/debug_mode.h
===
--- /dev/null
+++ test/support/debug_mode.h
@@ -0,0 +1,34 @@
+#ifndef SUPPORT_DEBUG_MODE_H
+#define SUPPORT_DEBUG_MODE_H
+
+#ifndef _LIBCPP_DEBUG
+#error _LIBCPP_DEBUG must be defined before including the header
+#endif
+#ifdef _LIBCPP_CONFIG
+#error debug_mode.h must be included before any libc++ files
+#endif
+
+#include <__debug>
+#include 
+
+typedef std::__debug_assertion_handler_t DebugHandlerT;
+typedef std::__debug_assertion_info DebugInfo;
+
+inline DebugHandlerT getDebugHandler(DebugHandlerT new_h = nullptr) {
+return std::__debug_assertion_handler(new_h);
+}
+
+void exitZeroHandler(DebugInfo const&) {
+std::exit(0);
+}
+
+struct DebugException {
+DebugInfo info;
+DebugException(DebugInfo xinfo) : info(xinfo) {}
+};
+
+inline void throwingDebugHandler(DebugInfo const& info) {
+throw DebugException(info);
+}
+
+#endif // SUPPORT_DEBUG_MODE_H
Index: test/libcxx/algorithms/debug_less.pass.cpp
===
--- /dev/null
+++ test/libcxx/algorithms/debug_less.pass.cpp
@@ -0,0 +1,164 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// 
+
+// template  struct __debug_less
+
+// __debug_less checks that a comparator actually provides a strict-weak ordering.
+
+#define _LIBCPP_DEBUG 0
+#include "debug_mode.h"
+
+#include 
+#include 
+
+template 
+struct MyType {
+int value;
+explicit MyType(int xvalue = 0) : value(xvalue) {}
+};
+
+template 
+bool operator<(MyType const& LHS, MyType const& RHS) {
+return LHS.value < RHS.value;
+}
+
+struct CompareBase {
+static int called;
+static void reset() {
+called = 0;
+}
+};
+
+int CompareBase::called = 0;
+
+template 
+struct GoodComparator : public CompareBase {
+bool operator()(ValueType const& lhs, ValueType const& rhs) const {
+++CompareBase::called;
+return lhs < rhs;
+}
+};
+
+template 
+struct BadComparator : public CompareBase {
+bool operator()(ValueType const&, ValueType const&) const {
+++CompareBase::called;
+return true;
+}
+};
+
+template 
+struct TwoWayHomoComparator : public CompareBase {
+bool operator()(T1 const& lhs, T2 const& rhs) const {
+++CompareBase::called;
+return lhs < rhs;
+}
+
+bool operator()(T2 const& lhs, T1 const& rhs) const {
+++CompareBase::called;
+return lhs < rhs;
+}
+};
+
+template 
+struct OneWayHomoComparator : public CompareBase {
+bool operator()(T1 const& lhs, T2 const& rhs) const {
+++CompareBase::called;
+return lhs < rhs;
+}
+};
+
+using std::__debug_less;
+
+typedef MyType<0> MT0;
+typedef MyType<1> MT1;
+
+void test_passing() {
+int& called = CompareBase::called;
+called = 0;
+MT0 one(1);
+MT0 two(2);
+MT1 three(3);
+MT1 four(4);
+
+{
+typedef GoodComparator C;
+typedef __debug_less D;
+
+C c;
+D d(c);
+
+assert(d(one, two) == true);
+assert(called == 2);
+called = 0;
+
+assert(d(one, one) == false);
+assert(called == 1);
+called = 0;
+
+assert(d(two, one) == false);
+assert(called == 1);
+called = 0;
+}
+{
+typedef TwoWayHomoComparator C;
+typedef __debug_less D;
+C c;
+D d(c);
+
+assert(d(one, three) == true);
+assert(called == 2);
+called = 0;
+
+assert(d(three, one) == false);
+assert(called == 1);
+called = 0;
+}
+{
+typedef OneWayHomoComparator C;
+typedef __debug_less D;
+C c;
+D d(c);
+
+assert(d(one, three) == true);
+assert(called == 1);
+called = 0;
+}
+}
+
+void test_failing() {
+int& called = CompareBase::called;
+called = 0;
+MT0 one(1);
+MT0 two(2);
+
+{
+typedef BadComparator C;
+typedef __debug_less D;
+C c;
+D d(c);
+
+try {
+d(one, two);
+assert(false);
+} catch (DebugException const&) {
+}
+
+assert(called == 2);
+called = 0;
+}
+}
+
+int main() {
+getDebugHandler(&throwingDebugHandler);
+test_passing();
+test_failing();
+}
\ No newline at end of file
Index: include/algorithm
=

  1   2   >