Re: [PATCH] D20270: libc++abi: build with -fvisibility=hidden

2016-05-24 Thread Eric Fiselier via cfe-commits
EricWF added a comment.

Added cfe-commits.


Repository:
  rL LLVM

http://reviews.llvm.org/D20270



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


r270536 - [OPENMP] Fixed codegen for firstprivate vars in standalone worksharing

2016-05-24 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Tue May 24 02:40:12 2016
New Revision: 270536

URL: http://llvm.org/viewvc/llvm-project?rev=270536&view=rev
Log:
[OPENMP] Fixed codegen for firstprivate vars in standalone worksharing
directives.

If firstprivate variable is is captured by value in outlined region and then 
used as firstprivate variable in inner worksharing directive, the copy for this 
firstprivate variable was not created. Fixed this bug.

Modified:
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
cfe/trunk/test/OpenMP/sections_firstprivate_codegen.cpp
cfe/trunk/test/OpenMP/single_firstprivate_codegen.cpp

Modified: cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp?rev=270536&r1=270535&r2=270536&view=diff
==
--- cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp Tue May 24 02:40:12 2016
@@ -571,6 +571,7 @@ bool CodeGenFunction::EmitOMPFirstprivat
   cast(cast(D)->getDecl())->getCanonicalDecl());
   }
   llvm::DenseSet EmittedAsFirstprivate;
+  CGCapturedStmtInfo CapturesInfo(cast(*D.getAssociatedStmt()));
   for (const auto *C : D.getClausesOfKind()) {
 auto IRef = C->varlist_begin();
 auto InitsRef = C->inits().begin();
@@ -578,8 +579,9 @@ bool CodeGenFunction::EmitOMPFirstprivat
   auto *OrigVD = cast(cast(*IRef)->getDecl());
   bool ThisFirstprivateIsLastprivate =
   Lastprivates.count(OrigVD->getCanonicalDecl()) > 0;
+  auto *CapFD = CapturesInfo.lookup(OrigVD);
   auto *FD = CapturedStmtInfo->lookup(OrigVD);
-  if (!ThisFirstprivateIsLastprivate && FD &&
+  if (!ThisFirstprivateIsLastprivate && FD && (FD == CapFD) &&
   !FD->getType()->isReferenceType()) {
 EmittedAsFirstprivate.insert(OrigVD->getCanonicalDecl());
 ++IRef;

Modified: cfe/trunk/test/OpenMP/sections_firstprivate_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/sections_firstprivate_codegen.cpp?rev=270536&r1=270535&r2=270536&view=diff
==
--- cfe/trunk/test/OpenMP/sections_firstprivate_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/sections_firstprivate_codegen.cpp Tue May 24 02:40:12 
2016
@@ -216,6 +216,7 @@ int main() {
 // firstprivate t_var(t_var)
 // CHECK: [[T_VAR_VAL:%.+]] = load i{{[0-9]+}}, i{{[0-9]+}}* [[T_VAR]],
 // CHECK: store i{{[0-9]+}} [[T_VAR_VAL]], i{{[0-9]+}}* [[T_VAR_PRIV]],
+
 // firstprivate vec(vec)
 // CHECK: [[VEC_DEST:%.+]] = bitcast [2 x i{{[0-9]+}}]* [[VEC_PRIV]] to i8*
 // CHECK: call void @llvm.memcpy.{{.+}}(i8* [[VEC_DEST]], i8* bitcast ([2 x 
i{{[0-9]+}}]* [[VEC]] to i8*),
@@ -262,11 +263,13 @@ int main() {
 //
 // CHECK: define internal void [[TMAIN_MICROTASK]](i{{[0-9]+}}* noalias 
[[GTID_ADDR:%.+]], i{{[0-9]+}}* noalias %{{.+}},
 // Skip temp vars for loop
-// CHECK: [[T_VAR_PRIV:%.+]] = alloca i{{[0-9]+}},
 // CHECK: alloca i{{[0-9]+}},
 // CHECK: alloca i{{[0-9]+}},
 // CHECK: alloca i{{[0-9]+}},
 // CHECK: alloca i{{[0-9]+}},
+// CHECK: alloca i{{[0-9]+}},
+// CHECK: alloca i{{[0-9]+}},
+// CHECK: [[T_VAR_PRIV:%.+]] = alloca i{{[0-9]+}},
 // CHECK: [[VEC_PRIV:%.+]] = alloca [2 x i{{[0-9]+}}],
 // CHECK: [[S_ARR_PRIV:%.+]] = alloca [2 x [[S_INT_TY]]],
 // CHECK: [[VAR_PRIV:%.+]] = alloca [[S_INT_TY]],
@@ -278,7 +281,8 @@ int main() {
 // CHECK: [[VAR_REF:%.+]] = load [[S_INT_TY]]*, [[S_INT_TY]]** %
 
 // firstprivate t_var(t_var)
-// CHECK-NOT: load i{{[0-9]+}}, i{{[0-9]+}}*
+// CHECK: [[T_VAR_VAL:%.+]] = load i{{[0-9]+}}, i{{[0-9]+}}*
+// CHECK: store i{{[0-9]+}} [[T_VAR_VAL]], i{{[0-9]+}}* [[T_VAR_PRIV]],
 
 // firstprivate vec(vec)
 // CHECK: [[VEC_DEST:%.+]] = bitcast [2 x i{{[0-9]+}}]* [[VEC_PRIV]] to i8*

Modified: cfe/trunk/test/OpenMP/single_firstprivate_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/single_firstprivate_codegen.cpp?rev=270536&r1=270535&r2=270536&view=diff
==
--- cfe/trunk/test/OpenMP/single_firstprivate_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/single_firstprivate_codegen.cpp Tue May 24 02:40:12 
2016
@@ -228,6 +228,7 @@ int main() {
 // CHECK: ret
 //
 // CHECK: define internal void [[TMAIN_MICROTASK]](i{{[0-9]+}}* noalias 
[[GTID_ADDR:%.+]], i{{[0-9]+}}* noalias %{{.+}}, i32 {{.*}}%{{.+}}, [2 x i32]* 
dereferenceable(8) %{{.+}}, [2 x [[S_INT_TY]]]* dereferenceable(8) %{{.+}}, 
[[S_INT_TY]]* dereferenceable(4) %{{.+}})
+// CHECK: alloca i{{[0-9]+}},
 // CHECK: [[T_VAR_PRIV:%.+]] = alloca i{{[0-9]+}},
 // CHECK: [[VEC_PRIV:%.+]] = alloca [2 x i{{[0-9]+}}],
 // CHECK: [[S_ARR_PRIV:%.+]] = alloca [2 x [[S_INT_TY]]],
@@ -244,7 +245,8 @@ int main() {
 // CHECK: call i32 @__kmpc_single(
 
 // firstprivate t_var(t_var)
-// CHECK-NOT: load i{{[0-9]+}}, i{{[0-9]+}}*
+// CHECK: [[T_VAR_VAL:%.+]] = load i{{[0-9]+}}, i{{[0-9]+}

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

2016-05-24 Thread Roger Ferrer Ibanez via cfe-commits
rogfer01 created this revision.
rogfer01 added a reviewer: rsmith.
rogfer01 added a subscriber: cfe-commits.

This patch implements PR#22821.

Taking the address of a packed member is dangerous since the reduced
alignment of the pointee is lost. This can lead to memory alignment
faults in some architectures if the pointer value is dereferenced.

This change adds a new warning to clang emitted when taking the address
of a packed member. A packed member is either a field/data member
declared as __attribute__((packed)) or belonging to a struct/class
declared as such. The associated flag is -Waddress-of-packed-member

http://reviews.llvm.org/D20561

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

Index: test/Sema/address-packed.c
===
--- /dev/null
+++ test/Sema/address-packed.c
@@ -0,0 +1,201 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -xc++ -fsyntax-only -verify %s
+extern void f1(int *);
+extern void f2(char *);
+
+struct Ok {
+  char c;
+  int x;
+};
+
+struct __attribute__((packed)) Arguable {
+  char c;
+  int x;
+#ifdef __cplusplus
+  static void foo();
+#endif
+};
+
+union __attribute__((packed)) UnionArguable {
+  char c;
+  int x;
+#ifdef __cplusplus
+  static void foo();
+#endif
+};
+
+extern void f3(void());
+
+typedef struct Arguable ArguableT;
+
+#ifdef __cplusplus
+namespace Foo {
+struct __attribute__((packed)) Arguable {
+  char c;
+  int x;
+  static void foo();
+};
+}
+#endif
+
+void g0() {
+  {
+struct Ok ok;
+f1(&ok.x); // no-warning
+f2(&ok.c); // no-warning
+  }
+  {
+struct Arguable arguable;
+f1(&arguable.x); // expected-warning {{packed member 'x' of class or structure 'Arguable'}}
+f2(&arguable.c); // expected-warning {{packed member 'c' of class or structure 'Arguable'}}
+  }
+  {
+union UnionArguable arguable;
+f1(&arguable.x); // expected-warning {{packed member 'x' of class or structure 'UnionArguable'}}
+f2(&arguable.c); // expected-warning {{packed member 'c' of class or structure 'UnionArguable'}}
+  }
+  {
+ArguableT arguable;
+f1(&arguable.x); // expected-warning {{packed member 'x' of class or structure }}
+f2(&arguable.c); // expected-warning {{packed member 'c' of class or structure }}
+  }
+  {
+struct Arguable *arguable;
+f1(&(arguable->x)); // expected-warning {{packed member 'x' of class or structure 'Arguable'}}
+f2(&(arguable->c)); // expected-warning {{packed member 'c' of class or structure 'Arguable'}}
+  }
+  {
+ArguableT *arguable;
+f1(&(arguable->x)); // expected-warning {{packed member 'x' of class or structure 'Arguable'}}
+f2(&(arguable->c)); // expected-warning {{packed member 'c' of class or structure 'Arguable'}}
+  }
+
+#ifdef __cplusplus
+  {
+Ok ok;
+f1(&ok.x); // no-warning
+f2(&ok.c); // no-warning
+  }
+  {
+Arguable arguable;
+f1(&arguable.x);   // expected-warning {{packed member 'x' of class or structure 'Arguable'}}
+f2(&arguable.c);   // expected-warning {{packed member 'c' of class or structure 'Arguable'}}
+f3(&arguable.foo); // no-warning
+  }
+  {
+Foo::Arguable arguable;
+f1(&arguable.x);   // expected-warning {{packed member 'x' of class or structure 'Foo::Arguable'}}
+f2(&arguable.c);   // expected-warning {{packed member 'c' of class or structure 'Foo::Arguable'}}
+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);   // expected-warning {{packed member 'c' of class or structure 'Arguable'}}
+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);   // expected-warning {{packed member 'c' of class or structure 'Arguable'}}
+f3(&arguable->foo); // no-warning
+  }
+#endif
+}
+
+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;
+

Re: [PATCH] D19250: Update libcxx.llvm.org documentation by linking to new docs.

2016-05-24 Thread Eric Fiselier via cfe-commits
EricWF added a comment.

Ping. Marshall do you have any objections to this change.


http://reviews.llvm.org/D19250



___
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-05-24 Thread michael zuckerman via cfe-commits
m_zuckerman updated this revision to Diff 58201.

http://reviews.llvm.org/D20359

Files:
  include/llvm/IR/IntrinsicsX86.td
  lib/Target/X86/X86ISelLowering.cpp
  lib/Target/X86/X86IntrinsicsInfo.h
  test/CodeGen/X86/avx512-intrinsics.ll

Index: lib/Target/X86/X86IntrinsicsInfo.h
===
--- lib/Target/X86/X86IntrinsicsInfo.h
+++ lib/Target/X86/X86IntrinsicsInfo.h
@@ -33,7 +33,7 @@
   INTR_TYPE_SCALAR_MASK_RM, INTR_TYPE_3OP_SCALAR_MASK_RM,
   COMPRESS_EXPAND_IN_REG, COMPRESS_TO_MEM, BRCST_SUBVEC_TO_VEC,
   TRUNCATE_TO_MEM_VI8, TRUNCATE_TO_MEM_VI16, TRUNCATE_TO_MEM_VI32,
-  EXPAND_FROM_MEM, LOADA, LOADU, STOREA, STOREU, STOREANT, BLEND, INSERT_SUBVEC,
+  EXPAND_FROM_MEM, LOADA, LOADU, STOREA, STOREU, BLEND, INSERT_SUBVEC,
   TERLOG_OP_MASK, TERLOG_OP_MASKZ, BROADCASTM, KUNPCK, FIXUPIMM, FIXUPIMM_MASKZ, FIXUPIMMS,
   FIXUPIMMS_MASKZ, CONVERT_MASK_TO_VEC, CONVERT_TO_MASK
 };
@@ -276,9 +276,6 @@
   X86_INTRINSIC_DATA(avx512_scattersiv4_si, SCATTER, X86::VPSCATTERDDZ128mr, 0),
   X86_INTRINSIC_DATA(avx512_scattersiv8_sf, SCATTER, X86::VSCATTERDPSZ256mr, 0),
   X86_INTRINSIC_DATA(avx512_scattersiv8_si, SCATTER, X86::VPSCATTERDDZ256mr, 0),
-  X86_INTRINSIC_DATA(avx512_storent_pd_512, STOREANT, ISD::DELETED_NODE, 0),
-  X86_INTRINSIC_DATA(avx512_storent_ps_512, STOREANT, ISD::DELETED_NODE, 0),
-  X86_INTRINSIC_DATA(avx512_storent_q_512,  STOREANT, ISD::DELETED_NODE, 0),
   X86_INTRINSIC_DATA(rdpmc, RDPMC,  X86ISD::RDPMC_DAG, 0),
   X86_INTRINSIC_DATA(rdrand_16, RDRAND, X86ISD::RDRAND, 0),
   X86_INTRINSIC_DATA(rdrand_32, RDRAND, X86ISD::RDRAND, 0),
Index: lib/Target/X86/X86ISelLowering.cpp
===
--- lib/Target/X86/X86ISelLowering.cpp
+++ lib/Target/X86/X86ISelLowering.cpp
@@ -4072,7 +4072,6 @@
 break;
   }
   case STOREA:
-  case STOREANT:
   case STOREU: {
 Info.ptrVal = I.getArgOperand(0);
 Info.memVT = MVT::getVT(I.getArgOperand(1)->getType());
@@ -18256,20 +18255,6 @@
 return DAG.getMaskedStore(Chain, dl, Data, Addr, VMask, VT,
   MemIntr->getMemOperand(), false);
   }
-  case STOREANT: {
-// Store (MOVNTPD, MOVNTPS, MOVNTDQ) using non-temporal hint intrinsic implementation.
-SDValue Data = Op.getOperand(3);
-SDValue Addr = Op.getOperand(2);
-SDValue Chain = Op.getOperand(0);
-
-MemIntrinsicSDNode *MemIntr = dyn_cast(Op);
-assert(MemIntr && "Expected MemIntrinsicSDNode!");
-MachineMemOperand *MMO = MemIntr->getMemOperand();
-
-MMO->setFlags(MachineMemOperand::MONonTemporal);
-
-return DAG.getStore(Chain, dl, Data, Addr, MMO);
-  }
   }
 }
 
Index: include/llvm/IR/IntrinsicsX86.td
===
--- include/llvm/IR/IntrinsicsX86.td
+++ include/llvm/IR/IntrinsicsX86.td
@@ -2234,18 +2234,6 @@
   [IntrArgMemOnly]>;
 }
 
-// Store ops using non-temporal hint
-let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
-  def int_x86_avx512_storent_q_512 :
-GCCBuiltin<"__builtin_ia32_movntdq512">,
-Intrinsic<[], [llvm_ptr_ty, llvm_v8i64_ty], [IntrArgMemOnly]>;
-  def int_x86_avx512_storent_pd_512 :
-GCCBuiltin<"__builtin_ia32_movntpd512">,
-Intrinsic<[], [llvm_ptr_ty, llvm_v8f64_ty], [IntrArgMemOnly]>;
-  def int_x86_avx512_storent_ps_512 :
-GCCBuiltin<"__builtin_ia32_movntps512">,
-Intrinsic<[], [llvm_ptr_ty, llvm_v16f32_ty], [IntrArgMemOnly]>;
-}
 //===--===//
 // AVX2
 
Index: test/CodeGen/X86/avx512-intrinsics.ll
===
--- test/CodeGen/X86/avx512-intrinsics.ll
+++ test/CodeGen/X86/avx512-intrinsics.ll
@@ -7413,39 +7413,6 @@
   ret <2 x double> %res4
 }
 
-declare void @llvm.x86.avx512.storent.q.512(i8*, <8 x i64>)
-
-define void@test_storent_q_512(<8 x i64> %data, i8* %ptr) {
-; CHECK-LABEL: test_storent_q_512:
-; CHECK:   ## BB#0:
-; CHECK-NEXT:vmovntdq %zmm0, (%rdi)
-; CHECK-NEXT:retq
-  call void @llvm.x86.avx512.storent.q.512(i8* %ptr, <8 x i64> %data)
-  ret void
-}
-
-declare void @llvm.x86.avx512.storent.pd.512(i8*, <8 x double>)
-
-define void @test_storent_pd_512(<8 x double> %data, i8* %ptr) {
-; CHECK-LABEL: test_storent_pd_512:
-; CHECK:   ## BB#0:
-; CHECK-NEXT:vmovntpd %zmm0, (%rdi)
-; CHECK-NEXT:retq
-  call void @llvm.x86.avx512.storent.pd.512(i8* %ptr, <8 x double> %data)
-  ret void
-}
-
-declare void @llvm.x86.avx512.storent.ps.512(i8*, <16 x float>)
-
-define void @test_storent_ps_512(<16 x float> %data, i8* %ptr) {
-; CHECK-LABEL: test_storent_ps_512:
-; CHECK:   ## BB#0:
-; CHECK-NEXT:vmovntps %zmm0, (%rdi)
-; CHECK-NEXT:retq
-  call void @llvm.x86.avx512.storent.ps.512(i8* %ptr, <16 x float> %data)
-  ret void
-}
-
 declare i16 @llvm.x86.avx512.ptestnm.d.512(<16 x i32>, <16 x i32>, i16 %x2)
 
 def

Re: [PATCH] D20419: [Sparc] Add software float option -msoft-float

2016-05-24 Thread Jacob Baungard Hansen via cfe-commits
jacob_hansen updated this revision to Diff 58199.
jacob_hansen added a comment.

Updated against latest master in preparation for commit.


http://reviews.llvm.org/D20419

Files:
  lib/Basic/Targets.cpp
  lib/Driver/Tools.cpp
  lib/Driver/Tools.h
  test/CodeGen/function-target-features.c
  test/Driver/sparc-float.c

Index: test/Driver/sparc-float.c
===
--- test/Driver/sparc-float.c
+++ test/Driver/sparc-float.c
@@ -18,7 +18,25 @@
 // RUN: %clang -c %s -### -o %t.o 2>&1 \
 // RUN: -target sparc-linux-gnu -msoft-float \
 // RUN:   | FileCheck --check-prefix=CHECK-SOFT %s
-// CHECK-SOFT: error: unsupported option '-msoft-float'
+// CHECK-SOFT: "-target-feature" "+soft-float"
+//
+// -mfloat-abi=soft
+// RUN: %clang -c %s -### -o %t.o 2>&1 \
+// RUN: -target sparc-linux-gnu -mfloat-abi=soft \
+// RUN:   | FileCheck --check-prefix=CHECK-FLOATABISOFT %s
+// CHECK-FLOATABISOFT: "-target-feature" "+soft-float"
+//
+// -mfloat-abi=hard
+// RUN: %clang -c %s -### -o %t.o 2>&1 \
+// RUN: -target sparc-linux-gnu -mfloat-abi=hard \
+// RUN:   | FileCheck --check-prefix=CHECK-FLOATABIHARD %s
+// CHECK-FLOATABIHARD-NOT: "-target-feature" "+soft-float"
+//
+// check invalid -mfloat-abi
+// RUN: %clang -c %s -### -o %t.o 2>&1 \
+// RUN: -target sparc-linux-gnu -mfloat-abi=x \
+// RUN:   | FileCheck --check-prefix=CHECK-ERRMSG %s
+// CHECK-ERRMSG: error: invalid float ABI '-mfloat-abi=x'
 //
 // Default sparc64
 // RUN: %clang -c %s -### -o %t.o 2>&1 \
@@ -37,4 +55,22 @@
 // RUN: %clang -c %s -### -o %t.o 2>&1 \
 // RUN: -target sparc64-linux-gnu -msoft-float \
 // RUN:   | FileCheck --check-prefix=CHECK-SOFT-SPARC64 %s
-// CHECK-SOFT-SPARC64: error: unsupported option '-msoft-float'
+// CHECK-SOFT-SPARC64: "-target-feature" "+soft-float"
+//
+// -mfloat-abi=soft
+// RUN: %clang -c %s -### -o %t.o 2>&1 \
+// RUN: -target sparc64-linux-gnu -mfloat-abi=soft \
+// RUN:   | FileCheck --check-prefix=CHECK-FLOATABISOFT64 %s
+// CHECK-FLOATABISOFT64: "-target-feature" "+soft-float"
+//
+// -mfloat-abi=hard
+// RUN: %clang -c %s -### -o %t.o 2>&1 \
+// RUN: -target sparc64-linux-gnu -mfloat-abi=hard \
+// RUN:   | FileCheck --check-prefix=CHECK-FLOATABIHARD64 %s
+// CHECK-FLOATABIHARD64-NOT: "-target-feature" "+soft-float"
+//
+// check invalid -mfloat-abi
+// RUN: %clang -c %s -### -o %t.o 2>&1 \
+// RUN: -target sparc64-linux-gnu -mfloat-abi=x \
+// RUN:   | FileCheck --check-prefix=CHECK-ERRMSG64 %s
+// CHECK-ERRMSG64: error: invalid float ABI '-mfloat-abi=x'
Index: test/CodeGen/function-target-features.c
===
--- test/CodeGen/function-target-features.c
+++ test/CodeGen/function-target-features.c
@@ -9,7 +9,7 @@
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o - %s -target-cpu corei7 -target-feature +avx | FileCheck %s -check-prefix=CORE-CPU-AND-FEATURES
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o - %s -target-cpu x86-64 | FileCheck %s -check-prefix=X86-64-CPU
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o - %s -target-cpu corei7-avx -target-feature -avx | FileCheck %s -check-prefix=AVX-MINUS-FEATURE
-// RUN: %clang_cc1 -triple sparc-unknown-unknown -emit-llvm -o - %s -target-feature +soft-float | FileCheck %s -check-prefix=NO-SOFT-FLOAT
+// RUN: %clang_cc1 -triple sparc-unknown-unknown -emit-llvm -o - %s -target-feature +soft-float | FileCheck %s -check-prefix=SOFT-FLOAT
 // RUN: %clang_cc1 -triple arm-unknown-unknown -emit-llvm -o - %s -target-feature +soft-float | FileCheck %s -check-prefix=SOFT-FLOAT
 // RUN: %clang_cc1 -triple mips-unknown-unknown -emit-llvm -o - %s -target-feature +soft-float | FileCheck %s -check-prefix=SOFT-FLOAT
 
Index: lib/Driver/Tools.h
===
--- lib/Driver/Tools.h
+++ lib/Driver/Tools.h
@@ -777,6 +777,16 @@
 FloatABI getPPCFloatABI(const Driver &D, const llvm::opt::ArgList &Args);
 } // end namespace ppc
 
+namespace sparc {
+enum class FloatABI {
+  Invalid,
+  Soft,
+  Hard,
+};
+
+FloatABI getSparcFloatABI(const Driver &D, const llvm::opt::ArgList &Args);
+} // end namespace sparc
+
 namespace XCore {
 // For XCore, we do not need to instantiate tools for PreProcess, PreCompile and
 // Compile.
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -1640,28 +1640,66 @@
   return "";
 }
 
-void Clang::AddSparcTargetArgs(const ArgList &Args,
-   ArgStringList &CmdArgs) const {
-  const Driver &D = getToolChain().getDriver();
-  std::string Triple = getToolChain().ComputeEffectiveClangTriple(Args);
-
-  bool SoftFloatABI = false;
+sparc::FloatABI sparc::getSparcFloatABI(const Driver &D,
+const ArgList &Args) {
+  sparc::FloatABI ABI = sparc::FloatABI::Invalid;
   if (Ar

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

2016-05-24 Thread michael zuckerman via cfe-commits
m_zuckerman added a comment.

Yes, we can delete it. We don't need it any more .


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] D20419: [Sparc] Add software float option -msoft-float

2016-05-24 Thread Jacob Baungard Hansen via cfe-commits
jacob_hansen updated this revision to Diff 58203.
jacob_hansen added a comment.

Corrected formatting of a line that exceeded 80 columns.


http://reviews.llvm.org/D20419

Files:
  lib/Basic/Targets.cpp
  lib/Driver/Tools.cpp
  lib/Driver/Tools.h
  test/CodeGen/function-target-features.c
  test/Driver/sparc-float.c

Index: test/Driver/sparc-float.c
===
--- test/Driver/sparc-float.c
+++ test/Driver/sparc-float.c
@@ -18,7 +18,25 @@
 // RUN: %clang -c %s -### -o %t.o 2>&1 \
 // RUN: -target sparc-linux-gnu -msoft-float \
 // RUN:   | FileCheck --check-prefix=CHECK-SOFT %s
-// CHECK-SOFT: error: unsupported option '-msoft-float'
+// CHECK-SOFT: "-target-feature" "+soft-float"
+//
+// -mfloat-abi=soft
+// RUN: %clang -c %s -### -o %t.o 2>&1 \
+// RUN: -target sparc-linux-gnu -mfloat-abi=soft \
+// RUN:   | FileCheck --check-prefix=CHECK-FLOATABISOFT %s
+// CHECK-FLOATABISOFT: "-target-feature" "+soft-float"
+//
+// -mfloat-abi=hard
+// RUN: %clang -c %s -### -o %t.o 2>&1 \
+// RUN: -target sparc-linux-gnu -mfloat-abi=hard \
+// RUN:   | FileCheck --check-prefix=CHECK-FLOATABIHARD %s
+// CHECK-FLOATABIHARD-NOT: "-target-feature" "+soft-float"
+//
+// check invalid -mfloat-abi
+// RUN: %clang -c %s -### -o %t.o 2>&1 \
+// RUN: -target sparc-linux-gnu -mfloat-abi=x \
+// RUN:   | FileCheck --check-prefix=CHECK-ERRMSG %s
+// CHECK-ERRMSG: error: invalid float ABI '-mfloat-abi=x'
 //
 // Default sparc64
 // RUN: %clang -c %s -### -o %t.o 2>&1 \
@@ -37,4 +55,22 @@
 // RUN: %clang -c %s -### -o %t.o 2>&1 \
 // RUN: -target sparc64-linux-gnu -msoft-float \
 // RUN:   | FileCheck --check-prefix=CHECK-SOFT-SPARC64 %s
-// CHECK-SOFT-SPARC64: error: unsupported option '-msoft-float'
+// CHECK-SOFT-SPARC64: "-target-feature" "+soft-float"
+//
+// -mfloat-abi=soft
+// RUN: %clang -c %s -### -o %t.o 2>&1 \
+// RUN: -target sparc64-linux-gnu -mfloat-abi=soft \
+// RUN:   | FileCheck --check-prefix=CHECK-FLOATABISOFT64 %s
+// CHECK-FLOATABISOFT64: "-target-feature" "+soft-float"
+//
+// -mfloat-abi=hard
+// RUN: %clang -c %s -### -o %t.o 2>&1 \
+// RUN: -target sparc64-linux-gnu -mfloat-abi=hard \
+// RUN:   | FileCheck --check-prefix=CHECK-FLOATABIHARD64 %s
+// CHECK-FLOATABIHARD64-NOT: "-target-feature" "+soft-float"
+//
+// check invalid -mfloat-abi
+// RUN: %clang -c %s -### -o %t.o 2>&1 \
+// RUN: -target sparc64-linux-gnu -mfloat-abi=x \
+// RUN:   | FileCheck --check-prefix=CHECK-ERRMSG64 %s
+// CHECK-ERRMSG64: error: invalid float ABI '-mfloat-abi=x'
Index: test/CodeGen/function-target-features.c
===
--- test/CodeGen/function-target-features.c
+++ test/CodeGen/function-target-features.c
@@ -9,7 +9,7 @@
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o - %s -target-cpu corei7 -target-feature +avx | FileCheck %s -check-prefix=CORE-CPU-AND-FEATURES
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o - %s -target-cpu x86-64 | FileCheck %s -check-prefix=X86-64-CPU
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o - %s -target-cpu corei7-avx -target-feature -avx | FileCheck %s -check-prefix=AVX-MINUS-FEATURE
-// RUN: %clang_cc1 -triple sparc-unknown-unknown -emit-llvm -o - %s -target-feature +soft-float | FileCheck %s -check-prefix=NO-SOFT-FLOAT
+// RUN: %clang_cc1 -triple sparc-unknown-unknown -emit-llvm -o - %s -target-feature +soft-float | FileCheck %s -check-prefix=SOFT-FLOAT
 // RUN: %clang_cc1 -triple arm-unknown-unknown -emit-llvm -o - %s -target-feature +soft-float | FileCheck %s -check-prefix=SOFT-FLOAT
 // RUN: %clang_cc1 -triple mips-unknown-unknown -emit-llvm -o - %s -target-feature +soft-float | FileCheck %s -check-prefix=SOFT-FLOAT
 
Index: lib/Driver/Tools.h
===
--- lib/Driver/Tools.h
+++ lib/Driver/Tools.h
@@ -777,6 +777,16 @@
 FloatABI getPPCFloatABI(const Driver &D, const llvm::opt::ArgList &Args);
 } // end namespace ppc
 
+namespace sparc {
+enum class FloatABI {
+  Invalid,
+  Soft,
+  Hard,
+};
+
+FloatABI getSparcFloatABI(const Driver &D, const llvm::opt::ArgList &Args);
+} // end namespace sparc
+
 namespace XCore {
 // For XCore, we do not need to instantiate tools for PreProcess, PreCompile and
 // Compile.
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -1640,28 +1640,67 @@
   return "";
 }
 
-void Clang::AddSparcTargetArgs(const ArgList &Args,
-   ArgStringList &CmdArgs) const {
-  const Driver &D = getToolChain().getDriver();
-  std::string Triple = getToolChain().ComputeEffectiveClangTriple(Args);
-
-  bool SoftFloatABI = false;
+sparc::FloatABI sparc::getSparcFloatABI(const Driver &D,
+const ArgList &Args) {
+  sparc::FloatABI ABI = sparc::FloatABI::Invalid;
   if (Ar

r270538 - [Sparc] Add software float option -msoft-float

2016-05-24 Thread Jacob Baungard Hansen via cfe-commits
Author: jacob_hansen
Date: Tue May 24 03:30:08 2016
New Revision: 270538

URL: http://llvm.org/viewvc/llvm-project?rev=270538&view=rev
Log:
[Sparc] Add software float option -msoft-float

Summary:
Following patch D19265 which enable software floating point support in the 
Sparc backend, this patch enables the option to be enabled in the front-end 
using the -msoft-float option.

The user should ensure a library (such as the builtins from Compiler-RT) that 
includes the software floating point routines is provided.

Reviewers: jyknight, lero_chris

Subscribers: jyknight, cfe-commits

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

Modified:
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/lib/Driver/Tools.h
cfe/trunk/test/CodeGen/function-target-features.c
cfe/trunk/test/Driver/sparc-float.c

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=270538&r1=270537&r2=270538&view=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Tue May 24 03:30:08 2016
@@ -6333,12 +6333,10 @@ public:
 
   bool handleTargetFeatures(std::vector &Features,
 DiagnosticsEngine &Diags) override {
-// The backend doesn't actually handle soft float yet, but in case someone
-// is using the support for the front end continue to support it.
+// Check if software floating point is enabled
 auto Feature = std::find(Features.begin(), Features.end(), "+soft-float");
 if (Feature != Features.end()) {
   SoftFloat = true;
-  Features.erase(Feature);
 }
 return true;
   }

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=270538&r1=270537&r2=270538&view=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Tue May 24 03:30:08 2016
@@ -1640,28 +1640,67 @@ static std::string getLanaiTargetCPU(con
   return "";
 }
 
-void Clang::AddSparcTargetArgs(const ArgList &Args,
-   ArgStringList &CmdArgs) const {
-  const Driver &D = getToolChain().getDriver();
-  std::string Triple = getToolChain().ComputeEffectiveClangTriple(Args);
-
-  bool SoftFloatABI = false;
+sparc::FloatABI sparc::getSparcFloatABI(const Driver &D,
+const ArgList &Args) {
+  sparc::FloatABI ABI = sparc::FloatABI::Invalid;
   if (Arg *A =
-  Args.getLastArg(options::OPT_msoft_float, options::OPT_mhard_float)) 
{
+  Args.getLastArg(options::OPT_msoft_float, options::OPT_mhard_float,
+  options::OPT_mfloat_abi_EQ)) {
 if (A->getOption().matches(options::OPT_msoft_float))
-  SoftFloatABI = true;
+  ABI = sparc::FloatABI::Soft;
+else if (A->getOption().matches(options::OPT_mhard_float))
+  ABI = sparc::FloatABI::Hard;
+else {
+  ABI = llvm::StringSwitch(A->getValue())
+.Case("soft", sparc::FloatABI::Soft)
+.Case("hard", sparc::FloatABI::Hard)
+.Default(sparc::FloatABI::Invalid);
+  if (ABI == sparc::FloatABI::Invalid &&
+  !StringRef(A->getValue()).empty()) {
+D.Diag(diag::err_drv_invalid_mfloat_abi) << A->getAsString(Args);
+ABI = sparc::FloatABI::Hard;
+  }
+}
   }
 
+  // If unspecified, choose the default based on the platform.
   // Only the hard-float ABI on Sparc is standardized, and it is the
-  // default. GCC also supports a nonstandard soft-float ABI mode, and
-  // perhaps LLVM should implement that, too. However, since llvm
-  // currently does not support Sparc soft-float, at all, display an
-  // error if it's requested.
-  if (SoftFloatABI) {
-D.Diag(diag::err_drv_unsupported_opt_for_target) << "-msoft-float"
- << Triple;
+  // default. GCC also supports a nonstandard soft-float ABI mode, also
+  // implemented in LLVM. However as this is not standard we set the default
+  // to be hard-float.
+  if (ABI == sparc::FloatABI::Invalid) {
+ABI = sparc::FloatABI::Hard;
   }
 
+  return ABI;
+}
+
+static void getSparcTargetFeatures(const Driver &D, const ArgList &Args,
+ std::vector &Features) {
+  sparc::FloatABI FloatABI = sparc::getSparcFloatABI(D, Args);
+  if (FloatABI == sparc::FloatABI::Soft)
+Features.push_back("+soft-float");
+}
+
+void Clang::AddSparcTargetArgs(const ArgList &Args,
+   ArgStringList &CmdArgs) const {
+  //const Driver &D = getToolChain().getDriver();
+  std::string Triple = getToolChain().ComputeEffectiveClangTriple(Args);
+
+  sparc::FloatABI FloatABI =
+  sparc::getSparcFloatABI(getToolChain().getDriver(), Args);
+
+  if (FloatABI == sparc

Re: [PATCH] D20419: [Sparc] Add software float option -msoft-float

2016-05-24 Thread Jacob Baungard Hansen via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL270538: [Sparc] Add software float option -msoft-float 
(authored by jacob_hansen).

Changed prior to commit:
  http://reviews.llvm.org/D20419?vs=58203&id=58204#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D20419

Files:
  cfe/trunk/lib/Basic/Targets.cpp
  cfe/trunk/lib/Driver/Tools.cpp
  cfe/trunk/lib/Driver/Tools.h
  cfe/trunk/test/CodeGen/function-target-features.c
  cfe/trunk/test/Driver/sparc-float.c

Index: cfe/trunk/lib/Basic/Targets.cpp
===
--- cfe/trunk/lib/Basic/Targets.cpp
+++ cfe/trunk/lib/Basic/Targets.cpp
@@ -6333,12 +6333,10 @@
 
   bool handleTargetFeatures(std::vector &Features,
 DiagnosticsEngine &Diags) override {
-// The backend doesn't actually handle soft float yet, but in case someone
-// is using the support for the front end continue to support it.
+// Check if software floating point is enabled
 auto Feature = std::find(Features.begin(), Features.end(), "+soft-float");
 if (Feature != Features.end()) {
   SoftFloat = true;
-  Features.erase(Feature);
 }
 return true;
   }
Index: cfe/trunk/lib/Driver/Tools.h
===
--- cfe/trunk/lib/Driver/Tools.h
+++ cfe/trunk/lib/Driver/Tools.h
@@ -777,6 +777,16 @@
 FloatABI getPPCFloatABI(const Driver &D, const llvm::opt::ArgList &Args);
 } // end namespace ppc
 
+namespace sparc {
+enum class FloatABI {
+  Invalid,
+  Soft,
+  Hard,
+};
+
+FloatABI getSparcFloatABI(const Driver &D, const llvm::opt::ArgList &Args);
+} // end namespace sparc
+
 namespace XCore {
 // For XCore, we do not need to instantiate tools for PreProcess, PreCompile and
 // Compile.
Index: cfe/trunk/lib/Driver/Tools.cpp
===
--- cfe/trunk/lib/Driver/Tools.cpp
+++ cfe/trunk/lib/Driver/Tools.cpp
@@ -1640,28 +1640,67 @@
   return "";
 }
 
-void Clang::AddSparcTargetArgs(const ArgList &Args,
-   ArgStringList &CmdArgs) const {
-  const Driver &D = getToolChain().getDriver();
-  std::string Triple = getToolChain().ComputeEffectiveClangTriple(Args);
-
-  bool SoftFloatABI = false;
+sparc::FloatABI sparc::getSparcFloatABI(const Driver &D,
+const ArgList &Args) {
+  sparc::FloatABI ABI = sparc::FloatABI::Invalid;
   if (Arg *A =
-  Args.getLastArg(options::OPT_msoft_float, options::OPT_mhard_float)) {
+  Args.getLastArg(options::OPT_msoft_float, options::OPT_mhard_float,
+  options::OPT_mfloat_abi_EQ)) {
 if (A->getOption().matches(options::OPT_msoft_float))
-  SoftFloatABI = true;
+  ABI = sparc::FloatABI::Soft;
+else if (A->getOption().matches(options::OPT_mhard_float))
+  ABI = sparc::FloatABI::Hard;
+else {
+  ABI = llvm::StringSwitch(A->getValue())
+.Case("soft", sparc::FloatABI::Soft)
+.Case("hard", sparc::FloatABI::Hard)
+.Default(sparc::FloatABI::Invalid);
+  if (ABI == sparc::FloatABI::Invalid &&
+  !StringRef(A->getValue()).empty()) {
+D.Diag(diag::err_drv_invalid_mfloat_abi) << A->getAsString(Args);
+ABI = sparc::FloatABI::Hard;
+  }
+}
   }
 
+  // If unspecified, choose the default based on the platform.
   // Only the hard-float ABI on Sparc is standardized, and it is the
-  // default. GCC also supports a nonstandard soft-float ABI mode, and
-  // perhaps LLVM should implement that, too. However, since llvm
-  // currently does not support Sparc soft-float, at all, display an
-  // error if it's requested.
-  if (SoftFloatABI) {
-D.Diag(diag::err_drv_unsupported_opt_for_target) << "-msoft-float"
- << Triple;
+  // default. GCC also supports a nonstandard soft-float ABI mode, also
+  // implemented in LLVM. However as this is not standard we set the default
+  // to be hard-float.
+  if (ABI == sparc::FloatABI::Invalid) {
+ABI = sparc::FloatABI::Hard;
   }
 
+  return ABI;
+}
+
+static void getSparcTargetFeatures(const Driver &D, const ArgList &Args,
+ std::vector &Features) {
+  sparc::FloatABI FloatABI = sparc::getSparcFloatABI(D, Args);
+  if (FloatABI == sparc::FloatABI::Soft)
+Features.push_back("+soft-float");
+}
+
+void Clang::AddSparcTargetArgs(const ArgList &Args,
+   ArgStringList &CmdArgs) const {
+  //const Driver &D = getToolChain().getDriver();
+  std::string Triple = getToolChain().ComputeEffectiveClangTriple(Args);
+
+  sparc::FloatABI FloatABI =
+  sparc::getSparcFloatABI(getToolChain().getDriver(), Args);
+
+  if (FloatABI == sparc::FloatABI::Soft) {
+// Floating point operations and argument passing are soft.
+CmdArgs.push_back("-msoft-float");
+CmdAr

Re: [PATCH] D20089: Adding a TargetParser for AArch64

2016-05-24 Thread jojo.ma via cfe-commits
jojo added inline comments.


Comment at: include/llvm/Support/AArch64TargetParser.def:20
@@ +19,3 @@
+AARCH64_ARCH("armv8-a", AK_ARMV8A, "8-A", "v8", ARMBuildAttrs::CPUArch::v8_A,
+  FK_CRYPTO_NEON_FP_ARMV8, (AArch64::AEK_CRC | AArch64::AEK_CRYPTO | 
AArch64::AEK_FP | AArch64::AEK_SIMD | AArch64::AEK_FP16 | AArch64::AEK_PROFILE))
+AARCH64_ARCH("armv8.1-a", AK_ARMV8_1A, "8.1-A", "v8.1a", 
ARMBuildAttrs::CPUArch::v8_A,

rengolin wrote:
> Please, format this file to 80-columns.
I neglected this.Format it in the update.


Comment at: include/llvm/Support/AArch64TargetParser.def:31
@@ +30,3 @@
+// FIXME: This would be nicer were it tablegen
+AARCH64_ARCH_EXT_NAME("invalid",  AArch64::AEK_INVALID,  nullptr,  nullptr)
+AARCH64_ARCH_EXT_NAME("none", AArch64::AEK_NONE, nullptr,  nullptr)

rengolin wrote:
> Same comment as the ARM def file, wrapping with "namespace AArch64 { }".
Looks like the namespace is not supported in the def file. I tried this in the 
early time.


Comment at: include/llvm/Support/ARMTargetParser.def:48
@@ -47,3 +47,3 @@
 ARM_ARCH("invalid", AK_INVALID, nullptr, nullptr,
-  ARMBuildAttrs::CPUArch::Pre_v4, FK_NONE, AEK_NONE)
+  ARMBuildAttrs::CPUArch::Pre_v4, FK_NONE, ARM::AEK_NONE)
 ARM_ARCH("armv2", AK_ARMV2, "2", "v2", ARMBuildAttrs::CPUArch::Pre_v4,

rengolin wrote:
> This is the "ARM" def file, maybe wrap with "namespace ARM { }"?
Same as "AArch64" def file.


Comment at: include/llvm/Support/TargetParser.h:144
@@ +143,3 @@
+
+namespace AArch64 {
+

rengolin wrote:
> Please, add a FIXME line here, saying this really should be made into a 
> class, to use ARM's methods from inheritance.
Well,yes.Done it in the update.


Comment at: lib/Support/TargetParser.cpp:764
@@ +763,3 @@
+  Arch = getCanonicalArchName(Arch);
+  if (!Arch.startswith("v8"))
+return ARM::AK_INVALID;

rengolin wrote:
> Maybe a better check here would be:
> 
> if (checkArchVersion(Arch) < 8)
> return ARM::AK_INVALID;
Good advice.Put the check in a method alone.


Comment at: lib/Support/TargetParser.cpp:770
@@ +769,3 @@
+if (A.getName().endswith(Syn)) {
+  if (A.ID == ARM::AK_ARMV8_1A)
+Features.push_back("+v8.1a");

rengolin wrote:
> I don't like mixing Features with parseArch. Maybe we could do two different 
> methods and get callers to use both when needed, just like with ARM.
> 
> parseArch needs to be dead simple.
Yes.Moving this to another method "getArchFeatures".


http://reviews.llvm.org/D20089



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


Re: [PATCH] D20089: Adding a TargetParser for AArch64

2016-05-24 Thread jojo.ma via cfe-commits
jojo set the repository for this revision to rL LLVM.
jojo changed the visibility of this Differential Revision from "Public (No 
Login Required)" to "All Users".
jojo updated this revision to Diff 58205.
jojo added a comment.

1.include/llvm/Support/AArch64TargetParser.def

  Format this file.

2.include/llvm/Support/TargetParser.h

  Add FIXME and the definition of  two methods

3.lib/Support/TargetParser.cpp

  Adjust "llvm::AArch64::parseArch" logic.


Repository:
  rL LLVM

http://reviews.llvm.org/D20089

Files:
  include/llvm/Support/AArch64TargetParser.def
  include/llvm/Support/ARMTargetParser.def
  include/llvm/Support/TargetParser.h
  lib/Support/TargetParser.cpp

Index: lib/Support/TargetParser.cpp
===
--- lib/Support/TargetParser.cpp
+++ lib/Support/TargetParser.cpp
@@ -21,6 +21,7 @@
 
 using namespace llvm;
 using namespace ARM;
+using namespace AArch64;
 
 namespace {
 
@@ -75,6 +76,11 @@
   {NAME, sizeof(NAME) - 1, CPU_ATTR, sizeof(CPU_ATTR) - 1, SUB_ARCH,   \
sizeof(SUB_ARCH) - 1, ARCH_FPU, ARCH_BASE_EXT, ID, ARCH_ATTR},
 #include "llvm/Support/ARMTargetParser.def"
+},AArch64ARCHNames[] = {
+#define AARCH64_ARCH(NAME, ID, CPU_ATTR, SUB_ARCH, ARCH_ATTR, ARCH_FPU, ARCH_BASE_EXT)   \
+  {NAME, sizeof(NAME) - 1, CPU_ATTR, sizeof(CPU_ATTR) - 1, SUB_ARCH,   \
+   sizeof(SUB_ARCH) - 1, ARCH_FPU, ARCH_BASE_EXT, ID, ARCH_ATTR},
+#include "llvm/Support/AArch64TargetParser.def"
 };
 
 // List of Arch Extension names.
@@ -91,6 +97,10 @@
 #define ARM_ARCH_EXT_NAME(NAME, ID, FEATURE, NEGFEATURE) \
   { NAME, sizeof(NAME) - 1, ID, FEATURE, NEGFEATURE },
 #include "llvm/Support/ARMTargetParser.def"
+},AArch64ARCHExtNames[] = {
+#define AARCH64_ARCH_EXT_NAME(NAME, ID, FEATURE, NEGFEATURE) \
+  { NAME, sizeof(NAME) - 1, ID, FEATURE, NEGFEATURE },
+#include "llvm/Support/AArch64TargetParser.def"
 };
 
 // List of HWDiv names (use getHWDivSynonym) and which architectural
@@ -124,6 +134,10 @@
 #define ARM_CPU_NAME(NAME, ID, DEFAULT_FPU, IS_DEFAULT, DEFAULT_EXT) \
   { NAME, sizeof(NAME) - 1, ID, IS_DEFAULT, DEFAULT_EXT },
 #include "llvm/Support/ARMTargetParser.def"
+},AArch64CPUNames[] = {
+#define AARCH64_CPU_NAME(NAME, ID, DEFAULT_FPU, IS_DEFAULT, DEFAULT_EXT) \
+  { NAME, sizeof(NAME) - 1, ID, IS_DEFAULT, DEFAULT_EXT },
+#include "llvm/Support/AArch64TargetParser.def"
 };
 
 } // namespace
@@ -369,6 +383,153 @@
   return "generic";
 }
 
+StringRef llvm::AArch64::getFPUName(unsigned FPUKind) {
+  return ARM::getFPUName(FPUKind);
+}
+
+unsigned llvm::AArch64::getFPUVersion(unsigned FPUKind) {
+  return ARM::getFPUVersion(FPUKind);
+}
+
+unsigned llvm::AArch64::getFPUNeonSupportLevel(unsigned FPUKind) {
+  return ARM::getFPUNeonSupportLevel( FPUKind);
+}
+
+unsigned llvm::AArch64::getFPURestriction(unsigned FPUKind) {
+  return ARM::getFPURestriction(FPUKind);
+}
+
+unsigned llvm::AArch64::getDefaultFPU(StringRef CPU, unsigned ArchKind) {
+  if (CPU == "generic")
+return AArch64ARCHNames[ArchKind].DefaultFPU;
+
+  return StringSwitch(CPU)
+#define AARCH64_CPU_NAME(NAME, ID, DEFAULT_FPU, IS_DEFAULT, DEFAULT_EXT) \
+.Case(NAME, DEFAULT_FPU)
+#include "llvm/Support/AArch64TargetParser.def"
+.Default(ARM::FK_INVALID);
+}
+
+unsigned llvm::AArch64::getDefaultExtensions(StringRef CPU, unsigned ArchKind) {
+  if (CPU == "generic")
+return AArch64ARCHNames[ArchKind].ArchBaseExtensions;
+
+  return StringSwitch(CPU)
+#define AARCH64_CPU_NAME(NAME, ID, DEFAULT_FPU, IS_DEFAULT, DEFAULT_EXT) \
+.Case(NAME, AArch64ARCHNames[ID].ArchBaseExtensions | DEFAULT_EXT)
+#include "llvm/Support/AArch64TargetParser.def"
+.Default(AArch64::AEK_INVALID);
+}
+
+bool llvm::AArch64::getExtensionFeatures(unsigned Extensions,
+ std::vector &Features) {
+
+  if (Extensions == AArch64::AEK_INVALID)
+return false;
+
+  if (Extensions & AArch64::AEK_FP)
+Features.push_back("+fp-armv8");
+  if (Extensions & AArch64::AEK_SIMD)
+Features.push_back("+neon");
+  if (Extensions & AArch64::AEK_CRC)
+Features.push_back("+crc");
+  if (Extensions & AArch64::AEK_CRYPTO)
+Features.push_back("+crypto");
+  if (Extensions & AArch64::AEK_FP16)
+Features.push_back("+fullfp16");
+  if (Extensions & AArch64::AEK_PROFILE)
+Features.push_back("+spe");
+
+  return true;
+}
+
+bool llvm::AArch64::getFPUFeatures(unsigned FPUKind,
+   std::vector &Features) {
+  return ARM::getFPUFeatures(FPUKind, Features);
+}
+
+StringRef llvm::AArch64::getArchName(unsigned ArchKind) {
+  if (ArchKind >= ARM::AK_LAST)
+return StringRef();
+  return AArch64ARCHNames[ArchKind].getName();
+}
+
+bool llvm::AArch64::getArchFeatures(unsigned ArchKind,
+ std::vector &Features) {
+  if (ArchKind == ARM::AK_INVALID || ArchKind >= ARM::AK_LAST)
+return false;
+
+  if (ArchKind == ARM::AK_ARMV8_1A)
+Features.push_back("+v8.1a");
+  if (ArchKind == ARM::

Re: [PATCH] D20243: [PCH] Disable inclusion of timestamps when generating pch files on windows.

2016-05-24 Thread pierre gousseau via cfe-commits
pgousseau updated this revision to Diff 58207.
pgousseau added a comment.

Moving REQUIRE line higher following Bruno's comments.


http://reviews.llvm.org/D20243

Files:
  lib/Frontend/FrontendActions.cpp
  lib/Serialization/ASTReader.cpp
  test/PCH/Inputs/pragma-once2-pch.h
  test/PCH/Inputs/pragma-once2.h
  test/PCH/pragma-once-timestamp.cpp

Index: test/PCH/pragma-once-timestamp.cpp
===
--- /dev/null
+++ test/PCH/pragma-once-timestamp.cpp
@@ -0,0 +1,24 @@
+// On Windows, timestamps for pch are not handled correctly.
+// This would cause pragma once to be ignored on distributed builds.
+// pragma-once2-pch.h includes pragma-once2.h which has a pragma once 
directive.
+// pragma-once2.h is then touched before using the generated pch.
+// On Linux this will cause an expected error, but on Windows we want to
+// ignore the timestamp as the timestamp handling on Windows is
+// inconsistent at the moment.
+
+// REQUIRES: system-windows
+
+// Test this without pch.
+// RUN: %clang_cc1 -include %S/Inputs/pragma-once2-pch.h -fsyntax-only -verify 
%s
+
+// Test with pch.
+// RUN: %clang_cc1 -emit-pch -o %t -x c++-header %S/Inputs/pragma-once2-pch.h
+// RUN: touch %S/Inputs/pragma-once2.h
+// RUN: %clang_cc1 -include-pch %t -fsyntax-only -verify %s
+
+// expected-no-diagnostics
+
+#include "Inputs/pragma-once2.h"
+
+void g() { f(); }
+
Index: test/PCH/Inputs/pragma-once2.h
===
--- /dev/null
+++ test/PCH/Inputs/pragma-once2.h
@@ -0,0 +1,4 @@
+#pragma once
+
+inline void f() {}
+
Index: test/PCH/Inputs/pragma-once2-pch.h
===
--- /dev/null
+++ test/PCH/Inputs/pragma-once2-pch.h
@@ -0,0 +1,2 @@
+#include "pragma-once2.h"
+
Index: lib/Serialization/ASTReader.cpp
===
--- lib/Serialization/ASTReader.cpp
+++ lib/Serialization/ASTReader.cpp
@@ -2013,6 +2013,8 @@
// In our regression testing, the Windows file system seems to
// have inconsistent modification times that sometimes
// erroneously trigger this error-handling path.
+   // For now timestamps are disabled for pch files on Windows (c.f
+   // GeneratePCHAction::CreateASTConsumer).
//
// FIXME: This probably also breaks HeaderFileInfo lookups on Windows.
(StoredTime && StoredTime != File->getModificationTime() &&
Index: lib/Frontend/FrontendActions.cpp
===
--- lib/Frontend/FrontendActions.cpp
+++ lib/Frontend/FrontendActions.cpp
@@ -90,9 +90,15 @@
 
   auto Buffer = std::make_shared();
   std::vector> Consumers;
+  // FIXME: There is a known issue with timestamps appearing to be inconsistent
+  // on Windows (c.f. ASTReader::getInputFile) so we disable timestamps checks
+  // on Windows for now.
+  llvm::Triple HostTriple(LLVM_HOST_TRIPLE);
   Consumers.push_back(llvm::make_unique(
 CI.getPreprocessor(), OutputFile, nullptr, Sysroot,
-Buffer, CI.getFrontendOpts().ModuleFileExtensions));
+Buffer, CI.getFrontendOpts().ModuleFileExtensions,
+/*AllowASTWithErrors*/false,
+/*IncludeTimestamps*/!HostTriple.isOSWindows()));
   Consumers.push_back(CI.getPCHContainerWriter().CreatePCHContainerGenerator(
   CI, InFile, OutputFile, OS, Buffer));
 


Index: test/PCH/pragma-once-timestamp.cpp
===
--- /dev/null
+++ test/PCH/pragma-once-timestamp.cpp
@@ -0,0 +1,24 @@
+// On Windows, timestamps for pch are not handled correctly.
+// This would cause pragma once to be ignored on distributed builds.
+// pragma-once2-pch.h includes pragma-once2.h which has a pragma once directive.
+// pragma-once2.h is then touched before using the generated pch.
+// On Linux this will cause an expected error, but on Windows we want to
+// ignore the timestamp as the timestamp handling on Windows is
+// inconsistent at the moment.
+
+// REQUIRES: system-windows
+
+// Test this without pch.
+// RUN: %clang_cc1 -include %S/Inputs/pragma-once2-pch.h -fsyntax-only -verify %s
+
+// Test with pch.
+// RUN: %clang_cc1 -emit-pch -o %t -x c++-header %S/Inputs/pragma-once2-pch.h
+// RUN: touch %S/Inputs/pragma-once2.h
+// RUN: %clang_cc1 -include-pch %t -fsyntax-only -verify %s
+
+// expected-no-diagnostics
+
+#include "Inputs/pragma-once2.h"
+
+void g() { f(); }
+
Index: test/PCH/Inputs/pragma-once2.h
===
--- /dev/null
+++ test/PCH/Inputs/pragma-once2.h
@@ -0,0 +1,4 @@
+#pragma once
+
+inline void f() {}
+
Index: test/PCH/Inputs/pragma-once2-pch.h
===
--- /dev/null
+++ test/PCH/Inputs/pragma-once2-pch.h
@@ -0,0 +1,2 @@
+#include "

Re: [PATCH] D20537: clang-rename: fix renaming non-members variables when referenced as macro arguments

2016-05-24 Thread Manuel Klimek via cfe-commits
klimek accepted this revision.
klimek added a comment.
This revision is now accepted and ready to land.

lg


http://reviews.llvm.org/D20537



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


Re: [PATCH] D20243: [PCH] Disable inclusion of timestamps when generating pch files on windows.

2016-05-24 Thread pierre gousseau via cfe-commits
pgousseau added a comment.

In http://reviews.llvm.org/D20243#437192, @thakis wrote:

> Hm, the ASTReader code this works around is over 6 years old (r100866). Maybe 
> we could try enabling the access time check instead?


Yes the issue described in ASTReader lacks a reproducible so it makes sense to 
tentatively re-enabling the timestamp check on windows. If the issue still 
occurs on some bots then at least we can document the issue better before 
re-disabling it.

I also would like to provide a switch to disable inclusion of timestamps. I 
will hopefully be proposing a patch for it soon.


http://reviews.llvm.org/D20243



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


Re: [PATCH] D20089: Adding a TargetParser for AArch64

2016-05-24 Thread jojo.ma via cfe-commits
jojo added a comment.

> While I agree with Bradley that the repetition is not pretty, I think it will 
> expose all issues to make a class design simple and straightforward, once we 
> get all the sharp edges out. But we need to know what are the difficulties on 
> Clang, llc and the back-ends, and make sure that the architectural part of 
> the change is correct, before we that.


A class based design *will* change how every TargetParser method is being 
called now, and will touch a large number of files with mechanical changes, 
including in the ARM side, unrelated to the addition of AArch64.

Yes.It will be a big project really,especially for me.I need to have a 
considerable understanding of the front-end, back-end, and the arm 
architecture, if I'm going to do it.

> After my failed attempt at getting a class design across, I'd rather 
> introduce functionality first, then design better, than the other way round. 
> But I think they should be separated commits based on their intents and 
> merits alone.


Totally agree.And that's exactly what I think.I think we can take class design 
as a low priority task.Maybe we could put it in our backlog list.


Repository:
  rL LLVM

http://reviews.llvm.org/D20089



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


Re: [PATCH] D20088: Using AArch64TargetParser in clang

2016-05-24 Thread jojo.ma via cfe-commits
jojo set the repository for this revision to rL LLVM.
jojo changed the visibility of this Differential Revision from "Public (No 
Login Required)" to "All Users".
jojo updated this revision to Diff 58210.
jojo added a comment.

Adjust "getAArch64ArchFeaturesFromMarch" logic.In file lib/Driver/Tools.cpp.


Repository:
  rL LLVM

http://reviews.llvm.org/D20088

Files:
  lib/Basic/Targets.cpp
  lib/Driver/Tools.cpp

Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -2223,22 +2223,9 @@
   text.split(Split, StringRef("+"), -1, false);
 
   for (StringRef Feature : Split) {
-const char *result = llvm::StringSwitch(Feature)
- .Case("fp", "+fp-armv8")
- .Case("simd", "+neon")
- .Case("crc", "+crc")
- .Case("crypto", "+crypto")
- .Case("fp16", "+fullfp16")
- .Case("profile", "+spe")
- .Case("nofp", "-fp-armv8")
- .Case("nosimd", "-neon")
- .Case("nocrc", "-crc")
- .Case("nocrypto", "-crypto")
- .Case("nofp16", "-fullfp16")
- .Case("noprofile", "-spe")
- .Default(nullptr);
-if (result)
-  Features.push_back(result);
+const char *FeatureName = llvm::AArch64::getArchExtFeature(Feature);
+if (FeatureName)
+  Features.push_back(FeatureName);
 else if (Feature == "neon" || Feature == "noneon")
   D.Diag(diag::err_drv_no_neon_modifier);
 else
@@ -2253,20 +2240,16 @@
   std::vector &Features) {
   std::pair Split = Mcpu.split("+");
   CPU = Split.first;
-  if (CPU == "cortex-a53" || CPU == "cortex-a57" ||
-  CPU == "cortex-a72" || CPU == "cortex-a35" || CPU == "exynos-m1" ||
-  CPU == "kryo") {
-Features.push_back("+neon");
-Features.push_back("+crc");
-Features.push_back("+crypto");
-  } else if (CPU == "cyclone") {
-Features.push_back("+neon");
-Features.push_back("+crypto");
-  } else if (CPU == "generic") {
+
+  if (CPU == "generic") {
 Features.push_back("+neon");
   } else {
-return false;
-  }
+unsigned ArchKind = llvm::AArch64::parseCPUArch(CPU);
+unsigned Extersion = llvm::AArch64::getDefaultExtensions(CPU,ArchKind);
+
+if (!llvm::AArch64::getExtensionFeatures(Extersion,Features))
+  return false;
+   }
 
   if (Split.second.size() && !DecodeAArch64Features(D, Split.second, Features))
 return false;
@@ -2278,20 +2261,13 @@
 getAArch64ArchFeaturesFromMarch(const Driver &D, StringRef March,
 const ArgList &Args,
 std::vector &Features) {
+  unsigned ArchKind;
   std::string MarchLowerCase = March.lower();
   std::pair Split = StringRef(MarchLowerCase).split("+");
 
-  if (Split.first == "armv8-a" || Split.first == "armv8a") {
-// ok, no additional features.
-  } else if (Split.first == "armv8.1-a" || Split.first == "armv8.1a") {
-Features.push_back("+v8.1a");
-  } else if (Split.first == "armv8.2-a" || Split.first == "armv8.2a" ) {
-Features.push_back("+v8.2a");
-  } else {
-return false;
-  }
-
-  if (Split.second.size() && !DecodeAArch64Features(D, Split.second, Features))
+  ArchKind = llvm::AArch64::parseArch(Split.first);
+  if (ArchKind == llvm::ARM::AK_INVALID || !llvm::AArch64::getArchFeatures(ArchKind, Features) ||
+	  (Split.second.size() && !DecodeAArch64Features(D, Split.second, Features)))
 return false;
 
   return true;
Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -5665,14 +5665,10 @@
   }
 
   bool setCPU(const std::string &Name) override {
-bool CPUKnown = llvm::StringSwitch(Name)
-.Case("generic", true)
-.Cases("cortex-a53", "cortex-a57", "cortex-a72",
-   "cortex-a35", "exynos-m1", true)
-.Case("cyclone", true)
-.Case("kryo", true)
-.Default(false);
-return CPUKnown;
+if (Name == "generic" || llvm::AArch64::parseCPUArch(Name) != llvm::ARM::AK_INVALID)
+  return true;
+
+return false;
   }
 
   void getTargetDefines(const LangOptions &Opts,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r270373 - [driver][mips] Support new versions of MIPS CodeScape toolchains

2016-05-24 Thread Ismail Donmez via cfe-commits
Hi,

On Sun, May 22, 2016 at 9:18 PM, Simon Atanasyan via cfe-commits
 wrote:
> Author: atanasyan
> Date: Sun May 22 13:18:07 2016
> New Revision: 270373
>
> URL: http://llvm.org/viewvc/llvm-project?rev=270373&view=rev
> Log:
> [driver][mips] Support new versions of MIPS CodeScape toolchains

Two tests fail for me on Linux, please the attached build log.

Thanks,
ismail


build.txt.gz
Description: GNU Zip compressed data
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20113: Fix mangled name of method with ns_consumed parameters.

2016-05-24 Thread Sylvain Defresne via cfe-commits
sdefresne added a comment.

Thank you for the comment.

I think my change still needs to be reviewed and approved by someone (at least 
in the Phabricator interface it still appears as "Need review"). Can you do the 
review and give approval if it looks good to you?

Once this is approved, should I just follow instructions at 
http://llvm.org/docs/Phabricator.html#subversion-and-arcanist? Do I need to 
request any kind of access rights?

Sorry for the questions, as I said, this is my first change against clang/llvm. 
Cheers,


http://reviews.llvm.org/D20113



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


[PATCH] D20562: [Clang][AVX512][BUILTIN] Adding intrinsics for set1

2016-05-24 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/D20562

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
@@ -328,6 +328,34 @@
   return _mm512_set1_pd(d);
 }
 
+__m512d test_mm512_set1_epi8(char d)
+{
+  // CHECK-LABEL: @test_mm512_set1_epi8
+  // CHECK: insertelement <64 x i8> {{.*}}, i32 0
+  // CHECK: insertelement <64 x i8> {{.*}}, i32 1
+  // CHECK: insertelement <64 x i8> {{.*}}, i32 2
+  // CHECK: insertelement <64 x i8> {{.*}}, i32 3
+  // CHECK: insertelement <64 x i8> {{.*}}, i32 4
+  // CHECK: insertelement <64 x i8> {{.*}}, i32 5
+  // CHECK: insertelement <64 x i8> {{.*}}, i32 6
+  // CHECK: insertelement <64 x i8> {{.*}}, i32 7
+  return _mm512_set1_epi8(d);
+}
+
+__m512d test_mm512_set1_epi16(short d)
+{
+  // CHECK-LABEL: @test_mm512_set1_epi16
+  // CHECK: insertelement <32 x i16> {{.*}}, i32 0
+  // CHECK: insertelement <32 x i16> {{.*}}, i32 1
+  // CHECK: insertelement <32 x i16> {{.*}}, i32 2
+  // CHECK: insertelement <32 x i16> {{.*}}, i32 3
+  // CHECK: insertelement <32 x i16> {{.*}}, i32 4
+  // CHECK: insertelement <32 x i16> {{.*}}, i32 5
+  // CHECK: insertelement <32 x i16> {{.*}}, i32 6
+  // CHECK: insertelement <32 x i16> {{.*}}, i32 7
+  return _mm512_set1_epi16(d);
+}
+
 __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
@@ -27,6 +27,8 @@
 #ifndef __AVX512FINTRIN_H
 #define __AVX512FINTRIN_H
 
+typedef char __v64qi __attribute__((__vector_size__(64)));
+typedef short __v32hi __attribute__((__vector_size__(64)));
 typedef double __v8df __attribute__((__vector_size__(64)));
 typedef float __v16sf __attribute__((__vector_size__(64)));
 typedef long long __v8di __attribute__((__vector_size__(64)));
@@ -286,6 +288,28 @@
 }
 
 static __inline __m512i __DEFAULT_FN_ATTRS
+_mm512_set1_epi8(char __w)
+{
+  return (__m512i)(__v64qi){ __w, __w, __w, __w, __w, __w, __w, __w,
+ __w, __w, __w, __w, __w, __w, __w, __w,
+ __w, __w, __w, __w, __w, __w, __w, __w,
+ __w, __w, __w, __w, __w, __w, __w, __w,
+ __w, __w, __w, __w, __w, __w, __w, __w,
+ __w, __w, __w, __w, __w, __w, __w, __w,
+ __w, __w, __w, __w, __w, __w, __w, __w,
+ __w, __w, __w, __w, __w, __w, __w, __w  };
+}
+
+static __inline __m512i __DEFAULT_FN_ATTRS
+_mm512_set1_epi16(short __w)
+{
+  return (__m512i)(__v32hi){ __w, __w, __w, __w, __w, __w, __w, __w,
+ __w, __w, __w, __w, __w, __w, __w, __w,
+ __w, __w, __w, __w, __w, __w, __w, __w,
+ __w, __w, __w, __w, __w, __w, __w, __w };
+}
+
+static __inline __m512i __DEFAULT_FN_ATTRS
 _mm512_set1_epi32(int __s)
 {
   return (__m512i)(__v16si){ __s, __s, __s, __s, __s, __s, __s, __s,


Index: test/CodeGen/avx512f-builtins.c
===
--- test/CodeGen/avx512f-builtins.c
+++ test/CodeGen/avx512f-builtins.c
@@ -328,6 +328,34 @@
   return _mm512_set1_pd(d);
 }
 
+__m512d test_mm512_set1_epi8(char d)
+{
+  // CHECK-LABEL: @test_mm512_set1_epi8
+  // CHECK: insertelement <64 x i8> {{.*}}, i32 0
+  // CHECK: insertelement <64 x i8> {{.*}}, i32 1
+  // CHECK: insertelement <64 x i8> {{.*}}, i32 2
+  // CHECK: insertelement <64 x i8> {{.*}}, i32 3
+  // CHECK: insertelement <64 x i8> {{.*}}, i32 4
+  // CHECK: insertelement <64 x i8> {{.*}}, i32 5
+  // CHECK: insertelement <64 x i8> {{.*}}, i32 6
+  // CHECK: insertelement <64 x i8> {{.*}}, i32 7
+  return _mm512_set1_epi8(d);
+}
+
+__m512d test_mm512_set1_epi16(short d)
+{
+  // CHECK-LABEL: @test_mm512_set1_epi16
+  // CHECK: insertelement <32 x i16> {{.*}}, i32 0
+  // CHECK: insertelement <32 x i16> {{.*}}, i32 1
+  // CHECK: insertelement <32 x i16> {{.*}}, i32 2
+  // CHECK: insertelement <32 x i16> {{.*}}, i32 3
+  // CHECK: insertelement <32 x i16> {{.*}}, i32 4
+  // CHECK: insertelement <32 x i16> {{.*}}, i32 5
+  // CHECK: insertelement <32 x i16> {{.*}}, i32 6
+  // CHECK: insertelement <32 x i16> {{.*}}, i32 7
+  return _mm512_set1_epi16(d);
+}
+
 __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
@@ -27,6 +27,8 @@
 #ifndef __AVX512FINTRIN_H
 #define __AVX512FINTRIN_H
 

[PATCH] D20563: Add load/store co-processor intrinsics

2016-05-24 Thread Ranjeet Singh via cfe-commits
rs created this revision.
rs added a reviewer: rengolin.
rs added a subscriber: cfe-commits.

Patch adds intrinsics for ldc, ldcl, ldc2, ldc2l, stc, stcl, stc2 and stc2l.

http://reviews.llvm.org/D20563

Files:
  include/clang/Basic/BuiltinsARM.def
  test/CodeGen/builtins-arm.c
  test/Sema/builtins-arm.c

Index: test/Sema/builtins-arm.c
===
--- test/Sema/builtins-arm.c
+++ test/Sema/builtins-arm.c
@@ -48,6 +48,30 @@
 }
 
 void test6(int a, int b, int c) {
+  __builtin_arm_ldc(a, 2, &a); // expected-error {{argument to '__builtin_arm_ldc' must be a constant integer}}
+  __builtin_arm_ldc(1, a, &a); // expected-error {{argument to '__builtin_arm_ldc' must be a constant integer}}
+
+  __builtin_arm_ldcl(a, 2, &a); // expected-error {{argument to '__builtin_arm_ldcl' must be a constant integer}}
+  __builtin_arm_ldcl(1, a, &a); // expected-error {{argument to '__builtin_arm_ldcl' must be a constant integer}}
+
+  __builtin_arm_ldc2(a, 2, &a); // expected-error {{argument to '__builtin_arm_ldc2' must be a constant integer}}
+  __builtin_arm_ldc2(1, a, &a); // expected-error {{argument to '__builtin_arm_ldc2' must be a constant integer}}
+
+  __builtin_arm_ldc2l(a, 2, &a); // expected-error {{argument to '__builtin_arm_ldc2l' must be a constant integer}}
+  __builtin_arm_ldc2l(1, a, &a); // expected-error {{argument to '__builtin_arm_ldc2l' must be a constant integer}}
+
+  __builtin_arm_stc(a, 2, &a); // expected-error {{argument to '__builtin_arm_stc' must be a constant integer}}
+  __builtin_arm_stc(1, a, &a); // expected-error {{argument to '__builtin_arm_stc' must be a constant integer}}
+
+  __builtin_arm_stcl(a, 2, &a); // expected-error {{argument to '__builtin_arm_stcl' must be a constant integer}}
+  __builtin_arm_stcl(1, a, &a); // expected-error {{argument to '__builtin_arm_stcl' must be a constant integer}}
+
+  __builtin_arm_stc2(a, 2, &a); // expected-error {{argument to '__builtin_arm_stc2' must be a constant integer}}
+  __builtin_arm_stc2(1, a, &a); // expected-error {{argument to '__builtin_arm_stc2' must be a constant integer}}
+
+  __builtin_arm_stc2l(a, 2, &a); // expected-error {{argument to '__builtin_arm_stc2l' must be a constant integer}}
+  __builtin_arm_stc2l(1, a, &a); // expected-error {{argument to '__builtin_arm_stc2l' must be a constant integer}}
+
   __builtin_arm_cdp(a, 2, 3, 4, 5, 6); // expected-error {{argument to '__builtin_arm_cdp' must be a constant integer}}
   __builtin_arm_cdp(1, a, 3, 4, 5, 6); // expected-error {{argument to '__builtin_arm_cdp' must be a constant integer}}
   __builtin_arm_cdp(1, 2, a, 4, 5, 6); // expected-error {{argument to '__builtin_arm_cdp' must be a constant integer}}
Index: test/CodeGen/builtins-arm.c
===
--- test/CodeGen/builtins-arm.c
+++ test/CodeGen/builtins-arm.c
@@ -84,6 +84,62 @@
 // CHECK: call {{.*}} @llvm.prefetch(i8* %{{.*}}, i32 1, i32 3, i32 0)
 }
 
+void ldc(const void *i) {
+  // CHECK: define void @ldc(i8* %i)
+  // CHECK: call void @llvm.arm.ldc(i32 1, i32 2, i8* %i)
+  // CHECK-NEXT: ret void
+  __builtin_arm_ldc(1, 2, i);
+}
+
+void ldcl(const void *i) {
+  // CHECK: define void @ldcl(i8* %i)
+  // CHECK: call void @llvm.arm.ldcl(i32 1, i32 2, i8* %i)
+  // CHECK-NEXT: ret void
+  __builtin_arm_ldcl(1, 2, i);
+}
+
+void ldc2(const void *i) {
+  // CHECK: define void @ldc2(i8* %i)
+  // CHECK: call void @llvm.arm.ldc2(i32 1, i32 2, i8* %i)
+  // CHECK-NEXT: ret void
+  __builtin_arm_ldc2(1, 2, i);
+}
+
+void ldc2l(const void *i) {
+  // CHECK: define void @ldc2l(i8* %i)
+  // CHECK: call void @llvm.arm.ldc2l(i32 1, i32 2, i8* %i)
+  // CHECK-NEXT: ret void
+  __builtin_arm_ldc2l(1, 2, i);
+}
+
+void stc(void *i) {
+  // CHECK: define void @stc(i8* %i)
+  // CHECK: call void @llvm.arm.stc(i32 1, i32 2, i8* %i)
+  // CHECK-NEXT: ret void
+  __builtin_arm_stc(1, 2, i);
+}
+
+void stcl(void *i) {
+  // CHECK: define void @stcl(i8* %i)
+  // CHECK: call void @llvm.arm.stcl(i32 1, i32 2, i8* %i)
+  // CHECK-NEXT: ret void
+  __builtin_arm_stcl(1, 2, i);
+}
+
+void stc2(void *i) {
+  // CHECK: define void @stc2(i8* %i)
+  // CHECK: call void @llvm.arm.stc2(i32 1, i32 2, i8* %i)
+  // CHECK-NEXT: ret void
+  __builtin_arm_stc2(1, 2, i);
+}
+
+void stc2l(void *i) {
+  // CHECK: define void @stc2l(i8* %i)
+  // CHECK: call void @llvm.arm.stc2l(i32 1, i32 2, i8* %i)
+  // CHECK-NEXT: ret void
+  __builtin_arm_stc2l(1, 2, i);
+}
+
 void cdp() {
   // CHECK: define void @cdp()
   // CHECK: call void @llvm.arm.cdp(i32 1, i32 2, i32 3, i32 4, i32 5, i32 6)
Index: include/clang/Basic/BuiltinsARM.def
===
--- include/clang/Basic/BuiltinsARM.def
+++ include/clang/Basic/BuiltinsARM.def
@@ -48,6 +48,16 @@
 BUILTIN(__builtin_arm_vcvtr_d, "fdi", "nc")
 
 // Coprocessor
+BUILTIN(__builtin_arm_ldc, "vUIiUIivC*", "")
+BUILTIN(__builtin_arm_ldcl, "vUIiUIivC*", ""

Re: [PATCH] D20563: Add load/store co-processor intrinsics

2016-05-24 Thread Ranjeet Singh via cfe-commits
rs added a comment.

LLVM part of the patch is here http://reviews.llvm.org/D20564


http://reviews.llvm.org/D20563



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


Re: [PATCH] D20249: [OpenCL] Hierarchical/dynamic parallelism - enqueue kernel in OpenCL 2.0

2016-05-24 Thread Anastasia Stulova via cfe-commits
Anastasia updated this revision to Diff 58219.
Anastasia added a comment.

- Improved with suggestions from Sam: reformatting, renaming!
- Removed unused  err_opencl_function_not_supported diagnostic.
- Rebased and changed to_addr builtins to allow the same identifier to be used 
in earlier than CL2.0 versions.


http://reviews.llvm.org/D20249

Files:
  include/clang/Basic/Builtins.def
  include/clang/Basic/Builtins.h
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Basic/Builtins.cpp
  lib/CodeGen/CGBuiltin.cpp
  lib/Sema/SemaChecking.cpp
  test/CodeGenOpenCL/cl20-device-side-enqueue.cl
  test/SemaOpenCL/cl20-device-side-enqueue.cl
  test/SemaOpenCL/clang-builtin-version.cl
  test/SemaOpenCL/to_addr_builtin.cl

Index: test/SemaOpenCL/to_addr_builtin.cl
===
--- test/SemaOpenCL/to_addr_builtin.cl
+++ test/SemaOpenCL/to_addr_builtin.cl
@@ -10,43 +10,44 @@
 
   glob = to_global(glob, loc);
 #if __OPENCL_C_VERSION__ < CL_VERSION_2_0
-  // expected-error@-2{{'to_global' requires OpenCL version 2.0 or above}}
+  // expected-warning@-2{{implicit declaration of function 'to_global' is invalid in C99}}
+  // expected-warning@-3{{incompatible integer to pointer conversion assigning to '__global int *' from 'int'}}
 #else
-  // expected-error@-4{{invalid number of arguments to function: 'to_global'}}
+  // expected-error@-5{{invalid number of arguments to function: 'to_global'}}
 #endif
 
   int x;
   glob = to_global(x);
 #if __OPENCL_C_VERSION__ < CL_VERSION_2_0
-  // expected-error@-2{{'to_global' requires OpenCL version 2.0 or above}}
+  // expected-warning@-2{{incompatible integer to pointer conversion assigning to '__global int *' from 'int'}}
 #else
   // expected-error@-4{{invalid argument x to function: 'to_global', expecting a generic pointer argument}}
 #endif
 
   glob = to_global(con);
 #if __OPENCL_C_VERSION__ < CL_VERSION_2_0
-  // expected-error@-2{{'to_global' requires OpenCL version 2.0 or above}}
+  // expected-warning@-2{{incompatible integer to pointer conversion assigning to '__global int *' from 'int'}}
 #else
   // expected-error@-4{{invalid argument con to function: 'to_global', expecting a generic pointer argument}}
 #endif
 
   glob = to_global(con_typedef);
 #if __OPENCL_C_VERSION__ < CL_VERSION_2_0
-  // expected-error@-2{{'to_global' requires OpenCL version 2.0 or above}}
+  // expected-warning@-2{{incompatible integer to pointer conversion assigning to '__global int *' from 'int'}}
 #else
   // expected-error@-4{{invalid argument con_typedef to function: 'to_global', expecting a generic pointer argument}}
 #endif
 
   loc = to_global(glob);
 #if __OPENCL_C_VERSION__ < CL_VERSION_2_0
-  // expected-error@-2{{'to_global' requires OpenCL version 2.0 or above}}
+  // expected-warning@-2{{incompatible integer to pointer conversion assigning to '__local int *' from 'int'}}
 #else
   // expected-error@-4{{assigning '__global int *' to '__local int *' changes address space of pointer}}
 #endif
 
   global char *glob_c = to_global(loc);
 #if __OPENCL_C_VERSION__ < CL_VERSION_2_0
-  // expected-error@-2{{'to_global' requires OpenCL version 2.0 or above}}
+  // expected-warning@-2{{incompatible integer to pointer conversion initializing '__global char *' with an expression of type 'int'}}
 #else
   // expected-warning@-4{{incompatible pointer types initializing '__global char *' with an expression of type '__global int *'}}
 #endif
Index: test/SemaOpenCL/clang-builtin-version.cl
===
--- /dev/null
+++ test/SemaOpenCL/clang-builtin-version.cl
@@ -0,0 +1,44 @@
+// RUN: %clang_cc1 %s -fblocks -verify -pedantic -fsyntax-only -ferror-limit 100
+
+// Confirm CL2.0 Clang builtins are not available in earlier versions
+
+kernel void dse_builtins() {
+  int tmp;
+  enqueue_kernel(tmp, tmp, tmp, ^(void) { // expected-warning{{implicit declaration of function 'enqueue_kernel' is invalid in C99}}
+return;
+  });
+  unsigned size = get_kernel_work_group_size(^(void) { // expected-warning{{implicit declaration of function 'get_kernel_work_group_size' is invalid in C99}}
+return;
+  });
+  size = get_kernel_preferred_work_group_size_multiple(^(void) { // expected-warning{{implicit declaration of function 'get_kernel_preferred_work_group_size_multiple' is invalid in C99}}
+return;
+  });
+}
+
+void pipe_builtins() {
+  int tmp;
+
+  read_pipe(tmp, tmp);  // expected-warning{{implicit declaration of function 'read_pipe' is invalid in C99}}
+  write_pipe(tmp, tmp); // expected-warning{{implicit declaration of function 'write_pipe' is invalid in C99}}
+
+  reserve_read_pipe(tmp, tmp);  // expected-warning{{implicit declaration of function 'reserve_read_pipe' is invalid in C99}}
+  reserve_write_pipe(tmp, tmp); // expected-warning{{implicit declaration of function 'reserve_write_pipe' is invalid in C99}}
+
+  work_group_reserve_read_pipe(tmp, tmp);  // expected-warning{{implicit

Re: [PATCH] D20249: [OpenCL] Hierarchical/dynamic parallelism - enqueue kernel in OpenCL 2.0

2016-05-24 Thread Anastasia Stulova via cfe-commits
Anastasia marked 6 inline comments as done.


Comment at: include/clang/Basic/DiagnosticSemaKinds.td:7820
@@ -7819,3 +7819,3 @@
   "kernel must have void return type">;
 def err_sampler_argument_required : Error<
   "sampler_t variable required - got %0">;

It's not used actually!


Comment at: lib/CodeGen/CGBuiltin.cpp:2150
@@ +2149,3 @@
+
+if (NumArgs == 4) {
+  // The most basic form of the call with parameters:

yaxunl wrote:
> Can we remove the non-vararg version and keep only the vararg version? The 
> vararg can be empty, so the non-vararg version is redundant.
We still need it for checking the parameters of blocks are 'local void*'.

Also I am not sure there is a way to combine Clang builtin and non-builtin 
prototype for the same function easily...


http://reviews.llvm.org/D20249



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


r270553 - [modules] Ask the canonical decl whether the constructor was defaulted.

2016-05-24 Thread Vassil Vassilev via cfe-commits
Author: vvassilev
Date: Tue May 24 07:10:36 2016
New Revision: 270553

URL: http://llvm.org/viewvc/llvm-project?rev=270553&view=rev
Log:
[modules] Ask the canonical decl whether the constructor was defaulted.

In case of template instantiations query the template instantiation pattern,
which had actually '=default'.

Fixes https://llvm.org/bugs/show_bug.cgi?id=27739

Patch reviewed by Richard Smith.

Added:
cfe/trunk/test/Modules/Inputs/PR27739/
cfe/trunk/test/Modules/Inputs/PR27739/DataInputHandler.h
cfe/trunk/test/Modules/Inputs/PR27739/Types.h
cfe/trunk/test/Modules/Inputs/PR27739/map
cfe/trunk/test/Modules/Inputs/PR27739/module.modulemap
cfe/trunk/test/Modules/pr27739.cpp
Modified:
cfe/trunk/lib/Sema/SemaDeclCXX.cpp

Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=270553&r1=270552&r2=270553&view=diff
==
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Tue May 24 07:10:36 2016
@@ -13098,14 +13098,14 @@ void Sema::SetDeclDefaulted(Decl *Dcl, S
 // the record is complete.
 const FunctionDecl *Primary = MD;
 if (const FunctionDecl *Pattern = MD->getTemplateInstantiationPattern())
-  // Find the uninstantiated declaration that actually had the '= default'
-  // on it.
-  Pattern->isDefined(Primary);
+  // Ask the template instantiation pattern that actually had the
+  // '= default' on it.
+  Primary = Pattern;
 
 // If the method was defaulted on its first declaration, we will have
 // already performed the checking in CheckCompletedCXXClass. Such a
 // declaration doesn't trigger an implicit definition.
-if (Primary == Primary->getCanonicalDecl())
+if (Primary->getCanonicalDecl()->isDefaulted())
   return;
 
 CheckExplicitlyDefaultedSpecialMember(MD);

Added: cfe/trunk/test/Modules/Inputs/PR27739/DataInputHandler.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/PR27739/DataInputHandler.h?rev=270553&view=auto
==
--- cfe/trunk/test/Modules/Inputs/PR27739/DataInputHandler.h (added)
+++ cfe/trunk/test/Modules/Inputs/PR27739/DataInputHandler.h Tue May 24 
07:10:36 2016
@@ -0,0 +1,19 @@
+template < typename > struct vector {};
+
+#include 
+#include "Types.h"
+
+struct TString {
+   TString (char *);
+};
+
+struct TreeInfo {};
+
+class DataInputHandler {
+   void AddTree ();
+   void SignalTreeInfo () {
+  fInputTrees[(char*)""];
+   }
+   map  >fInputTrees;
+   map  fExplicitTrainTest;
+};

Added: cfe/trunk/test/Modules/Inputs/PR27739/Types.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/PR27739/Types.h?rev=270553&view=auto
==
--- cfe/trunk/test/Modules/Inputs/PR27739/Types.h (added)
+++ cfe/trunk/test/Modules/Inputs/PR27739/Types.h Tue May 24 07:10:36 2016
@@ -0,0 +1 @@
+#include 

Added: cfe/trunk/test/Modules/Inputs/PR27739/map
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/PR27739/map?rev=270553&view=auto
==
--- cfe/trunk/test/Modules/Inputs/PR27739/map (added)
+++ cfe/trunk/test/Modules/Inputs/PR27739/map Tue May 24 07:10:36 2016
@@ -0,0 +1,20 @@
+#ifndef _GLIBCXX_MAP
+#define _GLIBCXX_MAP
+struct basic_string {
+  basic_string(char *);
+} typedef string;
+
+template  class D;
+template  struct D {
+  _Elements _M_;
+  D(D &) = default;
+};
+
+template  D<_Elements &&> forward_as_tuple(_Elements);
+
+template  struct map {
+  _Tp operator[](_Key p1) {
+auto b = &forward_as_tuple(p1);
+  }
+};
+#endif

Added: cfe/trunk/test/Modules/Inputs/PR27739/module.modulemap
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/PR27739/module.modulemap?rev=270553&view=auto
==
--- cfe/trunk/test/Modules/Inputs/PR27739/module.modulemap (added)
+++ cfe/trunk/test/Modules/Inputs/PR27739/module.modulemap Tue May 24 07:10:36 
2016
@@ -0,0 +1,2 @@
+module "DataInputHandler.h" { header "DataInputHandler.h" export * }
+module "Types.h" { header "Types.h" export *}

Added: cfe/trunk/test/Modules/pr27739.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/pr27739.cpp?rev=270553&view=auto
==
--- cfe/trunk/test/Modules/pr27739.cpp (added)
+++ cfe/trunk/test/Modules/pr27739.cpp Tue May 24 07:10:36 2016
@@ -0,0 +1,12 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -std=c++11 -internal-externc-isystem %S/Inputs/PR27739 
-verify %s
+// RUN: %clang_cc1 -std=c++11 -fmodules 
-fmodule-map-file=%S/Inputs/PR27739/module.modulemap -fmodules-cache-path=%t 
-internal-externc-isy

[PATCH] D20566: [find-all-symbols] Added hardcode header mapping from header postfix to header name for STL symbols.

2016-05-24 Thread Eric Liu via cfe-commits
ioeric created this revision.
ioeric added reviewers: bkramer, klimek.
ioeric added subscribers: hokein, cfe-commits.

[find-all-symbols] Added hardcode header mapping from header postfix to header 
name for STL symbols.

http://reviews.llvm.org/D20566

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/FindAllSymbolsAction.cpp
  include-fixer/find-all-symbols/FindAllSymbolsAction.h
  include-fixer/find-all-symbols/HeaderMapCollector.cpp
  include-fixer/find-all-symbols/HeaderMapCollector.h
  include-fixer/find-all-symbols/tool/CMakeLists.txt
  include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp
  include-fixer/find-all-symbols/tool/STLPostfixHeaderMap.cpp
  include-fixer/find-all-symbols/tool/STLPostfixHeaderMap.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
@@ -7,10 +7,8 @@
 //
 //===--===//
 
-#include "FindAllMacros.h"
-#include "FindAllSymbols.h"
+#include "FindAllSymbolsAction.h"
 #include "HeaderMapCollector.h"
-#include "PragmaCommentHandler.h"
 #include "SymbolInfo.h"
 #include "SymbolReporter.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
@@ -54,44 +52,6 @@
   std::vector Symbols;
 };
 
-class TestFindAllSymbolsAction : public clang::ASTFrontendAction {
-public:
-  TestFindAllSymbolsAction(SymbolReporter *Reporter)
-  : Reporter(Reporter), MatchFinder(), Collector(), Handler(&Collector),
-Matcher(Reporter, &Collector) {
-Matcher.registerMatchers(&MatchFinder);
-  }
-
-  std::unique_ptr
-  CreateASTConsumer(clang::CompilerInstance &Compiler,
-StringRef InFile) override {
-Compiler.getPreprocessor().addCommentHandler(&Handler);
-Compiler.getPreprocessor().addPPCallbacks(llvm::make_unique(
-Reporter, &Compiler.getSourceManager(), &Collector));
-return MatchFinder.newASTConsumer();
-  }
-
-private:
-  SymbolReporter *const Reporter;
-  ast_matchers::MatchFinder MatchFinder;
-  HeaderMapCollector Collector;
-  PragmaCommentHandler Handler;
-  FindAllSymbols Matcher;
-};
-
-class TestFindAllSymbolsActionFactory
-: public clang::tooling::FrontendActionFactory {
-public:
-  TestFindAllSymbolsActionFactory(TestSymbolReporter *Reporter)
-  : Reporter(Reporter) {}
-  clang::FrontendAction *create() override {
-return new TestFindAllSymbolsAction(Reporter);
-  }
-
-private:
-  TestSymbolReporter *const Reporter;
-};
-
 class FindAllSymbolsTest : public ::testing::Test {
 public:
   bool hasSymbol(const SymbolInfo &Symbol) {
@@ -106,8 +66,20 @@
 
 std::string FileName = "symbol.cc";
 
+const std::string InternalHeader = "internal/internal.h";
+const std::string TopHeader = "";
+HeaderMapCollector::HeaderMap PostfixMap = {
+{InternalHeader, TopHeader},
+};
+
+std::string InternalCode = "class Internal {};";
+SymbolInfo InternalSymbol("Internal", SymbolInfo::SymbolKind::Class,
+  TopHeader, 1, {});
+InMemoryFileSystem->addFile(InternalHeader, 0,
+llvm::MemoryBuffer::getMemBuffer(InternalCode));
+
 std::unique_ptr Factory(
-new TestFindAllSymbolsActionFactory(&Reporter));
+new FindAllSymbolsActionFactory(&Reporter, &PostfixMap));
 
 tooling::ToolInvocation Invocation(
 {std::string("find_all_symbols"), std::string("-fsyntax-only"),
@@ -118,10 +90,13 @@
 InMemoryFileSystem->addFile(HeaderName, 0,
 llvm::MemoryBuffer::getMemBuffer(Code));
 
-std::string Content = "#include\"" + std::string(HeaderName) + "\"";
+std::string Content = "#include\"" + std::string(HeaderName) +
+  "\"\n"
+  "#include \"internal/internal.h\"";
 InMemoryFileSystem->addFile(FileName, 0,
 llvm::MemoryBuffer::getMemBuffer(Content));
 Invocation.run();
+EXPECT_TRUE(hasSymbol(InternalSymbol));
 return true;
   }
 
Index: include-fixer/find-all-symbols/tool/STLPostfixHeaderMap.h
===
--- /dev/null
+++ include-fixer/find-all-symbols/tool/STLPostfixHeaderMap.h
@@ -0,0 +1,23 @@
+//===-- HeaderMapCoolector.h - hardcoded postfix header map -*- 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_T

Re: r270373 - [driver][mips] Support new versions of MIPS CodeScape toolchains

2016-05-24 Thread Simon Atanasyan via cfe-commits
Hi,

On Tue, May 24, 2016 at 12:37 PM, Ismail Donmez  wrote:
>
> On Sun, May 22, 2016 at 9:18 PM, Simon Atanasyan via cfe-commits
>  wrote:
>> Author: atanasyan
>> Date: Sun May 22 13:18:07 2016
>> New Revision: 270373
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=270373&view=rev
>> Log:
>> [driver][mips] Support new versions of MIPS CodeScape toolchains
>
> Two tests fail for me on Linux, please the attached build log.

1. Revision 270373 contains a bug fixed at r270380. Do you use the
latest Clang source code?

2. If so could you please send an output of the following command?

/home/abuild/rpmbuild/BUILD/llvm/stage2/bin/clang -no-canonical-prefixes \
  /home/abuild/rpmbuild/BUILD/llvm/tools/clang/test/Driver/mips-img-v2.cpp \
  -### -o 
/home/abuild/rpmbuild/BUILD/llvm/stage2/tools/clang/test/Driver/Output/mips-img-v2.cpp.tmp.o
\
  --target=mips-img-linux-gnu \
  
--gcc-toolchain=/home/abuild/rpmbuild/BUILD/llvm/tools/clang/test/Driver/Inputs/mips_img_v2_tree
\
  -EB -mips32r6 -mhard-float -mabi=32

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


Re: [PATCH] D20566: [find-all-symbols] Added hardcode header mapping from header postfix to header name for STL symbols.

2016-05-24 Thread Eric Liu via cfe-commits
ioeric updated this revision to Diff 58228.
ioeric added a comment.

- fixed nits.


http://reviews.llvm.org/D20566

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/FindAllSymbolsAction.cpp
  include-fixer/find-all-symbols/FindAllSymbolsAction.h
  include-fixer/find-all-symbols/HeaderMapCollector.cpp
  include-fixer/find-all-symbols/HeaderMapCollector.h
  include-fixer/find-all-symbols/tool/CMakeLists.txt
  include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp
  include-fixer/find-all-symbols/tool/STLPostfixHeaderMap.cpp
  include-fixer/find-all-symbols/tool/STLPostfixHeaderMap.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
@@ -7,10 +7,8 @@
 //
 //===--===//
 
-#include "FindAllMacros.h"
-#include "FindAllSymbols.h"
+#include "FindAllSymbolsAction.h"
 #include "HeaderMapCollector.h"
-#include "PragmaCommentHandler.h"
 #include "SymbolInfo.h"
 #include "SymbolReporter.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
@@ -54,44 +52,6 @@
   std::vector Symbols;
 };
 
-class TestFindAllSymbolsAction : public clang::ASTFrontendAction {
-public:
-  TestFindAllSymbolsAction(SymbolReporter *Reporter)
-  : Reporter(Reporter), MatchFinder(), Collector(), Handler(&Collector),
-Matcher(Reporter, &Collector) {
-Matcher.registerMatchers(&MatchFinder);
-  }
-
-  std::unique_ptr
-  CreateASTConsumer(clang::CompilerInstance &Compiler,
-StringRef InFile) override {
-Compiler.getPreprocessor().addCommentHandler(&Handler);
-Compiler.getPreprocessor().addPPCallbacks(llvm::make_unique(
-Reporter, &Compiler.getSourceManager(), &Collector));
-return MatchFinder.newASTConsumer();
-  }
-
-private:
-  SymbolReporter *const Reporter;
-  ast_matchers::MatchFinder MatchFinder;
-  HeaderMapCollector Collector;
-  PragmaCommentHandler Handler;
-  FindAllSymbols Matcher;
-};
-
-class TestFindAllSymbolsActionFactory
-: public clang::tooling::FrontendActionFactory {
-public:
-  TestFindAllSymbolsActionFactory(TestSymbolReporter *Reporter)
-  : Reporter(Reporter) {}
-  clang::FrontendAction *create() override {
-return new TestFindAllSymbolsAction(Reporter);
-  }
-
-private:
-  TestSymbolReporter *const Reporter;
-};
-
 class FindAllSymbolsTest : public ::testing::Test {
 public:
   bool hasSymbol(const SymbolInfo &Symbol) {
@@ -106,8 +66,20 @@
 
 std::string FileName = "symbol.cc";
 
+const std::string InternalHeader = "internal/internal.h";
+const std::string TopHeader = "";
+HeaderMapCollector::HeaderMap PostfixMap = {
+{"internal.h", TopHeader},
+};
+
+std::string InternalCode = "class Internal {};";
+SymbolInfo InternalSymbol("Internal", SymbolInfo::SymbolKind::Class,
+  TopHeader, 1, {});
+InMemoryFileSystem->addFile(InternalHeader, 0,
+llvm::MemoryBuffer::getMemBuffer(InternalCode));
+
 std::unique_ptr Factory(
-new TestFindAllSymbolsActionFactory(&Reporter));
+new FindAllSymbolsActionFactory(&Reporter, &PostfixMap));
 
 tooling::ToolInvocation Invocation(
 {std::string("find_all_symbols"), std::string("-fsyntax-only"),
@@ -118,10 +90,13 @@
 InMemoryFileSystem->addFile(HeaderName, 0,
 llvm::MemoryBuffer::getMemBuffer(Code));
 
-std::string Content = "#include\"" + std::string(HeaderName) + "\"";
+std::string Content = "#include\"" + std::string(HeaderName) +
+  "\"\n"
+  "#include \"internal/internal.h\"";
 InMemoryFileSystem->addFile(FileName, 0,
 llvm::MemoryBuffer::getMemBuffer(Content));
 Invocation.run();
+EXPECT_TRUE(hasSymbol(InternalSymbol));
 return true;
   }
 
Index: include-fixer/find-all-symbols/tool/STLPostfixHeaderMap.h
===
--- /dev/null
+++ include-fixer/find-all-symbols/tool/STLPostfixHeaderMap.h
@@ -0,0 +1,23 @@
+//===-- STLPostfixHeaderMap.h - hardcoded header map for STL *- 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_TOOL_STL_POSTFIX_HEADER_MAP_H
+#define LLVM_CLANG_TOOLS_EXTRA_FIND_ALL_SYMBOLS_TOOL_STL_POSTFIX_HEADER_MAP_H
+

Re: [PATCH] D20566: [find-all-symbols] Added hardcode header mapping from header postfix to header name for STL symbols.

2016-05-24 Thread Eric Liu via cfe-commits
ioeric added a comment.

This patch is now ready for review.

Sorry that I also refactored `FindAllSymbolsAction` into a separate file in 
this patch...should've done that in a separate patch at the very beginning.


http://reviews.llvm.org/D20566



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


Re: [PATCH] D18035: [GCC] PR23529 Mangler part of attrbute abi_tag support

2016-05-24 Thread Renato Golin via cfe-commits
rengolin added a subscriber: rengolin.
rengolin added a comment.

Ping?

Can we get some traction on this one, please? The 3.8.1 deadline is tomorrow 
and I'd really like to see these two patches (plus the related fixes) in it, or 
some LTS Linux distributions will live without them, and thus with completely 
broken copies of LLVM.

FWIW, multiple people seem to have tested it and reported good results. Also, 
Arch Linux has had the patch for several months, without a hiccup, probably 
others, too.

I think we can get this one in as it is, and maybe apply fixes later if 
relevant.

cheers,
--renato


http://reviews.llvm.org/D18035



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


Re: [PATCH] D20010: [clang-tidy] UnnecessaryCopyInitialization - Extend to trigger on non-const "this" object argument if it is not modified

2016-05-24 Thread Matt Kulukundis via cfe-commits
fowles added a comment.

LGTM, but I will wait for people who know this stuff better to sign off


http://reviews.llvm.org/D20010



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


Re: [PATCH] D20089: Adding a TargetParser for AArch64

2016-05-24 Thread Renato Golin via cfe-commits
rengolin added a comment.

Hi Jojo,

I've just mapped these changes to the current ARM implementation and they look 
correct. I only have two minor comments and I'm happy with it, but I'll let 
Bradley have the final review.

Bradley,

If history is of any help, Jojo will have to change a few things once she makes 
Clang and others use it. It shouldn't be a huge deal, but I believe there will 
be some teething issues. Once that's done, our next step would be to make into 
a class.

From what I see, there are two steps to the merge:

1. Create an interface, from which both ARM and AArch64 derive, and remove all 
obviously redundant methods (direct calls to ARM). An alternative would be to 
have AArch64 extend ARM, but I think that would be unfair to MIPS, as they 
could profit from this, too. Since we have no proof of that, I'd be ok with the 
second option, if people think it isn't worth being generic.

2. See how much of the tables can be the same, but having different contents, 
in a way that all the other non obvious redundancies can be resolved (all parse 
methods with tables). From the looks of it, almost everything can be merged, 
and most methods can be reduced to the base class.

IMO, each should be done separately, as they're both big changes. The first 
change will also come with a huge list of changed files in both Clang and LLVM, 
so we need to keep it as simple as possible.

cheers,
--renato



Comment at: include/llvm/Support/TargetParser.h:173
@@ +172,3 @@
+StringRef getArchName(unsigned ArchKind);
+bool getArchFeatures(unsigned ArchKind, std::vector &Features);
+unsigned getArchAttr(unsigned ArchKind);

Nitpick, move this declaration with the others that use &Features.


Comment at: include/llvm/Support/TargetParser.h:184
@@ +183,3 @@
+unsigned  getDefaultExtensions(StringRef CPU, unsigned ArchKind);
+StringRef getDefaultCPU(StringRef Arch, std::vector &Features);
+

You don't need the &Features any more. Same of the implementation in the cpp 
file.


Repository:
  rL LLVM

http://reviews.llvm.org/D20089



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


Re: [PATCH] D18953: [ms][dll] #26935 Defining a dllimport function should cause it to be exported

2016-05-24 Thread Andrew V. Tischenko via cfe-commits
avt77 updated this revision to Diff 58233.
avt77 added a comment.

I built the project from scratch and found an issue in Clang build system. 
There was a problem with undefined DiagGroup in DiagnosticSemaKinds.td: the 
error message was generated but all executables were created that's why I was 
not aware about this issue (I missed the message at the time of  my first build 
and all next re-builds worked without any problems). I created a new warning 
group (MicrosoftInconsistentDllImport) in DiagnosticGroups.td and made the 
corresponding changes in DiagnosticSemaKinds.td (2 lines).

Sorry for inconvenience but review the above two files and confirm your LGTM if 
it is.

And I suppose I should create a new record in Bugzilla, right?


http://reviews.llvm.org/D18953

Files:
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaDecl.cpp
  test/CodeGen/dllimport.c
  test/CodeGenCXX/dllimport-members.cpp
  test/CodeGenCXX/dllimport.cpp
  test/Sema/dllimport.c
  test/SemaCXX/dllimport.cpp

Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -5523,9 +5523,13 @@
 
 static void checkDLLAttributeRedeclaration(Sema &S, NamedDecl *OldDecl,
NamedDecl *NewDecl,
-   bool IsSpecialization) {
-  if (TemplateDecl *OldTD = dyn_cast(OldDecl))
+   bool IsSpecialization,
+   bool IsDefinition) {
+  if (TemplateDecl *OldTD = dyn_cast(OldDecl)) {
 OldDecl = OldTD->getTemplatedDecl();
+if (!IsSpecialization)
+  IsDefinition = false;
+  }
   if (TemplateDecl *NewTD = dyn_cast(NewDecl))
 NewDecl = NewTD->getTemplatedDecl();
 
@@ -5581,30 +5585,43 @@
 
   // A redeclaration is not allowed to drop a dllimport attribute, the only
   // exceptions being inline function definitions, local extern declarations,
-  // and qualified friend declarations.
-  // NB: MSVC converts such a declaration to dllexport.
+  // qualified friend declarations or special MSVC extension: in the last case,
+  // the declaration is treated as if it were marked dllexport.
   bool IsInline = false, IsStaticDataMember = false, IsQualifiedFriend = false;
-  if (const auto *VD = dyn_cast(NewDecl))
+  bool IsMicrosoft = S.Context.getTargetInfo().getCXXABI().isMicrosoft();
+  if (const auto *VD = dyn_cast(NewDecl)) {
 // Ignore static data because out-of-line definitions are diagnosed
 // separately.
 IsStaticDataMember = VD->isStaticDataMember();
-  else if (const auto *FD = dyn_cast(NewDecl)) {
+IsDefinition = VD->isThisDeclarationADefinition(S.Context) !=
+   VarDecl::DeclarationOnly;
+  } else if (const auto *FD = dyn_cast(NewDecl)) {
 IsInline = FD->isInlined();
 IsQualifiedFriend = FD->getQualifier() &&
 FD->getFriendObjectKind() == Decl::FOK_Declared;
   }
 
   if (OldImportAttr && !HasNewAttr && !IsInline && !IsStaticDataMember &&
   !NewDecl->isLocalExternDecl() && !IsQualifiedFriend) {
-S.Diag(NewDecl->getLocation(),
-   diag::warn_redeclaration_without_attribute_prev_attribute_ignored)
-  << NewDecl << OldImportAttr;
-S.Diag(OldDecl->getLocation(), diag::note_previous_declaration);
-S.Diag(OldImportAttr->getLocation(), diag::note_previous_attribute);
-OldDecl->dropAttr();
-NewDecl->dropAttr();
-  } else if (IsInline && OldImportAttr &&
- !S.Context.getTargetInfo().getCXXABI().isMicrosoft()) {
+if (IsMicrosoft && IsDefinition) {
+  S.Diag(NewDecl->getLocation(),
+ diag::warn_redeclaration_without_import_attribute)
+  << NewDecl;
+  S.Diag(OldDecl->getLocation(), diag::note_previous_declaration);
+  NewDecl->dropAttr();
+  NewDecl->addAttr(::new (S.Context) DLLExportAttr(
+  NewImportAttr->getRange(), S.Context,
+  NewImportAttr->getSpellingListIndex()));
+} else {
+  S.Diag(NewDecl->getLocation(),
+ diag::warn_redeclaration_without_attribute_prev_attribute_ignored)
+  << NewDecl << OldImportAttr;
+  S.Diag(OldDecl->getLocation(), diag::note_previous_declaration);
+  S.Diag(OldImportAttr->getLocation(), diag::note_previous_attribute);
+  OldDecl->dropAttr();
+  NewDecl->dropAttr();
+}
+  } else if (IsInline && OldImportAttr && !IsMicrosoft) {
 // In MinGW, seeing a function declared inline drops the dllimport attribute.
 OldDecl->dropAttr();
 NewDecl->dropAttr();
@@ -6388,7 +6405,7 @@
   if (D.isRedeclaration() && !Previous.empty()) {
 checkDLLAttributeRedeclaration(
 *this, dyn_cast(Previous.getRepresentativeDecl()), NewVD,
-IsExplicitSpecialization);
+IsExplicitSpecialization, D.isFunctionDefinition());
   }
 
   if (NewTemplate) {
@@ -8419,7 +8436,8 @@
   if (D.isRedeclaration()

Re: [PATCH] D20566: [find-all-symbols] Added hardcode header mapping from header postfix to header name for STL symbols.

2016-05-24 Thread Benjamin Kramer via cfe-commits
bkramer added inline comments.


Comment at: include-fixer/find-all-symbols/tool/STLPostfixHeaderMap.cpp:15
@@ +14,3 @@
+
+const HeaderMapCollector::HeaderMap STLPostfixHeaderMap = {
+{"include/__stddef_max_align_t.h", ""},

I wonder if it's worth lazy-initializing this map with ManagedStatic or 
something, having a global with ctor&dtor isn't pretty.


Comment at: include-fixer/find-all-symbols/tool/STLPostfixHeaderMap.cpp:20
@@ +19,3 @@
+{"include/adxintrin.h", ""},
+{"include/ammintrin.h", ""},
+{"include/avx2intrin.h", ""},

random


Comment at: include-fixer/find-all-symbols/tool/STLPostfixHeaderMap.cpp:82
@@ +81,3 @@
+{"include/asm-generic/errno.h", ""},
+{"/usr/include/assert.h", ""},
+{"algorithm", ""},

Why is assert.h special?


http://reviews.llvm.org/D20566



___
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-05-24 Thread Anastasia Stulova via cfe-commits
Anastasia added inline comments.


Comment at: test/SemaOpenCL/extension-version.cl:11
@@ +10,3 @@
+#endif
+#pragma OPENCL EXTENSION cl_clang_storage_class_specifiers: enable
+

Could you use standard diagnostic check please:
  expected-warning{{unknown OpenCL extension ...

Similarly to SemaOpenCL/extensions.cl


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] D20249: [OpenCL] Hierarchical/dynamic parallelism - enqueue kernel in OpenCL 2.0

2016-05-24 Thread Alexey Bader via cfe-commits
bader added inline comments.


Comment at: lib/Sema/SemaChecking.cpp:81
@@ +80,3 @@
+static bool checkBlockArgs(Sema &S, Expr *BlockArg) {
+  const BlockPointerType *BPT = cast(BlockArg->getType());
+  ArrayRef Params =

There should be some check before cast.
Here is the code snippet that will crash the compiler:

  extern queue_t get_default_queue();
  extern int get_global_id(int);
  extern ndrange_t get_ndrange();
  typedef void (^MyBlock)(local void*, local int*);

  const MyBlock myBlock = (MyBlock)^(local int *p1, local int *p2) {
int id = get_global_id(0);
p1[id] += p2[id];
  };

  void kernel f2(global int* a, global int* b) {
enqueue_kernel(get_default_queue(), 0, get_ndrange(), myBlock, 2U, 1U);
  }



Comment at: test/CodeGenOpenCL/cl20-device-side-enqueue.cl:19
@@ +18,3 @@
+  // CHECK: [[NDR:%[0-9]+]] = load %opencl.ndrange_t*, %opencl.ndrange_t** 
%ndrange
+  // CHECK: [[BL:%[0-9]+]] = bitcast <{ i8*, i32, i32, i8*, 
%struct.__block_descriptor*, i32 addrspace(1)*, i32 addrspace(1)*, i32 }>* 
%block to void ()*
+  // CHECK: [[BL_I8:%[0-9]+]] = bitcast void ()* [[BL]] to i8*

This check is failing on my machine:

  test\CodeGenOpenCL\cl20-device-side-enqueue.cl:19:12: error: expected string 
not found in input
  // CHECK: [[BL:%[0-9]+]] = bitcast <{ i8*, i32, i32, i8*, 
%struct.__block_descriptor*, i32 addrspace(1)*, i32 addrspace(1)*, i32 }>* 
%block to void ()*
  :47:60: note: scanning from here
  %3 = load %opencl.ndrange_t*, %opencl.ndrange_t** %ndrange, align 4
  :67:2: note: possible intended match here
  %7 = bitcast <{ i8*, i32, i32, i8*, %struct.__block_descriptor*, i32 
addrspace(1)*, i32, i32 addrspace(1)* }>* %block to void ()*

It looks like the order of captured arguments is different from expected? Is 
the order specified or test shouldn't check it?


http://reviews.llvm.org/D20249



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


Re: [PATCH] D20566: [find-all-symbols] Added hardcode header mapping from header postfix to header name for STL symbols.

2016-05-24 Thread Eric Liu via cfe-commits
ioeric updated this revision to Diff 58235.
ioeric marked 3 inline comments as done.
ioeric added a comment.

- Fixed postfix header mapping.


http://reviews.llvm.org/D20566

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/FindAllSymbolsAction.cpp
  include-fixer/find-all-symbols/FindAllSymbolsAction.h
  include-fixer/find-all-symbols/HeaderMapCollector.cpp
  include-fixer/find-all-symbols/HeaderMapCollector.h
  include-fixer/find-all-symbols/tool/CMakeLists.txt
  include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp
  include-fixer/find-all-symbols/tool/STLPostfixHeaderMap.cpp
  include-fixer/find-all-symbols/tool/STLPostfixHeaderMap.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
@@ -7,10 +7,8 @@
 //
 //===--===//
 
-#include "FindAllMacros.h"
-#include "FindAllSymbols.h"
+#include "FindAllSymbolsAction.h"
 #include "HeaderMapCollector.h"
-#include "PragmaCommentHandler.h"
 #include "SymbolInfo.h"
 #include "SymbolReporter.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
@@ -54,44 +52,6 @@
   std::vector Symbols;
 };
 
-class TestFindAllSymbolsAction : public clang::ASTFrontendAction {
-public:
-  TestFindAllSymbolsAction(SymbolReporter *Reporter)
-  : Reporter(Reporter), MatchFinder(), Collector(), Handler(&Collector),
-Matcher(Reporter, &Collector) {
-Matcher.registerMatchers(&MatchFinder);
-  }
-
-  std::unique_ptr
-  CreateASTConsumer(clang::CompilerInstance &Compiler,
-StringRef InFile) override {
-Compiler.getPreprocessor().addCommentHandler(&Handler);
-Compiler.getPreprocessor().addPPCallbacks(llvm::make_unique(
-Reporter, &Compiler.getSourceManager(), &Collector));
-return MatchFinder.newASTConsumer();
-  }
-
-private:
-  SymbolReporter *const Reporter;
-  ast_matchers::MatchFinder MatchFinder;
-  HeaderMapCollector Collector;
-  PragmaCommentHandler Handler;
-  FindAllSymbols Matcher;
-};
-
-class TestFindAllSymbolsActionFactory
-: public clang::tooling::FrontendActionFactory {
-public:
-  TestFindAllSymbolsActionFactory(TestSymbolReporter *Reporter)
-  : Reporter(Reporter) {}
-  clang::FrontendAction *create() override {
-return new TestFindAllSymbolsAction(Reporter);
-  }
-
-private:
-  TestSymbolReporter *const Reporter;
-};
-
 class FindAllSymbolsTest : public ::testing::Test {
 public:
   bool hasSymbol(const SymbolInfo &Symbol) {
@@ -106,8 +66,20 @@
 
 std::string FileName = "symbol.cc";
 
+const std::string InternalHeader = "internal/internal.h";
+const std::string TopHeader = "";
+HeaderMapCollector::HeaderMap PostfixMap = {
+{"internal.h", TopHeader},
+};
+
+std::string InternalCode = "class Internal {};";
+SymbolInfo InternalSymbol("Internal", SymbolInfo::SymbolKind::Class,
+  TopHeader, 1, {});
+InMemoryFileSystem->addFile(InternalHeader, 0,
+llvm::MemoryBuffer::getMemBuffer(InternalCode));
+
 std::unique_ptr Factory(
-new TestFindAllSymbolsActionFactory(&Reporter));
+new FindAllSymbolsActionFactory(&Reporter, &PostfixMap));
 
 tooling::ToolInvocation Invocation(
 {std::string("find_all_symbols"), std::string("-fsyntax-only"),
@@ -118,10 +90,13 @@
 InMemoryFileSystem->addFile(HeaderName, 0,
 llvm::MemoryBuffer::getMemBuffer(Code));
 
-std::string Content = "#include\"" + std::string(HeaderName) + "\"";
+std::string Content = "#include\"" + std::string(HeaderName) +
+  "\"\n"
+  "#include \"internal/internal.h\"";
 InMemoryFileSystem->addFile(FileName, 0,
 llvm::MemoryBuffer::getMemBuffer(Content));
 Invocation.run();
+EXPECT_TRUE(hasSymbol(InternalSymbol));
 return true;
   }
 
Index: include-fixer/find-all-symbols/tool/STLPostfixHeaderMap.h
===
--- /dev/null
+++ include-fixer/find-all-symbols/tool/STLPostfixHeaderMap.h
@@ -0,0 +1,23 @@
+//===-- STLPostfixHeaderMap.h - hardcoded header map for STL *- 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_TOOL_STL_POSTFIX_HEADER_MAP_H
+#define LLVM_CLANG_TO

[clang-tools-extra] r270565 - [clang-tidy] modernize-pass-by-value bugfix

2016-05-24 Thread Mads Ravn via cfe-commits
Author: madsravn
Date: Tue May 24 10:00:16 2016
New Revision: 270565

URL: http://llvm.org/viewvc/llvm-project?rev=270565&view=rev
Log:
[clang-tidy] modernize-pass-by-value bugfix

Modified the clang-tidy PassByValue check. It now stops adding std::move to 
type which is trivially copyable because that caused the clang-tidy 
MoveConstArg to complain and revert, thus creating a cycle.

I have also added a lit-style test to verify the bugfix.

This is the bug on bugzilla: https://llvm.org/bugs/show_bug.cgi?id=27731

This is the code review on phabricator: http://reviews.llvm.org/D20365

Modified:
clang-tools-extra/trunk/clang-tidy/modernize/PassByValueCheck.cpp
clang-tools-extra/trunk/test/clang-tidy/modernize-pass-by-value.cpp

Modified: clang-tools-extra/trunk/clang-tidy/modernize/PassByValueCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/PassByValueCheck.cpp?rev=270565&r1=270564&r2=270565&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/PassByValueCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/PassByValueCheck.cpp Tue May 
24 10:00:16 2016
@@ -181,6 +181,11 @@ void PassByValueCheck::check(const Match
   if (!paramReferredExactlyOnce(Ctor, ParamDecl))
 return;
 
+  // If the parameter is trivial to copy, don't move it. Moving a trivivally
+  // copyable type will cause a problem with misc-move-const-arg
+  if (ParamDecl->getType().isTriviallyCopyableType(*Result.Context)) 
+return;
+
   auto Diag = diag(ParamDecl->getLocStart(), "pass by value and use 
std::move");
 
   // Iterate over all declarations of the constructor.

Modified: clang-tools-extra/trunk/test/clang-tidy/modernize-pass-by-value.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-pass-by-value.cpp?rev=270565&r1=270564&r2=270565&view=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/modernize-pass-by-value.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-pass-by-value.cpp Tue May 
24 10:00:16 2016
@@ -1,3 +1,6 @@
+#include 
+#include 
+
 // RUN: %check_clang_tidy %s modernize-pass-by-value %t -- -- -std=c++11 
-fno-delayed-template-parsing
 
 // CHECK-FIXES: #include 
@@ -17,7 +20,7 @@ struct NotMovable {
 }
 
 struct A {
-  A(const Movable &M) : M(M) {}
+  A(Movable M) : M(std::move(M)) {}
   // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: pass by value and use std::move 
[modernize-pass-by-value]
   // CHECK-FIXES: A(Movable M) : M(std::move(M)) {}
   Movable M;
@@ -46,17 +49,17 @@ struct C {
 
 // Test that both declaration and definition are updated.
 struct D {
-  D(const Movable &M);
+  D(Movable M);
   // CHECK-FIXES: D(Movable M);
   Movable M;
 };
-D::D(const Movable &M) : M(M) {}
+D::D(Movable M) : M(std::move(M)) {}
 // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: pass by value and use std::move
 // CHECK-FIXES: D::D(Movable M) : M(std::move(M)) {}
 
 // Test with default parameter.
 struct E {
-  E(const Movable &M = Movable()) : M(M) {}
+  E(Movable M = Movable()) : M(std::move(M)) {}
   // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: pass by value and use std::move
   // CHECK-FIXES: E(Movable M = Movable()) : M(std::move(M)) {}
   Movable M;
@@ -71,11 +74,11 @@ struct F {
 
 // Test unnamed parameter in declaration.
 struct G {
-  G(const Movable &);
+  G(Movable );
   // CHECK-FIXES: G(Movable );
   Movable M;
 };
-G::G(const Movable &M) : M(M) {}
+G::G(Movable M) : M(std::move(M)) {}
 // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: pass by value and use std::move
 // CHECK-FIXES: G::G(Movable M) : M(std::move(M)) {}
 
@@ -84,12 +87,12 @@ namespace ns_H {
 typedef ::Movable HMovable;
 }
 struct H {
-  H(const ns_H::HMovable &M);
+  H(ns_H::HMovable M);
   // CHECK-FIXES: H(ns_H::HMovable M);
   ns_H::HMovable M;
 };
 using namespace ns_H;
-H::H(const HMovable &M) : M(M) {}
+H::H(HMovable M) : M(std::move(M)) {}
 // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: pass by value and use std::move
 // CHECK-FIXES: H(HMovable M) : M(std::move(M)) {}
 
@@ -122,14 +125,14 @@ struct K_Movable {
 
 // Test with movable type with an user defined move constructor.
 struct K {
-  K(const K_Movable &M) : M(M) {}
+  K(K_Movable M) : M(std::move(M)) {}
   // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: pass by value and use std::move
   // CHECK-FIXES: K(K_Movable M) : M(std::move(M)) {}
   K_Movable M;
 };
 
 template  struct L {
-  L(const Movable &M) : M(M) {}
+  L(Movable M) : M(std::move(M)) {}
   // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: pass by value and use std::move
   // CHECK-FIXES: L(Movable M) : M(std::move(M)) {}
   Movable M;
@@ -138,7 +141,7 @@ L l(Movable());
 
 // Test with a non-instantiated template class.
 template  struct N {
-  N(const Movable &M) : M(M) {}
+  N(Movable M) : M(std::move(M)) {}
   // CHECK-MESSAGES: :[[@LINE-1]]

[clang-tools-extra] r270566 - [find-all-symbols] Added hardcode header mapping from header postfix to header name for STL symbols.

2016-05-24 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Tue May 24 10:10:58 2016
New Revision: 270566

URL: http://llvm.org/viewvc/llvm-project?rev=270566&view=rev
Log:
[find-all-symbols] Added hardcode header mapping from header postfix to header 
name for STL symbols.

Summary: [find-all-symbols] Added hardcode header mapping from header postfix 
to header name for STL symbols.

Reviewers: klimek, bkramer

Subscribers: cfe-commits, hokein

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

Added:

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

clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbolsAction.h

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

clang-tools-extra/trunk/include-fixer/find-all-symbols/tool/STLPostfixHeaderMap.cpp

clang-tools-extra/trunk/include-fixer/find-all-symbols/tool/STLPostfixHeaderMap.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/include-fixer/find-all-symbols/HeaderMapCollector.h
clang-tools-extra/trunk/include-fixer/find-all-symbols/tool/CMakeLists.txt

clang-tools-extra/trunk/include-fixer/find-all-symbols/tool/FindAllSymbolsMain.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=270566&r1=270565&r2=270566&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 Tue 
May 24 10:10:58 2016
@@ -4,7 +4,9 @@ set(LLVM_LINK_COMPONENTS
 
 add_clang_library(findAllSymbols
   FindAllSymbols.cpp
+  FindAllSymbolsAction.cpp
   FindAllMacros.cpp
+  HeaderMapCollector.cpp
   PragmaCommentHandler.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=270566&r1=270565&r2=270566&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 
Tue May 24 10:10:58 2016
@@ -28,11 +28,7 @@ void FindAllMacros::MacroDefined(const T
 return;
 
   // If Collector is not nullptr, check pragma remapping header.
-  if (Collector) {
-auto Iter = Collector->getHeaderMappingTable().find(FilePath);
-if (Iter != Collector->getHeaderMappingTable().end())
-  FilePath = Iter->second;
-  }
+  FilePath = Collector ? Collector->getMappedHeader(FilePath) : FilePath;
 
   SymbolInfo Symbol(MacroNameTok.getIdentifierInfo()->getName(),
 SymbolInfo::SymbolKind::Macro, FilePath.str(),

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=270566&r1=270565&r2=270566&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 
Tue May 24 10:10:58 2016
@@ -97,11 +97,7 @@ CreateSymbolInfo(const NamedDecl *ND, co
 return llvm::None;
 
   // If Collector is not nullptr, check pragma remapping header.
-  if (Collector) {
-auto Iter = Collector->getHeaderMappingTable().find(FilePath);
-if (Iter != Collector->getHeaderMappingTable().end())
-  FilePath = Iter->second;
-  }
+  FilePath = Collector ? Collector->getMappedHeader(FilePath) : FilePath;
 
   return SymbolInfo(ND->getNameAsString(), Type, FilePath.str(),
 SM.getExpansionLineNumber(Loc), GetContexts(ND));

Added: 
clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbolsAction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbolsAction.cpp?rev=270566&view=auto
==
--- 
clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbolsAction.cpp 
(added)
+++ 
clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbolsAction.cpp 
Tue May 24 10:10:58 2016
@@ -0,0 +1,32 @@
+//===-- FindAllSymbolsAction.cpp - find all symbols action *- C++ 
-*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+

Re: [PATCH] D20566: [find-all-symbols] Added hardcode header mapping from header postfix to header name for STL symbols.

2016-05-24 Thread Eric Liu via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL270566: [find-all-symbols] Added hardcode header mapping 
from header postfix to… (authored by ioeric).

Changed prior to commit:
  http://reviews.llvm.org/D20566?vs=58235&id=58237#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D20566

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/FindAllSymbolsAction.cpp
  clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbolsAction.h
  clang-tools-extra/trunk/include-fixer/find-all-symbols/HeaderMapCollector.cpp
  clang-tools-extra/trunk/include-fixer/find-all-symbols/HeaderMapCollector.h
  clang-tools-extra/trunk/include-fixer/find-all-symbols/tool/CMakeLists.txt
  
clang-tools-extra/trunk/include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp
  
clang-tools-extra/trunk/include-fixer/find-all-symbols/tool/STLPostfixHeaderMap.cpp
  
clang-tools-extra/trunk/include-fixer/find-all-symbols/tool/STLPostfixHeaderMap.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
@@ -7,10 +7,8 @@
 //
 //===--===//
 
-#include "FindAllMacros.h"
-#include "FindAllSymbols.h"
+#include "FindAllSymbolsAction.h"
 #include "HeaderMapCollector.h"
-#include "PragmaCommentHandler.h"
 #include "SymbolInfo.h"
 #include "SymbolReporter.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
@@ -54,44 +52,6 @@
   std::vector Symbols;
 };
 
-class TestFindAllSymbolsAction : public clang::ASTFrontendAction {
-public:
-  TestFindAllSymbolsAction(SymbolReporter *Reporter)
-  : Reporter(Reporter), MatchFinder(), Collector(), Handler(&Collector),
-Matcher(Reporter, &Collector) {
-Matcher.registerMatchers(&MatchFinder);
-  }
-
-  std::unique_ptr
-  CreateASTConsumer(clang::CompilerInstance &Compiler,
-StringRef InFile) override {
-Compiler.getPreprocessor().addCommentHandler(&Handler);
-Compiler.getPreprocessor().addPPCallbacks(llvm::make_unique(
-Reporter, &Compiler.getSourceManager(), &Collector));
-return MatchFinder.newASTConsumer();
-  }
-
-private:
-  SymbolReporter *const Reporter;
-  ast_matchers::MatchFinder MatchFinder;
-  HeaderMapCollector Collector;
-  PragmaCommentHandler Handler;
-  FindAllSymbols Matcher;
-};
-
-class TestFindAllSymbolsActionFactory
-: public clang::tooling::FrontendActionFactory {
-public:
-  TestFindAllSymbolsActionFactory(TestSymbolReporter *Reporter)
-  : Reporter(Reporter) {}
-  clang::FrontendAction *create() override {
-return new TestFindAllSymbolsAction(Reporter);
-  }
-
-private:
-  TestSymbolReporter *const Reporter;
-};
-
 class FindAllSymbolsTest : public ::testing::Test {
 public:
   bool hasSymbol(const SymbolInfo &Symbol) {
@@ -106,8 +66,20 @@
 
 std::string FileName = "symbol.cc";
 
+const std::string InternalHeader = "internal/internal.h";
+const std::string TopHeader = "";
+HeaderMapCollector::HeaderMap PostfixMap = {
+{"internal.h", TopHeader},
+};
+
+std::string InternalCode = "class Internal {};";
+SymbolInfo InternalSymbol("Internal", SymbolInfo::SymbolKind::Class,
+  TopHeader, 1, {});
+InMemoryFileSystem->addFile(InternalHeader, 0,
+llvm::MemoryBuffer::getMemBuffer(InternalCode));
+
 std::unique_ptr Factory(
-new TestFindAllSymbolsActionFactory(&Reporter));
+new FindAllSymbolsActionFactory(&Reporter, &PostfixMap));
 
 tooling::ToolInvocation Invocation(
 {std::string("find_all_symbols"), std::string("-fsyntax-only"),
@@ -118,10 +90,13 @@
 InMemoryFileSystem->addFile(HeaderName, 0,
 llvm::MemoryBuffer::getMemBuffer(Code));
 
-std::string Content = "#include\"" + std::string(HeaderName) + "\"";
+std::string Content = "#include\"" + std::string(HeaderName) +
+  "\"\n"
+  "#include \"internal/internal.h\"";
 InMemoryFileSystem->addFile(FileName, 0,
 llvm::MemoryBuffer::getMemBuffer(Content));
 Invocation.run();
+EXPECT_TRUE(hasSymbol(InternalSymbol));
 return true;
   }
 
Index: clang-tools-extra/trunk/include-fixer/find-all-symbols/HeaderMapCollector.h
===
--- 

[clang-tools-extra] r270567 - [clang-tidy] modernize-pass-by-value bugfix. Reverting lit-style test

2016-05-24 Thread Mads Ravn via cfe-commits
Author: madsravn
Date: Tue May 24 10:13:44 2016
New Revision: 270567

URL: http://llvm.org/viewvc/llvm-project?rev=270567&view=rev
Log:
[clang-tidy] modernize-pass-by-value bugfix. Reverting lit-style test

Adding to revision 270565. The lit-style test was wrong. This is being fixed by 
this commit.

This is the bug on bugzilla: https://llvm.org/bugs/show_bug.cgi?id=27731

This is the code review on phabricator: http://reviews.llvm.org/D20365

Modified:
clang-tools-extra/trunk/test/clang-tidy/modernize-pass-by-value.cpp

Modified: clang-tools-extra/trunk/test/clang-tidy/modernize-pass-by-value.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-pass-by-value.cpp?rev=270567&r1=270566&r2=270567&view=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/modernize-pass-by-value.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-pass-by-value.cpp Tue May 
24 10:13:44 2016
@@ -1,9 +1,7 @@
-#include 
-#include 
-
 // RUN: %check_clang_tidy %s modernize-pass-by-value %t -- -- -std=c++11 
-fno-delayed-template-parsing
 
 // CHECK-FIXES: #include 
+#include 
 
 namespace {
 // POD types are trivially move constructible.
@@ -20,7 +18,7 @@ struct NotMovable {
 }
 
 struct A {
-  A(Movable M) : M(std::move(M)) {}
+  A(const Movable &M) : M(M) {}
   // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: pass by value and use std::move 
[modernize-pass-by-value]
   // CHECK-FIXES: A(Movable M) : M(std::move(M)) {}
   Movable M;
@@ -49,17 +47,17 @@ struct C {
 
 // Test that both declaration and definition are updated.
 struct D {
-  D(Movable M);
+  D(const Movable &M);
   // CHECK-FIXES: D(Movable M);
   Movable M;
 };
-D::D(Movable M) : M(std::move(M)) {}
+D::D(const Movable &M) : M(M) {}
 // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: pass by value and use std::move
 // CHECK-FIXES: D::D(Movable M) : M(std::move(M)) {}
 
 // Test with default parameter.
 struct E {
-  E(Movable M = Movable()) : M(std::move(M)) {}
+  E(const Movable &M = Movable()) : M(M) {}
   // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: pass by value and use std::move
   // CHECK-FIXES: E(Movable M = Movable()) : M(std::move(M)) {}
   Movable M;
@@ -74,11 +72,11 @@ struct F {
 
 // Test unnamed parameter in declaration.
 struct G {
-  G(Movable );
+  G(const Movable &);
   // CHECK-FIXES: G(Movable );
   Movable M;
 };
-G::G(Movable M) : M(std::move(M)) {}
+G::G(const Movable &M) : M(M) {}
 // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: pass by value and use std::move
 // CHECK-FIXES: G::G(Movable M) : M(std::move(M)) {}
 
@@ -87,12 +85,12 @@ namespace ns_H {
 typedef ::Movable HMovable;
 }
 struct H {
-  H(ns_H::HMovable M);
+  H(const ns_H::HMovable &M);
   // CHECK-FIXES: H(ns_H::HMovable M);
   ns_H::HMovable M;
 };
 using namespace ns_H;
-H::H(HMovable M) : M(std::move(M)) {}
+H::H(const HMovable &M) : M(M) {}
 // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: pass by value and use std::move
 // CHECK-FIXES: H(HMovable M) : M(std::move(M)) {}
 
@@ -125,14 +123,14 @@ struct K_Movable {
 
 // Test with movable type with an user defined move constructor.
 struct K {
-  K(K_Movable M) : M(std::move(M)) {}
+  K(const K_Movable &M) : M(M) {}
   // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: pass by value and use std::move
   // CHECK-FIXES: K(K_Movable M) : M(std::move(M)) {}
   K_Movable M;
 };
 
 template  struct L {
-  L(Movable M) : M(std::move(M)) {}
+  L(const Movable &M) : M(M) {}
   // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: pass by value and use std::move
   // CHECK-FIXES: L(Movable M) : M(std::move(M)) {}
   Movable M;
@@ -141,7 +139,7 @@ L l(Movable());
 
 // Test with a non-instantiated template class.
 template  struct N {
-  N(Movable M) : M(std::move(M)) {}
+  N(const Movable &M) : M(M) {}
   // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: pass by value and use std::move
   // CHECK-FIXES: N(Movable M) : M(std::move(M)) {}
 
@@ -151,7 +149,7 @@ template  struct N {
 
 // Test with value parameter.
 struct O {
-  O(Movable M) : M(std::move(M)) {}
+  O(Movable M) : M(M) {}
   // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: pass by value and use std::move
   // CHECK-FIXES: O(Movable M) : M(std::move(M)) {}
   Movable M;
@@ -167,8 +165,8 @@ struct P {
 // Test with multiples parameters where some need to be changed and some don't.
 // need to.
 struct Q {
-  Q(const Movable &A, Movable B, Movable C, double D)
-  : A(A), B(std::move(B)), C(std::move(C)), D(D) {}
+  Q(const Movable &A, const Movable &B, const Movable &C, double D)
+  : A(A), B(B), C(C), D(D) {}
   // CHECK-MESSAGES: :[[@LINE-2]]:23: warning: pass by value and use std::move
   // CHECK-MESSAGES: :[[@LINE-3]]:41: warning: pass by value and use std::move
   // CHECK-FIXES:  Q(const Movable &A, Movable B, Movable C, double D)
@@ -184,7 +182,7 @@ namespace ns_R {
 typedef ::Movable RMovable;
 }
 struct R {
-  R(ns_R::RMovable M) : M(std::move(M)) {}
+  R(ns_R::R

Re: [PATCH] D20338: [PCH] Fixed overridden files always invalidating preamble even when unchanged

2016-05-24 Thread Cameron via cfe-commits
cameron314 added a comment.

I'm not sure how to test this (originally I found this bug by stepping through 
with a debugger) -- is there a way to determine if an ASTUnit used a PCH for 
the preamble or not? I'd call the `getMainBufferWithPrecompiledPreamble` method 
manually but it's private.


Repository:
  rL LLVM

http://reviews.llvm.org/D20338



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


[clang-tools-extra] r270571 - [include-fixer][find-all-symbols] removed unused const member from YamlReporter to fix build bot failure.

2016-05-24 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Tue May 24 10:34:37 2016
New Revision: 270571

URL: http://llvm.org/viewvc/llvm-project?rev=270571&view=rev
Log:
[include-fixer][find-all-symbols] removed unused const member from YamlReporter 
to fix build bot failure.

Modified:

clang-tools-extra/trunk/include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp

Modified: 
clang-tools-extra/trunk/include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp?rev=270571&r1=270570&r2=270571&view=diff
==
--- 
clang-tools-extra/trunk/include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp
 (original)
+++ 
clang-tools-extra/trunk/include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp
 Tue May 24 10:34:37 2016
@@ -82,8 +82,6 @@ public:
   }
 
 private:
-  // Directory to write yaml files to.
-  const std::string Directory;
   std::map> Symbols;
 };
 


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


Re: [PATCH] D20119: [libunwind] Improve unwinder stack usage

2016-05-24 Thread Jonathan Roelofs via cfe-commits
jroelofs added a comment.

In http://reviews.llvm.org/D20119#437191, @rmaprath wrote:

> In http://reviews.llvm.org/D20119#436849, @jroelofs wrote:
>
> > In http://reviews.llvm.org/D20119#431997, @rmaprath wrote:
> >
> > > Addressing review comments from @jroelofs:
> > >
> > > - Moved the assertion in `libunwind.cpp` back to `UnwindCursor.cpp` where 
> > > it really belogs.
> > >
> > >   @jroelofs: I just realized that, with this new native-only build of 
> > > `libunwind`, users of `libunwind.h` would have to explicitly `#define` 
> > > the flag `_LIBUNWIND_IS_NATIVE_ONLY` in order to get the header in-sync 
> > > with the library. I can't see an immediate problem if they don't define 
> > > that flag though, it's just that they'll end up passing larger buffers 
> > > than the library needs. Do you see a problem here?
> >
> >
> > I'm not convinced it's a problem, (though possibly performance left on the 
> > table)...
> >
> > > 'libc++' uses a `__config_site` mechanism to wire the cmake build options 
> > > into the `__config` header. We can implement a similar mechanism in 
> > > `libunwind`, not sure if that's necessary here.
> >
> >
> > I think that's the right way to go.
> >
> > Jon
> >
> > > WDYT?
> >
> > > 
> >
> > > Thanks.
> >
> > > 
> >
> > > / Asiri
> >
>
>
> Apologies, it looks like we don't have any targets for installing 
> `libunwind.h` header (or any other headers from `libunwind` project for that 
> matter). I think this means we use `libunwind.h` only for building 
> libunwind+libcxxabi libraries, and there's no need to explicitly adjust 
> `libunwind.h` header as it is not used from outside as-is. Hope this makes 
> sense.
>
> OK to commit? Sorry for the diversion.


Ah, ok. LGTM then!

Jon

> / Asiri





http://reviews.llvm.org/D20119



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


r270576 - [MS Volatile] Don't make volatile loads/stores to underaligned objects atomic

2016-05-24 Thread David Majnemer via cfe-commits
Author: majnemer
Date: Tue May 24 11:09:25 2016
New Revision: 270576

URL: http://llvm.org/viewvc/llvm-project?rev=270576&view=rev
Log:
[MS Volatile] Don't make volatile loads/stores to underaligned objects atomic

Underaligned atomic LValues require libcalls which MSVC doesn't have.
MSVC doesn't seem to consider such operations as requiring a barrier
anyway.

This fixes PR27843.

Modified:
cfe/trunk/lib/CodeGen/CGAtomic.cpp
cfe/trunk/lib/CodeGen/CGExpr.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
cfe/trunk/test/CodeGen/ms-volatile.c

Modified: cfe/trunk/lib/CodeGen/CGAtomic.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGAtomic.cpp?rev=270576&r1=270575&r2=270576&view=diff
==
--- cfe/trunk/lib/CodeGen/CGAtomic.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGAtomic.cpp Tue May 24 11:09:25 2016
@@ -1274,31 +1274,11 @@ bool CodeGenFunction::LValueIsSuitableFo
   bool IsVolatile = LV.isVolatile() || hasVolatileMember(LV.getType());
   // An atomic is inline if we don't need to use a libcall.
   bool AtomicIsInline = !AI.shouldUseLibcall();
-  return IsVolatile && AtomicIsInline;
-}
-
-/// An type is a candidate for having its loads and stores be made atomic if
-/// we are operating under /volatile:ms *and* we know the access is volatile 
and
-/// performing such an operation can be performed without a libcall.
-bool CodeGenFunction::typeIsSuitableForInlineAtomic(QualType Ty,
-bool IsVolatile) const {
-  // The operation must be volatile for us to make it atomic.
-  if (!IsVolatile)
-return false;
-  // The -fms-volatile flag must be passed for us to adopt this behavior.
-  if (!CGM.getCodeGenOpts().MSVolatile)
-return false;
-
-  // An atomic is inline if we don't need to use a libcall (e.g. it is 
builtin).
-  if (!getContext().getTargetInfo().hasBuiltinAtomic(
-  getContext().getTypeSize(Ty), getContext().getTypeAlign(Ty)))
-return false;
-
   // MSVC doesn't seem to do this for types wider than a pointer.
-  if (getContext().getTypeSize(Ty) >
+  if (getContext().getTypeSize(LV.getType()) >
   getContext().getTypeSize(getContext().getIntPtrType()))
 return false;
-  return true;
+  return IsVolatile && AtomicIsInline;
 }
 
 RValue CodeGenFunction::EmitAtomicLoad(LValue LV, SourceLocation SL,

Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=270576&r1=270575&r2=270576&view=diff
==
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Tue May 24 11:09:25 2016
@@ -1273,10 +1273,10 @@ llvm::Value *CodeGenFunction::EmitLoadOf
   }
 
   // Atomic operations have to be done on integral types.
-  if (Ty->isAtomicType() || typeIsSuitableForInlineAtomic(Ty, Volatile)) {
-LValue lvalue =
+  LValue AtomicLValue =
   LValue::MakeAddr(Addr, Ty, getContext(), AlignSource, TBAAInfo);
-return EmitAtomicLoad(lvalue, Loc).getScalarVal();
+  if (Ty->isAtomicType() || LValueIsSuitableForInlineAtomic(AtomicLValue)) {
+return EmitAtomicLoad(AtomicLValue, Loc).getScalarVal();
   }
 
   llvm::LoadInst *Load = Builder.CreateLoad(Addr, Volatile);
@@ -1384,12 +1384,11 @@ void CodeGenFunction::EmitStoreOfScalar(
 
   Value = EmitToMemory(Value, Ty);
 
+  LValue AtomicLValue =
+  LValue::MakeAddr(Addr, Ty, getContext(), AlignSource, TBAAInfo);
   if (Ty->isAtomicType() ||
-  (!isInit && typeIsSuitableForInlineAtomic(Ty, Volatile))) {
-EmitAtomicStore(RValue::get(Value),
-LValue::MakeAddr(Addr, Ty, getContext(),
- AlignSource, TBAAInfo),
-isInit);
+  (!isInit && LValueIsSuitableForInlineAtomic(AtomicLValue))) {
+EmitAtomicStore(RValue::get(Value), AtomicLValue, isInit);
 return;
   }
 

Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.h?rev=270576&r1=270575&r2=270576&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenFunction.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.h Tue May 24 11:09:25 2016
@@ -2496,7 +2496,6 @@ public:
   void EmitAtomicInit(Expr *E, LValue lvalue);
 
   bool LValueIsSuitableForInlineAtomic(LValue Src);
-  bool typeIsSuitableForInlineAtomic(QualType Ty, bool IsVolatile) const;
 
   RValue EmitAtomicLoad(LValue LV, SourceLocation SL,
 AggValueSlot Slot = AggValueSlot::ignored());

Modified: cfe/trunk/test/CodeGen/ms-volatile.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/ms-volatile.c?rev=270576&r1=270575&r2=270576&view=diff
==
--- cfe/trunk/test/CodeGen/ms-volatil

[clang-tools-extra] r270575 - [clang-tidy] modernize-pass-by-value bugfix. Reverting lit-style test

2016-05-24 Thread Mads Ravn via cfe-commits
Author: madsravn
Date: Tue May 24 11:09:24 2016
New Revision: 270575

URL: http://llvm.org/viewvc/llvm-project?rev=270575&view=rev
Log:
[clang-tidy] modernize-pass-by-value bugfix. Reverting lit-style test

Adding to revision 270567. The lit-style test was wrong. This is being fixed by 
this commit.

This is the bug on bugzilla: https://llvm.org/bugs/show_bug.cgi?id=27731

This is the code review on phabricator: http://reviews.llvm.org/D20365

Modified:
clang-tools-extra/trunk/test/clang-tidy/modernize-pass-by-value.cpp

Modified: clang-tools-extra/trunk/test/clang-tidy/modernize-pass-by-value.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-pass-by-value.cpp?rev=270575&r1=270574&r2=270575&view=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/modernize-pass-by-value.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-pass-by-value.cpp Tue May 
24 11:09:24 2016
@@ -150,8 +150,7 @@ template  struct N {
 // Test with value parameter.
 struct O {
   O(Movable M) : M(M) {}
-  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: pass by value and use std::move
-  // CHECK-FIXES: O(Movable M) : M(std::move(M)) {}
+  // CHECK-FIXES: O(Movable M) : M(M) {}
   Movable M;
 };
 
@@ -183,8 +182,7 @@ typedef ::Movable RMovable;
 }
 struct R {
   R(ns_R::RMovable M) : M(M) {}
-  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: pass by value and use std::move
-  // CHECK-FIXES: R(ns_R::RMovable M) : M(std::move(M)) {}
+  // CHECK-FIXES: R(ns_R::RMovable M) : M(M) {}
   ns_R::RMovable M;
 };
 
@@ -198,6 +196,7 @@ struct S {
 // Test that types that are trivially copyable will not use std::move. This 
will
 // cause problems with misc-move-const-arg, as it will revert it.
 struct T {
-  std::array a_;
   T(std::array a) : a_(a) {}
+  // CHECK-FIXES: T(std::array a) : a_(a) {} 
+  std::array a_;
 };


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


Re: [PATCH] D18953: [ms][dll] #26935 Defining a dllimport function should cause it to be exported

2016-05-24 Thread Reid Kleckner via cfe-commits
rnk added a comment.

lgtm


http://reviews.llvm.org/D18953



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


Re: [PATCH] D20111: [OpenMP] Adjust map type bits according to latest spec and use zero size array sections for pointers.

2016-05-24 Thread Samuel Antao via cfe-commits
sfantao updated this revision to Diff 58252.
sfantao added a comment.

- Rebase after last changes related to first private.


http://reviews.llvm.org/D20111

Files:
  lib/CodeGen/CGOpenMPRuntime.cpp
  test/OpenMP/target_codegen.cpp
  test/OpenMP/target_codegen_registration.cpp
  test/OpenMP/target_data_codegen.cpp
  test/OpenMP/target_enter_data_codegen.cpp
  test/OpenMP/target_exit_data_codegen.cpp
  test/OpenMP/target_firstprivate_codegen.cpp
  test/OpenMP/target_map_codegen.cpp

Index: test/OpenMP/target_map_codegen.cpp
===
--- test/OpenMP/target_map_codegen.cpp
+++ test/OpenMP/target_map_codegen.cpp
@@ -16,8 +16,8 @@
 #ifdef CK1
 
 // CK1-DAG: [[SIZES:@.+]] = {{.+}}constant [1 x i[[sz:64|32]]] [i{{64|32}} 4]
-// Map types: OMP_MAP_BYCOPY = 128
-// CK1-DAG: [[TYPES:@.+]] = {{.+}}constant [1 x i32] [i32 128]
+// Map types: OMP_MAP_PRIVATE_VAL | OMP_MAP_IS_FIRST = 288
+// CK1-DAG: [[TYPES:@.+]] = {{.+}}constant [1 x i32] [i32 288]
 
 // CK1-LABEL: implicit_maps_integer
 void implicit_maps_integer (int a){
@@ -61,8 +61,8 @@
 #ifdef CK2
 
 // CK2-DAG: [[SIZES:@.+]] = {{.+}}constant [1 x i[[sz:64|32]]] [i{{64|32}} 4]
-// Map types: OMP_MAP_BYCOPY = 128
-// CK2-DAG: [[TYPES:@.+]] = {{.+}}constant [1 x i32] [i32 128]
+// Map types: OMP_MAP_PRIVATE_VAL | OMP_MAP_IS_FIRST = 288
+// CK2-DAG: [[TYPES:@.+]] = {{.+}}constant [1 x i32] [i32 288]
 
 // CK2-LABEL: implicit_maps_integer_reference
 void implicit_maps_integer_reference (int a){
@@ -110,8 +110,8 @@
 #ifdef CK3
 
 // CK3-DAG: [[SIZES:@.+]] = {{.+}}constant [1 x i[[sz:64|32]]] [i{{64|32}} 4]
-// Map types: OMP_MAP_BYCOPY = 128
-// CK3-DAG: [[TYPES:@.+]] = {{.+}}constant [1 x i32] [i32 128]
+// Map types: OMP_MAP_PRIVATE_VAL | OMP_MAP_IS_FIRST = 288
+// CK3-DAG: [[TYPES:@.+]] = {{.+}}constant [1 x i32] [i32 288]
 
 // CK3-LABEL: implicit_maps_parameter
 void implicit_maps_parameter (int a){
@@ -154,8 +154,8 @@
 #ifdef CK4
 
 // CK4-DAG: [[SIZES:@.+]] = {{.+}}constant [1 x i[[sz:64|32]]] [i{{64|32}} 4]
-// Map types: OMP_MAP_BYCOPY = 128
-// CK4-DAG: [[TYPES:@.+]] = {{.+}}constant [1 x i32] [i32 128]
+// Map types: OMP_MAP_PRIVATE_VAL | OMP_MAP_IS_FIRST = 288
+// CK4-DAG: [[TYPES:@.+]] = {{.+}}constant [1 x i32] [i32 288]
 
 // CK4-LABEL: implicit_maps_nested_integer
 void implicit_maps_nested_integer (int a){
@@ -210,8 +210,8 @@
 #ifdef CK5
 
 // CK5-DAG: [[SIZES:@.+]] = {{.+}}constant [1 x i[[sz:64|32]]] [i{{64|32}} 4]
-// Map types: OMP_MAP_BYCOPY = 128
-// CK5-DAG: [[TYPES:@.+]] = {{.+}}constant [1 x i32] [i32 128]
+// Map types: OMP_MAP_PRIVATE_VAL | OMP_MAP_IS_FIRST = 288
+// CK5-DAG: [[TYPES:@.+]] = {{.+}}constant [1 x i32] [i32 288]
 
 // CK5-LABEL: implicit_maps_nested_integer_and_enum
 void implicit_maps_nested_integer_and_enum (int a){
@@ -261,8 +261,8 @@
 #ifdef CK6
 // CK6-DAG: [[GBL:@Gi]] = global i32 0
 // CK6-DAG: [[SIZES:@.+]] = {{.+}}constant [1 x i[[sz:64|32]]] [i{{64|32}} 4]
-// Map types: OMP_MAP_BYCOPY = 128
-// CK6-DAG: [[TYPES:@.+]] = {{.+}}constant [1 x i32] [i32 128]
+// Map types: OMP_MAP_PRIVATE_VAL | OMP_MAP_IS_FIRST = 288
+// CK6-DAG: [[TYPES:@.+]] = {{.+}}constant [1 x i32] [i32 288]
 
 // CK6-LABEL: implicit_maps_host_global
 int Gi;
@@ -310,10 +310,10 @@
 // therefore it is passed by reference with a map 'to' specification.
 
 // CK7-DAG: [[SIZES:@.+]] = {{.+}}constant [1 x i[[sz:64|32]]] [i{{64|32}} 8]
-// Map types: OMP_MAP_BYCOPY = 128
-// CK7-64-DAG: [[TYPES:@.+]] = {{.+}}constant [1 x i32] [i32 128]
-// Map types: OMP_MAP_TO = 1
-// CK7-32-DAG: [[TYPES:@.+]] = {{.+}}constant [1 x i32] [i32 1]
+// Map types: OMP_MAP_PRIVATE_VAL | OMP_MAP_IS_FIRST = 288
+// CK7-64-DAG: [[TYPES:@.+]] = {{.+}}constant [1 x i32] [i32 288]
+// Map types: OMP_MAP_TO  | OMP_MAP_IS_FIRST = 33
+// CK7-32-DAG: [[TYPES:@.+]] = {{.+}}constant [1 x i32] [i32 33]
 
 // CK7-LABEL: implicit_maps_double
 void implicit_maps_double (int a){
@@ -369,8 +369,8 @@
 #ifdef CK8
 
 // CK8-DAG: [[SIZES:@.+]] = {{.+}}constant [1 x i[[sz:64|32]]] [i{{64|32}} 4]
-// Map types: OMP_MAP_BYCOPY = 128
-// CK8-DAG: [[TYPES:@.+]] = {{.+}}constant [1 x i32] [i32 128]
+// Map types: OMP_MAP_PRIVATE_VAL | OMP_MAP_IS_FIRST = 288
+// CK8-DAG: [[TYPES:@.+]] = {{.+}}constant [1 x i32] [i32 288]
 
 // CK8-LABEL: implicit_maps_float
 void implicit_maps_float (int a){
@@ -413,8 +413,8 @@
 #ifdef CK9
 
 // CK9-DAG: [[SIZES:@.+]] = {{.+}}constant [1 x i[[sz:64|32]]] [i{{64|32}} 16]
-// Map types: OMP_MAP_TO + OMP_MAP_FROM = 2 + 1
-// CK9-DAG: [[TYPES:@.+]] = {{.+}}constant [1 x i32] [i32 3]
+// Map types: OMP_MAP_TO + OMP_MAP_FROM + OMP_MAP_IS_FIRST = 35
+// CK9-DAG: [[TYPES:@.+]] = {{.+}}constant [1 x i32] [i32 35]
 
 // CK9-LABEL: implicit_maps_array
 void implicit_maps_array (int a){
@@ -453,9 +453,9 @@
 // RUN: %clang_cc1 -fopenmp -fomptargets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s  --check-prefix CK10
 #ifdef CK10
 
-// CK10-DAG: [[SIZE

[clang-tools-extra] r270578 - [include-fixer][find-all-symbols] added missing dependencies.

2016-05-24 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Tue May 24 11:35:24 2016
New Revision: 270578

URL: http://llvm.org/viewvc/llvm-project?rev=270578&view=rev
Log:
[include-fixer][find-all-symbols] added missing dependencies.

Modified:
clang-tools-extra/trunk/include-fixer/find-all-symbols/CMakeLists.txt

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=270578&r1=270577&r2=270578&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 Tue 
May 24 11:35:24 2016
@@ -14,7 +14,9 @@ add_clang_library(findAllSymbols
   clangAST
   clangASTMatchers
   clangBasic
+  clangFrontend
   clangLex
+  clangTooling
   )
 
 add_subdirectory(tool)


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


Re: [PATCH] D20112: [OpenMP] Add support for the 'private pointer' flag to signal variables captured in target regions and used in first-private clauses.

2016-05-24 Thread Samuel Antao via cfe-commits
sfantao updated this revision to Diff 58253.
sfantao marked 2 inline comments as done.
sfantao added a comment.

- Rebase after last changes related to first private.


http://reviews.llvm.org/D20112

Files:
  lib/CodeGen/CGOpenMPRuntime.cpp
  test/OpenMP/target_firstprivate_codegen.cpp
  test/OpenMP/target_map_codegen.cpp

Index: test/OpenMP/target_map_codegen.cpp
===
--- test/OpenMP/target_map_codegen.cpp
+++ test/OpenMP/target_map_codegen.cpp
@@ -4281,8 +4281,17 @@
 // CK27: [[SIZE03:@.+]] = private {{.*}}constant [1 x i[[Z]]] zeroinitializer
 // CK27: [[MTYPE03:@.+]] = private {{.*}}constant [1 x i32] [i32 35]
 
-// CK27-LABEL: zero_size_section_maps
-void zero_size_section_maps (int ii){
+// CK27: [[SIZE05:@.+]] = private {{.*}}constant [1 x i[[Z]]] zeroinitializer
+// CK27: [[MTYPE05:@.+]] = private {{.*}}constant [1 x i32] [i32 32]
+
+// CK27: [[SIZE07:@.+]] = private {{.*}}constant [1 x i[[Z]]] [i[[Z]] 4]
+// CK27: [[MTYPE07:@.+]] = private {{.*}}constant [1 x i32] [i32 288]
+
+// CK27: [[SIZE09:@.+]] = private {{.*}}constant [1 x i[[Z]]] [i[[Z]] 40]
+// CK27: [[MTYPE09:@.+]] = private {{.*}}constant [1 x i32] [i32 161]
+
+// CK27-LABEL: zero_size_section_and_private_maps
+void zero_size_section_and_private_maps (int ii){
 
   // Map of a pointer.
   int *pa;
@@ -4367,12 +4376,99 @@
   {
 pa[50]++;
   }
+
+  int *pvtPtr;
+  int pvtScl;
+  int pvtArr[10];
+
+  // Region 04
+  // CK27: call i32 @__tgt_target(i32 {{[^,]+}}, i8* {{[^,]+}}, i32 0, i8** null, i8** null, i{{64|32}}* null, i32* null)
+  // CK27: call void [[CALL04:@.+]]()
+  #pragma omp target private(pvtPtr)
+  {
+pvtPtr[5]++;
+  }
+
+  // Region 05
+  // CK27-DAG: call i32 @__tgt_target(i32 {{[^,]+}}, i8* {{[^,]+}}, i32 1, i8** [[GEPBP:%.+]], i8** [[GEPP:%.+]], {{.+}}getelementptr {{.+}}[1 x i{{.+}}]* [[SIZE05]], {{.+}}getelementptr {{.+}}[1 x i{{.+}}]* [[MTYPE05]]{{.+}})
+  // CK27-DAG: [[GEPBP]] = getelementptr inbounds {{.+}}[[BP:%[^,]+]]
+  // CK27-DAG: [[GEPP]] = getelementptr inbounds {{.+}}[[P:%[^,]+]]
+
+  // CK27-DAG: [[BP0:%.+]] = getelementptr inbounds {{.+}}[[BP]], i{{.+}} 0, i{{.+}} 0
+  // CK27-DAG: [[P0:%.+]] = getelementptr inbounds {{.+}}[[P]], i{{.+}} 0, i{{.+}} 0
+  // CK27-DAG: store i8* [[CBPVAL0:%[^,]+]], i8** [[BP0]]
+  // CK27-DAG: store i8* [[CPVAL0:%[^,]+]], i8** [[P0]]
+  // CK27-DAG: [[CBPVAL0]] = bitcast i32* [[VAR0:%.+]] to i8*
+  // CK27-DAG: [[CPVAL0]] = bitcast i32* [[VAR0]] to i8*
+
+  // CK27: call void [[CALL05:@.+]](i32* {{[^,]+}})
+  #pragma omp target firstprivate(pvtPtr)
+  {
+pvtPtr[5]++;
+  }
+
+  // Region 06
+  // CK27: call i32 @__tgt_target(i32 {{[^,]+}}, i8* {{[^,]+}}, i32 0, i8** null, i8** null, i{{64|32}}* null, i32* null)
+  // CK27: call void [[CALL06:@.+]]()
+  #pragma omp target private(pvtScl)
+  {
+pvtScl++;
+  }
+
+  // Region 07
+  // CK27-DAG: call i32 @__tgt_target(i32 {{.+}}, i8* {{.+}}, i32 1, i8** [[BPGEP:%[0-9]+]], i8** [[PGEP:%[0-9]+]], {{.+}}[[SIZE07]]{{.+}}, {{.+}}[[MTYPE07]]{{.+}})
+  // CK27-DAG: [[BPGEP]] = getelementptr inbounds {{.+}}[[BPS:%[^,]+]], i32 0, i32 0
+  // CK27-DAG: [[PGEP]] = getelementptr inbounds {{.+}}[[PS:%[^,]+]], i32 0, i32 0
+  // CK27-DAG: [[BP1:%.+]] = getelementptr inbounds {{.+}}[[BPS]], i32 0, i32 0
+  // CK27-DAG: [[P1:%.+]] = getelementptr inbounds {{.+}}[[PS]], i32 0, i32 0
+  // CK27-DAG: store i8* [[VALBP:%.+]], i8** [[BP1]],
+  // CK27-DAG: store i8* [[VALP:%.+]], i8** [[P1]],
+  // CK27-DAG: [[VALBP]] = inttoptr i[[Z]] [[VAL:%.+]] to i8*
+  // CK27-DAG: [[VALP]] = inttoptr i[[Z]] [[VAL:%.+]] to i8*
+  // CK27-DAG: [[VAL]] = load i[[Z]], i[[Z]]* [[ADDR:%.+]],
+  // CK27-64-DAG: [[CADDR:%.+]] = bitcast i[[Z]]* [[ADDR]] to i32*
+  // CK27-64-DAG: store i32 {{.+}}, i32* [[CADDR]],
+
+  // CK27: call void [[CALL07:@.+]](i[[Z]] [[VAL]])
+  #pragma omp target firstprivate(pvtScl)
+  {
+pvtScl++;
+  }
+
+  // Region 08
+  // CK27: call i32 @__tgt_target(i32 {{[^,]+}}, i8* {{[^,]+}}, i32 0, i8** null, i8** null, i{{64|32}}* null, i32* null)
+  // CK27: call void [[CALL08:@.+]]()
+  #pragma omp target private(pvtArr)
+  {
+pvtArr[5]++;
+  }
+
+  // Region 09
+  // CK27-DAG: call i32 @__tgt_target(i32 {{[^,]+}}, i8* {{[^,]+}}, i32 1, i8** [[GEPBP:%.+]], i8** [[GEPP:%.+]], {{.+}}getelementptr {{.+}}[1 x i{{.+}}]* [[SIZE09]], {{.+}}getelementptr {{.+}}[1 x i{{.+}}]* [[MTYPE09]]{{.+}})
+  // CK27-DAG: [[GEPBP]] = getelementptr inbounds {{.+}}[[BP:%[^,]+]]
+  // CK27-DAG: [[GEPP]] = getelementptr inbounds {{.+}}[[P:%[^,]+]]
+
+  // CK27-DAG: [[BP0:%.+]] = getelementptr inbounds {{.+}}[[BP]], i{{.+}} 0, i{{.+}} 0
+  // CK27-DAG: [[P0:%.+]] = getelementptr inbounds {{.+}}[[P]], i{{.+}} 0, i{{.+}} 0
+  // CK27-DAG: store i8* [[CBPVAL0:%[^,]+]], i8** [[BP0]]
+  // CK27-DAG: store i8* [[CPVAL0:%[^,]+]], i8** [[P0]]
+  // CK27-DAG: [[CBPVAL0]] = bitcast [10 x i32]* [[VAR0:%.+]] to i8*
+  // CK27-DAG: [[CPVAL0]] = bitcast [10 x i32]* [[VAR0]] to i8*
+
+  // CK27: call vo

Re: [clang-tools-extra] r270567 - [clang-tidy] modernize-pass-by-value bugfix. Reverting lit-style test

2016-05-24 Thread Renato Golin via cfe-commits
On 24 May 2016 at 16:13, Mads Ravn via cfe-commits
 wrote:
> Author: madsravn
> Date: Tue May 24 10:13:44 2016
> New Revision: 270567
>
> URL: http://llvm.org/viewvc/llvm-project?rev=270567&view=rev
> Log:
> [clang-tidy] modernize-pass-by-value bugfix. Reverting lit-style test
>
> Adding to revision 270565. The lit-style test was wrong. This is being fixed 
> by this commit.

Still haven't fixed the ARM bots:

http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15/builds/12383

http://lab.llvm.org:8011/builders/clang-cmake-aarch64-quick/builds/7290

http://lab.llvm.org:8011/builders/clang-cmake-thumbv7-a15/builds/12665

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


Re: [PATCH] D20563: Add load/store co-processor intrinsics

2016-05-24 Thread Tim Northover via cfe-commits
t.p.northover added a subscriber: t.p.northover.
t.p.northover added a comment.

Just one suggestion for the tests here:



Comment at: test/Sema/builtins-arm.c:50
@@ -49,2 +49,3 @@
 
 void test6(int a, int b, int c) {
+  __builtin_arm_ldc(a, 2, &a); // expected-error {{argument to 
'__builtin_arm_ldc' must be a constant integer}}

Perhaps some no-error lines too? Otherwise we might regress to producing a 
warning (e.g. about pointer conversions or whatever) without knowing as CodeGen 
would still pass.


http://reviews.llvm.org/D20563



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


[PATCH] D20573: [libcxx] Allow explicit pthread opt-in

2016-05-24 Thread Ben Craig via cfe-commits
bcraig created this revision.
bcraig added reviewers: rmaprath, mclow.lists, EricWF.
bcraig added a subscriber: cfe-commits.

The existing pthread detection code in __config is pretty good for common 
operating systems.  It doesn't allow cmake-time choices to be made for uncommon 
operating systems though.

This change adds the LIBCXX_HAS_PTHREAD_API cmake flag, which turns into the 
_LIBCPP_HAS_THREAD_API_PTHREAD preprocessor define.  This is a name change from 
the old _LIBCPP_THREAD_API_PTHREAD.  The lit tests want __config_site.in 
variables to have a _LIBCPP_HAS prefix.

http://reviews.llvm.org/D20573

Files:
  CMakeLists.txt
  include/__config
  include/__config_site.in
  include/__threading_support

Index: include/__threading_support
===
--- include/__threading_support
+++ include/__threading_support
@@ -19,14 +19,14 @@
 
 #ifndef _LIBCPP_HAS_NO_THREADS
 
-#if defined(_LIBCPP_THREAD_API_PTHREAD)
+#if defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
 #include 
 #include 
 #endif
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
-#if defined(_LIBCPP_THREAD_API_PTHREAD)
+#if defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
 
 // Mutex
 #define _LIBCPP_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
@@ -194,7 +194,7 @@
 pthread_setspecific(__key, __p);
 }
 
-#else // !_LIBCPP_THREAD_API_PTHREAD
+#else // !_LIBCPP_HAS_THREAD_API_PTHREAD
   #error "No thread API selected."
 #endif
 
Index: include/__config_site.in
===
--- include/__config_site.in
+++ include/__config_site.in
@@ -19,5 +19,6 @@
 #cmakedefine _LIBCPP_HAS_NO_MONOTONIC_CLOCK
 #cmakedefine _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS
 #cmakedefine _LIBCPP_HAS_MUSL_LIBC
+#cmakedefine _LIBCPP_HAS_THREAD_API_PTHREAD
 
 #endif // _LIBCPP_CONFIG_SITE
Index: include/__config
===
--- include/__config
+++ include/__config
@@ -813,17 +813,17 @@
 #endif
 
 // Thread API
-#ifndef _LIBCPP_HAS_NO_THREADS
+#if !defined(_LIBCPP_HAS_NO_THREADS) && 
!defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
 # if defined(__FreeBSD__) || \
 defined(__NetBSD__) || \
 defined(__linux__) || \
 defined(__APPLE__) || \
 defined(__CloudABI__) || \
 defined(__sun__)
-#  define _LIBCPP_THREAD_API_PTHREAD
+#  define _LIBCPP_HAS_THREAD_API_PTHREAD
 # else
 #  error "No thread API"
-# endif // _LIBCPP_THREAD_API
+# endif // _LIBCPP_HAS_THREAD_API
 #endif // _LIBCPP_HAS_NO_THREADS
 
 
Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -384,6 +384,7 @@
 config_define_if_not(LIBCXX_ENABLE_MONOTONIC_CLOCK 
_LIBCPP_HAS_NO_MONOTONIC_CLOCK)
 config_define_if_not(LIBCXX_ENABLE_THREAD_UNSAFE_C_FUNCTIONS 
_LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS)
 
+config_define_if(LIBCXX_HAS_PTHREAD_API _LIBCPP_HAS_THREAD_API_PTHREAD)
 config_define_if(LIBCXX_HAS_MUSL_LIBC _LIBCPP_HAS_MUSL_LIBC)
 
 if (LIBCXX_NEEDS_SITE_CONFIG)


Index: include/__threading_support
===
--- include/__threading_support
+++ include/__threading_support
@@ -19,14 +19,14 @@
 
 #ifndef _LIBCPP_HAS_NO_THREADS
 
-#if defined(_LIBCPP_THREAD_API_PTHREAD)
+#if defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
 #include 
 #include 
 #endif
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
-#if defined(_LIBCPP_THREAD_API_PTHREAD)
+#if defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
 
 // Mutex
 #define _LIBCPP_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
@@ -194,7 +194,7 @@
 pthread_setspecific(__key, __p);
 }
 
-#else // !_LIBCPP_THREAD_API_PTHREAD
+#else // !_LIBCPP_HAS_THREAD_API_PTHREAD
   #error "No thread API selected."
 #endif
 
Index: include/__config_site.in
===
--- include/__config_site.in
+++ include/__config_site.in
@@ -19,5 +19,6 @@
 #cmakedefine _LIBCPP_HAS_NO_MONOTONIC_CLOCK
 #cmakedefine _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS
 #cmakedefine _LIBCPP_HAS_MUSL_LIBC
+#cmakedefine _LIBCPP_HAS_THREAD_API_PTHREAD
 
 #endif // _LIBCPP_CONFIG_SITE
Index: include/__config
===
--- include/__config
+++ include/__config
@@ -813,17 +813,17 @@
 #endif
 
 // Thread API
-#ifndef _LIBCPP_HAS_NO_THREADS
+#if !defined(_LIBCPP_HAS_NO_THREADS) && !defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
 # if defined(__FreeBSD__) || \
 defined(__NetBSD__) || \
 defined(__linux__) || \
 defined(__APPLE__) || \
 defined(__CloudABI__) || \
 defined(__sun__)
-#  define _LIBCPP_THREAD_API_PTHREAD
+#  define _LIBCPP_HAS_THREAD_API_PTHREAD
 # else
 #  error "No thread API"
-# endif // _LIBCPP_THREAD_API
+# endif // _LIBCPP_HAS_THREAD_API
 #endif // _LIBCPP_HAS_NO_THREADS
 
 
Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -384,6 +384,7 @@
 config_define_if_not(LIBCXX_E

[PATCH] D20574: [libcxxabi] Allow explicit pthread opt-in

2016-05-24 Thread Ben Craig via cfe-commits
bcraig created this revision.
bcraig added reviewers: rmaprath, mclow.lists, EricWF.
bcraig added a subscriber: cfe-commits.

Companion to http://reviews.llvm.org/D20573

When building libcxxabi in tree (i.e. in llvm/projects/libcxxabi, along with 
llvm/projects/libcxx), libcxx's __config_site.in doesn't get created in a 
timely manner.  This means that any configuration that is normally set in 
libcxx's __config_site.in needs to be duplicated in libcxxabi to successfully 
build libcxxabi.  This patch does exactly that for the 
_LIBCPP_HAS_THREAD_API_PTHREAD preprocessor define.

http://reviews.llvm.org/D20574

Files:
  CMakeLists.txt

Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -275,6 +275,10 @@
   add_definitions(-DLIBCXXABI_HAS_NO_THREADS=1)
 endif()
 
+if (LIBCXXABI_HAS_PTHREAD_API)
+  add_definitions(-D_LIBCPP_HAS_THREAD_API_PTHREAD)
+endif()
+
 # This is the _ONLY_ place where add_definitions is called.
 if (MSVC)
   add_definitions(-D_CRT_SECURE_NO_WARNINGS)


Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -275,6 +275,10 @@
   add_definitions(-DLIBCXXABI_HAS_NO_THREADS=1)
 endif()
 
+if (LIBCXXABI_HAS_PTHREAD_API)
+  add_definitions(-D_LIBCPP_HAS_THREAD_API_PTHREAD)
+endif()
+
 # This is the _ONLY_ place where add_definitions is called.
 if (MSVC)
   add_definitions(-D_CRT_SECURE_NO_WARNINGS)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r270580 - [Lex] Support more type-traits in __has_feature

2016-05-24 Thread David Majnemer via cfe-commits
Author: majnemer
Date: Tue May 24 11:53:13 2016
New Revision: 270580

URL: http://llvm.org/viewvc/llvm-project?rev=270580&view=rev
Log:
[Lex] Support more type-traits in __has_feature

It looks like we forgot to update the __has_feature support when we
added some of the type traits.

Modified:
cfe/trunk/lib/Lex/PPMacroExpansion.cpp
cfe/trunk/test/Lexer/has_feature_type_traits.cpp

Modified: cfe/trunk/lib/Lex/PPMacroExpansion.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPMacroExpansion.cpp?rev=270580&r1=270579&r2=270580&view=diff
==
--- cfe/trunk/lib/Lex/PPMacroExpansion.cpp (original)
+++ cfe/trunk/lib/Lex/PPMacroExpansion.cpp Tue May 24 11:53:13 2016
@@ -1191,8 +1191,10 @@ static bool HasFeature(const Preprocesso
   .Case("has_nothrow_copy", LangOpts.CPlusPlus)
   .Case("has_nothrow_constructor", LangOpts.CPlusPlus)
   .Case("has_trivial_assign", LangOpts.CPlusPlus)
+  .Case("has_trivial_move_assign", LangOpts.CPlusPlus)
   .Case("has_trivial_copy", LangOpts.CPlusPlus)
   .Case("has_trivial_constructor", LangOpts.CPlusPlus)
+  .Case("has_trivial_move_constructor", LangOpts.CPlusPlus)
   .Case("has_trivial_destructor", LangOpts.CPlusPlus)
   .Case("has_virtual_destructor", LangOpts.CPlusPlus)
   .Case("is_abstract", LangOpts.CPlusPlus)
@@ -1201,14 +1203,21 @@ static bool HasFeature(const Preprocesso
   .Case("is_class", LangOpts.CPlusPlus)
   .Case("is_constructible", LangOpts.CPlusPlus)
   .Case("is_convertible_to", LangOpts.CPlusPlus)
+  .Case("is_destructible",
+LangOpts.CPlusPlus &&LangOpts.MicrosoftExt)
   .Case("is_empty", LangOpts.CPlusPlus)
   .Case("is_enum", LangOpts.CPlusPlus)
   .Case("is_final", LangOpts.CPlusPlus)
   .Case("is_literal", LangOpts.CPlusPlus)
-  .Case("is_standard_layout", LangOpts.CPlusPlus)
+  .Case("is_nothrow_assignable", LangOpts.CPlusPlus)
+  .Case("is_nothrow_constructible", LangOpts.CPlusPlus)
+  .Case("is_nothrow_destructible",
+LangOpts.CPlusPlus && LangOpts.MicrosoftExt)
   .Case("is_pod", LangOpts.CPlusPlus)
   .Case("is_polymorphic", LangOpts.CPlusPlus)
-  .Case("is_sealed", LangOpts.MicrosoftExt)
+  .Case("is_sealed",
+LangOpts.CPlusPlus && LangOpts.MicrosoftExt)
+  .Case("is_standard_layout", LangOpts.CPlusPlus)
   .Case("is_trivial", LangOpts.CPlusPlus)
   .Case("is_trivially_assignable", LangOpts.CPlusPlus)
   .Case("is_trivially_constructible", LangOpts.CPlusPlus)

Modified: cfe/trunk/test/Lexer/has_feature_type_traits.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Lexer/has_feature_type_traits.cpp?rev=270580&r1=270579&r2=270580&view=diff
==
--- cfe/trunk/test/Lexer/has_feature_type_traits.cpp (original)
+++ cfe/trunk/test/Lexer/has_feature_type_traits.cpp Tue May 24 11:53:13 2016
@@ -20,6 +20,16 @@ int has_trivial_assign();
 #endif
 // CHECK: int has_trivial_assign();
 
+#if __has_feature(has_trivial_move_assign)
+int has_trivial_move_assign();
+#endif
+// CHECK: int has_trivial_move_assign();
+
+#if __has_feature(has_trivial_move_constructor)
+int has_trivial_move_constructor();
+#endif
+// CHECK: int has_trivial_move_constructor();
+
 #if __has_feature(has_trivial_copy)
 int has_trivial_copy();
 #endif
@@ -105,6 +115,16 @@ int is_literal();
 #endif
 // CHECK: int is_literal();
 
+#if __has_feature(is_nothrow_assignable)
+int is_nothrow_assignable();
+#endif
+// CHECK: int is_nothrow_assignable();
+
+#if __has_feature(is_nothrow_constructible)
+int is_nothrow_constructible();
+#endif
+// CHECK: int is_nothrow_constructible();
+
 #if __has_feature(is_standard_layout)
 int is_standard_layout();
 #endif


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


[clang-tools-extra] r270581 - [clang-tidy] Don't rely on being available.

2016-05-24 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Tue May 24 11:54:26 2016
New Revision: 270581

URL: http://llvm.org/viewvc/llvm-project?rev=270581&view=rev
Log:
[clang-tidy] Don't rely on  being available.

The STL isn't necessarily around when running tests. Make our own fake
std::array to test this.

Modified:
clang-tools-extra/trunk/test/clang-tidy/modernize-pass-by-value.cpp

Modified: clang-tools-extra/trunk/test/clang-tidy/modernize-pass-by-value.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-pass-by-value.cpp?rev=270581&r1=270580&r2=270581&view=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/modernize-pass-by-value.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-pass-by-value.cpp Tue May 
24 11:54:26 2016
@@ -1,8 +1,5 @@
 // RUN: %check_clang_tidy %s modernize-pass-by-value %t -- -- -std=c++11 
-fno-delayed-template-parsing
 
-// CHECK-FIXES: #include 
-#include 
-
 namespace {
 // POD types are trivially move constructible.
 struct Movable {
@@ -193,10 +190,12 @@ struct S {
   Movable M;
 };
 
+template  struct array { T A[N]; };
+
 // Test that types that are trivially copyable will not use std::move. This 
will
 // cause problems with misc-move-const-arg, as it will revert it.
 struct T {
-  T(std::array a) : a_(a) {}
-  // CHECK-FIXES: T(std::array a) : a_(a) {} 
-  std::array a_;
+  T(array a) : a_(a) {}
+  // CHECK-FIXES: T(array a) : a_(a) {}
+  array a_;
 };


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


Re: [clang-tools-extra] r270575 - [clang-tidy] modernize-pass-by-value bugfix. Reverting lit-style test

2016-05-24 Thread Renato Golin via cfe-commits
On 24 May 2016 at 17:09, Mads Ravn via cfe-commits
 wrote:
> Author: madsravn
> Date: Tue May 24 11:09:24 2016
> New Revision: 270575
>
> URL: http://llvm.org/viewvc/llvm-project?rev=270575&view=rev
> Log:
> [clang-tidy] modernize-pass-by-value bugfix. Reverting lit-style test

This seems to have done the trick, thanks!

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


Re: [PATCH] D18369: [OpenCL] Upstreaming khronos OpenCL header file.

2016-05-24 Thread Anastasia Stulova via cfe-commits
Anastasia added a comment.

Sam, there are a few small comments, otherwise it seems to be in a good shape.

@rsmith, do you think you could take a look here? The OpenCL side is fine, but 
I was just wondering if you see any issue with us adding a header of ~17K 
lines. It is all part of OpenCL standard libraries though and would be very 
helpful to have it upstream for all of us. Any suggestion on testing would be 
useful too as it's a bit simplified for now due to its size.



Comment at: lib/Headers/opencl-c.h:19
@@ +18,3 @@
+
+#define _ovld __attribute__((overloadable))
+

Could we change to ovld and cnfn with double underscores please?


Comment at: lib/Headers/opencl-c.h:143
@@ +142,3 @@
+#if __OPENCL_C_VERSION__ >= CL_VERSION_2_0
+#define NULL  ((void*)0)
+#endif

indentation seems wrong!


Comment at: lib/Headers/opencl-c.h:175
@@ +174,3 @@
+ */
+#define NAN as_float(INT_MAX)
+

Is this a part of spec? I don't see it in s6.13.2.1.


Comment at: lib/Headers/opencl-c.h:7953
@@ +7952,3 @@
+/**
+ * Compute the base e exponential of x.
+ */

Ping!


Comment at: lib/Headers/opencl-c.h:8307
@@ +8306,3 @@
+#else
+float _ovld fract(float x, __global float *iptr);
+float2 _ovld fract(float2 x, __global float2 *iptr);

Any problem with doing this unconditionally?


Comment at: lib/Headers/opencl-c.h:8458
@@ +8457,3 @@
+/**
+ * Compute the value of the square root of x^2+ y^2
+ * without undue overflow or underflow.

Ping!


Comment at: lib/Headers/opencl-c.h:12646
@@ +12645,3 @@
+/**
+ * Return sizeof (gentypen) bytes of data read
+ * from address (p + (offset * n)). The address

This description is missing explaining what gentype is! The same happens in 
other places too.


Comment at: lib/Headers/opencl-c.h:12773
@@ +12772,3 @@
+#ifdef cl_khr_fp16
+half _ovld vload(size_t offset, const half *p);
+half2 _ovld vload2(size_t offset, const half *p);

Ping!


Comment at: lib/Headers/opencl-c.h:14004
@@ +14003,3 @@
+
+// Builtin functions to_global, to_local, and to_private need to be declared 
as Clang builtin functions
+// and checked in Sema since they should be declared as

Formatting is wrong!


http://reviews.llvm.org/D18369



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


Re: [PATCH] D20328: [libcxx] Externally threaded libc++ variant

2016-05-24 Thread Ben Craig via cfe-commits
bcraig added a comment.

Note: You'll want to look at http://reviews.llvm.org/D20573, as there will be 
confilicts for whoever submits second.



Comment at: include/__threading_support:201
@@ +200,3 @@
+// Mutex
+#define _LIBCPP_MUTEX_INITIALIZER nullptr
+struct __libcpp_platform_mutex_t;

I'm not sure I like taking the freedom to define _LIBCPP_MUTEX_INITIALIZER away 
from implementers.

Would it be too terrible to replace this entire #elif block with something like 
the following?

```
#if !defined(__has_include) || __has_include()
#include 
#else
#error "_LIBCPP_THREAD_API_EXTERNAL requires the implementer to provide 
 in the include path"
#endif
```




http://reviews.llvm.org/D20328



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


Re: r270580 - [Lex] Support more type-traits in __has_feature

2016-05-24 Thread Richard Smith via cfe-commits
As I recall, this was intentional. The supported way to check for these is
has_builtin. The has_feature support is provided only for backwards
compatibility.
On 24 May 2016 9:59 a.m., "David Majnemer via cfe-commits" <
cfe-commits@lists.llvm.org> wrote:

> Author: majnemer
> Date: Tue May 24 11:53:13 2016
> New Revision: 270580
>
> URL: http://llvm.org/viewvc/llvm-project?rev=270580&view=rev
> Log:
> [Lex] Support more type-traits in __has_feature
>
> It looks like we forgot to update the __has_feature support when we
> added some of the type traits.
>
> Modified:
> cfe/trunk/lib/Lex/PPMacroExpansion.cpp
> cfe/trunk/test/Lexer/has_feature_type_traits.cpp
>
> Modified: cfe/trunk/lib/Lex/PPMacroExpansion.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPMacroExpansion.cpp?rev=270580&r1=270579&r2=270580&view=diff
>
> ==
> --- cfe/trunk/lib/Lex/PPMacroExpansion.cpp (original)
> +++ cfe/trunk/lib/Lex/PPMacroExpansion.cpp Tue May 24 11:53:13 2016
> @@ -1191,8 +1191,10 @@ static bool HasFeature(const Preprocesso
>.Case("has_nothrow_copy", LangOpts.CPlusPlus)
>.Case("has_nothrow_constructor", LangOpts.CPlusPlus)
>.Case("has_trivial_assign", LangOpts.CPlusPlus)
> +  .Case("has_trivial_move_assign", LangOpts.CPlusPlus)
>.Case("has_trivial_copy", LangOpts.CPlusPlus)
>.Case("has_trivial_constructor", LangOpts.CPlusPlus)
> +  .Case("has_trivial_move_constructor", LangOpts.CPlusPlus)
>.Case("has_trivial_destructor", LangOpts.CPlusPlus)
>.Case("has_virtual_destructor", LangOpts.CPlusPlus)
>.Case("is_abstract", LangOpts.CPlusPlus)
> @@ -1201,14 +1203,21 @@ static bool HasFeature(const Preprocesso
>.Case("is_class", LangOpts.CPlusPlus)
>.Case("is_constructible", LangOpts.CPlusPlus)
>.Case("is_convertible_to", LangOpts.CPlusPlus)
> +  .Case("is_destructible",
> +LangOpts.CPlusPlus &&LangOpts.MicrosoftExt)
>.Case("is_empty", LangOpts.CPlusPlus)
>.Case("is_enum", LangOpts.CPlusPlus)
>.Case("is_final", LangOpts.CPlusPlus)
>.Case("is_literal", LangOpts.CPlusPlus)
> -  .Case("is_standard_layout", LangOpts.CPlusPlus)
> +  .Case("is_nothrow_assignable", LangOpts.CPlusPlus)
> +  .Case("is_nothrow_constructible", LangOpts.CPlusPlus)
> +  .Case("is_nothrow_destructible",
> +LangOpts.CPlusPlus && LangOpts.MicrosoftExt)
>.Case("is_pod", LangOpts.CPlusPlus)
>.Case("is_polymorphic", LangOpts.CPlusPlus)
> -  .Case("is_sealed", LangOpts.MicrosoftExt)
> +  .Case("is_sealed",
> +LangOpts.CPlusPlus && LangOpts.MicrosoftExt)
> +  .Case("is_standard_layout", LangOpts.CPlusPlus)
>.Case("is_trivial", LangOpts.CPlusPlus)
>.Case("is_trivially_assignable", LangOpts.CPlusPlus)
>.Case("is_trivially_constructible", LangOpts.CPlusPlus)
>
> Modified: cfe/trunk/test/Lexer/has_feature_type_traits.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Lexer/has_feature_type_traits.cpp?rev=270580&r1=270579&r2=270580&view=diff
>
> ==
> --- cfe/trunk/test/Lexer/has_feature_type_traits.cpp (original)
> +++ cfe/trunk/test/Lexer/has_feature_type_traits.cpp Tue May 24 11:53:13
> 2016
> @@ -20,6 +20,16 @@ int has_trivial_assign();
>  #endif
>  // CHECK: int has_trivial_assign();
>
> +#if __has_feature(has_trivial_move_assign)
> +int has_trivial_move_assign();
> +#endif
> +// CHECK: int has_trivial_move_assign();
> +
> +#if __has_feature(has_trivial_move_constructor)
> +int has_trivial_move_constructor();
> +#endif
> +// CHECK: int has_trivial_move_constructor();
> +
>  #if __has_feature(has_trivial_copy)
>  int has_trivial_copy();
>  #endif
> @@ -105,6 +115,16 @@ int is_literal();
>  #endif
>  // CHECK: int is_literal();
>
> +#if __has_feature(is_nothrow_assignable)
> +int is_nothrow_assignable();
> +#endif
> +// CHECK: int is_nothrow_assignable();
> +
> +#if __has_feature(is_nothrow_constructible)
> +int is_nothrow_constructible();
> +#endif
> +// CHECK: int is_nothrow_constructible();
> +
>  #if __has_feature(is_standard_layout)
>  int is_standard_layout();
>  #endif
>
>
> ___
> 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


[PATCH] D20576: [Driver] Add support for -finline-functions and /Ob2 flags

2016-05-24 Thread Rudy Pons via cfe-commits
Ilod created this revision.
Ilod added a reviewer: hans.
Ilod added a subscriber: cfe-commits.

-finline-functions and /Ob2 are currently ignored by Clang. The only way to 
enable inlining is to use the global O flags, which also enable other options, 
or to emit LLVM bitcode using Clang, then running opt by hand with the inline 
pass.
This patch allows to simply use the -finline-functions flag (same as GCC) or 
/Ob2 in clang-cl mode to enable inlining without other optimizations.
This is the first patch of a serie to improve support for the /Ob flags.

http://reviews.llvm.org/D20576

Files:
  include/clang/Driver/CLCompatOptions.td
  include/clang/Driver/Options.td
  lib/Driver/Tools.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGen/inline-optim.c
  test/Driver/cl-options.c
  test/Driver/clang_f_opts.c

Index: test/Driver/clang_f_opts.c
===
--- test/Driver/clang_f_opts.c
+++ test/Driver/clang_f_opts.c
@@ -285,7 +285,6 @@
 // RUN: -fexpensive-optimizations \
 // RUN: -fno-expensive-optimizations  \
 // RUN: -fno-defer-pop\
-// RUN: -finline-functions\
 // RUN: -fkeep-inline-functions   \
 // RUN: -fno-keep-inline-functions\
 // RUN: -freorder-blocks  \
@@ -353,7 +352,6 @@
 // CHECK-WARNING-DAG: optimization flag '-fexpensive-optimizations' is not supported
 // CHECK-WARNING-DAG: optimization flag '-fno-expensive-optimizations' is not supported
 // CHECK-WARNING-DAG: optimization flag '-fno-defer-pop' is not supported
-// CHECK-WARNING-DAG: optimization flag '-finline-functions' is not supported
 // CHECK-WARNING-DAG: optimization flag '-fkeep-inline-functions' is not supported
 // CHECK-WARNING-DAG: optimization flag '-fno-keep-inline-functions' is not supported
 // CHECK-WARNING-DAG: optimization flag '-freorder-blocks' is not supported
Index: test/Driver/cl-options.c
===
--- test/Driver/cl-options.c
+++ test/Driver/cl-options.c
@@ -97,6 +97,9 @@
 // RUN: %clang_cl /Ob0 -### -- %s 2>&1 | FileCheck -check-prefix=Ob0 %s
 // Ob0: -fno-inline
 
+// RUN: %clang_cl /Ob2 -### -- %s 2>&1 | FileCheck -check-prefix=Ob2 %s
+// Ob2: -finline-functions
+
 // RUN: %clang_cl /Od -### -- %s 2>&1 | FileCheck -check-prefix=Od %s
 // Od: -O0
 
@@ -265,7 +268,6 @@
 // RUN:/kernel- \
 // RUN:/nologo \
 // RUN:/Ob1 \
-// RUN:/Ob2 \
 // RUN:/openmp- \
 // RUN:/RTC1 \
 // RUN:/sdl \
Index: test/CodeGen/inline-optim.c
===
--- test/CodeGen/inline-optim.c
+++ test/CodeGen/inline-optim.c
@@ -0,0 +1,26 @@
+// Make sure -finline-functions family flags are behaving correctly.
+
+// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck -check-prefix=NOINLINE %s
+// RUN: %clang_cc1 -O3 -fno-inline-functions -emit-llvm %s -o - | FileCheck -check-prefix=NOINLINE %s
+// RUN: %clang_cc1 -finline-functions -emit-llvm %s -o - | FileCheck -check-prefix=INLINE %s
+
+inline int inline_hint(int a, int b) { return(a+b); }
+
+int inline_no_hint(int a, int b) { return (a/b); }
+
+inline __attribute__ ((__always_inline__)) int inline_always(int a, int b) { return(a*b); }
+
+volatile int *pa = (int*) 0x1000;
+void foo() {
+// NOINLINE: @foo
+// INLINE: @foo
+// NOINLINE: inline_hint
+// INLINE-NOT: inline_hint
+pa[0] = inline_hint(pa[1],pa[2]);	
+// NOINLINE-NOT: inline_always
+// INLINE-NOT: inline_always
+pa[3] = inline_always(pa[4],pa[5]);
+// NOINLINE: inline_no_hint
+// INLINE-NOT: inline_no_hint
+pa[6] = inline_no_hint(pa[7], pa[8]);
+}
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -441,8 +441,10 @@
  : CodeGenOptions::OnlyAlwaysInlining);
   // -fno-inline-functions overrides OptimizationLevel > 1.
   Opts.NoInline = Args.hasArg(OPT_fno_inline);
-  Opts.setInlining(Args.hasArg(OPT_fno_inline_functions) ?
- CodeGenOptions::OnlyAlwaysInlining : Opts.getInlining());
+  if (Arg* InlineArg = Args.getLastArg(options::OPT_finline_functions, options::OPT_fno_inline_functions)) {
+Opts.setInlining(InlineArg->getOption().matches(options::OPT_finline_functions) ?
+CodeGenOptions::NormalInlining : CodeGenOptions::OnlyAlwaysInlining);
+  }
 
   if (Arg *A = Args.getLastArg(OPT_fveclib)) {
 StringRef Name = A->getValue();
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -5332,8 +5332,10 @@
   if 

Re: [clang-tools-extra] r270575 - [clang-tidy] modernize-pass-by-value bugfix. Reverting lit-style test

2016-05-24 Thread Mads Ravn via cfe-commits
I'm glad. I'm finally getting the hang of this (I think) :)

Best regards,
Mads Ravn

On Tue, May 24, 2016 at 7:01 PM Renato Golin 
wrote:

> On 24 May 2016 at 17:09, Mads Ravn via cfe-commits
>  wrote:
> > Author: madsravn
> > Date: Tue May 24 11:09:24 2016
> > New Revision: 270575
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=270575&view=rev
> > Log:
> > [clang-tidy] modernize-pass-by-value bugfix. Reverting lit-style test
>
> This seems to have done the trick, thanks!
>
> --renato
>
___
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-05-24 Thread Jan Vesely via cfe-commits
jvesely added inline comments.


Comment at: test/SemaOpenCL/extension-version.cl:11
@@ +10,3 @@
+#endif
+#pragma OPENCL EXTENSION cl_clang_storage_class_specifiers: enable
+

Anastasia wrote:
> Could you use standard diagnostic check please:
>   expected-warning{{unknown OpenCL extension ...
> 
> Similarly to SemaOpenCL/extensions.cl
not sure I follow, the test does not trigger any diagnostics (by design).
are you saying that I should introduce negative checks to make sure extensions 
are not available outside of their respective context?
Is there a way to filter verifier tags based on clang invocation? (something 
like FileCheck prefix)


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: r270580 - [Lex] Support more type-traits in __has_feature

2016-05-24 Thread Richard Smith via cfe-commits
On 24 May 2016 10:15 a.m., "Richard Smith"  wrote:
>
> As I recall, this was intentional. The supported way to check for these
is has_builtin. The has_feature support is provided only for backwards
compatibility.

See documentation here:
http://clang.llvm.org/docs/LanguageExtensions.html#checks-for-type-trait-primitives

These should be covered only by has_extension, not by has_feature.

> On 24 May 2016 9:59 a.m., "David Majnemer via cfe-commits" <
cfe-commits@lists.llvm.org> wrote:
>>
>> Author: majnemer
>> Date: Tue May 24 11:53:13 2016
>> New Revision: 270580
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=270580&view=rev
>> Log:
>> [Lex] Support more type-traits in __has_feature
>>
>> It looks like we forgot to update the __has_feature support when we
>> added some of the type traits.
>>
>> Modified:
>> cfe/trunk/lib/Lex/PPMacroExpansion.cpp
>> cfe/trunk/test/Lexer/has_feature_type_traits.cpp
>>
>> Modified: cfe/trunk/lib/Lex/PPMacroExpansion.cpp
>> URL:
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPMacroExpansion.cpp?rev=270580&r1=270579&r2=270580&view=diff
>>
==
>> --- cfe/trunk/lib/Lex/PPMacroExpansion.cpp (original)
>> +++ cfe/trunk/lib/Lex/PPMacroExpansion.cpp Tue May 24 11:53:13 2016
>> @@ -1191,8 +1191,10 @@ static bool HasFeature(const Preprocesso
>>.Case("has_nothrow_copy", LangOpts.CPlusPlus)
>>.Case("has_nothrow_constructor", LangOpts.CPlusPlus)
>>.Case("has_trivial_assign", LangOpts.CPlusPlus)
>> +  .Case("has_trivial_move_assign", LangOpts.CPlusPlus)
>>.Case("has_trivial_copy", LangOpts.CPlusPlus)
>>.Case("has_trivial_constructor", LangOpts.CPlusPlus)
>> +  .Case("has_trivial_move_constructor", LangOpts.CPlusPlus)
>>.Case("has_trivial_destructor", LangOpts.CPlusPlus)
>>.Case("has_virtual_destructor", LangOpts.CPlusPlus)
>>.Case("is_abstract", LangOpts.CPlusPlus)
>> @@ -1201,14 +1203,21 @@ static bool HasFeature(const Preprocesso
>>.Case("is_class", LangOpts.CPlusPlus)
>>.Case("is_constructible", LangOpts.CPlusPlus)
>>.Case("is_convertible_to", LangOpts.CPlusPlus)
>> +  .Case("is_destructible",
>> +LangOpts.CPlusPlus &&LangOpts.MicrosoftExt)
>>.Case("is_empty", LangOpts.CPlusPlus)
>>.Case("is_enum", LangOpts.CPlusPlus)
>>.Case("is_final", LangOpts.CPlusPlus)
>>.Case("is_literal", LangOpts.CPlusPlus)
>> -  .Case("is_standard_layout", LangOpts.CPlusPlus)
>> +  .Case("is_nothrow_assignable", LangOpts.CPlusPlus)
>> +  .Case("is_nothrow_constructible", LangOpts.CPlusPlus)
>> +  .Case("is_nothrow_destructible",
>> +LangOpts.CPlusPlus && LangOpts.MicrosoftExt)
>>.Case("is_pod", LangOpts.CPlusPlus)
>>.Case("is_polymorphic", LangOpts.CPlusPlus)
>> -  .Case("is_sealed", LangOpts.MicrosoftExt)
>> +  .Case("is_sealed",
>> +LangOpts.CPlusPlus && LangOpts.MicrosoftExt)
>> +  .Case("is_standard_layout", LangOpts.CPlusPlus)
>>.Case("is_trivial", LangOpts.CPlusPlus)
>>.Case("is_trivially_assignable", LangOpts.CPlusPlus)
>>.Case("is_trivially_constructible", LangOpts.CPlusPlus)
>>
>> Modified: cfe/trunk/test/Lexer/has_feature_type_traits.cpp
>> URL:
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Lexer/has_feature_type_traits.cpp?rev=270580&r1=270579&r2=270580&view=diff
>>
==
>> --- cfe/trunk/test/Lexer/has_feature_type_traits.cpp (original)
>> +++ cfe/trunk/test/Lexer/has_feature_type_traits.cpp Tue May 24 11:53:13
2016
>> @@ -20,6 +20,16 @@ int has_trivial_assign();
>>  #endif
>>  // CHECK: int has_trivial_assign();
>>
>> +#if __has_feature(has_trivial_move_assign)
>> +int has_trivial_move_assign();
>> +#endif
>> +// CHECK: int has_trivial_move_assign();
>> +
>> +#if __has_feature(has_trivial_move_constructor)
>> +int has_trivial_move_constructor();
>> +#endif
>> +// CHECK: int has_trivial_move_constructor();
>> +
>>  #if __has_feature(has_trivial_copy)
>>  int has_trivial_copy();
>>  #endif
>> @@ -105,6 +115,16 @@ int is_literal();
>>  #endif
>>  // CHECK: int is_literal();
>>
>> +#if __has_feature(is_nothrow_assignable)
>> +int is_nothrow_assignable();
>> +#endif
>> +// CHECK: int is_nothrow_assignable();
>> +
>> +#if __has_feature(is_nothrow_constructible)
>> +int is_nothrow_constructible();
>> +#endif
>> +// CHECK: int is_nothrow_constructible();
>> +
>>  #if __has_feature(is_standard_layout)
>>  int is_standard_layout();
>>  #endif
>>
>>
>> ___
>> 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


r270583 - Revert "[Lex] Support more type-traits in __has_feature"

2016-05-24 Thread David Majnemer via cfe-commits
Author: majnemer
Date: Tue May 24 12:21:42 2016
New Revision: 270583

URL: http://llvm.org/viewvc/llvm-project?rev=270583&view=rev
Log:
Revert "[Lex] Support more type-traits in __has_feature"

This reverts commit r270580.  Using __has_feature to test for
type-traits is deprecated.

Modified:
cfe/trunk/lib/Lex/PPMacroExpansion.cpp
cfe/trunk/test/Lexer/has_feature_type_traits.cpp

Modified: cfe/trunk/lib/Lex/PPMacroExpansion.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPMacroExpansion.cpp?rev=270583&r1=270582&r2=270583&view=diff
==
--- cfe/trunk/lib/Lex/PPMacroExpansion.cpp (original)
+++ cfe/trunk/lib/Lex/PPMacroExpansion.cpp Tue May 24 12:21:42 2016
@@ -1187,37 +1187,29 @@ static bool HasFeature(const Preprocesso
   // FIXME: Should this be __has_feature or __has_extension?
   //.Case("raw_invocation_type", LangOpts.CPlusPlus)
   // Type traits
+  // N.B. Additional type traits should not be added to the following list.
+  // Instead, they should be detected by has_extension.
   .Case("has_nothrow_assign", LangOpts.CPlusPlus)
   .Case("has_nothrow_copy", LangOpts.CPlusPlus)
   .Case("has_nothrow_constructor", LangOpts.CPlusPlus)
   .Case("has_trivial_assign", LangOpts.CPlusPlus)
-  .Case("has_trivial_move_assign", LangOpts.CPlusPlus)
   .Case("has_trivial_copy", LangOpts.CPlusPlus)
   .Case("has_trivial_constructor", LangOpts.CPlusPlus)
-  .Case("has_trivial_move_constructor", LangOpts.CPlusPlus)
   .Case("has_trivial_destructor", LangOpts.CPlusPlus)
   .Case("has_virtual_destructor", LangOpts.CPlusPlus)
   .Case("is_abstract", LangOpts.CPlusPlus)
-  .Case("is_assignable", LangOpts.CPlusPlus)
   .Case("is_base_of", LangOpts.CPlusPlus)
   .Case("is_class", LangOpts.CPlusPlus)
   .Case("is_constructible", LangOpts.CPlusPlus)
   .Case("is_convertible_to", LangOpts.CPlusPlus)
-  .Case("is_destructible",
-LangOpts.CPlusPlus &&LangOpts.MicrosoftExt)
   .Case("is_empty", LangOpts.CPlusPlus)
   .Case("is_enum", LangOpts.CPlusPlus)
   .Case("is_final", LangOpts.CPlusPlus)
   .Case("is_literal", LangOpts.CPlusPlus)
-  .Case("is_nothrow_assignable", LangOpts.CPlusPlus)
-  .Case("is_nothrow_constructible", LangOpts.CPlusPlus)
-  .Case("is_nothrow_destructible",
-LangOpts.CPlusPlus && LangOpts.MicrosoftExt)
+  .Case("is_standard_layout", LangOpts.CPlusPlus)
   .Case("is_pod", LangOpts.CPlusPlus)
   .Case("is_polymorphic", LangOpts.CPlusPlus)
-  .Case("is_sealed",
-LangOpts.CPlusPlus && LangOpts.MicrosoftExt)
-  .Case("is_standard_layout", LangOpts.CPlusPlus)
+  .Case("is_sealed", LangOpts.CPlusPlus && LangOpts.MicrosoftExt)
   .Case("is_trivial", LangOpts.CPlusPlus)
   .Case("is_trivially_assignable", LangOpts.CPlusPlus)
   .Case("is_trivially_constructible", LangOpts.CPlusPlus)

Modified: cfe/trunk/test/Lexer/has_feature_type_traits.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Lexer/has_feature_type_traits.cpp?rev=270583&r1=270582&r2=270583&view=diff
==
--- cfe/trunk/test/Lexer/has_feature_type_traits.cpp (original)
+++ cfe/trunk/test/Lexer/has_feature_type_traits.cpp Tue May 24 12:21:42 2016
@@ -20,16 +20,6 @@ int has_trivial_assign();
 #endif
 // CHECK: int has_trivial_assign();
 
-#if __has_feature(has_trivial_move_assign)
-int has_trivial_move_assign();
-#endif
-// CHECK: int has_trivial_move_assign();
-
-#if __has_feature(has_trivial_move_constructor)
-int has_trivial_move_constructor();
-#endif
-// CHECK: int has_trivial_move_constructor();
-
 #if __has_feature(has_trivial_copy)
 int has_trivial_copy();
 #endif
@@ -55,11 +45,6 @@ int is_abstract();
 #endif
 // CHECK: int is_abstract();
 
-#if __has_feature(is_assignable)
-int is_assignable();
-#endif
-// CHECK: int is_assignable();
-
 #if __has_feature(is_base_of)
 int is_base_of();
 #endif
@@ -115,16 +100,6 @@ int is_literal();
 #endif
 // CHECK: int is_literal();
 
-#if __has_feature(is_nothrow_assignable)
-int is_nothrow_assignable();
-#endif
-// CHECK: int is_nothrow_assignable();
-
-#if __has_feature(is_nothrow_constructible)
-int is_nothrow_constructible();
-#endif
-// CHECK: int is_nothrow_constructible();
-
 #if __has_feature(is_standard_layout)
 int is_standard_layout();
 #endif


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


Re: r270580 - [Lex] Support more type-traits in __has_feature

2016-05-24 Thread David Majnemer via cfe-commits
Done with r270583, I added a note in a comment to avoid this situation in
the future.

On Tue, May 24, 2016 at 10:26 AM, Richard Smith 
wrote:

> On 24 May 2016 10:15 a.m., "Richard Smith"  wrote:
> >
> > As I recall, this was intentional. The supported way to check for these
> is has_builtin. The has_feature support is provided only for backwards
> compatibility.
>
> See documentation here:
>
> http://clang.llvm.org/docs/LanguageExtensions.html#checks-for-type-trait-primitives
>
> These should be covered only by has_extension, not by has_feature.
>
> > On 24 May 2016 9:59 a.m., "David Majnemer via cfe-commits" <
> cfe-commits@lists.llvm.org> wrote:
> >>
> >> Author: majnemer
> >> Date: Tue May 24 11:53:13 2016
> >> New Revision: 270580
> >>
> >> URL: http://llvm.org/viewvc/llvm-project?rev=270580&view=rev
> >> Log:
> >> [Lex] Support more type-traits in __has_feature
> >>
> >> It looks like we forgot to update the __has_feature support when we
> >> added some of the type traits.
> >>
> >> Modified:
> >> cfe/trunk/lib/Lex/PPMacroExpansion.cpp
> >> cfe/trunk/test/Lexer/has_feature_type_traits.cpp
> >>
> >> Modified: cfe/trunk/lib/Lex/PPMacroExpansion.cpp
> >> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPMacroExpansion.cpp?rev=270580&r1=270579&r2=270580&view=diff
> >>
> ==
> >> --- cfe/trunk/lib/Lex/PPMacroExpansion.cpp (original)
> >> +++ cfe/trunk/lib/Lex/PPMacroExpansion.cpp Tue May 24 11:53:13 2016
> >> @@ -1191,8 +1191,10 @@ static bool HasFeature(const Preprocesso
> >>.Case("has_nothrow_copy", LangOpts.CPlusPlus)
> >>.Case("has_nothrow_constructor", LangOpts.CPlusPlus)
> >>.Case("has_trivial_assign", LangOpts.CPlusPlus)
> >> +  .Case("has_trivial_move_assign", LangOpts.CPlusPlus)
> >>.Case("has_trivial_copy", LangOpts.CPlusPlus)
> >>.Case("has_trivial_constructor", LangOpts.CPlusPlus)
> >> +  .Case("has_trivial_move_constructor", LangOpts.CPlusPlus)
> >>.Case("has_trivial_destructor", LangOpts.CPlusPlus)
> >>.Case("has_virtual_destructor", LangOpts.CPlusPlus)
> >>.Case("is_abstract", LangOpts.CPlusPlus)
> >> @@ -1201,14 +1203,21 @@ static bool HasFeature(const Preprocesso
> >>.Case("is_class", LangOpts.CPlusPlus)
> >>.Case("is_constructible", LangOpts.CPlusPlus)
> >>.Case("is_convertible_to", LangOpts.CPlusPlus)
> >> +  .Case("is_destructible",
> >> +LangOpts.CPlusPlus &&LangOpts.MicrosoftExt)
> >>.Case("is_empty", LangOpts.CPlusPlus)
> >>.Case("is_enum", LangOpts.CPlusPlus)
> >>.Case("is_final", LangOpts.CPlusPlus)
> >>.Case("is_literal", LangOpts.CPlusPlus)
> >> -  .Case("is_standard_layout", LangOpts.CPlusPlus)
> >> +  .Case("is_nothrow_assignable", LangOpts.CPlusPlus)
> >> +  .Case("is_nothrow_constructible", LangOpts.CPlusPlus)
> >> +  .Case("is_nothrow_destructible",
> >> +LangOpts.CPlusPlus && LangOpts.MicrosoftExt)
> >>.Case("is_pod", LangOpts.CPlusPlus)
> >>.Case("is_polymorphic", LangOpts.CPlusPlus)
> >> -  .Case("is_sealed", LangOpts.MicrosoftExt)
> >> +  .Case("is_sealed",
> >> +LangOpts.CPlusPlus && LangOpts.MicrosoftExt)
> >> +  .Case("is_standard_layout", LangOpts.CPlusPlus)
> >>.Case("is_trivial", LangOpts.CPlusPlus)
> >>.Case("is_trivially_assignable", LangOpts.CPlusPlus)
> >>.Case("is_trivially_constructible", LangOpts.CPlusPlus)
> >>
> >> Modified: cfe/trunk/test/Lexer/has_feature_type_traits.cpp
> >> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Lexer/has_feature_type_traits.cpp?rev=270580&r1=270579&r2=270580&view=diff
> >>
> ==
> >> --- cfe/trunk/test/Lexer/has_feature_type_traits.cpp (original)
> >> +++ cfe/trunk/test/Lexer/has_feature_type_traits.cpp Tue May 24
> 11:53:13 2016
> >> @@ -20,6 +20,16 @@ int has_trivial_assign();
> >>  #endif
> >>  // CHECK: int has_trivial_assign();
> >>
> >> +#if __has_feature(has_trivial_move_assign)
> >> +int has_trivial_move_assign();
> >> +#endif
> >> +// CHECK: int has_trivial_move_assign();
> >> +
> >> +#if __has_feature(has_trivial_move_constructor)
> >> +int has_trivial_move_constructor();
> >> +#endif
> >> +// CHECK: int has_trivial_move_constructor();
> >> +
> >>  #if __has_feature(has_trivial_copy)
> >>  int has_trivial_copy();
> >>  #endif
> >> @@ -105,6 +115,16 @@ int is_literal();
> >>  #endif
> >>  // CHECK: int is_literal();
> >>
> >> +#if __has_feature(is_nothrow_assignable)
> >> +int is_nothrow_assignable();
> >> +#endif
> >> +// CHECK: int is_nothrow_assignable();
> >> +
> >> +#if __has_feature(is_nothrow_constructible)
> >> +int is_nothrow_constructible();
> >> +#endif
> >> +// CHECK: int is_nothrow_constructible();
> >> +
> >>  #if __has_feature(is_standard_layout)
> >>  int is_standard_layout();
> >>  #endif

[PATCH] D20581: [include-fixer] Simplify the code since we won't handle multiple includes at once.

2016-05-24 Thread Haojian Wu via cfe-commits
hokein created this revision.
hokein added a reviewer: bkramer.
hokein added a subscriber: cfe-commits.

http://reviews.llvm.org/D20581

Files:
  include-fixer/IncludeFixer.cpp

Index: include-fixer/IncludeFixer.cpp
===
--- include-fixer/IncludeFixer.cpp
+++ include-fixer/IncludeFixer.cpp
@@ -282,64 +282,46 @@
clang::HeaderSearch &HeaderSearch,
std::set &Headers,
std::vector &Replacements) {
-if (Untried.empty())
+if (SymbolQueryResults.empty())
   return false;
 
-const auto &ToTry = UntriedList.front();
+// FIXME: Rank the results and pick the best one instead of the first one.
+const auto &ToTry = SymbolQueryResults.front();
 Headers.insert(minimizeInclude(ToTry, SourceManager, HeaderSearch));
 
 StringRef Code = 
SourceManager.getBufferData(SourceManager.getMainFileID());
 Replacements = CreateReplacementsForHeaders(Code, Headers);
 
 // We currently abort after the first inserted include. The more
 // includes we have the less safe this becomes due to error recovery
 // changing the results.
-// FIXME: Handle multiple includes at once.
 return true;
   }
 
   /// Sets the location at the very top of the file.
   void setFileBegin(clang::SourceLocation Location) { FileBegin = Location; }
 
-  /// Add an include to the set of includes to try.
-  /// \param include_path The include path to try.
-  void TryInclude(const std::string &query, const std::string &include_path) {
-if (Untried.insert(include_path).second)
-  UntriedList.push_back(include_path);
-  }
-
 private:
   /// Query the database for a given identifier.
   bool query(StringRef Query, SourceLocation Loc) {
 assert(!Query.empty() && "Empty query!");
 
-// Save database lookups by not looking up identifiers multiple times.
-if (!SeenQueries.insert(Query).second)
-  return true;
+// Skip other identifers once we have discovered an identfier successfully.
+if (!SymbolQueryResults.empty())
+  return false;
 
 DEBUG(llvm::dbgs() << "Looking up '" << Query << "' at ");
 DEBUG(Loc.print(llvm::dbgs(), getCompilerInstance().getSourceManager()));
 DEBUG(llvm::dbgs() << " ...");
 
-std::string error_text;
-auto SearchReply = SymbolIndexMgr.search(Query);
-DEBUG(llvm::dbgs() << SearchReply.size() << " replies\n");
-if (SearchReply.empty())
-  return false;
-
-// Add those files to the set of includes to try out.
-// FIXME: Rank the results and pick the best one instead of the first one.
-TryInclude(Query, SearchReply[0]);
-
-return true;
+SymbolQueryResults = SymbolIndexMgr.search(Query);
+DEBUG(llvm::dbgs() << SymbolQueryResults.size() << " replies\n");
+return !SymbolQueryResults.empty();
   }
 
   /// The client to use to find cross-references.
   SymbolIndexManager &SymbolIndexMgr;
 
-  // Remeber things we looked up to avoid querying things twice.
-  llvm::StringSet<> SeenQueries;
-
   /// The absolute path to the file being processed.
   std::string Filename;
 
@@ -354,11 +336,9 @@
   /// clang-format config file found.
   std::string FallbackStyle;
 
-  /// Includes we have left to try. A set to unique them and a list to keep
-  /// track of the order. We prefer includes that were discovered early to 
avoid
-  /// getting caught in results from error recovery.
-  std::set Untried;
-  std::vector UntriedList;
+  /// The query results of an identifier. We only include the first discovered
+  /// identifier to avoid getting caught in results from error recovery.
+  std::vector SymbolQueryResults;
 
   /// Whether we should use the smallest possible include path.
   bool MinimizeIncludePaths = true;


Index: include-fixer/IncludeFixer.cpp
===
--- include-fixer/IncludeFixer.cpp
+++ include-fixer/IncludeFixer.cpp
@@ -282,64 +282,46 @@
clang::HeaderSearch &HeaderSearch,
std::set &Headers,
std::vector &Replacements) {
-if (Untried.empty())
+if (SymbolQueryResults.empty())
   return false;
 
-const auto &ToTry = UntriedList.front();
+// FIXME: Rank the results and pick the best one instead of the first one.
+const auto &ToTry = SymbolQueryResults.front();
 Headers.insert(minimizeInclude(ToTry, SourceManager, HeaderSearch));
 
 StringRef Code = SourceManager.getBufferData(SourceManager.getMainFileID());
 Replacements = CreateReplacementsForHeaders(Code, Headers);
 
 // We currently abort after the first inserted include. The more
 // includes we have the less safe this becomes due to error recovery
 // changing the results.
-// FIXME: Handle multiple includes at once.
 return true;
   }
 
   /// Sets the location at the very top of the file.
   void setFileBegin(clang::SourceLocation Location) { FileBegin = Location; }
 
-  /// Add

Re: [PATCH] D20334: [libcxx] Fix a bug in strstreambuf::overflow

2016-05-24 Thread Akira Hatanaka via cfe-commits
ping.

> On May 17, 2016, at 12:20 PM, Akira Hatanaka via cfe-commits 
>  wrote:
> 
> ahatanak created this revision.
> ahatanak added reviewers: mclow.lists, EricWF, howard.hinnant.
> ahatanak added a subscriber: cfe-commits.
> 
> The end pointer should point to one past the end of the newly allocated 
> buffer.
> 
> Without this fix, asan reports an error when the following code is compiled 
> and executed:
> 
> $ cat test.cpp
> 
> ```
> std::string stringOfLength(const size_t length) {
>  std::string s("");
> 
>  std::string characters("abcdefghijklmnopqrstuvwxyz0123456789+-*/");
>  for (size_t i = 0; i < length; ++i) {
>s += characters[i % characters.size()];
>  }
> 
>  return s;
> }
> 
> int main(int, char const **argv) {
>  std::ostrstream oss;
> 
>  oss << stringOfLength(atoi(argv[1])) << std::ends;
>  std::cout << oss.str();
>  oss.freeze(false);
> 
>  return 0;
> }```
> 
> $ clang++  -fsanitize=address test.cpp && ./a.out 4096
> ==18970==ERROR: AddressSanitizer: heap-buffer-overflow on address 
> 0x6211dd00 at pc 0x00010277c45d bp 0x7fff5d4ce6e0 sp 0x7fff5d4cdea0
> READ of size 4097 at 0x6211dd00 thread T0
>#0 0x10277c45c in wrap_strlen (libclang_rt.asan_osx_dynamic.dylib+0x4345c)
>#1 0x102733954 in std::__1::char_traits::length(char const*) 
> (a.out+0x12954)
>#2 0x10273390b in std::__1::basic_ostream std::__1::char_traits >& 
> std::__1::operator<< 
> >(std::__1::basic_ostream >&, char const*) 
> (a.out+0x1290b)
>#3 0x102733346 in main (a.out+0x12346)
>#4 0x7fff901905ac in start (libdyld.dylib+0x35ac)
>#5 0x1  ()
> 
> 0x6211dd00 is located 0 bytes to the right of 4096-byte region 
> [0x6211cd00,0x6211dd00)
> allocated by thread T0 here:
>#0 0x10278d42b in wrap__Znam (libclang_rt.asan_osx_dynamic.dylib+0x5442b)
>#1 0x7fff9bdc9fa1 in std::__1::strstreambuf::overflow(int) 
> (libc++.1.dylib+0x44fa1)
>#2 0x7fff9bd901cc in std::__1::basic_streambuf std::__1::char_traits >::xsputn(char const*, long) 
> (libc++.1.dylib+0xb1cc)
>#3 0x10273547c in std::__1::ostreambuf_iterator std::__1::char_traits > std::__1::__pad_and_output std::__1::char_traits >(std::__1::ostreambuf_iterator std::__1::char_traits >, char const*, char const*, char const*, 
> std::__1::ios_base&, char) (a.out+0x1447c)
>#4 0x102734312 in std::__1::basic_ostream std::__1::char_traits >& std::__1::__put_character_sequence std::__1::char_traits >(std::__1::basic_ostream std::__1::char_traits >&, char const*, unsigned long) 
> (a.out+0x13312)
>#5 0x10273389d in std::__1::basic_ostream std::__1::char_traits >& std::__1::operator<< std::__1::char_traits, std::__1::allocator 
> >(std::__1::basic_ostream >&, 
> std::__1::basic_string, 
> std::__1::allocator > const&) (a.out+0x1289d)
>#6 0x1027332c4 in main (a.out+0x122c4)
>#7 0x7fff901905ac in start (libdyld.dylib+0x35ac)
>#8 0x1  ()
> 
> http://reviews.llvm.org/D20334
> 
> Files:
>  src/strstream.cpp
> 
> Index: src/strstream.cpp
> ===
> --- src/strstream.cpp
> +++ src/strstream.cpp
> @@ -180,7 +180,7 @@
> delete [] eback();
> }
> setg(buf, buf + ninp, buf + einp);
> -setp(buf + einp, buf + einp + eout);
> +setp(buf + einp, buf + new_size);
> pbump(static_cast(nout));
> __strmode_ |= __allocated;
> }
> 
> 
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

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


Re: [PATCH] D20334: [libcxx] Fix a bug in strstreambuf::overflow

2016-05-24 Thread Ben Craig via cfe-commits
bcraig added a subscriber: bcraig.
bcraig added a comment.

I don't believe this is a libcxx bug, but it is a bug in the test code.  
oss.str(); isn't required to return a null terminated string.  std::cout << 
(char *) requires a null terminated string though.


http://reviews.llvm.org/D20334



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


Re: [PATCH] D20576: [Driver] Add support for -finline-functions and /Ob2 flags

2016-05-24 Thread Hans Wennborg via cfe-commits
hans added a comment.

Thanks! Some comments below:



Comment at: lib/Driver/Tools.cpp:5335
@@ -5334,3 +5334,3 @@
 
-  if (Args.hasArg(options::OPT_fno_inline_functions))
-CmdArgs.push_back("-fno-inline-functions");
+  if (Arg* InlineArg = Args.getLastArg(options::OPT_finline_functions, 
options::OPT_fno_inline_functions)) {
+
CmdArgs.push_back(InlineArg->getOption().matches(options::OPT_finline_functions)
 ?

Please line break this; lines should be <= 80 columns wide.


Comment at: lib/Driver/Tools.cpp:5337
@@ +5336,3 @@
+
CmdArgs.push_back(InlineArg->getOption().matches(options::OPT_finline_functions)
 ?
+"-finline-functions" : "-fno-inline-functions");
+  }

I think this can be:

```
InlineArg->render(Args, CmdArgs)
```
instead


Comment at: lib/Frontend/CompilerInvocation.cpp:446
@@ +445,3 @@
+
Opts.setInlining(InlineArg->getOption().matches(options::OPT_finline_functions) 
?
+CodeGenOptions::NormalInlining : CodeGenOptions::OnlyAlwaysInlining);
+  }

This line and 444 need line breaks too.


Comment at: test/CodeGen/inline-optim.c:16
@@ +15,3 @@
+// NOINLINE: @foo
+// INLINE: @foo
+// NOINLINE: inline_hint

I'd suggest using "check-label" for the @foo checks. See 
http://llvm.org/docs/CommandGuide/FileCheck.html#the-check-label-directive


Comment at: test/CodeGen/inline-optim.c:24
@@ +23,3 @@
+// NOINLINE: inline_no_hint
+// INLINE-NOT: inline_no_hint
+pa[6] = inline_no_hint(pa[7], pa[8]);

For all these checks, I'd suggest matching e.g.

 "call i32 @inline_hint"

to make it a little easier to see what' being matched for. I suppose your 
checks could match either the calls, or the definitions of the called function.


http://reviews.llvm.org/D20576



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


r270591 - [RecordLayout] Use an ASTVector instead of using a separate pointer and counter

2016-05-24 Thread David Majnemer via cfe-commits
Author: majnemer
Date: Tue May 24 13:10:50 2016
New Revision: 270591

URL: http://llvm.org/viewvc/llvm-project?rev=270591&view=rev
Log:
[RecordLayout] Use an ASTVector instead of using a separate pointer and counter

No functional change is intended.

Modified:
cfe/trunk/include/clang/AST/RecordLayout.h
cfe/trunk/lib/AST/RecordLayout.cpp
cfe/trunk/lib/AST/RecordLayoutBuilder.cpp

Modified: cfe/trunk/include/clang/AST/RecordLayout.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/RecordLayout.h?rev=270591&r1=270590&r2=270591&view=diff
==
--- cfe/trunk/include/clang/AST/RecordLayout.h (original)
+++ cfe/trunk/include/clang/AST/RecordLayout.h Tue May 24 13:10:50 2016
@@ -71,10 +71,7 @@ private:
   CharUnits RequiredAlignment;
 
   /// FieldOffsets - Array of field offsets in bits.
-  uint64_t *FieldOffsets;
-
-  // FieldCount - Number of fields.
-  unsigned FieldCount;
+  ASTVector FieldOffsets;
 
   /// CXXRecordLayoutInfo - Contains C++ specific layout information.
   struct CXXRecordLayoutInfo {
@@ -136,9 +133,8 @@ private:
   friend class ASTContext;
 
   ASTRecordLayout(const ASTContext &Ctx, CharUnits size, CharUnits alignment,
-  CharUnits requiredAlignment,
-  CharUnits datasize, const uint64_t *fieldoffsets,
-  unsigned fieldcount);
+  CharUnits requiredAlignment, CharUnits datasize,
+  ArrayRef fieldoffsets);
 
   // Constructor for C++ records.
   typedef CXXRecordLayoutInfo::BaseOffsetsMapTy BaseOffsetsMapTy;
@@ -148,7 +144,7 @@ private:
   bool hasOwnVFPtr, bool hasExtendableVFPtr,
   CharUnits vbptroffset,
   CharUnits datasize,
-  const uint64_t *fieldoffsets, unsigned fieldcount,
+  ArrayRef fieldoffsets,
   CharUnits nonvirtualsize, CharUnits nonvirtualalignment,
   CharUnits SizeOfLargestEmptySubobject,
   const CXXRecordDecl *PrimaryBase,
@@ -174,12 +170,11 @@ public:
   CharUnits getSize() const { return Size; }
 
   /// getFieldCount - Get the number of fields in the layout.
-  unsigned getFieldCount() const { return FieldCount; }
+  unsigned getFieldCount() const { return FieldOffsets.size(); }
 
   /// getFieldOffset - Get the offset of the given field index, in
   /// bits.
   uint64_t getFieldOffset(unsigned FieldNo) const {
-assert (FieldNo < FieldCount && "Invalid Field No");
 return FieldOffsets[FieldNo];
   }
 

Modified: cfe/trunk/lib/AST/RecordLayout.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/RecordLayout.cpp?rev=270591&r1=270590&r2=270591&view=diff
==
--- cfe/trunk/lib/AST/RecordLayout.cpp (original)
+++ cfe/trunk/lib/AST/RecordLayout.cpp Tue May 24 13:10:50 2016
@@ -18,8 +18,6 @@
 using namespace clang;
 
 void ASTRecordLayout::Destroy(ASTContext &Ctx) {
-  if (FieldOffsets)
-Ctx.Deallocate(FieldOffsets);
   if (CXXInfo) {
 CXXInfo->~CXXRecordLayoutInfo();
 Ctx.Deallocate(CXXInfo);
@@ -29,18 +27,13 @@ void ASTRecordLayout::Destroy(ASTContext
 }
 
 ASTRecordLayout::ASTRecordLayout(const ASTContext &Ctx, CharUnits size,
- CharUnits alignment, 
+ CharUnits alignment,
  CharUnits requiredAlignment,
  CharUnits datasize,
- const uint64_t *fieldoffsets,
- unsigned fieldcount)
-  : Size(size), DataSize(datasize), Alignment(alignment),
-RequiredAlignment(requiredAlignment), FieldOffsets(nullptr),
-FieldCount(fieldcount), CXXInfo(nullptr) {
-  if (FieldCount > 0)  {
-FieldOffsets = new (Ctx) uint64_t[FieldCount];
-memcpy(FieldOffsets, fieldoffsets, FieldCount * sizeof(*FieldOffsets));
-  }
+ ArrayRef fieldoffsets)
+: Size(size), DataSize(datasize), Alignment(alignment),
+  RequiredAlignment(requiredAlignment), CXXInfo(nullptr) {
+  FieldOffsets.append(Ctx, fieldoffsets.begin(), fieldoffsets.end());
 }
 
 // Constructor for C++ records.
@@ -50,8 +43,7 @@ ASTRecordLayout::ASTRecordLayout(const A
  bool hasOwnVFPtr, bool hasExtendableVFPtr,
  CharUnits vbptroffset,
  CharUnits datasize,
- const uint64_t *fieldoffsets,
- unsigned fieldcount,
+ ArrayRef fieldoffsets,
  CharUnits nonvirtualsize,
  CharUnits nonvirtualalignment,
  CharUnits SizeOfLargestEmptySubobject,
@@ -63,13 +55,9 @@ ASTRecordLayout::ASTRecordLayout(const A

Re: [PATCH] D20334: [libcxx] Fix a bug in strstreambuf::overflow

2016-05-24 Thread Akira Hatanaka via cfe-commits
ahatanak added a comment.

My understanding is that typically std::ends is explicitly appended to 
null-terminate the stream buffer. The test case in the example does that.

http://en.cppreference.com/w/cpp/io/ostrstream/str


http://reviews.llvm.org/D20334



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


Re: [PATCH] arc-repeated-use-of-weak should not warn about IBOutlet properties

2016-05-24 Thread Manman via cfe-commits

> On May 23, 2016, at 8:15 PM, Bob Wilson  wrote:
> 
> Revision r211132 was supposed to disable -Warc-repeated-use-of-weak for 
> Objective-C properties marked with the IBOutlet attribute. Those properties 
> are supposed to be weak but they are only accessed from the main thread so 
> there is no risk of asynchronous updates setting them to nil. That 
> combination makes -Warc-repeated-use-of-weak very noisy. The previous change 
> only handled one kind of access to weak IBOutlet properties. Instead of 
> trying to add checks for all the different kinds of property accesses, this 
> patch removes the previous special case check and adds a check at the point 
> where the diagnostic is reported.

The approach looks good to me in general. 
> diff --git lib/Sema/AnalysisBasedWarnings.cpp 
> lib/Sema/AnalysisBasedWarnings.cpp
> index 3f2c41b..eb45315 100644
> --- lib/Sema/AnalysisBasedWarnings.cpp
> +++ lib/Sema/AnalysisBasedWarnings.cpp
> @@ -1334,6 +1334,12 @@ static void diagnoseRepeatedUseOfWeak(Sema &S,
>  else
>llvm_unreachable("Unexpected weak object kind!");
>  
> +// Do not warn about IBOutlet weak property receivers being set to null
> +// since they are typically only used from the main thread.
> +if (const ObjCPropertyDecl *Prop = dyn_cast(D))
> +  if (Prop->hasAttr())
> +continue;
> +
>  // Show the first time the object was read.
>  S.Diag(FirstRead->getLocStart(), DiagKind)
><< int(ObjectKind) << D << int(FunctionKind)

Should we guard the call to diagnoseRepeatedUseOfWeak, instead of checking the 
decl inside a loop in diagnoseRepeatedUseOfWeak?

  if (S.getLangOpts().ObjCWeak &&
  !Diags.isIgnored(diag::warn_arc_repeated_use_of_weak, D->getLocStart()))
diagnoseRepeatedUseOfWeak(S, fscope, D, AC.getParentMap());
—> check IBOutlet here?

> diff --git lib/Sema/SemaPseudoObject.cpp lib/Sema/SemaPseudoObject.cpp
> index 62c823b..c93d800 100644
> --- lib/Sema/SemaPseudoObject.cpp
> +++ lib/Sema/SemaPseudoObject.cpp
> @@ -578,7 +578,7 @@ bool ObjCPropertyOpBuilder::isWeakProperty() const {
>if (RefExpr->isExplicitProperty()) {
>  const ObjCPropertyDecl *Prop = RefExpr->getExplicitProperty();
>  if (Prop->getPropertyAttributes() & ObjCPropertyDecl::OBJC_PR_weak)
> -  return !Prop->hasAttr();
> +  return true;
>  
>  T = Prop->getType();
>} else if (Getter) {

I wonder if this change is necessary to make the testing case pass, or is it 
introduced for clarity, to better reflect the function name isWeakProperty?

Thanks,
Manman

> rdar://problem/21366461
> 
> 

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


Re: [PATCH] D20573: [libcxx] Allow explicit pthread opt-in

2016-05-24 Thread Asiri Rathnayake via cfe-commits
rmaprath added a comment.

Couple of minor comments. LGTM otherwise.

/ Asiri



Comment at: CMakeLists.txt:387
@@ -386,2 +386,3 @@
 
+config_define_if(LIBCXX_HAS_PTHREAD_API _LIBCPP_HAS_THREAD_API_PTHREAD)
 config_define_if(LIBCXX_HAS_MUSL_LIBC _LIBCPP_HAS_MUSL_LIBC)

I think we should put in a check to make sure that `LIBCXX_HAS_PTHREAD_API` is 
only enabled when `LIBCXX_ENABLE_THREADS` is also enabled.


Comment at: include/__config:816
@@ -815,3 +815,3 @@
 // Thread API
-#ifndef _LIBCPP_HAS_NO_THREADS
+#if !defined(_LIBCPP_HAS_NO_THREADS) && 
!defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
 # if defined(__FreeBSD__) || \

Similarly here. For example, there is a similar check for 
`_LIBCPP_HAS_NO_MONOTONIC_CLOCK` compatibility with the `LIBCXX_ENABLE_THREADS` 
flag.


http://reviews.llvm.org/D20573



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


Re: [clang-tools-extra] r261991 - [clang-tidy] Fix a crash issue when clang-tidy runs with compilation database.

2016-05-24 Thread Edoardo P. via cfe-commits
Ping,

who's going to merge? I have no commit access.

Cheers,
Edward-san


2016-05-20 18:34 GMT+02:00 Tom Stellard :
> Hi,
>
> This looks fine to me, go ahead and merge.
>
> -Tom
>
> On Thu, May 19, 2016 at 08:29:14PM +0200, Alexander Kornienko wrote:
>> On Thu, May 19, 2016 at 4:45 PM, Hans Wennborg  wrote:
>>
>> > +Tom who manages 3.8.1
>> > +Alex who's owner of clang-tidy: is this ok for 3.8.1?
>> >
>>
>> Yes, would be nice to have this in 3.8.1. This fixes a rather annoying
>> problem.
>>
>>
>> >
>> > On Thu, May 19, 2016 at 1:56 AM, Edoardo P. via cfe-commits
>> >  wrote:
>> > > Is it possible to port this commit to 3.8.1?
>> > >
>> > > Cheers,
>> > > Edward-san
>> > >
>> > > 2016-02-26 10:19 GMT+01:00 Haojian Wu via cfe-commits
>> > > :
>> > >> Author: hokein
>> > >> Date: Fri Feb 26 03:19:33 2016
>> > >> New Revision: 261991
>> > >>
>> > >> URL: http://llvm.org/viewvc/llvm-project?rev=261991&view=rev
>> > >> Log:
>> > >> [clang-tidy] Fix a crash issue when clang-tidy runs with compilation
>> > database.
>> > >>
>> > >> Summary:
>> > >> The clang-tidy will trigger an assertion if it's not in the building
>> > directory.
>> > >>
>> > >> TEST:
>> > >> cd /
>> > >> ./build/bin/clang-tidy --checks=-*,modernize-use-nullptr -p build
>> > tools/clang/tools/extra/clang-tidy/ClangTidy.cpp
>> > >>
>> > >> The crash issue is gone after applying this patch.
>> > >>
>> > >> Fixes PR24834, PR26241
>> > >>
>> > >> Reviewers: bkramer, alexfh
>> > >>
>> > >> Subscribers: rizsotto.mailinglist, cfe-commits
>> > >>
>> > >> Differential Revision: http://reviews.llvm.org/D17335
>> > >>
>> > >> Added:
>> > >> clang-tools-extra/trunk/test/clang-tidy/Inputs/compilation-database/
>> > >>
>> >  
>> > clang-tools-extra/trunk/test/clang-tidy/Inputs/compilation-database/template.json
>> > >>
>> >  clang-tools-extra/trunk/test/clang-tidy/clang-tidy-run-with-database.cpp
>> > >> Modified:
>> > >> clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
>> > >> clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp
>> > >> clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.h
>> > >>
>> > >> Modified: clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
>> > >> URL:
>> > http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp?rev=261991&r1=261990&r2=261991&view=diff
>> > >>
>> > ==
>> > >> --- clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp (original)
>> > >> +++ clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp Fri Feb 26
>> > 03:19:33 2016
>> > >> @@ -107,6 +107,10 @@ public:
>> > >>  DiagPrinter->BeginSourceFile(LangOpts);
>> > >>}
>> > >>
>> > >> +  SourceManager& getSourceManager() {
>> > >> +return SourceMgr;
>> > >> +  }
>> > >> +
>> > >>void reportDiagnostic(const ClangTidyError &Error) {
>> > >>  const ClangTidyMessage &Message = Error.Message;
>> > >>  SourceLocation Loc = getLocation(Message.FilePath,
>> > Message.FileOffset);
>> > >> @@ -124,7 +128,10 @@ public:
>> > >>auto Diag = Diags.Report(Loc, Diags.getCustomDiagID(Level, "%0
>> > [%1]"))
>> > >><< Message.Message << Name;
>> > >>for (const tooling::Replacement &Fix : Error.Fix) {
>> > >> -SourceLocation FixLoc = getLocation(Fix.getFilePath(),
>> > Fix.getOffset());
>> > >> +SmallString<128> FixAbsoluteFilePath = Fix.getFilePath();
>> > >> +Files.makeAbsolutePath(FixAbsoluteFilePath);
>> > >> +SourceLocation FixLoc =
>> > >> +getLocation(FixAbsoluteFilePath, Fix.getOffset());
>> > >>  SourceLocation FixEndLoc =
>> > FixLoc.getLocWithOffset(Fix.getLength());
>> > >>  Diag << FixItHint::CreateReplacement(SourceRange(FixLoc,
>> > FixEndLoc),
>> > >>   Fix.getReplacementText());
>> > >> @@ -232,6 +239,13 @@ ClangTidyASTConsumerFactory::CreateASTCo
>> > >>Context.setCurrentFile(File);
>> > >>Context.setASTContext(&Compiler.getASTContext());
>> > >>
>> > >> +  auto WorkingDir = Compiler.getSourceManager()
>> > >> +.getFileManager()
>> > >> +.getVirtualFileSystem()
>> > >> +->getCurrentWorkingDirectory();
>> > >> +  if (WorkingDir)
>> > >> +Context.setCurrentBuildDirectory(WorkingDir.get());
>> > >> +
>> > >>std::vector> Checks;
>> > >>CheckFactories->createChecks(&Context, Checks);
>> > >>
>> > >> @@ -446,8 +460,24 @@ runClangTidy(std::unique_ptr> > >>  void handleErrors(const std::vector &Errors, bool Fix,
>> > >>unsigned &WarningsAsErrorsCount) {
>> > >>ErrorReporter Reporter(Fix);
>> > >> -  for (const ClangTidyError &Error : Errors)
>> > >> +  vfs::FileSystem &FileSystem =
>> > >> +
>> > *Reporter.getSourceManager().getFileManager().getVirtualFileSystem();
>> > >> +  auto InitialWorkingDir = FileSystem.getCurrentWorkingDirectory();
>> > >> +  if (!InitialWorkingD

Re: [PATCH] D20574: [libcxxabi] Allow explicit pthread opt-in

2016-05-24 Thread Asiri Rathnayake via cfe-commits
rmaprath added inline comments.


Comment at: CMakeLists.txt:278
@@ -277,1 +277,3 @@
 
+if (LIBCXXABI_HAS_PTHREAD_API)
+  add_definitions(-D_LIBCPP_HAS_THREAD_API_PTHREAD)

Shouldn't there be an `option()` line for this new build option? Also a check 
for compatibility with the `LIBCXXABI_ENABLE_THREADS` option?


http://reviews.llvm.org/D20574



___
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-05-24 Thread Anastasia Stulova via cfe-commits
Anastasia added inline comments.


Comment at: test/SemaOpenCL/extension-version.cl:11
@@ +10,3 @@
+#endif
+#pragma OPENCL EXTENSION cl_clang_storage_class_specifiers: enable
+

jvesely wrote:
> Anastasia wrote:
> > Could you use standard diagnostic check please:
> >   expected-warning{{unknown OpenCL extension ...
> > 
> > Similarly to SemaOpenCL/extensions.cl
> not sure I follow, the test does not trigger any diagnostics (by design).
> are you saying that I should introduce negative checks to make sure 
> extensions are not available outside of their respective context?
> Is there a way to filter verifier tags based on clang invocation? (something 
> like FileCheck prefix)
Exactly, you should check that the extensions are enabled correctly based on CL 
versions.

For example if you compile this without passing -cl-std=CL1.2:
  #pragma OPENCL EXTENSION cl_khr_gl_msaa_sharing: enable
the following error is produced:
  unsupported OpenCL extension 'cl_khr_gl_msaa_sharing' - ignoring

You can condition error directives on CL version passed as it's done in the 
example test SemaOpenCL/extensions.cl.

So what is the original intension of this tests? Not sure I understand what you 
are trying to test.


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] D20328: [libcxx] Externally threaded libc++ variant

2016-05-24 Thread Asiri Rathnayake via cfe-commits
rmaprath added inline comments.


Comment at: include/__threading_support:201
@@ +200,3 @@
+// Mutex
+#define _LIBCPP_MUTEX_INITIALIZER nullptr
+struct __libcpp_platform_mutex_t;

bcraig wrote:
> I'm not sure I like taking the freedom to define _LIBCPP_MUTEX_INITIALIZER 
> away from implementers.
> 
> Would it be too terrible to replace this entire #elif block with something 
> like the following?
> 
> ```
> #if !defined(__has_include) || __has_include()
> #include 
> #else
> #error "_LIBCPP_THREAD_API_EXTERNAL requires the implementer to provide 
>  in the include path"
> #endif
> ```
> 
> 
The problem is that, `std::mutex` constructor needs to be `constexpr` (as you 
pointed out earlier). And since `__libcpp_mutex_t` is a pointer type (for this 
externally threaded variant), sensible definitions for 
`_LIBCPP_MUTEX_INITIALIZER` are limited.

Other than `nullptr`, one may be able to define `_LIBCPP_MUTEX_INITIALIZER` to 
be a pointer to some constant mutex (presuming that make it `constexpr` OK?) 
but I'm not convinced if such a setup would be very useful.

Hope that sounds sensible?


http://reviews.llvm.org/D20328



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


Re: [PATCH] arc-repeated-use-of-weak should not warn about IBOutlet properties

2016-05-24 Thread Bob Wilson via cfe-commits

> On May 24, 2016, at 11:21 AM, Manman  wrote:
> 
> 
>> On May 23, 2016, at 8:15 PM, Bob Wilson  wrote:
>> 
>> Revision r211132 was supposed to disable -Warc-repeated-use-of-weak for 
>> Objective-C properties marked with the IBOutlet attribute. Those properties 
>> are supposed to be weak but they are only accessed from the main thread so 
>> there is no risk of asynchronous updates setting them to nil. That 
>> combination makes -Warc-repeated-use-of-weak very noisy. The previous change 
>> only handled one kind of access to weak IBOutlet properties. Instead of 
>> trying to add checks for all the different kinds of property accesses, this 
>> patch removes the previous special case check and adds a check at the point 
>> where the diagnostic is reported.
> 
> The approach looks good to me in general. 
>> diff --git lib/Sema/AnalysisBasedWarnings.cpp 
>> lib/Sema/AnalysisBasedWarnings.cpp
>> index 3f2c41b..eb45315 100644
>> --- lib/Sema/AnalysisBasedWarnings.cpp
>> +++ lib/Sema/AnalysisBasedWarnings.cpp
>> @@ -1334,6 +1334,12 @@ static void diagnoseRepeatedUseOfWeak(Sema &S,
>> else
>>   llvm_unreachable("Unexpected weak object kind!");
>> 
>> +// Do not warn about IBOutlet weak property receivers being set to null
>> +// since they are typically only used from the main thread.
>> +if (const ObjCPropertyDecl *Prop = dyn_cast(D))
>> +  if (Prop->hasAttr())
>> +continue;
>> +
>> // Show the first time the object was read.
>> S.Diag(FirstRead->getLocStart(), DiagKind)
>>   << int(ObjectKind) << D << int(FunctionKind)
> 
> Should we guard the call to diagnoseRepeatedUseOfWeak, instead of checking 
> the decl inside a loop in diagnoseRepeatedUseOfWeak?
> 
>  if (S.getLangOpts().ObjCWeak &&
>  !Diags.isIgnored(diag::warn_arc_repeated_use_of_weak, D->getLocStart()))
>diagnoseRepeatedUseOfWeak(S, fscope, D, AC.getParentMap());
> —> check IBOutlet here?

diagnoseRepeatedUseOfWeak is used to report all of the issues within a 
function. Some of those may involve IBOutlet properties and others not. We have 
to check each one separately.

Your comment prompted me to look more closely and I realized that the code is 
confusing because there is a local variable “D” that shadows the “const Decl 
*D” argument of diagnoseRepeatedUseOfWeak:

const NamedDecl *D = Key.getProperty();

We should rename that to avoid potential confusion. I can do that as a 
follow-up change.

> 
>> diff --git lib/Sema/SemaPseudoObject.cpp lib/Sema/SemaPseudoObject.cpp
>> index 62c823b..c93d800 100644
>> --- lib/Sema/SemaPseudoObject.cpp
>> +++ lib/Sema/SemaPseudoObject.cpp
>> @@ -578,7 +578,7 @@ bool ObjCPropertyOpBuilder::isWeakProperty() const {
>>   if (RefExpr->isExplicitProperty()) {
>> const ObjCPropertyDecl *Prop = RefExpr->getExplicitProperty();
>> if (Prop->getPropertyAttributes() & ObjCPropertyDecl::OBJC_PR_weak)
>> -  return !Prop->hasAttr();
>> +  return true;
>> 
>> T = Prop->getType();
>>   } else if (Getter) {
> 
> I wonder if this change is necessary to make the testing case pass, or is it 
> introduced for clarity, to better reflect the function name isWeakProperty?

This is the one special-case check that was introduced by r211132. I removed it 
because there is no need for it after we add the check in 
diagnoseRepeatedUseOfWeak.

> 
> Thanks,
> Manman
> 
>> rdar://problem/21366461
>> 
>> 
> 

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


Re: [PATCH] arc-repeated-use-of-weak should not warn about IBOutlet properties

2016-05-24 Thread Manman Ren via cfe-commits

> On May 24, 2016, at 11:42 AM, Bob Wilson  wrote:
> 
>> 
>> On May 24, 2016, at 11:21 AM, Manman  wrote:
>> 
>> 
>>> On May 23, 2016, at 8:15 PM, Bob Wilson  wrote:
>>> 
>>> Revision r211132 was supposed to disable -Warc-repeated-use-of-weak for 
>>> Objective-C properties marked with the IBOutlet attribute. Those properties 
>>> are supposed to be weak but they are only accessed from the main thread so 
>>> there is no risk of asynchronous updates setting them to nil. That 
>>> combination makes -Warc-repeated-use-of-weak very noisy. The previous 
>>> change only handled one kind of access to weak IBOutlet properties. Instead 
>>> of trying to add checks for all the different kinds of property accesses, 
>>> this patch removes the previous special case check and adds a check at the 
>>> point where the diagnostic is reported.
>> 
>> The approach looks good to me in general. 
>>> diff --git lib/Sema/AnalysisBasedWarnings.cpp 
>>> lib/Sema/AnalysisBasedWarnings.cpp
>>> index 3f2c41b..eb45315 100644
>>> --- lib/Sema/AnalysisBasedWarnings.cpp
>>> +++ lib/Sema/AnalysisBasedWarnings.cpp
>>> @@ -1334,6 +1334,12 @@ static void diagnoseRepeatedUseOfWeak(Sema &S,
>>>else
>>>  llvm_unreachable("Unexpected weak object kind!");
>>> 
>>> +// Do not warn about IBOutlet weak property receivers being set to null
>>> +// since they are typically only used from the main thread.
>>> +if (const ObjCPropertyDecl *Prop = dyn_cast(D))
>>> +  if (Prop->hasAttr())
>>> +continue;
>>> +
>>>// Show the first time the object was read.
>>>S.Diag(FirstRead->getLocStart(), DiagKind)
>>>  << int(ObjectKind) << D << int(FunctionKind)
>> 
>> Should we guard the call to diagnoseRepeatedUseOfWeak, instead of checking 
>> the decl inside a loop in diagnoseRepeatedUseOfWeak?
>> 
>> if (S.getLangOpts().ObjCWeak &&
>> !Diags.isIgnored(diag::warn_arc_repeated_use_of_weak, D->getLocStart()))
>>   diagnoseRepeatedUseOfWeak(S, fscope, D, AC.getParentMap());
>> —> check IBOutlet here?
> 
> diagnoseRepeatedUseOfWeak is used to report all of the issues within a 
> function. Some of those may involve IBOutlet properties and others not. We 
> have to check each one separately.
> 
> Your comment prompted me to look more closely and I realized that the code is 
> confusing because there is a local variable “D” that shadows the “const Decl 
> *D” argument of diagnoseRepeatedUseOfWeak:
> 
>const NamedDecl *D = Key.getProperty();
> 
> We should rename that to avoid potential confusion. I can do that as a 
> follow-up change.

Yes, I missed the local variable “D”.

> 
>> 
>>> diff --git lib/Sema/SemaPseudoObject.cpp lib/Sema/SemaPseudoObject.cpp
>>> index 62c823b..c93d800 100644
>>> --- lib/Sema/SemaPseudoObject.cpp
>>> +++ lib/Sema/SemaPseudoObject.cpp
>>> @@ -578,7 +578,7 @@ bool ObjCPropertyOpBuilder::isWeakProperty() const {
>>>  if (RefExpr->isExplicitProperty()) {
>>>const ObjCPropertyDecl *Prop = RefExpr->getExplicitProperty();
>>>if (Prop->getPropertyAttributes() & ObjCPropertyDecl::OBJC_PR_weak)
>>> -  return !Prop->hasAttr();
>>> +  return true;
>>> 
>>>T = Prop->getType();
>>>  } else if (Getter) {
>> 
>> I wonder if this change is necessary to make the testing case pass, or is it 
>> introduced for clarity, to better reflect the function name isWeakProperty?
> 
> This is the one special-case check that was introduced by r211132. I removed 
> it because there is no need for it after we add the check in 
> diagnoseRepeatedUseOfWeak.

Thanks for the explanation!

Patch looks good to me,
Manman

> 
>> 
>> Thanks,
>> Manman
>> 
>>> rdar://problem/21366461 
>>> 
>>> 

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


RE: r267590 - [OpenCL] Add predefined macros.

2016-05-24 Thread Anastasia Stulova via cfe-commits
Hi Sam,

I think this commit broke Clang.

It seems we are no longer able to pass the -std=CL2.0, which is important for 
the standalone Clang OpenCL users as -cl-std is frontend only option.
 
clang  -std=CL2.0 test.cl
error: invalid argument '-std=CL2.0' not allowed with 'OpenCL'

We might have to revert or rework this bit:

--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Tue Apr 26 14:25:46 
+++ 2016
@@ -1495,9 +1495,8 @@ static void ParseLangArgs(LangOptions &O
 << A->getAsString(Args) << "C++/ObjC++";
 break;
   case IK_OpenCL:
-if (!Std.isC99())
-  Diags.Report(diag::err_drv_argument_not_allowed_with)
-<< A->getAsString(Args) << "OpenCL";
+Diags.Report(diag::err_drv_argument_not_allowed_with)
+  << A->getAsString(Args) << "OpenCL";
 break;
   case IK_CUDA:
   case IK_PreprocessedCuda:

Do you think you could look into this?

Thanks,
Anastasia

-Original Message-
From: cfe-commits [mailto:cfe-commits-boun...@lists.llvm.org] On Behalf Of 
Yaxun Liu via cfe-commits
Sent: 26 April 2016 20:26
To: cfe-commits@lists.llvm.org
Subject: r267590 - [OpenCL] Add predefined macros.

Author: yaxunl
Date: Tue Apr 26 14:25:46 2016
New Revision: 267590

URL: http://llvm.org/viewvc/llvm-project?rev=267590&view=rev
Log:
[OpenCL] Add predefined macros.

OpenCL spec requires __OPENCL_C_VERSION__ to be defined based on -cl-std 
option. This patch implements that.

The patch also defines __FAST_RELAXED_MATH__ based on -cl-fast-relaxed-math 
option.

Also fixed a test using -std=c99 for OpenCL program. Limit allowed language 
standard of OpenCL to be OpenCL standards.

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

Removed:
cfe/trunk/test/Frontend/std.cl
Modified:
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/lib/Frontend/InitPreprocessor.cpp
cfe/trunk/test/Frontend/stdlang.c
cfe/trunk/test/Preprocessor/predefined-macros.c

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=267590&r1=267589&r2=267590&view=diff
==
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Tue Apr 26 14:25:46 
+++ 2016
@@ -1495,9 +1495,8 @@ static void ParseLangArgs(LangOptions &O
 << A->getAsString(Args) << "C++/ObjC++";
 break;
   case IK_OpenCL:
-if (!Std.isC99())
-  Diags.Report(diag::err_drv_argument_not_allowed_with)
-<< A->getAsString(Args) << "OpenCL";
+Diags.Report(diag::err_drv_argument_not_allowed_with)
+  << A->getAsString(Args) << "OpenCL";
 break;
   case IK_CUDA:
   case IK_PreprocessedCuda:

Modified: cfe/trunk/lib/Frontend/InitPreprocessor.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/InitPreprocessor.cpp?rev=267590&r1=267589&r2=267590&view=diff
==
--- cfe/trunk/lib/Frontend/InitPreprocessor.cpp (original)
+++ cfe/trunk/lib/Frontend/InitPreprocessor.cpp Tue Apr 26 14:25:46 2016
@@ -408,6 +408,39 @@ static void InitializeStandardPredefined
   if (LangOpts.ObjC1)
 Builder.defineMacro("__OBJC__");
 
+  // OpenCL v1.0/1.1 s6.9, v1.2/2.0 s6.10: Preprocessor Directives and Macros.
+  if (LangOpts.OpenCL) {
+// OpenCL v1.0 and v1.1 do not have a predefined macro to indicate the
+// language standard with which the program is compiled. __OPENCL_VERSION__
+// is for the OpenCL version supported by the OpenCL device, which is not
+// necessarily the language standard with which the program is compiled.
+// A shared OpenCL header file requires a macro to indicate the language
+// standard. As a workaround, __OPENCL_C_VERSION__ is defined for
+// OpenCL v1.0 and v1.1.
+switch (LangOpts.OpenCLVersion) {
+case 100:
+  Builder.defineMacro("__OPENCL_C_VERSION__", "100");
+  break;
+case 110:
+  Builder.defineMacro("__OPENCL_C_VERSION__", "110");
+  break;
+case 120:
+  Builder.defineMacro("__OPENCL_C_VERSION__", "120");
+  break;
+case 200:
+  Builder.defineMacro("__OPENCL_C_VERSION__", "200");
+  break;
+default:
+  llvm_unreachable("Unsupported OpenCL version");
+}
+Builder.defineMacro("CL_VERSION_1_0", "100");
+Builder.defineMacro("CL_VERSION_1_1", "110");
+Builder.defineMacro("CL_VERSION_1_2", "120");
+Builder.defineMacro("CL_VERSION_2_0", "200");
+
+if (LangOpts.FastRelaxedMath)
+  Builder.defineMacro("__FAST_RELAXED_MATH__");
+  }
   // Not "standard" per se, but available even with the -undef flag.
   if (LangOpts.AsmPreprocessor)
 Builder.defineMacro("__ASSEMBLER__");

Removed: cfe/trunk/test/Frontend/std.cl
URL: 
http://ll

RE: r267590 - [OpenCL] Add predefined macros.

2016-05-24 Thread Liu, Yaxun (Sam) via cfe-commits
Did clang accept -std=CL2.0 before this change?

According to this diff, the only accepted option for -std= is c99 when 
compiling OpenCL programs.

Sam

-Original Message-
From: Anastasia Stulova [mailto:anastasia.stul...@arm.com] 
Sent: Tuesday, May 24, 2016 2:48 PM
To: Liu, Yaxun (Sam) ; cfe-commits@lists.llvm.org
Cc: nd 
Subject: RE: r267590 - [OpenCL] Add predefined macros.

Hi Sam,

I think this commit broke Clang.

It seems we are no longer able to pass the -std=CL2.0, which is important for 
the standalone Clang OpenCL users as -cl-std is frontend only option.
 
clang  -std=CL2.0 test.cl
error: invalid argument '-std=CL2.0' not allowed with 'OpenCL'

We might have to revert or rework this bit:

--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Tue Apr 26 14:25:46
+++ 2016
@@ -1495,9 +1495,8 @@ static void ParseLangArgs(LangOptions &O
 << A->getAsString(Args) << "C++/ObjC++";
 break;
   case IK_OpenCL:
-if (!Std.isC99())
-  Diags.Report(diag::err_drv_argument_not_allowed_with)
-<< A->getAsString(Args) << "OpenCL";
+Diags.Report(diag::err_drv_argument_not_allowed_with)
+  << A->getAsString(Args) << "OpenCL";
 break;
   case IK_CUDA:
   case IK_PreprocessedCuda:

Do you think you could look into this?

Thanks,
Anastasia

-Original Message-
From: cfe-commits [mailto:cfe-commits-boun...@lists.llvm.org] On Behalf Of 
Yaxun Liu via cfe-commits
Sent: 26 April 2016 20:26
To: cfe-commits@lists.llvm.org
Subject: r267590 - [OpenCL] Add predefined macros.

Author: yaxunl
Date: Tue Apr 26 14:25:46 2016
New Revision: 267590

URL: http://llvm.org/viewvc/llvm-project?rev=267590&view=rev
Log:
[OpenCL] Add predefined macros.

OpenCL spec requires __OPENCL_C_VERSION__ to be defined based on -cl-std 
option. This patch implements that.

The patch also defines __FAST_RELAXED_MATH__ based on -cl-fast-relaxed-math 
option.

Also fixed a test using -std=c99 for OpenCL program. Limit allowed language 
standard of OpenCL to be OpenCL standards.

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

Removed:
cfe/trunk/test/Frontend/std.cl
Modified:
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/lib/Frontend/InitPreprocessor.cpp
cfe/trunk/test/Frontend/stdlang.c
cfe/trunk/test/Preprocessor/predefined-macros.c

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=267590&r1=267589&r2=267590&view=diff
==
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Tue Apr 26 14:25:46
+++ 2016
@@ -1495,9 +1495,8 @@ static void ParseLangArgs(LangOptions &O
 << A->getAsString(Args) << "C++/ObjC++";
 break;
   case IK_OpenCL:
-if (!Std.isC99())
-  Diags.Report(diag::err_drv_argument_not_allowed_with)
-<< A->getAsString(Args) << "OpenCL";
+Diags.Report(diag::err_drv_argument_not_allowed_with)
+  << A->getAsString(Args) << "OpenCL";
 break;
   case IK_CUDA:
   case IK_PreprocessedCuda:

Modified: cfe/trunk/lib/Frontend/InitPreprocessor.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/InitPreprocessor.cpp?rev=267590&r1=267589&r2=267590&view=diff
==
--- cfe/trunk/lib/Frontend/InitPreprocessor.cpp (original)
+++ cfe/trunk/lib/Frontend/InitPreprocessor.cpp Tue Apr 26 14:25:46 2016
@@ -408,6 +408,39 @@ static void InitializeStandardPredefined
   if (LangOpts.ObjC1)
 Builder.defineMacro("__OBJC__");
 
+  // OpenCL v1.0/1.1 s6.9, v1.2/2.0 s6.10: Preprocessor Directives and Macros.
+  if (LangOpts.OpenCL) {
+// OpenCL v1.0 and v1.1 do not have a predefined macro to indicate the
+// language standard with which the program is compiled. __OPENCL_VERSION__
+// is for the OpenCL version supported by the OpenCL device, which is not
+// necessarily the language standard with which the program is compiled.
+// A shared OpenCL header file requires a macro to indicate the language
+// standard. As a workaround, __OPENCL_C_VERSION__ is defined for
+// OpenCL v1.0 and v1.1.
+switch (LangOpts.OpenCLVersion) {
+case 100:
+  Builder.defineMacro("__OPENCL_C_VERSION__", "100");
+  break;
+case 110:
+  Builder.defineMacro("__OPENCL_C_VERSION__", "110");
+  break;
+case 120:
+  Builder.defineMacro("__OPENCL_C_VERSION__", "120");
+  break;
+case 200:
+  Builder.defineMacro("__OPENCL_C_VERSION__", "200");
+  break;
+default:
+  llvm_unreachable("Unsupported OpenCL version");
+}
+Builder.defineMacro("CL_VERSION_1_0", "100");
+Builder.defineMacro("CL_VERSION_1_1", "110");
+Build

[clang-tools-extra] r270599 - clang-rename: fix renaming non-members variables when referenced as macro arguments

2016-05-24 Thread Miklos Vajna via cfe-commits
Author: vmiklos
Date: Tue May 24 14:08:53 2016
New Revision: 270599

URL: http://llvm.org/viewvc/llvm-project?rev=270599&view=rev
Log:
clang-rename: fix renaming non-members variables when referenced as macro 
arguments

The second check failed, FOO(C::X) wasn't renamed to FOO(C::Y).

Reviewers: klimek

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

Added:
clang-tools-extra/trunk/test/clang-rename/DeclRefExpr.cpp
Modified:
clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp

Modified: clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp?rev=270599&r1=270598&r2=270599&view=diff
==
--- clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp (original)
+++ clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp Tue May 24 14:08:53 
2016
@@ -94,7 +94,9 @@ public:
 
 checkNestedNameSpecifierLoc(Expr->getQualifierLoc());
 if (getUSRForDecl(Decl) == USR) {
-  LocationsFound.push_back(Expr->getLocation());
+  const SourceManager &Manager = Decl->getASTContext().getSourceManager();
+  SourceLocation Location = Manager.getSpellingLoc(Expr->getLocation());
+  LocationsFound.push_back(Location);
 }
 
 return true;

Added: clang-tools-extra/trunk/test/clang-rename/DeclRefExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-rename/DeclRefExpr.cpp?rev=270599&view=auto
==
--- clang-tools-extra/trunk/test/clang-rename/DeclRefExpr.cpp (added)
+++ clang-tools-extra/trunk/test/clang-rename/DeclRefExpr.cpp Tue May 24 
14:08:53 2016
@@ -0,0 +1,24 @@
+// RUN: cat %s > %t.cpp
+// RUN: clang-rename -offset=158 -new-name=Y %t.cpp -i --
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
+class C
+{
+public:
+  static int X;
+};
+
+int foo(int x)
+{
+  return 0;
+}
+#define FOO(a) foo(a)
+
+int main()
+{
+  C::X = 1; // CHECK: C::Y
+  FOO(C::X); // CHECK: C::Y
+  int y = C::X; // CHECK: C::Y
+}
+
+// Use grep -FUbo 'X'  to get the correct offset of foo when changing
+// this file.


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


Re: [PATCH] D20537: clang-rename: fix renaming non-members variables when referenced as macro arguments

2016-05-24 Thread Miklos Vajna via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL270599: clang-rename: fix renaming non-members variables 
when referenced as macro… (authored by vmiklos).

Changed prior to commit:
  http://reviews.llvm.org/D20537?vs=58136&id=58290#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D20537

Files:
  clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp
  clang-tools-extra/trunk/test/clang-rename/DeclRefExpr.cpp

Index: clang-tools-extra/trunk/test/clang-rename/DeclRefExpr.cpp
===
--- clang-tools-extra/trunk/test/clang-rename/DeclRefExpr.cpp
+++ clang-tools-extra/trunk/test/clang-rename/DeclRefExpr.cpp
@@ -0,0 +1,24 @@
+// RUN: cat %s > %t.cpp
+// RUN: clang-rename -offset=158 -new-name=Y %t.cpp -i --
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
+class C
+{
+public:
+  static int X;
+};
+
+int foo(int x)
+{
+  return 0;
+}
+#define FOO(a) foo(a)
+
+int main()
+{
+  C::X = 1; // CHECK: C::Y
+  FOO(C::X); // CHECK: C::Y
+  int y = C::X; // CHECK: C::Y
+}
+
+// Use grep -FUbo 'X'  to get the correct offset of foo when changing
+// this file.
Index: clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp
===
--- clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp
+++ clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp
@@ -94,7 +94,9 @@
 
 checkNestedNameSpecifierLoc(Expr->getQualifierLoc());
 if (getUSRForDecl(Decl) == USR) {
-  LocationsFound.push_back(Expr->getLocation());
+  const SourceManager &Manager = Decl->getASTContext().getSourceManager();
+  SourceLocation Location = Manager.getSpellingLoc(Expr->getLocation());
+  LocationsFound.push_back(Location);
 }
 
 return true;


Index: clang-tools-extra/trunk/test/clang-rename/DeclRefExpr.cpp
===
--- clang-tools-extra/trunk/test/clang-rename/DeclRefExpr.cpp
+++ clang-tools-extra/trunk/test/clang-rename/DeclRefExpr.cpp
@@ -0,0 +1,24 @@
+// RUN: cat %s > %t.cpp
+// RUN: clang-rename -offset=158 -new-name=Y %t.cpp -i --
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
+class C
+{
+public:
+  static int X;
+};
+
+int foo(int x)
+{
+  return 0;
+}
+#define FOO(a) foo(a)
+
+int main()
+{
+  C::X = 1; // CHECK: C::Y
+  FOO(C::X); // CHECK: C::Y
+  int y = C::X; // CHECK: C::Y
+}
+
+// Use grep -FUbo 'X'  to get the correct offset of foo when changing
+// this file.
Index: clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp
===
--- clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp
+++ clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp
@@ -94,7 +94,9 @@
 
 checkNestedNameSpecifierLoc(Expr->getQualifierLoc());
 if (getUSRForDecl(Decl) == USR) {
-  LocationsFound.push_back(Expr->getLocation());
+  const SourceManager &Manager = Decl->getASTContext().getSourceManager();
+  SourceLocation Location = Manager.getSpellingLoc(Expr->getLocation());
+  LocationsFound.push_back(Location);
 }
 
 return true;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20328: [libcxx] Externally threaded libc++ variant

2016-05-24 Thread Ben Craig via cfe-commits
bcraig added inline comments.


Comment at: include/__threading_support:201
@@ +200,3 @@
+// Mutex
+#define _LIBCPP_MUTEX_INITIALIZER nullptr
+struct __libcpp_platform_mutex_t;

rmaprath wrote:
> bcraig wrote:
> > I'm not sure I like taking the freedom to define _LIBCPP_MUTEX_INITIALIZER 
> > away from implementers.
> > 
> > Would it be too terrible to replace this entire #elif block with something 
> > like the following?
> > 
> > ```
> > #if !defined(__has_include) || __has_include()
> > #include 
> > #else
> > #error "_LIBCPP_THREAD_API_EXTERNAL requires the implementer to provide 
> >  in the include path"
> > #endif
> > ```
> > 
> > 
> The problem is that, `std::mutex` constructor needs to be `constexpr` (as you 
> pointed out earlier). And since `__libcpp_mutex_t` is a pointer type (for 
> this externally threaded variant), sensible definitions for 
> `_LIBCPP_MUTEX_INITIALIZER` are limited.
> 
> Other than `nullptr`, one may be able to define `_LIBCPP_MUTEX_INITIALIZER` 
> to be a pointer to some constant mutex (presuming that make it `constexpr` 
> OK?) but I'm not convinced if such a setup would be very useful.
> 
> Hope that sounds sensible?
If the implementer gets to provide an entire header, then they also get to 
choose what libcpp_mutex_t will be.  They could make it a struct.


http://reviews.llvm.org/D20328



___
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-05-24 Thread Jan Vesely via cfe-commits
jvesely added inline comments.


Comment at: test/SemaOpenCL/extension-version.cl:11
@@ +10,3 @@
+#endif
+#pragma OPENCL EXTENSION cl_clang_storage_class_specifiers: enable
+

Anastasia wrote:
> jvesely wrote:
> > Anastasia wrote:
> > > Could you use standard diagnostic check please:
> > >   expected-warning{{unknown OpenCL extension ...
> > > 
> > > Similarly to SemaOpenCL/extensions.cl
> > not sure I follow, the test does not trigger any diagnostics (by design).
> > are you saying that I should introduce negative checks to make sure 
> > extensions are not available outside of their respective context?
> > Is there a way to filter verifier tags based on clang invocation? 
> > (something like FileCheck prefix)
> Exactly, you should check that the extensions are enabled correctly based on 
> CL versions.
> 
> For example if you compile this without passing -cl-std=CL1.2:
>   #pragma OPENCL EXTENSION cl_khr_gl_msaa_sharing: enable
> the following error is produced:
>   unsupported OpenCL extension 'cl_khr_gl_msaa_sharing' - ignoring
> 
> You can condition error directives on CL version passed as it's done in the 
> example test SemaOpenCL/extensions.cl.
> 
> So what is the original intension of this tests? Not sure I understand what 
> you are trying to test.
it's a positive test that checks that extensions are available (both that the 
define is present, and that #pragma passes without error).

I did not include negative tests (check that extension is not available outside 
of its respective context), because I think it's a bit overzealous reading of 
the specs.
For example cl_khr_d3d10_sharing is first mentioned in OpenCL 1.1 specs, but 
the text of the extension says that it is written against OpenCL 1.0.48 spec. 
(I moved cl_khr_icd to 1.0 for the same reason). I think if a vendor can add 
vendor specific extensions to the list of supported extensions, it should be 
possible to add extensions from higher CL versions.

similarly, I would argue against warnings for extensions promoted to core 
features (or at least hide the warning behind -pedantic). they are listed in 
CL_DEVICE_EXTENSIONS for backwards compatibility so I'd say it is OK to allow 
pragmas in higher CLC versions for backward compatibility.


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] D20328: [libcxx] Externally threaded libc++ variant

2016-05-24 Thread Asiri Rathnayake via cfe-commits
rmaprath added inline comments.


Comment at: include/__threading_support:201
@@ +200,3 @@
+// Mutex
+#define _LIBCPP_MUTEX_INITIALIZER nullptr
+struct __libcpp_platform_mutex_t;

bcraig wrote:
> rmaprath wrote:
> > bcraig wrote:
> > > I'm not sure I like taking the freedom to define 
> > > _LIBCPP_MUTEX_INITIALIZER away from implementers.
> > > 
> > > Would it be too terrible to replace this entire #elif block with 
> > > something like the following?
> > > 
> > > ```
> > > #if !defined(__has_include) || __has_include()
> > > #include 
> > > #else
> > > #error "_LIBCPP_THREAD_API_EXTERNAL requires the implementer to provide 
> > >  in the include path"
> > > #endif
> > > ```
> > > 
> > > 
> > The problem is that, `std::mutex` constructor needs to be `constexpr` (as 
> > you pointed out earlier). And since `__libcpp_mutex_t` is a pointer type 
> > (for this externally threaded variant), sensible definitions for 
> > `_LIBCPP_MUTEX_INITIALIZER` are limited.
> > 
> > Other than `nullptr`, one may be able to define `_LIBCPP_MUTEX_INITIALIZER` 
> > to be a pointer to some constant mutex (presuming that make it `constexpr` 
> > OK?) but I'm not convinced if such a setup would be very useful.
> > 
> > Hope that sounds sensible?
> If the implementer gets to provide an entire header, then they also get to 
> choose what libcpp_mutex_t will be.  They could make it a struct.
This externally-threaded library variant needs to be compiled against a set 
API, so we have this header with declarations like `__libcpp_mutex_lock()` 
which are referred from within the library sources (same function signatures as 
those used in `LIBCPP_THREAD_API_PTHREAD` - this allows us to keep the library 
source changes to a minimum).

Now, in this particular library variant, we want to differ these calls to 
runtime rather than libcxx compile-time! 

On the other hand, I think you are proposing a compile-time (static) thread 
porting setup where the platform vendors need to supply a header file with 
appropriate definitions for these functions / types, and they would compile 
libcxx themselves? That sounds like a good idea, but the current patch is 
aiming for a different goal: we provide a pre-compiled libcxx library which 
calls out to those `__libcpp_xxx` functions at runtime, and platform vendors 
need to provide those functions, they don't have to compile libcxx themselves. 
This is what forces us to use opaque pointer types to capture platform-defined 
threading primitives.

Perhaps I could improve the naming here, may be 
`LIBCPP_HAS_RUNTIME_THREAD_API`? Or `LIBCPP_HAS_DYNAMIC_THREAD_API`?


http://reviews.llvm.org/D20328



___
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 module

2016-05-24 Thread Yaxun Liu via cfe-commits
yaxunl updated this revision to Diff 58297.
yaxunl added a comment.

Fix regressions in unit test due to ConstructJob disables builtin include path.


http://reviews.llvm.org/D20444

Files:
  include/clang/Basic/LangOptions.def
  include/clang/Driver/CC1Options.td
  include/clang/Frontend/CompilerInvocation.h
  lib/Frontend/CompilerInvocation.cpp
  lib/Headers/module.modulemap
  test/CodeGenOpenCL/bool_cast.cl
  test/Headers/opencl-c-header.cl
  test/Parser/opencl-atomics-cl20.cl
  unittests/AST/MatchVerifier.h

Index: unittests/AST/MatchVerifier.h
===
--- unittests/AST/MatchVerifier.h
+++ unittests/AST/MatchVerifier.h
@@ -114,6 +114,10 @@
 FileName = "input.cc";
 break;
   case Lang_OpenCL:
+// ConstructJob disables builtin include path which is required by OpenCL
+// default header file, therefore default header needs to be disabled.
+Args.push_back("-Xclang");
+Args.push_back("-fno-default-header");
 FileName = "input.cl";
 break;
   case Lang_OBJCXX:
Index: test/Parser/opencl-atomics-cl20.cl
===
--- test/Parser/opencl-atomics-cl20.cl
+++ test/Parser/opencl-atomics-cl20.cl
@@ -1,4 +1,6 @@
-// RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only
+// ToDo: a bug causing cached AST of header containing typedef of atomic_int for CL1.0. After the bug is fixed
+// -fno-default-header should be removed.
+// RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -fno-default-header
 // 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
 
Index: test/Headers/opencl-c-header.cl
===
--- test/Headers/opencl-c-header.cl
+++ test/Headers/opencl-c-header.cl
@@ -1,9 +1,14 @@
-// RUN: %clang_cc1 -internal-isystem ../../lib/Headers -include opencl-c.h -emit-llvm -o - %s | FileCheck %s
-// RUN: %clang_cc1 -internal-isystem ../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -cl-std=CL1.1| FileCheck %s
-// RUN: %clang_cc1 -internal-isystem ../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -cl-std=CL1.2| FileCheck %s
-// RUN: %clang_cc1 -internal-isystem ../../lib/Headers -include opencl-c.h -fblocks -emit-llvm -o - %s -cl-std=CL2.0| FileCheck %s
+// RUN: %clang_cc1 -fno-default-header -internal-isystem ../../lib/Headers -include opencl-c.h -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -fno-default-header -internal-isystem ../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -cl-std=CL1.1| FileCheck %s
+// RUN: %clang_cc1 -fno-default-header -internal-isystem ../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -cl-std=CL1.2| FileCheck %s
+// RUN: %clang_cc1 -fno-default-header -internal-isystem ../../lib/Headers -include opencl-c.h -fblocks -emit-llvm -o - %s -cl-std=CL2.0| FileCheck %s
 
+// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm -verify -fno-default-header -DNO_HEADER %s
 // CHECK: _Z16convert_char_rtec
 char f(char x) {
   return convert_char_rte(x);
+#ifdef NO_HEADER
+  //expected-warning@-2{{implicit declaration of function 'convert_char_rte' is invalid in C99}}
+#endif
 }
Index: test/CodeGenOpenCL/bool_cast.cl
===
--- test/CodeGenOpenCL/bool_cast.cl
+++ test/CodeGenOpenCL/bool_cast.cl
@@ -1,9 +1,5 @@
 // RUN: %clang_cc1 %s -emit-llvm -o - -O0 | FileCheck %s
 
-typedef unsigned char uchar4 __attribute((ext_vector_type(4)));
-typedef unsigned int int4 __attribute((ext_vector_type(4)));
-typedef float float4 __attribute((ext_vector_type(4)));
-
 // CHECK-LABEL: define void @ker()
 void kernel ker() {
   bool t = true;
Index: lib/Headers/module.modulemap
===
--- lib/Headers/module.modulemap
+++ lib/Headers/module.modulemap
@@ -155,6 +155,11 @@
   header "vecintrin.h"
 }
   }
+  
+  explicit module opencl_c {
+requires opencl
+header "opencl-c.h"
+  }
 }
 
 module _Builtin_stddef_max_align_t [system] [extern_c] {
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -1400,6 +1400,7 @@
 
 void CompilerInvocation::setLangDefaults(LangOptions &Opts, InputKind IK,
  const llvm::Triple &T,
+ PreprocessorOptions &PPOpts,
  LangStandard::Kind LangStd) {
   // Set some properties which depend solely on the input kind; it would be nice
   // to move these to the language standard, and have the driver resolve the
@@ -1481,6 +1482,12 @@
 Opts.DefaultFPCon

Re: [PATCH] D20328: [libcxx] Externally threaded libc++ variant

2016-05-24 Thread Ben Craig via cfe-commits
bcraig added inline comments.


Comment at: include/__threading_support:201
@@ +200,3 @@
+// Mutex
+#define _LIBCPP_MUTEX_INITIALIZER nullptr
+struct __libcpp_platform_mutex_t;

rmaprath wrote:
> bcraig wrote:
> > rmaprath wrote:
> > > bcraig wrote:
> > > > I'm not sure I like taking the freedom to define 
> > > > _LIBCPP_MUTEX_INITIALIZER away from implementers.
> > > > 
> > > > Would it be too terrible to replace this entire #elif block with 
> > > > something like the following?
> > > > 
> > > > ```
> > > > #if !defined(__has_include) || __has_include()
> > > > #include 
> > > > #else
> > > > #error "_LIBCPP_THREAD_API_EXTERNAL requires the implementer to provide 
> > > >  in the include path"
> > > > #endif
> > > > ```
> > > > 
> > > > 
> > > The problem is that, `std::mutex` constructor needs to be `constexpr` (as 
> > > you pointed out earlier). And since `__libcpp_mutex_t` is a pointer type 
> > > (for this externally threaded variant), sensible definitions for 
> > > `_LIBCPP_MUTEX_INITIALIZER` are limited.
> > > 
> > > Other than `nullptr`, one may be able to define 
> > > `_LIBCPP_MUTEX_INITIALIZER` to be a pointer to some constant mutex 
> > > (presuming that make it `constexpr` OK?) but I'm not convinced if such a 
> > > setup would be very useful.
> > > 
> > > Hope that sounds sensible?
> > If the implementer gets to provide an entire header, then they also get to 
> > choose what libcpp_mutex_t will be.  They could make it a struct.
> This externally-threaded library variant needs to be compiled against a set 
> API, so we have this header with declarations like `__libcpp_mutex_lock()` 
> which are referred from within the library sources (same function signatures 
> as those used in `LIBCPP_THREAD_API_PTHREAD` - this allows us to keep the 
> library source changes to a minimum).
> 
> Now, in this particular library variant, we want to differ these calls to 
> runtime rather than libcxx compile-time! 
> 
> On the other hand, I think you are proposing a compile-time (static) thread 
> porting setup where the platform vendors need to supply a header file with 
> appropriate definitions for these functions / types, and they would compile 
> libcxx themselves? That sounds like a good idea, but the current patch is 
> aiming for a different goal: we provide a pre-compiled libcxx library which 
> calls out to those `__libcpp_xxx` functions at runtime, and platform vendors 
> need to provide those functions, they don't have to compile libcxx 
> themselves. This is what forces us to use opaque pointer types to capture 
> platform-defined threading primitives.
> 
> Perhaps I could improve the naming here, may be 
> `LIBCPP_HAS_RUNTIME_THREAD_API`? Or `LIBCPP_HAS_DYNAMIC_THREAD_API`?
That is an excellent summary, and it does a good job of explaining the 
disconnect we were having.  I'm going to push forward with the disconnect 
though :)

I think you can implement the dynamic case in terms of the static case without 
loss of generality or performance.  You ("Vendor X") could pre-compile your 
library with a pointer-sized libcpp_mutex_t defined in , 
and at runtime call out to a different library that has an implementation of 
libcpp_mutex_lock.  Someone else ("Vendor Y") could have a larger 
libcpp_mutex_t defined, and provide a static inline definition of 
libcpp_mutex_lock.


http://reviews.llvm.org/D20328



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


Re: [PATCH] D20576: [Driver] Add support for -finline-functions and /Ob2 flags

2016-05-24 Thread Rudy Pons via cfe-commits
Ilod updated this revision to Diff 58302.
Ilod added a comment.

Thanks!

Updated to respect the 80-columns limit.
Updated the tests to have a clearer checks. (I don't know well the FileCheck, 
so I took example from test/CodeGen/noinline.c, but this is indeed more 
comprehensible).


http://reviews.llvm.org/D20576

Files:
  include/clang/Driver/CLCompatOptions.td
  include/clang/Driver/Options.td
  lib/Driver/Tools.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGen/inline-optim.c
  test/Driver/cl-options.c
  test/Driver/clang_f_opts.c

Index: test/Driver/clang_f_opts.c
===
--- test/Driver/clang_f_opts.c
+++ test/Driver/clang_f_opts.c
@@ -285,7 +285,6 @@
 // RUN: -fexpensive-optimizations \
 // RUN: -fno-expensive-optimizations  \
 // RUN: -fno-defer-pop\
-// RUN: -finline-functions\
 // RUN: -fkeep-inline-functions   \
 // RUN: -fno-keep-inline-functions\
 // RUN: -freorder-blocks  \
@@ -353,7 +352,6 @@
 // CHECK-WARNING-DAG: optimization flag '-fexpensive-optimizations' is not supported
 // CHECK-WARNING-DAG: optimization flag '-fno-expensive-optimizations' is not supported
 // CHECK-WARNING-DAG: optimization flag '-fno-defer-pop' is not supported
-// CHECK-WARNING-DAG: optimization flag '-finline-functions' is not supported
 // CHECK-WARNING-DAG: optimization flag '-fkeep-inline-functions' is not supported
 // CHECK-WARNING-DAG: optimization flag '-fno-keep-inline-functions' is not supported
 // CHECK-WARNING-DAG: optimization flag '-freorder-blocks' is not supported
Index: test/Driver/cl-options.c
===
--- test/Driver/cl-options.c
+++ test/Driver/cl-options.c
@@ -97,6 +97,9 @@
 // RUN: %clang_cl /Ob0 -### -- %s 2>&1 | FileCheck -check-prefix=Ob0 %s
 // Ob0: -fno-inline
 
+// RUN: %clang_cl /Ob2 -### -- %s 2>&1 | FileCheck -check-prefix=Ob2 %s
+// Ob2: -finline-functions
+
 // RUN: %clang_cl /Od -### -- %s 2>&1 | FileCheck -check-prefix=Od %s
 // Od: -O0
 
@@ -265,7 +268,6 @@
 // RUN:/kernel- \
 // RUN:/nologo \
 // RUN:/Ob1 \
-// RUN:/Ob2 \
 // RUN:/openmp- \
 // RUN:/RTC1 \
 // RUN:/sdl \
Index: test/CodeGen/inline-optim.c
===
--- test/CodeGen/inline-optim.c
+++ test/CodeGen/inline-optim.c
@@ -0,0 +1,26 @@
+// Make sure -finline-functions family flags are behaving correctly.
+
+// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck -check-prefix=NOINLINE %s
+// RUN: %clang_cc1 -O3 -fno-inline-functions -emit-llvm %s -o - | FileCheck -check-prefix=NOINLINE %s
+// RUN: %clang_cc1 -finline-functions -emit-llvm %s -o - | FileCheck -check-prefix=INLINE %s
+
+inline int inline_hint(int a, int b) { return(a+b); }
+
+int inline_no_hint(int a, int b) { return (a/b); }
+
+inline __attribute__ ((__always_inline__)) int inline_always(int a, int b) { return(a*b); }
+
+volatile int *pa = (int*) 0x1000;
+void foo() {
+// NOINLINE-LABEL: @foo
+// INLINE-LABEL: @foo
+// NOINLINE: call i32 @inline_hint
+// INLINE-NOT: call i32 @inline_hint
+pa[0] = inline_hint(pa[1],pa[2]);	
+// NOINLINE-NOT: call i32 @inline_always
+// INLINE-NOT: call i32 @inline_always
+pa[3] = inline_always(pa[4],pa[5]);
+// NOINLINE: call i32 @inline_no_hint
+// INLINE-NOT: call i32 @inline_no_hint
+pa[6] = inline_no_hint(pa[7], pa[8]);
+}
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -441,8 +441,12 @@
  : CodeGenOptions::OnlyAlwaysInlining);
   // -fno-inline-functions overrides OptimizationLevel > 1.
   Opts.NoInline = Args.hasArg(OPT_fno_inline);
-  Opts.setInlining(Args.hasArg(OPT_fno_inline_functions) ?
- CodeGenOptions::OnlyAlwaysInlining : Opts.getInlining());
+  if (Arg* InlineArg = Args.getLastArg(options::OPT_finline_functions,
+   options::OPT_fno_inline_functions)) {
+Opts.setInlining(
+  InlineArg->getOption().matches(options::OPT_finline_functions) ?
+CodeGenOptions::NormalInlining : CodeGenOptions::OnlyAlwaysInlining);
+  }
 
   if (Arg *A = Args.getLastArg(OPT_fveclib)) {
 StringRef Name = A->getValue();
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -5332,8 +5332,9 @@
   if (Args.hasArg(options::OPT_fno_inline))
 CmdArgs.push_back("-fno-inline");
 
-  if (Args.hasArg(options::OPT_fno_inline_functions))
-CmdArgs.push_ba

Re: [PATCH] D18540: [Sema] Note when we've actually encountered a failure in ExprConstant, and take that into account when looking up objects.

2016-05-24 Thread George Burgess IV via cfe-commits
george.burgess.iv added a comment.

Ping :)


http://reviews.llvm.org/D18540



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


Re: [PATCH] D17462: Fix a codegen bug for variadic functions with pass_object_size params

2016-05-24 Thread George Burgess IV via cfe-commits
george.burgess.iv added a comment.

Ping :)


http://reviews.llvm.org/D17462



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


Re: [PATCH] D20576: [Driver] Add support for -finline-functions and /Ob2 flags

2016-05-24 Thread Hans Wennborg via cfe-commits
hans accepted this revision.
hans added a comment.
This revision is now accepted and ready to land.

Looks good to me!

Do you have commit access, or would you like me to commit this for you?


http://reviews.llvm.org/D20576



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


Re: [PATCH] D20576: [Driver] Add support for -finline-functions and /Ob2 flags

2016-05-24 Thread Rudy Pons via cfe-commits
Ilod added a comment.

I don't have commit access, so you can do it for me, thanks.


http://reviews.llvm.org/D20576



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


[PATCH] D20596: [libcxx] Refactor locale switching, creation, and destruction

2016-05-24 Thread Ben Craig via cfe-commits
bcraig created this revision.
bcraig added reviewers: mclow.lists, EricWF, joerg, jroelofs.
bcraig added a subscriber: cfe-commits.
Herald added a subscriber: jfb.

This patch cleans up libcxx's usage of newlocale, freelocale, uselocale, and 
locale_t.

First, libcxx no longer defines the posix newlocale, freelocale, uselocale, and 
locale_t names on non-posix compliant systems.  Those names don't belong to 
libcxx, so _libcpp variants and forwarders have been created.  The renaming is 
the bulk of the diff.

Second, improved locale management RAII objects have been created and used.  
_locale_raii was a typedef for a unique_ptr with a function pointer deleter.  
That requires a fatter object and an indirect call.  Instead, a small, custom 
RAII object was added to manage the switching of locales with uselocale.  This 
also allows for a terser syntax.  An RAII object for the newlocale / freelocale 
pair was also created, as was a fancier RAII object to handle the case when we 
are handed a locale that (maybe) isn't supposed to be deleted.

The last significant change is that the nop_locale_mgmt's newlocale (used by 
newlib) will now attempt to support the "C" and "POSIX" locales, rather than 
return 0.

Tested on Linux x64, and on an embedded target that also happens to use all the 
trivial locale wrappers (like nop_locale_mgmt).

http://reviews.llvm.org/D20596

Files:
  include/__bsd_locale_fallbacks.h
  include/__locale
  include/__locale_mgmt.h
  include/__posix_locale_mgmt_defaults.h
  include/locale
  include/support/ibm/locale_mgmt_aix.h
  include/support/ibm/xlocale.h
  include/support/musl/xlocale.h
  include/support/solaris/xlocale.h
  include/support/win32/locale_mgmt_win32.h
  include/support/win32/locale_win32.h
  include/support/xlocale/__nop_locale_mgmt.h
  include/support/xlocale/__posix_l_fallback.h
  include/support/xlocale/__strtonum_fallback.h
  src/locale.cpp
  src/support/solaris/mbsnrtowcs.inc
  src/support/solaris/wcsnrtombs.inc
  src/support/solaris/xlocale.c
  src/support/win32/locale_win32.cpp

Index: src/support/win32/locale_win32.cpp
===
--- src/support/win32/locale_win32.cpp
+++ src/support/win32/locale_win32.cpp
@@ -12,13 +12,13 @@
 #include  // va_start, va_end
 
 // FIXME: base currently unused. Needs manual work to construct the new locale
-locale_t newlocale( int mask, const char * locale, locale_t /*base*/ )
+__libcpp_locale_t newlocale( int mask, const char * locale, __libcpp_locale_t /*base*/ )
 {
 return _create_locale( mask, locale );
 }
-locale_t uselocale( locale_t newloc )
+__libcpp_locale_t uselocale( __libcpp_locale_t newloc )
 {
-locale_t old_locale = _get_current_locale();
+__libcpp_locale_t old_locale = _get_current_locale();
 if ( newloc == NULL )
 return old_locale;
 // uselocale sets the thread's locale by definition, so unconditionally use thread-local locale
@@ -28,61 +28,61 @@
 // uselocale returns the old locale_t
 return old_locale;
 }
-lconv *localeconv_l( locale_t loc )
+lconv *localeconv_l( __libcpp_locale_t loc )
 {
-__locale_raii __current( uselocale(loc), uselocale );
+std::__locale_sentry __current(loc);
 return localeconv();
 }
 size_t mbrlen_l( const char *__restrict s, size_t n,
- mbstate_t *__restrict ps, locale_t loc )
+ mbstate_t *__restrict ps, __libcpp_locale_t loc )
 {
-__locale_raii __current( uselocale(loc), uselocale );
+std::__locale_sentry __current(loc);
 return mbrlen( s, n, ps );
 }
 size_t mbsrtowcs_l( wchar_t *__restrict dst, const char **__restrict src,
-size_t len, mbstate_t *__restrict ps, locale_t loc )
+size_t len, mbstate_t *__restrict ps, __libcpp_locale_t loc )
 {
-__locale_raii __current( uselocale(loc), uselocale );
+std::__locale_sentry __current(loc);
 return mbsrtowcs( dst, src, len, ps );
 }
 size_t wcrtomb_l( char *__restrict s, wchar_t wc, mbstate_t *__restrict ps,
-  locale_t loc )
+  __libcpp_locale_t loc )
 {
-__locale_raii __current( uselocale(loc), uselocale );
+std::__locale_sentry __current(loc);
 return wcrtomb( s, wc, ps );
 }
 size_t mbrtowc_l( wchar_t *__restrict pwc, const char *__restrict s,
-  size_t n, mbstate_t *__restrict ps, locale_t loc )
+  size_t n, mbstate_t *__restrict ps, __libcpp_locale_t loc )
 {
-__locale_raii __current( uselocale(loc), uselocale );
+std::__locale_sentry __current(loc);
 return mbrtowc( pwc, s, n, ps );
 }
 size_t mbsnrtowcs_l( wchar_t *__restrict dst, const char **__restrict src,
- size_t nms, size_t len, mbstate_t *__restrict ps, locale_t loc )
+ size_t nms, size_t len, mbstate_t *__restrict ps, __libcpp_locale_t loc )
 {
-__locale_raii __current( uselocale(loc), uselocale );
+std::__locale_sentry __current(loc);
 return mbs

Re: [PATCH] D20328: [libcxx] Externally threaded libc++ variant

2016-05-24 Thread Asiri Rathnayake via cfe-commits
rmaprath added inline comments.


Comment at: include/__threading_support:201
@@ +200,3 @@
+// Mutex
+#define _LIBCPP_MUTEX_INITIALIZER nullptr
+struct __libcpp_platform_mutex_t;

bcraig wrote:
> rmaprath wrote:
> > bcraig wrote:
> > > rmaprath wrote:
> > > > bcraig wrote:
> > > > > I'm not sure I like taking the freedom to define 
> > > > > _LIBCPP_MUTEX_INITIALIZER away from implementers.
> > > > > 
> > > > > Would it be too terrible to replace this entire #elif block with 
> > > > > something like the following?
> > > > > 
> > > > > ```
> > > > > #if !defined(__has_include) || __has_include()
> > > > > #include 
> > > > > #else
> > > > > #error "_LIBCPP_THREAD_API_EXTERNAL requires the implementer to 
> > > > > provide  in the include path"
> > > > > #endif
> > > > > ```
> > > > > 
> > > > > 
> > > > The problem is that, `std::mutex` constructor needs to be `constexpr` 
> > > > (as you pointed out earlier). And since `__libcpp_mutex_t` is a pointer 
> > > > type (for this externally threaded variant), sensible definitions for 
> > > > `_LIBCPP_MUTEX_INITIALIZER` are limited.
> > > > 
> > > > Other than `nullptr`, one may be able to define 
> > > > `_LIBCPP_MUTEX_INITIALIZER` to be a pointer to some constant mutex 
> > > > (presuming that make it `constexpr` OK?) but I'm not convinced if such 
> > > > a setup would be very useful.
> > > > 
> > > > Hope that sounds sensible?
> > > If the implementer gets to provide an entire header, then they also get 
> > > to choose what libcpp_mutex_t will be.  They could make it a struct.
> > This externally-threaded library variant needs to be compiled against a set 
> > API, so we have this header with declarations like `__libcpp_mutex_lock()` 
> > which are referred from within the library sources (same function 
> > signatures as those used in `LIBCPP_THREAD_API_PTHREAD` - this allows us to 
> > keep the library source changes to a minimum).
> > 
> > Now, in this particular library variant, we want to differ these calls to 
> > runtime rather than libcxx compile-time! 
> > 
> > On the other hand, I think you are proposing a compile-time (static) thread 
> > porting setup where the platform vendors need to supply a header file with 
> > appropriate definitions for these functions / types, and they would compile 
> > libcxx themselves? That sounds like a good idea, but the current patch is 
> > aiming for a different goal: we provide a pre-compiled libcxx library which 
> > calls out to those `__libcpp_xxx` functions at runtime, and platform 
> > vendors need to provide those functions, they don't have to compile libcxx 
> > themselves. This is what forces us to use opaque pointer types to capture 
> > platform-defined threading primitives.
> > 
> > Perhaps I could improve the naming here, may be 
> > `LIBCPP_HAS_RUNTIME_THREAD_API`? Or `LIBCPP_HAS_DYNAMIC_THREAD_API`?
> That is an excellent summary, and it does a good job of explaining the 
> disconnect we were having.  I'm going to push forward with the disconnect 
> though :)
> 
> I think you can implement the dynamic case in terms of the static case 
> without loss of generality or performance.  You ("Vendor X") could 
> pre-compile your library with a pointer-sized libcpp_mutex_t defined in 
> , and at runtime call out to a different library that 
> has an implementation of libcpp_mutex_lock.  Someone else ("Vendor Y") could 
> have a larger libcpp_mutex_t defined, and provide a static inline definition 
> of libcpp_mutex_lock.
OK, I think I understand your point :)

Will meditate on it a bit and spin a new patch tomorrow. Thanks!




http://reviews.llvm.org/D20328



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


r270609 - [Driver] Add support for -finline-functions and /Ob2 flags

2016-05-24 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Tue May 24 15:40:51 2016
New Revision: 270609

URL: http://llvm.org/viewvc/llvm-project?rev=270609&view=rev
Log:
[Driver] Add support for -finline-functions and /Ob2 flags

-finline-functions and /Ob2 are currently ignored by Clang. The only way to
enable inlining is to use the global O flags, which also enable other options,
or to emit LLVM bitcode using Clang, then running opt by hand with the inline
pass.

This patch allows to simply use the -finline-functions flag (same as GCC) or
/Ob2 in clang-cl mode to enable inlining without other optimizations.

This is the first patch of a serie to improve support for the /Ob flags.

Patch by Rudy Pons !

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

Added:
cfe/trunk/test/CodeGen/inline-optim.cc
Modified:
cfe/trunk/include/clang/Driver/CLCompatOptions.td
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/test/Driver/cl-options.c
cfe/trunk/test/Driver/clang_f_opts.c

Modified: cfe/trunk/include/clang/Driver/CLCompatOptions.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CLCompatOptions.td?rev=270609&r1=270608&r2=270609&view=diff
==
--- cfe/trunk/include/clang/Driver/CLCompatOptions.td (original)
+++ cfe/trunk/include/clang/Driver/CLCompatOptions.td Tue May 24 15:40:51 2016
@@ -102,6 +102,8 @@ def _SLASH_O0 : CLFlag<"O0">, Alias;
 def _SLASH_O : CLJoined<"O">, HelpText<"Optimization level">;
 def _SLASH_Ob0 : CLFlag<"Ob0">, HelpText<"Disable inlining">,
   Alias;
+def _SLASH_Ob2 : CLFlag<"Ob2">, HelpText<"Enable inlining">,
+  Alias;
 def _SLASH_Od : CLFlag<"Od">, HelpText<"Disable optimization">, Alias;
 def _SLASH_Oi : CLFlag<"Oi">, HelpText<"Enable use of builtin functions">,
   Alias;
@@ -293,7 +295,6 @@ def _SLASH_GS_ : CLIgnoredFlag<"GS-">;
 def _SLASH_kernel_ : CLIgnoredFlag<"kernel-">;
 def _SLASH_nologo : CLIgnoredFlag<"nologo">;
 def _SLASH_Ob1 : CLIgnoredFlag<"Ob1">;
-def _SLASH_Ob2 : CLIgnoredFlag<"Ob2">;
 def _SLASH_Og : CLIgnoredFlag<"Og">;
 def _SLASH_openmp_ : CLIgnoredFlag<"openmp-">;
 def _SLASH_RTC : CLIgnoredJoined<"RTC">;

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=270609&r1=270608&r2=270609&view=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Tue May 24 15:40:51 2016
@@ -741,7 +741,7 @@ def fgnu_runtime : Flag<["-"], "fgnu-run
 def fheinous_gnu_extensions : Flag<["-"], "fheinous-gnu-extensions">, 
Flags<[CC1Option]>;
 def filelist : Separate<["-"], "filelist">, Flags<[LinkerInput]>;
 def : Flag<["-"], "findirect-virtual-calls">, Alias;
-def finline_functions : Flag<["-"], "finline-functions">, 
Group;
+def finline_functions : Flag<["-"], "finline-functions">, 
Group, Flags<[CC1Option]>;
 def finline : Flag<["-"], "finline">, Group;
 def finput_charset_EQ : Joined<["-"], "finput-charset=">, Group;
 def fexec_charset_EQ : Joined<["-"], "fexec-charset=">, Group;

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=270609&r1=270608&r2=270609&view=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Tue May 24 15:40:51 2016
@@ -5332,8 +5332,9 @@ void Clang::ConstructJob(Compilation &C,
   if (Args.hasArg(options::OPT_fno_inline))
 CmdArgs.push_back("-fno-inline");
 
-  if (Args.hasArg(options::OPT_fno_inline_functions))
-CmdArgs.push_back("-fno-inline-functions");
+  if (Arg* InlineArg = Args.getLastArg(options::OPT_finline_functions,
+   options::OPT_fno_inline_functions))
+InlineArg->render(Args, CmdArgs);
 
   ObjCRuntime objcRuntime = AddObjCRuntimeArgs(Args, CmdArgs, rewriteKind);
 

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=270609&r1=270608&r2=270609&view=diff
==
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Tue May 24 15:40:51 2016
@@ -441,8 +441,12 @@ static bool ParseCodeGenArgs(CodeGenOpti
  : CodeGenOptions::OnlyAlwaysInlining);
   // -fno-inline-functions overrides OptimizationLevel > 1.
   Opts.NoInline = Args.hasArg(OPT_fno_inline);
-  Opts.setInlining(Args.hasArg(OPT_fno_inline_functions) ?
- CodeGenOptions::OnlyAlwaysInlining : Opts.getInlining());
+  if (Arg* InlineArg = Args.getLastArg(options::OPT_finline_functions,
+ 

Re: [PATCH] D20576: [Driver] Add support for -finline-functions and /Ob2 flags

2016-05-24 Thread Hans Wennborg via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL270609: [Driver] Add support for -finline-functions and /Ob2 
flags (authored by hans).

Changed prior to commit:
  http://reviews.llvm.org/D20576?vs=58302&id=58308#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D20576

Files:
  cfe/trunk/include/clang/Driver/CLCompatOptions.td
  cfe/trunk/include/clang/Driver/Options.td
  cfe/trunk/lib/Driver/Tools.cpp
  cfe/trunk/lib/Frontend/CompilerInvocation.cpp
  cfe/trunk/test/CodeGen/inline-optim.cc
  cfe/trunk/test/Driver/cl-options.c
  cfe/trunk/test/Driver/clang_f_opts.c

Index: cfe/trunk/include/clang/Driver/Options.td
===
--- cfe/trunk/include/clang/Driver/Options.td
+++ cfe/trunk/include/clang/Driver/Options.td
@@ -741,7 +741,7 @@
 def fheinous_gnu_extensions : Flag<["-"], "fheinous-gnu-extensions">, Flags<[CC1Option]>;
 def filelist : Separate<["-"], "filelist">, Flags<[LinkerInput]>;
 def : Flag<["-"], "findirect-virtual-calls">, Alias;
-def finline_functions : Flag<["-"], "finline-functions">, Group;
+def finline_functions : Flag<["-"], "finline-functions">, Group, Flags<[CC1Option]>;
 def finline : Flag<["-"], "finline">, Group;
 def finput_charset_EQ : Joined<["-"], "finput-charset=">, Group;
 def fexec_charset_EQ : Joined<["-"], "fexec-charset=">, Group;
Index: cfe/trunk/include/clang/Driver/CLCompatOptions.td
===
--- cfe/trunk/include/clang/Driver/CLCompatOptions.td
+++ cfe/trunk/include/clang/Driver/CLCompatOptions.td
@@ -102,6 +102,8 @@
 def _SLASH_O : CLJoined<"O">, HelpText<"Optimization level">;
 def _SLASH_Ob0 : CLFlag<"Ob0">, HelpText<"Disable inlining">,
   Alias;
+def _SLASH_Ob2 : CLFlag<"Ob2">, HelpText<"Enable inlining">,
+  Alias;
 def _SLASH_Od : CLFlag<"Od">, HelpText<"Disable optimization">, Alias;
 def _SLASH_Oi : CLFlag<"Oi">, HelpText<"Enable use of builtin functions">,
   Alias;
@@ -293,7 +295,6 @@
 def _SLASH_kernel_ : CLIgnoredFlag<"kernel-">;
 def _SLASH_nologo : CLIgnoredFlag<"nologo">;
 def _SLASH_Ob1 : CLIgnoredFlag<"Ob1">;
-def _SLASH_Ob2 : CLIgnoredFlag<"Ob2">;
 def _SLASH_Og : CLIgnoredFlag<"Og">;
 def _SLASH_openmp_ : CLIgnoredFlag<"openmp-">;
 def _SLASH_RTC : CLIgnoredJoined<"RTC">;
Index: cfe/trunk/test/Driver/cl-options.c
===
--- cfe/trunk/test/Driver/cl-options.c
+++ cfe/trunk/test/Driver/cl-options.c
@@ -97,6 +97,9 @@
 // RUN: %clang_cl /Ob0 -### -- %s 2>&1 | FileCheck -check-prefix=Ob0 %s
 // Ob0: -fno-inline
 
+// RUN: %clang_cl /Ob2 -### -- %s 2>&1 | FileCheck -check-prefix=Ob2 %s
+// Ob2: -finline-functions
+
 // RUN: %clang_cl /Od -### -- %s 2>&1 | FileCheck -check-prefix=Od %s
 // Od: -O0
 
@@ -265,7 +268,6 @@
 // RUN:/kernel- \
 // RUN:/nologo \
 // RUN:/Ob1 \
-// RUN:/Ob2 \
 // RUN:/openmp- \
 // RUN:/RTC1 \
 // RUN:/sdl \
Index: cfe/trunk/test/Driver/clang_f_opts.c
===
--- cfe/trunk/test/Driver/clang_f_opts.c
+++ cfe/trunk/test/Driver/clang_f_opts.c
@@ -285,7 +285,6 @@
 // RUN: -fexpensive-optimizations \
 // RUN: -fno-expensive-optimizations  \
 // RUN: -fno-defer-pop\
-// RUN: -finline-functions\
 // RUN: -fkeep-inline-functions   \
 // RUN: -fno-keep-inline-functions\
 // RUN: -freorder-blocks  \
@@ -353,7 +352,6 @@
 // CHECK-WARNING-DAG: optimization flag '-fexpensive-optimizations' is not supported
 // CHECK-WARNING-DAG: optimization flag '-fno-expensive-optimizations' is not supported
 // CHECK-WARNING-DAG: optimization flag '-fno-defer-pop' is not supported
-// CHECK-WARNING-DAG: optimization flag '-finline-functions' is not supported
 // CHECK-WARNING-DAG: optimization flag '-fkeep-inline-functions' is not supported
 // CHECK-WARNING-DAG: optimization flag '-fno-keep-inline-functions' is not supported
 // CHECK-WARNING-DAG: optimization flag '-freorder-blocks' is not supported
Index: cfe/trunk/test/CodeGen/inline-optim.cc
===
--- cfe/trunk/test/CodeGen/inline-optim.cc
+++ cfe/trunk/test/CodeGen/inline-optim.cc
@@ -0,0 +1,26 @@
+// Make sure -finline-functions family flags are behaving correctly.
+
+// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck -check-prefix=NOINLINE %s
+// RUN: %clang_cc1 -O3 -fno-inline-functions -emit-llvm %s -o - | FileCheck -check-prefix=NOINLINE %s
+// RUN: %clang_cc1 -finline-functions -emit-llvm %s -o - | FileCheck -check-prefix=INLINE %s
+
+inline int inline_hint(int a, int b) { return(a+b); }
+
+int inline_no

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

2016-05-24 Thread Piotr Padlewski via cfe-commits
Prazek updated this revision to Diff 58309.
Prazek added a comment.

Some small bugfixes afeter running it on llvm


http://reviews.llvm.org/D18821

Files:
  clang-tidy/CMakeLists.txt
  clang-tidy/bugprone/BoolToIntegerConversionCheck.cpp
  clang-tidy/bugprone/BoolToIntegerConversionCheck.h
  clang-tidy/bugprone/BugProneModule.cpp
  clang-tidy/bugprone/CMakeLists.txt
  clang-tidy/plugin/CMakeLists.txt
  clang-tidy/tool/CMakeLists.txt
  clang-tidy/tool/ClangTidyMain.cpp
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/bugprone-bool-to-integer-conversion.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/index.rst
  test/clang-tidy/bugprone-bool-to-integer-conversion.cpp

Index: test/clang-tidy/bugprone-bool-to-integer-conversion.cpp
===
--- /dev/null
+++ test/clang-tidy/bugprone-bool-to-integer-conversion.cpp
@@ -0,0 +1,200 @@
+// RUN: %check_clang_tidy %s bugprone-bool-to-integer-conversion %t
+
+const int is42Answer = true;
+// CHECK-MESSAGES: :[[@LINE-1]]:24: warning: implicitly converting bool literal to 'int'; use integer literal instead [bugprone-bool-to-integer-conversion]
+// CHECK-FIXES: const int is42Answer = 1;{{$}}
+
+volatile int noItsNot = false;
+// CHECK-MESSAGES: :[[@LINE-1]]:25: warning: implicitly converting bool literal to 'int'; {{..}}
+// CHECK-FIXES: volatile int noItsNot = 0;{{$}}
+int a = 42;
+int az = a;
+
+long long ll = true;
+// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: implicitly converting bool literal to 'long long';{{..}}
+// CHECK-FIXES: long long ll = 1;{{$}}
+
+void fun(int) {}
+#define ONE true
+
+// No fixup for macros.
+int one = ONE;
+// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: implicitly converting bool literal to 'int'; use integer literal instead [bugprone-bool-to-integer-conversion]
+
+void test() {
+  fun(ONE);
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: implicitly converting bool{{..}}
+
+  fun(42);
+  fun(true);
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: implicitly {{..}}
+// CHECK-FIXES: fun(1);{{$}}
+}
+
+char c = true;
+// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: implicitly {{..}}
+// CHECK-FIXES: char c = 1;
+
+float f = false;
+// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: implicitly converting bool literal to 'float';{{..}}
+// CHECK-FIXES: float f = 0;
+
+struct Blah {
+  Blah(int blah) { }
+};
+
+const int &ref = false;
+// CHECK-MESSAGES: :[[@LINE-1]]:18: warning: implicitly converting bool literal to 'int'{{..}}
+// CHECK-FIXES: const int &ref = 0;
+
+Blah bla = true;
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: implicitly converting bool literal to 'int'{{..}}
+// CHECK-FIXES: Blah bla = 1;
+
+Blah bla2 = 1;
+
+char c2 = 1;
+char c3 = '0';
+bool b = true;
+
+// Don't warn of bitfields of size 1. Unfortunately we can't just
+// change type of flag to bool, because some compilers like MSVC doesn't
+// pack bitfields of different types.
+struct BitFields {
+  BitFields() : a(true), flag(false) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:19: warning: implicitly converting
+// CHECK-FIXES: BitFields() : a(1), flag(false) {}
+
+  unsigned a : 3;
+  unsigned flag : 1;
+};
+
+struct some_struct {
+  bool p;
+  int z;
+};
+
+void testBitFields() {
+  BitFields b;
+  b.flag = true;
+  b.a = true;
+// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: implicitly converting
+// CHECK-FIXES: b.a = 1;
+
+  b.flag |= true;
+  some_struct s;
+  s.p |= true;
+  s.z |= true;
+// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: implicitly converting
+// CHECK-FIXES: s.z |= 1;
+}
+
+bool returnsBool() { return true; }
+
+void test_operators() {
+  bool p = false;
+  if (p == false) {
+
+  }
+  int z = 1;
+  if (z == true) {
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: implicitly converting
+// CHECK-FIXES: if (z == 1) {
+
+  }
+  bool p2 = false != p;
+
+  int z2 = z - true;
+// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: implicitly converting
+// CHECK-FIXES: int z2 = z - 1;
+
+  bool p3 = z + true;
+// CHECK-MESSAGES: :[[@LINE-1]]:17: warning: implicitly converting
+// CHECK-FIXES: bool p3 = z + 1;
+
+  if(true && p == false) {}
+  if (returnsBool() == false) {}
+}
+
+bool ok() {
+  return true;
+  {
+return false;
+  }
+  bool z;
+  return z;
+}
+
+int change_type();
+// CHECK-FIXES: bool change_type();
+
+// This function returns only bools
+int change_type() {
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: function has return type 'int' but returns only bools [bugprone-bool-to-integer-conversion]
+  // CHECK-FIXES: bool change_type() {
+
+  bool p;
+  return p;
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: note: converting bool to 'int' here
+
+  return true;
+  {
+return false;
+  }
+  return ok();
+}
+
+int change_type(int);
+
+char change_type2() {
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function has return type 'char' but returns only bools [bugprone-bool-to-integer-conversion]
+  // CHECK-FIXES: bool change_type2() {
+
+  bool z;
+  return z;
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: note: converting bool to

[PATCH] D20597: Speed up check by using a recursive visitor.

2016-05-24 Thread Samuel Benzaquen via cfe-commits
sbenza created this revision.
sbenza added a reviewer: alexfh.
sbenza added a subscriber: cfe-commits.

Use a recursive visitor instead of forEachDescendant() matcher.
The latter requires several layers of virtual function calls for each node and
it is more expensive than the visitor.
Benchmark results show improvement of ~6% walltime in clang-tidy.

http://reviews.llvm.org/D20597

Files:
  clang-tidy/readability/FunctionSizeCheck.cpp
  clang-tidy/readability/FunctionSizeCheck.h

Index: clang-tidy/readability/FunctionSizeCheck.h
===
--- clang-tidy/readability/FunctionSizeCheck.h
+++ clang-tidy/readability/FunctionSizeCheck.h
@@ -34,21 +34,11 @@
   void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
   void registerMatchers(ast_matchers::MatchFinder *Finder) override;
   void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
-  void onEndOfTranslationUnit() override;
 
 private:
-  struct FunctionInfo {
-FunctionInfo() : Lines(0), Statements(0), Branches(0) {}
-unsigned Lines;
-unsigned Statements;
-unsigned Branches;
-  };
-
   const unsigned LineThreshold;
   const unsigned StatementThreshold;
   const unsigned BranchThreshold;
-
-  llvm::DenseMap FunctionInfos;
 };
 
 } // namespace readability
Index: clang-tidy/readability/FunctionSizeCheck.cpp
===
--- clang-tidy/readability/FunctionSizeCheck.cpp
+++ clang-tidy/readability/FunctionSizeCheck.cpp
@@ -8,14 +8,64 @@
 //===--===//
 
 #include "FunctionSizeCheck.h"
+#include "clang/AST/RecursiveASTVisitor.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 
 using namespace clang::ast_matchers;
 
 namespace clang {
 namespace tidy {
 namespace readability {
 
+class FunctionASTVisitor : public RecursiveASTVisitor {
+  using Base = RecursiveASTVisitor;
+
+ public:
+  bool TraverseStmt(Stmt* Node) {
+if (!Node) return Base::TraverseStmt(Node);
+
+if (TrackedParent.back() && !isa(Node)) ++Info.Statements;
+
+switch (Node->getStmtClass()) {
+  case Stmt::IfStmtClass:
+  case Stmt::WhileStmtClass:
+  case Stmt::DoStmtClass:
+  case Stmt::CXXForRangeStmtClass:
+  case Stmt::ForStmtClass:
+  case Stmt::SwitchStmtClass:
+++Info.Branches;
+// fallthrough
+  case Stmt::CompoundStmtClass:
+TrackedParent.push_back(true);
+break;
+  default:
+TrackedParent.push_back(false);
+break;
+}
+
+Base::TraverseStmt(Node);
+
+TrackedParent.pop_back();
+return true;
+  }
+
+  bool TraverseDecl(Decl* Node) {
+TrackedParent.push_back(false);
+Base::TraverseDecl(Node);
+TrackedParent.pop_back();
+return true;
+  }
+
+  struct FunctionInfo {
+FunctionInfo() : Lines(0), Statements(0), Branches(0) {}
+unsigned Lines;
+unsigned Statements;
+unsigned Branches;
+  };
+  FunctionInfo Info;
+  std::vector TrackedParent;
+};
+
 FunctionSizeCheck::FunctionSizeCheck(StringRef Name, ClangTidyContext *Context)
 : ClangTidyCheck(Name, Context),
   LineThreshold(Options.get("LineThreshold", -1U)),
@@ -29,76 +79,52 @@
 }
 
 void FunctionSizeCheck::registerMatchers(MatchFinder *Finder) {
-  Finder->addMatcher(
-  functionDecl(
-  unless(isInstantiated()),
-  forEachDescendant(
-  stmt(unless(compoundStmt()),
-   hasParent(stmt(anyOf(compoundStmt(), ifStmt(),
-anyOf(whileStmt(), doStmt(),
-  cxxForRangeStmt(), forStmt())
-  .bind("stmt"))).bind("func"),
-  this);
+  Finder->addMatcher(functionDecl(unless(isInstantiated())).bind("func"), this);
 }
 
 void FunctionSizeCheck::check(const MatchFinder::MatchResult &Result) {
   const auto *Func = Result.Nodes.getNodeAs("func");
 
-  FunctionInfo &FI = FunctionInfos[Func];
+  FunctionASTVisitor Visitor;
+  Visitor.TraverseDecl(const_cast(Func));
+  auto& FI = Visitor.Info;
+
+  if (FI.Statements == 0) return;
 
   // Count the lines including whitespace and comments. Really simple.
-  if (!FI.Lines) {
-if (const Stmt *Body = Func->getBody()) {
-  SourceManager *SM = Result.SourceManager;
-  if (SM->isWrittenInSameFile(Body->getLocStart(), Body->getLocEnd())) {
-FI.Lines = SM->getSpellingLineNumber(Body->getLocEnd()) -
-   SM->getSpellingLineNumber(Body->getLocStart());
-  }
+  if (const Stmt *Body = Func->getBody()) {
+SourceManager *SM = Result.SourceManager;
+if (SM->isWrittenInSameFile(Body->getLocStart(), Body->getLocEnd())) {
+  FI.Lines = SM->getSpellingLineNumber(Body->getLocEnd()) -
+   SM->getSpellingLineNumber(Body->getLocStart());
 }
   }
 
-  const auto *Statement = Result.Nodes.getNodeAs("stmt");
-  ++FI.Statements;
-
-  // TODO: sw

  1   2   >