r271368 - [Clang][Intrinsics][avx512] Adding round roundscale to clang

2016-06-01 Thread Michael Zuckerman via cfe-commits
Author: mzuckerm
Date: Wed Jun  1 02:35:44 2016
New Revision: 271368

URL: http://llvm.org/viewvc/llvm-project?rev=271368&view=rev
Log:
[Clang][Intrinsics][avx512] Adding round roundscale to clang

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

Modified:
cfe/trunk/lib/Headers/avx512fintrin.h
cfe/trunk/test/CodeGen/avx512f-builtins.c

Modified: cfe/trunk/lib/Headers/avx512fintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512fintrin.h?rev=271368&r1=271367&r2=271368&view=diff
==
--- cfe/trunk/lib/Headers/avx512fintrin.h (original)
+++ cfe/trunk/lib/Headers/avx512fintrin.h Wed Jun  1 02:35:44 2016
@@ -2382,6 +2382,24 @@ _mm512_maskz_div_ps(__mmask16 __U, __m51
  (__mmask16)(A), \
  _MM_FROUND_CUR_DIRECTION); })
 
+#define _mm512_mask_roundscale_round_ps( __A, __B, __C, __imm, __R) 
__extension__ ({ \
+  (__m512)__builtin_ia32_rndscaleps_mask ((__v16sf)( __C), (int)__imm,\
+  (__v16sf)( __A),\
+  (__mmask16)( __B),(int) __R);\
+})
+
+#define _mm512_maskz_roundscale_round_ps( __A, __B, __imm,__R) __extension__ 
({ \
+  (__m512)__builtin_ia32_rndscaleps_mask ((__v16sf)( __B), (int)__imm,\
+  (__v16sf)_mm512_setzero_ps (),\
+  (__mmask16)( __A),(int) __R);\
+})
+
+#define _mm512_roundscale_round_ps( __A, __imm, __R) __extension__ ({ \
+  (__m512)__builtin_ia32_rndscaleps_mask ((__v16sf)( __A),(int) __imm,\
+  (__v16sf) _mm512_undefined_ps (),\
+  (__mmask16) -1,(int) __R);\
+})
+
 #define _mm512_roundscale_pd(A, B) __extension__ ({ \
   (__m512d)__builtin_ia32_rndscalepd_mask((__v8df)(__m512d)(A), (int)(B), \
   (__v8df)(__m512d)(A), (__mmask8)-1, \
@@ -2398,6 +2416,24 @@ _mm512_maskz_div_ps(__mmask16 __U, __m51
   (__mmask8)(A), \
   _MM_FROUND_CUR_DIRECTION); })
 
+#define _mm512_mask_roundscale_round_pd( __A, __B, __C, __imm ,__R) 
__extension__ ({ \
+  (__m512d)__builtin_ia32_rndscalepd_mask ((__v8df)( __C),(int)__imm,\
+   (__v8df)( __A),\
+   (__mmask8)( __B),(int)__R);\
+})
+
+#define _mm512_maskz_roundscale_round_pd( __A, __B, __imm, __R) __extension__ 
({ \
+  (__m512d)__builtin_ia32_rndscalepd_mask ((__v8df)( __B),(int)__imm,\
+(__v8df)_mm512_setzero_pd (),\
+(__mmask8)( __A),(int) __R);\
+})
+
+#define _mm512_roundscale_round_pd( __A, __imm , __R) __extension__ ({ \
+  (__m512d)__builtin_ia32_rndscalepd_mask ((__v8df)( __A),(int) __imm,\
+(__v8df)_mm512_undefined_pd (),\
+(__mmask8) -1,(int) __R);\
+})
+
 #define _mm512_fmadd_round_pd(A, B, C, R) __extension__ ({ \
   (__m512d)__builtin_ia32_vfmaddpd512_mask((__v8df)(__m512d)(A), \
(__v8df)(__m512d)(B), \

Modified: cfe/trunk/test/CodeGen/avx512f-builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/avx512f-builtins.c?rev=271368&r1=271367&r2=271368&view=diff
==
--- cfe/trunk/test/CodeGen/avx512f-builtins.c (original)
+++ cfe/trunk/test/CodeGen/avx512f-builtins.c Wed Jun  1 02:35:44 2016
@@ -6653,6 +6653,27 @@ __m512 test_mm512_maskz_roundscale_ps(__
   return _mm512_maskz_roundscale_ps(__U,__A, 1);
 }
 
+__m512 test_mm512_mask_roundscale_round_ps(__m512 __A,__mmask16 __U,__m512 __C)
+{
+  // CHECK-LABEL: @test_mm512_mask_roundscale_round_ps
+  // CHECK: @llvm.x86.avx512.mask.rndscale.ps.512
+  return 
_mm512_mask_roundscale_round_ps(__A,__U,__C,3,_MM_FROUND_CUR_DIRECTION);
+}
+
+__m512 test_mm512_maskz_roundscale_round_ps(__m512 __A,__mmask16 __U) 
+{
+  // CHECK-LABEL: @test_mm512_maskz_roundscale_round_ps
+  // CHECK: @llvm.x86.avx512.mask.rndscale.ps.512
+  return _mm512_maskz_roundscale_round_ps(__U,__A,3,_MM_FROUND_CUR_DIRECTION);
+}
+
+__m512 test_mm512_roundscale_round_ps(__m512 __A)
+{
+  // CHECK-LABEL: @test_mm512_roundscale_round_ps
+  // CHECK: @llvm.x86.avx512.mask.rndscale.ps.512
+  return _mm512_roundscale_round_ps(__A,3,_MM_FROUND_CUR_DIRECTION);
+}
+
 __m512d test_mm512_mask_roundscale_pd(__m512d __W, __mmask8 __U, __m512d __A) 
 {
   // CHECK-LABEL: @test_mm512_mask_roundscale_pd
@@ -6667,6 +6688,27 @@ __m512d test_mm512_maskz_roundscale_pd(_
   return _mm512_maskz_roundscale_pd(__U,__A, 1);
 }
 
+__m512d test_mm512_mask_roundscale_round_pd(__m512d __A,__mmask8 __U,__m512d 
__C)
+{
+  // CHECK-LAB

Re: [PATCH] D20815: [Clang][Intrinsics][avx512] Adding round roundscale to clang

2016-06-01 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL271368: [Clang][Intrinsics][avx512] Adding round roundscale 
to clang (authored by mzuckerm).

Changed prior to commit:
  http://reviews.llvm.org/D20815?vs=59064&id=59175#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D20815

Files:
  cfe/trunk/lib/Headers/avx512fintrin.h
  cfe/trunk/test/CodeGen/avx512f-builtins.c

Index: cfe/trunk/test/CodeGen/avx512f-builtins.c
===
--- cfe/trunk/test/CodeGen/avx512f-builtins.c
+++ cfe/trunk/test/CodeGen/avx512f-builtins.c
@@ -6653,6 +6653,27 @@
   return _mm512_maskz_roundscale_ps(__U,__A, 1);
 }
 
+__m512 test_mm512_mask_roundscale_round_ps(__m512 __A,__mmask16 __U,__m512 __C)
+{
+  // CHECK-LABEL: @test_mm512_mask_roundscale_round_ps
+  // CHECK: @llvm.x86.avx512.mask.rndscale.ps.512
+  return _mm512_mask_roundscale_round_ps(__A,__U,__C,3,_MM_FROUND_CUR_DIRECTION);
+}
+
+__m512 test_mm512_maskz_roundscale_round_ps(__m512 __A,__mmask16 __U) 
+{
+  // CHECK-LABEL: @test_mm512_maskz_roundscale_round_ps
+  // CHECK: @llvm.x86.avx512.mask.rndscale.ps.512
+  return _mm512_maskz_roundscale_round_ps(__U,__A,3,_MM_FROUND_CUR_DIRECTION);
+}
+
+__m512 test_mm512_roundscale_round_ps(__m512 __A)
+{
+  // CHECK-LABEL: @test_mm512_roundscale_round_ps
+  // CHECK: @llvm.x86.avx512.mask.rndscale.ps.512
+  return _mm512_roundscale_round_ps(__A,3,_MM_FROUND_CUR_DIRECTION);
+}
+
 __m512d test_mm512_mask_roundscale_pd(__m512d __W, __mmask8 __U, __m512d __A) 
 {
   // CHECK-LABEL: @test_mm512_mask_roundscale_pd
@@ -6667,6 +6688,27 @@
   return _mm512_maskz_roundscale_pd(__U,__A, 1);
 }
 
+__m512d test_mm512_mask_roundscale_round_pd(__m512d __A,__mmask8 __U,__m512d __C)
+{
+  // CHECK-LABEL: @test_mm512_mask_roundscale_round_pd
+  // CHECK: @llvm.x86.avx512.mask.rndscale.pd.512
+  return _mm512_mask_roundscale_round_pd(__A,__U,__C,3,_MM_FROUND_CUR_DIRECTION);
+}
+
+__m512d test_mm512_maskz_roundscale_round_pd(__m512d __A,__mmask8 __U)
+{
+  // CHECK-LABEL: @test_mm512_maskz_roundscale_round_pd
+  // CHECK: @llvm.x86.avx512.mask.rndscale.pd.512
+  return _mm512_maskz_roundscale_round_pd(__U,__A,3,_MM_FROUND_CUR_DIRECTION);
+}
+
+__m512d test_mm512_roundscale_round_pd(__m512d __A)
+{
+  // CHECK-LABEL: @test_mm512_roundscale_round_pd
+  // CHECK: @llvm.x86.avx512.mask.rndscale.pd.512
+  return _mm512_roundscale_round_pd(__A,3,_MM_FROUND_CUR_DIRECTION);
+}
+
 __m512i test_mm512_mask_max_epi32 (__m512i __W, __mmask16 __M, __m512i __A, __m512i __B)
 {
   // CHECK-LABEL: @test_mm512_mask_max_epi32 
Index: cfe/trunk/lib/Headers/avx512fintrin.h
===
--- cfe/trunk/lib/Headers/avx512fintrin.h
+++ cfe/trunk/lib/Headers/avx512fintrin.h
@@ -2382,6 +2382,24 @@
  (__mmask16)(A), \
  _MM_FROUND_CUR_DIRECTION); })
 
+#define _mm512_mask_roundscale_round_ps( __A, __B, __C, __imm, __R) __extension__ ({ \
+  (__m512)__builtin_ia32_rndscaleps_mask ((__v16sf)( __C), (int)__imm,\
+  (__v16sf)( __A),\
+  (__mmask16)( __B),(int) __R);\
+})
+
+#define _mm512_maskz_roundscale_round_ps( __A, __B, __imm,__R) __extension__ ({ \
+  (__m512)__builtin_ia32_rndscaleps_mask ((__v16sf)( __B), (int)__imm,\
+  (__v16sf)_mm512_setzero_ps (),\
+  (__mmask16)( __A),(int) __R);\
+})
+
+#define _mm512_roundscale_round_ps( __A, __imm, __R) __extension__ ({ \
+  (__m512)__builtin_ia32_rndscaleps_mask ((__v16sf)( __A),(int) __imm,\
+  (__v16sf) _mm512_undefined_ps (),\
+  (__mmask16) -1,(int) __R);\
+})
+
 #define _mm512_roundscale_pd(A, B) __extension__ ({ \
   (__m512d)__builtin_ia32_rndscalepd_mask((__v8df)(__m512d)(A), (int)(B), \
   (__v8df)(__m512d)(A), (__mmask8)-1, \
@@ -2398,6 +2416,24 @@
   (__mmask8)(A), \
   _MM_FROUND_CUR_DIRECTION); })
 
+#define _mm512_mask_roundscale_round_pd( __A, __B, __C, __imm ,__R) __extension__ ({ \
+  (__m512d)__builtin_ia32_rndscalepd_mask ((__v8df)( __C),(int)__imm,\
+   (__v8df)( __A),\
+   (__mmask8)( __B),(int)__R);\
+})
+
+#define _mm512_maskz_roundscale_round_pd( __A, __B, __imm, __R) __extension__ ({ \
+  (__m512d)__builtin_ia32_rndscalepd_mask ((__v8df)( __B),(int)__imm,\
+(__v8df)_mm512_setzero_pd (),\
+(__mmask8)( __A),(int) __R);\
+})
+
+#define _mm512_roundscale_round_pd( __A, __imm , __R) __extension__ ({ \
+  (__m512d)__builtin_ia32_rndscalepd_mask ((__v8df)( __A),

Re: [PATCH] D20359: [LLVM][AVX512][Intrinsics] Convert AVX non-temporal store builtins to LLVM-native IR.

2016-06-01 Thread Craig Topper via cfe-commits
craig.topper accepted this revision.
craig.topper added a comment.
This revision is now accepted and ready to land.

LGTM


http://reviews.llvm.org/D20359



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


Re: [PATCH] D20359: [LLVM][AVX512][Intrinsics] Convert AVX non-temporal store builtins to LLVM-native IR.

2016-06-01 Thread Craig Topper via cfe-commits
craig.topper requested changes to this revision.
craig.topper added a comment.
This revision now requires changes to proceed.

Actually can you add autoupgrade support?


http://reviews.llvm.org/D20359



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


Re: [PATCH] D20561: Warn when taking address of packed member

2016-06-01 Thread Roger Ferrer Ibanez via cfe-commits
rogfer01 updated this revision to Diff 59178.
rogfer01 marked an inline comment as done.
rogfer01 added a comment.

Do not warn if the alignment of the type of the field is already 1 as packed 
does not have any effect on those fields.


http://reviews.llvm.org/D20561

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaExpr.cpp
  test/Sema/address-packed.c
  test/SemaCXX/address-packed.cpp

Index: test/SemaCXX/address-packed.cpp
===
--- /dev/null
+++ test/SemaCXX/address-packed.cpp
@@ -0,0 +1,77 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+extern void f1(int *);
+extern void f2(char *);
+
+struct __attribute__((packed)) Arguable {
+  int x;
+  char c;
+  static void foo();
+};
+
+extern void f3(void());
+
+typedef struct Arguable ArguableT;
+
+namespace Foo {
+struct __attribute__((packed)) Arguable {
+  char c;
+  int x;
+  static void foo();
+};
+}
+
+struct Arguable *get_arguable();
+
+void g0() {
+  {
+Foo::Arguable arguable;
+f1(&arguable.x);   // expected-warning {{packed member 'x' of class or structure 'Foo::Arguable'}}
+f2(&arguable.c);   // no-warning
+f3(&arguable.foo); // no-warning
+  }
+  {
+Arguable arguable1;
+Arguable &arguable(arguable1);
+f1(&arguable.x);   // expected-warning {{packed member 'x' of class or structure 'Arguable'}}
+f2(&arguable.c);   // no-warning
+f3(&arguable.foo); // no-warning
+  }
+  {
+Arguable *arguable1;
+Arguable *&arguable(arguable1);
+f1(&arguable->x);   // expected-warning {{packed member 'x' of class or structure 'Arguable'}}
+f2(&arguable->c);   // no-warning
+f3(&arguable->foo); // no-warning
+  }
+}
+
+struct __attribute__((packed)) A {
+  int x;
+  char c;
+
+  int *f0() {
+return &this->x; // expected-warning {{packed member 'x' of class or structure 'A'}}
+  }
+
+  int *g0() {
+return &x; // expected-warning {{packed member 'x' of class or structure 'A'}}
+  }
+
+  char *h0() {
+return &c; // no-warning
+  }
+};
+
+struct B : A {
+  int *f1() {
+return &this->x; // expected-warning {{packed member 'x' of class or structure 'A'}}
+  }
+
+  int *g1() {
+return &x; // expected-warning {{packed member 'x' of class or structure 'A'}}
+  }
+
+  char *h1() {
+return &c; // no-warning
+  }
+};
Index: test/Sema/address-packed.c
===
--- /dev/null
+++ test/Sema/address-packed.c
@@ -0,0 +1,126 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+extern void f1(int *);
+extern void f2(char *);
+
+struct Ok {
+  char c;
+  int x;
+};
+
+struct __attribute__((packed)) Arguable {
+  char c0;
+  int x;
+  char c1;
+};
+
+union __attribute__((packed)) UnionArguable {
+  char c;
+  int x;
+};
+
+extern void f3(void());
+
+typedef struct Arguable ArguableT;
+
+struct Arguable *get_arguable();
+
+void g0() {
+  {
+struct Ok ok;
+f1(&ok.x); // no-warning
+f2(&ok.c); // no-warning
+  }
+  {
+struct Arguable arguable;
+f2(&arguable.c0); // no-warning
+f1(&arguable.x);  // expected-warning {{packed member 'x' of class or structure 'Arguable'}}
+f2(&arguable.c1); // no-warning
+  }
+  {
+union UnionArguable arguable;
+f2(&arguable.c); // no-warning
+f1(&arguable.x); // expected-warning {{packed member 'x' of class or structure 'UnionArguable'}}
+  }
+  {
+ArguableT arguable;
+f2(&arguable.c0); // no-warning
+f1(&arguable.x);  // expected-warning {{packed member 'x' of class or structure }}
+f2(&arguable.c1); // no-warning
+  }
+  {
+struct Arguable *arguable = get_arguable();
+f2(&(arguable->c0)); // no-warning
+f1(&(arguable->x));  // no-warning
+f2(&(arguable->c1)); // no-warning
+  }
+  {
+ArguableT *arguable = get_arguable();
+f2(&(arguable->c0)); // no-warning
+f1(&(arguable->x));  // no-warning
+f2(&(arguable->c1)); // no-warning
+  }
+}
+
+struct S1 {
+  char c;
+  int i __attribute__((packed));
+};
+
+int *g1(struct S1 *s1) {
+  return &s1->i; // expected-warning {{packed member 'i' of class or structure 'S1'}}
+}
+
+struct S2_i {
+  int i;
+};
+struct __attribute__((packed)) S2 {
+  char c;
+  struct S2_i inner;
+};
+
+int *g2(struct S2 *s2) {
+  return &s2->inner.i; // expected-warning {{packed member 'inner' of class or structure 'S2'}}
+}
+
+struct S2_a {
+  char c;
+  struct S2_i inner __attribute__((packed));
+};
+
+int *g2_a(struct S2_a *s2_a) {
+  return &s2_a->inner.i; // expected-warning {{packed member 'inner' of class or structure 'S2_a'}}
+}
+
+struct __attribute__((packed)) S3 {
+  char c;
+  struct {
+int i;
+  } inner;
+};
+
+int *g3(struct S3 *s3) {
+  return &s3->inner.i; // expected-warning {{packed member 'inner' of class or structure 'S3'}}
+}
+
+struct S4 {
+  char c;
+  struct __attribute__((packed)) {
+int i;
+  } inner;
+};
+
+int *g4(struct S4 *s4) {
+  return &s4->inner.i; // expected-warning {{packed member 'i' of class or struc

Re: [PATCH] D20561: Warn when taking address of packed member

2016-06-01 Thread Roger Ferrer Ibanez via cfe-commits
rogfer01 marked an inline comment as done.
rogfer01 added a comment.

http://reviews.llvm.org/D20561



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


r271373 - [Clang][Intrinsics][avx512] Adding round intrinsics fot max/min/sqrt instruction set to clang

2016-06-01 Thread Michael Zuckerman via cfe-commits
Author: mzuckerm
Date: Wed Jun  1 03:34:03 2016
New Revision: 271373

URL: http://llvm.org/viewvc/llvm-project?rev=271373&view=rev
Log:
[Clang][Intrinsics][avx512] Adding round intrinsics fot max/min/sqrt 
instruction set to clang

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

Modified:
cfe/trunk/lib/Headers/avx512fintrin.h
cfe/trunk/test/CodeGen/avx512f-builtins.c

Modified: cfe/trunk/lib/Headers/avx512fintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512fintrin.h?rev=271373&r1=271372&r2=271373&view=diff
==
--- cfe/trunk/lib/Headers/avx512fintrin.h (original)
+++ cfe/trunk/lib/Headers/avx512fintrin.h Wed Jun  1 03:34:03 2016
@@ -813,6 +813,29 @@ _mm512_maskz_sub_epi32 (__mmask16 __U, _
  (__mmask16) __U);
 }
 
+#define _mm512_mask_max_round_pd( __W, __U, __A, __B, __R) __extension__ ({ \
+__builtin_ia32_maxpd512_mask ((__v8df)( __A),\
+(__v8df)( __B),\
+(__v8df)( __W),\
+(__mmask8)( __U),( __R));\
+})
+
+#define _mm512_maskz_max_round_pd( __U, __A, __B, __R) __extension__ ({ \
+__builtin_ia32_maxpd512_mask ((__v8df)( __A),\
+(__v8df)( __B),\
+(__v8df)\
+_mm512_setzero_pd (),\
+(__mmask8)( __U),( __R));\
+})
+
+#define _mm512_max_round_pd( __A, __B, __R) __extension__ ({ \
+__builtin_ia32_maxpd512_mask ((__v8df)( __A),\
+(__v8df)( __B),\
+(__v8df)\
+_mm512_undefined_pd (),\
+(__mmask8) -1,( __R));\
+})
+
 static  __inline__ __m512d __DEFAULT_FN_ATTRS
 _mm512_max_pd(__m512d __A, __m512d __B)
 {
@@ -845,6 +868,29 @@ _mm512_maskz_max_pd (__mmask8 __U, __m51
   _MM_FROUND_CUR_DIRECTION);
 }
 
+#define _mm512_mask_max_round_ps( __W, __U, __A, __B, __R) __extension__ ({ \
+__builtin_ia32_maxps512_mask ((__v16sf)( __A),\
+   (__v16sf)( __B),\
+   (__v16sf)( __W),\
+   (__mmask16)( __U),( __R));\
+})
+
+#define _mm512_maskz_max_round_ps( __U, __A, __B, __R) __extension__ ({ \
+__builtin_ia32_maxps512_mask ((__v16sf)( __A),\
+   (__v16sf)( __B),\
+   (__v16sf)\
+   _mm512_setzero_ps (),\
+   (__mmask16)( __U),( __R));\
+})
+
+#define _mm512_max_round_ps( __A, __B, __R) __extension__ ({ \
+__builtin_ia32_maxps512_mask ((__v16sf)( __A),\
+   (__v16sf)( __B),\
+   (__v16sf)\
+   _mm512_undefined_ps (),\
+   (__mmask16) -1,( __R));\
+})
+
 static  __inline__ __m512 __DEFAULT_FN_ATTRS
 _mm512_max_ps(__m512 __A, __m512 __B)
 {
@@ -1062,6 +1108,29 @@ _mm512_maskz_max_epu64 (__mmask8 __M, __
__M);
 }
 
+#define _mm512_mask_min_round_pd( __W, __U, __A, __B, __R) __extension__ ({ \
+__builtin_ia32_minpd512_mask ((__v8df)( __A),\
+(__v8df)( __B),\
+(__v8df)( __W),\
+(__mmask8)( __U),( __R));\
+})
+
+#define _mm512_maskz_min_round_pd( __U, __A, __B, __R) __extension__ ({ \
+__builtin_ia32_minpd512_mask ((__v8df)( __A),\
+(__v8df)( __B),\
+(__v8df)\
+_mm512_setzero_pd (),\
+(__mmask8)( __U),( __R));\
+})
+
+#define _mm512_min_round_pd( __A, __B, __R) __extension__ ({ \
+__builtin_ia32_minpd512_mask ((__v8df)( __A),\
+(__v8df)( __B),\
+(__v8df)\
+_mm512_undefined_pd (),\
+(__mmask8) -1,( __R));\
+})
+
 static  __inline__ __m512d __DEFAULT_FN_ATTRS
 _mm512_min_pd(__m512d __A, __m512d __B)
 {
@@ -1083,6 +1152,29 @@ _mm512_mask_min_pd (__m512d __W, __mmask
   _MM_FROUND_CUR_DIRECTION);
 }
 
+#define _mm512_mask_min_round_ps( __W, __U, __A, __B, __R) __extension__ ({ \
+__builtin_ia32_minps512_mask ((__v16sf)( __A),\
+   (__v16sf)( __B),\
+   (__v16sf)( __W),\
+   (__mmask16)( __U),( __R));\
+})
+
+#define _mm512_maskz_min_round_ps( __U, __A, __B, __R) __extension__ ({ \
+__builtin_ia32_minps512_mask ((__v16sf)( __A),\
+   (__v16sf)( __B),\
+   (__v16sf)\
+   _mm512_setzero_ps (),\
+   (__mmask16)( __U),( __R));\
+})
+
+#define _mm512_min_round_ps( __A, __B, __R) __extension__ ({ \
+__builtin_ia32_minps512_mask ((__v16sf)( __A),\
+   (__v16sf)( __B),\
+   (__v16sf)\
+   _mm512_undefined_ps (),\
+   (__mmask16) -1,( __R));\
+})
+
 static __inline__ __m512d __DEFAULT_FN_ATTRS
 _mm512_maskz_min_pd (__mmask8 __U, __m512d __A, __m512d __B)
 {
@@ -1391,6 +1483,26 @@ _mm512_mask_mullo_epi32 (__m512i __W, __
   (__v16si) __W, __M);
 }
 
+#define _mm512_mask_sqrt_round_pd( __W, __U, __A, __R) __extension__ ({ \
+__builtin_ia32_sqrtpd512_mask ((__v8df)( __A),\
+ (__v8df)( __W),\
+ (__mmask8)( __U),( __R));\
+})
+
+#define _mm512_maskz_sqrt_round_pd( __U, __A, __R) __extension__ ({ \
+__builtin_ia32_sqrtpd512_mask ((__v8df)( __A),\
+ (__v8df)\
+ _mm512_setzero_pd (),\
+   

Re: [PATCH] D20827: [include-fixer] Use YAML format in -output-headers and -insert-header mode.

2016-06-01 Thread Haojian Wu via cfe-commits
hokein updated this revision to Diff 59183.
hokein added a comment.

Get rid of yaml dependency, using json module.


http://reviews.llvm.org/D20827

Files:
  include-fixer/IncludeFixer.cpp
  include-fixer/IncludeFixerContext.h
  include-fixer/tool/ClangIncludeFixer.cpp
  include-fixer/tool/clang-include-fixer.py
  test/include-fixer/commandline_options.cpp
  test/include-fixer/ranking.cpp

Index: test/include-fixer/ranking.cpp
===
--- test/include-fixer/ranking.cpp
+++ test/include-fixer/ranking.cpp
@@ -1,6 +1,5 @@
-// RUN: clang-include-fixer -db=yaml -input=%S/Inputs/fake_yaml_db.yaml -output-headers %s -- | FileCheck %s -implicit-check-not=.h
+// RUN: clang-include-fixer -db=yaml -input=%S/Inputs/fake_yaml_db.yaml -output-headers %s -- | FileCheck %s
 
-// CHECK: "../include/bar.h"
-// CHECK-NEXT: "../include/zbar.h"
+// CHECK: "Headers": [ "\"../include/bar.h\"", "\"../include/zbar.h\"" ]
 
 bar b;
Index: test/include-fixer/commandline_options.cpp
===
--- test/include-fixer/commandline_options.cpp
+++ test/include-fixer/commandline_options.cpp
@@ -1,10 +1,9 @@
 // REQUIRES: shell
 // RUN: sed -e 's#//.*$##' %s > %t.cpp
 // RUN: clang-include-fixer -db=fixed -input='foo= "foo.h","bar.h"' -output-headers %t.cpp -- | FileCheck %s -check-prefix=CHECK-HEADERS
-// RUN: cat %t.cpp | clang-include-fixer -stdin -insert-header='"foo.h"' %t.cpp | FileCheck %s -check-prefix=CHECK
+// RUN: cat %t.cpp | clang-include-fixer -stdin -insert-header='{SymbolIdentifier: foo, Headers: ["\"foo.h\""]}' %t.cpp | FileCheck %s -check-prefix=CHECK
 //
-// CHECK-HEADERS: "foo.h"
-// CHECK-HEADERS: "bar.h"
+// CHECK-HEADERS: "Headers": [ "\"foo.h\"", "\"bar.h\"" ]
 //
 // CHECK: #include "foo.h"
 // CHECK: foo f;
Index: include-fixer/tool/clang-include-fixer.py
===
--- include-fixer/tool/clang-include-fixer.py
+++ include-fixer/tool/clang-include-fixer.py
@@ -19,6 +19,7 @@
 import difflib
 import subprocess
 import vim
+import json
 
 # set g:clang_include_fixer_path to the path to clang-include-fixer if it is not
 # on the path.
@@ -49,7 +50,7 @@
 
 
 def InsertHeaderToVimBuffer(header, text):
-  command = [binary, "-stdin", "-insert-header="+header,
+  command = [binary, "-stdin", "-insert-header="+json.dumps(header),
  vim.current.buffer.name]
   stdout, stderr = execute(command, text)
   if stdout:
@@ -77,30 +78,38 @@
   command = [binary, "-stdin", "-output-headers", "-db="+args.db,
  "-input="+args.input, vim.current.buffer.name]
   stdout, stderr = execute(command, text)
-  lines = stdout.splitlines()
-  if len(lines) < 2:
-print "No header is included.\n"
+  include_fixer_context = json.loads(stdout)
+  symbol = include_fixer_context["SymbolIdentifier"]
+  headers = include_fixer_context["Headers"]
+
+  if not symbol:
+print "The file is fine, no need to add a header.\n"
+return;
+
+  if not headers:
+print "Couldn't find a header for {0}.\n".format(symbol)
 return
 
   # The first line is the symbol name.
-  symbol = lines[0]
   # If there is only one suggested header, insert it directly.
-  if len(lines) == 2 or maximum_suggested_headers == 1:
-InsertHeaderToVimBuffer(lines[1], text)
-print "Added #include {0} for {1}.\n".format(lines[1], symbol)
+  if len(headers) == 1 or maximum_suggested_headers == 1:
+InsertHeaderToVimBuffer({"SymbolIdentifier": symbol,
+ "Headers":[headers[0]]}, text)
+print "Added #include {0} for {1}.\n".format(headers[0], symbol)
 return
 
   choices_message = ""
   index = 1;
-  for header in lines[1:1+maximum_suggested_headers]:
+  for header in headers[0:maximum_suggested_headers]:
 choices_message += "&{0} {1}\n".format(index, header)
 index += 1
 
   select = ShowDialog("choose a header file for {0}.".format(symbol),
   choices_message)
   # Insert a selected header.
-  InsertHeaderToVimBuffer(lines[select], text)
-  print "Added #include {0} for {1}.\n".format(lines[select], symbol)
+  InsertHeaderToVimBuffer({"SymbolIdentifier": symbol,
+   "Headers":[headers[select-1]]}, text)
+  print "Added #include {0} for {1}.\n".format(headers[select-1], symbol)
   return;
 
 
Index: include-fixer/tool/ClangIncludeFixer.cpp
===
--- include-fixer/tool/ClangIncludeFixer.cpp
+++ include-fixer/tool/ClangIncludeFixer.cpp
@@ -18,9 +18,25 @@
 #include "clang/Tooling/CommonOptionsParser.h"
 #include "clang/Tooling/Tooling.h"
 #include "llvm/Support/CommandLine.h"
+#include "llvm/Support/YAMLTraits.h"
 
 using namespace clang;
 using namespace llvm;
+using clang::include_fixer::IncludeFixerContext;
+
+LLVM_YAML_IS_DOCUMENT_LIST_VECTOR(IncludeFixerContext)
+LLVM_YAML_IS_FLOW_SEQUENCE_VECTOR(std::string)
+
+namespace 

Re: [PATCH] D20827: [include-fixer] Use YAML format in -output-headers and -insert-header mode.

2016-06-01 Thread Haojian Wu via cfe-commits
hokein marked 2 inline comments as done.
hokein added a comment.

http://reviews.llvm.org/D20827



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


Re: [PATCH] D20827: [include-fixer] Use YAML format in -output-headers and -insert-header mode.

2016-06-01 Thread Haojian Wu via cfe-commits
hokein updated this revision to Diff 59184.
hokein added a comment.

Show error message when clang-include-fixer died with a fatal error.


http://reviews.llvm.org/D20827

Files:
  include-fixer/IncludeFixer.cpp
  include-fixer/IncludeFixerContext.h
  include-fixer/tool/ClangIncludeFixer.cpp
  include-fixer/tool/clang-include-fixer.py
  test/include-fixer/commandline_options.cpp
  test/include-fixer/ranking.cpp

Index: test/include-fixer/ranking.cpp
===
--- test/include-fixer/ranking.cpp
+++ test/include-fixer/ranking.cpp
@@ -1,6 +1,5 @@
-// RUN: clang-include-fixer -db=yaml -input=%S/Inputs/fake_yaml_db.yaml -output-headers %s -- | FileCheck %s -implicit-check-not=.h
+// RUN: clang-include-fixer -db=yaml -input=%S/Inputs/fake_yaml_db.yaml -output-headers %s -- | FileCheck %s
 
-// CHECK: "../include/bar.h"
-// CHECK-NEXT: "../include/zbar.h"
+// CHECK: "Headers": [ "\"../include/bar.h\"", "\"../include/zbar.h\"" ]
 
 bar b;
Index: test/include-fixer/commandline_options.cpp
===
--- test/include-fixer/commandline_options.cpp
+++ test/include-fixer/commandline_options.cpp
@@ -1,10 +1,9 @@
 // REQUIRES: shell
 // RUN: sed -e 's#//.*$##' %s > %t.cpp
 // RUN: clang-include-fixer -db=fixed -input='foo= "foo.h","bar.h"' -output-headers %t.cpp -- | FileCheck %s -check-prefix=CHECK-HEADERS
-// RUN: cat %t.cpp | clang-include-fixer -stdin -insert-header='"foo.h"' %t.cpp | FileCheck %s -check-prefix=CHECK
+// RUN: cat %t.cpp | clang-include-fixer -stdin -insert-header='{SymbolIdentifier: foo, Headers: ["\"foo.h\""]}' %t.cpp | FileCheck %s -check-prefix=CHECK
 //
-// CHECK-HEADERS: "foo.h"
-// CHECK-HEADERS: "bar.h"
+// CHECK-HEADERS: "Headers": [ "\"foo.h\"", "\"bar.h\"" ]
 //
 // CHECK: #include "foo.h"
 // CHECK: foo f;
Index: include-fixer/tool/clang-include-fixer.py
===
--- include-fixer/tool/clang-include-fixer.py
+++ include-fixer/tool/clang-include-fixer.py
@@ -19,6 +19,7 @@
 import difflib
 import subprocess
 import vim
+import json
 
 # set g:clang_include_fixer_path to the path to clang-include-fixer if it is not
 # on the path.
@@ -49,7 +50,7 @@
 
 
 def InsertHeaderToVimBuffer(header, text):
-  command = [binary, "-stdin", "-insert-header="+header,
+  command = [binary, "-stdin", "-insert-header="+json.dumps(header),
  vim.current.buffer.name]
   stdout, stderr = execute(command, text)
   if stdout:
@@ -77,30 +78,42 @@
   command = [binary, "-stdin", "-output-headers", "-db="+args.db,
  "-input="+args.input, vim.current.buffer.name]
   stdout, stderr = execute(command, text)
-  lines = stdout.splitlines()
-  if len(lines) < 2:
-print "No header is included.\n"
+  if stderr:
+print >> sys.stderr, "Error while running clang-include-fixer: " + stderr
+return
+
+  include_fixer_context = json.loads(stdout)
+  symbol = include_fixer_context["SymbolIdentifier"]
+  headers = include_fixer_context["Headers"]
+
+  if not symbol:
+print "The file is fine, no need to add a header.\n"
+return;
+
+  if not headers:
+print "Couldn't find a header for {0}.\n".format(symbol)
 return
 
   # The first line is the symbol name.
-  symbol = lines[0]
   # If there is only one suggested header, insert it directly.
-  if len(lines) == 2 or maximum_suggested_headers == 1:
-InsertHeaderToVimBuffer(lines[1], text)
-print "Added #include {0} for {1}.\n".format(lines[1], symbol)
+  if len(headers) == 1 or maximum_suggested_headers == 1:
+InsertHeaderToVimBuffer({"SymbolIdentifier": symbol,
+ "Headers":[headers[0]]}, text)
+print "Added #include {0} for {1}.\n".format(headers[0], symbol)
 return
 
   choices_message = ""
   index = 1;
-  for header in lines[1:1+maximum_suggested_headers]:
+  for header in headers[0:maximum_suggested_headers]:
 choices_message += "&{0} {1}\n".format(index, header)
 index += 1
 
   select = ShowDialog("choose a header file for {0}.".format(symbol),
   choices_message)
   # Insert a selected header.
-  InsertHeaderToVimBuffer(lines[select], text)
-  print "Added #include {0} for {1}.\n".format(lines[select], symbol)
+  InsertHeaderToVimBuffer({"SymbolIdentifier": symbol,
+   "Headers":[headers[select-1]]}, text)
+  print "Added #include {0} for {1}.\n".format(headers[select-1], symbol)
   return;
 
 
Index: include-fixer/tool/ClangIncludeFixer.cpp
===
--- include-fixer/tool/ClangIncludeFixer.cpp
+++ include-fixer/tool/ClangIncludeFixer.cpp
@@ -18,9 +18,25 @@
 #include "clang/Tooling/CommonOptionsParser.h"
 #include "clang/Tooling/Tooling.h"
 #include "llvm/Support/CommandLine.h"
+#include "llvm/Support/YAMLTraits.h"
 
 using namespace clang;
 using namespace llvm;
+using clang::include_fixer::IncludeFixe

Re: [PATCH] D20827: [include-fixer] Use YAML format in -output-headers and -insert-header mode.

2016-06-01 Thread Benjamin Kramer via cfe-commits
bkramer added inline comments.


Comment at: include-fixer/tool/ClangIncludeFixer.cpp:160
@@ +159,3 @@
+  for (const auto &Header : Context.Headers) {
+// Escape double quote.
+if (Header.front() == '"')

Can you just llvm::yaml::escape the string?


http://reviews.llvm.org/D20827



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


Re: [PATCH] D20827: [include-fixer] Use YAML format in -output-headers and -insert-header mode.

2016-06-01 Thread Haojian Wu via cfe-commits
hokein updated this revision to Diff 59185.
hokein added a comment.

Use llvm::yaml::escape to escape double quote.


http://reviews.llvm.org/D20827

Files:
  include-fixer/IncludeFixer.cpp
  include-fixer/IncludeFixerContext.h
  include-fixer/tool/ClangIncludeFixer.cpp
  include-fixer/tool/clang-include-fixer.py
  test/include-fixer/commandline_options.cpp
  test/include-fixer/ranking.cpp

Index: test/include-fixer/ranking.cpp
===
--- test/include-fixer/ranking.cpp
+++ test/include-fixer/ranking.cpp
@@ -1,6 +1,5 @@
-// RUN: clang-include-fixer -db=yaml -input=%S/Inputs/fake_yaml_db.yaml -output-headers %s -- | FileCheck %s -implicit-check-not=.h
+// RUN: clang-include-fixer -db=yaml -input=%S/Inputs/fake_yaml_db.yaml -output-headers %s -- | FileCheck %s
 
-// CHECK: "../include/bar.h"
-// CHECK-NEXT: "../include/zbar.h"
+// CHECK: "Headers": [ "\"../include/bar.h\"", "\"../include/zbar.h\"" ]
 
 bar b;
Index: test/include-fixer/commandline_options.cpp
===
--- test/include-fixer/commandline_options.cpp
+++ test/include-fixer/commandline_options.cpp
@@ -1,10 +1,9 @@
 // REQUIRES: shell
 // RUN: sed -e 's#//.*$##' %s > %t.cpp
 // RUN: clang-include-fixer -db=fixed -input='foo= "foo.h","bar.h"' -output-headers %t.cpp -- | FileCheck %s -check-prefix=CHECK-HEADERS
-// RUN: cat %t.cpp | clang-include-fixer -stdin -insert-header='"foo.h"' %t.cpp | FileCheck %s -check-prefix=CHECK
+// RUN: cat %t.cpp | clang-include-fixer -stdin -insert-header='{SymbolIdentifier: foo, Headers: ["\"foo.h\""]}' %t.cpp | FileCheck %s -check-prefix=CHECK
 //
-// CHECK-HEADERS: "foo.h"
-// CHECK-HEADERS: "bar.h"
+// CHECK-HEADERS: "Headers": [ "\"foo.h\"", "\"bar.h\"" ]
 //
 // CHECK: #include "foo.h"
 // CHECK: foo f;
Index: include-fixer/tool/clang-include-fixer.py
===
--- include-fixer/tool/clang-include-fixer.py
+++ include-fixer/tool/clang-include-fixer.py
@@ -19,6 +19,7 @@
 import difflib
 import subprocess
 import vim
+import json
 
 # set g:clang_include_fixer_path to the path to clang-include-fixer if it is not
 # on the path.
@@ -49,7 +50,7 @@
 
 
 def InsertHeaderToVimBuffer(header, text):
-  command = [binary, "-stdin", "-insert-header="+header,
+  command = [binary, "-stdin", "-insert-header="+json.dumps(header),
  vim.current.buffer.name]
   stdout, stderr = execute(command, text)
   if stdout:
@@ -77,30 +78,42 @@
   command = [binary, "-stdin", "-output-headers", "-db="+args.db,
  "-input="+args.input, vim.current.buffer.name]
   stdout, stderr = execute(command, text)
-  lines = stdout.splitlines()
-  if len(lines) < 2:
-print "No header is included.\n"
+  if stderr:
+print >> sys.stderr, "Error while running clang-include-fixer: " + stderr
+return
+
+  include_fixer_context = json.loads(stdout)
+  symbol = include_fixer_context["SymbolIdentifier"]
+  headers = include_fixer_context["Headers"]
+
+  if not symbol:
+print "The file is fine, no need to add a header.\n"
+return;
+
+  if not headers:
+print "Couldn't find a header for {0}.\n".format(symbol)
 return
 
   # The first line is the symbol name.
-  symbol = lines[0]
   # If there is only one suggested header, insert it directly.
-  if len(lines) == 2 or maximum_suggested_headers == 1:
-InsertHeaderToVimBuffer(lines[1], text)
-print "Added #include {0} for {1}.\n".format(lines[1], symbol)
+  if len(headers) == 1 or maximum_suggested_headers == 1:
+InsertHeaderToVimBuffer({"SymbolIdentifier": symbol,
+ "Headers":[headers[0]]}, text)
+print "Added #include {0} for {1}.\n".format(headers[0], symbol)
 return
 
   choices_message = ""
   index = 1;
-  for header in lines[1:1+maximum_suggested_headers]:
+  for header in headers[0:maximum_suggested_headers]:
 choices_message += "&{0} {1}\n".format(index, header)
 index += 1
 
   select = ShowDialog("choose a header file for {0}.".format(symbol),
   choices_message)
   # Insert a selected header.
-  InsertHeaderToVimBuffer(lines[select], text)
-  print "Added #include {0} for {1}.\n".format(lines[select], symbol)
+  InsertHeaderToVimBuffer({"SymbolIdentifier": symbol,
+   "Headers":[headers[select-1]]}, text)
+  print "Added #include {0} for {1}.\n".format(headers[select-1], symbol)
   return;
 
 
Index: include-fixer/tool/ClangIncludeFixer.cpp
===
--- include-fixer/tool/ClangIncludeFixer.cpp
+++ include-fixer/tool/ClangIncludeFixer.cpp
@@ -18,9 +18,25 @@
 #include "clang/Tooling/CommonOptionsParser.h"
 #include "clang/Tooling/Tooling.h"
 #include "llvm/Support/CommandLine.h"
+#include "llvm/Support/YAMLTraits.h"
 
 using namespace clang;
 using namespace llvm;
+using clang::include_fixer::IncludeFixerContext;
+
+LLVM_YAML

[PATCH] D20853: [clang-tidy] misc-macro-parentheses: Don't insert parentheses in variable declarations. Fixes bugzilla 26273

2016-06-01 Thread Daniel Marjamäki via cfe-commits
danielmarjamaki created this revision.
danielmarjamaki added subscribers: cfe-commits, alexfh.
danielmarjamaki set the repository for this revision to rL LLVM.

This is a quick fix for bugzilla 26273. parentheses should not be inserted in 
variable declarations.

This patch will introduce false negatives when a macro looks like it could be 
variable declaration but is not.

For example:

#define ABC   A*B*C

To avoid false positives in such expression, I am guessing that non-keywords 
such as "A", "B" and "C" are types or qualifiers so "A*B*C" is some variable 
declaration. My primary focus was to avoid FP.

Maybe there is a method that I am not aware of, to see if there is a type "A" 
during preprocessing.. that would be great.

The "possibleVarDecl" could be much more clever. For instance, variable 
declarations can at least contain :: < & also, I could handle those better also 
but that would mean more false negatives.


Repository:
  rL LLVM

http://reviews.llvm.org/D20853

Files:
  clang-tidy/misc/MacroParenthesesCheck.cpp
  test/clang-tidy/misc-macro-parentheses.cpp

Index: test/clang-tidy/misc-macro-parentheses.cpp
===
--- test/clang-tidy/misc-macro-parentheses.cpp
+++ test/clang-tidy/misc-macro-parentheses.cpp
@@ -8,6 +8,8 @@
 // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: macro argument should be enclosed 
in parentheses [misc-macro-parentheses]
 #define BAD4(x)   ((unsigned char)(x & 0xff))
 // CHECK-MESSAGES: :[[@LINE-1]]:44: warning: macro argument should be enclosed 
in parentheses [misc-macro-parentheses]
+#define BAD5(X)   A*B=(C*)X+2
+// CHECK-MESSAGES: :[[@LINE-1]]:35: warning: macro argument should be enclosed 
in parentheses [misc-macro-parentheses]
 
 #define GOOD1 1
 #define GOOD2 (1+2)
@@ -39,6 +41,7 @@
 #define GOOD28(x) namespace x {int b;}
 #define GOOD29(...)   std::cout << __VA_ARGS__;
 #define GOOD30(args...)   std::cout << args;
+#define GOOD31(X) A*X=2
 
 // These are allowed for now..
 #define MAYBE1*12.34
Index: clang-tidy/misc/MacroParenthesesCheck.cpp
===
--- clang-tidy/misc/MacroParenthesesCheck.cpp
+++ clang-tidy/misc/MacroParenthesesCheck.cpp
@@ -19,8 +19,7 @@
 namespace {
 class MacroParenthesesPPCallbacks : public PPCallbacks {
 public:
-  MacroParenthesesPPCallbacks(Preprocessor *PP,
-  MacroParenthesesCheck *Check)
+  MacroParenthesesPPCallbacks(Preprocessor *PP, MacroParenthesesCheck *Check)
   : PP(PP), Check(Check) {}
 
   void MacroDefined(const Token &MacroNameTok,
@@ -67,8 +66,31 @@
tok::amp, tok::pipe, tok::caret);
 }
 
+static bool possibleVarDecl(const MacroInfo *MI) {
+  if (MI->tokens_empty())
+return false;
+
+  const Token *Tok = MI->tokens_begin();
+
+  // Skip possible unknown types
+  while (Tok != MI->tokens_end() && !isKeyword(*Tok) &&
+ Tok->isOneOf(tok::identifier, tok::raw_identifier) &&
+ MI->getArgumentNum(Tok->getIdentifierInfo()) < 0) {
+Tok++;
+  }
+
+  // Return true for 'UNKNOWN_ID*X', 'UNKNOWN_ID X' etc.
+  return Tok != MI->tokens_begin() && Tok != MI->tokens_end() && 
!isKeyword(*Tok) &&
+ Tok->isOneOf(tok::star, tok::identifier, tok::raw_identifier);
+}
+
 void MacroParenthesesPPCallbacks::replacementList(const Token &MacroNameTok,
   const MacroInfo *MI) {
+  // Make sure macro replacement isn't a variable declaration, that begins
+  // with unknown identifier(s).
+  if (possibleVarDecl(MI))
+return;
+
   // Count how deep we are in parentheses/braces/squares.
   int Count = 0;
 
@@ -117,6 +139,7 @@
 
 void MacroParenthesesPPCallbacks::argument(const Token &MacroNameTok,
const MacroInfo *MI) {
+  bool VarDecl = possibleVarDecl(MI);
 
   for (auto TI = MI->tokens_begin(), TE = MI->tokens_end(); TI != TE; ++TI) {
 // First token.
@@ -132,6 +155,13 @@
 
 const Token &Tok = *TI;
 
+// Don't warn in possible variable declaration.
+if (VarDecl) {
+  if (Tok.is(tok::equal))
+VarDecl = false;
+  continue;
+}
+
 // Only interested in identifiers.
 if (!Tok.isOneOf(tok::identifier, tok::raw_identifier))
   continue;


Index: test/clang-tidy/misc-macro-parentheses.cpp
===
--- test/clang-tidy/misc-macro-parentheses.cpp
+++ test/clang-tidy/misc-macro-parentheses.cpp
@@ -8,6 +8,8 @@
 // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: macro argument should be enclosed in parentheses [misc-macro-parentheses]
 #define BAD4(x)   ((unsigned char)(x & 0xff))
 // CHECK-MESSAGES: :[[@LINE-1]]:44: warning: macro argument should be enclosed in parentheses [misc-macro-parentheses]
+#define BAD5(X)   A*B=(C*)X+2
+// CHECK-MESSAGES: :[[@LINE-1]]:35: warning: macro a

Re: [PATCH] D20827: [include-fixer] Use YAML format in -output-headers and -insert-header mode.

2016-06-01 Thread Haojian Wu via cfe-commits
hokein marked an inline comment as done.
hokein added a comment.

http://reviews.llvm.org/D20827



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


Re: [PATCH] D20827: [include-fixer] Use YAML format in -output-headers and -insert-header mode.

2016-06-01 Thread Benjamin Kramer via cfe-commits
bkramer added inline comments.


Comment at: include-fixer/tool/ClangIncludeFixer.cpp:160
@@ +159,3 @@
+  for (const auto &Header : Context.Headers) {
+// Escape double quote.
+if (Header.front() == '"')

I think we should do the escaping always and not just when the first character 
is a quote.


http://reviews.llvm.org/D20827



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


Re: [PATCH] D20827: [include-fixer] Use YAML format in -output-headers and -insert-header mode.

2016-06-01 Thread Haojian Wu via cfe-commits
hokein marked an inline comment as done.
hokein added a comment.

http://reviews.llvm.org/D20827



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


Re: [PATCH] D20827: [include-fixer] Use YAML format in -output-headers and -insert-header mode.

2016-06-01 Thread Haojian Wu via cfe-commits
hokein updated this revision to Diff 59187.
hokein added a comment.

Always escape headers.


http://reviews.llvm.org/D20827

Files:
  include-fixer/IncludeFixer.cpp
  include-fixer/IncludeFixerContext.h
  include-fixer/tool/ClangIncludeFixer.cpp
  include-fixer/tool/clang-include-fixer.py
  test/include-fixer/commandline_options.cpp
  test/include-fixer/ranking.cpp

Index: test/include-fixer/ranking.cpp
===
--- test/include-fixer/ranking.cpp
+++ test/include-fixer/ranking.cpp
@@ -1,6 +1,5 @@
-// RUN: clang-include-fixer -db=yaml -input=%S/Inputs/fake_yaml_db.yaml -output-headers %s -- | FileCheck %s -implicit-check-not=.h
+// RUN: clang-include-fixer -db=yaml -input=%S/Inputs/fake_yaml_db.yaml -output-headers %s -- | FileCheck %s
 
-// CHECK: "../include/bar.h"
-// CHECK-NEXT: "../include/zbar.h"
+// CHECK: "Headers": [ "\"../include/bar.h\"", "\"../include/zbar.h\"" ]
 
 bar b;
Index: test/include-fixer/commandline_options.cpp
===
--- test/include-fixer/commandline_options.cpp
+++ test/include-fixer/commandline_options.cpp
@@ -1,10 +1,9 @@
 // REQUIRES: shell
 // RUN: sed -e 's#//.*$##' %s > %t.cpp
 // RUN: clang-include-fixer -db=fixed -input='foo= "foo.h","bar.h"' -output-headers %t.cpp -- | FileCheck %s -check-prefix=CHECK-HEADERS
-// RUN: cat %t.cpp | clang-include-fixer -stdin -insert-header='"foo.h"' %t.cpp | FileCheck %s -check-prefix=CHECK
+// RUN: cat %t.cpp | clang-include-fixer -stdin -insert-header='{SymbolIdentifier: foo, Headers: ["\"foo.h\""]}' %t.cpp | FileCheck %s -check-prefix=CHECK
 //
-// CHECK-HEADERS: "foo.h"
-// CHECK-HEADERS: "bar.h"
+// CHECK-HEADERS: "Headers": [ "\"foo.h\"", "\"bar.h\"" ]
 //
 // CHECK: #include "foo.h"
 // CHECK: foo f;
Index: include-fixer/tool/clang-include-fixer.py
===
--- include-fixer/tool/clang-include-fixer.py
+++ include-fixer/tool/clang-include-fixer.py
@@ -19,6 +19,7 @@
 import difflib
 import subprocess
 import vim
+import json
 
 # set g:clang_include_fixer_path to the path to clang-include-fixer if it is not
 # on the path.
@@ -49,7 +50,7 @@
 
 
 def InsertHeaderToVimBuffer(header, text):
-  command = [binary, "-stdin", "-insert-header="+header,
+  command = [binary, "-stdin", "-insert-header="+json.dumps(header),
  vim.current.buffer.name]
   stdout, stderr = execute(command, text)
   if stdout:
@@ -77,30 +78,42 @@
   command = [binary, "-stdin", "-output-headers", "-db="+args.db,
  "-input="+args.input, vim.current.buffer.name]
   stdout, stderr = execute(command, text)
-  lines = stdout.splitlines()
-  if len(lines) < 2:
-print "No header is included.\n"
+  if stderr:
+print >> sys.stderr, "Error while running clang-include-fixer: " + stderr
+return
+
+  include_fixer_context = json.loads(stdout)
+  symbol = include_fixer_context["SymbolIdentifier"]
+  headers = include_fixer_context["Headers"]
+
+  if not symbol:
+print "The file is fine, no need to add a header.\n"
+return;
+
+  if not headers:
+print "Couldn't find a header for {0}.\n".format(symbol)
 return
 
   # The first line is the symbol name.
-  symbol = lines[0]
   # If there is only one suggested header, insert it directly.
-  if len(lines) == 2 or maximum_suggested_headers == 1:
-InsertHeaderToVimBuffer(lines[1], text)
-print "Added #include {0} for {1}.\n".format(lines[1], symbol)
+  if len(headers) == 1 or maximum_suggested_headers == 1:
+InsertHeaderToVimBuffer({"SymbolIdentifier": symbol,
+ "Headers":[headers[0]]}, text)
+print "Added #include {0} for {1}.\n".format(headers[0], symbol)
 return
 
   choices_message = ""
   index = 1;
-  for header in lines[1:1+maximum_suggested_headers]:
+  for header in headers[0:maximum_suggested_headers]:
 choices_message += "&{0} {1}\n".format(index, header)
 index += 1
 
   select = ShowDialog("choose a header file for {0}.".format(symbol),
   choices_message)
   # Insert a selected header.
-  InsertHeaderToVimBuffer(lines[select], text)
-  print "Added #include {0} for {1}.\n".format(lines[select], symbol)
+  InsertHeaderToVimBuffer({"SymbolIdentifier": symbol,
+   "Headers":[headers[select-1]]}, text)
+  print "Added #include {0} for {1}.\n".format(headers[select-1], symbol)
   return;
 
 
Index: include-fixer/tool/ClangIncludeFixer.cpp
===
--- include-fixer/tool/ClangIncludeFixer.cpp
+++ include-fixer/tool/ClangIncludeFixer.cpp
@@ -18,9 +18,25 @@
 #include "clang/Tooling/CommonOptionsParser.h"
 #include "clang/Tooling/Tooling.h"
 #include "llvm/Support/CommandLine.h"
+#include "llvm/Support/YAMLTraits.h"
 
 using namespace clang;
 using namespace llvm;
+using clang::include_fixer::IncludeFixerContext;
+
+LLVM_YAML_IS_DOCUMENT_LIST_VECTOR

Re: [PATCH] D20853: [clang-tidy] misc-macro-parentheses: Don't insert parentheses in variable declarations. Fixes bugzilla 26273

2016-06-01 Thread Daniel Marjamäki via cfe-commits
danielmarjamaki added a comment.

> The "possibleVarDecl" could be much more clever. For instance, variable 
> declarations can at least contain :: < & also, I could handle those better 
> also but that would mean more false negatives.


I now saw bugzilla 27399 also.

I do need to handle templates also.

so I will send a new patch with updated possibleVarDecl().


Repository:
  rL LLVM

http://reviews.llvm.org/D20853



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


Re: [PATCH] D19201: [clang-tidy] misc-throw-with-noexcept

2016-06-01 Thread Stanisław Barzowski via cfe-commits
sbarzowski added a comment.

Note ``FunctionProtoType::getNoExceptExpr`` is weird. If you have the same expr 
in multiple noexcepts, then it returns the same object for all of them, so it 
is useless for determining the location in code.

I ended up finding it all "by hand" with lexer (looking for matching 
parentheses).


Repository:
  rL LLVM

http://reviews.llvm.org/D19201



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


Re: [PATCH] D19201: [clang-tidy] misc-throw-with-noexcept

2016-06-01 Thread Stanisław Barzowski via cfe-commits
sbarzowski updated the summary for this revision.
sbarzowski removed rL LLVM as the repository for this revision.
sbarzowski updated this revision to Diff 59179.

http://reviews.llvm.org/D19201

Files:
  clang-tidy/misc/CMakeLists.txt
  clang-tidy/misc/MiscTidyModule.cpp
  clang-tidy/misc/ThrowWithNoexceptCheck.cpp
  clang-tidy/misc/ThrowWithNoexceptCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/misc-throw-with-noexcept.rst
  test/clang-tidy/misc-throw-with-noexcept.cpp

Index: test/clang-tidy/misc-throw-with-noexcept.cpp
===
--- /dev/null
+++ test/clang-tidy/misc-throw-with-noexcept.cpp
@@ -0,0 +1,70 @@
+// RUN: %check_clang_tidy %s misc-throw-with-noexcept %t
+
+void f_throw_with_ne() noexcept(true) {
+  {
+throw 5;
+  }
+}
+// CHECK-MESSAGES: :[[@LINE-5]]:24: warning: In function declared no-throw here: [misc-throw-with-noexcept]
+// CHECK-MESSAGES: :[[@LINE-4]]:5: warning: throw in function declared no-throw [misc-throw-with-noexcept]
+// CHECK-FIXES: void f_throw_with_ne() {
+
+void f_noexcept_false() noexcept(false) {
+  throw 5;
+}
+
+void f_decl_only() noexcept;
+
+// Controversial example
+void throw_and_catch() noexcept(true) {
+  try {
+throw 5;
+  } catch (...) {
+  }
+}
+// CHECK-MESSAGES: :[[@LINE-6]]:24: warning: In function declared no-throw here: [misc-throw-with-noexcept]
+// CHECK-MESSAGES: :[[@LINE-5]]:5: warning: throw in function declared no-throw [misc-throw-with-noexcept]
+// CHECK-FIXES: void throw_and_catch() {
+
+void with_parens() noexcept((true)) {
+	throw 42;
+}
+// CHECK-MESSAGES: :[[@LINE-3]]:20: warning: In function declared no-throw here: [misc-throw-with-noexcept]
+// CHECK-MESSAGES: :[[@LINE-3]]:2: warning: throw in function declared no-throw [misc-throw-with-noexcept]
+// CHECK-FIXES: void with_parens() {
+
+
+void with_parens_and_spaces() noexcept(  (true)  ) {
+	throw 42;
+}
+// CHECK-MESSAGES: :[[@LINE-3]]:31: warning: In function declared no-throw here: [misc-throw-with-noexcept]
+// CHECK-MESSAGES: :[[@LINE-3]]:2: warning: throw in function declared no-throw [misc-throw-with-noexcept]
+// CHECK-FIXES: void with_parens_and_spaces() {
+
+class Class {
+  void InClass() const noexcept(true) {
+throw 42;
+  }
+};
+// CHECK-MESSAGES: :[[@LINE-4]]:24: warning: In function declared no-throw here: [misc-throw-with-noexcept]
+// CHECK-MESSAGES: :[[@LINE-4]]:5: warning: throw in function declared no-throw [misc-throw-with-noexcept]
+// CHECK-FIXES: void InClass() const {
+
+
+void forward_declared() noexcept;
+// CHECK-MESSAGES: :[[@LINE-1]]:25: warning: In function declared no-throw here: [misc-throw-with-noexcept]
+// CHECK-FIXES: void forward_declared() ;
+
+void forward_declared() noexcept {
+	throw 42;
+}
+// CHECK-MESSAGES: :[[@LINE-3]]:25: warning: In function declared no-throw here: [misc-throw-with-noexcept]
+// CHECK-MESSAGES: :[[@LINE-3]]:2: warning: throw in function declared no-throw [misc-throw-with-noexcept]
+// CHECK-FIXES: void forward_declared() {
+
+#define NOEXCEPT noexcept
+
+void with_macro() NOEXCEPT {
+	throw 42;
+}
+// CHECK-MESSAGES: :[[@LINE-2]]:2: warning: throw in function declared no-throw [misc-throw-with-noexcept]
Index: docs/clang-tidy/checks/misc-throw-with-noexcept.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/misc-throw-with-noexcept.rst
@@ -0,0 +1,22 @@
+.. title:: clang-tidy - misc-throw-with-noexcept
+
+boost-use-to-string
+===
+
+This check finds cases of using ``throw`` in a function declared as noexcept.
+Please note that the warning is issued even if the exception is caught within
+the same function, as that would be probably a bad style anyway.
+
+It removes the noexcept specifier as a fix.
+
+
+  .. code-block:: c++
+
+void f() noexcept {
+	throw 42;
+}
+
+// Will be changed to
+void f() {
+	throw 42;
+}
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -83,6 +83,7 @@
misc-suspicious-string-compare
misc-swapped-arguments
misc-throw-by-value-catch-by-reference
+   misc-throw-with-noexcept
misc-unconventional-assign-operator
misc-undelegated-constructor
misc-uniqueptr-reset-release
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -63,9 +63,14 @@
 explain them more clearly, and provide more accurate fix-its for the issues
 identified.  The improvements since the 3.8 release include:
 
+- New `misc-throw-with-noexcept
+  `_ check
+
+  Flags ``throw`` statements in functions marked as no-throw.
+
 - New Boost module containing checks for issues with Boost library.
 
-- New `b

[PATCH] D20856: [clang-tidy] readability-identifier-naming - Support for Type Aliases

2016-06-01 Thread James Reynolds via cfe-commits
JamesReynolds created this revision.
JamesReynolds added a reviewer: alexfh.
JamesReynolds added a subscriber: cfe-commits.

Added support for Type Alias declarations.

http://reviews.llvm.org/D20856

Files:
  clang-tidy/readability/IdentifierNamingCheck.cpp
  test/clang-tidy/readability-identifier-naming.cpp

Index: test/clang-tidy/readability-identifier-naming.cpp
===
--- test/clang-tidy/readability-identifier-naming.cpp
+++ test/clang-tidy/readability-identifier-naming.cpp
@@ -61,6 +61,8 @@
 // RUN: {key: readability-identifier-naming.VariableCase, value: 
lower_case}, \
 // RUN: {key: readability-identifier-naming.VirtualMethodCase, value: 
UPPER_CASE}, \
 // RUN: {key: readability-identifier-naming.VirtualMethodPrefix, value: 
'v_'}, \
+// RUN: {key: readability-identifier-naming.TypeAliasCase, value: 
lower_case}, \
+// RUN: {key: readability-identifier-naming.TypeAliasSuffix, value: '_t'}, 
\
 // RUN: {key: readability-identifier-naming.IgnoreFailedSplit, value: 0} \
 // RUN:   ]}' -- -std=c++11 -fno-delayed-template-parsing \
 // RUN:   -I%S/Inputs/readability-identifier-naming \
@@ -191,8 +193,8 @@
 // CHECK-FIXES: {{^}}class CMyOtherTemplatedClass : CMyTemplatedClass<  
CMyClass>, private CMyDerivedClass {};{{$}}
 
 template
-using MYSUPER_TPL = my_other_templated_class  <:: FOO_NS  ::my_class>;
-// CHECK-FIXES: {{^}}using MYSUPER_TPL = CMyOtherTemplatedClass  <:: foo_ns  
::CMyClass>;{{$}}
+using mysuper_tpl_t = my_other_templated_class  <:: FOO_NS  ::my_class>;
+// CHECK-FIXES: {{^}}using mysuper_tpl_t = CMyOtherTemplatedClass  <:: foo_ns  
::CMyClass>;{{$}}
 
 const int global_Constant = 6;
 // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: invalid case style for global 
constant 'global_Constant'
@@ -305,6 +307,15 @@
 // CHECK-MESSAGES: :[[@LINE-1]]:26: warning: invalid case style for typedef 
'struct_type'
 // CHECK-FIXES: {{^}}typedef this_structure struct_type_t;{{$}}
 
+using my_struct_type = THIS___Structure;
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for type alias 
'my_struct_type'
+// CHECK-FIXES: {{^}}using my_struct_type_t = this_structure;{{$}}
+ 
+template
+using SomeOtherTemplate = my_other_templated_class  <:: FOO_NS  ::my_class>;
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for type alias 
'SomeOtherTemplate'
+// CHECK-FIXES: {{^}}using some_other_template_t = CMyOtherTemplatedClass  <:: 
foo_ns  ::CMyClass>;{{$}}
+
 static void static_Function() {
 // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: invalid case style for function 
'static_Function'
 // CHECK-FIXES: {{^}}static void staticFunction() {{{$}}
Index: clang-tidy/readability/IdentifierNamingCheck.cpp
===
--- clang-tidy/readability/IdentifierNamingCheck.cpp
+++ clang-tidy/readability/IdentifierNamingCheck.cpp
@@ -65,6 +65,7 @@
 m(ValueTemplateParameter) \
 m(TemplateTemplateParameter) \
 m(TemplateParameter) \
+m(TypeAlias) \
 
 enum StyleKind {
 #define ENUMERATE(v) SK_ ## v,
@@ -258,6 +259,9 @@
   if (isa(D) && NamingStyles[SK_Typedef].isSet())
 return SK_Typedef;
 
+  if (isa(D) && NamingStyles[SK_TypeAlias].isSet())
+return SK_TypeAlias;
+
   if (const auto *Decl = dyn_cast(D)) {
 if (Decl->isAnonymousNamespace())
   return SK_Invalid;


Index: test/clang-tidy/readability-identifier-naming.cpp
===
--- test/clang-tidy/readability-identifier-naming.cpp
+++ test/clang-tidy/readability-identifier-naming.cpp
@@ -61,6 +61,8 @@
 // RUN: {key: readability-identifier-naming.VariableCase, value: lower_case}, \
 // RUN: {key: readability-identifier-naming.VirtualMethodCase, value: UPPER_CASE}, \
 // RUN: {key: readability-identifier-naming.VirtualMethodPrefix, value: 'v_'}, \
+// RUN: {key: readability-identifier-naming.TypeAliasCase, value: lower_case}, \
+// RUN: {key: readability-identifier-naming.TypeAliasSuffix, value: '_t'}, \
 // RUN: {key: readability-identifier-naming.IgnoreFailedSplit, value: 0} \
 // RUN:   ]}' -- -std=c++11 -fno-delayed-template-parsing \
 // RUN:   -I%S/Inputs/readability-identifier-naming \
@@ -191,8 +193,8 @@
 // CHECK-FIXES: {{^}}class CMyOtherTemplatedClass : CMyTemplatedClass<  CMyClass>, private CMyDerivedClass {};{{$}}
 
 template
-using MYSUPER_TPL = my_other_templated_class  <:: FOO_NS  ::my_class>;
-// CHECK-FIXES: {{^}}using MYSUPER_TPL = CMyOtherTemplatedClass  <:: foo_ns  ::CMyClass>;{{$}}
+using mysuper_tpl_t = my_other_templated_class  <:: FOO_NS  ::my_class>;
+// CHECK-FIXES: {{^}}using mysuper_tpl_t = CMyOtherTemplatedClass  <:: foo_ns  ::CMyClass>;{{$}}
 
 const int global_Constant = 6;
 // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: invalid case style for global constant 'global_Constant'
@@ -305,6 +307,15 @@
 // CHECK-MESSAGES: :[[@LINE-1]]:26: warning: invalid case style for typede

Re: [PATCH] D19201: [clang-tidy] misc-throw-with-noexcept

2016-06-01 Thread Aaron Ballman via cfe-commits
aaron.ballman added a subscriber: aaron.ballman.
aaron.ballman added a reviewer: aaron.ballman.
aaron.ballman added a comment.

In http://reviews.llvm.org/D19201#445406, @sbarzowski wrote:

> Note ``FunctionProtoType::getNoExceptExpr`` is weird. If you have the same 
> expr in multiple noexcepts, then it returns the same object for all of them, 
> so it is useless for determining the location in code.
>
> I ended up finding it all "by hand" with lexer (looking for matching 
> parentheses).


I think you may want to take a dependency on: http://reviews.llvm.org/D20428


Repository:
  rL LLVM

http://reviews.llvm.org/D19201



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


Re: [PATCH] D19201: [clang-tidy] misc-throw-with-noexcept

2016-06-01 Thread Piotr Padlewski via cfe-commits
Prazek added a comment.

In http://reviews.llvm.org/D19201#445496, @aaron.ballman wrote:

> In http://reviews.llvm.org/D19201#445406, @sbarzowski wrote:
>
> > Note ``FunctionProtoType::getNoExceptExpr`` is weird. If you have the same 
> > expr in multiple noexcepts, then it returns the same object for all of 
> > them, so it is useless for determining the location in code.
> >
> > I ended up finding it all "by hand" with lexer (looking for matching 
> > parentheses).
>
>
> I think you may want to take a dependency on: http://reviews.llvm.org/D20428


We will see how much time it will take to make it pushable to master. IMHO this 
code is not complicated enough to make it wait for your patch, but it's cool 
that you took care of it :)


Repository:
  rL LLVM

http://reviews.llvm.org/D19201



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


Re: [PATCH] D20821: Fix a few issues while skipping function bodies

2016-06-01 Thread Olivier Goffart via cfe-commits
ogoffart updated this revision to Diff 59197.
ogoffart added a comment.

Right, i forgot about the C++11 initializer list syntax.  I hope I got it right 
now.


http://reviews.llvm.org/D20821

Files:
  lib/Parse/ParseCXXInlineMethods.cpp
  lib/Parse/ParseObjc.cpp
  lib/Parse/ParseStmt.cpp
  lib/Parse/Parser.cpp
  lib/Sema/SemaDecl.cpp
  unittests/Tooling/ToolingTest.cpp

Index: unittests/Tooling/ToolingTest.cpp
===
--- unittests/Tooling/ToolingTest.cpp
+++ unittests/Tooling/ToolingTest.cpp
@@ -241,7 +241,7 @@
 struct SkipBodyConsumer : public clang::ASTConsumer {
   /// Skip the 'skipMe' function.
   bool shouldSkipFunctionBody(Decl *D) override {
-FunctionDecl *F = dyn_cast(D);
+NamedDecl *F = dyn_cast(D);
 return F && F->getNameAsString() == "skipMe";
   }
 };
@@ -259,6 +259,56 @@
 "int skipMe() { an_error_here }"));
   EXPECT_FALSE(runToolOnCode(new SkipBodyAction,
  "int skipMeNot() { an_error_here }"));
+
+  // Test constructors with initializers
+  EXPECT_TRUE(
+  runToolOnCode(new SkipBodyAction,
+"struct skipMe { skipMe() : an_error() { more error } };"));
+  EXPECT_TRUE(
+  runToolOnCode(new SkipBodyAction,
+"struct skipMe { skipMe(); };"
+"skipMe::skipMe() : an_error([](){;}) { more error }"));
+  EXPECT_TRUE(
+  runToolOnCode(new SkipBodyAction,
+"struct skipMe { skipMe(); };"
+"skipMe::skipMe() : an_error{[](){;}} { more error }"));
+  EXPECT_TRUE(
+  runToolOnCode(new SkipBodyAction,
+"struct skipMe { skipMe(); };"
+"skipMe::skipMe() : a(e)>>(), f{}, g() { error }"));
+  EXPECT_TRUE(
+  runToolOnCode(new SkipBodyAction,
+"struct skipMe { skipMe() : bases()... { error } };"));
+
+  EXPECT_FALSE(
+  runToolOnCode(new SkipBodyAction,
+"struct skipMeNot { skipMeNot() : an_error() { } };"));
+  EXPECT_FALSE(runToolOnCode(new SkipBodyAction,
+ "struct skipMeNot { skipMeNot(); };"
+ "skipMeNot::skipMeNot() : an_error() { }"));
+
+  // Try/catch
+  EXPECT_TRUE(runToolOnCode(
+  new SkipBodyAction,
+  "void skipMe() try { an_error() } catch(error) { error };"));
+  EXPECT_TRUE(runToolOnCode(
+  new SkipBodyAction,
+  "struct S { void skipMe() try { an_error() } catch(error) { error } };"));
+  EXPECT_TRUE(
+  runToolOnCode(new SkipBodyAction,
+"void skipMe() try { an_error() } catch(error) { error; }"
+"catch(error) { error } catch (error) { }"));
+  EXPECT_FALSE(runToolOnCode(
+  new SkipBodyAction,
+  "void skipMe() try something;")); // don't crash while parsing
+
+  // Template
+  EXPECT_TRUE(runToolOnCode(
+  new SkipBodyAction, "template int skipMe() { an_error_here }"
+  "int x = skipMe();"));
+  EXPECT_FALSE(
+  runToolOnCode(new SkipBodyAction,
+"template int skipMeNot() { an_error_here }"));
 }
 
 TEST(runToolOnCodeWithArgs, TestNoDepFile) {
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -11378,7 +11378,7 @@
 FD->setHasSkippedBody();
   else if (ObjCMethodDecl *MD = dyn_cast_or_null(Decl))
 MD->setHasSkippedBody();
-  return ActOnFinishFunctionBody(Decl, nullptr);
+  return Decl;
 }
 
 Decl *Sema::ActOnFinishFunctionBody(Decl *D, Stmt *BodyArg) {
Index: lib/Parse/Parser.cpp
===
--- lib/Parse/Parser.cpp
+++ lib/Parse/Parser.cpp
@@ -1044,6 +1044,12 @@
 D.complete(DP);
 D.getMutableDeclSpec().abort();
 
+if (SkipFunctionBodies && (!DP || Actions.canSkipFunctionBody(DP)) &&
+trySkippingFunctionBody()) {
+  BodyScope.Exit();
+  return Actions.ActOnSkippedFunctionBody(DP);
+}
+
 CachedTokens Toks;
 LexTemplateFunctionForLateParsing(Toks);
 
@@ -1136,6 +1142,13 @@
 return Res;
   }
 
+  if (SkipFunctionBodies && (!Res || Actions.canSkipFunctionBody(Res)) &&
+  trySkippingFunctionBody()) {
+BodyScope.Exit();
+Actions.ActOnSkippedFunctionBody(Res);
+return Actions.ActOnFinishFunctionBody(Res, nullptr, false);
+  }
+
   if (Tok.is(tok::kw_try))
 return ParseFunctionTryBlock(Res, BodyScope);
 
Index: lib/Parse/ParseStmt.cpp
===
--- lib/Parse/ParseStmt.cpp
+++ lib/Parse/ParseStmt.cpp
@@ -1916,12 +1916,6 @@
   assert(Tok.is(tok::l_brace));
   SourceLocation LBraceLoc = Tok.getLocation();
 
-  if (SkipFunctionBodies && (!Decl || Actions.canSkipFunctionBody(Decl)) &&
-  trySkippingFunctionBody()) {
-BodyScope.Exit();
-return Actions.ActOnSkippedFunctionBody(Decl);
-  }
-
   PrettyDeclStackTrace

Re: [PATCH] D20855: [include-fixer] use includer of .inc header to be the file path of a symbol from .inc header.

2016-06-01 Thread Benjamin Kramer via cfe-commits
bkramer accepted this revision.
This revision is now accepted and ready to land.


Comment at: include-fixer/find-all-symbols/PathConfig.cpp:20
@@ +19,3 @@
+  llvm::StringRef FilePath;
+  while (true) {
+if (!Loc.isValid() || SM.isInMainFile(Loc))

Maybe add a comment that we walk up the include stack for .inc files?


Comment at: include-fixer/find-all-symbols/PathConfig.cpp:33
@@ +32,3 @@
+  // If Collector is not nullptr, check pragma remapping header.
+  FilePath = Collector ? Collector->getMappedHeader(FilePath) : FilePath;
+

Not your fault here, but I'd really prefer
  
```
if (Collector)
  FilePath = Collector->getMappedHeader(FilePath);
```


http://reviews.llvm.org/D20855



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


[clang-tools-extra] r271382 - [include-fixer] Use YAML format in -output-headers and -insert-header mode.

2016-06-01 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Wed Jun  1 06:43:10 2016
New Revision: 271382

URL: http://llvm.org/viewvc/llvm-project?rev=271382&view=rev
Log:
[include-fixer] Use YAML format in -output-headers and -insert-header mode.

Summary:
And some improvements:
* Show better error messages on unfound symbols.
* Fix a typo.

Reviewers: bkramer

Subscribers: cfe-commits

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

Modified:
clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp
clang-tools-extra/trunk/include-fixer/IncludeFixerContext.h
clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp
clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer.py
clang-tools-extra/trunk/test/include-fixer/commandline_options.cpp
clang-tools-extra/trunk/test/include-fixer/ranking.cpp

Modified: clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp?rev=271382&r1=271381&r2=271382&view=diff
==
--- clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp (original)
+++ clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp Wed Jun  1 06:43:10 
2016
@@ -193,10 +193,7 @@ public:
   getIncludeFixerContext(const clang::SourceManager &SourceManager,
  clang::HeaderSearch &HeaderSearch) {
 IncludeFixerContext FixerContext;
-if (SymbolQueryResults.empty())
-  return FixerContext;
-
-FixerContext.SymbolIdentifer = QuerySymbol;
+FixerContext.SymbolIdentifier = QuerySymbol;
 for (const auto &Header : SymbolQueryResults)
   FixerContext.Headers.push_back(
   minimizeInclude(Header, SourceManager, HeaderSearch));

Modified: clang-tools-extra/trunk/include-fixer/IncludeFixerContext.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/IncludeFixerContext.h?rev=271382&r1=271381&r2=271382&view=diff
==
--- clang-tools-extra/trunk/include-fixer/IncludeFixerContext.h (original)
+++ clang-tools-extra/trunk/include-fixer/IncludeFixerContext.h Wed Jun  1 
06:43:10 2016
@@ -19,7 +19,7 @@ namespace include_fixer {
 /// \brief A context for the symbol being queried.
 struct IncludeFixerContext {
   /// \brief The symbol name.
-  std::string SymbolIdentifer;
+  std::string SymbolIdentifier;
   /// \brief The headers which have SymbolIdentifier definitions.
   std::vector Headers;
 };

Modified: clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp?rev=271382&r1=271381&r2=271382&view=diff
==
--- clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp (original)
+++ clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp Wed Jun  1 
06:43:10 2016
@@ -18,9 +18,25 @@
 #include "clang/Tooling/CommonOptionsParser.h"
 #include "clang/Tooling/Tooling.h"
 #include "llvm/Support/CommandLine.h"
+#include "llvm/Support/YAMLTraits.h"
 
 using namespace clang;
 using namespace llvm;
+using clang::include_fixer::IncludeFixerContext;
+
+LLVM_YAML_IS_DOCUMENT_LIST_VECTOR(IncludeFixerContext)
+LLVM_YAML_IS_FLOW_SEQUENCE_VECTOR(std::string)
+
+namespace llvm {
+namespace yaml {
+template <> struct MappingTraits {
+  static void mapping(IO &io, IncludeFixerContext &Context) {
+io.mapRequired("SymbolIdentifier", Context.SymbolIdentifier);
+io.mapRequired("Headers", Context.Headers);
+  }
+};
+} // namespace yaml
+} // namespace llvm
 
 namespace {
 cl::OptionCategory IncludeFixerCategory("Tool options");
@@ -60,19 +76,21 @@ cl::opt
 
 cl::opt OutputHeaders(
 "output-headers",
-cl::desc("Output the symbol being quired and all its relevant headers.\n"
- "The first line is the symbol name; The other lines\n"
- "are the headers: \n"
- "   b::foo\n"
- "   path/to/foo_a.h\n"
- "   path/to/foo_b.h\n"),
+cl::desc("Print the symbol being queried and all its relevant headers in\n"
+ "JSON format to stdout:\n"
+ "  {\n"
+ "\"SymbolIdentifier\": \"foo\",\n"
+ "\"Headers\": [\"\\\"foo_a.h\\\"\"]\n"
+ "  }"),
 cl::init(false), cl::cat(IncludeFixerCategory));
 
 cl::opt InsertHeader(
 "insert-header",
 cl::desc("Insert a specific header. This should run with STDIN mode.\n"
  "The result is written to stdout. It is currently used for\n"
- "editor integration."),
+ "editor integration. Support YAML/JSON format:\n"
+ "  -insert-header=\"{SymbolIdentifier: foo,\n"
+ "   Headers: ['\\\"foo_a.h\\\"']}\""),
 cl::init(""), cl::cat(IncludeFixerCategory));
 
 cl::opt
@@ -134,6 +152,19 @@ crea

Re: [PATCH] D20827: [include-fixer] Use YAML format in -output-headers and -insert-header mode.

2016-06-01 Thread Haojian Wu via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL271382: [include-fixer] Use YAML format in -output-headers 
and -insert-header mode. (authored by hokein).

Changed prior to commit:
  http://reviews.llvm.org/D20827?vs=59187&id=59198#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D20827

Files:
  clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp
  clang-tools-extra/trunk/include-fixer/IncludeFixerContext.h
  clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp
  clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer.py
  clang-tools-extra/trunk/test/include-fixer/commandline_options.cpp
  clang-tools-extra/trunk/test/include-fixer/ranking.cpp

Index: clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp
===
--- clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp
+++ clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp
@@ -193,10 +193,7 @@
   getIncludeFixerContext(const clang::SourceManager &SourceManager,
  clang::HeaderSearch &HeaderSearch) {
 IncludeFixerContext FixerContext;
-if (SymbolQueryResults.empty())
-  return FixerContext;
-
-FixerContext.SymbolIdentifer = QuerySymbol;
+FixerContext.SymbolIdentifier = QuerySymbol;
 for (const auto &Header : SymbolQueryResults)
   FixerContext.Headers.push_back(
   minimizeInclude(Header, SourceManager, HeaderSearch));
Index: clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer.py
===
--- clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer.py
+++ clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer.py
@@ -19,6 +19,7 @@
 import difflib
 import subprocess
 import vim
+import json
 
 # set g:clang_include_fixer_path to the path to clang-include-fixer if it is not
 # on the path.
@@ -49,7 +50,7 @@
 
 
 def InsertHeaderToVimBuffer(header, text):
-  command = [binary, "-stdin", "-insert-header="+header,
+  command = [binary, "-stdin", "-insert-header="+json.dumps(header),
  vim.current.buffer.name]
   stdout, stderr = execute(command, text)
   if stdout:
@@ -77,30 +78,42 @@
   command = [binary, "-stdin", "-output-headers", "-db="+args.db,
  "-input="+args.input, vim.current.buffer.name]
   stdout, stderr = execute(command, text)
-  lines = stdout.splitlines()
-  if len(lines) < 2:
-print "No header is included.\n"
+  if stderr:
+print >> sys.stderr, "Error while running clang-include-fixer: " + stderr
+return
+
+  include_fixer_context = json.loads(stdout)
+  symbol = include_fixer_context["SymbolIdentifier"]
+  headers = include_fixer_context["Headers"]
+
+  if not symbol:
+print "The file is fine, no need to add a header.\n"
+return;
+
+  if not headers:
+print "Couldn't find a header for {0}.\n".format(symbol)
 return
 
   # The first line is the symbol name.
-  symbol = lines[0]
   # If there is only one suggested header, insert it directly.
-  if len(lines) == 2 or maximum_suggested_headers == 1:
-InsertHeaderToVimBuffer(lines[1], text)
-print "Added #include {0} for {1}.\n".format(lines[1], symbol)
+  if len(headers) == 1 or maximum_suggested_headers == 1:
+InsertHeaderToVimBuffer({"SymbolIdentifier": symbol,
+ "Headers":[headers[0]]}, text)
+print "Added #include {0} for {1}.\n".format(headers[0], symbol)
 return
 
   choices_message = ""
   index = 1;
-  for header in lines[1:1+maximum_suggested_headers]:
+  for header in headers[0:maximum_suggested_headers]:
 choices_message += "&{0} {1}\n".format(index, header)
 index += 1
 
   select = ShowDialog("choose a header file for {0}.".format(symbol),
   choices_message)
   # Insert a selected header.
-  InsertHeaderToVimBuffer(lines[select], text)
-  print "Added #include {0} for {1}.\n".format(lines[select], symbol)
+  InsertHeaderToVimBuffer({"SymbolIdentifier": symbol,
+   "Headers":[headers[select-1]]}, text)
+  print "Added #include {0} for {1}.\n".format(headers[select-1], symbol)
   return;
 
 
Index: clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp
===
--- clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp
+++ clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp
@@ -18,9 +18,25 @@
 #include "clang/Tooling/CommonOptionsParser.h"
 #include "clang/Tooling/Tooling.h"
 #include "llvm/Support/CommandLine.h"
+#include "llvm/Support/YAMLTraits.h"
 
 using namespace clang;
 using namespace llvm;
+using clang::include_fixer::IncludeFixerContext;
+
+LLVM_YAML_IS_DOCUMENT_LIST_VECTOR(IncludeFixerContext)
+LLVM_YAML_IS_FLOW_SEQUENCE_VECTOR(std::string)
+
+namespace llvm {
+namespace yaml {
+template <> struct MappingTraits {
+  static void mapping(IO &io, IncludeFixerConte

[PATCH] D20858: [clang-format] make header guard identification stricter in header insertion.

2016-06-01 Thread Eric Liu via cfe-commits
ioeric created this revision.
ioeric added a reviewer: djasper.
ioeric added a subscriber: cfe-commits.
Herald added a subscriber: klimek.

don't just identify first #define as header guard anymore. Use #ifndef
#define to tell if a #define belongs to header guard.

http://reviews.llvm.org/D20858

Files:
  lib/Format/Format.cpp
  unittests/Format/CleanupTest.cpp

Index: unittests/Format/CleanupTest.cpp
===
--- unittests/Format/CleanupTest.cpp
+++ unittests/Format/CleanupTest.cpp
@@ -537,6 +537,34 @@
   EXPECT_EQ(Expected, formatAndApply(Code, Replaces));
 }
 
+TEST_F(CleanUpReplacementsTest, DontJustInsertAfterRandomDefine) {
+  std::string Code = "#define X 1";
+  std::string Expected = "#include \n"
+ "#define X 1";
+  tooling::Replacements Replaces = {createInsertion("#include ")};
+  EXPECT_EQ(Expected, apply(Code, Replaces));
+}
+
+TEST_F(CleanUpReplacementsTest, InsertAfterHeaderGuard) {
+  std::string Code = "#ifndef X_H\n"
+ "#define X_H\n";
+  std::string Expected = "#ifndef X_H\n"
+ "#define X_H\n"
+ "#include \n";
+  tooling::Replacements Replaces = {createInsertion("#include ")};
+  EXPECT_EQ(Expected, apply(Code, Replaces));
+}
+
+TEST_F(CleanUpReplacementsTest, DontInsertAfterNonMatchedHeaderGuard) {
+  std::string Code = "#ifndef X_H\n"
+ "#define Y_H";
+  std::string Expected = "#include \n"
+ "#ifndef X_H\n"
+ "#define Y_H";
+  tooling::Replacements Replaces = {createInsertion("#include ")};
+  EXPECT_EQ(Expected, apply(Code, Replaces));
+}
+
 } // end namespace
 } // end namespace format
 } // end namespace clang
Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -1469,7 +1469,8 @@
   std::inserter(Result, Result.begin()));
 
   llvm::Regex IncludeRegex(IncludeRegexPattern);
-  llvm::Regex DefineRegex(R"(^[\t\ ]*#[\t\ ]*define[\t\ ]*[^\\]*$)");
+  llvm::Regex IfNDefRegex(R"(^[\t\ ]*#[\t\ ]*ifndef[\t\ ]*([^\\]*)$)");
+  llvm::Regex DefineRegex(R"(^[\t\ ]*#[\t\ ]*define[\t\ ]*([^\\]*)$)");
   SmallVector Matches;
 
   StringRef FileName = Replaces.begin()->getFilePath();
@@ -1484,7 +1485,9 @@
 Priorities.insert(Category.Priority);
   int FirstIncludeOffset = -1;
   int Offset = 0;
+  int AfterFirstIfNDef = 0;
   int AfterHeaderGuard = 0;
+  StringRef FirstIfNDefName;
   SmallVector Lines;
   Code.split(Lines, '\n');
   for (auto Line : Lines) {
@@ -1496,10 +1499,15 @@
   if (FirstIncludeOffset < 0)
 FirstIncludeOffset = Offset;
 }
+if (AfterHeaderGuard == 0 && AfterFirstIfNDef > 0 &&
+AfterFirstIfNDef == Offset && DefineRegex.match(Line, &Matches) &&
+Matches[1] == FirstIfNDefName)
+  AfterHeaderGuard = Offset + Line.size() + 1;
 Offset += Line.size() + 1;
-// FIXME: make header guard matching stricter, e.g. consider #ifndef.
-if (AfterHeaderGuard == 0 && DefineRegex.match(Line))
-  AfterHeaderGuard = Offset;
+if (AfterFirstIfNDef == 0 && IfNDefRegex.match(Line, &Matches)) {
+  FirstIfNDefName = Matches[1];
+  AfterFirstIfNDef = Offset;
+}
   }
 
   // Populate CategoryEndOfssets:


Index: unittests/Format/CleanupTest.cpp
===
--- unittests/Format/CleanupTest.cpp
+++ unittests/Format/CleanupTest.cpp
@@ -537,6 +537,34 @@
   EXPECT_EQ(Expected, formatAndApply(Code, Replaces));
 }
 
+TEST_F(CleanUpReplacementsTest, DontJustInsertAfterRandomDefine) {
+  std::string Code = "#define X 1";
+  std::string Expected = "#include \n"
+ "#define X 1";
+  tooling::Replacements Replaces = {createInsertion("#include ")};
+  EXPECT_EQ(Expected, apply(Code, Replaces));
+}
+
+TEST_F(CleanUpReplacementsTest, InsertAfterHeaderGuard) {
+  std::string Code = "#ifndef X_H\n"
+ "#define X_H\n";
+  std::string Expected = "#ifndef X_H\n"
+ "#define X_H\n"
+ "#include \n";
+  tooling::Replacements Replaces = {createInsertion("#include ")};
+  EXPECT_EQ(Expected, apply(Code, Replaces));
+}
+
+TEST_F(CleanUpReplacementsTest, DontInsertAfterNonMatchedHeaderGuard) {
+  std::string Code = "#ifndef X_H\n"
+ "#define Y_H";
+  std::string Expected = "#include \n"
+ "#ifndef X_H\n"
+ "#define Y_H";
+  tooling::Replacements Replaces = {createInsertion("#include ")};
+  EXPECT_EQ(Expected, apply(Code, Replaces));
+}
+
 } // end namespace
 } // end namespace format
 } // end namespace clang
Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -1469,7 +1469,8 @@
   std::inserter(Resu

Re: [PATCH] D20855: [include-fixer] use includer of .inc header to be the file path of a symbol from .inc header.

2016-06-01 Thread Eric Liu via cfe-commits
ioeric updated this revision to Diff 59200.
ioeric added a comment.

- Addressed reviewer's comments.


http://reviews.llvm.org/D20855

Files:
  include-fixer/find-all-symbols/CMakeLists.txt
  include-fixer/find-all-symbols/FindAllMacros.cpp
  include-fixer/find-all-symbols/FindAllSymbols.cpp
  include-fixer/find-all-symbols/PathConfig.cpp
  include-fixer/find-all-symbols/PathConfig.h
  unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp

Index: unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
===
--- unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
+++ unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
@@ -68,13 +68,23 @@
 
 const std::string InternalHeader = "internal/internal.h";
 const std::string TopHeader = "";
+// Test .inc header path. The header for `IncHeaderClass` should be
+// internal.h, which will eventually be mapped to .
+std::string IncHeader = "internal/private.inc";
+std::string IncHeaderCode = "class IncHeaderClass {};";
+
 HeaderMapCollector::HeaderMap PostfixMap = {
 {"internal.h", TopHeader},
 };
 
-std::string InternalCode = "class Internal {};";
+std::string InternalCode =
+"#include \"private.inc\"\nclass Internal {};";
 SymbolInfo InternalSymbol("Internal", SymbolInfo::SymbolKind::Class,
-  TopHeader, 1, {});
+  TopHeader, 2, {});
+SymbolInfo IncSymbol("IncHeaderClass", SymbolInfo::SymbolKind::Class,
+ TopHeader, 1, {});
+InMemoryFileSystem->addFile(
+IncHeader, 0, llvm::MemoryBuffer::getMemBuffer(IncHeaderCode));
 InMemoryFileSystem->addFile(InternalHeader, 0,
 llvm::MemoryBuffer::getMemBuffer(InternalCode));
 
@@ -111,6 +121,7 @@
 llvm::MemoryBuffer::getMemBuffer(Content));
 Invocation.run();
 EXPECT_TRUE(hasSymbol(InternalSymbol));
+EXPECT_TRUE(hasSymbol(IncSymbol));
 #if !defined(_MSC_VER) && !defined(__MINGW32__)
 EXPECT_TRUE(hasSymbol(DirtySymbol));
 EXPECT_TRUE(hasSymbol(DirtyMacro));
Index: include-fixer/find-all-symbols/PathConfig.h
===
--- /dev/null
+++ include-fixer/find-all-symbols/PathConfig.h
@@ -0,0 +1,37 @@
+//===-- PathConfig.h - Process paths of symbols -*- C++ -*-===//
+//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_FIND_ALL_SYMBOLS_PATH_CONFIG_H
+#define LLVM_CLANG_TOOLS_EXTRA_FIND_ALL_SYMBOLS_PATH_CONFIG_H
+
+#include "HeaderMapCollector.h"
+#include "clang/Basic/SourceManager.h"
+#include 
+
+namespace clang {
+namespace find_all_symbols {
+
+/// \brief This calculates the include path for \p Loc.
+///
+/// \param SM SourceManager.
+/// \param Loc A SourceLocation.
+/// \param Collector An optional header mapping collector.
+///
+/// \return The file path (or mapped file path if Collector is provided) of the
+/// header that includes \p Loc. If \p Loc comes from .inc header file, \p Loc
+/// is set to the location from which the .inc header file is included. If \p
+/// Loc is invalid or comes from a main file, this returns an empty string.
+std::string getIncludePath(const SourceManager &SM, SourceLocation Loc,
+   const HeaderMapCollector *Collector = nullptr);
+
+} // namespace find_all_symbols
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_FIND_ALL_SYMBOLS_PATH_CONFIG_H
Index: include-fixer/find-all-symbols/PathConfig.cpp
===
--- /dev/null
+++ include-fixer/find-all-symbols/PathConfig.cpp
@@ -0,0 +1,42 @@
+//===-- PathConfig.cpp - Process paths of symbols ---*- C++ -*-===//
+//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "PathConfig.h"
+#include "llvm/Support/Path.h"
+
+namespace clang {
+namespace find_all_symbols {
+
+std::string getIncludePath(const SourceManager &SM, SourceLocation Loc,
+   const HeaderMapCollector *Collector) {
+  llvm::StringRef FilePath;
+  // Walk up the include stack to skip .inc files.
+  while (true) {
+if (!Loc.isValid() || SM.isInMainFile(Loc))
+  return "";
+FilePath = SM.getFilename(Loc);
+if (FilePath.empty())
+  return "";
+if (!FilePath.endswith(".inc"))
+  break;
+FileID ID = SM.getFileID(Loc);
+Loc = SM.getIncludeLoc(ID);
+  }
+
+

Re: [PATCH] D20855: [include-fixer] use includer of .inc header to be the file path of a symbol from .inc header.

2016-06-01 Thread Eric Liu via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL271385: [include-fixer] use includer of .inc header to be 
the file path of a symbol… (authored by ioeric).

Changed prior to commit:
  http://reviews.llvm.org/D20855?vs=59200&id=59202#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D20855

Files:
  clang-tools-extra/trunk/include-fixer/find-all-symbols/CMakeLists.txt
  clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllMacros.cpp
  clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbols.cpp
  clang-tools-extra/trunk/include-fixer/find-all-symbols/PathConfig.cpp
  clang-tools-extra/trunk/include-fixer/find-all-symbols/PathConfig.h
  
clang-tools-extra/trunk/unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp

Index: clang-tools-extra/trunk/unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
===
--- clang-tools-extra/trunk/unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
+++ clang-tools-extra/trunk/unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
@@ -68,13 +68,23 @@
 
 const std::string InternalHeader = "internal/internal.h";
 const std::string TopHeader = "";
+// Test .inc header path. The header for `IncHeaderClass` should be
+// internal.h, which will eventually be mapped to .
+std::string IncHeader = "internal/private.inc";
+std::string IncHeaderCode = "class IncHeaderClass {};";
+
 HeaderMapCollector::HeaderMap PostfixMap = {
 {"internal.h", TopHeader},
 };
 
-std::string InternalCode = "class Internal {};";
+std::string InternalCode =
+"#include \"private.inc\"\nclass Internal {};";
 SymbolInfo InternalSymbol("Internal", SymbolInfo::SymbolKind::Class,
-  TopHeader, 1, {});
+  TopHeader, 2, {});
+SymbolInfo IncSymbol("IncHeaderClass", SymbolInfo::SymbolKind::Class,
+ TopHeader, 1, {});
+InMemoryFileSystem->addFile(
+IncHeader, 0, llvm::MemoryBuffer::getMemBuffer(IncHeaderCode));
 InMemoryFileSystem->addFile(InternalHeader, 0,
 llvm::MemoryBuffer::getMemBuffer(InternalCode));
 
@@ -111,6 +121,7 @@
 llvm::MemoryBuffer::getMemBuffer(Content));
 Invocation.run();
 EXPECT_TRUE(hasSymbol(InternalSymbol));
+EXPECT_TRUE(hasSymbol(IncSymbol));
 #if !defined(_MSC_VER) && !defined(__MINGW32__)
 EXPECT_TRUE(hasSymbol(DirtySymbol));
 EXPECT_TRUE(hasSymbol(DirtyMacro));
Index: clang-tools-extra/trunk/include-fixer/find-all-symbols/CMakeLists.txt
===
--- clang-tools-extra/trunk/include-fixer/find-all-symbols/CMakeLists.txt
+++ clang-tools-extra/trunk/include-fixer/find-all-symbols/CMakeLists.txt
@@ -7,6 +7,7 @@
   FindAllSymbolsAction.cpp
   FindAllMacros.cpp
   HeaderMapCollector.cpp
+  PathConfig.cpp
   PragmaCommentHandler.cpp
   STLPostfixHeaderMap.cpp
   SymbolInfo.cpp
Index: clang-tools-extra/trunk/include-fixer/find-all-symbols/PathConfig.h
===
--- clang-tools-extra/trunk/include-fixer/find-all-symbols/PathConfig.h
+++ clang-tools-extra/trunk/include-fixer/find-all-symbols/PathConfig.h
@@ -0,0 +1,37 @@
+//===-- PathConfig.h - Process paths of symbols -*- C++ -*-===//
+//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_FIND_ALL_SYMBOLS_PATH_CONFIG_H
+#define LLVM_CLANG_TOOLS_EXTRA_FIND_ALL_SYMBOLS_PATH_CONFIG_H
+
+#include "HeaderMapCollector.h"
+#include "clang/Basic/SourceManager.h"
+#include 
+
+namespace clang {
+namespace find_all_symbols {
+
+/// \brief This calculates the include path for \p Loc.
+///
+/// \param SM SourceManager.
+/// \param Loc A SourceLocation.
+/// \param Collector An optional header mapping collector.
+///
+/// \return The file path (or mapped file path if Collector is provided) of the
+/// header that includes \p Loc. If \p Loc comes from .inc header file, \p Loc
+/// is set to the location from which the .inc header file is included. If \p
+/// Loc is invalid or comes from a main file, this returns an empty string.
+std::string getIncludePath(const SourceManager &SM, SourceLocation Loc,
+   const HeaderMapCollector *Collector = nullptr);
+
+} // namespace find_all_symbols
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_FIND_ALL_SYMBOLS_PATH_CONFIG_H
Index: clang-tools-extra/trunk/include-fixer/find-all-symbols/PathConfig.cpp
===
--- clang-tools-extra/trunk/include-fi

r271387 - Adding front-end support to several intrinsics (bit scanning, conversion and state reading intrinsics)

2016-06-01 Thread Michael Zuckerman via cfe-commits
Author: mzuckerm
Date: Wed Jun  1 07:21:00 2016
New Revision: 271387

URL: http://llvm.org/viewvc/llvm-project?rev=271387&view=rev
Log:
Adding front-end support to several intrinsics (bit scanning, conversion and 
state reading intrinsics)


Adding LLVM front-end support to two intrinsics dealing with bit scan: 
_bit_scan_forward and _bit_scan_reverse.
 Their functionality is as described in Intel intrinsics guide:
 
https://software.intel.com/sites/landingpage/IntrinsicsGuide/#text=_bit_scan_forward&expand=371,370
 
https://software.intel.com/sites/landingpage/IntrinsicsGuide/#text=_bit_scan_reverse&expand=371,370

 Furthermore, adding clang front-end support to these conversion intrinsics: 
_mm256_cvtsd_f64, _mm256_cvtsi256_si32 and _mm256_cvtss_f32.

 Finally, adding tests to all of the above, as well as to the state reading 
intrinsics _rdpmc and _rdtsc.
  Their functionality is also specified in the Intel intrinsics guide.


Commit on behalf of Omer Paparo Bivas


Added:
cfe/trunk/test/CodeGen/bitscan-builtins.c
cfe/trunk/test/CodeGen/rd-builtins.c
Modified:
cfe/trunk/include/clang/Basic/BuiltinsX86.def
cfe/trunk/lib/Headers/avxintrin.h
cfe/trunk/lib/Headers/ia32intrin.h
cfe/trunk/lib/Headers/immintrin.h
cfe/trunk/test/CodeGen/avx-builtins.c

Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86.def?rev=271387&r1=271386&r2=271387&view=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Wed Jun  1 07:21:00 2016
@@ -35,6 +35,10 @@ BUILTIN(__builtin_ms_va_start, "vc*&.",
 BUILTIN(__builtin_ms_va_end, "vc*&", "n")
 BUILTIN(__builtin_ms_va_copy, "vc*&c*&", "n")
 
+// Bit scan
+TARGET_BUILTIN(__builtin_ia32_bit_scan_forward, "ii", "", "")
+TARGET_BUILTIN(__builtin_ia32_bit_scan_reverse, "ii", "", "")
+
 // Undefined Values
 //
 TARGET_BUILTIN(__builtin_ia32_undef128, "V2d", "nc", "")

Modified: cfe/trunk/lib/Headers/avxintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avxintrin.h?rev=271387&r1=271386&r2=271387&view=diff
==
--- cfe/trunk/lib/Headers/avxintrin.h (original)
+++ cfe/trunk/lib/Headers/avxintrin.h Wed Jun  1 07:21:00 2016
@@ -2123,6 +2123,25 @@ _mm256_cvttps_epi32(__m256 __a)
   return (__m256i)__builtin_ia32_cvttps2dq256((__v8sf) __a);
 }
 
+static __inline double __DEFAULT_FN_ATTRS
+_mm256_cvtsd_f64(__m256d __a)
+{
+ return __a[0];
+}
+
+static __inline int __DEFAULT_FN_ATTRS
+_mm256_cvtsi256_si32(__m256i __a)
+{
+ __v8si __b = (__v8si)__a;
+ return __b[0];
+}
+
+static __inline float __DEFAULT_FN_ATTRS
+_mm256_cvtss_f32(__m256 __a)
+{
+ return __a[0];
+}
+
 /* Vector replicate */
 static __inline __m256 __DEFAULT_FN_ATTRS
 _mm256_movehdup_ps(__m256 __a)

Modified: cfe/trunk/lib/Headers/ia32intrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/ia32intrin.h?rev=271387&r1=271386&r2=271387&view=diff
==
--- cfe/trunk/lib/Headers/ia32intrin.h (original)
+++ cfe/trunk/lib/Headers/ia32intrin.h Wed Jun  1 07:21:00 2016
@@ -74,4 +74,6 @@ __rdtscp(unsigned int *__A) {
 
 #define _rdtsc() __rdtsc()
 
+#define _rdpmc(A) __rdpmc(A)
+
 #endif /* __IA32INTRIN_H */

Modified: cfe/trunk/lib/Headers/immintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/immintrin.h?rev=271387&r1=271386&r2=271387&view=diff
==
--- cfe/trunk/lib/Headers/immintrin.h (original)
+++ cfe/trunk/lib/Headers/immintrin.h Wed Jun  1 07:21:00 2016
@@ -169,6 +169,18 @@ _rdrand32_step(unsigned int *__p)
   return __builtin_ia32_rdrand32_step(__p);
 }
 
+/* __bit_scan_forward */
+static __inline__ int __attribute__((__always_inline__, __nodebug__))
+_bit_scan_forward(int __A) {
+ return __builtin_ia32_bit_scan_forward(__A);
+}
+
+/* __bit_scan_reverse */
+static __inline__ int __attribute__((__always_inline__, __nodebug__))
+_bit_scan_reverse(int __A) {
+ return __builtin_ia32_bit_scan_reverse(__A);
+}
+
 #ifdef __x86_64__
 static __inline__ int __attribute__((__always_inline__, __nodebug__, 
__target__("rdrnd")))
 _rdrand64_step(unsigned long long *__p)
@@ -227,6 +239,7 @@ _writegsbase_u64(unsigned long long __V)
 {
   return __builtin_ia32_wrgsbase64(__V);
 }
+
 #endif
 #endif /* __FSGSBASE__ */
 

Modified: cfe/trunk/test/CodeGen/avx-builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/avx-builtins.c?rev=271387&r1=271386&r2=271387&view=diff
==
--- cfe/trunk/test/CodeGen/avx-builtins.c (original)
+++ cfe/trunk/test/CodeGen/avx-builtins.c Wed Jun  1 07:21:00 2016
@@ -1385,3 +1385,24 @@ void test_mm256_zeroupp

[clang-tools-extra] r271385 - [include-fixer] use includer of .inc header to be the file path of a symbol from .inc header.

2016-06-01 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Wed Jun  1 07:01:06 2016
New Revision: 271385

URL: http://llvm.org/viewvc/llvm-project?rev=271385&view=rev
Log:
[include-fixer] use includer of .inc header to be the file path of a symbol 
from .inc header.

Summary: added PathConfig.cpp and use includer of .inc header to be the file 
path of a symbol from .inc header.

Reviewers: bkramer

Subscribers: cfe-commits

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

Added:
clang-tools-extra/trunk/include-fixer/find-all-symbols/PathConfig.cpp
clang-tools-extra/trunk/include-fixer/find-all-symbols/PathConfig.h
Modified:
clang-tools-extra/trunk/include-fixer/find-all-symbols/CMakeLists.txt
clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllMacros.cpp
clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbols.cpp

clang-tools-extra/trunk/unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp

Modified: clang-tools-extra/trunk/include-fixer/find-all-symbols/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/find-all-symbols/CMakeLists.txt?rev=271385&r1=271384&r2=271385&view=diff
==
--- clang-tools-extra/trunk/include-fixer/find-all-symbols/CMakeLists.txt 
(original)
+++ clang-tools-extra/trunk/include-fixer/find-all-symbols/CMakeLists.txt Wed 
Jun  1 07:01:06 2016
@@ -7,6 +7,7 @@ add_clang_library(findAllSymbols
   FindAllSymbolsAction.cpp
   FindAllMacros.cpp
   HeaderMapCollector.cpp
+  PathConfig.cpp
   PragmaCommentHandler.cpp
   STLPostfixHeaderMap.cpp
   SymbolInfo.cpp

Modified: 
clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllMacros.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllMacros.cpp?rev=271385&r1=271384&r2=271385&view=diff
==
--- clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllMacros.cpp 
(original)
+++ clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllMacros.cpp 
Wed Jun  1 07:01:06 2016
@@ -9,6 +9,7 @@
 
 #include "FindAllMacros.h"
 #include "HeaderMapCollector.h"
+#include "PathConfig.h"
 #include "SymbolInfo.h"
 #include "clang/Basic/IdentifierTable.h"
 #include "clang/Basic/SourceManager.h"
@@ -21,21 +22,11 @@ namespace find_all_symbols {
 void FindAllMacros::MacroDefined(const Token &MacroNameTok,
  const MacroDirective *MD) {
   SourceLocation Loc = SM->getExpansionLoc(MacroNameTok.getLocation());
-  if (Loc.isInvalid() || SM->isInMainFile(Loc))
-return;
-
-  llvm::StringRef FilePath = SM->getFilename(Loc);
-  if (FilePath.empty())
-return;
-
-  // If Collector is not nullptr, check pragma remapping header.
-  FilePath = Collector ? Collector->getMappedHeader(FilePath) : FilePath;
-
-  SmallString<256> CleanedFilePath = FilePath;
-  llvm::sys::path::remove_dots(CleanedFilePath, /*remove_dot_dot=*/true);
+  std::string FilePath = getIncludePath(*SM, Loc, Collector);
+  if (FilePath.empty()) return;
 
   SymbolInfo Symbol(MacroNameTok.getIdentifierInfo()->getName(),
-SymbolInfo::SymbolKind::Macro, CleanedFilePath,
+SymbolInfo::SymbolKind::Macro, FilePath,
 SM->getSpellingLineNumber(Loc), {});
 
   Reporter->reportSymbol(SM->getFileEntryForID(SM->getMainFileID())->getName(),

Modified: 
clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbols.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbols.cpp?rev=271385&r1=271384&r2=271385&view=diff
==
--- clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbols.cpp 
(original)
+++ clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbols.cpp 
Wed Jun  1 07:01:06 2016
@@ -9,6 +9,7 @@
 
 #include "FindAllSymbols.h"
 #include "HeaderMapCollector.h"
+#include "PathConfig.h"
 #include "SymbolInfo.h"
 #include "clang/AST/Decl.h"
 #include "clang/AST/DeclCXX.h"
@@ -92,17 +93,11 @@ CreateSymbolInfo(const NamedDecl *ND, co
  << ") has invalid declaration location.";
 return llvm::None;
   }
-  llvm::StringRef FilePath = SM.getFilename(Loc);
-  if (FilePath.empty())
-return llvm::None;
-
-  // If Collector is not nullptr, check pragma remapping header.
-  FilePath = Collector ? Collector->getMappedHeader(FilePath) : FilePath;
 
-  SmallString<256> CleanedFilePath = FilePath;
-  llvm::sys::path::remove_dots(CleanedFilePath, /*remove_dot_dot=*/true);
+  std::string FilePath = getIncludePath(SM, Loc, Collector);
+  if (FilePath.empty()) return llvm::None;
 
-  return SymbolInfo(ND->getNameAsString(), Type, CleanedFilePath,
+  return SymbolInfo(ND->getNameAsString(), Type, FilePath,
 SM.getExpansionLineNumber(Loc), GetContexts(ND)

Re: [PATCH] D20858: [clang-format] make header guard identification stricter in header insertion.

2016-06-01 Thread Eric Liu via cfe-commits
ioeric updated this revision to Diff 59206.
ioeric added a comment.

- Use iterator looping to simplify code.


http://reviews.llvm.org/D20858

Files:
  lib/Format/Format.cpp
  unittests/Format/CleanupTest.cpp

Index: unittests/Format/CleanupTest.cpp
===
--- unittests/Format/CleanupTest.cpp
+++ unittests/Format/CleanupTest.cpp
@@ -537,6 +537,34 @@
   EXPECT_EQ(Expected, formatAndApply(Code, Replaces));
 }
 
+TEST_F(CleanUpReplacementsTest, DontJustInsertAfterRandomDefine) {
+  std::string Code = "#define X 1";
+  std::string Expected = "#include \n"
+ "#define X 1";
+  tooling::Replacements Replaces = {createInsertion("#include ")};
+  EXPECT_EQ(Expected, apply(Code, Replaces));
+}
+
+TEST_F(CleanUpReplacementsTest, InsertAfterHeaderGuard) {
+  std::string Code = "#ifndef X_H\n"
+ "#define X_H\n";
+  std::string Expected = "#ifndef X_H\n"
+ "#define X_H\n"
+ "#include \n";
+  tooling::Replacements Replaces = {createInsertion("#include ")};
+  EXPECT_EQ(Expected, apply(Code, Replaces));
+}
+
+TEST_F(CleanUpReplacementsTest, DontInsertAfterNonMatchedHeaderGuard) {
+  std::string Code = "#ifndef X_H\n"
+ "#define Y_H";
+  std::string Expected = "#include \n"
+ "#ifndef X_H\n"
+ "#define Y_H";
+  tooling::Replacements Replaces = {createInsertion("#include ")};
+  EXPECT_EQ(Expected, apply(Code, Replaces));
+}
+
 } // end namespace
 } // end namespace format
 } // end namespace clang
Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -1469,7 +1469,8 @@
   std::inserter(Result, Result.begin()));
 
   llvm::Regex IncludeRegex(IncludeRegexPattern);
-  llvm::Regex DefineRegex(R"(^[\t\ ]*#[\t\ ]*define[\t\ ]*[^\\]*$)");
+  llvm::Regex IfNDefRegex(R"(^[\t\ ]*#[\t\ ]*ifndef[\t\ ]*([^\\]*)$)");
+  llvm::Regex DefineRegex(R"(^[\t\ ]*#[\t\ ]*define[\t\ ]*([^\\]*)$)");
   SmallVector Matches;
 
   StringRef FileName = Replaces.begin()->getFilePath();
@@ -1487,7 +1488,9 @@
   int AfterHeaderGuard = 0;
   SmallVector Lines;
   Code.split(Lines, '\n');
-  for (auto Line : Lines) {
+  for (auto I = Lines.begin(), B = Lines.begin(), E = Lines.end(); I != E;
+   ++I) {
+StringRef Line = *I;
 if (IncludeRegex.match(Line, &Matches)) {
   StringRef IncludeName = Matches[2];
   int Category = Categories.getIncludePriority(
@@ -1497,9 +1500,13 @@
 FirstIncludeOffset = Offset;
 }
 Offset += Line.size() + 1;
-// FIXME: make header guard matching stricter, e.g. consider #ifndef.
-if (AfterHeaderGuard == 0 && DefineRegex.match(Line))
-  AfterHeaderGuard = Offset;
+if (FirstIncludeOffset < 0 && AfterHeaderGuard == 0 && I != B &&
+DefineRegex.match(Line, &Matches)) {
+  StringRef DefineName = Matches[1];
+  if (IfNDefRegex.match(*std::prev(I), &Matches) &&
+  DefineName == Matches[1])
+AfterHeaderGuard = Offset;
+}
   }
 
   // Populate CategoryEndOfssets:


Index: unittests/Format/CleanupTest.cpp
===
--- unittests/Format/CleanupTest.cpp
+++ unittests/Format/CleanupTest.cpp
@@ -537,6 +537,34 @@
   EXPECT_EQ(Expected, formatAndApply(Code, Replaces));
 }
 
+TEST_F(CleanUpReplacementsTest, DontJustInsertAfterRandomDefine) {
+  std::string Code = "#define X 1";
+  std::string Expected = "#include \n"
+ "#define X 1";
+  tooling::Replacements Replaces = {createInsertion("#include ")};
+  EXPECT_EQ(Expected, apply(Code, Replaces));
+}
+
+TEST_F(CleanUpReplacementsTest, InsertAfterHeaderGuard) {
+  std::string Code = "#ifndef X_H\n"
+ "#define X_H\n";
+  std::string Expected = "#ifndef X_H\n"
+ "#define X_H\n"
+ "#include \n";
+  tooling::Replacements Replaces = {createInsertion("#include ")};
+  EXPECT_EQ(Expected, apply(Code, Replaces));
+}
+
+TEST_F(CleanUpReplacementsTest, DontInsertAfterNonMatchedHeaderGuard) {
+  std::string Code = "#ifndef X_H\n"
+ "#define Y_H";
+  std::string Expected = "#include \n"
+ "#ifndef X_H\n"
+ "#define Y_H";
+  tooling::Replacements Replaces = {createInsertion("#include ")};
+  EXPECT_EQ(Expected, apply(Code, Replaces));
+}
+
 } // end namespace
 } // end namespace format
 } // end namespace clang
Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -1469,7 +1469,8 @@
   std::inserter(Result, Result.begin()));
 
   llvm::Regex IncludeRegex(IncludeRegexPattern);
-  llvm::Regex DefineRegex(R"(^[\t\ ]*#[\t\ ]*define[\t\ ]*[^\\]*$)");
+  llvm::Regex IfN

Re: [PATCH] D20853: [clang-tidy] misc-macro-parentheses: Don't insert parentheses in variable declarations. Fixes bugzilla 26273

2016-06-01 Thread Daniel Marjamäki via cfe-commits
danielmarjamaki removed rL LLVM as the repository for this revision.
danielmarjamaki updated this revision to Diff 59208.
danielmarjamaki added a comment.

Updated diff. Now also handles bugzilla 27399.


http://reviews.llvm.org/D20853

Files:
  clang-tidy/misc/MacroParenthesesCheck.cpp
  test/clang-tidy/misc-macro-parentheses.cpp

Index: test/clang-tidy/misc-macro-parentheses.cpp
===
--- test/clang-tidy/misc-macro-parentheses.cpp
+++ test/clang-tidy/misc-macro-parentheses.cpp
@@ -8,6 +8,8 @@
 // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: macro argument should be enclosed in parentheses [misc-macro-parentheses]
 #define BAD4(x)   ((unsigned char)(x & 0xff))
 // CHECK-MESSAGES: :[[@LINE-1]]:44: warning: macro argument should be enclosed in parentheses [misc-macro-parentheses]
+#define BAD5(X)   A*B=(C*)X+2
+// CHECK-MESSAGES: :[[@LINE-1]]:35: warning: macro argument should be enclosed in parentheses [misc-macro-parentheses]
 
 #define GOOD1 1
 #define GOOD2 (1+2)
@@ -39,6 +41,8 @@
 #define GOOD28(x) namespace x {int b;}
 #define GOOD29(...)   std::cout << __VA_ARGS__;
 #define GOOD30(args...)   std::cout << args;
+#define GOOD31(X) A*X=2
+#define GOOD32(X) std::vector
 
 // These are allowed for now..
 #define MAYBE1*12.34
Index: clang-tidy/misc/MacroParenthesesCheck.cpp
===
--- clang-tidy/misc/MacroParenthesesCheck.cpp
+++ clang-tidy/misc/MacroParenthesesCheck.cpp
@@ -19,8 +19,7 @@
 namespace {
 class MacroParenthesesPPCallbacks : public PPCallbacks {
 public:
-  MacroParenthesesPPCallbacks(Preprocessor *PP,
-  MacroParenthesesCheck *Check)
+  MacroParenthesesPPCallbacks(Preprocessor *PP, MacroParenthesesCheck *Check)
   : PP(PP), Check(Check) {}
 
   void MacroDefined(const Token &MacroNameTok,
@@ -67,8 +66,46 @@
tok::amp, tok::pipe, tok::caret);
 }
 
+/// Is given Token a keyword that is used in variable declarations?
+static bool isVarDeclKeyword(const Token &T) {
+  return T.isOneOf(tok::kw_bool, tok::kw_char, tok::kw_short, tok::kw_int,
+   tok::kw_long, tok::kw_float, tok::kw_double, tok::kw_const,
+   tok::kw_enum, tok::kw_inline, tok::kw_static, tok::kw_struct,
+   tok::kw_signed, tok::kw_unsigned);
+}
+
+/// Is there a possible variable declaration at Tok?
+static bool possibleVarDecl(const MacroInfo *MI, const Token *Tok) {
+  if (Tok == MI->tokens_end())
+return false;
+
+  // If we see int/short/struct etc just assume this is a variable declaration
+  if (isVarDeclKeyword(*Tok))
+return true;
+
+  // Variable declarations start with identifier or coloncolon
+  if (!Tok->isOneOf(tok::identifier, tok::raw_identifier, tok::coloncolon))
+return false;
+
+  // Skip possible types, etc
+  while (
+  Tok != MI->tokens_end() &&
+  (Tok->isOneOf(tok::identifier, tok::raw_identifier, tok::coloncolon,
+tok::star, tok::amp, tok::ampamp, tok::less, tok::greater)))
+Tok++;
+
+  // Return true for possible variable declarations
+  return Tok == MI->tokens_end() ||
+ Tok->isOneOf(tok::equal, tok::semi, tok::l_square, tok::l_paren) ||
+ isVarDeclKeyword(*Tok);
+}
+
 void MacroParenthesesPPCallbacks::replacementList(const Token &MacroNameTok,
   const MacroInfo *MI) {
+  // Make sure macro replacement isn't a variable declaration
+  if (possibleVarDecl(MI, MI->tokens_begin()))
+return;
+
   // Count how deep we are in parentheses/braces/squares.
   int Count = 0;
 
@@ -117,6 +154,9 @@
 
 void MacroParenthesesPPCallbacks::argument(const Token &MacroNameTok,
const MacroInfo *MI) {
+  
+  // Skip variable declaration
+  bool VarDecl = possibleVarDecl(MI, MI->tokens_begin());
 
   for (auto TI = MI->tokens_begin(), TE = MI->tokens_end(); TI != TE; ++TI) {
 // First token.
@@ -132,6 +172,13 @@
 
 const Token &Tok = *TI;
 
+// There should not be extra parentheses in possible variable declaration.
+if (VarDecl) {
+  if (Tok.isOneOf(tok::equal, tok::semi, tok::l_square, tok::l_paren))
+VarDecl = false;
+  continue;
+}
+
 // Only interested in identifiers.
 if (!Tok.isOneOf(tok::identifier, tok::raw_identifier))
   continue;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D20859: [X86][SSE] Replace (V)CVTTPS2DQ and VCVTTPD2DQ truncating (round to zero) f32/f64 to i32 with generic IR (clang)

2016-06-01 Thread Simon Pilgrim via cfe-commits
RKSimon created this revision.
RKSimon added reviewers: ab, mkuper, craig.topper, spatel, andreadb.
RKSimon added a subscriber: cfe-commits.
RKSimon set the repository for this revision to rL LLVM.

The 'cvtt' truncation (round to zero) conversions can be safely represented as 
generic __builtin_convertvector (fptosi) calls instead of x86 intrinsics.

We already do this (implicitly) for the scalar equivalents.

Note: I looked at updating _mm_cvttpd_epi32 as well but this still requires a 
lot more backend work to correctly lower (both for debug and optimized builds).

Repository:
  rL LLVM

http://reviews.llvm.org/D20859

Files:
  include/clang/Basic/BuiltinsX86.def
  lib/Headers/avxintrin.h
  lib/Headers/emmintrin.h
  test/CodeGen/avx-builtins.c
  test/CodeGen/builtins-x86.c
  test/CodeGen/sse2-builtins.c

Index: test/CodeGen/sse2-builtins.c
===
--- test/CodeGen/sse2-builtins.c
+++ test/CodeGen/sse2-builtins.c
@@ -533,7 +533,7 @@
 
 __m128i test_mm_cvttps_epi32(__m128 A) {
   // CHECK-LABEL: test_mm_cvttps_epi32
-  // CHECK: call <4 x i32> @llvm.x86.sse2.cvttps2dq(<4 x float> %{{.*}})
+  // CHECK: fptosi <4 x float> %{{.*}} to <4 x i32>
   return _mm_cvttps_epi32(A);
 }
 
Index: test/CodeGen/builtins-x86.c
===
--- test/CodeGen/builtins-x86.c
+++ test/CodeGen/builtins-x86.c
@@ -335,7 +335,6 @@
   tmp_LLi = __builtin_ia32_cvtsd2si64(tmp_V2d);
 #endif
   tmp_V4i = __builtin_ia32_cvtps2dq(tmp_V4f);
-  tmp_V4i = __builtin_ia32_cvttps2dq(tmp_V4f);
   (void) __builtin_ia32_clflush(tmp_vCp);
   (void) __builtin_ia32_lfence();
   (void) __builtin_ia32_mfence();
@@ -415,9 +414,7 @@
   tmp_V8f = __builtin_ia32_cvtdq2ps256(tmp_V8i);
   tmp_V4f = __builtin_ia32_cvtpd2ps256(tmp_V4d);
   tmp_V8i = __builtin_ia32_cvtps2dq256(tmp_V8f);
-  tmp_V4i = __builtin_ia32_cvttpd2dq256(tmp_V4d);
   tmp_V4i = __builtin_ia32_cvtpd2dq256(tmp_V4d);
-  tmp_V8i = __builtin_ia32_cvttps2dq256(tmp_V8f);
   tmp_V4d = __builtin_ia32_vperm2f128_pd256(tmp_V4d, tmp_V4d, 0x7);
   tmp_V8f = __builtin_ia32_vperm2f128_ps256(tmp_V8f, tmp_V8f, 0x7);
   tmp_V8i = __builtin_ia32_vperm2f128_si256(tmp_V8i, tmp_V8i, 0x7);
Index: test/CodeGen/avx-builtins.c
===
--- test/CodeGen/avx-builtins.c
+++ test/CodeGen/avx-builtins.c
@@ -286,13 +286,13 @@
 
 __m128i test_mm256_cvttpd_epi32(__m256d A) {
   // CHECK-LABEL: test_mm256_cvttpd_epi32
-  // CHECK: call <4 x i32> @llvm.x86.avx.cvtt.pd2dq.256(<4 x double> %{{.*}})
+  // CHECK: fptosi <4 x double> %{{.*}} to <4 x i32>
   return _mm256_cvttpd_epi32(A);
 }
 
 __m256i test_mm256_cvttps_epi32(__m256 A) {
   // CHECK-LABEL: test_mm256_cvttps_epi32
-  // CHECK: call <8 x i32> @llvm.x86.avx.cvtt.ps2dq.256(<8 x float> %{{.*}})
+  // CHECK: fptosi <8 x float> %{{.*}} to <8 x i32>
   return _mm256_cvttps_epi32(A);
 }
 
Index: lib/Headers/emmintrin.h
===
--- lib/Headers/emmintrin.h
+++ lib/Headers/emmintrin.h
@@ -1744,7 +1744,7 @@
 static __inline__ __m128i __DEFAULT_FN_ATTRS
 _mm_cvttps_epi32(__m128 __a)
 {
-  return (__m128i)__builtin_ia32_cvttps2dq((__v4sf)__a);
+  return (__m128i)__builtin_convertvector((__v4sf)__a, __v4si);
 }
 
 /// \brief Returns a vector of [4 x i32] where the lowest element is the input
Index: lib/Headers/avxintrin.h
===
--- lib/Headers/avxintrin.h
+++ lib/Headers/avxintrin.h
@@ -2108,7 +2108,7 @@
 static __inline __m128i __DEFAULT_FN_ATTRS
 _mm256_cvttpd_epi32(__m256d __a)
 {
-  return (__m128i)__builtin_ia32_cvttpd2dq256((__v4df) __a);
+  return (__m128i)__builtin_convertvector((__v4df) __a, __v4si);
 }
 
 static __inline __m128i __DEFAULT_FN_ATTRS
@@ -2120,7 +2120,7 @@
 static __inline __m256i __DEFAULT_FN_ATTRS
 _mm256_cvttps_epi32(__m256 __a)
 {
-  return (__m256i)__builtin_ia32_cvttps2dq256((__v8sf) __a);
+  return (__m256i)__builtin_convertvector((__v8sf) __a, __v8si);
 }
 
 /* Vector replicate */
Index: include/clang/Basic/BuiltinsX86.def
===
--- include/clang/Basic/BuiltinsX86.def
+++ include/clang/Basic/BuiltinsX86.def
@@ -335,7 +335,6 @@
 TARGET_BUILTIN(__builtin_ia32_cvtsd2si, "iV2d", "", "sse2")
 TARGET_BUILTIN(__builtin_ia32_cvtsd2si64, "LLiV2d", "", "sse2")
 TARGET_BUILTIN(__builtin_ia32_cvtps2dq, "V4iV4f", "", "sse2")
-TARGET_BUILTIN(__builtin_ia32_cvttps2dq, "V4iV4f", "", "sse2")
 TARGET_BUILTIN(__builtin_ia32_clflush, "vvC*", "", "sse2")
 TARGET_BUILTIN(__builtin_ia32_lfence, "v", "", "sse2")
 TARGET_BUILTIN(__builtin_ia32_mfence, "v", "", "sse2")
@@ -458,9 +457,7 @@
 TARGET_BUILTIN(__builtin_ia32_cvtdq2ps256, "V8fV8i", "", "avx")
 TARGET_BUILTIN(__builtin_ia32_cvtpd2ps256, "V4fV4d", "", "avx")
 TARGET_BUILTIN(__builtin_ia32_cvtps2dq256, "V8iV8f", "", "avx")
-TARGET_BUILTIN(__builtin_ia32_cvttpd2dq256

Re: [PATCH] D19201: [clang-tidy] misc-throw-with-noexcept

2016-06-01 Thread Piotr Padlewski via cfe-commits
Prazek added inline comments.


Comment at: clang-tidy/misc/ThrowWithNoexceptCheck.cpp:25
@@ +24,3 @@
+  Finder->addMatcher(
+  cxxThrowExpr(stmt(hasAncestor(functionDecl(isNoThrow()).bind("func"
+  .bind("throw"),

you can use forFunction instead of hasAncestor(functionDecl(
cxxThrowExpr(stmt(forFunction(isNoThrow() or 
cxxThrowExpr(stmt(forFunction(functionDecl(isNoThrow(
you can even try to remove stmt.


Also add test case

  void getFunction() noexcept {
   struct X { 
static void inner()
{
throw 42;
}
   }; 
  }



Comment at: clang-tidy/misc/ThrowWithNoexceptCheck.cpp:130
@@ +129,3 @@
+  const auto *Throw = Result.Nodes.getNodeAs("throw");
+  diag(Throw->getLocStart(), "throw in function declared no-throw");
+  for (auto Redecl : Function->redecls()) {

add new line after this line


Comment at: clang-tidy/misc/ThrowWithNoexceptCheck.cpp:131
@@ +130,3 @@
+  diag(Throw->getLocStart(), "throw in function declared no-throw");
+  for (auto Redecl : Function->redecls()) {
+SourceRange NoExceptRange =

add some new line


Comment at: clang-tidy/misc/ThrowWithNoexceptCheck.cpp:134
@@ +133,3 @@
+FindNoExceptRange(*Result.Context, *Result.SourceManager, *Redecl);
+if (NoExceptRange.isValid()) {
+  diag(NoExceptRange.getBegin(), "In function declared no-throw here:")

if one one the redecl won't be valid, then you can't change any of them. I 
guess you should accumulate them in 
llvm::SmallVector whilie checking if they are valid. If all of 
them will be valid then perform fix on all of them.


Comment at: clang-tidy/misc/ThrowWithNoexceptCheck.cpp:135
@@ +134,3 @@
+if (NoExceptRange.isValid()) {
+  diag(NoExceptRange.getBegin(), "In function declared no-throw here:")
+  << FixItHint::CreateRemoval(CharSourceRange::getCharRange(

I think it would be better to tell about declaration only in one place (where 
is the definition)

Also, I would use "note:" instead of warning here. (passing  
DiagnosticIDs::Level::Note as third argument)
You can also see how to do it here:
http://reviews.llvm.org/D18821

Also I think "no-throw function declared here" would be better


Repository:
  rL LLVM

http://reviews.llvm.org/D19201



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


[PATCH] D20861: [AVX512] add missing integer to float conversion

2016-06-01 Thread Asaf Badouh via cfe-commits
AsafBadouh created this revision.
AsafBadouh added reviewers: m_zuckerman, opaparo, igorb, delena, craig.topper.
AsafBadouh added a subscriber: cfe-commits.
AsafBadouh set the repository for this revision to rL LLVM.

I used SSE intrinsics to implement some of the conversion.
for example:

```

#define _mm_cvtss_i32 _mm_cvtss_si32

```
Backend will generate avx512 asm in cases we compile with avx512f flag.


Repository:
  rL LLVM

http://reviews.llvm.org/D20861

Files:
  tools/clang/lib/Headers/avx512fintrin.h
  tools/clang/test/CodeGen/avx512f-builtins.c

Index: tools/clang/lib/Headers/avx512fintrin.h
===
--- tools/clang/lib/Headers/avx512fintrin.h
+++ tools/clang/lib/Headers/avx512fintrin.h
@@ -9267,6 +9267,33 @@
  (__v4sf)_mm_setzero_ps(), \
  (__mmask8)(U), (int)(R)); })
 
+static __inline__ __m128 __DEFAULT_FN_ATTRS
+_mm_mask_cvtsd_ss (__m128 W, __mmask8 U, __m128 A, __m128d B)
+{
+  return __builtin_ia32_cvtsd2ss_round_mask ((__v4sf)(A),
+ (__v2df)(B),
+ (__v4sf)(W), 
+ (__mmask8)(U), _MM_FROUND_CUR_DIRECTION);
+}
+
+static __inline__ __m128 __DEFAULT_FN_ATTRS
+_mm_maskz_cvtsd_ss (__mmask8 U, __m128 A, __m128d B)
+{
+  return __builtin_ia32_cvtsd2ss_round_mask ((__v4sf)(A),
+ (__v2df)(B),
+ (__v4sf)_mm_setzero_ps(), 
+ (__mmask8)(U), _MM_FROUND_CUR_DIRECTION);
+}
+
+#define _mm_cvtss_i32 _mm_cvtss_si32
+#define _mm_cvtss_i64 _mm_cvtss_si64
+#define _mm_cvtsd_i32 _mm_cvtsd_si32
+#define _mm_cvtsd_i64 _mm_cvtsd_si64
+#define _mm_cvti32_sd _mm_cvtsi32_sd
+#define _mm_cvti64_sd _mm_cvtsi64_sd
+#define _mm_cvti32_ss _mm_cvtsi32_ss
+#define _mm_cvti64_ss _mm_cvtsi64_ss
+
 #define _mm_cvt_roundi64_sd(A, B, R) __extension__ ({ \
   (__m128d)__builtin_ia32_cvtsi2sd64((__v2df)(__m128d)(A), (long long)(B), \
  (int)(R)); })
@@ -9308,6 +9335,24 @@
   (__mmask8)(U), (int)(R)); })
 
 static __inline__ __m128d __DEFAULT_FN_ATTRS
+_mm_mask_cvtss_sd (__m128d W, __mmask8 U, __m128d A, __m128 B)
+{
+  return __builtin_ia32_cvtss2sd_round_mask((__v2df)(A),
+  (__v4sf)(B),
+  (__v2df)(W),
+  (__mmask8)(U), _MM_FROUND_CUR_DIRECTION); 
+}
+
+static __inline__ __m128d __DEFAULT_FN_ATTRS
+_mm_maskz_cvtss_sd (__mmask8 U, __m128d A, __m128 B)
+{
+  return __builtin_ia32_cvtss2sd_round_mask((__v2df)(A),
+  (__v4sf)(B),
+  (__v2df)_mm_setzero_pd(), 
+  (__mmask8)(U), _MM_FROUND_CUR_DIRECTION); 
+}
+
+static __inline__ __m128d __DEFAULT_FN_ATTRS
 _mm_cvtu32_sd (__m128d __A, unsigned __B)
 {
   return (__m128d) __builtin_ia32_cvtusi2sd32 ((__v2df) __A, __B);
Index: tools/clang/test/CodeGen/avx512f-builtins.c
===
--- tools/clang/test/CodeGen/avx512f-builtins.c
+++ tools/clang/test/CodeGen/avx512f-builtins.c
@@ -7202,3 +7202,80 @@
 return _mm512_setr_ps( __A, __B, __C, __D, __E, __F, __G, __H,
   __I, __J, __K, __L, __M, __N, __O, __P);
 }
+
+int test_mm_cvtss_i32(__m128 A) {
+  // CHECK-LABEL: test_mm_cvtss_i32
+  // CHECK: call i32 @llvm.x86.sse.cvtss2si(<4 x float> %{{.*}})
+  return _mm_cvtss_i32(A);
+}
+
+long long test_mm_cvtss_i64(__m128 A) {
+  // CHECK-LABEL: test_mm_cvtss_i64
+  // CHECK: call i64 @llvm.x86.sse.cvtss2si64(<4 x float> %{{.*}})
+  return _mm_cvtss_i64(A);
+}
+
+__m128d test_mm_cvti32_sd(__m128d A, int B) {
+  // CHECK-LABEL: test_mm_cvti32_sd
+  // CHECK: sitofp i32 %{{.*}} to double
+  // CHECK: insertelement <2 x double> %{{.*}}, double %{{.*}}, i32 0
+  return _mm_cvti32_sd(A, B);
+}
+
+__m128d test_mm_cvti64_sd(__m128d A, long long B) {
+  // CHECK-LABEL: test_mm_cvti64_sd
+  // CHECK: sitofp i64 %{{.*}} to double
+  // CHECK: insertelement <2 x double> %{{.*}}, double %{{.*}}, i32 0
+  return _mm_cvti64_sd(A, B);
+}
+
+__m128 test_mm_cvti32_ss(__m128 A, int B) {
+  // CHECK-LABEL: test_mm_cvti32_ss
+  // CHECK: sitofp i32 %{{.*}} to float
+  // CHECK: insertelement <4 x float> %{{.*}}, float %{{.*}}, i32 0
+  return _mm_cvti32_ss(A, B);
+}
+
+__m128 test_mm_cvti64_ss(__m128 A, long long B) {
+  // CHECK-LABEL: test_mm_cvti64_ss
+  // CHECK: sitofp i64 %{{.*}} to float
+  // CHECK: insertelement <4 x float> %{{.*}}, float %{{.*}}, i32 0
+  return _mm_cvti64_ss(A, B);
+}
+
+int test_mm_cvtsd_i32(__m128d A) {
+  // CHECK-LABEL: test_mm_cvtsd_i32
+  // CHECK: call i32 @ll

Re: [PATCH] D20858: [clang-format] make header guard identification stricter in header insertion.

2016-06-01 Thread Daniel Jasper via cfe-commits
djasper added inline comments.


Comment at: lib/Format/Format.cpp:1472
@@ -1471,2 +1471,3 @@
   llvm::Regex IncludeRegex(IncludeRegexPattern);
-  llvm::Regex DefineRegex(R"(^[\t\ ]*#[\t\ ]*define[\t\ ]*[^\\]*$)");
+  llvm::Regex IfNDefRegex(R"(^[\t\ ]*#[\t\ ]*ifndef[\t\ ]*([^\\]*)$)");
+  llvm::Regex DefineRegex(R"(^[\t\ ]*#[\t\ ]*define[\t\ ]*([^\\]*)$)");

I think there is too much in the regex group here. If there are trailing 
comments on the #ifndef or #define lines, this should still work. Also, there 
might actually be empty lines or comment lines in-between the two. I would for 
now just check that there:
- Is no non-comment line before the first #ifndef
- That there is a #ifndef
- That the next non-comment line after the #ifndef is a #define

We can refine more if necessary.

I think we should be conservative here as this should only really ever affect 
.cc files (or else the header guard would be there and identified correctly) 
that don't have any #includes (or put them after unrelated #defines). So, we 
have to weigh this case being so rare against incorrectly identifying weird 
header guards in headers (which IMO might be more common).


http://reviews.llvm.org/D20858



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


[libcxxabi] r271388 - Missed part of D16545 (static lib testing)

2016-06-01 Thread Ben Craig via cfe-commits
Author: bcraig
Date: Wed Jun  1 07:50:30 2016
New Revision: 271388

URL: http://llvm.org/viewvc/llvm-project?rev=271388&view=rev
Log:
Missed part of D16545 (static lib testing)

http://reviews.llvm.org/D16545

Modified:
libcxxabi/trunk/CMakeLists.txt

Modified: libcxxabi/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/CMakeLists.txt?rev=271388&r1=271387&r2=271388&view=diff
==
--- libcxxabi/trunk/CMakeLists.txt (original)
+++ libcxxabi/trunk/CMakeLists.txt Wed Jun  1 07:50:30 2016
@@ -115,9 +115,9 @@ option(LIBCXXABI_ENABLE_WERROR "Fail and
 option(LIBCXXABI_USE_LLVM_UNWINDER "Build and use the LLVM unwinder." OFF)
 option(LIBCXXABI_ENABLE_THREADS "Build with threads enabled" ON)
 option(LIBCXXABI_HAS_PTHREAD_API "Ignore auto-detection and force use of 
pthread API" OFF)
-set(LIBCXXABI_GCC_TOOLCHAIN "" CACHE STRING "GCC toolchain for cross 
compiling.")
-set(LIBCXXABI_SYSROOT "" CACHE STRING "Sysroot for cross compiling.")
-set(LIBCXXABI_LIBCXX_LIBRARY_PATH "" CACHE STRING "The path to libc++ 
library.")
+set(LIBCXXABI_GCC_TOOLCHAIN "" CACHE PATH "GCC toolchain for cross compiling.")
+set(LIBCXXABI_SYSROOT "" CACHE PATH "Sysroot for cross compiling.")
+set(LIBCXXABI_LIBCXX_LIBRARY_PATH "" CACHE PATH "The path to libc++ library.")
 
 # Default to building a shared library so that the default options still test
 # the libc++abi that is being built. There are two problems with testing a
@@ -184,6 +184,13 @@ set(LIBCXXABI_LIBRARY_DIR ${CMAKE_BINARY
 set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${LIBCXXABI_LIBRARY_DIR})
 set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${LIBCXXABI_LIBRARY_DIR})
 
+# By default, for non-standalone builds, libcxx and libcxxabi share a library
+# directory.
+if (NOT LIBCXXABI_LIBCXX_LIBRARY_PATH)
+  set(LIBCXXABI_LIBCXX_LIBRARY_PATH "${LIBCXXABI_LIBRARY_DIR}" CACHE PATH
+  "The path to libc++ library.")
+endif ()
+
 
#===
 # Setup Compiler Flags
 
#===
@@ -358,14 +365,16 @@ endif ()
 # soname, etc...
 add_subdirectory(src)
 
-if(NOT LIBCXXABI_ENABLE_SHARED)
-  # TODO: Fix the libc++ cmake files so that libc++abi can be statically 
linked.
-  # As it is now, libc++ will prefer linking against a dynamic libc++abi in the
-  # system library paths over a static libc++abi in the out directory. This
-  # would test the system library rather than the one we just built, which 
isn't
-  # very helpful.
-  message(WARNING "The libc++abi tests are currently only valid when "
-  "LIBCXXABI_ENABLE_SHARED is on, no check target will be "
+if (LIBCXXABI_BUILT_STANDALONE AND NOT LIBCXXABI_ENABLE_SHARED)
+  # We can't reasonably test the system C++ library with a static libc++abi.
+  # We either need to be able to replace libc++abi at run time (with a shared
+  # libc++abi), or we need to be able to replace the C++ runtime (with a non-
+  # standalone build).
+  message(WARNING "The libc++abi tests aren't valid when libc++abi is built "
+  "standalone (i.e. outside of llvm/projects/libcxxabi ) and "
+  "is built without a shared library.  Either build a shared "
+  "library, build libc++abi at the same time as you build "
+  "libc++, or do without testing.  No check target will be "
   "available!")
 else()
   add_subdirectory(test)


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


Re: [PATCH] D16545: [libcxxabi] Enable testing for static libc++abi

2016-06-01 Thread Ben Craig via cfe-commits
bcraig added a comment.

In http://reviews.llvm.org/D16545#444869, @bcraig wrote:

> In http://reviews.llvm.org/D16545#444854, @rmaprath wrote:
>
> > Perhaps you forgot to commit that file?
>
>
> Hrm, you're right, it didn't go in.  I'll get it in tomorrow morning.


Should be in now.  r271388.


http://reviews.llvm.org/D16545



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


Re: [PATCH] D19201: [clang-tidy] misc-throw-with-noexcept

2016-06-01 Thread Piotr Padlewski via cfe-commits
Prazek added inline comments.


Comment at: clang-tidy/misc/ThrowWithNoexceptCheck.cpp:32
@@ +31,3 @@
+// token including trailing whitespace.
+static SourceRange FindToken(const SourceManager &Sources, LangOptions 
LangOpts,
+ SourceLocation StartLoc, SourceLocation EndLoc,

function in llvm starts with lower case


Comment at: clang-tidy/misc/ThrowWithNoexceptCheck.cpp:57
@@ +56,3 @@
+// Returns the range of the expression including trailing whitespace.
+static SourceRange ParenExprRange(const SourceManager &Sources,
+  LangOptions LangOpts, SourceLocation 
StartLoc,

same here


Comment at: clang-tidy/misc/ThrowWithNoexceptCheck.cpp:71
@@ +70,3 @@
+return SourceRange();
+assert(false);
+  }

move it one line higher


Comment at: clang-tidy/misc/ThrowWithNoexceptCheck.cpp:73
@@ +72,3 @@
+  }
+  int OpenCnt = 1;
+  do {

Use full words. Consider changit to OpenParenCount


Comment at: clang-tidy/misc/ThrowWithNoexceptCheck.cpp:91
@@ +90,3 @@
+
+SourceRange FindNoExceptRange(const ASTContext &Context,
+  const SourceManager &Sources,

rename it to findNoexceptRange at mark it static.


Comment at: clang-tidy/misc/ThrowWithNoexceptCheck.cpp:102
@@ +101,3 @@
+
+  if (!NoExceptTokenRange.isValid()) {
+return SourceRange();

remove extra braces


Comment at: clang-tidy/misc/ThrowWithNoexceptCheck.cpp:108-110
@@ +107,5 @@
+  const auto NoexceptSpec = ProtoType->getNoexceptSpec(Context);
+  if (NoexceptSpec != FunctionProtoType::NR_Nothrow) {
+/* We have noexcept without the expression inside */
+return SourceRange();
+  } else if (ProtoType->getNoexceptExpr() == nullptr) {

The comment is wrong. Shouldn't it be // We have noexcept that doesn't evaluate 
to true


Repository:
  rL LLVM

http://reviews.llvm.org/D19201



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


Re: [PATCH] D20858: [clang-format] make header guard identification stricter in header insertion.

2016-06-01 Thread Eric Liu via cfe-commits
ioeric added inline comments.


Comment at: lib/Format/Format.cpp:1472
@@ -1471,2 +1471,3 @@
   llvm::Regex IncludeRegex(IncludeRegexPattern);
-  llvm::Regex DefineRegex(R"(^[\t\ ]*#[\t\ ]*define[\t\ ]*[^\\]*$)");
+  llvm::Regex IfNDefRegex(R"(^[\t\ ]*#[\t\ ]*ifndef[\t\ ]*([^\\]*)$)");
+  llvm::Regex DefineRegex(R"(^[\t\ ]*#[\t\ ]*define[\t\ ]*([^\\]*)$)");

djasper wrote:
> I think there is too much in the regex group here. If there are trailing 
> comments on the #ifndef or #define lines, this should still work. Also, there 
> might actually be empty lines or comment lines in-between the two. I would 
> for now just check that there:
> - Is no non-comment line before the first #ifndef
> - That there is a #ifndef
> - That the next non-comment line after the #ifndef is a #define
> 
> We can refine more if necessary.
> 
> I think we should be conservative here as this should only really ever affect 
> .cc files (or else the header guard would be there and identified correctly) 
> that don't have any #includes (or put them after unrelated #defines). So, we 
> have to weigh this case being so rare against incorrectly identifying weird 
> header guards in headers (which IMO might be more common).
Okay.

I guess I should've work on the comment skipping FIXME first. I'll work on 
skipping comments first and then continue with this patch,


http://reviews.llvm.org/D20858



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


Re: [PATCH] D18821: Add bugprone-bool-to-integer-conversion

2016-06-01 Thread Piotr Padlewski via cfe-commits
Prazek added a comment.

ping


http://reviews.llvm.org/D18821



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


Re: [PATCH] D20561: Warn when taking address of packed member

2016-06-01 Thread Aaron Ballman via cfe-commits
aaron.ballman added a comment.

This is getting really close, I mostly only have nits left.



Comment at: lib/Sema/SemaExpr.cpp:10529
@@ +10528,3 @@
+bool ByteAligned = Context.getTypeAlignInChars(MD->getType()).isOne();
+if (ByteAligned) // packed has had not any effect on it
+  break;

Comments should be complete sentences including capitalization and punctuation, 
so perhaps instead: `// Packed does not have any effect.`


Comment at: test/Sema/address-packed.c:21
@@ +20,3 @@
+
+extern void f3(void());
+

This is unused and can be removed.


Comment at: test/Sema/address-packed.c:27
@@ +26,3 @@
+
+void g0() {
+  {

Function should take `(void)` since this is C.


Comment at: test/Sema/address-packed.c:47
@@ +46,3 @@
+f2(&arguable.c0); // no-warning
+f1(&arguable.x);  // expected-warning {{packed member 'x' of class or 
structure }}
+f2(&arguable.c1); // no-warning

Extra space before `}}`.


Comment at: test/Sema/address-packed.c:51
@@ +50,3 @@
+  {
+struct Arguable *arguable = get_arguable();
+f2(&(arguable->c0)); // no-warning

Should put in a comment explaining that this produces no diagnostic because of 
the parens.


Comment at: test/SemaCXX/address-packed.cpp:13
@@ +12,3 @@
+
+typedef struct Arguable ArguableT;
+

This is unused and can be removed.


Comment at: test/SemaCXX/address-packed.cpp:77
@@ +76,2 @@
+  }
+};

Can we get one further test?
```
template 
class __attribute__((packed)) S {
  Ty X;
public:
  Ty *get() const {
return &X; // no warning?
  }
};
```
I am fine if this does not warn. I am also fine if it only warns when there are 
instantiations of S for which Ty should warn (e.g., do an explicit 
instantiation with `char` that does not warn and another one with `int` that 
does).


http://reviews.llvm.org/D20561



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


Re: [PATCH] D19165: [clang-tidy] Add modernize-increment-bool check.

2016-06-01 Thread Aaron Ballman via cfe-commits
aaron.ballman added a comment.

In http://reviews.llvm.org/D19165#419848, @Prazek wrote:

> ping @Alexfh have you check it?


I would still strongly prefer to see this fixed in 
`CheckIncrementDecrementOperand` instead of creating an entire clang-tidy check 
for it.


http://reviews.llvm.org/D19165



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


Re: [PATCH] D19201: [clang-tidy] misc-throw-with-noexcept

2016-06-01 Thread Aaron Ballman via cfe-commits
aaron.ballman requested changes to this revision.
This revision now requires changes to proceed.


Comment at: clang-tidy/misc/ThrowWithNoexceptCheck.cpp:25
@@ +24,3 @@
+  Finder->addMatcher(
+  cxxThrowExpr(stmt(hasAncestor(functionDecl(isNoThrow()).bind("func"
+  .bind("throw"),

Prazek wrote:
> you can use forFunction instead of hasAncestor(functionDecl(
> cxxThrowExpr(stmt(forFunction(isNoThrow() or 
> cxxThrowExpr(stmt(forFunction(functionDecl(isNoThrow(
> you can even try to remove stmt.
> 
> 
> Also add test case
> 
>   void getFunction() noexcept {
>struct X { 
> static void inner()
> {
> throw 42;
> }
>}; 
>   }
> 
Hmm, I wonder if it's trivial enough to filter out throw statements that are 
inside a try block scope (even without checking the expression and catch block 
types)?


Comment at: clang-tidy/misc/ThrowWithNoexceptCheck.cpp:32
@@ +31,3 @@
+// token including trailing whitespace.
+static SourceRange FindToken(const SourceManager &Sources, LangOptions 
LangOpts,
+ SourceLocation StartLoc, SourceLocation EndLoc,

Prazek wrote:
> function in llvm starts with lower case
I prefer this be gated on D20428; we should be pushing this functionality down 
where it belongs instead of replicating it in several different clang-tidy 
checks.


Comment at: clang-tidy/misc/ThrowWithNoexceptCheck.cpp:91
@@ +90,3 @@
+
+SourceRange FindNoExceptRange(const ASTContext &Context,
+  const SourceManager &Sources,

Prazek wrote:
> rename it to findNoexceptRange at mark it static.
This function will not work with dynamic exception specifications that also 
specify the function is nonthrowing, e.g., `throw()`.


Comment at: clang-tidy/misc/ThrowWithNoexceptCheck.cpp:130
@@ +129,3 @@
+  const auto *Throw = Result.Nodes.getNodeAs("throw");
+  diag(Throw->getLocStart(), "throw in function declared no-throw");
+  for (auto Redecl : Function->redecls()) {

Prazek wrote:
> add new line after this line
How about wording the diagnostic: "'throw' expression in a function declared 
with a non-throwing exception specification"


Comment at: clang-tidy/misc/ThrowWithNoexceptCheck.cpp:131
@@ +130,3 @@
+  diag(Throw->getLocStart(), "throw in function declared no-throw");
+  for (auto Redecl : Function->redecls()) {
+SourceRange NoExceptRange =

Prazek wrote:
> add some new line
`const auto *`, please (assuming Redecl is a pointer type).


Comment at: clang-tidy/misc/ThrowWithNoexceptCheck.h:20
@@ +19,3 @@
+///\brief Warns about using throw in function declared as noexcept.
+/// It complains about every throw, even if it is caught later.
+class ThrowWithNoexceptCheck : public ClangTidyCheck {

What is the false positive rate with this check over a large codebase that uses 
exceptions?


Comment at: test/clang-tidy/misc-throw-with-noexcept.cpp:70
@@ +69,2 @@
+}
+// CHECK-MESSAGES: :[[@LINE-2]]:2: warning: throw in function declared 
no-throw [misc-throw-with-noexcept]

There are no tests for dynamic exception specifications.


Repository:
  rL LLVM

http://reviews.llvm.org/D19201



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


Re: [PATCH] D20810: [Clang][Intrinsics][avx512] Continue Adding round cvt to clang

2016-06-01 Thread Asaf Badouh via cfe-commits
AsafBadouh accepted this revision.
AsafBadouh added a comment.
This revision is now accepted and ready to land.

minor fixes, LGTM



Comment at: lib/Headers/avx512fintrin.h:3658
@@ +3657,3 @@
+_mm256_undefined_si256 (),\
+-1);\
+})

please add (__mmask16)


Comment at: lib/Headers/avx512fintrin.h:3669
@@ +3668,3 @@
+#define _mm512_maskz_cvt_roundps_ph( __W, __A, __I) __extension__ ({ \
+__builtin_ia32_vcvtps2ph512_mask ((__v16sf)( __A),\
+   ( __I),\

please add casting to return type (__m256i)

same for the rest


Comment at: test/CodeGen/avx512f-builtins.c:3121
@@ +3120,3 @@
+// CHECK: @llvm.x86.avx512.mask.cvttps2udq.512
+
+return _mm512_mask_cvtt_roundps_epu32(__W, __U, __A, 
_MM_FROUND_CUR_DIRECTION);

remove empty line


Comment at: test/CodeGen/avx512f-builtins.c:3129
@@ +3128,3 @@
+// CHECK: @llvm.x86.avx512.mask.cvttps2udq.512
+
+return _mm512_maskz_cvtt_roundps_epu32(__U, __A, _MM_FROUND_CUR_DIRECTION);

remove empty line


http://reviews.llvm.org/D20810



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


r271392 - Fix the CLANG_ENABLE_STATIC_ANALYZER=OFF build.

2016-06-01 Thread Yaron Keren via cfe-commits
Author: yrnkrn
Date: Wed Jun  1 08:47:26 2016
New Revision: 271392

URL: http://llvm.org/viewvc/llvm-project?rev=271392&view=rev
Log:
Fix the CLANG_ENABLE_STATIC_ANALYZER=OFF build.

tools/clang/tools/CMakeLists.txt does not create the
clang-check target when CLANG_ENABLE_STATIC_ANALYZER=OFF.


Modified:
cfe/trunk/test/CMakeLists.txt

Modified: cfe/trunk/test/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CMakeLists.txt?rev=271392&r1=271391&r2=271392&view=diff
==
--- cfe/trunk/test/CMakeLists.txt (original)
+++ cfe/trunk/test/CMakeLists.txt Wed Jun  1 08:47:26 2016
@@ -26,10 +26,16 @@ endif ()
 
 list(APPEND CLANG_TEST_DEPS
   clang clang-headers
-  clang-check clang-format
+  clang-format
   c-index-test diagtool
   clang-tblgen
   )
+  
+if(CLANG_ENABLE_STATIC_ANALYZER)
+  list(APPEND CLANG_TEST_DEPS
+clang-check
+)
+endif()
 
 if (CLANG_ENABLE_ARCMT)
   list(APPEND CLANG_TEST_DEPS


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


Re: [PATCH] D20811: [analyzer] Model some library functions

2016-06-01 Thread Gábor Horváth via cfe-commits
xazax.hun added a comment.

It is great to model more widely used functions! However I think the 
LibraryFunctionsChecker name might be a bit to broad, wouldn't something like 
StdCLibraryFunctions be more informative?


http://reviews.llvm.org/D20811



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


[PATCH] D20863: [analyzer] Fix for the strdup family in unix.malloc checker

2016-06-01 Thread Balogh , Ádám via cfe-commits
baloghadamsoftware created this revision.
baloghadamsoftware added a reviewer: dcoughlin.
baloghadamsoftware added subscribers: cfe-commits, xazax.hun, o.gyorgy.

The strdup family was only partially handled in the original checker. As a 
consequence it did not recognize leaks where a variable which received a result 
of an strdup was later overwritten. (The unix.cstring checkers did not 
recognize this leak either, but their task is also different.) This patch fixes 
this issue by simulating the memory allocation of strdup functions. Some new 
functions where taken from the unix.cstring checkers but they were also 
simplified and adapted for the purpose of the checker. Some other tests had to 
be fixed as well since they contained strdup caused memory leaks. (The leak was 
not fixed but the warning is now expected.)

http://reviews.llvm.org/D20863

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

Index: test/Analysis/unions.cpp
===
--- test/Analysis/unions.cpp
+++ test/Analysis/unions.cpp
@@ -93,7 +93,7 @@
 
 // FIXME: This is a leak of uu.s.
 uu = vv;
-  }
+  } // expected-warning{{leak}}
 
   void testIndirectInvalidation() {
 IntOrString uu;
Index: test/Analysis/pr22954.c
===
--- test/Analysis/pr22954.c
+++ test/Analysis/pr22954.c
@@ -585,7 +585,8 @@
   m28[j].s3[k] = 1;
   struct ll * l28 = (struct ll*)(&m28[1]);
   l28->s1[l] = 2;
-  char input[] = {'a', 'b', 'c', 'd'};
+  char input[] = {'a', 'b', 'c', 'd'}; // \
+  expected-warning{{Potential leak of memory pointed to by field 's4'}}
   memcpy(l28->s1, input, 4);
   clang_analyzer_eval(m28[0].s3[0] == 1); // expected-warning{{UNKNOWN}}
   clang_analyzer_eval(m28[0].s3[1] == 1); // expected-warning{{UNKNOWN}}
Index: test/Analysis/malloc.c
===
--- test/Analysis/malloc.c
+++ test/Analysis/malloc.c
@@ -1106,54 +1106,70 @@
 }
 
 // Test various allocation/deallocation functions.
-void testStrdup(const char *s, unsigned validIndex) {
+void testStrdup(const char *s) {
   char *s2 = strdup(s);
-  s2[validIndex + 1] = 'b';
 } // expected-warning {{Potential leak of memory pointed to by}}
 
-void testWinStrdup(const char *s, unsigned validIndex) {
+void testWinStrdup(const char *s) {
   char *s2 = _strdup(s);
-  s2[validIndex + 1] = 'b';
 } // expected-warning {{Potential leak of memory pointed to by}}
 
-void testWcsdup(const wchar_t *s, unsigned validIndex) {
+void testWcsdup(const wchar_t *s) {
   wchar_t *s2 = wcsdup(s);
-  s2[validIndex + 1] = 'b';
 } // expected-warning {{Potential leak of memory pointed to by}}
 
-void testWinWcsdup(const wchar_t *s, unsigned validIndex) {
+void testWinWcsdup(const wchar_t *s) {
   wchar_t *s2 = _wcsdup(s);
-  s2[validIndex + 1] = 'b';
 } // expected-warning {{Potential leak of memory pointed to by}}
 
-int testStrndup(const char *s, unsigned validIndex, unsigned size) {
+void testStrndup(const char *s, unsigned size) {
   char *s2 = strndup(s, size);
-  s2 [validIndex + 1] = 'b';
-  if (s2[validIndex] != 'a')
-return 0;
-  else
-return 1;// expected-warning {{Potential leak of memory pointed to by}}
-}
+} // expected-warning {{Potential leak of memory pointed to by}}
+
+void testStrdupOverwritten(const char *s) {
+  char *s2 = strdup(s);
+  s2 = 0;
+} // expected-warning {{Potential leak of memory pointed to by}}
+
+void testWinStrdupOverwritten(const char *s) {
+  char *s2 = _strdup(s);
+  s2 = 0;
+} // expected-warning {{Potential leak of memory pointed to by}}
+
+void testWcsdupOverwritten(const wchar_t *s) {
+  wchar_t *s2 = wcsdup(s);
+  s2 = 0;
+} // expected-warning {{Potential leak of memory pointed to by}}
+
+void testWinWcsdupOverwritten(const wchar_t *s) {
+  wchar_t *s2 = _wcsdup(s);
+  s2 = 0;
+} // expected-warning {{Potential leak of memory pointed to by}}
+
+void testStrndupOverwritten(const char *s, unsigned size) {
+  char *s2 = strndup(s, size);
+  s2 = 0;
+} // expected-warning {{Potential leak of memory pointed to by}}
 
-void testStrdupContentIsDefined(const char *s, unsigned validIndex) {
+void testStrdupContentIsDefined(const char *s) {
   char *s2 = strdup(s);
   char result = s2[1];// no warning
   free(s2);
 }
 
-void testWinStrdupContentIsDefined(const char *s, unsigned validIndex) {
+void testWinStrdupContentIsDefined(const char *s) {
   char *s2 = _strdup(s);
   char result = s2[1];// no warning
   free(s2);
 }
 
-void testWcsdupContentIsDefined(const wchar_t *s, unsigned validIndex) {
+void testWcsdupContentIsDefined(const wchar_t *s) {
   wchar_t *s2 = wcsdup(s);
   wchar_t result = s2[1];// no warning
   free(s2);
 }
 
-void testWinWcsdupContentIsDefined(const wchar_t *s, unsigned validIndex) {
+void testWinWcsdupContentIsDefined(const wchar_t *s) {
   wchar_t *s2 = _wcsdup(s);
   wchar_t resu

[PATCH] D20864: Adding support for Cortex-A73

2016-06-01 Thread Sjoerd Meijer via cfe-commits
SjoerdMeijer created this revision.
SjoerdMeijer added reviewers: rengolin, t.p.northover.
SjoerdMeijer added a subscriber: cfe-commits.

This adds target support and tests for Cortex-A73

http://reviews.llvm.org/D20864

Files:
  lib/Basic/Targets.cpp
  lib/Driver/Tools.cpp
  test/CodeGen/arm-target-features.c
  test/Driver/aarch64-cpus.c
  test/Driver/arm-cortex-cpus.c
  test/Preprocessor/aarch64-target-features.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
@@ -303,6 +303,8 @@
 // RUN: %clang -target armv8 -mthumb -mcpu=cortex-a32 -x c -E -dM %s -o - | FileCheck -match-full-lines --check-prefix=ARMV8 %s
 // RUN: %clang -target armv8 -mcpu=cortex-a53 -x c -E -dM %s -o - | FileCheck -match-full-lines --check-prefix=ARMV8 %s
 // RUN: %clang -target armv8 -mthumb -mcpu=cortex-a53 -x c -E -dM %s -o - | FileCheck -match-full-lines --check-prefix=ARMV8 %s
+// RUN: %clang -target armv8 -mcpu=cortex-a73 -x c -E -dM %s -o - | FileCheck -match-full-lines --check-prefix=ARMV8 %s
+// RUN: %clang -target armv8 -mthumb -mcpu=cortex-a73 -x c -E -dM %s -o - | FileCheck -match-full-lines --check-prefix=ARMV8 %s
 // ARMV8:#define __ARM_ARCH_EXT_IDIV__ 1
 // ARMV8:#define __ARM_FEATURE_DSP 1
 // ARMV8:#define __ARM_FP 0xE
Index: test/Preprocessor/aarch64-target-features.c
===
--- test/Preprocessor/aarch64-target-features.c
+++ test/Preprocessor/aarch64-target-features.c
@@ -92,13 +92,15 @@
 // RUN: %clang -target aarch64 -mcpu=cortex-a53 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-MCPU-A53 %s
 // RUN: %clang -target aarch64 -mcpu=cortex-a57 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-MCPU-A57 %s
 // RUN: %clang -target aarch64 -mcpu=cortex-a72 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-MCPU-A72 %s
+// RUN: %clang -target aarch64 -mcpu=cortex-a73 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-MCPU-CORTEX-A73 %s
 // RUN: %clang -target aarch64 -mcpu=exynos-m1 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-MCPU-M1 %s
 // RUN: %clang -target aarch64 -mcpu=kryo -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-MCPU-KRYO %s
 // CHECK-MCPU-CYCLONE: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+neon" "-target-feature" "+crypto" "-target-feature" "+zcm" "-target-feature" "+zcz"
 // CHECK-MCPU-A35: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+neon" "-target-feature" "+crc" "-target-feature" "+crypto"
 // CHECK-MCPU-A53: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+neon" "-target-feature" "+crc" "-target-feature" "+crypto"
 // CHECK-MCPU-A57: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+neon" "-target-feature" "+crc" "-target-feature" "+crypto"
 // CHECK-MCPU-A72: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+neon" "-target-feature" "+crc" "-target-feature" "+crypto"
+// CHECK-MCPU-CORTEX-A73: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+neon" "-target-feature" "+crc" "-target-feature" "+crypto"
 // CHECK-MCPU-M1: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+neon" "-target-feature" "+crc" "-target-feature" "+crypto"
 // CHECK-MCPU-KRYO: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+neon" "-target-feature" "+crc" "-target-feature" "+crypto"
 
Index: test/Driver/arm-cortex-cpus.c
===
--- test/Driver/arm-cortex-cpus.c
+++ test/Driver/arm-cortex-cpus.c
@@ -468,57 +468,74 @@
 // RUN: %clang -target arm -mcpu=cortex-a53 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV8A %s
 // RUN: %clang -target arm -mcpu=cortex-a57 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV8A %s
 // RUN: %clang -target arm -mcpu=cortex-a72 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV8A %s
+// RUN: %clang -target arm -mcpu=cortex-a73 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV8A %s
 // RUN: %clang -target arm -mcpu=exynos-m1 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV8A %s
 // RUN: %clang -target arm -mcpu=cortex-a32 -mlittle-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV8A %s
 // RUN: %clang -target arm -mcpu=cortex-a35 -mlittle-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV8A %s
 // RUN: %clang -target arm -mcpu=cortex-a53 -mlittle-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV8A %s
 // RUN: %clang -target arm -mcpu=cortex-a57 -mlittle-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV8A %s
 // RUN: %clang -target arm -mcpu=cortex-a72 -mlittle-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV8A %s
+// RUN: %clang -target arm -mcpu=cortex-a73 -mlittle-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV8A %s
 // RUN: %clang -target arm -mcpu=exynos-m1 -mlittle-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV8A %s
 /

[PATCH] D20866: [Clang][AVX512]Adding set4 intrinsics

2016-06-01 Thread michael zuckerman via cfe-commits
m_zuckerman created this revision.
m_zuckerman added reviewers: delena, AsafBadouh, igorb.
m_zuckerman added a subscriber: cfe-commits.

http://reviews.llvm.org/D20866

Files:
  lib/Headers/avx512fintrin.h
  test/CodeGen/avx512f-builtins.c

Index: test/CodeGen/avx512f-builtins.c
===
--- test/CodeGen/avx512f-builtins.c
+++ test/CodeGen/avx512f-builtins.c
@@ -6130,6 +6130,62 @@
   return _mm512_set1_epi16(d);
 }
 
+__m512i test_mm512_set4_epi32 (int __A, int __B, int __C, int __D)
+{
+  // CHECK-LABEL: @test_mm512_set4_epi32 
+  // CHECK: insertelement <16 x i32> {{.*}}, i32 15
+  return _mm512_set4_epi32 (__A,__B,__C,__D);
+}
+
+__m512i test_mm512_set4_epi64 (long long __A, long long __B, long long __C, long long __D)
+{
+  // CHECK-LABEL: @test_mm512_set4_epi64 
+  // CHECK: insertelement <8 x i64> {{.*}}, i32 7
+  return _mm512_set4_epi64 (__A,__B,__C,__D);
+}
+
+__m512d test_mm512_set4_pd (double __A, double __B, double __C, double __D)
+{
+  // CHECK-LABEL: @test_mm512_set4_pd 
+  // CHECK: insertelement <8 x double> {{.*}}, i32 7
+  return _mm512_set4_pd (__A,__B,__C,__D);
+}
+
+__m512 test_mm512_set4_ps (float __A, float __B, float __C, float __D)
+{
+  // CHECK-LABEL: @test_mm512_set4_ps 
+  // CHECK: insertelement <16 x float> {{.*}}, i32 15
+  return _mm512_set4_ps (__A,__B,__C,__D);
+}
+
+__m512i test_mm512_setr4_epi32(e0,e1,e2,e3)
+{
+  // CHECK-LABEL: @test_mm512_setr4_epi32
+  // CHECK: insertelement <16 x i32> {{.*}}, i32 15
+  return _mm512_setr4_epi32(e0,e1,e2,e3);
+}
+
+ __m512i test_mm512_setr4_epi64(e0,e1,e2,e3)
+{
+  // CHECK-LABEL: @test_mm512_setr4_epi64
+  // CHECK: insertelement <8 x i64> {{.*}}, i32 7
+  return _mm512_setr4_epi64(e0,e1,e2,e3);
+}
+
+__m512i test_mm512_setr4_pd(e0,e1,e2,e3)
+{
+  // CHECK-LABEL: @test_mm512_setr4_pd
+  // CHECK: insertelement <8 x double> {{.*}}, i32 7
+  return _mm512_setr4_pd(e0,e1,e2,e3);
+}
+
+ __m512i test_mm512_setr4_ps(e0,e1,e2,e3)
+{
+  // CHECK-LABEL: @test_mm512_setr4_ps
+  // CHECK: insertelement <16 x float> {{.*}}, i32 15
+  return _mm512_setr4_ps(e0,e1,e2,e3);
+}
+
 __m512d test_mm512_castpd256_pd512(__m256d a)
 {
   // CHECK-LABEL: @test_mm512_castpd256_pd512
Index: lib/Headers/avx512fintrin.h
===
--- lib/Headers/avx512fintrin.h
+++ lib/Headers/avx512fintrin.h
@@ -332,6 +332,49 @@
 __f, __f, __f, __f };
 }
 
+static __inline __m512i __DEFAULT_FN_ATTRS
+_mm512_set4_epi32 (int __A, int __B, int __C, int __D)
+{
+  return  (__m512i)(__v16si)
+   { __D, __C, __B, __A, __D, __C, __B, __A,
+ __D, __C, __B, __A, __D, __C, __B, __A };
+}
+
+static __inline __m512i __DEFAULT_FN_ATTRS
+_mm512_set4_epi64 (long long __A, long long __B, long long __C,
+   long long __D)
+{
+  return  (__m512i) (__v8di)
+   { __D, __C, __B, __A, __D, __C, __B, __A };
+}
+
+static __inline __m512d __DEFAULT_FN_ATTRS
+_mm512_set4_pd (double __A, double __B, double __C, double __D)
+{
+  return  (__m512d)
+   { __D, __C, __B, __A, __D, __C, __B, __A };
+}
+
+static __inline __m512 __DEFAULT_FN_ATTRS
+_mm512_set4_ps (float __A, float __B, float __C, float __D)
+{
+  return  (__m512)
+   { __D, __C, __B, __A, __D, __C, __B, __A,
+ __D, __C, __B, __A, __D, __C, __B, __A };
+}
+
+#define _mm512_setr4_epi32(e0,e1,e2,e3)   \
+  _mm512_set4_epi32(e3,e2,e1,e0)
+
+#define _mm512_setr4_epi64(e0,e1,e2,e3)   \
+  _mm512_set4_epi64(e3,e2,e1,e0)
+
+#define _mm512_setr4_pd(e0,e1,e2,e3)\
+  _mm512_set4_pd(e3,e2,e1,e0)
+
+#define _mm512_setr4_ps(e0,e1,e2,e3)\
+  _mm512_set4_ps(e3,e2,e1,e0)
+
 static __inline__ __m512d __DEFAULT_FN_ATTRS
 _mm512_broadcastsd_pd(__m128d __X)
 {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20866: [Clang][AVX512]Adding set4 intrinsics

2016-06-01 Thread Asaf Badouh via cfe-commits
AsafBadouh added inline comments.


Comment at: test/CodeGen/avx512f-builtins.c:6161
@@ +6160,3 @@
+
+__m512i test_mm512_setr4_epi32(e0,e1,e2,e3)
+{

types are missing


http://reviews.llvm.org/D20866



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


r271398 - [Clang][Intrinsics][avx512] Continue Adding round cvt to clang

2016-06-01 Thread Michael Zuckerman via cfe-commits
Author: mzuckerm
Date: Wed Jun  1 09:41:41 2016
New Revision: 271398

URL: http://llvm.org/viewvc/llvm-project?rev=271398&view=rev
Log:
[Clang][Intrinsics][avx512] Continue Adding round cvt to clang

And remove trailing spaces in intrinsic f test
Differential Revision: http://reviews.llvm.org/D20810

Modified:
cfe/trunk/lib/Headers/avx512fintrin.h
cfe/trunk/test/CodeGen/avx512f-builtins.c

Modified: cfe/trunk/lib/Headers/avx512fintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512fintrin.h?rev=271398&r1=271397&r2=271398&view=diff
==
--- cfe/trunk/lib/Headers/avx512fintrin.h (original)
+++ cfe/trunk/lib/Headers/avx512fintrin.h Wed Jun  1 09:41:41 2016
@@ -3585,6 +3585,27 @@ _mm512_mask_blend_epi32(__mmask16 __U, _
 
 /* Conversion */
 
+#define _mm512_cvtt_roundps_epu32( __A, __R) __extension__ ({ \
+__builtin_ia32_cvttps2udq512_mask ((__v16sf)( __A),\
+ (__v16si)\
+ _mm512_undefined_epi32 (),\
+ (__mmask16) -1,( __R));\
+})
+
+#define _mm512_mask_cvtt_roundps_epu32( __W, __U, __A, __R) __extension__ ({ \
+__builtin_ia32_cvttps2udq512_mask ((__v16sf)( __A),\
+ (__v16si)( __W),\
+ (__mmask16)( __U),( __R));\
+})
+
+#define _mm512_maskz_cvtt_roundps_epu32( __U, __A, __R) __extension__ ({ \
+__builtin_ia32_cvttps2udq512_mask ((__v16sf)( __A),\
+ (__v16si)\
+ _mm512_setzero_si512 (),\
+ (__mmask16)( __U),( __R));\
+})
+
+
 static __inline __m512i __DEFAULT_FN_ATTRS
 _mm512_cvttps_epu32(__m512 __A)
 {
@@ -3795,6 +3816,28 @@ _mm512_maskz_cvtpd_ps (__mmask8 __U, __m
 _MM_FROUND_CUR_DIRECTION);
 }
 
+#define _mm512_cvt_roundps_ph( __A, __I) __extension__ ({ \
+  (__m256i)__builtin_ia32_vcvtps2ph512_mask ((__v16sf)( __A),\
+ (__I),\
+ (__v16hi)_mm256_undefined_si256 
(),\
+ (__mmask16) -1);\
+})
+
+#define _mm512_mask_cvt_roundps_ph( __U, __W, __A, __I) __extension__ ({ \
+  (__m256i)__builtin_ia32_vcvtps2ph512_mask ((__v16sf)( __A),\
+ (__I),\
+ (__v16hi)( __U),\
+ (__mmask16)( __W));\
+})
+
+#define _mm512_maskz_cvt_roundps_ph( __W, __A, __I) __extension__ ({ \
+  (__m256i)__builtin_ia32_vcvtps2ph512_mask ((__v16sf)( __A),\
+ (__I),\
+ (__v16hi)\
+ _mm256_setzero_si256 (),\
+ (__mmask16)( __W));\
+})
+
 #define _mm512_cvtps_ph(A, I) __extension__ ({ \
   (__m256i)__builtin_ia32_vcvtps2ph512_mask((__v16sf)(__m512)(A), (int)(I), \
 (__v16hi)_mm256_setzero_si256(), \
@@ -3809,7 +3852,28 @@ _mm512_maskz_cvtpd_ps (__mmask8 __U, __m
   (__m256i)__builtin_ia32_vcvtps2ph512_mask((__v16sf)(__m512)(A), (int)(I), \
 (__v16hi)_mm256_setzero_si256(), \
 (__mmask16)(W)); })
-   
+
+#define _mm512_cvt_roundph_ps( __A, __R) __extension__ ({ \
+__builtin_ia32_vcvtph2ps512_mask ((__v16hi)( __A),\
+   (__v16sf)\
+   _mm512_undefined_ps (),\
+   (__mmask16) -1,( __R));\
+})
+
+#define _mm512_mask_cvt_roundph_ps( __W, __U, __A, __R) __extension__ ({ \
+__builtin_ia32_vcvtph2ps512_mask ((__v16hi)( __A),\
+   (__v16sf)( __W),\
+   (__mmask16)( __U),( __R));\
+})
+
+#define _mm512_maskz_cvt_roundph_ps( __U, __A, __R) __extension__ ({ \
+__builtin_ia32_vcvtph2ps512_mask ((__v16hi)( __A),\
+   (__v16sf)\
+   _mm512_setzero_ps (),\
+   (__mmask16)( __U),( __R));\
+})
+ 
+ 
 static  __inline __m512 __DEFAULT_FN_ATTRS
 _mm512_cvtph_ps(__m256i __A)
 {

Modified: cfe/trunk/test/CodeGen/avx512f-builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/avx512f-builtins.c?rev=271398&r1=271397&r2=271398&view=diff
==
--- cfe/trunk/test/CodeGen/avx512f-builtins.c (original)
+++ cfe/trunk/test/CodeGen/avx512f-builtins.c Wed Jun  1 09:41:41 2016
@@ -2948,19 +2948,19 @@ __m512 test_mm512_maskz_unpacklo_ps(__mm
 int test_mm_cvt_roundsd_si32(__m128d __A) {
   // CHECK-LABEL: @test_mm_cvt_roundsd_si32
   // CHECK: @llvm.x86.avx512.vcvtsd2si32
-  return _mm_cvt_roundsd_si32(__A, _MM_FROUND_CUR_DIRECTION); 
+  return _mm_cvt_roundsd_si32(__A, _MM_FROUND_CUR_DIRECTION);
 }
 
 int test_mm_cvt_roundsd_i32(__m128d __A) {
   // CHECK-LABEL: @test_mm_cvt_roundsd_i32
   // CHECK: @llvm.x86.avx512.vcvtsd2si32
-  re

Add Comments::const_child_iterator and (const_)child_range

2016-06-01 Thread Andre Vehreschild via cfe-commits
Hi all,

this is my first patch, so please be patient. I normaly submit to gfortran and 
their policies for submission are somewhat different.

Subject of the patch: 

The patch adds the missing const_child_iterator to all Comment classes and 
changes the mutable child_iterator to be mutable again. This of course needed 
some changes in other places: where formerly the immutable child_iterator was 
used now the const_child_iterator is needed. These changes are also applied by 
the patch. A comment at the child_iterator describes the change and advises the 
use of the const_-version when compile issues are encountered in tools using 
clang.

Furthermore does the patch add the range-accessor to all Comment classes 
enabling the use of children() in the for-range loop. This is modelled using 
the Stmt::children() implementation as a blueprint.

Regtests ok on x86_64-linux-gnu/F23 and x86_64-win64/Win7 using Visual Studio 
12.

Any comment?

Regards,
Andre

CommentsIteratorRange.patch
Description: Binary data
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20810: [Clang][Intrinsics][avx512] Continue Adding round cvt to clang

2016-06-01 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL271398: [Clang][Intrinsics][avx512] Continue Adding round 
cvt to clang (authored by mzuckerm).

Changed prior to commit:
  http://reviews.llvm.org/D20810?vs=59048&id=59223#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D20810

Files:
  cfe/trunk/lib/Headers/avx512fintrin.h
  cfe/trunk/test/CodeGen/avx512f-builtins.c

Index: cfe/trunk/test/CodeGen/avx512f-builtins.c
===
--- cfe/trunk/test/CodeGen/avx512f-builtins.c
+++ cfe/trunk/test/CodeGen/avx512f-builtins.c
@@ -2948,19 +2948,19 @@
 int test_mm_cvt_roundsd_si32(__m128d __A) {
   // CHECK-LABEL: @test_mm_cvt_roundsd_si32
   // CHECK: @llvm.x86.avx512.vcvtsd2si32
-  return _mm_cvt_roundsd_si32(__A, _MM_FROUND_CUR_DIRECTION); 
+  return _mm_cvt_roundsd_si32(__A, _MM_FROUND_CUR_DIRECTION);
 }
 
 int test_mm_cvt_roundsd_i32(__m128d __A) {
   // CHECK-LABEL: @test_mm_cvt_roundsd_i32
   // CHECK: @llvm.x86.avx512.vcvtsd2si32
-  return _mm_cvt_roundsd_i32(__A, _MM_FROUND_CUR_DIRECTION); 
+  return _mm_cvt_roundsd_i32(__A, _MM_FROUND_CUR_DIRECTION);
 }
 
 unsigned test_mm_cvt_roundsd_u32(__m128d __A) {
   // CHECK-LABEL: @test_mm_cvt_roundsd_u32
   // CHECK: @llvm.x86.avx512.vcvtsd2usi32
-  return _mm_cvt_roundsd_u32(__A, _MM_FROUND_CUR_DIRECTION); 
+  return _mm_cvt_roundsd_u32(__A, _MM_FROUND_CUR_DIRECTION);
 }
 
 unsigned test_mm_cvtsd_u32(__m128d __A) {
@@ -2972,7 +2972,7 @@
 unsigned long long test_mm_cvt_roundsd_u64(__m128d __A) {
   // CHECK-LABEL: @test_mm_cvt_roundsd_u64
   // CHECK: @llvm.x86.avx512.vcvtsd2usi64
-  return _mm_cvt_roundsd_u64(__A, _MM_FROUND_CUR_DIRECTION); 
+  return _mm_cvt_roundsd_u64(__A, _MM_FROUND_CUR_DIRECTION);
 }
 
 unsigned long long test_mm_cvtsd_u64(__m128d __A) {
@@ -2984,31 +2984,31 @@
 int test_mm_cvt_roundss_si32(__m128 __A) {
   // CHECK-LABEL: @test_mm_cvt_roundss_si32
   // CHECK: @llvm.x86.avx512.vcvtss2si32
-  return _mm_cvt_roundss_si32(__A, _MM_FROUND_CUR_DIRECTION); 
+  return _mm_cvt_roundss_si32(__A, _MM_FROUND_CUR_DIRECTION);
 }
 
 int test_mm_cvt_roundss_i32(__m128 __A) {
   // CHECK-LABEL: @test_mm_cvt_roundss_i32
   // CHECK: @llvm.x86.avx512.vcvtss2si32
-  return _mm_cvt_roundss_i32(__A, _MM_FROUND_CUR_DIRECTION); 
+  return _mm_cvt_roundss_i32(__A, _MM_FROUND_CUR_DIRECTION);
 }
 
 int test_mm_cvt_roundss_si64(__m128 __A) {
   // CHECK-LABEL: @test_mm_cvt_roundss_si64
   // CHECK: @llvm.x86.avx512.vcvtss2si64
-  return _mm_cvt_roundss_si64(__A, _MM_FROUND_CUR_DIRECTION); 
+  return _mm_cvt_roundss_si64(__A, _MM_FROUND_CUR_DIRECTION);
 }
 
 long long test_mm_cvt_roundss_i64(__m128 __A) {
   // CHECK-LABEL: @test_mm_cvt_roundss_i64
   // CHECK: @llvm.x86.avx512.vcvtss2si64
-  return _mm_cvt_roundss_i64(__A, _MM_FROUND_CUR_DIRECTION); 
+  return _mm_cvt_roundss_i64(__A, _MM_FROUND_CUR_DIRECTION);
 }
 
 unsigned test_mm_cvt_roundss_u32(__m128 __A) {
   // CHECK-LABEL: @test_mm_cvt_roundss_u32
   // CHECK: @llvm.x86.avx512.vcvtss2usi32
-  return _mm_cvt_roundss_u32(__A, _MM_FROUND_CUR_DIRECTION); 
+  return _mm_cvt_roundss_u32(__A, _MM_FROUND_CUR_DIRECTION);
 }
 
 unsigned test_mm_cvtss_u32(__m128 __A) {
@@ -3020,7 +3020,7 @@
 unsigned long long test_mm_cvt_roundss_u64(__m128 __A) {
   // CHECK-LABEL: @test_mm_cvt_roundss_u64
   // CHECK: @llvm.x86.avx512.vcvtss2usi64
-  return _mm_cvt_roundss_u64(__A, _MM_FROUND_CUR_DIRECTION); 
+  return _mm_cvt_roundss_u64(__A, _MM_FROUND_CUR_DIRECTION);
 }
 
 unsigned long long test_mm_cvtss_u64(__m128 __A) {
@@ -3032,13 +3032,13 @@
 int test_mm_cvtt_roundsd_i32(__m128d __A) {
   // CHECK-LABEL: @test_mm_cvtt_roundsd_i32
   // CHECK: @llvm.x86.avx512.cvttsd2si
-  return _mm_cvtt_roundsd_i32(__A, _MM_FROUND_CUR_DIRECTION); 
+  return _mm_cvtt_roundsd_i32(__A, _MM_FROUND_CUR_DIRECTION);
 }
 
 int test_mm_cvtt_roundsd_si32(__m128d __A) {
   // CHECK-LABEL: @test_mm_cvtt_roundsd_si32
   // CHECK: @llvm.x86.avx512.cvttsd2si
-  return _mm_cvtt_roundsd_si32(__A, _MM_FROUND_CUR_DIRECTION); 
+  return _mm_cvtt_roundsd_si32(__A, _MM_FROUND_CUR_DIRECTION);
 }
 
 int test_mm_cvttsd_i32(__m128d __A) {
@@ -3050,13 +3050,13 @@
 unsigned long long test_mm_cvtt_roundsd_si64(__m128d __A) {
   // CHECK-LABEL: @test_mm_cvtt_roundsd_si64
   // CHECK: @llvm.x86.avx512.cvttsd2si64
-  return _mm_cvtt_roundsd_si64(__A, _MM_FROUND_CUR_DIRECTION); 
+  return _mm_cvtt_roundsd_si64(__A, _MM_FROUND_CUR_DIRECTION);
 }
 
 long long test_mm_cvtt_roundsd_i64(__m128d __A) {
   // CHECK-LABEL: @test_mm_cvtt_roundsd_i64
   // CHECK: @llvm.x86.avx512.cvttsd2si64
-  return _mm_cvtt_roundsd_i64(__A, _MM_FROUND_CUR_DIRECTION); 
+  return _mm_cvtt_roundsd_i64(__A, _MM_FROUND_CUR_DIRECTION);
 }
 
 long long test_mm_cvttsd_i64(__m128d __A) {
@@ -3068,7 +3068,7 @@
 unsigned test_mm_cvtt_roundsd_u32(__m128d __A) {
   // CHECK-LABEL: @test_mm_cvtt_roundsd_u32
   // CHECK: @llvm.x86.avx512.cvttsd2usi
-  return _mm_cvtt_roundsd_u32(__A, _MM_FROUND_CUR_DIRECTION); 

Re: [PATCH] D20859: [X86][SSE] Replace (V)CVTTPS2DQ and VCVTTPD2DQ truncating (round to zero) f32/f64 to i32 with generic IR (clang)

2016-06-01 Thread Ahmed Bougacha via cfe-commits
ab accepted this revision.
ab added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rL LLVM

http://reviews.llvm.org/D20859



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


Re: [PATCH] D20447: [OpenCL] Fixup extension list

2016-06-01 Thread Anastasia Stulova via cfe-commits
Anastasia added inline comments.


Comment at: test/SemaOpenCL/extension-version.cl:41
@@ +40,3 @@
+
+// COre features in CL 1.1
+#if (__OPENCL_C_VERSION__ < 110)

Anastasia wrote:
> COre -> core
Actually looking at other comments -> Core


Repository:
  rL LLVM

http://reviews.llvm.org/D20447



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


Re: [PATCH] D20447: [OpenCL] Fixup extension list

2016-06-01 Thread Anastasia Stulova via cfe-commits
Anastasia added inline comments.


Comment at: test/SemaOpenCL/extension-version.cl:41
@@ +40,3 @@
+
+// COre features in CL 1.1
+#if (__OPENCL_C_VERSION__ < 110)

COre -> core


Comment at: test/SemaOpenCL/extension-version.cl:73
@@ +72,3 @@
+
+#endif
+

Could you put a comment to make it more readable, something like 

#endif // (__OPENCL_C_VERSION__ < 110)


Repository:
  rL LLVM

http://reviews.llvm.org/D20447



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


Re: [PATCH] D20561: Warn when taking address of packed member

2016-06-01 Thread Roger Ferrer Ibanez via cfe-commits
rogfer01 added a comment.

It came to my mind that might be good idea adding one of those "fix-it" 
suggestions so the user knows it can silence the warning by using parentheses. 
What do you think?


http://reviews.llvm.org/D20561



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


Re: [PATCH] D20798: clang-format: [JS] Sort imported symbols.

2016-06-01 Thread Martin Probst via cfe-commits
mprobst marked an inline comment as done.
mprobst added a comment.

http://reviews.llvm.org/D20798



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


Re: [PATCH] D20798: clang-format: [JS] Sort imported symbols.

2016-06-01 Thread Martin Probst via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL271400: clang-format: [JS] Sort imported symbols. (authored 
by mprobst).

Changed prior to commit:
  http://reviews.llvm.org/D20798?vs=59070&id=59226#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D20798

Files:
  cfe/trunk/lib/Format/Format.cpp
  cfe/trunk/lib/Format/SortJavaScriptImports.cpp
  cfe/trunk/unittests/Format/SortImportsTestJS.cpp

Index: cfe/trunk/lib/Format/SortJavaScriptImports.cpp
===
--- cfe/trunk/lib/Format/SortJavaScriptImports.cpp
+++ cfe/trunk/lib/Format/SortJavaScriptImports.cpp
@@ -25,6 +25,7 @@
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/Support/Debug.h"
+#include 
 #include 
 
 #define DEBUG_TYPE "format-formatter"
@@ -40,6 +41,13 @@
 struct JsImportedSymbol {
   StringRef Symbol;
   StringRef Alias;
+  SourceRange Range;
+
+  bool operator==(const JsImportedSymbol &RHS) const {
+// Ignore Range for comparison, it is only used to stitch code together,
+// but imports at different code locations are still conceptually the same.
+return Symbol == RHS.Symbol && Alias == RHS.Alias;
+  }
 };
 
 // An ES6 module reference.
@@ -139,23 +147,14 @@
  [&](unsigned LHSI, unsigned RHSI) {
return References[LHSI] < References[RHSI];
  });
-// FIXME: Pull this into a common function.
-bool OutOfOrder = false;
-for (unsigned i = 0, e = Indices.size(); i != e; ++i) {
-  if (i != Indices[i]) {
-OutOfOrder = true;
-break;
-  }
-}
-if (!OutOfOrder)
-  return Result;
+bool ReferencesInOrder = std::is_sorted(Indices.begin(), Indices.end());
 
-// Replace all existing import/export statements.
 std::string ReferencesText;
+bool SymbolsInOrder = true;
 for (unsigned i = 0, e = Indices.size(); i != e; ++i) {
   JsModuleReference Reference = References[Indices[i]];
-  StringRef ReferenceStmt = getSourceText(Reference.Range);
-  ReferencesText += ReferenceStmt;
+  if (appendReference(ReferencesText, Reference))
+SymbolsInOrder = false;
   if (i + 1 < e) {
 // Insert breaks between imports and exports.
 ReferencesText += "\n";
@@ -167,6 +166,10 @@
   ReferencesText += "\n";
   }
 }
+
+if (ReferencesInOrder && SymbolsInOrder)
+  return Result;
+
 // Separate references from the main code body of the file.
 if (FirstNonImportLine && FirstNonImportLine->First->NewlinesBefore < 2)
   ReferencesText += "\n";
@@ -211,10 +214,45 @@
   }
 
   StringRef getSourceText(SourceRange Range) {
+return getSourceText(Range.getBegin(), Range.getEnd());
+  }
+
+  StringRef getSourceText(SourceLocation Begin, SourceLocation End) {
 const SourceManager &SM = Env.getSourceManager();
-return FileContents.substr(SM.getFileOffset(Range.getBegin()),
-   SM.getFileOffset(Range.getEnd()) -
-   SM.getFileOffset(Range.getBegin()));
+return FileContents.substr(SM.getFileOffset(Begin),
+   SM.getFileOffset(End) - SM.getFileOffset(Begin));
+  }
+
+  // Appends ``Reference`` to ``Buffer``, returning true if text within the
+  // ``Reference`` changed (e.g. symbol order).
+  bool appendReference(std::string &Buffer, JsModuleReference &Reference) {
+// Sort the individual symbols within the import.
+// E.g. `import {b, a} from 'x';` -> `import {a, b} from 'x';`
+SmallVector Symbols = Reference.Symbols;
+std::stable_sort(
+Symbols.begin(), Symbols.end(),
+[&](const JsImportedSymbol &LHS, const JsImportedSymbol &RHS) {
+  return LHS.Symbol < RHS.Symbol;
+});
+if (Symbols == Reference.Symbols) {
+  // No change in symbol order.
+  StringRef ReferenceStmt = getSourceText(Reference.Range);
+  Buffer += ReferenceStmt;
+  return false;
+}
+// Stitch together the module reference start...
+SourceLocation SymbolsStart = Reference.Symbols.front().Range.getBegin();
+SourceLocation SymbolsEnd = Reference.Symbols.back().Range.getEnd();
+Buffer += getSourceText(Reference.Range.getBegin(), SymbolsStart);
+// ... then the references in order ...
+for (auto *I = Symbols.begin(), *E = Symbols.end(); I != E; ++I) {
+  if (I != Symbols.begin())
+Buffer += ",";
+  Buffer += getSourceText(I->Range);
+}
+// ... followed by the module reference end.
+Buffer += getSourceText(SymbolsEnd, Reference.Range.getEnd());
+return true;
   }
 
   // Parses module references in the given lines. Returns the module references,
@@ -350,6 +388,9 @@
 
   JsImportedSymbol Symbol;
   Symbol.Symbol = Current->TokenText;
+  // Make sure to include any preceding comments.
+  Symbol.Range.setBegin(
+  Current->getPrevio

Re: [PATCH] D20561: Warn when taking address of packed member

2016-06-01 Thread Aaron Ballman via cfe-commits
aaron.ballman added a comment.

In http://reviews.llvm.org/D20561#445730, @rogfer01 wrote:

> It came to my mind that might be good idea adding one of those "fix-it" 
> suggestions so the user knows it can silence the warning by using 
> parentheses. What do you think?


I don't think that would be appropriate here. We usually only use fix-it hints 
when we know the code is incorrect and the hint is the proper way to fix the 
problem. In this case, when we trigger the warning, we want users to fix the 
underlying problem of taking the address of something that will result in an 
unaligned pointer, but the fix-it you're thinking of will merely silence the 
warning without fixing the underlying problem.


http://reviews.llvm.org/D20561



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


r271401 - clang-format: [JS] no ASI on `import {x as\n y}`.

2016-06-01 Thread Martin Probst via cfe-commits
Author: mprobst
Date: Wed Jun  1 10:22:47 2016
New Revision: 271401

URL: http://llvm.org/viewvc/llvm-project?rev=271401&view=rev
Log:
clang-format: [JS] no ASI on `import {x as\n y}`.

Summary: ASI did not handle the ES6 `as` operator correctly.

Reviewers: djasper

Subscribers: klimek, cfe-commits

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

Modified:
cfe/trunk/lib/Format/SortJavaScriptImports.cpp
cfe/trunk/lib/Format/UnwrappedLineParser.cpp
cfe/trunk/unittests/Format/FormatTestJS.cpp

Modified: cfe/trunk/lib/Format/SortJavaScriptImports.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/SortJavaScriptImports.cpp?rev=271401&r1=271400&r2=271401&view=diff
==
--- cfe/trunk/lib/Format/SortJavaScriptImports.cpp (original)
+++ cfe/trunk/lib/Format/SortJavaScriptImports.cpp Wed Jun  1 10:22:47 2016
@@ -245,7 +245,7 @@ private:
 SourceLocation SymbolsEnd = Reference.Symbols.back().Range.getEnd();
 Buffer += getSourceText(Reference.Range.getBegin(), SymbolsStart);
 // ... then the references in order ...
-for (auto *I = Symbols.begin(), *E = Symbols.end(); I != E; ++I) {
+for (auto I = Symbols.begin(), E = Symbols.end(); I != E; ++I) {
   if (I != Symbols.begin())
 Buffer += ",";
   Buffer += getSourceText(I->Range);

Modified: cfe/trunk/lib/Format/UnwrappedLineParser.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/UnwrappedLineParser.cpp?rev=271401&r1=271400&r2=271401&view=diff
==
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp (original)
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp Wed Jun  1 10:22:47 2016
@@ -668,11 +668,11 @@ static bool mustBeJSIdent(const Addition
   // FIXME: This returns true for C/C++ keywords like 'struct'.
   return FormatTok->is(tok::identifier) &&
  (FormatTok->Tok.getIdentifierInfo() == nullptr ||
-  !FormatTok->isOneOf(Keywords.kw_in, Keywords.kw_of, 
Keywords.kw_async,
-  Keywords.kw_await, Keywords.kw_yield,
-  Keywords.kw_finally, Keywords.kw_function,
-  Keywords.kw_import, Keywords.kw_is,
-  Keywords.kw_let, Keywords.kw_var,
+  !FormatTok->isOneOf(Keywords.kw_in, Keywords.kw_of, Keywords.kw_as,
+  Keywords.kw_async, Keywords.kw_await,
+  Keywords.kw_yield, Keywords.kw_finally,
+  Keywords.kw_function, Keywords.kw_import,
+  Keywords.kw_is, Keywords.kw_let, Keywords.kw_var,
   Keywords.kw_abstract, Keywords.kw_extends,
   Keywords.kw_implements, Keywords.kw_instanceof,
   Keywords.kw_interface, Keywords.kw_throws));

Modified: cfe/trunk/unittests/Format/FormatTestJS.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJS.cpp?rev=271401&r1=271400&r2=271401&view=diff
==
--- cfe/trunk/unittests/Format/FormatTestJS.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp Wed Jun  1 10:22:47 2016
@@ -1010,6 +1010,9 @@ TEST_F(FormatTestJS, Modules) {
"} from 'some/module.js';");
   verifyFormat("import {X, Y,} from 'some/module.js';");
   verifyFormat("import {X as myLocalX, Y as myLocalY} from 'some/module.js';");
+  // Ensure Automatic Semicolon Insertion does not break on "as\n".
+  verifyFormat("import {X as myX} from 'm';", "import {X as\n"
+  " myX} from 'm';");
   verifyFormat("import * as lib from 'some/module.js';");
   verifyFormat("var x = {import: 1};\nx.import = 2;");
 


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


Re: [PATCH] D20817: clang-format: [JS] no ASI on `import {x as\n y}`.

2016-06-01 Thread Martin Probst via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL271401: clang-format: [JS] no ASI on `import {x as\n y}`. 
(authored by mprobst).

Changed prior to commit:
  http://reviews.llvm.org/D20817?vs=59074&id=59227#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D20817

Files:
  cfe/trunk/lib/Format/SortJavaScriptImports.cpp
  cfe/trunk/lib/Format/UnwrappedLineParser.cpp
  cfe/trunk/unittests/Format/FormatTestJS.cpp

Index: cfe/trunk/lib/Format/SortJavaScriptImports.cpp
===
--- cfe/trunk/lib/Format/SortJavaScriptImports.cpp
+++ cfe/trunk/lib/Format/SortJavaScriptImports.cpp
@@ -245,7 +245,7 @@
 SourceLocation SymbolsEnd = Reference.Symbols.back().Range.getEnd();
 Buffer += getSourceText(Reference.Range.getBegin(), SymbolsStart);
 // ... then the references in order ...
-for (auto *I = Symbols.begin(), *E = Symbols.end(); I != E; ++I) {
+for (auto I = Symbols.begin(), E = Symbols.end(); I != E; ++I) {
   if (I != Symbols.begin())
 Buffer += ",";
   Buffer += getSourceText(I->Range);
Index: cfe/trunk/lib/Format/UnwrappedLineParser.cpp
===
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp
@@ -668,11 +668,11 @@
   // FIXME: This returns true for C/C++ keywords like 'struct'.
   return FormatTok->is(tok::identifier) &&
  (FormatTok->Tok.getIdentifierInfo() == nullptr ||
-  !FormatTok->isOneOf(Keywords.kw_in, Keywords.kw_of, 
Keywords.kw_async,
-  Keywords.kw_await, Keywords.kw_yield,
-  Keywords.kw_finally, Keywords.kw_function,
-  Keywords.kw_import, Keywords.kw_is,
-  Keywords.kw_let, Keywords.kw_var,
+  !FormatTok->isOneOf(Keywords.kw_in, Keywords.kw_of, Keywords.kw_as,
+  Keywords.kw_async, Keywords.kw_await,
+  Keywords.kw_yield, Keywords.kw_finally,
+  Keywords.kw_function, Keywords.kw_import,
+  Keywords.kw_is, Keywords.kw_let, Keywords.kw_var,
   Keywords.kw_abstract, Keywords.kw_extends,
   Keywords.kw_implements, Keywords.kw_instanceof,
   Keywords.kw_interface, Keywords.kw_throws));
Index: cfe/trunk/unittests/Format/FormatTestJS.cpp
===
--- cfe/trunk/unittests/Format/FormatTestJS.cpp
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp
@@ -1010,6 +1010,9 @@
"} from 'some/module.js';");
   verifyFormat("import {X, Y,} from 'some/module.js';");
   verifyFormat("import {X as myLocalX, Y as myLocalY} from 'some/module.js';");
+  // Ensure Automatic Semicolon Insertion does not break on "as\n".
+  verifyFormat("import {X as myX} from 'm';", "import {X as\n"
+  " myX} from 'm';");
   verifyFormat("import * as lib from 'some/module.js';");
   verifyFormat("var x = {import: 1};\nx.import = 2;");
 


Index: cfe/trunk/lib/Format/SortJavaScriptImports.cpp
===
--- cfe/trunk/lib/Format/SortJavaScriptImports.cpp
+++ cfe/trunk/lib/Format/SortJavaScriptImports.cpp
@@ -245,7 +245,7 @@
 SourceLocation SymbolsEnd = Reference.Symbols.back().Range.getEnd();
 Buffer += getSourceText(Reference.Range.getBegin(), SymbolsStart);
 // ... then the references in order ...
-for (auto *I = Symbols.begin(), *E = Symbols.end(); I != E; ++I) {
+for (auto I = Symbols.begin(), E = Symbols.end(); I != E; ++I) {
   if (I != Symbols.begin())
 Buffer += ",";
   Buffer += getSourceText(I->Range);
Index: cfe/trunk/lib/Format/UnwrappedLineParser.cpp
===
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp
@@ -668,11 +668,11 @@
   // FIXME: This returns true for C/C++ keywords like 'struct'.
   return FormatTok->is(tok::identifier) &&
  (FormatTok->Tok.getIdentifierInfo() == nullptr ||
-  !FormatTok->isOneOf(Keywords.kw_in, Keywords.kw_of, Keywords.kw_async,
-  Keywords.kw_await, Keywords.kw_yield,
-  Keywords.kw_finally, Keywords.kw_function,
-  Keywords.kw_import, Keywords.kw_is,
-  Keywords.kw_let, Keywords.kw_var,
+  !FormatTok->isOneOf(Keywords.kw_in, Keywords.kw_of, Keywords.kw_as,
+  Keywords.kw_async, Keywords.kw_await,
+  Keywords.kw_yield, Keywords.kw_finally,
+  Keywords.kw_function, Keywords.kw_import,
+ 

Re: [PATCH] D20389: NVPTX: Add supported CL features

2016-06-01 Thread Anastasia Stulova via cfe-commits
Anastasia added inline comments.


Comment at: test/Misc/nvptx.languageOptsOpenCL.cl:1
@@ +1,2 @@
+// REQUIRES: nvptx-registered-target
+// RUN: %clang_cc1 -x cl -cl-std=CL %s -verify -triple nvptx-unknown-unknown

Should we check for errors on unsupported extensions for this target too?


Repository:
  rL LLVM

http://reviews.llvm.org/D20389



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


r271400 - clang-format: [JS] Sort imported symbols.

2016-06-01 Thread Martin Probst via cfe-commits
Author: mprobst
Date: Wed Jun  1 10:19:53 2016
New Revision: 271400

URL: http://llvm.org/viewvc/llvm-project?rev=271400&view=rev
Log:
clang-format: [JS] Sort imported symbols.

Summary: E.g. sort `import {b, a} from 'x';` into `import {a, b} from 'x';`.

Reviewers: djasper

Subscribers: cfe-commits, klimek

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

Modified:
cfe/trunk/lib/Format/Format.cpp
cfe/trunk/lib/Format/SortJavaScriptImports.cpp
cfe/trunk/unittests/Format/SortImportsTestJS.cpp

Modified: cfe/trunk/lib/Format/Format.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=271400&r1=271399&r2=271400&view=diff
==
--- cfe/trunk/lib/Format/Format.cpp (original)
+++ cfe/trunk/lib/Format/Format.cpp Wed Jun  1 10:19:53 2016
@@ -34,6 +34,7 @@
 #include "llvm/Support/Path.h"
 #include "llvm/Support/Regex.h"
 #include "llvm/Support/YAMLTraits.h"
+#include 
 #include 
 #include 
 #include 
@@ -1225,14 +1226,7 @@ static void sortCppIncludes(const Format
 
   // If the #includes are out of order, we generate a single replacement fixing
   // the entire block. Otherwise, no replacement is generated.
-  bool OutOfOrder = false;
-  for (unsigned i = 1, e = Indices.size(); i != e; ++i) {
-if (Indices[i] != i) {
-  OutOfOrder = true;
-  break;
-}
-  }
-  if (!OutOfOrder)
+  if (std::is_sorted(Indices.begin(), Indices.end()))
 return;
 
   std::string result;

Modified: cfe/trunk/lib/Format/SortJavaScriptImports.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/SortJavaScriptImports.cpp?rev=271400&r1=271399&r2=271400&view=diff
==
--- cfe/trunk/lib/Format/SortJavaScriptImports.cpp (original)
+++ cfe/trunk/lib/Format/SortJavaScriptImports.cpp Wed Jun  1 10:19:53 2016
@@ -25,6 +25,7 @@
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/Support/Debug.h"
+#include 
 #include 
 
 #define DEBUG_TYPE "format-formatter"
@@ -40,6 +41,13 @@ using clang::format::FormatStyle;
 struct JsImportedSymbol {
   StringRef Symbol;
   StringRef Alias;
+  SourceRange Range;
+
+  bool operator==(const JsImportedSymbol &RHS) const {
+// Ignore Range for comparison, it is only used to stitch code together,
+// but imports at different code locations are still conceptually the same.
+return Symbol == RHS.Symbol && Alias == RHS.Alias;
+  }
 };
 
 // An ES6 module reference.
@@ -139,23 +147,14 @@ public:
  [&](unsigned LHSI, unsigned RHSI) {
return References[LHSI] < References[RHSI];
  });
-// FIXME: Pull this into a common function.
-bool OutOfOrder = false;
-for (unsigned i = 0, e = Indices.size(); i != e; ++i) {
-  if (i != Indices[i]) {
-OutOfOrder = true;
-break;
-  }
-}
-if (!OutOfOrder)
-  return Result;
+bool ReferencesInOrder = std::is_sorted(Indices.begin(), Indices.end());
 
-// Replace all existing import/export statements.
 std::string ReferencesText;
+bool SymbolsInOrder = true;
 for (unsigned i = 0, e = Indices.size(); i != e; ++i) {
   JsModuleReference Reference = References[Indices[i]];
-  StringRef ReferenceStmt = getSourceText(Reference.Range);
-  ReferencesText += ReferenceStmt;
+  if (appendReference(ReferencesText, Reference))
+SymbolsInOrder = false;
   if (i + 1 < e) {
 // Insert breaks between imports and exports.
 ReferencesText += "\n";
@@ -167,6 +166,10 @@ public:
   ReferencesText += "\n";
   }
 }
+
+if (ReferencesInOrder && SymbolsInOrder)
+  return Result;
+
 // Separate references from the main code body of the file.
 if (FirstNonImportLine && FirstNonImportLine->First->NewlinesBefore < 2)
   ReferencesText += "\n";
@@ -211,10 +214,45 @@ private:
   }
 
   StringRef getSourceText(SourceRange Range) {
+return getSourceText(Range.getBegin(), Range.getEnd());
+  }
+
+  StringRef getSourceText(SourceLocation Begin, SourceLocation End) {
 const SourceManager &SM = Env.getSourceManager();
-return FileContents.substr(SM.getFileOffset(Range.getBegin()),
-   SM.getFileOffset(Range.getEnd()) -
-   SM.getFileOffset(Range.getBegin()));
+return FileContents.substr(SM.getFileOffset(Begin),
+   SM.getFileOffset(End) - 
SM.getFileOffset(Begin));
+  }
+
+  // Appends ``Reference`` to ``Buffer``, returning true if text within the
+  // ``Reference`` changed (e.g. symbol order).
+  bool appendReference(std::string &Buffer, JsModuleReference &Reference) {
+// Sort the individual symbols within the import.
+// E.g. `import {b, a} from 'x';` -> `import {a, b} from 'x';`
+SmallVector Symbols = Reference.Symbols;
+std::stable_sort(

Re: [PATCH] D20388: AMDGPU: Fix supported CL features

2016-06-01 Thread Anastasia Stulova via cfe-commits
Anastasia added inline comments.


Comment at: test/Misc/amdgcn.languageOptsOpenCL.cl:1
@@ +1,2 @@
+// REQUIRES: amdgpu-registered-target
+// RUN: %clang_cc1 -x cl -cl-std=CL %s -verify -triple amdgcn-unknown-unknown

Negative testing?


Repository:
  rL LLVM

http://reviews.llvm.org/D20388



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


[PATCH] D20867: [PCH] Fix timestamp check on windows hosts.

2016-06-01 Thread pierre gousseau via cfe-commits
pgousseau created this revision.
pgousseau added reviewers: rsmith, thakis.
pgousseau added subscribers: cfe-commits, wristow, probinson, gbedwell, bruno, 
cameron314.

On Linux, if the timestamp of a header file, included in the pch, is modified, 
then including the pch without regenerating it causes a fatal error, which is 
reasonable.
On Windows the check is ifdefed out, allowing the compilation to continue in a 
broken state.
The root of the broken state is that, if timestamps dont match, the 
preprocessor will reparse a header without discarding the pch data.
This leads to "#pragma once" header to be included twice.
The reason behind the ifdefing of the check lacks documentation, and was done 6 
years ago.
This change tentatively removes the ifdefing and adds a cc1 option to disable 
the inclusion of timestamps in pch files, giving some flexibility to build 
systems such as distributed builds.

This change is a follow up to the discussion started in 
http://reviews.llvm.org/D20243

http://reviews.llvm.org/D20867

Files:
  include/clang/Driver/CC1Options.td
  include/clang/Frontend/FrontendOptions.h
  lib/Frontend/CompilerInvocation.cpp
  lib/Frontend/FrontendActions.cpp
  lib/Serialization/ASTReader.cpp
  test/PCH/Inputs/include-timestamp-pch.h
  test/PCH/Inputs/include-timestamp.h
  test/PCH/include-timestamp.cpp

Index: test/PCH/include-timestamp.cpp
===
--- /dev/null
+++ test/PCH/include-timestamp.cpp
@@ -0,0 +1,18 @@
+// Test that the timestamp is not included in the produced pch file with
+// -fno-pch-timestamp.
+
+// Check timestamp is included by default.
+// RUN: %clang_cc1 -x c++-header -emit-pch -o %t %S/Inputs/include-timestamp-pch.h
+// RUN: touch %S/Inputs/include-timestamp.h
+// RUN: sleep 1
+// RUN: not %clang_cc1 -include-pch %t %s 2>&1 | FileCheck -check-prefix=CHECK-TIMESTAMP %s
+
+// Check timestamp inclusion is disabled by -fno-pch-timestamp.
+// RUN: %clang_cc1 -x c++-header -emit-pch -o %t %S/Inputs/include-timestamp-pch.h -fno-pch-timestamp 
+// RUN: touch %S/Inputs/include-timestamp.h
+// RUN: sleep 1
+// RUN: %clang_cc1 -include-pch %t %s 2>&1
+
+#include "Inputs/include-timestamp.h"
+
+// CHECK-TIMESTAMP: fatal error: file {{.*}} has been modified since the precompiled header {{.*}} was built
Index: test/PCH/Inputs/include-timestamp.h
===
--- /dev/null
+++ test/PCH/Inputs/include-timestamp.h
@@ -0,0 +1,3 @@
+#pragma once
+
+inline void f() {}
Index: test/PCH/Inputs/include-timestamp-pch.h
===
--- /dev/null
+++ test/PCH/Inputs/include-timestamp-pch.h
@@ -0,0 +1,4 @@
+#include "include-timestamp.h"
+
+void g() { f(); }
+
Index: lib/Serialization/ASTReader.cpp
===
--- lib/Serialization/ASTReader.cpp
+++ lib/Serialization/ASTReader.cpp
@@ -2010,17 +2010,8 @@
   // For an overridden file, there is nothing to validate.
   if (!Overridden && //
   (StoredSize != File->getSize() ||
-#if defined(LLVM_ON_WIN32)
-   false
-#else
-   // In our regression testing, the Windows file system seems to
-   // have inconsistent modification times that sometimes
-   // erroneously trigger this error-handling path.
-   //
-   // FIXME: This probably also breaks HeaderFileInfo lookups on Windows.
(StoredTime && StoredTime != File->getModificationTime() &&
 !DisableValidation)
-#endif
)) {
 if (Complain) {
   // Build a list of the PCH imports that got us here (in reverse).
Index: lib/Frontend/FrontendActions.cpp
===
--- lib/Frontend/FrontendActions.cpp
+++ lib/Frontend/FrontendActions.cpp
@@ -92,7 +92,10 @@
   std::vector> Consumers;
   Consumers.push_back(llvm::make_unique(
 CI.getPreprocessor(), OutputFile, nullptr, Sysroot,
-Buffer, CI.getFrontendOpts().ModuleFileExtensions));
+Buffer, CI.getFrontendOpts().ModuleFileExtensions,
+/*AllowASTWithErrors*/false,
+/*IncludeTimestamps*/
+  +CI.getFrontendOpts().IncludeTimestamps));
   Consumers.push_back(CI.getPCHContainerWriter().CreatePCHContainerGenerator(
   CI, InFile, OutputFile, OS, Buffer));
 
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -1144,6 +1144,7 @@
   Opts.ModuleFiles = Args.getAllArgValues(OPT_fmodule_file);
   Opts.ModulesEmbedFiles = Args.getAllArgValues(OPT_fmodules_embed_file_EQ);
   Opts.ModulesEmbedAllFiles = Args.hasArg(OPT_fmodules_embed_all_files);
+  Opts.IncludeTimestamps = !Args.hasArg(OPT_fno_pch_timestamp);
 
   Opts.CodeCompleteOpts.IncludeMacros
 = Arg

Re: [PATCH] D20744: [OpenCL] Disable warning about core features by default

2016-06-01 Thread Anastasia Stulova via cfe-commits
Anastasia accepted this revision.
Anastasia added a comment.

LGTM!


Repository:
  rL LLVM

http://reviews.llvm.org/D20744



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


Re: [PATCH] D17438: [OpenCL] Add Sema checks for atomics and implicit declaration

2016-06-01 Thread Anastasia Stulova via cfe-commits
Anastasia added a comment.

In http://reviews.llvm.org/D17438#443422, @pxli168 wrote:

> Yes, I found although the khronos have make a clarify with implicit 
> declarations but they sames to be useful with some program link. And I found 
> some test case about link could not pass by this reason.
>  But how should we handle the new added spec?


Could you add the tests that don't pass to the Khronos bug? I will try to 
discuss it on the next call.

Thanks!


http://reviews.llvm.org/D17438



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


Re: r271399 - It seems we need to add SemaExpr.cpp to the /bigobj list; I am getting consistent failures of hitting the section count limit.

2016-06-01 Thread Yaron Keren via cfe-commits
Thanks!  I've just noticed this today locally. It happens with unoptimized
builds only so the bots are not catching it.



2016-06-01 18:17 GMT+03:00 Aaron Ballman via cfe-commits <
cfe-commits@lists.llvm.org>:

> Author: aaronballman
> Date: Wed Jun  1 10:17:54 2016
> New Revision: 271399
>
> URL: http://llvm.org/viewvc/llvm-project?rev=271399&view=rev
> Log:
> It seems we need to add SemaExpr.cpp to the /bigobj list; I am getting
> consistent failures of hitting the section count limit.
>
> Modified:
> cfe/trunk/lib/Sema/CMakeLists.txt
>
> Modified: cfe/trunk/lib/Sema/CMakeLists.txt
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/CMakeLists.txt?rev=271399&r1=271398&r2=271399&view=diff
>
> ==
> --- cfe/trunk/lib/Sema/CMakeLists.txt (original)
> +++ cfe/trunk/lib/Sema/CMakeLists.txt Wed Jun  1 10:17:54 2016
> @@ -2,6 +2,10 @@ set(LLVM_LINK_COMPONENTS
>Support
>)
>
> +if (MSVC)
> +  set_source_files_properties(SemaExpr.cpp PROPERTIES COMPILE_FLAGS
> /bigobj)
> +endif()
> +
>  add_clang_library(clangSema
>AnalysisBasedWarnings.cpp
>AttributeList.cpp
>
>
> ___
> 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


r271399 - It seems we need to add SemaExpr.cpp to the /bigobj list; I am getting consistent failures of hitting the section count limit.

2016-06-01 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Wed Jun  1 10:17:54 2016
New Revision: 271399

URL: http://llvm.org/viewvc/llvm-project?rev=271399&view=rev
Log:
It seems we need to add SemaExpr.cpp to the /bigobj list; I am getting 
consistent failures of hitting the section count limit.

Modified:
cfe/trunk/lib/Sema/CMakeLists.txt

Modified: cfe/trunk/lib/Sema/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/CMakeLists.txt?rev=271399&r1=271398&r2=271399&view=diff
==
--- cfe/trunk/lib/Sema/CMakeLists.txt (original)
+++ cfe/trunk/lib/Sema/CMakeLists.txt Wed Jun  1 10:17:54 2016
@@ -2,6 +2,10 @@ set(LLVM_LINK_COMPONENTS
   Support
   )
 
+if (MSVC)
+  set_source_files_properties(SemaExpr.cpp PROPERTIES COMPILE_FLAGS /bigobj)
+endif()
+
 add_clang_library(clangSema
   AnalysisBasedWarnings.cpp
   AttributeList.cpp


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


Re: [PATCH] D20843: ObjC lifetime: pull sugar off when the qualifiers conflict.

2016-06-01 Thread John McCall via cfe-commits
rjmccall added a comment.

Oh sure, because we don't strip the original type if there isn't a conflict.  
LGTM.


http://reviews.llvm.org/D20843



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


Re: [PATCH] D20843: ObjC lifetime: pull sugar off when the qualifiers conflict.

2016-06-01 Thread Manman Ren via cfe-commits
manmanren added a comment.

In http://reviews.llvm.org/D20843#445756, @rjmccall wrote:

> Oh sure, because we don't strip the original type if there isn't a conflict.  
> LGTM.


Exactly, thanks for reviewing!

Manman


http://reviews.llvm.org/D20843



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


Re: [PATCH] D20844: FixIt: correctly set DeclSpec's range end for a type name annotation.

2016-06-01 Thread John McCall via cfe-commits
rjmccall added a comment.

Hmm.  No, I think the original code is correct here — RangeEnd is a token 
range, and those are generally inclusive rather than exclusive.  The fix-it 
needs to be inserting at the end of the token.


http://reviews.llvm.org/D20844



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


Re: [PATCH] D20630: [OpenCL] Allow -std={cl|CL}{|1.1|1.2|2.0} in driver

2016-06-01 Thread Anastasia Stulova via cfe-commits
Anastasia accepted this revision.
Anastasia added a comment.
This revision is now accepted and ready to land.

LGTM! Thanks!


http://reviews.llvm.org/D20630



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


Re: [PATCH] D20561: Warn when taking address of packed member

2016-06-01 Thread Roger Ferrer Ibanez via cfe-commits
rogfer01 marked 2 inline comments as done.
rogfer01 added a comment.

Well, the assignment-vs-comparison warning does emit a fix-it in 
`Sema::DiagnoseAssignmentAsCondition(Expr *E)`

  Diag(Loc, diag::note_condition_assign_silence)
<< FixItHint::CreateInsertion(Open, "(")
<< FixItHint::CreateInsertion(Close, ")");



  def note_condition_assign_silence : Note<
"place parentheses around the assignment to silence this warning">;

so I thought it could be appropiate.


http://reviews.llvm.org/D20561



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


Re: [PATCH] D20444: [OpenCL] Include opencl-c.h by default as a clang module

2016-06-01 Thread Anastasia Stulova via cfe-commits
Anastasia added inline comments.


Comment at: lib/Frontend/CompilerInvocation.cpp:1782
@@ -1773,2 +1781,3 @@
   Opts.RTTIData = Opts.RTTI && !Args.hasArg(OPT_fno_rtti_data);
-  Opts.Blocks = Args.hasArg(OPT_fblocks);
+  Opts.Blocks = Args.hasArg(OPT_fblocks) || (Opts.OpenCL
+&& Opts.OpenCLVersion >= 200 && !Args.hasArg(OPT_fno_blocks));

Is this change being tested somewhere?


http://reviews.llvm.org/D20444



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


[PATCH] D20870: [Clang][AVX512][INTRINSICS] adding round cvt and fix regular cvtps_ph

2016-06-01 Thread michael zuckerman via cfe-commits
m_zuckerman created this revision.
m_zuckerman added reviewers: AsafBadouh, igorb, delena.
m_zuckerman added a subscriber: cfe-commits.

http://reviews.llvm.org/D20870

Files:
  lib/Headers/avx512vlintrin.h
  test/CodeGen/avx512vl-builtins.c

Index: test/CodeGen/avx512vl-builtins.c
===
--- test/CodeGen/avx512vl-builtins.c
+++ test/CodeGen/avx512vl-builtins.c
@@ -6726,24 +6726,47 @@
 __m128i test_mm_mask_cvtps_ph(__m128i __W, __mmask8 __U, __m128 __A) {
   // CHECK-LABEL: @test_mm_mask_cvtps_ph
   // CHECK: @llvm.x86.avx512.mask.vcvtps2ph.128
-  return _mm_mask_cvtps_ph(__W, __U, __A, _MM_FROUND_CUR_DIRECTION); 
+  return _mm_mask_cvtps_ph(__W, __U, __A); 
 }
 
 __m128i test_mm_maskz_cvtps_ph(__mmask8 __U, __m128 __A) {
   // CHECK-LABEL: @test_mm_maskz_cvtps_ph
   // CHECK: @llvm.x86.avx512.mask.vcvtps2ph.128
-  return _mm_maskz_cvtps_ph(__U, __A, _MM_FROUND_CUR_DIRECTION); 
+  return _mm_maskz_cvtps_ph(__U, __A); 
 }
 
 __m128i test_mm256_mask_cvtps_ph(__m128i __W, __mmask8 __U, __m256 __A) {
   // CHECK-LABEL: @test_mm256_mask_cvtps_ph
   // CHECK: @llvm.x86.avx512.mask.vcvtps2ph.256
-  return _mm256_mask_cvtps_ph(__W, __U, __A, _MM_FROUND_CUR_DIRECTION); 
+  return _mm256_mask_cvtps_ph(__W, __U, __A); 
 }
 
 __m128i test_mm256_maskz_cvtps_ph(__mmask8 __U, __m256 __A) {
   // CHECK-LABEL: @test_mm256_maskz_cvtps_ph
   // CHECK: @llvm.x86.avx512.mask.vcvtps2ph.256
-  return _mm256_maskz_cvtps_ph(__U, __A, _MM_FROUND_CUR_DIRECTION); 
+  return _mm256_maskz_cvtps_ph(__U, __A);
 }
 
+__m128i test_mm_mask_cvt_roundps_ph(__m128i __W, __mmask8 __U, __m128 __A) {
+  // CHECK-LABEL: @test_mm_mask_cvt_roundps_ph
+  // CHECK: @llvm.x86.avx512.mask.vcvtps2ph.128
+  return _mm_mask_cvt_roundps_ph(__W, __U, __A, _MM_FROUND_CUR_DIRECTION); 
+}
+
+__m128i test_mm_maskz_cvt_roundps_ph(__mmask8 __U, __m128 __A) {
+  // CHECK-LABEL: @test_mm_maskz_cvt_roundps_ph
+  // CHECK: @llvm.x86.avx512.mask.vcvtps2ph.128
+  return _mm_maskz_cvt_roundps_ph(__U, __A, _MM_FROUND_CUR_DIRECTION); 
+}
+
+__m128i test_mm256_mask_cvt_roundps_ph(__m128i __W, __mmask8 __U, __m256 __A) {
+  // CHECK-LABEL: @test_mm256_mask_cvt_roundps_ph
+  // CHECK: @llvm.x86.avx512.mask.vcvtps2ph.256
+  return _mm256_mask_cvt_roundps_ph(__W, __U, __A, _MM_FROUND_CUR_DIRECTION); 
+}
+
+__m128i test_mm256_maskz_cvt_roundps_ph(__mmask8 __U, __m256 __A) {
+  // CHECK-LABEL: @test_mm256_maskz_cvt_roundps_ph
+  // CHECK: @llvm.x86.avx512.mask.vcvtps2ph.256
+  return _mm256_maskz_cvt_roundps_ph(__U, __A, _MM_FROUND_CUR_DIRECTION); 
+}
Index: lib/Headers/avx512vlintrin.h
===
--- lib/Headers/avx512vlintrin.h
+++ lib/Headers/avx512vlintrin.h
@@ -9383,26 +9383,58 @@
 (__mmask8) __U);
 }
 
-#define _mm_mask_cvtps_ph(W, U, A, I) __extension__ ({ \
+static __inline __m128i __DEFAULT_FN_ATTRS
+_mm_mask_cvtps_ph (__m128i __W, __mmask8 __U, __m128 __A)
+{
+  return (__m128i) __builtin_ia32_vcvtps2ph_mask ((__v4sf) __A, _MM_FROUND_CUR_DIRECTION,
+  (__v8hi) __W,
+  (__mmask8) __U);
+}
+
+static __inline __m128i __DEFAULT_FN_ATTRS
+_mm_maskz_cvtps_ph (__mmask8 __U, __m128 __A)
+{
+  return (__m128i) __builtin_ia32_vcvtps2ph_mask ((__v4sf) __A, _MM_FROUND_CUR_DIRECTION,
+  (__v8hi) _mm_setzero_si128 (),
+  (__mmask8) __U);
+}
+
+#define _mm_mask_cvt_roundps_ph(W, U, A, I) __extension__ ({ \
   (__m128i)__builtin_ia32_vcvtps2ph_mask((__v4sf)(__m128)(A), (int)(I), \
  (__v8hi)(__m128i)(W), \
  (__mmask8)(U)); })
 
-#define _mm_maskz_cvtps_ph(U, A, I) __extension__ ({ \
+#define _mm_maskz_cvt_roundps_ph(U, A, I) __extension__ ({ \
   (__m128i)__builtin_ia32_vcvtps2ph_mask((__v4sf)(__m128)(A), (int)(I), \
  (__v8hi)_mm_setzero_si128(), \
  (__mmask8)(U)); })
 
-#define _mm256_mask_cvtps_ph(W, U, A, I) __extension__ ({ \
+static __inline __m128i __DEFAULT_FN_ATTRS
+_mm256_mask_cvtps_ph (__m128i __W, __mmask8 __U, __m256 __A)
+{
+  return (__m128i) __builtin_ia32_vcvtps2ph256_mask ((__v8sf) __A, _MM_FROUND_CUR_DIRECTION,
+  (__v8hi) __W,
+  (__mmask8) __U);
+}
+
+static __inline __m128i __DEFAULT_FN_ATTRS
+_mm256_maskz_cvtps_ph ( __mmask8 __U, __m256 __A)
+{
+  return (__m128i) __builtin_ia32_vcvtps2ph256_mask ((__v8sf) __A, _MM_FROUND_CUR_DIRECTION,
+  (__v8hi) _mm_setzero_si128(),
+  (__mmask8) __U);
+}
+#define _mm256_mask_cvt_roundps_ph(W, U, A, I) __extension__ ({ \
   (__m128i)__builtin_i

Re: [PATCH] D20447: [OpenCL] Fixup extension list

2016-06-01 Thread Jan Vesely via cfe-commits
jvesely marked 2 inline comments as done.


Comment at: test/SemaOpenCL/extension-version.cl:73
@@ +72,3 @@
+
+#endif
+

Anastasia wrote:
> Could you put a comment to make it more readable, something like 
> 
> #endif // (__OPENCL_C_VERSION__ < 110)
These large blocks get broken into ~7 line pieces, in D20744. Do you still want 
the endif comments there, or should I add the comments here and remove them in 
D20744?


Repository:
  rL LLVM

http://reviews.llvm.org/D20447



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


Re: [PATCH] D20561: Warn when taking address of packed member

2016-06-01 Thread Roger Ferrer Ibanez via cfe-commits
rogfer01 added a comment.

I think I wasn't clear with the purpose of the fix-it: there are a few cases 
where getting the address of an unaligned pointer is safe (i.e. false 
positives).

For instance, when I checked Firefox and Chromium there are cases where getting 
the address of an unaligned pointer is fine. For the particular case of these 
two browsers, they both use a library (usrsctp) that represents protocol data 
as packed structs. That library passes addresses of packed fields to `memcpy` 
and `memmove` which is OK.

The fix-it can help silencing the warning for those cases once deemed safe. 
This is the reason why I keep comparing the new warning to the 
assignment-vs-comparison warning: there may not be an error, just extra syntax 
(parentheses) can be used to silence the warning.


http://reviews.llvm.org/D20561



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


[PATCH] D20871: [Clang][AVX512][Intrinsics] Adding two definitions _mm512_setzero and _mm512_setzero_epi32

2016-06-01 Thread michael zuckerman via cfe-commits
m_zuckerman created this revision.
m_zuckerman added reviewers: AsafBadouh, igorb, delena.
m_zuckerman added a subscriber: cfe-commits.

http://reviews.llvm.org/D20871

Files:
  lib/Headers/avx512fintrin.h

Index: lib/Headers/avx512fintrin.h
===
--- lib/Headers/avx512fintrin.h
+++ lib/Headers/avx512fintrin.h
@@ -164,6 +164,8 @@
   return (__m512i)(__v8di){ 0, 0, 0, 0, 0, 0, 0, 0 };
 }
 
+#define _mm512_setzero_epi32 _mm512_setzero_si512
+
 static __inline__ __m512d __DEFAULT_FN_ATTRS
 _mm512_undefined_pd()
 {
@@ -268,6 +270,9 @@
   return (__m512){ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
 }
+
+#define _mm512_setzero _mm512_setzero_ps
+
 static  __inline __m512d __DEFAULT_FN_ATTRS
 _mm512_setzero_pd(void)
 {


Index: lib/Headers/avx512fintrin.h
===
--- lib/Headers/avx512fintrin.h
+++ lib/Headers/avx512fintrin.h
@@ -164,6 +164,8 @@
   return (__m512i)(__v8di){ 0, 0, 0, 0, 0, 0, 0, 0 };
 }
 
+#define _mm512_setzero_epi32 _mm512_setzero_si512
+
 static __inline__ __m512d __DEFAULT_FN_ATTRS
 _mm512_undefined_pd()
 {
@@ -268,6 +270,9 @@
   return (__m512){ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
 }
+
+#define _mm512_setzero _mm512_setzero_ps
+
 static  __inline __m512d __DEFAULT_FN_ATTRS
 _mm512_setzero_pd(void)
 {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20447: [OpenCL] Fixup extension list

2016-06-01 Thread Anastasia Stulova via cfe-commits
Anastasia added inline comments.


Comment at: test/SemaOpenCL/extension-version.cl:73
@@ +72,3 @@
+
+#endif
+

jvesely wrote:
> Anastasia wrote:
> > Could you put a comment to make it more readable, something like 
> > 
> > #endif // (__OPENCL_C_VERSION__ < 110)
> These large blocks get broken into ~7 line pieces, in D20744. Do you still 
> want the endif comments there, or should I add the comments here and remove 
> them in D20744?
Ok, no problem. Let's just leave it as is. I guess the other change will be 
committed soon. :)


Repository:
  rL LLVM

http://reviews.llvm.org/D20447



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


Re: [PATCH] D20561: Warn when taking address of packed member

2016-06-01 Thread Roger Ferrer Ibanez via cfe-commits
rogfer01 marked 5 inline comments as done.
rogfer01 added a comment.

http://reviews.llvm.org/D20561



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


Re: [PATCH] D20447: [OpenCL] Fixup extension list

2016-06-01 Thread Jan Vesely via cfe-commits
jvesely updated this revision to Diff 59240.
jvesely added a comment.

Fix typo: COre -> Core


Repository:
  rL LLVM

http://reviews.llvm.org/D20447

Files:
  include/clang/Basic/OpenCLExtensions.def
  test/SemaOpenCL/extension-version.cl

Index: test/SemaOpenCL/extension-version.cl
===
--- /dev/null
+++ test/SemaOpenCL/extension-version.cl
@@ -0,0 +1,225 @@
+// RUN: %clang_cc1 -x cl -cl-std=CL %s -verify -triple spir-unknown-unknown
+// RUN: %clang_cc1 -x cl -cl-std=CL1.1 %s -verify -triple spir-unknown-unknown
+// RUN: %clang_cc1 -x cl -cl-std=CL1.2 %s -verify -triple spir-unknown-unknown
+// RUN: %clang_cc1 -x cl -cl-std=CL2.0 %s -verify -triple spir-unknown-unknown
+
+#if __OPENCL_C_VERSION__ >= 200
+// expected-no-diagnostics
+#endif
+
+// Extensions in all versions
+#ifndef cl_clang_storage_class_specifiers
+#error "Missing cl_clang_storage_class_specifiers define"
+#endif
+#pragma OPENCL EXTENSION cl_clang_storage_class_specifiers: enable
+
+#ifndef cl_khr_fp16
+#error "Missing cl_khr_fp16 define"
+#endif
+#pragma OPENCL EXTENSION cl_khr_fp16: enable
+
+#ifndef cl_khr_int64_base_atomics
+#error "Missing cl_khr_int64_base_atomics define"
+#endif
+#pragma OPENCL EXTENSION cl_khr_int64_base_atomics: enable
+
+#ifndef cl_khr_int64_extended_atomics
+#error "Missing cl_khr_int64_extended_atomics define"
+#endif
+#pragma OPENCL EXTENSION cl_khr_int64_extended_atomics: enable
+
+#ifndef cl_khr_gl_sharing
+#error "Missing cl_khr_gl_sharing define"
+#endif
+#pragma OPENCL EXTENSION cl_khr_gl_sharing: enable
+
+#ifndef cl_khr_icd
+#error "Missing cl_khr_icd define"
+#endif
+#pragma OPENCL EXTENSION cl_khr_icd: enable
+
+// Core features in CL 1.1
+#if (__OPENCL_C_VERSION__ < 110)
+#ifndef cl_khr_byte_addressable_store
+#error "Missing cl_khr_byte_addressable_store define"
+#endif
+#pragma OPENCL EXTENSION cl_khr_byte_addressable_store: enable
+
+#ifndef cl_khr_global_int32_base_atomics
+#error "Missing cl_khr_global_int32_base_atomics define"
+#endif
+#pragma OPENCL EXTENSION cl_khr_global_int32_base_atomics: enable
+
+#ifndef cl_khr_global_int32_extended_atomics
+#error "Missing cl_khr_global_int32_extended_atomics define"
+#endif
+#pragma OPENCL EXTENSION cl_khr_global_int32_extended_atomics: enable
+
+#ifndef cl_khr_local_int32_base_atomics
+#error "Missing cl_khr_local_int32_base_atomics define"
+#endif
+#pragma OPENCL EXTENSION cl_khr_local_int32_base_atomics: enable
+
+#ifndef cl_khr_local_int32_extended_atomics
+#error "Missing cl_khr_local_int32_extended_atomics define"
+#endif
+#pragma OPENCL EXTENSION cl_khr_local_int32_extended_atomics: enable
+
+#ifndef cl_khr_select_fprounding_mode
+#error "Missing cl_khr_select_fp_rounding_mode define"
+#endif
+#pragma OPENCL EXTENSION cl_khr_select_fprounding_mode: enable
+
+#endif
+
+// Core feature in CL 1.2
+#if (__OPENCL_C_VERSION__ < 120)
+#ifndef cl_khr_fp64
+#error "Missing cl_khr_fp64 define"
+#endif
+#pragma OPENCL EXTENSION cl_khr_fp64: enable
+#endif
+
+//Core feature in CL 2.0
+#if (__OPENCL_C_VERSION__ < 200)
+#ifndef cl_khr_3d_image_writes
+#error "Missing cl_khr_3d_image_writes define"
+#endif
+#pragma OPENCL EXTENSION cl_khr_3d_image_writes: enable
+#endif
+
+
+#if (__OPENCL_C_VERSION__ >= 110)
+#ifndef cl_khr_gl_event
+#error "Missing cl_khr_gl_event define"
+#endif
+#else
+// expected-warning@+2{{unsupported OpenCL extension 'cl_khr_gl_event' - ignoring}}
+#endif
+#pragma OPENCL EXTENSION cl_khr_gl_event: enable
+
+#if (__OPENCL_C_VERSION__ >= 110)
+#ifndef cl_khr_d3d10_sharing
+#error "Missing cl_khr_d3d10_sharing define"
+#endif
+#else
+// expected-warning@+2{{unsupported OpenCL extension 'cl_khr_d3d10_sharing' - ignoring}}
+#endif
+#pragma OPENCL EXTENSION cl_khr_d3d10_sharing: enable
+
+#if (__OPENCL_C_VERSION__ >= 120)
+#ifndef cl_khr_context_abort
+#error "Missing cl_context_abort define"
+#endif
+#else
+// expected-warning@+2{{unsupported OpenCL extension 'cl_khr_context_abort' - ignoring}}
+#endif
+#pragma OPENCL EXTENSION cl_khr_context_abort: enable
+
+#if (__OPENCL_C_VERSION__ >= 120)
+#ifndef cl_khr_d3d11_sharing
+#error "Missing cl_khr_d3d11_sharing define"
+#endif
+#else
+// expected-warning@+2{{unsupported OpenCL extension 'cl_khr_d3d11_sharing' - ignoring}}
+#endif
+#pragma OPENCL EXTENSION cl_khr_d3d11_sharing: enable
+
+#if (__OPENCL_C_VERSION__ >= 120)
+#ifndef cl_khr_dx9_media_sharing
+#error "Missing cl_khr_dx9_media_sharing define"
+#endif
+#else
+// expected-warning@+2{{unsupported OpenCL extension 'cl_khr_dx9_media_sharing' - ignoring}}
+#endif
+#pragma OPENCL EXTENSION cl_khr_dx9_media_sharing: enable
+
+#if (__OPENCL_C_VERSION__ >= 120)
+#ifndef cl_khr_image2d_from_buffer
+#error "Missing cl_khr_image2d_from_buffer define"
+#endif
+#else
+// expected-warning@+2{{unsupported OpenCL extension 'cl_khr_image2d_from_buffer' - ignoring}}
+#endif
+#pragma OPENCL EXTENSION cl_khr_image2d_from_buffer: enable
+
+#if (__OPENCL_C_VERSION__ >= 120)
+#ifndef cl_khr_ini

Re: [PATCH] D20561: Warn when taking address of packed member

2016-06-01 Thread Roger Ferrer Ibanez via cfe-commits
rogfer01 updated this revision to Diff 59241.
rogfer01 added a comment.

This change adds a fix-it suggesting parentheses to silence the warning.


http://reviews.llvm.org/D20561

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaExpr.cpp
  test/Sema/address-packed.c
  test/SemaCXX/address-packed.cpp

Index: test/SemaCXX/address-packed.cpp
===
--- /dev/null
+++ test/SemaCXX/address-packed.cpp
@@ -0,0 +1,110 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+extern void f1(int *);
+extern void f2(char *);
+
+struct __attribute__((packed)) Arguable {
+  int x;
+  char c;
+  static void foo();
+};
+
+extern void f3(void());
+
+namespace Foo {
+struct __attribute__((packed)) Arguable {
+  char c;
+  int x;
+  static void foo();
+};
+}
+
+struct Arguable *get_arguable();
+
+void g0() {
+  {
+Foo::Arguable arguable;
+f1(&arguable.x);   // expected-warning {{packed member 'x' of class or structure 'Foo::Arguable'}}
+   // expected-note@-1 {{place parentheses around the 'arguable.x'}}
+f2(&arguable.c);   // no-warning
+f3(&arguable.foo); // no-warning
+  }
+  {
+Arguable arguable1;
+Arguable &arguable(arguable1);
+f1(&arguable.x);   // expected-warning {{packed member 'x' of class or structure 'Arguable'}}
+   // expected-note@-1 {{place parentheses around the 'arguable.x'}}
+f2(&arguable.c);   // no-warning
+f3(&arguable.foo); // no-warning
+  }
+  {
+Arguable *arguable1;
+Arguable *&arguable(arguable1);
+f1(&arguable->x);   // expected-warning {{packed member 'x' of class or structure 'Arguable'}}
+// expected-note@-1 {{place parentheses around the 'arguable->x'}}
+f2(&arguable->c);   // no-warning
+f3(&arguable->foo); // no-warning
+  }
+}
+
+struct __attribute__((packed)) A {
+  int x;
+  char c;
+
+  int *f0() {
+return &this->x; // expected-warning {{packed member 'x' of class or structure 'A'}}
+ // expected-note@-1 {{place parentheses around the 'this->x'}}
+  }
+
+  int *g0() {
+return &x; // expected-warning {{packed member 'x' of class or structure 'A'}}
+   // expected-note@-1 {{place parentheses around the 'this->x'}}
+  }
+
+  char *h0() {
+return &c; // no-warning
+  }
+};
+
+struct B : A {
+  int *f1() {
+return &this->x; // expected-warning {{packed member 'x' of class or structure 'A'}}
+ // expected-note@-1 {{place parentheses around the 'this->x'}}
+  }
+
+  int *g1() {
+return &x; // expected-warning {{packed member 'x' of class or structure 'A'}}
+   // expected-note@-1 {{place parentheses around the 'this->x'}}
+  }
+
+  char *h1() {
+return &c; // no-warning
+  }
+};
+
+template 
+class __attribute__((packed)) S {
+  Ty X;
+
+public:
+  const Ty *get() const {
+return &X; // expected-warning {{packed member 'X' of class or structure 'S'}}
+   // expected-warning@-1 {{packed member 'X' of class or structure 'S'}}
+   // expected-note@-2 {{place parentheses around the 'this->X'}}
+   // expected-note@-3 {{place parentheses around the 'this->X'}}
+  }
+};
+
+template 
+void h(Ty*);
+
+void g1()
+{
+S s1;
+s1.get(); // expected-note {{in instantiation of member function 'S::get'}}
+
+S s2;
+s2.get();
+
+S s3;
+s3.get(); // expected-note {{in instantiation of member function 'S::get'}}
+}
Index: test/Sema/address-packed.c
===
--- /dev/null
+++ test/Sema/address-packed.c
@@ -0,0 +1,135 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+extern void f1(int *);
+extern void f2(char *);
+
+struct Ok {
+  char c;
+  int x;
+};
+
+struct __attribute__((packed)) Arguable {
+  char c0;
+  int x;
+  char c1;
+};
+
+union __attribute__((packed)) UnionArguable {
+  char c;
+  int x;
+};
+
+typedef struct Arguable ArguableT;
+
+struct Arguable *get_arguable();
+
+void g0(void) {
+  {
+struct Ok ok;
+f1(&ok.x); // no-warning
+f2(&ok.c); // no-warning
+  }
+  {
+struct Arguable arguable;
+f2(&arguable.c0); // no-warning
+f1(&arguable.x);  // expected-warning {{packed member 'x' of class or structure 'Arguable'}}
+  // expected-note@-1 {{place parentheses around the 'arguable.x'}}
+f2(&arguable.c1); // no-warning
+  }
+  {
+union UnionArguable arguable;
+f2(&arguable.c); // no-warning
+f1(&arguable.x); // expected-warning {{packed member 'x' of class or structure 'UnionArguable'}}
+ // expected-note@-1 {{place parentheses around the 'arguable.x'}}
+  }
+  {
+ArguableT arguable;
+f2(&arguable.c0); // no-warning
+f1(&arguable.x);  // expected-warning {{packed member 'x' of class or structure 'Arguable'}}
+  // expected-note@-1 {{place parentheses around the 'arguable.x'}}
+f2(&arguable.c1); // no-warning
+  }
+  {
+struct Arg

Re: [PATCH] D20447: [OpenCL] Fixup extension list

2016-06-01 Thread Anastasia Stulova via cfe-commits
Anastasia accepted this revision.
Anastasia added a comment.
This revision is now accepted and ready to land.

LGTM! Thanks!


Repository:
  rL LLVM

http://reviews.llvm.org/D20447



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


Re: [PATCH] D16545: [libcxxabi] Enable testing for static libc++abi

2016-06-01 Thread Asiri Rathnayake via cfe-commits
rmaprath added a comment.

Works great. Thanks!


http://reviews.llvm.org/D16545



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


Re: [PATCH] D20714: [Clang-tidy] Fix some Include What You Use warnings; other minor fixes

2016-06-01 Thread Eugene Zelenko via cfe-commits
Eugene.Zelenko added a comment.

There is a way to tell IWYU about compound headers with pragmas 
.
 I also suggested to make this possible via file with compound headers list.

But person who knows LLVM/Clang code base better then me should define such 
headers.


Repository:
  rL LLVM

http://reviews.llvm.org/D20714



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


Re: [PATCH] D20867: [PCH] Fix timestamp check on windows hosts.

2016-06-01 Thread Bruno Cardoso Lopes via cfe-commits
bruno added inline comments.


Comment at: test/PCH/include-timestamp.cpp:5
@@ +4,3 @@
+// Check timestamp is included by default.
+// RUN: %clang_cc1 -x c++-header -emit-pch -o %t 
%S/Inputs/include-timestamp-pch.h
+// RUN: touch %S/Inputs/include-timestamp.h

Can you also check the timestamp by looking at llvm-bcanalyzer output (assuming 
the tool outputs such info)?


Comment at: test/PCH/include-timestamp.cpp:7
@@ +6,3 @@
+// RUN: touch %S/Inputs/include-timestamp.h
+// RUN: sleep 1
+// RUN: not %clang_cc1 -include-pch %t %s 2>&1 | FileCheck 
-check-prefix=CHECK-TIMESTAMP %s

Why use `sleep 1` here?


Comment at: test/PCH/include-timestamp.cpp:16
@@ +15,3 @@
+
+#include "Inputs/include-timestamp.h"
+

It make sense for the context of this patch, but if 
http://reviews.llvm.org/D20243 gets in, you should re-use the same headers 
you're adding there.


http://reviews.llvm.org/D20867



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


r271409 - ObjC lifetime: pull sugar off when the qualifiers conflict.

2016-06-01 Thread Manman Ren via cfe-commits
Author: mren
Date: Wed Jun  1 12:14:19 2016
New Revision: 271409

URL: http://llvm.org/viewvc/llvm-project?rev=271409&view=rev
Log:
ObjC lifetime: pull sugar off when the qualifiers conflict.

It's possible to have multiple local ObjCLifetime qualifiers. When there is
a conflict, we can't stop after we reach a type that is directly qualified.
We need to keep pulling sugar off and removing the ObjCLifetime qualifers.

rdar://25804796

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

Added:
cfe/trunk/test/SemaObjC/arc-objc-lifetime-conflict.m
Modified:
cfe/trunk/lib/Sema/SemaType.cpp

Modified: cfe/trunk/lib/Sema/SemaType.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=271409&r1=271408&r2=271409&view=diff
==
--- cfe/trunk/lib/Sema/SemaType.cpp (original)
+++ cfe/trunk/lib/Sema/SemaType.cpp Wed Jun  1 12:14:19 2016
@@ -5415,11 +5415,13 @@ static bool handleObjCOwnershipTypeAttr(
 }
 
 // Otherwise, if the qualifiers actually conflict, pull sugar off
-// until we reach a type that is directly qualified.
+// and remove the ObjCLifetime qualifiers.
 if (previousLifetime != lifetime) {
-  // This should always terminate: the canonical type is
-  // qualified, so some bit of sugar must be hiding it.
-  while (!underlyingType.Quals.hasObjCLifetime()) {
+  // It's possible to have multiple local ObjCLifetime qualifiers. We
+  // can't stop after we reach a type that is directly qualified.
+  const Type *prevTy = nullptr;
+  while (!prevTy || prevTy != underlyingType.Ty) {
+prevTy = underlyingType.Ty;
 underlyingType = underlyingType.getSingleStepDesugaredType();
   }
   underlyingType.Quals.removeObjCLifetime();

Added: cfe/trunk/test/SemaObjC/arc-objc-lifetime-conflict.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/arc-objc-lifetime-conflict.m?rev=271409&view=auto
==
--- cfe/trunk/test/SemaObjC/arc-objc-lifetime-conflict.m (added)
+++ cfe/trunk/test/SemaObjC/arc-objc-lifetime-conflict.m Wed Jun  1 12:14:19 
2016
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fobjc-arc 
-fobjc-runtime-has-weak %s -emit-llvm -o - | FileCheck %s
+
+// CHECK: bitcast {{.*}} %self_weak_s_w_s
+// CHECK-NEXT: objc_destroyWeak
+// CHECK-NEXT: bitcast {{.*}} %self_strong_w_s
+// CHECK-NEXT: objc_storeStrong
+// CHECK-NEXT: bitcast {{.*}} %self_weak_s
+// CHECK-NEXT: objc_destroyWeak
+// CHECK-NEXT: bitcast {{.*}} %self_weak_s3
+// CHECK-NEXT: objc_destroyWeak
+// CHECK-NEXT: bitcast {{.*}} %self_strong3
+// CHECK-NEXT: objc_storeStrong
+// CHECK-NEXT: bitcast {{.*}} %self_strong2
+// CHECK-NEXT: objc_storeStrong
+// CHECK-NEXT: bitcast {{.*}} %self_strong
+// CHECK-NEXT: objc_storeStrong
+@interface NSObject
+@end
+@interface A : NSObject
+@end
+@implementation A
+- (void)test {
+  __attribute__((objc_ownership(strong))) __typeof__(self) self_strong;
+  __attribute__((objc_ownership(strong))) __typeof__(self_strong) self_strong2;
+  __attribute__((objc_ownership(strong))) __typeof__(self_strong2) 
self_strong3;
+  __attribute__((objc_ownership(weak))) __typeof__(self_strong3) self_weak_s3;
+ 
+  __attribute__((objc_ownership(weak))) __typeof__(self_strong) self_weak_s;
+  __attribute__((objc_ownership(strong))) __typeof__(self_weak_s) 
self_strong_w_s;
+  __attribute__((objc_ownership(weak))) __typeof__(self_strong_w_s) 
self_weak_s_w_s;
+}
+@end


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


Re: [PATCH] D20843: ObjC lifetime: pull sugar off when the qualifiers conflict.

2016-06-01 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL271409: ObjC lifetime: pull sugar off when the qualifiers 
conflict. (authored by mren).

Changed prior to commit:
  http://reviews.llvm.org/D20843?vs=59149&id=59249#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D20843

Files:
  cfe/trunk/lib/Sema/SemaType.cpp
  cfe/trunk/test/SemaObjC/arc-objc-lifetime-conflict.m

Index: cfe/trunk/test/SemaObjC/arc-objc-lifetime-conflict.m
===
--- cfe/trunk/test/SemaObjC/arc-objc-lifetime-conflict.m
+++ cfe/trunk/test/SemaObjC/arc-objc-lifetime-conflict.m
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fobjc-arc 
-fobjc-runtime-has-weak %s -emit-llvm -o - | FileCheck %s
+
+// CHECK: bitcast {{.*}} %self_weak_s_w_s
+// CHECK-NEXT: objc_destroyWeak
+// CHECK-NEXT: bitcast {{.*}} %self_strong_w_s
+// CHECK-NEXT: objc_storeStrong
+// CHECK-NEXT: bitcast {{.*}} %self_weak_s
+// CHECK-NEXT: objc_destroyWeak
+// CHECK-NEXT: bitcast {{.*}} %self_weak_s3
+// CHECK-NEXT: objc_destroyWeak
+// CHECK-NEXT: bitcast {{.*}} %self_strong3
+// CHECK-NEXT: objc_storeStrong
+// CHECK-NEXT: bitcast {{.*}} %self_strong2
+// CHECK-NEXT: objc_storeStrong
+// CHECK-NEXT: bitcast {{.*}} %self_strong
+// CHECK-NEXT: objc_storeStrong
+@interface NSObject
+@end
+@interface A : NSObject
+@end
+@implementation A
+- (void)test {
+  __attribute__((objc_ownership(strong))) __typeof__(self) self_strong;
+  __attribute__((objc_ownership(strong))) __typeof__(self_strong) self_strong2;
+  __attribute__((objc_ownership(strong))) __typeof__(self_strong2) 
self_strong3;
+  __attribute__((objc_ownership(weak))) __typeof__(self_strong3) self_weak_s3;
+ 
+  __attribute__((objc_ownership(weak))) __typeof__(self_strong) self_weak_s;
+  __attribute__((objc_ownership(strong))) __typeof__(self_weak_s) 
self_strong_w_s;
+  __attribute__((objc_ownership(weak))) __typeof__(self_strong_w_s) 
self_weak_s_w_s;
+}
+@end
Index: cfe/trunk/lib/Sema/SemaType.cpp
===
--- cfe/trunk/lib/Sema/SemaType.cpp
+++ cfe/trunk/lib/Sema/SemaType.cpp
@@ -5415,11 +5415,13 @@
 }
 
 // Otherwise, if the qualifiers actually conflict, pull sugar off
-// until we reach a type that is directly qualified.
+// and remove the ObjCLifetime qualifiers.
 if (previousLifetime != lifetime) {
-  // This should always terminate: the canonical type is
-  // qualified, so some bit of sugar must be hiding it.
-  while (!underlyingType.Quals.hasObjCLifetime()) {
+  // It's possible to have multiple local ObjCLifetime qualifiers. We
+  // can't stop after we reach a type that is directly qualified.
+  const Type *prevTy = nullptr;
+  while (!prevTy || prevTy != underlyingType.Ty) {
+prevTy = underlyingType.Ty;
 underlyingType = underlyingType.getSingleStepDesugaredType();
   }
   underlyingType.Quals.removeObjCLifetime();


Index: cfe/trunk/test/SemaObjC/arc-objc-lifetime-conflict.m
===
--- cfe/trunk/test/SemaObjC/arc-objc-lifetime-conflict.m
+++ cfe/trunk/test/SemaObjC/arc-objc-lifetime-conflict.m
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fobjc-arc -fobjc-runtime-has-weak %s -emit-llvm -o - | FileCheck %s
+
+// CHECK: bitcast {{.*}} %self_weak_s_w_s
+// CHECK-NEXT: objc_destroyWeak
+// CHECK-NEXT: bitcast {{.*}} %self_strong_w_s
+// CHECK-NEXT: objc_storeStrong
+// CHECK-NEXT: bitcast {{.*}} %self_weak_s
+// CHECK-NEXT: objc_destroyWeak
+// CHECK-NEXT: bitcast {{.*}} %self_weak_s3
+// CHECK-NEXT: objc_destroyWeak
+// CHECK-NEXT: bitcast {{.*}} %self_strong3
+// CHECK-NEXT: objc_storeStrong
+// CHECK-NEXT: bitcast {{.*}} %self_strong2
+// CHECK-NEXT: objc_storeStrong
+// CHECK-NEXT: bitcast {{.*}} %self_strong
+// CHECK-NEXT: objc_storeStrong
+@interface NSObject
+@end
+@interface A : NSObject
+@end
+@implementation A
+- (void)test {
+  __attribute__((objc_ownership(strong))) __typeof__(self) self_strong;
+  __attribute__((objc_ownership(strong))) __typeof__(self_strong) self_strong2;
+  __attribute__((objc_ownership(strong))) __typeof__(self_strong2) self_strong3;
+  __attribute__((objc_ownership(weak))) __typeof__(self_strong3) self_weak_s3;
+ 
+  __attribute__((objc_ownership(weak))) __typeof__(self_strong) self_weak_s;
+  __attribute__((objc_ownership(strong))) __typeof__(self_weak_s) self_strong_w_s;
+  __attribute__((objc_ownership(weak))) __typeof__(self_strong_w_s) self_weak_s_w_s;
+}
+@end
Index: cfe/trunk/lib/Sema/SemaType.cpp
===
--- cfe/trunk/lib/Sema/SemaType.cpp
+++ cfe/trunk/lib/Sema/SemaType.cpp
@@ -5415,11 +5415,13 @@
 }
 
 // Otherwise, if the qualifiers actually conflict, pull sugar off
-// until we reach a type that is directly qualified.
+// and remove the ObjCLifet

Re: [Diffusion] rL249410: [Tooling] Reuse FileManager in ASTUnit.

2016-06-01 Thread Cameron via cfe-commits
cameron314 added a subscriber: cfe-commits.

http://reviews.llvm.org/rL249410



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


Re: [PATCH] D20714: [Clang-tidy] Fix some Include What You Use warnings; other minor fixes

2016-06-01 Thread Etienne Bergeron via cfe-commits
etienneb added a comment.

In http://reviews.llvm.org/D20714#445911, @Eugene.Zelenko wrote:

> There is a way to tell IWYU about compound headers with pragmas 
> .
>  I also suggested to make this possible via file with compound headers list.
>
> But person who knows LLVM/Clang code base better then me should define such 
> headers.


I spent time thinking about that problem months ago and I've found so many 
strange cases.
It seems an easy problem on the surface, but when you dig you realized there is 
so many corner cases.

My comment on this patch is not related to the tool or how the tool is working.
It's more a question about whether or not we should "compound" some headers you 
expanded.
Most of the include you added are right and must be present.

A general question on your tool is: can we specify the IWYU pragma somewhere 
else than in the code.
I'm not in favor of building xmas tree with your header files.

  IWYU pragma:

I don't know how common they will be.


Repository:
  rL LLVM

http://reviews.llvm.org/D20714



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


Re: [PATCH] D20447: [OpenCL] Fixup extension list

2016-06-01 Thread Jan Vesely via cfe-commits
This revision was automatically updated to reflect the committed changes.
jvesely marked 5 inline comments as done.
Closed by commit rL271413: Fixup list of available extensions (authored by 
jvesely).

Changed prior to commit:
  http://reviews.llvm.org/D20447?vs=59240&id=59254#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D20447

Files:
  cfe/trunk/include/clang/Basic/OpenCLExtensions.def
  cfe/trunk/test/SemaOpenCL/extension-version.cl

Index: cfe/trunk/include/clang/Basic/OpenCLExtensions.def
===
--- cfe/trunk/include/clang/Basic/OpenCLExtensions.def
+++ cfe/trunk/include/clang/Basic/OpenCLExtensions.def
@@ -34,35 +34,39 @@
 #endif // OPENCLEXT_INTERNAL
 
 // OpenCL 1.0.
-OPENCLEXT_INTERNAL(cl_khr_3d_image_writes, 100, 120)
+OPENCLEXT_INTERNAL(cl_khr_3d_image_writes, 100, 200)
+// fprounding mode is special since it is not mentioned beyond 1.0
+OPENCLEXT_INTERNAL(cl_khr_select_fprounding_mode, 100, 110)
 OPENCLEXT_INTERNAL(cl_khr_byte_addressable_store, 100, 110)
 OPENCLEXT_INTERNAL(cl_khr_fp16, 100, ~0U)
 OPENCLEXT_INTERNAL(cl_khr_fp64, 100, 120)
 OPENCLEXT_INTERNAL(cl_khr_global_int32_base_atomics, 100, 110)
 OPENCLEXT_INTERNAL(cl_khr_global_int32_extended_atomics, 100, 110)
-OPENCLEXT_INTERNAL(cl_khr_gl_sharing, 100, ~0U)
-OPENCLEXT_INTERNAL(cl_khr_icd, 100, ~0U)
 OPENCLEXT_INTERNAL(cl_khr_local_int32_base_atomics, 100, 110)
 OPENCLEXT_INTERNAL(cl_khr_local_int32_extended_atomics, 100, 110)
+OPENCLEXT_INTERNAL(cl_khr_int64_base_atomics, 100, ~0U)
+OPENCLEXT_INTERNAL(cl_khr_int64_extended_atomics, 100, ~0U)
+OPENCLEXT_INTERNAL(cl_khr_gl_sharing, 100, ~0U)
+OPENCLEXT_INTERNAL(cl_khr_icd, 100, ~0U)
 
 // OpenCL 1.1.
-OPENCLEXT_INTERNAL(cl_khr_d3d10_sharing, 110, ~0U)
 OPENCLEXT_INTERNAL(cl_khr_gl_event, 110, ~0U)
-OPENCLEXT_INTERNAL(cl_khr_int64_base_atomics, 110, ~0U)
-OPENCLEXT_INTERNAL(cl_khr_int64_extended_atomics, 110, ~0U)
+OPENCLEXT_INTERNAL(cl_khr_d3d10_sharing, 110, ~0U)
 
 // OpenCL 1.2.
+OPENCLEXT_INTERNAL(cl_khr_context_abort, 120, ~0U)
 OPENCLEXT_INTERNAL(cl_khr_d3d11_sharing, 120, ~0U)
 OPENCLEXT_INTERNAL(cl_khr_depth_images, 120, ~0U)
 OPENCLEXT_INTERNAL(cl_khr_dx9_media_sharing, 120, ~0U)
+OPENCLEXT_INTERNAL(cl_khr_image2d_from_buffer, 120, ~0U)
+OPENCLEXT_INTERNAL(cl_khr_initialize_memory, 120, ~0U)
 OPENCLEXT_INTERNAL(cl_khr_gl_depth_images, 120, ~0U)
+OPENCLEXT_INTERNAL(cl_khr_gl_msaa_sharing, 120, ~0U)
 OPENCLEXT_INTERNAL(cl_khr_spir, 120, ~0U)
 
 // OpenCL 2.0.
 OPENCLEXT_INTERNAL(cl_khr_egl_event, 200, ~0U)
 OPENCLEXT_INTERNAL(cl_khr_egl_image, 200, ~0U)
-OPENCLEXT_INTERNAL(cl_khr_gl_msaa_sharing, 200, ~0U)
-OPENCLEXT_INTERNAL(cl_khr_initialize_memory, 200, ~0U)
 OPENCLEXT_INTERNAL(cl_khr_srgb_image_writes, 200, ~0U)
 OPENCLEXT_INTERNAL(cl_khr_subgroups, 200, ~0U)
 OPENCLEXT_INTERNAL(cl_khr_terminate_context, 200, ~0U)
Index: cfe/trunk/test/SemaOpenCL/extension-version.cl
===
--- cfe/trunk/test/SemaOpenCL/extension-version.cl
+++ cfe/trunk/test/SemaOpenCL/extension-version.cl
@@ -0,0 +1,225 @@
+// RUN: %clang_cc1 -x cl -cl-std=CL %s -verify -triple spir-unknown-unknown
+// RUN: %clang_cc1 -x cl -cl-std=CL1.1 %s -verify -triple spir-unknown-unknown
+// RUN: %clang_cc1 -x cl -cl-std=CL1.2 %s -verify -triple spir-unknown-unknown
+// RUN: %clang_cc1 -x cl -cl-std=CL2.0 %s -verify -triple spir-unknown-unknown
+
+#if __OPENCL_C_VERSION__ >= 200
+// expected-no-diagnostics
+#endif
+
+// Extensions in all versions
+#ifndef cl_clang_storage_class_specifiers
+#error "Missing cl_clang_storage_class_specifiers define"
+#endif
+#pragma OPENCL EXTENSION cl_clang_storage_class_specifiers: enable
+
+#ifndef cl_khr_fp16
+#error "Missing cl_khr_fp16 define"
+#endif
+#pragma OPENCL EXTENSION cl_khr_fp16: enable
+
+#ifndef cl_khr_int64_base_atomics
+#error "Missing cl_khr_int64_base_atomics define"
+#endif
+#pragma OPENCL EXTENSION cl_khr_int64_base_atomics: enable
+
+#ifndef cl_khr_int64_extended_atomics
+#error "Missing cl_khr_int64_extended_atomics define"
+#endif
+#pragma OPENCL EXTENSION cl_khr_int64_extended_atomics: enable
+
+#ifndef cl_khr_gl_sharing
+#error "Missing cl_khr_gl_sharing define"
+#endif
+#pragma OPENCL EXTENSION cl_khr_gl_sharing: enable
+
+#ifndef cl_khr_icd
+#error "Missing cl_khr_icd define"
+#endif
+#pragma OPENCL EXTENSION cl_khr_icd: enable
+
+// Core features in CL 1.1
+#if (__OPENCL_C_VERSION__ < 110)
+#ifndef cl_khr_byte_addressable_store
+#error "Missing cl_khr_byte_addressable_store define"
+#endif
+#pragma OPENCL EXTENSION cl_khr_byte_addressable_store: enable
+
+#ifndef cl_khr_global_int32_base_atomics
+#error "Missing cl_khr_global_int32_base_atomics define"
+#endif
+#pragma OPENCL EXTENSION cl_khr_global_int32_base_atomics: enable
+
+#ifndef cl_khr_global_int32_extended_atomics
+#error "Missing cl_khr_global_int32_extended_atomics define"
+#endif
+#pragma OPENCL EXTENSION cl_khr_global_int32_extended_atomics: enable
+
+#ifndef cl_khr

Re: [PATCH] D20744: [OpenCL] Disable warning about core features by default

2016-06-01 Thread Jan Vesely via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL271414: Disable warning about core features by default 
(authored by jvesely).

Changed prior to commit:
  http://reviews.llvm.org/D20744?vs=59079&id=59255#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D20744

Files:
  cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
  cfe/trunk/test/Parser/opencl-atomics-cl20.cl
  cfe/trunk/test/SemaOpenCL/extension-version.cl
  cfe/trunk/test/SemaOpenCL/invalid-logical-ops-1.2.cl

Index: cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
@@ -929,7 +929,7 @@
 def warn_pragma_unsupported_extension : Warning<
   "unsupported OpenCL extension %0 - ignoring">, InGroup;
 def warn_pragma_extension_is_core : Warning<
-  "OpenCL extension %0 is core feature or supported optional core feature - ignoring">, InGroup;
+  "OpenCL extension %0 is core feature or supported optional core feature - ignoring">, InGroup>, DefaultIgnore;
 
 // OpenCL errors.
 def err_opencl_taking_function_address_parser : Error<
Index: cfe/trunk/test/Parser/opencl-atomics-cl20.cl
===
--- cfe/trunk/test/Parser/opencl-atomics-cl20.cl
+++ cfe/trunk/test/Parser/opencl-atomics-cl20.cl
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only
 // RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -fsyntax-only -cl-std=CL2.0 -DCL20
-// RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -fsyntax-only -cl-std=CL2.0 -DCL20 -DEXT
+// RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -fsyntax-only -cl-std=CL2.0 -DCL20 -DEXT -Wpedantic-core-features
 
 #ifdef EXT
 #pragma OPENCL EXTENSION cl_khr_int64_base_atomics:enable
Index: cfe/trunk/test/SemaOpenCL/extension-version.cl
===
--- cfe/trunk/test/SemaOpenCL/extension-version.cl
+++ cfe/trunk/test/SemaOpenCL/extension-version.cl
@@ -2,8 +2,12 @@
 // RUN: %clang_cc1 -x cl -cl-std=CL1.1 %s -verify -triple spir-unknown-unknown
 // RUN: %clang_cc1 -x cl -cl-std=CL1.2 %s -verify -triple spir-unknown-unknown
 // RUN: %clang_cc1 -x cl -cl-std=CL2.0 %s -verify -triple spir-unknown-unknown
+// RUN: %clang_cc1 -x cl -cl-std=CL %s -verify -triple spir-unknown-unknown -Wpedantic-core-features -DTEST_CORE_FEATURES
+// RUN: %clang_cc1 -x cl -cl-std=CL1.1 %s -verify -triple spir-unknown-unknown -Wpedantic-core-features -DTEST_CORE_FEATURES
+// RUN: %clang_cc1 -x cl -cl-std=CL1.2 %s -verify -triple spir-unknown-unknown -Wpedantic-core-features -DTEST_CORE_FEATURES
+// RUN: %clang_cc1 -x cl -cl-std=CL2.0 %s -verify -triple spir-unknown-unknown -Wpedantic-core-features -DTEST_CORE_FEATURES
 
-#if __OPENCL_C_VERSION__ >= 200
+#if __OPENCL_C_VERSION__ >= 200 && ! defined TEST_CORE_FEATURES
 // expected-no-diagnostics
 #endif
 
@@ -39,56 +43,76 @@
 #pragma OPENCL EXTENSION cl_khr_icd: enable
 
 // Core features in CL 1.1
-#if (__OPENCL_C_VERSION__ < 110)
+
 #ifndef cl_khr_byte_addressable_store
 #error "Missing cl_khr_byte_addressable_store define"
 #endif
 #pragma OPENCL EXTENSION cl_khr_byte_addressable_store: enable
+#if (__OPENCL_C_VERSION__ >= 110) && defined TEST_CORE_FEATURES
+// expected-warning@-2{{OpenCL extension 'cl_khr_byte_addressable_store' is core feature or supported optional core feature - ignoring}}
+#endif
 
 #ifndef cl_khr_global_int32_base_atomics
 #error "Missing cl_khr_global_int32_base_atomics define"
 #endif
 #pragma OPENCL EXTENSION cl_khr_global_int32_base_atomics: enable
+#if (__OPENCL_C_VERSION__ >= 110) && defined TEST_CORE_FEATURES
+// expected-warning@-2{{OpenCL extension 'cl_khr_global_int32_base_atomics' is core feature or supported optional core feature - ignoring}}
+#endif
 
 #ifndef cl_khr_global_int32_extended_atomics
 #error "Missing cl_khr_global_int32_extended_atomics define"
 #endif
 #pragma OPENCL EXTENSION cl_khr_global_int32_extended_atomics: enable
+#if (__OPENCL_C_VERSION__ >= 110) && defined TEST_CORE_FEATURES
+// expected-warning@-2{{OpenCL extension 'cl_khr_global_int32_extended_atomics' is core feature or supported optional core feature - ignoring}}
+#endif
 
 #ifndef cl_khr_local_int32_base_atomics
 #error "Missing cl_khr_local_int32_base_atomics define"
 #endif
 #pragma OPENCL EXTENSION cl_khr_local_int32_base_atomics: enable
+#if (__OPENCL_C_VERSION__ >= 110) && defined TEST_CORE_FEATURES
+// expected-warning@-2{{OpenCL extension 'cl_khr_local_int32_base_atomics' is core feature or supported optional core feature - ignoring}}
+#endif
 
 #ifndef cl_khr_local_int32_extended_atomics
 #error "Missing cl_khr_local_int32_extended_atomics define"
 #endif
 #pragma OPENCL EXTENSION cl_khr_local_int32_extended_atomics: enable
+#if (__OPENCL_C_VERSION__ >= 110) && defined TEST_COR

r271414 - Disable warning about core features by default

2016-06-01 Thread Jan Vesely via cfe-commits
Author: jvesely
Date: Wed Jun  1 13:04:53 2016
New Revision: 271414

URL: http://llvm.org/viewvc/llvm-project?rev=271414&view=rev
Log:
Disable warning about core features by default

Reviewers: Anastasia, yaxunl

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

Modified:
cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
cfe/trunk/test/Parser/opencl-atomics-cl20.cl
cfe/trunk/test/SemaOpenCL/extension-version.cl
cfe/trunk/test/SemaOpenCL/invalid-logical-ops-1.2.cl

Modified: cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td?rev=271414&r1=271413&r2=271414&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td Wed Jun  1 13:04:53 
2016
@@ -929,7 +929,7 @@ def warn_pragma_unknown_extension : Warn
 def warn_pragma_unsupported_extension : Warning<
   "unsupported OpenCL extension %0 - ignoring">, InGroup;
 def warn_pragma_extension_is_core : Warning<
-  "OpenCL extension %0 is core feature or supported optional core feature - 
ignoring">, InGroup;
+  "OpenCL extension %0 is core feature or supported optional core feature - 
ignoring">, InGroup>, DefaultIgnore;
 
 // OpenCL errors.
 def err_opencl_taking_function_address_parser : Error<

Modified: cfe/trunk/test/Parser/opencl-atomics-cl20.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/opencl-atomics-cl20.cl?rev=271414&r1=271413&r2=271414&view=diff
==
--- cfe/trunk/test/Parser/opencl-atomics-cl20.cl (original)
+++ cfe/trunk/test/Parser/opencl-atomics-cl20.cl Wed Jun  1 13:04:53 2016
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic 
-fsyntax-only
 // RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -fsyntax-only 
-cl-std=CL2.0 -DCL20
-// RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -fsyntax-only 
-cl-std=CL2.0 -DCL20 -DEXT
+// RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -fsyntax-only 
-cl-std=CL2.0 -DCL20 -DEXT -Wpedantic-core-features
 
 #ifdef EXT
 #pragma OPENCL EXTENSION cl_khr_int64_base_atomics:enable

Modified: cfe/trunk/test/SemaOpenCL/extension-version.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCL/extension-version.cl?rev=271414&r1=271413&r2=271414&view=diff
==
--- cfe/trunk/test/SemaOpenCL/extension-version.cl (original)
+++ cfe/trunk/test/SemaOpenCL/extension-version.cl Wed Jun  1 13:04:53 2016
@@ -2,8 +2,12 @@
 // RUN: %clang_cc1 -x cl -cl-std=CL1.1 %s -verify -triple spir-unknown-unknown
 // RUN: %clang_cc1 -x cl -cl-std=CL1.2 %s -verify -triple spir-unknown-unknown
 // RUN: %clang_cc1 -x cl -cl-std=CL2.0 %s -verify -triple spir-unknown-unknown
+// RUN: %clang_cc1 -x cl -cl-std=CL %s -verify -triple spir-unknown-unknown 
-Wpedantic-core-features -DTEST_CORE_FEATURES
+// RUN: %clang_cc1 -x cl -cl-std=CL1.1 %s -verify -triple spir-unknown-unknown 
-Wpedantic-core-features -DTEST_CORE_FEATURES
+// RUN: %clang_cc1 -x cl -cl-std=CL1.2 %s -verify -triple spir-unknown-unknown 
-Wpedantic-core-features -DTEST_CORE_FEATURES
+// RUN: %clang_cc1 -x cl -cl-std=CL2.0 %s -verify -triple spir-unknown-unknown 
-Wpedantic-core-features -DTEST_CORE_FEATURES
 
-#if __OPENCL_C_VERSION__ >= 200
+#if __OPENCL_C_VERSION__ >= 200 && ! defined TEST_CORE_FEATURES
 // expected-no-diagnostics
 #endif
 
@@ -39,56 +43,76 @@
 #pragma OPENCL EXTENSION cl_khr_icd: enable
 
 // Core features in CL 1.1
-#if (__OPENCL_C_VERSION__ < 110)
+
 #ifndef cl_khr_byte_addressable_store
 #error "Missing cl_khr_byte_addressable_store define"
 #endif
 #pragma OPENCL EXTENSION cl_khr_byte_addressable_store: enable
+#if (__OPENCL_C_VERSION__ >= 110) && defined TEST_CORE_FEATURES
+// expected-warning@-2{{OpenCL extension 'cl_khr_byte_addressable_store' is 
core feature or supported optional core feature - ignoring}}
+#endif
 
 #ifndef cl_khr_global_int32_base_atomics
 #error "Missing cl_khr_global_int32_base_atomics define"
 #endif
 #pragma OPENCL EXTENSION cl_khr_global_int32_base_atomics: enable
+#if (__OPENCL_C_VERSION__ >= 110) && defined TEST_CORE_FEATURES
+// expected-warning@-2{{OpenCL extension 'cl_khr_global_int32_base_atomics' is 
core feature or supported optional core feature - ignoring}}
+#endif
 
 #ifndef cl_khr_global_int32_extended_atomics
 #error "Missing cl_khr_global_int32_extended_atomics define"
 #endif
 #pragma OPENCL EXTENSION cl_khr_global_int32_extended_atomics: enable
+#if (__OPENCL_C_VERSION__ >= 110) && defined TEST_CORE_FEATURES
+// expected-warning@-2{{OpenCL extension 
'cl_khr_global_int32_extended_atomics' is core feature or supported optional 
core feature - ignoring}}
+#endif
 
 #ifndef cl_khr_local_int32_base_atomics
 #error "Mi

r271413 - Fixup list of available extensions

2016-06-01 Thread Jan Vesely via cfe-commits
Author: jvesely
Date: Wed Jun  1 13:04:50 2016
New Revision: 271413

URL: http://llvm.org/viewvc/llvm-project?rev=271413&view=rev
Log:
Fixup list of available extensions

Reviewers: Anastasia

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

Added:
cfe/trunk/test/SemaOpenCL/extension-version.cl
Modified:
cfe/trunk/include/clang/Basic/OpenCLExtensions.def

Modified: cfe/trunk/include/clang/Basic/OpenCLExtensions.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/OpenCLExtensions.def?rev=271413&r1=271412&r2=271413&view=diff
==
--- cfe/trunk/include/clang/Basic/OpenCLExtensions.def (original)
+++ cfe/trunk/include/clang/Basic/OpenCLExtensions.def Wed Jun  1 13:04:50 2016
@@ -34,35 +34,39 @@
 #endif // OPENCLEXT_INTERNAL
 
 // OpenCL 1.0.
-OPENCLEXT_INTERNAL(cl_khr_3d_image_writes, 100, 120)
+OPENCLEXT_INTERNAL(cl_khr_3d_image_writes, 100, 200)
+// fprounding mode is special since it is not mentioned beyond 1.0
+OPENCLEXT_INTERNAL(cl_khr_select_fprounding_mode, 100, 110)
 OPENCLEXT_INTERNAL(cl_khr_byte_addressable_store, 100, 110)
 OPENCLEXT_INTERNAL(cl_khr_fp16, 100, ~0U)
 OPENCLEXT_INTERNAL(cl_khr_fp64, 100, 120)
 OPENCLEXT_INTERNAL(cl_khr_global_int32_base_atomics, 100, 110)
 OPENCLEXT_INTERNAL(cl_khr_global_int32_extended_atomics, 100, 110)
-OPENCLEXT_INTERNAL(cl_khr_gl_sharing, 100, ~0U)
-OPENCLEXT_INTERNAL(cl_khr_icd, 100, ~0U)
 OPENCLEXT_INTERNAL(cl_khr_local_int32_base_atomics, 100, 110)
 OPENCLEXT_INTERNAL(cl_khr_local_int32_extended_atomics, 100, 110)
+OPENCLEXT_INTERNAL(cl_khr_int64_base_atomics, 100, ~0U)
+OPENCLEXT_INTERNAL(cl_khr_int64_extended_atomics, 100, ~0U)
+OPENCLEXT_INTERNAL(cl_khr_gl_sharing, 100, ~0U)
+OPENCLEXT_INTERNAL(cl_khr_icd, 100, ~0U)
 
 // OpenCL 1.1.
-OPENCLEXT_INTERNAL(cl_khr_d3d10_sharing, 110, ~0U)
 OPENCLEXT_INTERNAL(cl_khr_gl_event, 110, ~0U)
-OPENCLEXT_INTERNAL(cl_khr_int64_base_atomics, 110, ~0U)
-OPENCLEXT_INTERNAL(cl_khr_int64_extended_atomics, 110, ~0U)
+OPENCLEXT_INTERNAL(cl_khr_d3d10_sharing, 110, ~0U)
 
 // OpenCL 1.2.
+OPENCLEXT_INTERNAL(cl_khr_context_abort, 120, ~0U)
 OPENCLEXT_INTERNAL(cl_khr_d3d11_sharing, 120, ~0U)
 OPENCLEXT_INTERNAL(cl_khr_depth_images, 120, ~0U)
 OPENCLEXT_INTERNAL(cl_khr_dx9_media_sharing, 120, ~0U)
+OPENCLEXT_INTERNAL(cl_khr_image2d_from_buffer, 120, ~0U)
+OPENCLEXT_INTERNAL(cl_khr_initialize_memory, 120, ~0U)
 OPENCLEXT_INTERNAL(cl_khr_gl_depth_images, 120, ~0U)
+OPENCLEXT_INTERNAL(cl_khr_gl_msaa_sharing, 120, ~0U)
 OPENCLEXT_INTERNAL(cl_khr_spir, 120, ~0U)
 
 // OpenCL 2.0.
 OPENCLEXT_INTERNAL(cl_khr_egl_event, 200, ~0U)
 OPENCLEXT_INTERNAL(cl_khr_egl_image, 200, ~0U)
-OPENCLEXT_INTERNAL(cl_khr_gl_msaa_sharing, 200, ~0U)
-OPENCLEXT_INTERNAL(cl_khr_initialize_memory, 200, ~0U)
 OPENCLEXT_INTERNAL(cl_khr_srgb_image_writes, 200, ~0U)
 OPENCLEXT_INTERNAL(cl_khr_subgroups, 200, ~0U)
 OPENCLEXT_INTERNAL(cl_khr_terminate_context, 200, ~0U)

Added: cfe/trunk/test/SemaOpenCL/extension-version.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCL/extension-version.cl?rev=271413&view=auto
==
--- cfe/trunk/test/SemaOpenCL/extension-version.cl (added)
+++ cfe/trunk/test/SemaOpenCL/extension-version.cl Wed Jun  1 13:04:50 2016
@@ -0,0 +1,225 @@
+// RUN: %clang_cc1 -x cl -cl-std=CL %s -verify -triple spir-unknown-unknown
+// RUN: %clang_cc1 -x cl -cl-std=CL1.1 %s -verify -triple spir-unknown-unknown
+// RUN: %clang_cc1 -x cl -cl-std=CL1.2 %s -verify -triple spir-unknown-unknown
+// RUN: %clang_cc1 -x cl -cl-std=CL2.0 %s -verify -triple spir-unknown-unknown
+
+#if __OPENCL_C_VERSION__ >= 200
+// expected-no-diagnostics
+#endif
+
+// Extensions in all versions
+#ifndef cl_clang_storage_class_specifiers
+#error "Missing cl_clang_storage_class_specifiers define"
+#endif
+#pragma OPENCL EXTENSION cl_clang_storage_class_specifiers: enable
+
+#ifndef cl_khr_fp16
+#error "Missing cl_khr_fp16 define"
+#endif
+#pragma OPENCL EXTENSION cl_khr_fp16: enable
+
+#ifndef cl_khr_int64_base_atomics
+#error "Missing cl_khr_int64_base_atomics define"
+#endif
+#pragma OPENCL EXTENSION cl_khr_int64_base_atomics: enable
+
+#ifndef cl_khr_int64_extended_atomics
+#error "Missing cl_khr_int64_extended_atomics define"
+#endif
+#pragma OPENCL EXTENSION cl_khr_int64_extended_atomics: enable
+
+#ifndef cl_khr_gl_sharing
+#error "Missing cl_khr_gl_sharing define"
+#endif
+#pragma OPENCL EXTENSION cl_khr_gl_sharing: enable
+
+#ifndef cl_khr_icd
+#error "Missing cl_khr_icd define"
+#endif
+#pragma OPENCL EXTENSION cl_khr_icd: enable
+
+// Core features in CL 1.1
+#if (__OPENCL_C_VERSION__ < 110)
+#ifndef cl_khr_byte_addressable_store
+#error "Missing cl_khr_byte_addressable_store define"
+#endif
+#pragma OPENCL EXTENSION cl_khr_byte_addressable_store: enable
+
+#ifndef cl_khr_global_int32_base_atomics
+#error "Missing cl_khr_global_int32_base_atomics define"
+#endif
+#pragma OP

Re: [PATCH] D20714: [Clang-tidy] Fix some Include What You Use warnings; other minor fixes

2016-06-01 Thread Eugene Zelenko via cfe-commits
Eugene.Zelenko added a comment.

See https://github.com/include-what-you-use/include-what-you-use/issues/292 and 
https://github.com/include-what-you-use/include-what-you-use/issues/301.


Repository:
  rL LLVM

http://reviews.llvm.org/D20714



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


  1   2   >