[PATCH] D31029: [analyzer] Fix logical not for pointers with different bit width

2017-04-03 Thread Daniel Marjamäki via Phabricator via cfe-commits
danielmarjamaki added a comment.

Ping


Repository:
  rL LLVM

https://reviews.llvm.org/D31029



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


[PATCH] D30295: [analyzer] clarify undef shift result when shift count is negative or exceeds the bit width

2017-04-03 Thread Daniel Marjamäki via Phabricator via cfe-commits
danielmarjamaki added a comment.

Ping


Repository:
  rL LLVM

https://reviews.llvm.org/D30295



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


[PATCH] D25596: alpha.core.Conversion - Fix false positive for 'U32 += S16; ' expression, that is not unsafe

2017-04-03 Thread Daniel Marjamäki via Phabricator via cfe-commits
danielmarjamaki added a comment.

Ping


Repository:
  rL LLVM

https://reviews.llvm.org/D25596



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


[PATCH] D30691: [analyzer] Support for naive cross translational unit analysis

2017-04-03 Thread Daniel Marjamäki via Phabricator via cfe-commits
danielmarjamaki added inline comments.



Comment at: tools/xtu-analysis/xtu-analyze.py:29
+
+threading_factor = int(multiprocessing.cpu_count() * 1.5)
+analyser_output_formats = ['plist-multi-file', 'plist', 'plist-html',

gerazo wrote:
> danielmarjamaki wrote:
> > does this mean that if there are 4 cores this script will by default use 6 
> > threads? isn't that too aggressive?
> Yes, it does mean that. You are right, it is aggressive. To be honest, the 
> xtu-build step is more io intensive where it really makes sense. In the 
> xtu-analyze step, it is marginal when big files are compiled (more cpu, less 
> io).  We will put this one back to 1.0 instead.
I see. Feel free to use such ratio.


https://reviews.llvm.org/D30691



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


[PATCH] D26953: clang-format: handle formatting on constexpr if

2017-04-03 Thread Gonzalo BG via Phabricator via cfe-commits
gnzlbg added a comment.

any progress on this?


https://reviews.llvm.org/D26953



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


r299354 - [ASTImporter] Lookup SearchName instead of Name

2017-04-03 Thread Gabor Horvath via cfe-commits
Author: xazax
Date: Mon Apr  3 04:30:20 2017
New Revision: 299354

URL: http://llvm.org/viewvc/llvm-project?rev=299354&view=rev
Log:
[ASTImporter] Lookup SearchName instead of Name

When the SearchName is already calculated we should use that for the lookup.

Patch by Peter Szecsi!

Differential Revision: https://reviews.llvm.org/D30877

Modified:
cfe/trunk/lib/AST/ASTImporter.cpp
cfe/trunk/test/ASTMerge/struct/Inputs/struct1.c
cfe/trunk/test/ASTMerge/struct/Inputs/struct2.c
cfe/trunk/test/ASTMerge/struct/test.c

Modified: cfe/trunk/lib/AST/ASTImporter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTImporter.cpp?rev=299354&r1=299353&r2=299354&view=diff
==
--- cfe/trunk/lib/AST/ASTImporter.cpp (original)
+++ cfe/trunk/lib/AST/ASTImporter.cpp Mon Apr  3 04:30:20 2017
@@ -2919,7 +2919,7 @@ Decl *ASTNodeImporter::VisitEnumDecl(Enu
   if (!DC->isFunctionOrMethod() && SearchName) {
 SmallVector ConflictingDecls;
 SmallVector FoundDecls;
-DC->getRedeclContext()->localUncachedLookup(Name, FoundDecls);
+DC->getRedeclContext()->localUncachedLookup(SearchName, FoundDecls);
 for (unsigned I = 0, N = FoundDecls.size(); I != N; ++I) {
   if (!FoundDecls[I]->isInIdentifierNamespace(IDNS))
 continue;
@@ -3008,7 +3008,7 @@ Decl *ASTNodeImporter::VisitRecordDecl(R
   if (!DC->isFunctionOrMethod()) {
 SmallVector ConflictingDecls;
 SmallVector FoundDecls;
-DC->getRedeclContext()->localUncachedLookup(Name, FoundDecls);
+DC->getRedeclContext()->localUncachedLookup(SearchName, FoundDecls);
 for (unsigned I = 0, N = FoundDecls.size(); I != N; ++I) {
   if (!FoundDecls[I]->isInIdentifierNamespace(IDNS))
 continue;

Modified: cfe/trunk/test/ASTMerge/struct/Inputs/struct1.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ASTMerge/struct/Inputs/struct1.c?rev=299354&r1=299353&r2=299354&view=diff
==
--- cfe/trunk/test/ASTMerge/struct/Inputs/struct1.c (original)
+++ cfe/trunk/test/ASTMerge/struct/Inputs/struct1.c Mon Apr  3 04:30:20 2017
@@ -61,3 +61,19 @@ struct {
   Int i;
   float f;
 } x11;
+
+// Matches
+typedef struct {
+  Int i;
+  float f;
+} S12;
+
+S12 x12;
+
+// Mismatch
+typedef struct {
+  Float i; // Mismatch here.
+  float f;
+} S13;
+
+S13 x13;

Modified: cfe/trunk/test/ASTMerge/struct/Inputs/struct2.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ASTMerge/struct/Inputs/struct2.c?rev=299354&r1=299353&r2=299354&view=diff
==
--- cfe/trunk/test/ASTMerge/struct/Inputs/struct2.c (original)
+++ cfe/trunk/test/ASTMerge/struct/Inputs/struct2.c Mon Apr  3 04:30:20 2017
@@ -58,3 +58,19 @@ struct {
   int i;
   float f;
 } x11;
+
+// Matches
+typedef struct {
+  int i;
+  float f;
+} S12;
+
+S12 x12;
+
+// Mismatch
+typedef struct {
+  int i; // Mismatch here.
+  float f;
+} S13;
+
+S13 x13;

Modified: cfe/trunk/test/ASTMerge/struct/test.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ASTMerge/struct/test.c?rev=299354&r1=299353&r2=299354&view=diff
==
--- cfe/trunk/test/ASTMerge/struct/test.c (original)
+++ cfe/trunk/test/ASTMerge/struct/test.c Mon Apr  3 04:30:20 2017
@@ -39,4 +39,9 @@
 // CHECK: struct2.c:53:43: note: field 'Deeper' has type 'struct DeeperError 
*' here
 // CHECK: struct2.c:54:3: error: external variable 'xDeep' declared with 
incompatible types in different translation units ('struct DeepError' vs. 
'struct DeepError')
 // CHECK: struct1.c:57:3: note: declared here with type 'struct DeepError'
-// CHECK: 8 warnings and 7 errors generated
+// CHECK: struct1.c:74:9: warning: type 'S13' has incompatible definitions in 
different translation units
+// CHECK: struct1.c:75:9: note: field 'i' has type 'Float' (aka 'float') here
+// CHECK: struct2.c:72:7: note: field 'i' has type 'int' here
+// CHECK: struct2.c:76:5: error: external variable 'x13' declared with 
incompatible types in different translation units ('S13' vs. 'S13')
+// CHECK: struct1.c:79:5: note: declared here with type 'S13'
+// CHECK: 9 warnings and 8 errors generated


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


[PATCH] D30643: [OpenCL] Extended diagnostics for atomic initialization

2017-04-03 Thread Egor Churaev via Phabricator via cfe-commits
echuraev updated this revision to Diff 93837.
echuraev marked an inline comment as done.

https://reviews.llvm.org/D30643

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaInit.cpp
  test/Parser/opencl-atomics-cl20.cl
  test/SemaOpenCL/atomic-init.cl


Index: test/SemaOpenCL/atomic-init.cl
===
--- /dev/null
+++ test/SemaOpenCL/atomic-init.cl
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -O0 -cl-std=CL2.0 -fsyntax-only -verify  %s
+
+global atomic_int a1 = 0;
+
+kernel void test_atomic_initialization() {
+  a1 = 1; // expected-error {{atomic variable can be assigned to a variable 
only in global address space}}
+  atomic_int a2 = 0; // expected-error {{atomic variable can be initialized to 
a variable only in global address space}}
+  private atomic_int a3 = 0; // expected-error {{atomic variable can be 
initialized to a variable only in global address space}}
+  local atomic_int a4 = 0; // expected-error {{'__local' variable cannot have 
an initializer}}
+  global atomic_int a5 = 0; // expected-error {{function scope variable cannot 
be declared in global address space}}
+  static global atomic_int a6 = 0;
+}
Index: test/Parser/opencl-atomics-cl20.cl
===
--- test/Parser/opencl-atomics-cl20.cl
+++ test/Parser/opencl-atomics-cl20.cl
@@ -67,7 +67,7 @@
   foo(&i);
 // OpenCL v2.0 s6.13.11.8, arithemtic operations are not permitted on atomic 
types.
   i++; // expected-error {{invalid argument type 'atomic_int' (aka 
'_Atomic(int)') to unary expression}}
-  i = 1; // expected-error {{atomic variable can only be assigned to a compile 
time constant in the declaration statement in the program scope}}
+  i = 1; // expected-error {{atomic variable can be assigned to a variable 
only in global address space}}
   i += 1; // expected-error {{invalid operands to binary expression 
('atomic_int' (aka '_Atomic(int)') and 'int')}}
   i = i + i; // expected-error {{invalid operands to binary expression 
('atomic_int' (aka '_Atomic(int)') and 'atomic_int')}}
 }
Index: lib/Sema/SemaInit.cpp
===
--- lib/Sema/SemaInit.cpp
+++ lib/Sema/SemaInit.cpp
@@ -6502,6 +6502,20 @@
   << Init->getSourceRange();
   }
 
+  // OpenCL v2.0 s6.13.11.1. atomic variables can be initialized in global 
scope
+  QualType ETy = Entity.getType();
+  Qualifiers TyQualifiers = ETy.getQualifiers();
+  bool HasGlobalAS = TyQualifiers.hasAddressSpace() &&
+ TyQualifiers.getAddressSpace() == LangAS::opencl_global;
+
+  if (S.getLangOpts().OpenCLVersion >= 200 &&
+  ETy->isAtomicType() && !HasGlobalAS &&
+  Entity.getKind() == InitializedEntity::EK_Variable && Args.size() > 0) {
+S.Diag(Args[0]->getLocStart(), diag::err_opencl_atomic_init) << 1 <<
+SourceRange(Entity.getDecl()->getLocStart(), Args[0]->getLocEnd());
+return ExprError();
+  }
+
   // Diagnose cases where we initialize a pointer to an array temporary, and 
the
   // pointer obviously outlives the temporary.
   if (Args.size() == 1 && Args[0]->getType()->isArrayType() &&
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -11121,7 +11121,7 @@
 if (LHSTy->isAtomicType() || RHSTy->isAtomicType()) {
   SourceRange SR(LHSExpr->getLocStart(), RHSExpr->getLocEnd());
   if (BO_Assign == Opc)
-Diag(OpLoc, diag::err_atomic_init_constant) << SR;
+Diag(OpLoc, diag::err_opencl_atomic_init) << 0 << SR;
   else
 ResultTy = InvalidOperands(OpLoc, LHS, RHS);
   return ExprError();
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -8284,9 +8284,9 @@
   "return value cannot be qualified with address space">;
 def err_opencl_constant_no_init : Error<
   "variable in constant address space must be initialized">;
-def err_atomic_init_constant : Error<
-  "atomic variable can only be assigned to a compile time constant"
-  " in the declaration statement in the program scope">;
+def err_opencl_atomic_init: Error<
+  "atomic variable can be %select{assigned|initialized}0 to a variable only "
+  "in global address space">;
 def err_opencl_implicit_vector_conversion : Error<
   "implicit conversions between vector types (%0 and %1) are not permitted">;
 def err_opencl_invalid_type_array : Error<


Index: test/SemaOpenCL/atomic-init.cl
===
--- /dev/null
+++ test/SemaOpenCL/atomic-init.cl
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -O0 -cl-std=CL2.0 -fsyntax-only -verify  %s
+
+global atomic_int a1 = 0;
+
+kernel void test_atomic_initialization() {
+  a1 = 1; // expected-error {{atomic variable can 

[PATCH] D31594: [OpenCL] Enables passing sampler initializer to function argument

2017-04-03 Thread Egor Churaev via Phabricator via cfe-commits
echuraev created this revision.
Herald added a subscriber: yaxunl.

https://reviews.llvm.org/D31594

Files:
  lib/Sema/SemaInit.cpp
  test/SemaOpenCL/sampler_t.cl


Index: test/SemaOpenCL/sampler_t.cl
===
--- test/SemaOpenCL/sampler_t.cl
+++ test/SemaOpenCL/sampler_t.cl
@@ -65,7 +65,7 @@
   foo(const_smp5);
   foo(const_smp6);
   foo(argsmp);
-  foo(5); // expected-error{{sampler_t variable required - got 'int'}}
+  foo(CLK_ADDRESS_CLAMP_TO_EDGE | CLK_NORMALIZED_COORDS_TRUE | 
CLK_FILTER_LINEAR);
   sampler_t sa[] = {argsmp, const_smp}; // expected-error {{array of 
'sampler_t' type is invalid in OpenCL}}
   foo(sa[0]);
   foo(bad());
Index: lib/Sema/SemaInit.cpp
===
--- lib/Sema/SemaInit.cpp
+++ lib/Sema/SemaInit.cpp
@@ -7174,7 +7174,7 @@
   QualType SourceType = Init->getType();
   // Case 1
   if (Entity.isParameterKind()) {
-if (!SourceType->isSamplerT()) {
+if (!SourceType->isSamplerT() && !SourceType->isIntegerType()) {
   S.Diag(Kind.getLocation(), diag::err_sampler_argument_required)
 << SourceType;
   break;


Index: test/SemaOpenCL/sampler_t.cl
===
--- test/SemaOpenCL/sampler_t.cl
+++ test/SemaOpenCL/sampler_t.cl
@@ -65,7 +65,7 @@
   foo(const_smp5);
   foo(const_smp6);
   foo(argsmp);
-  foo(5); // expected-error{{sampler_t variable required - got 'int'}}
+  foo(CLK_ADDRESS_CLAMP_TO_EDGE | CLK_NORMALIZED_COORDS_TRUE | CLK_FILTER_LINEAR);
   sampler_t sa[] = {argsmp, const_smp}; // expected-error {{array of 'sampler_t' type is invalid in OpenCL}}
   foo(sa[0]);
   foo(bad());
Index: lib/Sema/SemaInit.cpp
===
--- lib/Sema/SemaInit.cpp
+++ lib/Sema/SemaInit.cpp
@@ -7174,7 +7174,7 @@
   QualType SourceType = Init->getType();
   // Case 1
   if (Entity.isParameterKind()) {
-if (!SourceType->isSamplerT()) {
+if (!SourceType->isSamplerT() && !SourceType->isIntegerType()) {
   S.Diag(Kind.getLocation(), diag::err_sampler_argument_required)
 << SourceType;
   break;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D31417: [OpenMP] Add support for omp simd pragmas without runtime

2017-04-03 Thread Graham Hunter via Phabricator via cfe-commits
huntergr updated this revision to Diff 93841.
huntergr added a reviewer: kkwli0.
huntergr added a comment.

Changed to transform combined constructs to simd in ParseOpenMP.cpp instead of 
creating a new pragma handler. This also made it easier to add support for 
'declare simd': only needed the addition of a check for the option when code 
generating functions to enable it, so I've added a RUN line to test it in the 
'declare simd' codegen tests.


https://reviews.llvm.org/D31417

Files:
  docs/ClangCommandLineReference.rst
  docs/UsersManual.rst
  include/clang/Basic/LangOptions.def
  include/clang/Driver/Options.td
  lib/CodeGen/CodeGenFunction.cpp
  lib/CodeGen/CodeGenModule.cpp
  lib/Driver/ToolChains/Clang.cpp
  lib/Frontend/CompilerInvocation.cpp
  lib/Parse/ParseOpenMP.cpp
  lib/Parse/ParsePragma.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaOpenMP.cpp
  test/OpenMP/declare_simd_codegen.cpp
  test/OpenMP/linking.c
  test/OpenMP/simd_only.c

Index: test/OpenMP/simd_only.c
===
--- /dev/null
+++ test/OpenMP/simd_only.c
@@ -0,0 +1,157 @@
+// RUN: %clang_cc1 -verify -fopenmp-simd -x c -triple aarch64-unknown-unknown -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -verify -fopenmp-simd -x c -triple x86_64-unknown-unknown -emit-llvm %s -o - | FileCheck %s
+// expected-no-diagnostics
+
+// CHECK-LABEL: @simd_plain
+// CHECK-LABEL: omp.inner.for.body:
+// CHECK: load float, float* %arrayidx{{.*}} !llvm.mem.parallel_loop_access
+// CHECK: load float, float* %arrayidx{{.*}} !llvm.mem.parallel_loop_access
+// CHECK: store float %{{.*}}, float* %arrayidx{{.*}} !llvm.mem.parallel_loop_access
+// CHECK: ret void
+void simd_plain(float *a, float *b, float *c, int N) {
+  #pragma omp simd
+  for (int i = 0; i < N; i += 2)
+a[i] = b[i] * c[i];
+}
+
+// CHECK-LABEL: @simd_safelen_clause
+// CHECK-NOT: !llvm.mem.parallel_loop_access
+// CHECK-LABEL: omp.inner.for.inc:
+// CHECK: br label %omp.inner.for.cond, !llvm.loop
+// CHECK: ret void
+void simd_safelen_clause(float *a, float *b, float *c, int N) {
+  #pragma omp simd safelen(4)
+  for (int i = 0; i < N; i += 2)
+a[i] = b[i] * c[i];
+}
+
+extern long long initial_val();
+
+// CHECK-LABEL: @simd_simdlen_and_linear_clause
+// CHECK: omp.inner.for.body:
+// CHECK: !llvm.mem.parallel_loop_access
+// CHECK: ret void
+void simd_simdlen_and_linear_clause(float *a, float *b, float *c, int N) {
+  long long lv = initial_val();
+  #pragma omp simd simdlen(2) linear(lv: 4)
+  for (int i = 0; i < N; ++i) {
+a[lv] = b[lv] * c[lv];
+lv += 4;
+  }
+}
+
+extern float gfloat;
+
+// CHECK-LABEL: @simd_aligned_and_private_clause
+// CHECK-LABEL: entry:
+// CHECK: %gfloat = alloca float, align 4
+// CHECK: store float 1.00e+00, float* @gfloat, align 4
+// CHECK-LABEL: omp.inner.for.body:
+// CHECK-NOT: @gfloat
+// CHECK: load{{.*}}!llvm.mem.parallel_loop_access
+// CHECK: store float {{.*}}, float* %gfloat, align 4, !llvm.mem.parallel_loop_access
+// CHECK: %[[FADD:add[0-9]+]] = fadd float %{{[0-9]+}}, 2.00e+00
+// CHECK: store float %[[FADD]], float* {{.*}}, align 4, !llvm.mem.parallel_loop_access
+// CHECK: ret void
+void simd_aligned_and_private_clause(float *a, float *b, float *c, int N) {
+  gfloat = 1.0f;
+  #pragma omp simd aligned(a:4) private(gfloat)
+  for (int i = 0; i < N; i += 2) {
+gfloat = b[i] * c[i];
+a[i] = gfloat + 2.0f;
+  }
+}
+
+// CHECK-LABEL: @simd_lastprivate_and_reduction_clause
+// CHECK-LABEL: entry:
+// CHECK: %[[SUMVAR:sum[0-9]+]] = alloca float, align 4
+// CHECK: store float 0.00e+00, float* %[[SUMVAR]], align 4
+// CHECK-LABEL: omp.inner.for.body
+// CHECK: %[[LOAD:[0-9]+]] = load float, float* %[[SUMVAR]], align 4, !llvm.mem.parallel_loop_access
+// CHECK: %[[FADD:add[0-9]+]] = fadd float %[[LOAD]], %mul{{.*}}
+// CHECK: store float %[[FADD]], float* %[[SUMVAR]], align 4, !llvm.mem.parallel_loop_access
+// CHECK: store i32{{.*}}, i32* %[[IDXVAR:idx[0-9]+]]
+// CHECK-LABEL: omp.inner.for.end:
+// CHECK-DAG: %[[TMP1:[0-9]+]] = load i32, i32* %[[IDXVAR]], align 4
+// CHECK-DAG: store i32 %[[TMP1]], i32* %idx, align 4
+// CHECK-DAG: %[[INITVAL:[0-9]+]] = load float, float* %sum, align 4
+// CHECK-DAG: %[[TMP2:[0-9]+]] = load float, float* %[[SUMVAR]], align 4
+// CHECK-DAG: %[[SUMMED:add[0-9]+]] = fadd float %[[INITVAL]], %[[TMP2]]
+// CHECK-DAG: store float %[[SUMMED]], float* %sum, align 4
+// CHECK-LABEL: simd.if.end:
+// CHECK: %[[OUTVAL:[0-9]+]] = load float, float* %sum, align 4
+// CHECK: %[[OUTADDR:[0-9]+]] = load float*, float** %a.addr, align 8
+// CHECK: store float %[[OUTVAL]], float* %[[OUTADDR]], align 4
+// CHECK: %[[RETIDX:[0-9]+]] = load i32, i32* %idx, align 4
+// CHECK: ret i32 %[[RETIDX]]
+int simd_lastprivate_and_reduction_clause(float *a, float *b, float *c, int N) {
+  float sum = 0.0f;
+  int idx;
+  #pragma omp simd lastprivate(idx) reduction(+:sum)
+  for (int i = 0; i < N; ++i) {
+sum += b[i] * c[i];
+idx = i * 2;
+  }

[PATCH] D31417: [OpenMP] Add support for omp simd pragmas without runtime

2017-04-03 Thread Renato Golin via Phabricator via cfe-commits
rengolin added a comment.

Hi Graham,

It looks much simpler now, thanks!

I'm ok with the change, but I'd like @ABataev to confirm that the semantics is 
the expected one for all cases and approve.

cheers,
--renato




Comment at: lib/Parse/ParseOpenMP.cpp:174
+  case OMPD_target_teams_distribute_simd:
+DKind = OMPD_simd;
+break;

I'd like @ABataev to confirm this is the right semantics.



Comment at: lib/Parse/ParseOpenMP.cpp:1047
+// as the filter function will have switched the kind.
+if (!getLangOpts().OpenMPSimd)
+  Diag(Tok, diag::err_omp_unknown_directive);

What if it's really unknown, even to `-fopenmp-simd`?


https://reviews.llvm.org/D31417



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


[PATCH] D31417: [OpenMP] Add support for omp simd pragmas without runtime

2017-04-03 Thread Graham Hunter via Phabricator via cfe-commits
huntergr added inline comments.



Comment at: lib/Parse/ParseOpenMP.cpp:174
+  case OMPD_target_teams_distribute_simd:
+DKind = OMPD_simd;
+break;

rengolin wrote:
> I'd like @ABataev to confirm this is the right semantics.
Yes, would be good. I don't think there's a formal spec for this feature, but 
it's possible that directives intended for a different target than the cpu 
shouldn't apply with this flag.



Comment at: lib/Parse/ParseOpenMP.cpp:1047
+// as the filter function will have switched the kind.
+if (!getLangOpts().OpenMPSimd)
+  Diag(Tok, diag::err_omp_unknown_directive);

rengolin wrote:
> What if it's really unknown, even to `-fopenmp-simd`?
I did wonder about handling this case; I defaulted to ignoring it, since we are 
already filtering out other non-simd constructs.

If we do want to catch it, then I can think of two options: creating the 
diagnostic right before the filter switch (possibly messy), or adding a new 
enum value of OMPD_non_simd_construct (or a similar name) to represent 
constructs we recognize but don't want to handle and differentiate against a 
true unknown. I think the latter would be preferable.


https://reviews.llvm.org/D31417



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


r299355 - [ASTImporter] Fix for importing unnamed structs

2017-04-03 Thread Gabor Horvath via cfe-commits
Author: xazax
Date: Mon Apr  3 06:57:11 2017
New Revision: 299355

URL: http://llvm.org/viewvc/llvm-project?rev=299355&view=rev
Log:
[ASTImporter] Fix for importing unnamed structs

Patch by Peter Szecsi!

Differential Revision: https://reviews.llvm.org/D30876

Modified:
cfe/trunk/lib/AST/ASTImporter.cpp
cfe/trunk/test/ASTMerge/struct/Inputs/struct1.c
cfe/trunk/test/ASTMerge/struct/Inputs/struct2.c
cfe/trunk/test/ASTMerge/struct/test.c

Modified: cfe/trunk/lib/AST/ASTImporter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTImporter.cpp?rev=299355&r1=299354&r2=299355&view=diff
==
--- cfe/trunk/lib/AST/ASTImporter.cpp (original)
+++ cfe/trunk/lib/AST/ASTImporter.cpp Mon Apr  3 06:57:11 2017
@@ -1221,6 +1221,10 @@ static Optional findUntaggedSt
 // If the field looks like this:
 // struct { ... } A;
 QualType FieldType = F->getType();
+// In case of nested structs.
+while (const auto *ElabType = dyn_cast(FieldType)) {
+  FieldType = ElabType->getNamedType();
+}
 if (const auto *RecType = dyn_cast(FieldType)) {
   const RecordDecl *RecDecl = RecType->getDecl();
   if (RecDecl->getDeclContext() == Owner &&
@@ -3020,9 +3024,8 @@ Decl *ASTNodeImporter::VisitRecordDecl(R
   }
   
   if (RecordDecl *FoundRecord = dyn_cast(Found)) {
-if (D->isAnonymousStructOrUnion() && 
-FoundRecord->isAnonymousStructOrUnion()) {
-  // If both anonymous structs/unions are in a record context, make 
sure
+if (!SearchName) {
+  // If both unnamed structs/unions are in a record context, make sure
   // they occur in the same location in the context records.
   if (Optional Index1
   = findUntaggedStructOrUnionIndex(D)) {

Modified: cfe/trunk/test/ASTMerge/struct/Inputs/struct1.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ASTMerge/struct/Inputs/struct1.c?rev=299355&r1=299354&r2=299355&view=diff
==
--- cfe/trunk/test/ASTMerge/struct/Inputs/struct1.c (original)
+++ cfe/trunk/test/ASTMerge/struct/Inputs/struct1.c Mon Apr  3 06:57:11 2017
@@ -77,3 +77,65 @@ typedef struct {
 } S13;
 
 S13 x13;
+
+// Matches
+struct Unnamed {
+  union {
+struct {
+  int i;
+} S;
+struct {
+  float i;
+} R;
+  } U;
+} x14;
+
+// Matches
+struct DeepUnnamed {
+  union {
+union {
+  struct {
+long i;
+  } S;
+  struct {
+int i;
+  } R;
+} U1;
+union {
+  struct {
+long i;
+  } S;
+  struct {
+float i;
+  } T;
+} U2;
+  } U;
+  struct {
+long i;
+  } V;
+} x15;
+
+// Mismatch due to unnamed struct used internally
+struct DeepUnnamedError {
+  union {
+union {
+  struct {
+long i;
+  } S;
+  struct {
+int i;
+  } R;
+} U1;
+union {
+  struct {
+long i; // Mismatch here.
+  } S;
+  struct {
+float i;
+  } T;
+} U2;
+  } U;
+  struct {
+long i;
+  } V;
+} x16;

Modified: cfe/trunk/test/ASTMerge/struct/Inputs/struct2.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ASTMerge/struct/Inputs/struct2.c?rev=299355&r1=299354&r2=299355&view=diff
==
--- cfe/trunk/test/ASTMerge/struct/Inputs/struct2.c (original)
+++ cfe/trunk/test/ASTMerge/struct/Inputs/struct2.c Mon Apr  3 06:57:11 2017
@@ -74,3 +74,65 @@ typedef struct {
 } S13;
 
 S13 x13;
+
+// Matches
+struct Unnamed {
+  union {
+struct {
+  int i;
+} S;
+struct {
+  float i;
+} R;
+  } U;
+} x14;
+
+// Matches
+struct DeepUnnamed {
+  union {
+union {
+  struct {
+long i;
+  } S;
+  struct {
+int i;
+  } R;
+} U1;
+union {
+  struct {
+long i;
+  } S;
+  struct {
+float i;
+  } T;
+} U2;
+  } U;
+  struct {
+long i;
+  } V;
+} x15;
+
+// Mismatch due to unnamed struct used internally
+struct DeepUnnamedError {
+  union {
+union {
+  struct {
+long i;
+  } S;
+  struct {
+int i;
+  } R;
+} U1;
+union {
+  struct {
+float i; // Mismatch here.
+  } S;
+  struct {
+float i;
+  } T;
+} U2;
+  } U;
+  struct {
+long i;
+  } V;
+} x16;

Modified: cfe/trunk/test/ASTMerge/struct/test.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ASTMerge/struct/test.c?rev=299355&r1=299354&r2=299355&view=diff
==
--- cfe/trunk/test/ASTMerge/struct/test.c (original)
+++ cfe/trunk/test/ASTMerge/struct/test.c Mon Apr  3 06:57:11 2017
@@ -44,4 +44,12 @@
 // CHECK: struct2.c:72:7: note: field 'i' has type 'int' here
 // CHECK: struct2.c:76:5: error: external variable 'x13' declared w

[PATCH] D31597: [ObjC++] Conversions from specialized to non-specialized objective-c object type should be preferred over conversions to other object pointers

2017-04-03 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman created this revision.

Right now Clang will select incorrect overload when the Objective-C interface 
type is specialized, e.g.:

  void overload(Base *b);
  void overload(Derived *d);
  void test(Base b) {
overload(b); // This will select (Derived *) overload
  }

This patch ensures that the conversion from specialized to non-specialized type 
that points to the same interface is better than the other objective-c pointer 
conversions.


Repository:
  rL LLVM

https://reviews.llvm.org/D31597

Files:
  lib/Sema/SemaOverload.cpp
  test/SemaObjCXX/overload.mm


Index: test/SemaObjCXX/overload.mm
===
--- test/SemaObjCXX/overload.mm
+++ test/SemaObjCXX/overload.mm
@@ -174,3 +174,30 @@
   void f(Class) { }
   void f(id) { }
 }
+
+@interface NSDictionary<__covariant KeyType, __covariant ObjectType> : A
+@end
+
+@interface NSMutableDictionary : NSDictionary
+@end
+
+namespace rdar20124827 {
+
+int overload(NSDictionary *) { return 1; }
+
+__attribute__((deprecated))  // expected-note {{'overload' has been explicitly 
marked deprecated here}}
+int overload(NSMutableDictionary *) { return 0; }
+
+__attribute__((deprecated))
+void overload2(NSDictionary *); // expected-note {{candidate function}}
+void overload2(NSDictionary *); // expected-note {{candidate 
function}}
+
+void test(NSDictionary *d1, NSDictionary *d2, NSMutableDictionary *m1) {
+  overload(d1);
+  overload(d2); // no warning
+  overload(m1); // expected-warning {{'overload' is deprecated}}
+  overload2(d2); // no warning
+  overload2(m1); // expected-error {{call to 'overload2' is ambiguous}}
+}
+
+}
Index: lib/Sema/SemaOverload.cpp
===
--- lib/Sema/SemaOverload.cpp
+++ lib/Sema/SemaOverload.cpp
@@ -4048,7 +4048,7 @@
 = S.Context.canAssignObjCInterfaces(ToPtr1, ToPtr2);
   bool ToAssignRight
 = S.Context.canAssignObjCInterfaces(ToPtr2, ToPtr1);
-  
+
   // A conversion to an a non-id object pointer type or qualified 'id' 
   // type is better than a conversion to 'id'.
   if (ToPtr1->isObjCIdType() &&
@@ -4082,11 +4082,25 @@
 return ImplicitConversionSequence::Better;
 
   //   -- "conversion of C* to B* is better than conversion of C* to A*,"
-  if (S.Context.hasSameType(FromType1, FromType2) && 
+  if (S.Context.hasSameType(FromType1, FromType2) &&
   !FromPtr1->isObjCIdType() && !FromPtr1->isObjCClassType() &&
-  (ToAssignLeft != ToAssignRight))
+  (ToAssignLeft != ToAssignRight)) {
+if (FromPtr1->isSpecialized()) {
+  // "conversion of B * to B * is better than conversion of B * to
+  // C *.
+  bool IsFirstSame =
+  FromPtr1->getInterfaceDecl() == ToPtr1->getInterfaceDecl();
+  bool IsSecondSame =
+  FromPtr1->getInterfaceDecl() == ToPtr2->getInterfaceDecl();
+  if (IsFirstSame) {
+if (!IsSecondSame)
+  return ImplicitConversionSequence::Better;
+  } else if (IsSecondSame)
+return ImplicitConversionSequence::Worse;
+}
 return ToAssignLeft? ImplicitConversionSequence::Worse
: ImplicitConversionSequence::Better;
+  }
 
   //   -- "conversion of B* to A* is better than conversion of C* to A*,"
   if (S.Context.hasSameUnqualifiedType(ToType1, ToType2) &&


Index: test/SemaObjCXX/overload.mm
===
--- test/SemaObjCXX/overload.mm
+++ test/SemaObjCXX/overload.mm
@@ -174,3 +174,30 @@
   void f(Class) { }
   void f(id) { }
 }
+
+@interface NSDictionary<__covariant KeyType, __covariant ObjectType> : A
+@end
+
+@interface NSMutableDictionary : NSDictionary
+@end
+
+namespace rdar20124827 {
+
+int overload(NSDictionary *) { return 1; }
+
+__attribute__((deprecated))  // expected-note {{'overload' has been explicitly marked deprecated here}}
+int overload(NSMutableDictionary *) { return 0; }
+
+__attribute__((deprecated))
+void overload2(NSDictionary *); // expected-note {{candidate function}}
+void overload2(NSDictionary *); // expected-note {{candidate function}}
+
+void test(NSDictionary *d1, NSDictionary *d2, NSMutableDictionary *m1) {
+  overload(d1);
+  overload(d2); // no warning
+  overload(m1); // expected-warning {{'overload' is deprecated}}
+  overload2(d2); // no warning
+  overload2(m1); // expected-error {{call to 'overload2' is ambiguous}}
+}
+
+}
Index: lib/Sema/SemaOverload.cpp
===
--- lib/Sema/SemaOverload.cpp
+++ lib/Sema/SemaOverload.cpp
@@ -4048,7 +4048,7 @@
 = S.Context.canAssignObjCInterfaces(ToPtr1, ToPtr2);
   bool ToAssignRight
 = S.Context.canAssignObjCInterfaces(ToPtr2, ToPtr1);
-  
+
   // A conversion to an a non-id object pointer type or qualified 'id' 
   // type is better than a conver

[PATCH] D31501: [RFC] Integrate clang -cc1as diagnostics into DiagnosticsEngine

2017-04-03 Thread Sanne Wouda via Phabricator via cfe-commits
sanwou01 added a comment.

Hi Oli,

Thanks for taking a look! You're right, -w and -Werror could be implemented by 
passing them as MCTargetOptions flags.

This patch is indeed intended to enable -W options to promote or silence 
(categories of) warnings. To enable that, the first step is to be able to 
associate a diagnostic with an identifier. Clang defines IDs (and their warning 
groups) in Diagnostic*Kinds.td. The IDs need to be available where a diagnostic 
is raised, so a table for LLVM diagnostics (or just the enum) needs to live on 
the LLVM side (but they'd share encoding space with the clang enum, e.g., the 
clang diag enum starts where the llvm diag enum ends). It is then a matter of 
plumbing this ID from the point where the diagnostic gets raised, into an 
SMDiagnostic, and into the DiagnosticsEngine on the clang side.

Once the infrastructure is in place, the calls to `Report()` and friends can be 
updated with IDs on a case by case basis.

Thanks,
Sanne


https://reviews.llvm.org/D31501



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


[PATCH] D31594: [OpenCL] Enables passing sampler initializer to function argument

2017-04-03 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

I am not sure if this is going to work. At least you need to add a codegen test 
for this new usage.


https://reviews.llvm.org/D31594



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


[PATCH] D29905: [OpenMP] Pass argument to device kernel by reference when map is used.

2017-04-03 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea updated this revision to Diff 93859.
gtbercea added a comment.
Herald added a subscriber: rengolin.

Update test.


Repository:
  rL LLVM

https://reviews.llvm.org/D29905

Files:
  lib/Sema/SemaOpenMP.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
@@ -4756,3 +4756,20 @@
 }
 #endif
 #endif
+
+///==///
+// RUN: %clang_cc1 -DCK30 -std=c++11 -fopenmp -S -emit-llvm -fopenmp 
-fopenmp-targets=nvptx64-nvidia-cuda %s -o - 2>&1 | FileCheck 
-check-prefix=CK30 %s
+
+#ifdef CK30
+
+void target_maps_parallel_integer(int a){
+  int ParamToKernel = a;
+#pragma omp target map(tofrom: ParamToKernel)
+  {
+ParamToKernel += 1;
+  }
+}
+
+// CK30: {{.*}}void @__omp_offloading_{{.*}}(i32* dereferenceable(4) 
%ParamToKernel) #0 {
+
+#endif
Index: lib/Sema/SemaOpenMP.cpp
===
--- lib/Sema/SemaOpenMP.cpp
+++ lib/Sema/SemaOpenMP.cpp
@@ -355,6 +355,27 @@
 return false;
   }
 
+  /// Do the check specified in \a Check to all component lists at a given 
level
+  /// and return true if any issue is found.
+  bool checkMappableExprComponentListsForDeclAtLevel(
+  ValueDecl *VD, unsigned Level,
+  const llvm::function_ref<
+  bool(OMPClauseMappableExprCommon::MappableExprComponentListRef,
+   OpenMPClauseKind)> &Check) {
+auto StartI = std::next(Stack.begin());
+auto EndI = Stack.end();
+if (std::distance(StartI, EndI) <= (int)Level)
+  return false;
+std::advance(StartI, Level);
+
+auto MI = StartI->MappedExprComponents.find(VD);
+if (MI != StartI->MappedExprComponents.end())
+  for (auto &L : MI->second.Components)
+if (Check(L, MI->second.Kind))
+  return true;
+return false;
+  }
+
   /// Create a new mappable expression component list associated with a given
   /// declaration and initialize it with the provided list of components.
   void addMappableExpressionComponents(
@@ -912,9 +933,8 @@
 bool IsVariableUsedInMapClause = false;
 bool IsVariableAssociatedWithSection = false;
 
-DSAStack->checkMappableExprComponentListsForDecl(
-D, /*CurrentRegionOnly=*/true,
-[&](OMPClauseMappableExprCommon::MappableExprComponentListRef
+DSAStack->checkMappableExprComponentListsForDeclAtLevel(
+D, Level, [&](OMPClauseMappableExprCommon::MappableExprComponentListRef
 MapExprComponents,
 OpenMPClauseKind WhereFoundClauseKind) {
   // Only the map clause information influences how a variable is


Index: test/OpenMP/target_map_codegen.cpp
===
--- test/OpenMP/target_map_codegen.cpp
+++ test/OpenMP/target_map_codegen.cpp
@@ -4756,3 +4756,20 @@
 }
 #endif
 #endif
+
+///==///
+// RUN: %clang_cc1 -DCK30 -std=c++11 -fopenmp -S -emit-llvm -fopenmp -fopenmp-targets=nvptx64-nvidia-cuda %s -o - 2>&1 | FileCheck -check-prefix=CK30 %s
+
+#ifdef CK30
+
+void target_maps_parallel_integer(int a){
+  int ParamToKernel = a;
+#pragma omp target map(tofrom: ParamToKernel)
+  {
+ParamToKernel += 1;
+  }
+}
+
+// CK30: {{.*}}void @__omp_offloading_{{.*}}(i32* dereferenceable(4) %ParamToKernel) #0 {
+
+#endif
Index: lib/Sema/SemaOpenMP.cpp
===
--- lib/Sema/SemaOpenMP.cpp
+++ lib/Sema/SemaOpenMP.cpp
@@ -355,6 +355,27 @@
 return false;
   }
 
+  /// Do the check specified in \a Check to all component lists at a given level
+  /// and return true if any issue is found.
+  bool checkMappableExprComponentListsForDeclAtLevel(
+  ValueDecl *VD, unsigned Level,
+  const llvm::function_ref<
+  bool(OMPClauseMappableExprCommon::MappableExprComponentListRef,
+   OpenMPClauseKind)> &Check) {
+auto StartI = std::next(Stack.begin());
+auto EndI = Stack.end();
+if (std::distance(StartI, EndI) <= (int)Level)
+  return false;
+std::advance(StartI, Level);
+
+auto MI = StartI->MappedExprComponents.find(VD);
+if (MI != StartI->MappedExprComponents.end())
+  for (auto &L : MI->second.Components)
+if (Check(L, MI->second.Kind))
+  return true;
+return false;
+  }
+
   /// Create a new mappable expression component list associated with a given
   /// declaration and initialize it with the provided list of components.
   void addMappableExpressionComponents(
@@ -912,9 +933,8 @@
 bool IsVariableUsedInMapClause = false;
 bool IsVariableAssociatedWithSection = false;
 
-DSAStack->checkMappableExprComponentListsForDecl(
-D, /*CurrentRegionOnly=*/true,
-[&](OMPClauseMappableExprCommon::MappableExprCompone

[PATCH] D31591: Fix a bug which access nullptr and cause segmentation fault

2017-04-03 Thread Yuka Takahashi via Phabricator via cfe-commits
yamaguchi updated this revision to Diff 93860.
yamaguchi added a comment.

Moved comment inside if (ExistingInit).


https://reviews.llvm.org/D31591

Files:
  SemaInit.cpp


Index: SemaInit.cpp
===
--- SemaInit.cpp
+++ SemaInit.cpp
@@ -2260,15 +2260,17 @@
   assert(StructuredList->getNumInits() == 1
  && "A union should never have more than one initializer!");
 
-  // We're about to throw away an initializer, emit warning.
-  SemaRef.Diag(D->getFieldLoc(),
-   diag::warn_initializer_overrides)
-<< D->getSourceRange();
   Expr *ExistingInit = StructuredList->getInit(0);
-  SemaRef.Diag(ExistingInit->getLocStart(),
-   diag::note_previous_initializer)
-<< /*FIXME:has side effects=*/0
-<< ExistingInit->getSourceRange();
+  if (ExistingInit) {
+// We're about to throw away an initializer, emit warning.
+SemaRef.Diag(D->getFieldLoc(),
+ diag::warn_initializer_overrides)
+  << D->getSourceRange();
+SemaRef.Diag(ExistingInit->getLocStart(),
+ diag::note_previous_initializer)
+  << /*FIXME:has side effects=*/0
+  << ExistingInit->getSourceRange();
+  }
 
   // remove existing initializer
   StructuredList->resizeInits(SemaRef.Context, 0);


Index: SemaInit.cpp
===
--- SemaInit.cpp
+++ SemaInit.cpp
@@ -2260,15 +2260,17 @@
   assert(StructuredList->getNumInits() == 1
  && "A union should never have more than one initializer!");
 
-  // We're about to throw away an initializer, emit warning.
-  SemaRef.Diag(D->getFieldLoc(),
-   diag::warn_initializer_overrides)
-<< D->getSourceRange();
   Expr *ExistingInit = StructuredList->getInit(0);
-  SemaRef.Diag(ExistingInit->getLocStart(),
-   diag::note_previous_initializer)
-<< /*FIXME:has side effects=*/0
-<< ExistingInit->getSourceRange();
+  if (ExistingInit) {
+// We're about to throw away an initializer, emit warning.
+SemaRef.Diag(D->getFieldLoc(),
+ diag::warn_initializer_overrides)
+  << D->getSourceRange();
+SemaRef.Diag(ExistingInit->getLocStart(),
+ diag::note_previous_initializer)
+  << /*FIXME:has side effects=*/0
+  << ExistingInit->getSourceRange();
+  }
 
   // remove existing initializer
   StructuredList->resizeInits(SemaRef.Context, 0);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D31022: Implement P0298R3: `std::byte`

2017-04-03 Thread James Y Knight via Phabricator via cfe-commits
jyknight added a comment.

I believe this needs compiler support, too, in order to treat

  namespace std { enum class byte : unsigned char {}; }

as directly having tbaa type "omnipotent char" instead of a subtype.

That is, given:

  void foo(char* x, int *y) {
x[1] = char(y[0] & 0xff);
x[0] = char((y[0] & 0xff00) >> 8);
  }

the compiler assumes that x and y might alias each-other, and thus must have 
two loads of y[0]. If you replace "char" with "std::byte", the same should 
happen, but as of now does not.


https://reviews.llvm.org/D31022



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


[PATCH] D31501: [RFC] Integrate clang -cc1as diagnostics into DiagnosticsEngine

2017-04-03 Thread Oliver Stannard via Phabricator via cfe-commits
olista01 added a comment.

That all sounds sensible from an assembler perspective, especially the ability 
to gradually move diagnostics into categories rather than having one big change 
that touches every assembler diag. However, I've not done much work in clang, 
so it would be good to get someone more familiar with the clang 
diagnostics/driver side of things to have a look at this too.


https://reviews.llvm.org/D31501



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


[PATCH] D31591: Fix a bug which access nullptr and cause segmentation fault

2017-04-03 Thread Yuka Takahashi via Phabricator via cfe-commits
yamaguchi updated this revision to Diff 93864.
yamaguchi added a comment.

Made unified diff for the testcase and SemaInit.cpp.


https://reviews.llvm.org/D31591

Files:
  SemaInit.cpp
  sema-segvcheck.c


Index: sema-segvcheck.c
===
--- sema-segvcheck.c
+++ sema-segvcheck.c
@@ -0,0 +1,50 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only %s; test $? -eq 1
+
+typedef struct {
+  union {
+unsigned long long house;
+struct {
+  unsigned cat1;
+  unsigned cat2;
+};
+  };
+} struct_0;
+
+
+typedef struct {
+  union {
+struct {
+  union {
+unsigned cows;
+struct {
+  unsigned char c:1;
+};
+  };
+};
+  };
+
+  union {
+struct {
+  unsigned bird0;
+  unsigned bird1;
+};
+  };
+} struct_1;
+
+
+typedef struct {
+  struct_0 s0;
+  struct_1 s1[1];
+} struct_2;
+
+struct_2 s = {
+  .s0 = {
+.dog = 0x, // expected-error{{field designator}}
+  },
+
+  .s1[0] = {
+.cows = 0x5050,
+.c = 1,
+  },
+};
Index: SemaInit.cpp
===
--- SemaInit.cpp
+++ SemaInit.cpp
@@ -2260,15 +2260,17 @@
   assert(StructuredList->getNumInits() == 1
  && "A union should never have more than one initializer!");
 
-  // We're about to throw away an initializer, emit warning.
-  SemaRef.Diag(D->getFieldLoc(),
-   diag::warn_initializer_overrides)
-<< D->getSourceRange();
   Expr *ExistingInit = StructuredList->getInit(0);
-  SemaRef.Diag(ExistingInit->getLocStart(),
-   diag::note_previous_initializer)
-<< /*FIXME:has side effects=*/0
-<< ExistingInit->getSourceRange();
+  if (ExistingInit) {
+// We're about to throw away an initializer, emit warning.
+SemaRef.Diag(D->getFieldLoc(),
+ diag::warn_initializer_overrides)
+  << D->getSourceRange();
+SemaRef.Diag(ExistingInit->getLocStart(),
+ diag::note_previous_initializer)
+  << /*FIXME:has side effects=*/0
+  << ExistingInit->getSourceRange();
+  }
 
   // remove existing initializer
   StructuredList->resizeInits(SemaRef.Context, 0);


Index: sema-segvcheck.c
===
--- sema-segvcheck.c
+++ sema-segvcheck.c
@@ -0,0 +1,50 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only %s; test $? -eq 1
+
+typedef struct {
+  union {
+unsigned long long house;
+struct {
+  unsigned cat1;
+  unsigned cat2;
+};
+  };
+} struct_0;
+
+
+typedef struct {
+  union {
+struct {
+  union {
+unsigned cows;
+struct {
+  unsigned char c:1;
+};
+  };
+};
+  };
+
+  union {
+struct {
+  unsigned bird0;
+  unsigned bird1;
+};
+  };
+} struct_1;
+
+
+typedef struct {
+  struct_0 s0;
+  struct_1 s1[1];
+} struct_2;
+
+struct_2 s = {
+  .s0 = {
+.dog = 0x, // expected-error{{field designator}}
+  },
+
+  .s1[0] = {
+.cows = 0x5050,
+.c = 1,
+  },
+};
Index: SemaInit.cpp
===
--- SemaInit.cpp
+++ SemaInit.cpp
@@ -2260,15 +2260,17 @@
   assert(StructuredList->getNumInits() == 1
  && "A union should never have more than one initializer!");
 
-  // We're about to throw away an initializer, emit warning.
-  SemaRef.Diag(D->getFieldLoc(),
-   diag::warn_initializer_overrides)
-<< D->getSourceRange();
   Expr *ExistingInit = StructuredList->getInit(0);
-  SemaRef.Diag(ExistingInit->getLocStart(),
-   diag::note_previous_initializer)
-<< /*FIXME:has side effects=*/0
-<< ExistingInit->getSourceRange();
+  if (ExistingInit) {
+// We're about to throw away an initializer, emit warning.
+SemaRef.Diag(D->getFieldLoc(),
+ diag::warn_initializer_overrides)
+  << D->getSourceRange();
+SemaRef.Diag(ExistingInit->getLocStart(),
+ diag::note_previous_initializer)
+  << /*FIXME:has side effects=*/0
+  << ExistingInit->getSourceRange();
+  }
 
   // remove existing initializer
   StructuredList->resizeInits(SemaRef.Context, 0);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Quantum computing and C

2017-04-03 Thread AM via cfe-commits
hi. I heard Quantum Computers are coming. Are we able to compile and run
programs written in C or C++ on them?
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r299340 - Fixes for modernize-use-using check:

2017-04-03 Thread Krystyna Gajczyk via cfe-commits
Author: krystynka
Date: Sun Apr  2 14:12:20 2017
New Revision: 299340

URL: http://llvm.org/viewvc/llvm-project?rev=299340&view=rev
Log:
Fixes for modernize-use-using check:
- removed unnessacary namespaces
- added option to print warning in macros
- no fix for typedef with array
- removed "void" word from functions with 0 parameters

Differential Revision: https://reviews.llvm.org/D29262

Added:
clang-tools-extra/trunk/test/clang-tidy/modernize-use-using-macros.cpp
Modified:
clang-tools-extra/trunk/clang-tidy/modernize/UseUsingCheck.cpp
clang-tools-extra/trunk/clang-tidy/modernize/UseUsingCheck.h
clang-tools-extra/trunk/test/clang-tidy/modernize-use-using.cpp

Modified: clang-tools-extra/trunk/clang-tidy/modernize/UseUsingCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/UseUsingCheck.cpp?rev=299340&r1=299339&r2=299340&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/UseUsingCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseUsingCheck.cpp Sun Apr  2 
14:12:20 2017
@@ -17,6 +17,10 @@ namespace clang {
 namespace tidy {
 namespace modernize {
 
+UseUsingCheck::UseUsingCheck(StringRef Name, ClangTidyContext *Context)
+: ClangTidyCheck(Name, Context),
+  IgnoreMacros(Options.get("IgnoreMacros", true)) {}
+
 void UseUsingCheck::registerMatchers(MatchFinder *Finder) {
   if (!getLangOpts().CPlusPlus11)
 return;
@@ -79,18 +83,28 @@ void UseUsingCheck::check(const MatchFin
   auto &Context = *Result.Context;
   auto &SM = *Result.SourceManager;
 
+  SourceLocation StartLoc = MatchedDecl->getLocStart();
+
+  if (StartLoc.isMacroID() && IgnoreMacros)
+return;
+
   auto Diag =
-  diag(MatchedDecl->getLocStart(), "use 'using' instead of 'typedef'");
+  diag(StartLoc, "use 'using' instead of 'typedef'");
 
-  SourceLocation StartLoc = MatchedDecl->getLocStart();
-  if (StartLoc.isMacroID())
+  // do not fix if there is macro or array
+  if (MatchedDecl->getUnderlyingType()->isArrayType() || StartLoc.isMacroID())
 return;
 
   if (CheckRemoval(SM, StartLoc, Context)) {
+auto printPolicy = PrintingPolicy(getLangOpts());
+printPolicy.SuppressScope = true;
+printPolicy.ConstantArraySizeAsWritten = true;
+printPolicy.UseVoidForZeroParams = false;
+
 Diag << FixItHint::CreateReplacement(
 MatchedDecl->getSourceRange(),
 "using " + MatchedDecl->getNameAsString() + " = " +
-MatchedDecl->getUnderlyingType().getAsString(getLangOpts()));
+MatchedDecl->getUnderlyingType().getAsString(printPolicy));
   }
 }
 

Modified: clang-tools-extra/trunk/clang-tidy/modernize/UseUsingCheck.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/UseUsingCheck.h?rev=299340&r1=299339&r2=299340&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/UseUsingCheck.h (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseUsingCheck.h Sun Apr  2 
14:12:20 2017
@@ -21,9 +21,14 @@ namespace modernize {
 /// For the user-facing documentation see:
 /// http://clang.llvm.org/extra/clang-tidy/checks/modernize-use-using.html
 class UseUsingCheck : public ClangTidyCheck {
+
+  const bool IgnoreMacros;
+
 public:
-  UseUsingCheck(StringRef Name, ClangTidyContext *Context)
-  : ClangTidyCheck(Name, Context) {}
+  UseUsingCheck(StringRef Name, ClangTidyContext *Context);
+  void storeOptions(ClangTidyOptions::OptionMap &Opts) override {
+Options.store(Opts, "IgnoreMacros", IgnoreMacros);
+  }
   void registerMatchers(ast_matchers::MatchFinder *Finder) override;
   void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
 };

Added: clang-tools-extra/trunk/test/clang-tidy/modernize-use-using-macros.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-use-using-macros.cpp?rev=299340&view=auto
==
--- clang-tools-extra/trunk/test/clang-tidy/modernize-use-using-macros.cpp 
(added)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-using-macros.cpp Sun 
Apr  2 14:12:20 2017
@@ -0,0 +1,23 @@
+// RUN: %check_clang_tidy %s modernize-use-using %t -- \
+// RUN:   -config="{CheckOptions: [{key: modernize-use-using.IgnoreMacros, 
value: 0}]}" \
+// RUN:   -- -std=c++11 -I %S/Inputs/modernize-use-using
+
+#define CODE typedef int INT
+
+CODE;
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef'
+// CHECK-FIXES: #define CODE typedef int INT
+// CHECK-FIXES: CODE;
+
+struct Foo;
+#define Bar Baz
+typedef Foo Bar;
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef'
+// CHECK-FIXES: #define Bar Baz
+// CHECK-FIXES: using Baz = Foo;
+
+#define TYPEDEF typedef
+TYPEDEF Foo Bak;
+// CHECK-MESSAGES: :[[@

[PATCH] D30465: [mips] Set the Int64Type / IntMaxType types correctly for OpenBSD/mips64

2017-04-03 Thread Simon Dardis via Phabricator via cfe-commits
sdardis added a comment.

Do you need me to commit this for you?


Repository:
  rL LLVM

https://reviews.llvm.org/D30465



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


[PATCH] D31404: [OpenCL] Allow alloca return non-zero private pointer

2017-04-03 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 93870.
yaxunl marked an inline comment as done.
yaxunl added a comment.

Revised by Tony's comments.


https://reviews.llvm.org/D31404

Files:
  include/clang/AST/ASTContext.h
  include/clang/AST/Type.h
  include/clang/Basic/AddressSpaces.h
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/AST/ASTContext.cpp
  lib/AST/ExprClassification.cpp
  lib/AST/TypePrinter.cpp
  lib/Basic/Targets.cpp
  lib/CodeGen/CGCall.cpp
  lib/CodeGen/CGExpr.cpp
  lib/Sema/SemaExprCXX.cpp
  lib/Sema/SemaOverload.cpp
  lib/Sema/SemaType.cpp
  test/CodeGenOpenCL/address-space-constant-initializers.cl
  test/CodeGenOpenCL/address-spaces.cl
  test/CodeGenOpenCL/amdgpu-env-amdgiz.cl
  test/CodeGenOpenCL/vla.cl
  test/Sema/address_spaces.c
  test/Sema/invalid-assignment-constant-address-space.c
  test/SemaOpenCL/invalid-assignment-constant-address-space.cl

Index: test/SemaOpenCL/invalid-assignment-constant-address-space.cl
===
--- /dev/null
+++ test/SemaOpenCL/invalid-assignment-constant-address-space.cl
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only
+
+int constant c[3] = {0};
+
+void foo() {
+  c[0] = 1; //expected-error{{read-only variable is not assignable}}
+}
Index: test/Sema/invalid-assignment-constant-address-space.c
===
--- test/Sema/invalid-assignment-constant-address-space.c
+++ /dev/null
@@ -1,8 +0,0 @@
-// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only
-
-#define OPENCL_CONSTANT 8388354
-int __attribute__((address_space(OPENCL_CONSTANT))) c[3] = {0};
-
-void foo() {
-  c[0] = 1; //expected-error{{read-only variable is not assignable}}
-}
Index: test/Sema/address_spaces.c
===
--- test/Sema/address_spaces.c
+++ test/Sema/address_spaces.c
@@ -19,8 +19,8 @@
   _AS1 int array[5];  // expected-error {{automatic variable qualified with an address space}}
   _AS1 int arrarr[5][5]; // expected-error {{automatic variable qualified with an address space}}
 
-  __attribute__((address_space(-1))) int *_boundsA; // expected-error {{address space is negative}}
-  __attribute__((address_space(0x7F))) int *_boundsB;
+  __attribute__((address_space(-1))) int *_boundsA; // expected-warning {{address space is negative}}
+  __attribute__((address_space(0x7F))) int *_boundsB; // expected-error {{address space is larger than the maximum supported}}
   __attribute__((address_space(0x100))) int *_boundsC; // expected-error {{address space is larger than the maximum supported}}
   // chosen specifically to overflow 32 bits and come out reasonable
   __attribute__((address_space(4294967500))) int *_boundsD; // expected-error {{address space is larger than the maximum supported}}
Index: test/CodeGenOpenCL/vla.cl
===
--- test/CodeGenOpenCL/vla.cl
+++ test/CodeGenOpenCL/vla.cl
@@ -1,18 +1,26 @@
-// RUN: %clang_cc1 -emit-llvm -triple "spir-unknown-unknown" -O0 -cl-std=CL2.0 -o - %s | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm -triple "spir-unknown-unknown" -O0 -cl-std=CL2.0 -o - %s | FileCheck -check-prefixes=CHECK,SPIR %s
+// RUN: %clang_cc1 -emit-llvm -triple amdgcn-amd-amdhsa-opencl -O0 -cl-std=CL2.0 -o - %s | FileCheck -check-prefixes=CHECK,SPIR %s
+// RUN: %clang_cc1 -emit-llvm -triple amdgcn-amd-amdhsa-amdgizcl -O0 -cl-std=CL2.0 -o - %s | FileCheck -check-prefixes=CHECK,GIZ %s
 
 constant int sz0 = 5;
-// CHECK: @sz0 = addrspace(2) constant i32 5
+// SPIR: @sz0 = addrspace(2) constant i32 5
+// GIZ: @sz0 = addrspace(4) constant i32 5
 const global int sz1 = 16;
 // CHECK: @sz1 = addrspace(1) constant i32 16
 const constant int sz2 = 8;
-// CHECK: @sz2 = addrspace(2) constant i32 8
+// SPIR: @sz2 = addrspace(2) constant i32 8
+// GIZ: @sz2 = addrspace(4) constant i32 8
 // CHECK: @testvla.vla2 = internal addrspace(3) global [8 x i16] undef
 
 kernel void testvla()
 {
   int vla0[sz0];
-// CHECK: %vla0 = alloca [5 x i32]
+// SPIR: %vla0 = alloca [5 x i32]
+// SPIR-NOT: %vla0 = alloca [5 x i32]{{.*}}addrspace
+// GIZ: %vla0 = alloca [5 x i32]{{.*}}addrspace(5)
   char vla1[sz1];
-// CHECK: %vla1 = alloca [16 x i8]
+// SPIR: %vla1 = alloca [16 x i8]
+// SPIR-NOT: %vla1 = alloca [16 x i8]{{.*}}addrspace
+// GIZ: %vla1 = alloca [16 x i8]{{.*}}addrspace(5)
   local short vla2[sz2];
 }
Index: test/CodeGenOpenCL/amdgpu-env-amdgiz.cl
===
--- test/CodeGenOpenCL/amdgpu-env-amdgiz.cl
+++ test/CodeGenOpenCL/amdgpu-env-amdgiz.cl
@@ -4,6 +4,6 @@
 // RUN: %clang_cc1 %s -O0 -triple amdgcn---amdgizcl -emit-llvm -o - | FileCheck -check-prefix=GIZ %s
 
 // CHECK: target datalayout = "e-p:32:32-p1:64:64-p2:64:64-p3:32:32-p4:64:64-p5:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64"
-// GIZ: target datalayout = "e-p:64:64-

[PATCH] D31404: [OpenCL] Allow alloca return non-zero private pointer

2017-04-03 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



Comment at: include/clang/AST/ASTContext.h:2328
+return AddrSpaceMapMangling || 
+   AS >= LangAS::target_first;
   }

So we couldn't use the  LangAS::Count instead?

I have the same comment in other places that use LangAS::target_first. Why 
couldn't we simply use LangAS::Count? It there any point in having two tags?

Another comment is why do we need ASes specified by 
`__attribute__((address_space(n)))` to be unique enum number at the end of 
named ASes of OpenCL and CUDA? I think conceptually the full range of ASes can 
be used in C because the ASes from OpenCL and CUDA are not available there 
anyways.



Comment at: include/clang/AST/Type.h:339-340
+auto Addr = getAddressSpace();
+if (Addr == 0)
+  return 0;
+return Addr - LangAS::target_first;

t-tye wrote:
> Since you mention this is only used for  `__attribute__((address_space(n)))`, 
> why is this check for 0 needed?
> 
> If it is needed then to match other places should it simply be:
> 
> ```
> if (Addr)
>   return Addr - LangAS::target_first;
> return 0;
> ```
Could we use LangAS::Count instead?



Comment at: lib/AST/ASTContext.cpp:8732
+Type = Context.getAddrSpaceQualType(Type, AddrSpace +
+LangAS::target_first);
 Str = End;

Also here, could we use LangAS::Count instead?



Comment at: lib/AST/ASTContext.cpp:9556
+  if (AS == LangAS::Default && LangOpts.OpenCL)
+return getTargetInfo().getDataLayout().getAllocaAddrSpace();
+  if (AS >= LangAS::target_first)

t-tye wrote:
> An alternative to doing this would be to add an opencl_private to LangAS and 
> have each target map it accordingly. Then this could be:
> 
> ```
> // If a target specific address space was specified, simply return it.
> if (AS >= LangAS::target_first)
>   return AS - LangAS::target_first;
> // For OpenCL, only function local variables are not explicitly marked with
> // an address space in the AST, so treat them as the OpenCL private address 
> space.
> if (!AS && LangOpts.OpenCL)
>   AS = LangAS::opencl_private;
> return (*AddrSpaceMap)[AS];
> ```
> This seems to better express what is happening here. If no address space was 
> specified, and the language is OpenCL, then treat it as OpenCL private and 
> map it according to the target mapping.
> 
> If wanted to eliminate the LangAS::Default named constant then that would be 
> possible as it is no longer being used by name. However, would need to ensure 
> that the first named enumerators starts at 1 so that 0 is left as the "no 
> value explicitly specified" value that each target must map to the target 
> specific generic address space.
I would very much like to see `opencl_private` represented explicitly. This 
would allow us to simplify some parsing and also enable proper support of `NULL 
` literal (that has no AS by the spec).

We can of course do this refactoring work as a separate step.



Comment at: lib/Sema/SemaType.cpp:5537
+llvm::APSInt Offset(addrSpace.getBitWidth(), false);
+Offset = LangAS::target_first;
+addrSpace += Offset;

Do we need this temporary variable here?


https://reviews.llvm.org/D31404



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


[PATCH] D26953: clang-format: handle formatting on constexpr if

2017-04-03 Thread Denis Gladkikh via Phabricator via cfe-commits
outcoldman added a comment.

In https://reviews.llvm.org/D26953#716504, @gnzlbg wrote:

> any progress on this?


It is getting tracked in mailing list 
http://lists.llvm.org/pipermail/cfe-dev/2017-April/053397.html


https://reviews.llvm.org/D26953



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


[PATCH] D31394: [X86][Clang] Converting __mm{|256|512}_movm_epi{8|16|32|64} LLVMIR call into generic intrinsics.

2017-04-03 Thread michael zuckerman via Phabricator via cfe-commits
m_zuckerman added a comment.

Ping


https://reviews.llvm.org/D31394



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


[PATCH] D31404: [OpenCL] Allow alloca return non-zero private pointer

2017-04-03 Thread Tony Tye via Phabricator via cfe-commits
t-tye added inline comments.



Comment at: lib/Sema/SemaExprCXX.cpp:2055
+  << AllocType.getUnqualifiedType()
+  << AllocType.getQualifiers().getAddressSpacePrintValue();
   else if (getLangOpts().ObjCAutoRefCount) {

Would suggest renaming getAddressSpacePrintValue to 
getAddressSpaceAttributePrintValue since it only deals with address spaces 
coming from the` __attribute__((address_space(n)))`.


https://reviews.llvm.org/D31404



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


[PATCH] D31235: Enhance -Wshadow to warn when shadowing typedefs or type aliases

2017-04-03 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added a comment.

Thanks!

I'll commit it for you right now.


https://reviews.llvm.org/D31235



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


[PATCH] D31394: [X86][Clang] Converting __mm{|256|512}_movm_epi{8|16|32|64} LLVMIR call into generic intrinsics.

2017-04-03 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

Y




Comment at: lib/CodeGen/CGBuiltin.cpp:7176
+  return CGF.Builder.CreateSExt(
+  Mask, llvm::VectorType::get(IT, NumberOfElements), "vpmovm2");
+}

Why can't we just use DstTy here to create the SExt?


https://reviews.llvm.org/D31394



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


[PATCH] D31594: [OpenCL] Enables passing sampler initializer to function argument

2017-04-03 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



Comment at: test/SemaOpenCL/sampler_t.cl:68
   foo(argsmp);
-  foo(5); // expected-error{{sampler_t variable required - got 'int'}}
+  foo(CLK_ADDRESS_CLAMP_TO_EDGE | CLK_NORMALIZED_COORDS_TRUE | 
CLK_FILTER_LINEAR);
   sampler_t sa[] = {argsmp, const_smp}; // expected-error {{array of 
'sampler_t' type is invalid in OpenCL}}

I think we could keep just an int value (i.e. 5) as well.

Could we add a case with an error though. To make sure we are testing the 
diagnostic too.


https://reviews.llvm.org/D31594



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


r299363 - Enhance -Wshadow to warn when shadowing typedefs or type aliases

2017-04-03 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Mon Apr  3 11:43:21 2017
New Revision: 299363

URL: http://llvm.org/viewvc/llvm-project?rev=299363&view=rev
Log:
Enhance -Wshadow to warn when shadowing typedefs or type aliases

Enhance -Wshadow to emit a warning when typedefs or type aliases are shadowed.

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

Patch by Ahmed Asadi.

Differential Revision: https://reviews.llvm.org/D31235

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/SemaCXX/warn-shadow.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=299363&r1=299362&r2=299363&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Mon Apr  3 11:43:21 
2017
@@ -369,7 +369,9 @@ def warn_decl_shadow :
   "local variable|"
   "variable in %2|"
   "static data member of %2|"
-  "field of %2}1">,
+  "field of %2|"
+  "typedef in %2|"
+  "type alias in %2}1">,
   InGroup, DefaultIgnore;
 def warn_decl_shadow_uncaptured_local :
   Warning,

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=299363&r1=299362&r2=299363&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Mon Apr  3 11:43:21 2017
@@ -1738,8 +1738,11 @@ public:
 
   static bool adjustContextForLocalExternDecl(DeclContext *&DC);
   void DiagnoseFunctionSpecifiers(const DeclSpec &DS);
+  NamedDecl *getShadowedDeclaration(const TypedefNameDecl *D,
+const LookupResult &R);
   NamedDecl *getShadowedDeclaration(const VarDecl *D, const LookupResult &R);
-  void CheckShadow(VarDecl *D, NamedDecl *ShadowedDecl, const LookupResult &R);
+  void CheckShadow(NamedDecl *D, NamedDecl *ShadowedDecl,
+   const LookupResult &R);
   void CheckShadow(Scope *S, VarDecl *D);
 
   /// Warn if 'E', which is an expression that is about to be modified, refers

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=299363&r1=299362&r2=299363&view=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Mon Apr  3 11:43:21 2017
@@ -5530,6 +5530,10 @@ Sema::CheckTypedefForVariablyModifiedTyp
 NamedDecl*
 Sema::ActOnTypedefNameDecl(Scope *S, DeclContext *DC, TypedefNameDecl *NewTD,
LookupResult &Previous, bool &Redeclaration) {
+
+  // Find the shadowed declaration before filtering for scope.
+  NamedDecl *ShadowedDecl = getShadowedDeclaration(NewTD, Previous);
+
   // Merge the decl with the existing one if appropriate. If the decl is
   // in an outer scope, it isn't the same thing.
   FilterLookupForScope(Previous, DC, S, /*ConsiderLinkage*/false,
@@ -5540,6 +5544,9 @@ Sema::ActOnTypedefNameDecl(Scope *S, Dec
 MergeTypedefNameDecl(S, NewTD, Previous);
   }
 
+  if (ShadowedDecl && !Redeclaration)
+CheckShadow(NewTD, ShadowedDecl, Previous);
+
   // If this is the C FILE type, notify the AST context.
   if (IdentifierInfo *II = NewTD->getIdentifier())
 if (!NewTD->isInvalidDecl() &&
@@ -6671,13 +6678,25 @@ NamedDecl *Sema::ActOnVariableDeclarator
 }
 
 /// Enum describing the %select options in diag::warn_decl_shadow.
-enum ShadowedDeclKind { SDK_Local, SDK_Global, SDK_StaticMember, SDK_Field };
+enum ShadowedDeclKind {
+  SDK_Local,
+  SDK_Global,
+  SDK_StaticMember,
+  SDK_Field,
+  SDK_Typedef,
+  SDK_Using
+};
 
 /// Determine what kind of declaration we're shadowing.
 static ShadowedDeclKind computeShadowedDeclKind(const NamedDecl *ShadowedDecl,
 const DeclContext *OldDC) {
-  if (isa(OldDC))
+  if (isa(ShadowedDecl))
+return SDK_Using;
+  else if (isa(ShadowedDecl))
+return SDK_Typedef;
+  else if (isa(OldDC))
 return isa(ShadowedDecl) ? SDK_Field : SDK_StaticMember;
+
   return OldDC->isFileContext() ? SDK_Global : SDK_Local;
 }
 
@@ -6692,28 +6711,44 @@ static SourceLocation getCaptureLocation
   return SourceLocation();
 }
 
+static bool shouldWarnIfShadowedDecl(const DiagnosticsEngine &Diags,
+ const LookupResult &R) {
+  // Only diagnose if we're shadowing an unambiguous field or variable.
+  if (R.getResultKind() != LookupResult::Found)
+return false;
+
+  // Return false if warning is ignored.
+  return !Diags.isIgnored(diag::warn_decl_shadow, R.getNameLoc());
+}
+
 /// \brief Return the 

[PATCH] D31235: Enhance -Wshadow to warn when shadowing typedefs or type aliases

2017-04-03 Thread Alex Lorenz via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL299363: Enhance -Wshadow to warn when shadowing typedefs or 
type aliases (authored by arphaman).

Changed prior to commit:
  https://reviews.llvm.org/D31235?vs=93583&id=93878#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D31235

Files:
  cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
  cfe/trunk/include/clang/Sema/Sema.h
  cfe/trunk/lib/Sema/SemaDecl.cpp
  cfe/trunk/test/SemaCXX/warn-shadow.cpp

Index: cfe/trunk/include/clang/Sema/Sema.h
===
--- cfe/trunk/include/clang/Sema/Sema.h
+++ cfe/trunk/include/clang/Sema/Sema.h
@@ -1738,8 +1738,11 @@
 
   static bool adjustContextForLocalExternDecl(DeclContext *&DC);
   void DiagnoseFunctionSpecifiers(const DeclSpec &DS);
+  NamedDecl *getShadowedDeclaration(const TypedefNameDecl *D,
+const LookupResult &R);
   NamedDecl *getShadowedDeclaration(const VarDecl *D, const LookupResult &R);
-  void CheckShadow(VarDecl *D, NamedDecl *ShadowedDecl, const LookupResult &R);
+  void CheckShadow(NamedDecl *D, NamedDecl *ShadowedDecl,
+   const LookupResult &R);
   void CheckShadow(Scope *S, VarDecl *D);
 
   /// Warn if 'E', which is an expression that is about to be modified, refers
Index: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
@@ -369,7 +369,9 @@
   "local variable|"
   "variable in %2|"
   "static data member of %2|"
-  "field of %2}1">,
+  "field of %2|"
+  "typedef in %2|"
+  "type alias in %2}1">,
   InGroup, DefaultIgnore;
 def warn_decl_shadow_uncaptured_local :
   Warning,
Index: cfe/trunk/test/SemaCXX/warn-shadow.cpp
===
--- cfe/trunk/test/SemaCXX/warn-shadow.cpp
+++ cfe/trunk/test/SemaCXX/warn-shadow.cpp
@@ -1,20 +1,27 @@
-// RUN: %clang_cc1 -verify -fsyntax-only -Wshadow-all %s
+// RUN: %clang_cc1 -verify -fsyntax-only -std=c++11 -Wshadow-all %s
 
 namespace {
   int i; // expected-note {{previous declaration is here}}
 }
 
 namespace one {
 namespace two {
   int j; // expected-note {{previous declaration is here}}
+  typedef int jj; // expected-note 2 {{previous declaration is here}}
+  using jjj=int; // expected-note 2 {{previous declaration is here}}
 }
 }
 
 namespace xx {
   int m;
+  typedef int mm;
+  using mmm=int;
+
 }
 namespace yy {
   int m;
+  typedef char mm;
+  using mmm=char;
 }
 
 using namespace one::two;
@@ -25,14 +32,19 @@
   int i; // expected-warning {{declaration shadows a variable in namespace '(anonymous)'}}
   int j; // expected-warning {{declaration shadows a variable in namespace 'one::two'}}
   int m;
+  int mm;
+  int mmm;
 }
 
 class A {
-  static int data; // expected-note {{previous declaration}}
-  // expected-note@+1 {{previous declaration}}
+  static int data; // expected-note 1 {{previous declaration}}
+  // expected-note@+1 1 {{previous declaration}}
   int field;
   int f1, f2, f3, f4; // expected-note 8 {{previous declaration is here}}
 
+  typedef int a1; // expected-note 2 {{previous declaration}}
+  using a2=int; // expected-note 2 {{previous declaration}}
+
   // The initialization is safe, but the modifications are not.
   A(int f1, int f2, int f3, int f4) // expected-note-re 4 {{variable 'f{{[0-4]}}' is declared here}}
 	  : f1(f1) {
@@ -50,6 +62,28 @@
   void test() {
 char *field; // expected-warning {{declaration shadows a field of 'A'}}
 char *data; // expected-warning {{declaration shadows a static data member of 'A'}}
+char *a1; // no warning 
+char *a2; // no warning
+char *jj; // no warning
+char *jjj; // no warning
+  }
+
+  void test2() {
+typedef char field; // no warning
+typedef char data; // no warning
+typedef char a1; // expected-warning {{declaration shadows a typedef in 'A'}}
+typedef char a2; // expected-warning {{declaration shadows a type alias in 'A'}}
+typedef char jj; // expected-warning {{declaration shadows a typedef in namespace 'one::two'}}
+typedef char jjj; // expected-warning {{declaration shadows a type alias in namespace 'one::two'}}
+  }
+
+  void test3() {
+using field=char; // no warning
+using data=char; // no warning
+using a1=char; // expected-warning {{declaration shadows a typedef in 'A'}}
+using a2=char; // expected-warning {{declaration shadows a type alias in 'A'}}
+using jj=char; // expected-warning {{declaration shadows a typedef in namespace 'one::two'}}
+using jjj=char; // expected-warning {{declaration shadows a type alias in namespace 'one::two'}}
   }
 };
 
@@ -63,13 +97,23 @@
 namespace rdar8900456 {
 struct Foo {
   static void Baz();
+  static void Baz1();
+  stati

r299364 - [TargetInfo] Use llvm::alignOf() instead of rewriting it. NFCI.

2017-04-03 Thread Davide Italiano via cfe-commits
Author: davide
Date: Mon Apr  3 11:51:39 2017
New Revision: 299364

URL: http://llvm.org/viewvc/llvm-project?rev=299364&view=rev
Log:
[TargetInfo] Use llvm::alignOf() instead of rewriting it. NFCI.

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

Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=299364&r1=299363&r2=299364&view=diff
==
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Mon Apr  3 11:51:39 2017
@@ -4917,7 +4917,7 @@ ABIArgInfo AArch64ABIInfo::classifyArgum
   return coerceToIntArray(Ty, getContext(), getVMContext());
 }
 unsigned Alignment = getContext().getTypeAlign(Ty);
-Size = 64 * ((Size + 63) / 64); // round up to multiple of 8 bytes
+Size = llvm::alignTo(Size, 64); // round up to multiple of 8 bytes
 
 // We use a pair of i64 for 16-byte aggregate with 8-byte alignment.
 // For aggregates with 16-byte alignment, we use i128.
@@ -4967,7 +4967,7 @@ ABIArgInfo AArch64ABIInfo::classifyRetur
   return coerceToIntArray(RetTy, getContext(), getVMContext());
 }
 unsigned Alignment = getContext().getTypeAlign(RetTy);
-Size = 64 * ((Size + 63) / 64); // round up to multiple of 8 bytes
+Size = llvm::alignTo(Size, 64); // round up to multiple of 8 bytes
 
 // We use a pair of i64 for 16-byte aggregate with 8-byte alignment.
 // For aggregates with 16-byte alignment, we use i128.


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


[PATCH] D31168: Set FMF for -ffp-contract=fast

2017-04-03 Thread Adam Nemet via Phabricator via cfe-commits
anemet added a comment.

In https://reviews.llvm.org/D31168#716153, @rjmccall wrote:

> I may have missed earlier steps in this patch series.  Why is this being done 
> statefully and contextually in the IRBuilder instead of just applying the 
> flag from the BinaryOperator to the instruction when building it?  It's not 
> like ScalarExprEmitter doesn't know that it's building an FMul.


The main reason is that the other FMFlags are currently maintained in the 
IRBuilder (see CodeGenFunction.cpp:87).  That said as we move those over to the 
operators as well, it makes more sense to move away from using the IRBuilder 
for this.  See updated patch and thanks for the suggestion!

Also let me know if you have post-commit comments on the patches in the series. 
 You can find them either on the cfe-dev thread or in the dependencies of 
https://reviews.llvm.org/D31276


https://reviews.llvm.org/D31168



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


[PATCH] D31383: [inline asm] "=i" output constraint support - gcc compatiblity

2017-04-03 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added inline comments.



Comment at: lib/Basic/TargetInfo.cpp:506
 case '!': // Disparage severely.
 case '*': // Ignore for choosing register preferences.
+case 'i': // Ignore i as output constraint (match from the other chars)

If we are going to ignore 'i', should we ignore other constraints for immediate 
operands too (for example, 'n', 'E", and 'F')?


https://reviews.llvm.org/D31383



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


[PATCH] D31168: Set FMF for -ffp-contract=fast

2017-04-03 Thread Adam Nemet via Phabricator via cfe-commits
anemet updated this revision to Diff 93882.
anemet added a comment.

Address John's comment.


https://reviews.llvm.org/D31168

Files:
  lib/CodeGen/CGExprScalar.cpp
  test/CodeGen/ffp-contract-fast-option.cpp


Index: test/CodeGen/ffp-contract-fast-option.cpp
===
--- /dev/null
+++ test/CodeGen/ffp-contract-fast-option.cpp
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -O3 -ffp-contract=fast -triple %itanium_abi_triple 
-emit-llvm -o - %s | FileCheck %s
+
+float fp_contract_1(float a, float b, float c) {
+  // CHECK-LABEL: fp_contract_1fff(
+  // CHECK: fmul contract float
+  // CHECK: fadd contract float
+  return a * b + c;
+}
+
+float fp_contract_2(float a, float b, float c) {
+  // CHECK-LABEL: fp_contract_2fff(
+  // CHECK: fmul contract float
+  // CHECK: fsub contract float
+  return a * b - c;
+}
+
+void fp_contract_3(float *a, float b, float c) {
+  // CHECK-LABEL: fp_contract_3Pfff(
+  // CHECK: fmul contract float
+  // CHECK: fadd contract float
+  a[0] += b * c;
+}
+
+void fp_contract_4(float *a, float b, float c) {
+  // CHECK-LABEL: fp_contract_4Pfff(
+  // CHECK: fmul contract float
+  // CHECK: fsub contract float
+  a[0] -= b * c;
+}
Index: lib/CodeGen/CGExprScalar.cpp
===
--- lib/CodeGen/CGExprScalar.cpp
+++ lib/CodeGen/CGExprScalar.cpp
@@ -113,6 +113,22 @@
  (2 * Ctx.getTypeSize(RHSTy)) < PromotedSize;
 }
 
+/// Update the FastMathFlags of LLVM IR from the FPOptions in LangOptions.
+static void updateFastMathFlags(llvm::FastMathFlags &FMF,
+FPOptions FPFeatures) {
+  FMF.setAllowContract(FPFeatures.allowFPContractAcrossStatement());
+}
+
+/// Propagate fast-math flags from \p Op to the instruction in \p V.
+static Value *propagateFMFlags(Value *V, const BinOpInfo &Op) {
+  if (auto *I = dyn_cast(V)) {
+llvm::FastMathFlags FMF = I->getFastMathFlags();
+updateFastMathFlags(FMF, Op.FPFeatures);
+I->setFastMathFlags(FMF);
+  }
+  return V;
+}
+
 class ScalarExprEmitter
   : public StmtVisitor {
   CodeGenFunction &CGF;
@@ -553,8 +569,10 @@
 !CanElideOverflowCheck(CGF.getContext(), Ops))
   return EmitOverflowCheckedBinOp(Ops);
 
-if (Ops.LHS->getType()->isFPOrFPVectorTy())
-  return Builder.CreateFMul(Ops.LHS, Ops.RHS, "mul");
+if (Ops.LHS->getType()->isFPOrFPVectorTy()) {
+  Value *V = Builder.CreateFMul(Ops.LHS, Ops.RHS, "mul");
+  return propagateFMFlags(V, Ops);
+}
 return Builder.CreateMul(Ops.LHS, Ops.RHS, "mul");
   }
   /// Create a binary op that checks for overflow.
@@ -2722,7 +2740,8 @@
 if (Value *FMulAdd = tryEmitFMulAdd(op, CGF, Builder))
   return FMulAdd;
 
-return Builder.CreateFAdd(op.LHS, op.RHS, "add");
+Value *V = Builder.CreateFAdd(op.LHS, op.RHS, "add");
+return propagateFMFlags(V, op);
   }
 
   return Builder.CreateAdd(op.LHS, op.RHS, "add");
@@ -2755,7 +2774,8 @@
   // Try to form an fmuladd.
   if (Value *FMulAdd = tryEmitFMulAdd(op, CGF, Builder, true))
 return FMulAdd;
-  return Builder.CreateFSub(op.LHS, op.RHS, "sub");
+  Value *V = Builder.CreateFSub(op.LHS, op.RHS, "sub");
+  return propagateFMFlags(V, op);
 }
 
 return Builder.CreateSub(op.LHS, op.RHS, "sub");


Index: test/CodeGen/ffp-contract-fast-option.cpp
===
--- /dev/null
+++ test/CodeGen/ffp-contract-fast-option.cpp
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -O3 -ffp-contract=fast -triple %itanium_abi_triple -emit-llvm -o - %s | FileCheck %s
+
+float fp_contract_1(float a, float b, float c) {
+  // CHECK-LABEL: fp_contract_1fff(
+  // CHECK: fmul contract float
+  // CHECK: fadd contract float
+  return a * b + c;
+}
+
+float fp_contract_2(float a, float b, float c) {
+  // CHECK-LABEL: fp_contract_2fff(
+  // CHECK: fmul contract float
+  // CHECK: fsub contract float
+  return a * b - c;
+}
+
+void fp_contract_3(float *a, float b, float c) {
+  // CHECK-LABEL: fp_contract_3Pfff(
+  // CHECK: fmul contract float
+  // CHECK: fadd contract float
+  a[0] += b * c;
+}
+
+void fp_contract_4(float *a, float b, float c) {
+  // CHECK-LABEL: fp_contract_4Pfff(
+  // CHECK: fmul contract float
+  // CHECK: fsub contract float
+  a[0] -= b * c;
+}
Index: lib/CodeGen/CGExprScalar.cpp
===
--- lib/CodeGen/CGExprScalar.cpp
+++ lib/CodeGen/CGExprScalar.cpp
@@ -113,6 +113,22 @@
  (2 * Ctx.getTypeSize(RHSTy)) < PromotedSize;
 }
 
+/// Update the FastMathFlags of LLVM IR from the FPOptions in LangOptions.
+static void updateFastMathFlags(llvm::FastMathFlags &FMF,
+FPOptions FPFeatures) {
+  FMF.setAllowContract(FPFeatures.allowFPContractAcrossStatement());
+}
+
+/// Propagate fast-math flags from \p Op to the instruction in \p V.
+static Value *propagateFMFlags(Value *V, const BinOpInfo &Op) {
+ 

[PATCH] D29659: [OpenMP] Add flag for disabling the default generation of relocatable OpenMP target code for NVIDIA GPUs.

2017-04-03 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea updated this revision to Diff 93883.
gtbercea added a comment.

Update test.


Repository:
  rL LLVM

https://reviews.llvm.org/D29659

Files:
  include/clang/Driver/Options.td
  lib/Driver/ToolChains/Cuda.cpp
  test/Driver/openmp-offload.c


Index: test/Driver/openmp-offload.c
===
--- test/Driver/openmp-offload.c
+++ test/Driver/openmp-offload.c
@@ -609,6 +609,23 @@
 
 /// ###
 
+/// PTXAS is passed -c flag by default when offloading to an NVIDIA device 
using OpenMP - disable it.
+// RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda 
-fnoopenmp-relocatable-target -save-temps -no-canonical-prefixes %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-PTXAS-NORELO %s
+
+// CHK-PTXAS-NORELO-NOT: ptxas{{.*}}" "-c"
+
+/// ###
+
+/// PTXAS is passed -c flag by default when offloading to an NVIDIA device 
using OpenMP
+/// Check that the flag is passed when -fopenmp-relocatable-target is used.
+// RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda 
-fopenmp-relocatable-target -save-temps -no-canonical-prefixes %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-PTXAS-RELO %s
+
+// CHK-PTXAS-RELO: ptxas{{.*}}" "-c"
+
+/// ###
+
 /// Check -fopenmp-is-device is also passed when generating the *.i and *.s 
intermediate files.
 // RUN:   %clang -### -fopenmp=libomp 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -save-temps -no-canonical-prefixes 
%s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHK-FOPENMP-IS-DEVICE %s
Index: lib/Driver/ToolChains/Cuda.cpp
===
--- lib/Driver/ToolChains/Cuda.cpp
+++ lib/Driver/ToolChains/Cuda.cpp
@@ -292,7 +292,9 @@
 CmdArgs.push_back(Args.MakeArgString(A));
 
   // In OpenMP we need to generate relocatable code.
-  if (JA.isOffloading(Action::OFK_OpenMP))
+  if (JA.isOffloading(Action::OFK_OpenMP) &&
+  !Args.hasFlag(options::OPT_fnoopenmp_relocatable_target,
+options::OPT_fopenmp_relocatable_target, false))
 CmdArgs.push_back("-c");
 
   const char *Exec;
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -1260,6 +1260,10 @@
   HelpText<"Specify comma-separated list of triples OpenMP offloading targets 
to be supported">;
 def fopenmp_dump_offload_linker_script : Flag<["-"], 
"fopenmp-dump-offload-linker-script">, Group, 
   Flags<[NoArgumentUnused]>;
+def fopenmp_relocatable_target : Flag<["-"], "fopenmp-relocatable-target">, 
Group, Flags<[CC1Option, NoArgumentUnused]>,
+  HelpText<"OpenMP target code is compiled as relocatable using the -c flag. 
For OpenMP targets the code is relocatable by default.">;
+def fnoopenmp_relocatable_target : Flag<["-"], 
"fnoopenmp-relocatable-target">, Group, Flags<[CC1Option, 
NoArgumentUnused]>,
+  HelpText<"Do not compile OpenMP target code as relocatable.">;
 def fno_optimize_sibling_calls : Flag<["-"], "fno-optimize-sibling-calls">, 
Group;
 def foptimize_sibling_calls : Flag<["-"], "foptimize-sibling-calls">, 
Group;
 def force__cpusubtype__ALL : Flag<["-"], "force_cpusubtype_ALL">;


Index: test/Driver/openmp-offload.c
===
--- test/Driver/openmp-offload.c
+++ test/Driver/openmp-offload.c
@@ -609,6 +609,23 @@
 
 /// ###
 
+/// PTXAS is passed -c flag by default when offloading to an NVIDIA device using OpenMP - disable it.
+// RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -fnoopenmp-relocatable-target -save-temps -no-canonical-prefixes %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-PTXAS-NORELO %s
+
+// CHK-PTXAS-NORELO-NOT: ptxas{{.*}}" "-c"
+
+/// ###
+
+/// PTXAS is passed -c flag by default when offloading to an NVIDIA device using OpenMP
+/// Check that the flag is passed when -fopenmp-relocatable-target is used.
+// RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -fopenmp-relocatable-target -save-temps -no-canonical-prefixes %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-PTXAS-RELO %s
+
+// CHK-PTXAS-RELO: ptxas{{.*}}" "-c"
+
+/// ###
+
 /// Check -fopenmp-is-device is also passed when generating the *.i and *.s intermediate files.
 // RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=powerpc64le-ibm-linux-gnu -save-temps -no-canonical-prefixes %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHK-FOPENMP-IS-DEVICE %s
Index: lib/Driver/ToolChains/Cuda.cpp
=

[PATCH] D31608: [coroutines] Add emission of initial and final suspends

2017-04-03 Thread Gor Nishanov via Phabricator via cfe-commits
GorNishanov created this revision.

https://reviews.llvm.org/D31608

Files:
  lib/CodeGen/CGCoroutine.cpp
  test/CodeGenCoroutines/coro-await.cpp
  test/CodeGenCoroutines/coro-cleanup.cpp

Index: test/CodeGenCoroutines/coro-cleanup.cpp
===
--- test/CodeGenCoroutines/coro-cleanup.cpp
+++ test/CodeGenCoroutines/coro-cleanup.cpp
@@ -6,27 +6,27 @@
 
 template  struct coroutine_handle {
   coroutine_handle() = default;
-  static coroutine_handle from_address(void *) { return {}; }
+  static coroutine_handle from_address(void *) noexcept;
 };
 template <> struct coroutine_handle {
-  static coroutine_handle from_address(void *) { return {}; }
+  static coroutine_handle from_address(void *) noexcept;
   coroutine_handle() = default;
   template 
   coroutine_handle(coroutine_handle) {}
 };
 }
 
 struct suspend_always {
-  bool await_ready();
-  void await_suspend(std::experimental::coroutine_handle<>);
-  void await_resume();
+  bool await_ready() noexcept;
+  void await_suspend(std::experimental::coroutine_handle<>) noexcept;
+  void await_resume() noexcept;
 };
 
 template <> struct std::experimental::coroutine_traits {
   struct promise_type {
 void get_return_object();
-suspend_always initial_suspend();
-suspend_always final_suspend();
+suspend_always initial_suspend() noexcept;
+suspend_always final_suspend() noexcept;
 void return_void();
 promise_type();
 ~promise_type();
@@ -46,19 +46,19 @@
   // CHECK: invoke void @_ZNSt12experimental16coroutine_traitsIJvEE12promise_typeC1Ev(
   // CHECK-NEXT: to label %{{.+}} unwind label %[[DeallocPad:.+]]
 
+  // CHECK: [[DeallocPad]]:
+  // CHECK-NEXT: landingpad
+  // CHECK-NEXT:   cleanup
+  // CHECK: br label %[[Dealloc:.+]]
+
   Cleanup cleanup;
   may_throw();
 
   // if may_throw throws, check that we destroy the promise and free the memory.
 
   // CHECK: invoke void @_Z9may_throwv(
   // CHECK-NEXT: to label %{{.+}} unwind label %[[PromDtorPad:.+]]
 
-  // CHECK: [[DeallocPad]]:
-  // CHECK-NEXT: landingpad
-  // CHECK-NEXT:   cleanup
-  // CHECK: br label %[[Dealloc:.+]]
-
   // CHECK: [[PromDtorPad]]:
   // CHECK-NEXT: landingpad
   // CHECK-NEXT:   cleanup
Index: test/CodeGenCoroutines/coro-await.cpp
===
--- test/CodeGenCoroutines/coro-await.cpp
+++ test/CodeGenCoroutines/coro-await.cpp
@@ -21,6 +21,17 @@
 }
 }
 
+struct init_susp {
+  bool await_ready();
+  void await_suspend(std::experimental::coroutine_handle<>);
+  void await_resume();
+};
+struct final_susp {
+  bool await_ready();
+  void await_suspend(std::experimental::coroutine_handle<>);
+  void await_resume();
+};
+
 struct suspend_always {
   int stuff;
   bool await_ready();
@@ -32,16 +43,21 @@
 struct std::experimental::coroutine_traits {
   struct promise_type {
 void get_return_object();
-suspend_always initial_suspend();
-suspend_always final_suspend();
+init_susp initial_suspend();
+final_susp final_suspend();
 void return_void();
   };
 };
 
 // CHECK-LABEL: f0(
 extern "C" void f0() {
   // CHECK: %[[FRAME:.+]] = call i8* @llvm.coro.begin(
 
+  // See if initial_suspend was issued:
+  // --
+  // CHECK: call void @_ZNSt12experimental16coroutine_traitsIJvEE12promise_type15initial_suspendEv(
+  // CHECK-NEXT: call zeroext i1 @_ZN9init_susp11await_readyEv(%struct.init_susp*
+
   co_await suspend_always{};
   // See if we need to suspend:
   // --
@@ -76,6 +92,11 @@
   // --
   // CHECK: [[READY_BB]]:
   // CHECK:  call void @_ZN14suspend_always12await_resumeEv(%struct.suspend_always* %[[AWAITABLE]])
+
+  // See if final_suspend was issued:
+  // --
+  // CHECK: call void @_ZNSt12experimental16coroutine_traitsIJvEE12promise_type13final_suspendEv(
+  // CHECK-NEXT: call zeroext i1 @_ZN10final_susp11await_readyEv(%struct.final_susp*
 }
 
 struct suspend_maybe {
@@ -91,8 +112,8 @@
 struct std::experimental::coroutine_traits {
   struct promise_type {
 void get_return_object();
-suspend_always initial_suspend();
-suspend_always final_suspend();
+init_susp initial_suspend();
+final_susp final_suspend();
 void return_void();
 suspend_maybe yield_value(int);
   };
@@ -228,3 +249,21 @@
   // CHECK: call void @_ZN5MyAggawEv(%struct.MyAgg* %
   // CHECK: call void @_ZN11AggrAwaiter12await_resumeEv(%struct.Aggr* sret %
 }
+
+// CHECK-LABEL: EndlessLoop(
+extern "C" void EndlessLoop() {
+  // CHECK: %[[FRAME:.+]] = call i8* @llvm.coro.begin(
+
+  // See if initial_suspend was issued:
+  // --
+  // CHECK: call void @_ZNSt12experimental16coroutine_traitsIJvEE12promise_type15initial_suspendEv(
+  // CHECK-NEXT: call zeroext i1 @_ZN9init_susp11await_readyEv(%struct.init_susp*
+
+  for (;;)
+co_await suspend_always{};
+
+  // Verify that final_suspend w

[PATCH] D31608: [coroutines] Add emission of initial and final suspends

2017-04-03 Thread Gor Nishanov via Phabricator via cfe-commits
GorNishanov updated this revision to Diff 93889.
GorNishanov added a comment.

Added a CHECK that for a final suspend we correctly set "IsFinalSuspend" 
argument of @llvm.coro.suspend


https://reviews.llvm.org/D31608

Files:
  lib/CodeGen/CGCoroutine.cpp
  test/CodeGenCoroutines/coro-await.cpp
  test/CodeGenCoroutines/coro-cleanup.cpp

Index: test/CodeGenCoroutines/coro-cleanup.cpp
===
--- test/CodeGenCoroutines/coro-cleanup.cpp
+++ test/CodeGenCoroutines/coro-cleanup.cpp
@@ -6,27 +6,27 @@
 
 template  struct coroutine_handle {
   coroutine_handle() = default;
-  static coroutine_handle from_address(void *) { return {}; }
+  static coroutine_handle from_address(void *) noexcept;
 };
 template <> struct coroutine_handle {
-  static coroutine_handle from_address(void *) { return {}; }
+  static coroutine_handle from_address(void *) noexcept;
   coroutine_handle() = default;
   template 
   coroutine_handle(coroutine_handle) {}
 };
 }
 
 struct suspend_always {
-  bool await_ready();
-  void await_suspend(std::experimental::coroutine_handle<>);
-  void await_resume();
+  bool await_ready() noexcept;
+  void await_suspend(std::experimental::coroutine_handle<>) noexcept;
+  void await_resume() noexcept;
 };
 
 template <> struct std::experimental::coroutine_traits {
   struct promise_type {
 void get_return_object();
-suspend_always initial_suspend();
-suspend_always final_suspend();
+suspend_always initial_suspend() noexcept;
+suspend_always final_suspend() noexcept;
 void return_void();
 promise_type();
 ~promise_type();
@@ -46,19 +46,19 @@
   // CHECK: invoke void @_ZNSt12experimental16coroutine_traitsIJvEE12promise_typeC1Ev(
   // CHECK-NEXT: to label %{{.+}} unwind label %[[DeallocPad:.+]]
 
+  // CHECK: [[DeallocPad]]:
+  // CHECK-NEXT: landingpad
+  // CHECK-NEXT:   cleanup
+  // CHECK: br label %[[Dealloc:.+]]
+
   Cleanup cleanup;
   may_throw();
 
   // if may_throw throws, check that we destroy the promise and free the memory.
 
   // CHECK: invoke void @_Z9may_throwv(
   // CHECK-NEXT: to label %{{.+}} unwind label %[[PromDtorPad:.+]]
 
-  // CHECK: [[DeallocPad]]:
-  // CHECK-NEXT: landingpad
-  // CHECK-NEXT:   cleanup
-  // CHECK: br label %[[Dealloc:.+]]
-
   // CHECK: [[PromDtorPad]]:
   // CHECK-NEXT: landingpad
   // CHECK-NEXT:   cleanup
Index: test/CodeGenCoroutines/coro-await.cpp
===
--- test/CodeGenCoroutines/coro-await.cpp
+++ test/CodeGenCoroutines/coro-await.cpp
@@ -21,6 +21,17 @@
 }
 }
 
+struct init_susp {
+  bool await_ready();
+  void await_suspend(std::experimental::coroutine_handle<>);
+  void await_resume();
+};
+struct final_susp {
+  bool await_ready();
+  void await_suspend(std::experimental::coroutine_handle<>);
+  void await_resume();
+};
+
 struct suspend_always {
   int stuff;
   bool await_ready();
@@ -32,16 +43,23 @@
 struct std::experimental::coroutine_traits {
   struct promise_type {
 void get_return_object();
-suspend_always initial_suspend();
-suspend_always final_suspend();
+init_susp initial_suspend();
+final_susp final_suspend();
 void return_void();
   };
 };
 
 // CHECK-LABEL: f0(
 extern "C" void f0() {
   // CHECK: %[[FRAME:.+]] = call i8* @llvm.coro.begin(
 
+  // See if initial_suspend was issued:
+  // --
+  // CHECK: call void @_ZNSt12experimental16coroutine_traitsIJvEE12promise_type15initial_suspendEv(
+  // CHECK-NEXT: call zeroext i1 @_ZN9init_susp11await_readyEv(%struct.init_susp*
+  // CHECK: %[[INITSP_ID:.+]] = call token @llvm.coro.save(
+  // CHECK: call i8 @llvm.coro.suspend(token %[[INITSP_ID]], i1 false)
+
   co_await suspend_always{};
   // See if we need to suspend:
   // --
@@ -60,6 +78,7 @@
   // CHECK: %[[CH:.+]] = load i8*, i8** %{{.+}}
   // CHECK: call void @_ZN14suspend_always13await_suspendENSt12experimental16coroutine_handleIvEE(%struct.suspend_always* %[[AWAITABLE]], i8* %[[CH]])
   // -
+
   // Generate a suspend point:
   // -
   // CHECK: %[[OUTCOME:.+]] = call i8 @llvm.coro.suspend(token %[[SUSPEND_ID]], i1 false)
@@ -76,6 +95,13 @@
   // --
   // CHECK: [[READY_BB]]:
   // CHECK:  call void @_ZN14suspend_always12await_resumeEv(%struct.suspend_always* %[[AWAITABLE]])
+
+  // See if final_suspend was issued:
+  // --
+  // CHECK: call void @_ZNSt12experimental16coroutine_traitsIJvEE12promise_type13final_suspendEv(
+  // CHECK-NEXT: call zeroext i1 @_ZN10final_susp11await_readyEv(%struct.final_susp*
+  // CHECK: %[[FINALSP_ID:.+]] = call token @llvm.coro.save(
+  // CHECK: call i8 @llvm.coro.suspend(token %[[FINALSP_ID]], i1 true)
 }
 
 struct suspend_maybe {
@@ -91,8 +117,8 @@
 struct std::experimental::coroutine_traits {
   struct promise_type {
 void get_return_object();
-suspend_

[PATCH] D31440: PR32382: Adapt to LLVM changes in DIExpression.

2017-04-03 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl updated this revision to Diff 93897.
aprantl added a comment.

Add accidentally removed check for the debug info level back in.


https://reviews.llvm.org/D31440

Files:
  lib/CodeGen/CGBlocks.cpp
  lib/CodeGen/CGDebugInfo.cpp
  lib/CodeGen/CGDebugInfo.h
  test/CodeGenObjC/debug-info-block-captured-self.m
  test/CodeGenObjC/debug-info-blocks.m

Index: test/CodeGenObjC/debug-info-blocks.m
===
--- test/CodeGenObjC/debug-info-blocks.m
+++ test/CodeGenObjC/debug-info-blocks.m
@@ -4,11 +4,18 @@
 // Test that we generate the proper debug location for a captured self.
 // The second half of this test is in llvm/tests/DebugInfo/debug-info-blocks.ll
 
-// CHECK: define {{.*}}_block_invoke
-// CHECK: %[[BLOCK:.*]] = bitcast i8* %.block_descriptor to <{ i8*, i32, i32, i8*, %struct.__block_descriptor*, %0* }>*, !dbg
-// CHECK-NEXT: store <{ i8*, i32, i32, i8*, %struct.__block_descriptor*, %0* }>* %[[BLOCK]], <{ i8*, i32, i32, i8*, %struct.__block_descriptor*, %0* }>** %[[ALLOCA:.*]], align
-// CHECK-NEXT: call void @llvm.dbg.declare(metadata <{ i8*, i32, i32, i8*, %struct.__block_descriptor*, %0* }>** %[[ALLOCA]], metadata ![[SELF:[0-9]+]], metadata !{{.*}})
-// CHECK-NEXT: call void @llvm.dbg.declare(metadata %1** %d, metadata ![[D:[0-9]+]], metadata !{{.*}})
+// CHECK: define {{.*}}[A init]_block_invoke
+// CHECK-NEXT: entry
+// CHECK-NEXT: %[[DESC_ALLOCA:.*]] = alloca i8*, align 8
+// CHECK-NEXT: %[[BLOCK_ALLOCA:.*]] = alloca <{{.*}}>*, align 8
+// CHECK: store i8* %.block_descriptor, i8** %[[ALLOCA:.*]], align 8
+// CHECK: call void @llvm.dbg.declare(metadata i8** %[[DESC_ALLOCA]],
+// CHECK-SAME:metadata ![[BLOCK_VAR:[0-9]+]],
+// CHECK: call void @llvm.dbg.declare(
+// CHECK-SAME: metadata <{ i8*, i32, i32, i8*, %struct.__block_descriptor*, %0* }>**
+// CHECK-SAME:  %[[BLOCK_ALLOCA]], metadata ![[SELF_VAR:[0-9]+]],
+// CHECK-SAME:  metadata ![[SELF_EXPR:[0-9]+]])
+// CHECK: call void @llvm.dbg.declare(metadata %1** %d, metadata ![[D_VAR:[0-9]+]],
 
 // rdar://problem/14386148
 // Test that we don't emit bogus line numbers for the helper functions.
@@ -22,11 +29,13 @@
 // CHECK-NOT: ret
 // CHECK: load {{.*}}, !dbg ![[DESTROY_LINE:[0-9]+]]
 
-// CHECK-DAG: [[DBG_LINE]] = !DILocation(line: 0, scope: ![[COPY_SP:[0-9]+]])
-// CHECK-DAG: [[COPY_LINE]] = !DILocation(line: 0, scope: ![[COPY_SP:[0-9]+]])
-// CHECK-DAG: [[COPY_SP]] = distinct !DISubprogram(name: "__copy_helper_block_"
-// CHECK-DAG: [[DESTROY_LINE]] = !DILocation(line: 0, scope: ![[DESTROY_SP:[0-9]+]])
-// CHECK-DAG: [[DESTROY_SP]] = distinct !DISubprogram(name: "__destroy_helper_block_"
+// CHECK-DAG: ![[DBG_LINE]] = !DILocation(line: 0, scope: ![[COPY_SP:[0-9]+]])
+// CHECK-DAG: ![[COPY_LINE]] = !DILocation(line: 0, scope: ![[COPY_SP:[0-9]+]])
+// CHECK-DAG: ![[COPY_SP]] = distinct !DISubprogram(name: "__copy_helper_block_"
+// CHECK-DAG: ![[DESTROY_LINE]] = !DILocation(line: 0, scope: ![[DESTROY_SP:[0-9]+]])
+// CHECK-DAG: ![[DESTROY_SP]] = distinct !DISubprogram(name: "__destroy_helper_block_"
+// CHECK-DAG: ![[BLOCK_VAR]] = !DILocalVariable(name: ".block_descriptor"
+// CHECK-DAG: ![[SELF_EXPR]] = !DIExpression(DW_OP_plus, 32, DW_OP_deref)
 typedef unsigned int NSUInteger;
 
 @protocol NSObject
@@ -61,8 +70,8 @@
 {
 if ((self = [super init])) {
   run(^{
-  // CHECK-DAG: ![[SELF]] = !DILocalVariable(name: "self", scope:{{.*}}, line: [[@LINE+4]],
-  // CHECK-DAG: ![[D]] = !DILocalVariable(name: "d", scope:{{.*}}, line: [[@LINE+1]],
+  // CHECK-DAG: ![[SELF_VAR]] = !DILocalVariable(name: "self", scope:{{.*}}, line: [[@LINE+4]],
+  // CHECK-DAG: ![[D_VAR]] = !DILocalVariable(name: "d", scope:{{.*}}, line: [[@LINE+1]],
   NSMutableDictionary *d = [[NSMutableDictionary alloc] init]; 
   ivar = 42 + (int)[d count];
 });
Index: test/CodeGenObjC/debug-info-block-captured-self.m
===
--- test/CodeGenObjC/debug-info-block-captured-self.m
+++ test/CodeGenObjC/debug-info-block-captured-self.m
@@ -56,16 +56,22 @@
 // CHECK-NEXT:   [[DBGADDR:%.*]] = alloca [[BLOCK_T:<{.*}>]]*, align 8
 // CHECK:store i8* [[BLOCK_DESC:%.*]], i8** %[[MEM1]], align 8
 // CHECK:%[[TMP0:.*]] = load i8*, i8** %[[MEM1]]
-// CHECK:call void @llvm.dbg.value(metadata i8* %[[TMP0]], i64 0, metadata ![[BDMD:[0-9]+]], metadata !{{.*}})
-// CHECK:call void @llvm.dbg.declare(metadata i8* [[BLOCK_DESC]], metadata ![[BDMD:[0-9]+]], metadata !{{.*}})
+// CHECK:call void @llvm.dbg.declare(metadata i8** %[[MEM1]],
+// CHECK-SAME:   metadata ![[BDMD:[0-9]+]],
+// CHECK-SAME:   metadata ![[EMPTY:[0-9]+]])
 // CHECK:store [[BLOCK_T]]* {{%.*}}, [[BLOCK_T]]** [[DBGADDR]], align 8
-// CHECK:call void @llvm.dbg.declare(metadata [[BLOCK_T]]** [[DBGADDR]], metadat

[PATCH] D31440: PR32382: Adapt to LLVM changes in DIExpression.

2017-04-03 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl updated this revision to Diff 93900.

https://reviews.llvm.org/D31440

Files:
  lib/CodeGen/CGBlocks.cpp
  lib/CodeGen/CGDebugInfo.cpp
  lib/CodeGen/CGDebugInfo.h
  test/CodeGenObjC/debug-info-block-captured-self.m
  test/CodeGenObjC/debug-info-blocks.m

Index: test/CodeGenObjC/debug-info-blocks.m
===
--- test/CodeGenObjC/debug-info-blocks.m
+++ test/CodeGenObjC/debug-info-blocks.m
@@ -4,11 +4,18 @@
 // Test that we generate the proper debug location for a captured self.
 // The second half of this test is in llvm/tests/DebugInfo/debug-info-blocks.ll
 
-// CHECK: define {{.*}}_block_invoke
-// CHECK: %[[BLOCK:.*]] = bitcast i8* %.block_descriptor to <{ i8*, i32, i32, i8*, %struct.__block_descriptor*, %0* }>*, !dbg
-// CHECK-NEXT: store <{ i8*, i32, i32, i8*, %struct.__block_descriptor*, %0* }>* %[[BLOCK]], <{ i8*, i32, i32, i8*, %struct.__block_descriptor*, %0* }>** %[[ALLOCA:.*]], align
-// CHECK-NEXT: call void @llvm.dbg.declare(metadata <{ i8*, i32, i32, i8*, %struct.__block_descriptor*, %0* }>** %[[ALLOCA]], metadata ![[SELF:[0-9]+]], metadata !{{.*}})
-// CHECK-NEXT: call void @llvm.dbg.declare(metadata %1** %d, metadata ![[D:[0-9]+]], metadata !{{.*}})
+// CHECK: define {{.*}}[A init]_block_invoke
+// CHECK-NEXT: entry
+// CHECK-NEXT: %[[DESC_ALLOCA:.*]] = alloca i8*, align 8
+// CHECK-NEXT: %[[BLOCK_ALLOCA:.*]] = alloca <{{.*}}>*, align 8
+// CHECK: store i8* %.block_descriptor, i8** %[[ALLOCA:.*]], align 8
+// CHECK: call void @llvm.dbg.declare(metadata i8** %[[DESC_ALLOCA]],
+// CHECK-SAME:metadata ![[BLOCK_VAR:[0-9]+]],
+// CHECK: call void @llvm.dbg.declare(
+// CHECK-SAME: metadata <{ i8*, i32, i32, i8*, %struct.__block_descriptor*, %0* }>**
+// CHECK-SAME:  %[[BLOCK_ALLOCA]], metadata ![[SELF_VAR:[0-9]+]],
+// CHECK-SAME:  metadata ![[SELF_EXPR:[0-9]+]])
+// CHECK: call void @llvm.dbg.declare(metadata %1** %d, metadata ![[D_VAR:[0-9]+]],
 
 // rdar://problem/14386148
 // Test that we don't emit bogus line numbers for the helper functions.
@@ -22,11 +29,13 @@
 // CHECK-NOT: ret
 // CHECK: load {{.*}}, !dbg ![[DESTROY_LINE:[0-9]+]]
 
-// CHECK-DAG: [[DBG_LINE]] = !DILocation(line: 0, scope: ![[COPY_SP:[0-9]+]])
-// CHECK-DAG: [[COPY_LINE]] = !DILocation(line: 0, scope: ![[COPY_SP:[0-9]+]])
-// CHECK-DAG: [[COPY_SP]] = distinct !DISubprogram(name: "__copy_helper_block_"
-// CHECK-DAG: [[DESTROY_LINE]] = !DILocation(line: 0, scope: ![[DESTROY_SP:[0-9]+]])
-// CHECK-DAG: [[DESTROY_SP]] = distinct !DISubprogram(name: "__destroy_helper_block_"
+// CHECK-DAG: ![[DBG_LINE]] = !DILocation(line: 0, scope: ![[COPY_SP:[0-9]+]])
+// CHECK-DAG: ![[COPY_LINE]] = !DILocation(line: 0, scope: ![[COPY_SP:[0-9]+]])
+// CHECK-DAG: ![[COPY_SP]] = distinct !DISubprogram(name: "__copy_helper_block_"
+// CHECK-DAG: ![[DESTROY_LINE]] = !DILocation(line: 0, scope: ![[DESTROY_SP:[0-9]+]])
+// CHECK-DAG: ![[DESTROY_SP]] = distinct !DISubprogram(name: "__destroy_helper_block_"
+// CHECK-DAG: ![[BLOCK_VAR]] = !DILocalVariable(name: ".block_descriptor"
+// CHECK-DAG: ![[SELF_EXPR]] = !DIExpression(DW_OP_plus, 32, DW_OP_deref)
 typedef unsigned int NSUInteger;
 
 @protocol NSObject
@@ -61,8 +70,8 @@
 {
 if ((self = [super init])) {
   run(^{
-  // CHECK-DAG: ![[SELF]] = !DILocalVariable(name: "self", scope:{{.*}}, line: [[@LINE+4]],
-  // CHECK-DAG: ![[D]] = !DILocalVariable(name: "d", scope:{{.*}}, line: [[@LINE+1]],
+  // CHECK-DAG: ![[SELF_VAR]] = !DILocalVariable(name: "self", scope:{{.*}}, line: [[@LINE+4]],
+  // CHECK-DAG: ![[D_VAR]] = !DILocalVariable(name: "d", scope:{{.*}}, line: [[@LINE+1]],
   NSMutableDictionary *d = [[NSMutableDictionary alloc] init]; 
   ivar = 42 + (int)[d count];
 });
Index: test/CodeGenObjC/debug-info-block-captured-self.m
===
--- test/CodeGenObjC/debug-info-block-captured-self.m
+++ test/CodeGenObjC/debug-info-block-captured-self.m
@@ -56,16 +56,22 @@
 // CHECK-NEXT:   [[DBGADDR:%.*]] = alloca [[BLOCK_T:<{.*}>]]*, align 8
 // CHECK:store i8* [[BLOCK_DESC:%.*]], i8** %[[MEM1]], align 8
 // CHECK:%[[TMP0:.*]] = load i8*, i8** %[[MEM1]]
-// CHECK:call void @llvm.dbg.value(metadata i8* %[[TMP0]], i64 0, metadata ![[BDMD:[0-9]+]], metadata !{{.*}})
-// CHECK:call void @llvm.dbg.declare(metadata i8* [[BLOCK_DESC]], metadata ![[BDMD:[0-9]+]], metadata !{{.*}})
+// CHECK:call void @llvm.dbg.declare(metadata i8** %[[MEM1]],
+// CHECK-SAME:   metadata ![[BDMD:[0-9]+]],
+// CHECK-SAME:   metadata ![[EMPTY:[0-9]+]])
 // CHECK:store [[BLOCK_T]]* {{%.*}}, [[BLOCK_T]]** [[DBGADDR]], align 8
-// CHECK:call void @llvm.dbg.declare(metadata [[BLOCK_T]]** [[DBGADDR]], metadata ![[SELF:.*]], metadata !{{.*}})
+// CHECK:call void @llvm.dbg.declare(metadata [[B

[PATCH] D29660: [OpenMP] Add flag for overwriting default PTX version for OpenMP targets

2017-04-03 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea updated this revision to Diff 93901.
gtbercea added a comment.

Update test.


Repository:
  rL LLVM

https://reviews.llvm.org/D29660

Files:
  include/clang/Driver/Options.td
  lib/Driver/ToolChains/Cuda.cpp
  test/Driver/openmp-offload.c


Index: test/Driver/openmp-offload.c
===
--- test/Driver/openmp-offload.c
+++ test/Driver/openmp-offload.c
@@ -634,6 +634,16 @@
 
 /// ###
 
+/// Check PTXAS is passed the compute capability passed to the driver.
+// RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda 
--fopenmp-ptx=+ptx52 -save-temps -no-canonical-prefixes %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-PTXAS-VERSION %s
+
+// CHK-PTXAS-VERSION: clang{{.*}}.bc" {{.*}}"-target-feature" "+ptx52"
+// CHK-PTXAS-VERSION-NEXT: clang{{.*}}.bc" {{.*}}"-target-feature" "+ptx52"
+// CHK-PTXAS-VERSION-NEXT: clang{{.*}}.bc" {{.*}}"-target-feature" "+ptx52"
+
+/// ###
+
 /// Check -fopenmp-is-device is also passed when generating the *.i and *.s 
intermediate files.
 // RUN:   %clang -### -fopenmp=libomp 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -save-temps -no-canonical-prefixes 
%s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHK-FOPENMP-IS-DEVICE %s
Index: lib/Driver/ToolChains/Cuda.cpp
===
--- lib/Driver/ToolChains/Cuda.cpp
+++ lib/Driver/ToolChains/Cuda.cpp
@@ -492,8 +492,18 @@
   // than LLVM defaults to. Use PTX4.2 which is the PTX version that
   // came with CUDA-7.0.
   CC1Args.push_back("-target-feature");
+
+  StringRef PtxVersion = DriverArgs.getLastArgValue(
+options::OPT_fopenmp_ptx_EQ);
+
   CC1Args.push_back("+ptx42");
 
+  if (DeviceOffloadingKind == Action::OFK_OpenMP &&
+  !PtxVersion.empty()) {
+// Use PTX version passed to the driver.
+CC1Args.back() = PtxVersion.data();
+  }
+
   if (DeviceOffloadingKind == Action::OFK_OpenMP) {
 SmallVector LibraryPaths;
 if (char *Env = ::getenv("LIBRARY_PATH")) {
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -529,6 +529,8 @@
   HelpText<"CUDA installation path">;
 def fopenmp_cuda_gpu_arch_EQ : Joined<["--"], "fopenmp-cuda-gpu-arch=">, 
Flags<[DriverOption]>,
   HelpText<"Pass a single CUDA GPU architecture (default sm_20) to be used by 
OpenMP device offloading.">;
+def fopenmp_ptx_EQ : Joined<["--"], "fopenmp-ptx=">, Flags<[DriverOption]>,
+  HelpText<"Pass a PTX version +ptxXX, default +ptx42 (for PTX version 4.2) 
used by OpenMP device offloading.">;
 def ptxas_path_EQ : Joined<["--"], "ptxas-path=">, Group,
   HelpText<"Path to ptxas (used for compiling CUDA code)">;
 def fcuda_flush_denormals_to_zero : Flag<["-"], 
"fcuda-flush-denormals-to-zero">,


Index: test/Driver/openmp-offload.c
===
--- test/Driver/openmp-offload.c
+++ test/Driver/openmp-offload.c
@@ -634,6 +634,16 @@
 
 /// ###
 
+/// Check PTXAS is passed the compute capability passed to the driver.
+// RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda --fopenmp-ptx=+ptx52 -save-temps -no-canonical-prefixes %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-PTXAS-VERSION %s
+
+// CHK-PTXAS-VERSION: clang{{.*}}.bc" {{.*}}"-target-feature" "+ptx52"
+// CHK-PTXAS-VERSION-NEXT: clang{{.*}}.bc" {{.*}}"-target-feature" "+ptx52"
+// CHK-PTXAS-VERSION-NEXT: clang{{.*}}.bc" {{.*}}"-target-feature" "+ptx52"
+
+/// ###
+
 /// Check -fopenmp-is-device is also passed when generating the *.i and *.s intermediate files.
 // RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=powerpc64le-ibm-linux-gnu -save-temps -no-canonical-prefixes %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHK-FOPENMP-IS-DEVICE %s
Index: lib/Driver/ToolChains/Cuda.cpp
===
--- lib/Driver/ToolChains/Cuda.cpp
+++ lib/Driver/ToolChains/Cuda.cpp
@@ -492,8 +492,18 @@
   // than LLVM defaults to. Use PTX4.2 which is the PTX version that
   // came with CUDA-7.0.
   CC1Args.push_back("-target-feature");
+
+  StringRef PtxVersion = DriverArgs.getLastArgValue(
+options::OPT_fopenmp_ptx_EQ);
+
   CC1Args.push_back("+ptx42");
 
+  if (DeviceOffloadingKind == Action::OFK_OpenMP &&
+  !PtxVersion.empty()) {
+// Use PTX version passed to the driver.
+CC1Args.back() = PtxVersion.data();
+  }
+
   if (DeviceOffloadingKind == Action::OFK_OpenMP) {
 SmallVector LibraryPaths;
 if (char *Env = ::getenv("LIBRARY_PATH")) {
Index: include/clang/Driver/Options.td
==

[PATCH] D31422: Add builder for libunwind docs

2017-04-03 Thread Jonathan Roelofs via Phabricator via cfe-commits
jroelofs added a comment.

The 0th build seems to have been successful: 
http://lab.llvm.org:8011/builders/libunwind-sphinx-docs/builds/0

That being said, I did have to kick it off manually. I'll make a no-op change 
later this afternoon, and see if the builder picks it up.


https://reviews.llvm.org/D31422



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


[PATCH] D31404: [OpenCL] Allow alloca return non-zero private pointer

2017-04-03 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl marked 31 inline comments as done.
yaxunl added inline comments.



Comment at: include/clang/AST/ASTContext.h:2328
+return AddrSpaceMapMangling || 
+   AS >= LangAS::target_first;
   }

Anastasia wrote:
> So we couldn't use the  LangAS::Count instead?
> 
> I have the same comment in other places that use LangAS::target_first. Why 
> couldn't we simply use LangAS::Count? It there any point in having two tags?
> 
> Another comment is why do we need ASes specified by 
> `__attribute__((address_space(n)))` to be unique enum number at the end of 
> named ASes of OpenCL and CUDA? I think conceptually the full range of ASes 
> can be used in C because the ASes from OpenCL and CUDA are not available 
> there anyways.
I will use LangAS::Count instead and remove target_first, since their values 
are the same.

For your second question:  the values for `__attribute__((address_space(n)))` 
need to be different from the language specific address space values because 
they are mapped to target address space differently.

For language specific address space, they are mapped through a target defined 
mapping table.

For `__attribute__((address_space(n)))`, the target address space should be the 
same as n, without going through the mapping table.

If they are defined in overlapping value ranges, they cannot be handled in 
different ways.





Comment at: include/clang/AST/Type.h:339-340
+auto Addr = getAddressSpace();
+if (Addr == 0)
+  return 0;
+return Addr - LangAS::target_first;

t-tye wrote:
> Since you mention this is only used for  `__attribute__((address_space(n)))`, 
> why is this check for 0 needed?
> 
> If it is needed then to match other places should it simply be:
> 
> ```
> if (Addr)
>   return Addr - LangAS::target_first;
> return 0;
> ```
It is for `__attribute__((address_space(n)))` and the default addr space 0.

For the default addr space 0, we want to print 0 instead of 
`-LangAS::target_first`.

I will make the change for matching other places.



Comment at: include/clang/Basic/DiagnosticSemaKinds.td:2451-2453
+def warn_attribute_address_space_negative : Warning<
+  "address space is negative">,
+  InGroup>;

t-tye wrote:
> Now the one questionable test has been fixed, should the handling of 
> address_space attribute go back to it being an error if n is negative? That 
> seems more logical.
Will do



Comment at: lib/AST/ASTContext.cpp:9555
+  // alloca.
+  if (AS == LangAS::Default && LangOpts.OpenCL)
+return getTargetInfo().getDataLayout().getAllocaAddrSpace();

t-tye wrote:
> To be consistent with other places should this simply be:
> ```
> if (!AS && LangOpts.OpenCL)
> ```
Will do.



Comment at: lib/AST/ASTContext.cpp:9556
+  if (AS == LangAS::Default && LangOpts.OpenCL)
+return getTargetInfo().getDataLayout().getAllocaAddrSpace();
+  if (AS >= LangAS::target_first)

Anastasia wrote:
> t-tye wrote:
> > An alternative to doing this would be to add an opencl_private to LangAS 
> > and have each target map it accordingly. Then this could be:
> > 
> > ```
> > // If a target specific address space was specified, simply return it.
> > if (AS >= LangAS::target_first)
> >   return AS - LangAS::target_first;
> > // For OpenCL, only function local variables are not explicitly marked with
> > // an address space in the AST, so treat them as the OpenCL private address 
> > space.
> > if (!AS && LangOpts.OpenCL)
> >   AS = LangAS::opencl_private;
> > return (*AddrSpaceMap)[AS];
> > ```
> > This seems to better express what is happening here. If no address space 
> > was specified, and the language is OpenCL, then treat it as OpenCL private 
> > and map it according to the target mapping.
> > 
> > If wanted to eliminate the LangAS::Default named constant then that would 
> > be possible as it is no longer being used by name. However, would need to 
> > ensure that the first named enumerators starts at 1 so that 0 is left as 
> > the "no value explicitly specified" value that each target must map to the 
> > target specific generic address space.
> I would very much like to see `opencl_private` represented explicitly. This 
> would allow us to simplify some parsing and also enable proper support of 
> `NULL ` literal (that has no AS by the spec).
> 
> We can of course do this refactoring work as a separate step.
Introducing opencl_private could incur quite a few changes to AST, Sema, and 
lit tests.

We'd better do that in another patch since the main objective of this patch is 
to get Clang codegen work with the new alloca API and non-zero private address 
space.




Comment at: lib/Sema/SemaExprCXX.cpp:2055
+  << AllocType.getUnqualifiedType()
+  << AllocType.getQualifiers().getAddressSpacePrintValue();
   else if (getLangOpts().ObjCAutoRefCount) {

t-tye wrote:
> Woul

[PATCH] D31487: [coroutines] Fix rebuilding of implicit and dependent coroutine statements.

2017-04-03 Thread Gor Nishanov via Phabricator via cfe-commits
GorNishanov accepted this revision.
GorNishanov added a comment.
This revision is now accepted and ready to land.

LGTM with nits addressed


https://reviews.llvm.org/D31487



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


[PATCH] D31404: [OpenCL] Allow alloca return non-zero private pointer

2017-04-03 Thread Tony Tye via Phabricator via cfe-commits
t-tye added inline comments.



Comment at: include/clang/AST/Type.h:339-340
+auto Addr = getAddressSpace();
+if (Addr == 0)
+  return 0;
+return Addr - LangAS::target_first;

Anastasia wrote:
> yaxunl wrote:
> > t-tye wrote:
> > > Since you mention this is only used for  
> > > `__attribute__((address_space(n)))`, why is this check for 0 needed?
> > > 
> > > If it is needed then to match other places should it simply be:
> > > 
> > > ```
> > > if (Addr)
> > >   return Addr - LangAS::target_first;
> > > return 0;
> > > ```
> > It is for `__attribute__((address_space(n)))` and the default addr space 0.
> > 
> > For the default addr space 0, we want to print 0 instead of 
> > `-LangAS::target_first`.
> > 
> > I will make the change for matching other places.
> Could we use LangAS::Count instead?
I do not think the address space 0 should be returned as 0 as then it is 
impossible to distinguish between a type that has no address space attribute, 
and one that has an explicit address space attribute with the value 0.

But that seems to be a bug in the original code so I would suggest leaving this 
for now and fixing it as a separate patch. The diagnostic message should really 
be checking if an address space attribute was present (by checking for 0), and 
changing the working of the message accordingly.

Suggest add a TODO here to mention this which can be fixed in a later patch.


https://reviews.llvm.org/D31404



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


[PATCH] D31394: [X86][Clang] Converting __mm{|256|512}_movm_epi{8|16|32|64} LLVMIR call into generic intrinsics.

2017-04-03 Thread michael zuckerman via Phabricator via cfe-commits
m_zuckerman updated this revision to Diff 93915.

https://reviews.llvm.org/D31394

Files:
  lib/CodeGen/CGBuiltin.cpp
  test/CodeGen/avx512bw-builtins.c
  test/CodeGen/avx512dq-builtins.c
  test/CodeGen/avx512vlbw-builtins.c
  test/CodeGen/avx512vldq-builtins.c

Index: test/CodeGen/avx512vldq-builtins.c
===
--- test/CodeGen/avx512vldq-builtins.c
+++ test/CodeGen/avx512vldq-builtins.c
@@ -865,25 +865,32 @@
 
 __m128i test_mm_movm_epi32(__mmask8 __A) {
   // CHECK-LABEL: @test_mm_movm_epi32
-  // CHECK: @llvm.x86.avx512.cvtmask2d.128
+  // CHECK: %2 = bitcast i8 %1 to <8 x i1>
+  // CHECK: %extract.i = shufflevector <8 x i1> %2, <8 x i1> %2, <4 x i32> 
+  // CHECK: %vpmovm2.i = sext <4 x i1> %extract.i to <4 x i32>
   return _mm_movm_epi32(__A); 
 }
 
 __m256i test_mm256_movm_epi32(__mmask8 __A) {
   // CHECK-LABEL: @test_mm256_movm_epi32
-  // CHECK: @llvm.x86.avx512.cvtmask2d.256
+  // CHECK: %2 = bitcast i8 %1 to <8 x i1>
+  // CHECK: %vpmovm2.i = sext <8 x i1> %2 to <8 x i32>
   return _mm256_movm_epi32(__A); 
 }
 
 __m128i test_mm_movm_epi64(__mmask8 __A) {
   // CHECK-LABEL: @test_mm_movm_epi64
-  // CHECK: @llvm.x86.avx512.cvtmask2q.128
+  // CHECK: %2 = bitcast i8 %1 to <8 x i1>
+  // CHECK: %extract.i = shufflevector <8 x i1> %2, <8 x i1> %2, <2 x i32> 
+  // CHECK: %vpmovm2.i = sext <2 x i1> %extract.i to <2 x i64>
   return _mm_movm_epi64(__A); 
 }
 
 __m256i test_mm256_movm_epi64(__mmask8 __A) {
   // CHECK-LABEL: @test_mm256_movm_epi64
-  // CHECK: @llvm.x86.avx512.cvtmask2q.256
+  // CHECK: %2 = bitcast i8 %1 to <8 x i1>
+  // CHECK: %extract.i = shufflevector <8 x i1> %2, <8 x i1> %2, <4 x i32> 
+  // CHECK: %vpmovm2.i = sext <4 x i1> %extract.i to <4 x i64>
   return _mm256_movm_epi64(__A); 
 }
 
Index: test/CodeGen/avx512vlbw-builtins.c
===
--- test/CodeGen/avx512vlbw-builtins.c
+++ test/CodeGen/avx512vlbw-builtins.c
@@ -2521,25 +2521,29 @@
 
 __m128i test_mm_movm_epi8(__mmask16 __A) {
   // CHECK-LABEL: @test_mm_movm_epi8
-  // CHECK: @llvm.x86.avx512.cvtmask2b.128
+  // CHECK: %2 = bitcast i16 %1 to <16 x i1>
+  // CHECK: %vpmovm2.i = sext <16 x i1> %2 to <16 x i8>
   return _mm_movm_epi8(__A); 
 }
 
 __m256i test_mm256_movm_epi8(__mmask32 __A) {
   // CHECK-LABEL: @test_mm256_movm_epi8
-  // CHECK: @llvm.x86.avx512.cvtmask2b.256
+  // CHECK: %2 = bitcast i32 %1 to <32 x i1>
+  // CHECK: %vpmovm2.i = sext <32 x i1> %2 to <32 x i8>
   return _mm256_movm_epi8(__A); 
 }
 
 __m128i test_mm_movm_epi16(__mmask8 __A) {
   // CHECK-LABEL: @test_mm_movm_epi16
-  // CHECK: @llvm.x86.avx512.cvtmask2w.128
+  // CHECK: %2 = bitcast i8 %1 to <8 x i1>
+  // CHECK: %vpmovm2.i = sext <8 x i1> %2 to <8 x i16>
   return _mm_movm_epi16(__A); 
 }
 
 __m256i test_mm256_movm_epi16(__mmask16 __A) {
   // CHECK-LABEL: @test_mm256_movm_epi16
-  // CHECK: @llvm.x86.avx512.cvtmask2w.256
+  // CHECK: %2 = bitcast i16 %1 to <16 x i1>
+  // CHECK: %vpmovm2.i = sext <16 x i1> %2 to <16 x i16>
   return _mm256_movm_epi16(__A); 
 }
 
Index: test/CodeGen/avx512dq-builtins.c
===
--- test/CodeGen/avx512dq-builtins.c
+++ test/CodeGen/avx512dq-builtins.c
@@ -929,13 +929,15 @@
 
 __m512i test_mm512_movm_epi32(__mmask16 __A) {
   // CHECK-LABEL: @test_mm512_movm_epi32
-  // CHECK: @llvm.x86.avx512.cvtmask2d.512
+  // CHECK: %2 = bitcast i16 %1 to <16 x i1>
+  // CHECK: %vpmovm2.i = sext <16 x i1> %2 to <16 x i32>
   return _mm512_movm_epi32(__A); 
 }
 
 __m512i test_mm512_movm_epi64(__mmask8 __A) {
   // CHECK-LABEL: @test_mm512_movm_epi64
-  // CHECK: @llvm.x86.avx512.cvtmask2q.512
+  // CHECK: %2 = bitcast i8 %1 to <8 x i1>
+  // CHECK: %vpmovm2.i = sext <8 x i1> %2 to <8 x i64>
   return _mm512_movm_epi64(__A); 
 }
 
Index: test/CodeGen/avx512bw-builtins.c
===
--- test/CodeGen/avx512bw-builtins.c
+++ test/CodeGen/avx512bw-builtins.c
@@ -1543,13 +1543,15 @@
 
 __m512i test_mm512_movm_epi8(__mmask64 __A) {
   // CHECK-LABEL: @test_mm512_movm_epi8
-  // CHECK: @llvm.x86.avx512.cvtmask2b.512
+  // CHECK:  %2 = bitcast i64 %1 to <64 x i1>
+  // CHECK:  %vpmovm2.i = sext <64 x i1> %2 to <64 x i8>
   return _mm512_movm_epi8(__A); 
 }
 
 __m512i test_mm512_movm_epi16(__mmask32 __A) {
   // CHECK-LABEL: @test_mm512_movm_epi16
-  // CHECK: @llvm.x86.avx512.cvtmask2w.512
+  // CHECK:  %2 = bitcast i32 %1 to <32 x i1>
+  // CHECK:  %vpmovm2.i = sext <32 x i1> %2 to <32 x i16>
   return _mm512_movm_epi16(__A); 
 }
 
Index: lib/CodeGen/CGBuiltin.cpp
===
--- lib/CodeGen/CGBuiltin.cpp
+++ lib/CodeGen/CGBuiltin.cpp
@@ -7168,6 +7168,13 @@
   return EmitX86Select(CGF, Ops[3], Res, Ops[2]);
 }
 
+static Value *EmitX86SExtMask(CodeGenFunction &CGF, llvm::IntegerType *IT,
+  Value *Op, llvm::Type *DstTy) {

[PATCH] D31394: [X86][Clang] Converting __mm{|256|512}_movm_epi{8|16|32|64} LLVMIR call into generic intrinsics.

2017-04-03 Thread michael zuckerman via Phabricator via cfe-commits
m_zuckerman added inline comments.



Comment at: lib/CodeGen/CGBuiltin.cpp:7176
+  return CGF.Builder.CreateSExt(
+  Mask, llvm::VectorType::get(IT, NumberOfElements), "vpmovm2");
+}

craig.topper wrote:
> Why can't we just use DstTy here to create the SExt?
You are right Thanks


https://reviews.llvm.org/D31394



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


[PATCH] D31487: [coroutines] Fix rebuilding of implicit and dependent coroutine statements.

2017-04-03 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF updated this revision to Diff 93917.
EricWF marked 6 inline comments as done.
EricWF added a comment.

- Address inline comments.


https://reviews.llvm.org/D31487

Files:
  include/clang/AST/StmtCXX.h
  lib/AST/StmtCXX.cpp
  lib/Sema/CoroutineStmtBuilder.h
  lib/Sema/SemaCoroutine.cpp
  lib/Sema/TreeTransform.h
  test/SemaCXX/coroutines.cpp

Index: test/SemaCXX/coroutines.cpp
===
--- test/SemaCXX/coroutines.cpp
+++ test/SemaCXX/coroutines.cpp
@@ -534,6 +534,12 @@
   co_await a;
 }
 
+template 
+coro bad_implicit_return_dependent(T) { // expected-error {{'bad_promise_6' declares both 'return_value' and 'return_void'}}
+  co_await a;
+}
+template coro bad_implicit_return_dependent(bad_promise_6); // expected-note {{in instantiation}}
+
 struct bad_promise_7 {
   coro get_return_object();
   suspend_always initial_suspend();
@@ -544,25 +550,38 @@
   co_await a;
 }
 
+template 
+coro no_unhandled_exception_dependent(T) { // expected-error {{'bad_promise_7' is required to declare the member 'unhandled_exception()'}}
+  co_await a;
+}
+template coro no_unhandled_exception_dependent(bad_promise_7); // expected-note {{in instantiation}}
+
 struct bad_promise_base {
 private:
   void return_void();
 };
 struct bad_promise_8 : bad_promise_base {
   coro get_return_object();
   suspend_always initial_suspend();
   suspend_always final_suspend();
-  void unhandled_exception() __attribute__((unavailable)); // expected-note {{made unavailable}}
-  void unhandled_exception() const;// expected-note {{candidate}}
-  void unhandled_exception(void *) const;  // expected-note {{requires 1 argument, but 0 were provided}}
+  void unhandled_exception() __attribute__((unavailable)); // expected-note 2 {{made unavailable}}
+  void unhandled_exception() const;// expected-note 2 {{candidate}}
+  void unhandled_exception(void *) const;  // expected-note 2 {{requires 1 argument, but 0 were provided}}
 };
 coro calls_unhandled_exception() {
   // expected-error@-1 {{call to unavailable member function 'unhandled_exception'}}
   // FIXME: also warn about private 'return_void' here. Even though building
   // the call to unhandled_exception has already failed.
   co_await a;
 }
 
+template 
+coro calls_unhandled_exception_dependent(T) {
+  // expected-error@-1 {{call to unavailable member function 'unhandled_exception'}}
+  co_await a;
+}
+template coro calls_unhandled_exception_dependent(bad_promise_8); // expected-note {{in instantiation}}
+
 struct bad_promise_9 {
   coro get_return_object();
   suspend_always initial_suspend();
@@ -652,3 +671,26 @@
 extern "C" int f(promise_on_alloc_failure_tag) {
   co_return; //expected-note {{function is a coroutine due to use of 'co_return' here}}
 }
+
+struct bad_promise_11 {
+  coro get_return_object();
+  suspend_always initial_suspend();
+  suspend_always final_suspend();
+  void unhandled_exception();
+  void return_void();
+
+private:
+  static coro get_return_object_on_allocation_failure(); // expected-note 2 {{declared private here}}
+};
+coro private_alloc_failure_handler() {
+  // expected-error@-1 {{'get_return_object_on_allocation_failure' is a private member of 'bad_promise_11'}}
+  co_return; // FIXME: Add a "declared coroutine here" note.
+}
+
+template 
+coro dependent_private_alloc_failure_handler(T) {
+  // expected-error@-1 {{'get_return_object_on_allocation_failure' is a private member of 'bad_promise_11'}}
+  co_return; // FIXME: Add a "declared coroutine here" note.
+}
+template coro dependent_private_alloc_failure_handler(bad_promise_11);
+// expected-note@-1 {{requested here}}
Index: lib/Sema/TreeTransform.h
===
--- lib/Sema/TreeTransform.h
+++ lib/Sema/TreeTransform.h
@@ -14,6 +14,7 @@
 #ifndef LLVM_CLANG_LIB_SEMA_TREETRANSFORM_H
 #define LLVM_CLANG_LIB_SEMA_TREETRANSFORM_H
 
+#include "CoroutineStmtBuilder.h"
 #include "TypeLocBuilder.h"
 #include "clang/AST/Decl.h"
 #include "clang/AST/DeclObjC.h"
@@ -6851,13 +6852,9 @@
 template
 StmtResult
 TreeTransform::TransformCoroutineBodyStmt(CoroutineBodyStmt *S) {
-  // The coroutine body should be re-formed by the caller if necessary.
-  // FIXME: The coroutine body is always rebuilt by ActOnFinishFunctionBody
-  CoroutineBodyStmt::CtorArgs BodyArgs;
-
   auto *ScopeInfo = SemaRef.getCurFunction();
   auto *FD = cast(SemaRef.CurContext);
-  assert(ScopeInfo && !ScopeInfo->CoroutinePromise &&
+  assert(FD && ScopeInfo && !ScopeInfo->CoroutinePromise &&
  ScopeInfo->NeedsCoroutineSuspends &&
  ScopeInfo->CoroutineSuspends.first == nullptr &&
  ScopeInfo->CoroutineSuspends.second == nullptr &&
@@ -6869,17 +6866,11 @@
 
   // The new CoroutinePromise object needs to be built and put into the current
   // FunctionScopeInfo before any transformations or rebuilding occurs.
-  auto *Promise = S->g

r299380 - [coroutines] Fix rebuilding of implicit and dependent coroutine statements.

2017-04-03 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Mon Apr  3 14:21:00 2017
New Revision: 299380

URL: http://llvm.org/viewvc/llvm-project?rev=299380&view=rev
Log:
[coroutines] Fix rebuilding of implicit and dependent coroutine statements.

Summary:
Certain implicitly generated coroutine statements, such as the calls to 
'return_value()' or `return_void()` or 
`get_return_object_on_allocation_failure()`, cannot be built until the promise 
type is no longer dependent. This means they are not built until after the 
coroutine body statement has been transformed.

This patch fixes an issue where these statements would never be built for 
coroutine templates.

It also fixes a small issue where diagnostics about 
`get_return_object_on_allocation_failure()` were incorrectly suppressed. 

Reviewers: rsmith, majnemer, GorNishanov, aaron.ballman

Reviewed By: GorNishanov

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D31487

Added:
cfe/trunk/lib/Sema/CoroutineStmtBuilder.h
Modified:
cfe/trunk/include/clang/AST/StmtCXX.h
cfe/trunk/lib/AST/StmtCXX.cpp
cfe/trunk/lib/Sema/SemaCoroutine.cpp
cfe/trunk/lib/Sema/TreeTransform.h
cfe/trunk/test/SemaCXX/coroutines.cpp

Modified: cfe/trunk/include/clang/AST/StmtCXX.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/StmtCXX.h?rev=299380&r1=299379&r2=299380&view=diff
==
--- cfe/trunk/include/clang/AST/StmtCXX.h (original)
+++ cfe/trunk/include/clang/AST/StmtCXX.h Mon Apr  3 14:21:00 2017
@@ -344,6 +344,10 @@ private:
 public:
   static CoroutineBodyStmt *Create(const ASTContext &C, CtorArgs const &Args);
 
+  bool hasDependentPromiseType() const {
+return getPromiseDecl()->getType()->isDependentType();
+  }
+
   /// \brief Retrieve the body of the coroutine as written. This will be either
   /// a CompoundStmt or a TryStmt.
   Stmt *getBody() const {

Modified: cfe/trunk/lib/AST/StmtCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/StmtCXX.cpp?rev=299380&r1=299379&r2=299380&view=diff
==
--- cfe/trunk/lib/AST/StmtCXX.cpp (original)
+++ cfe/trunk/lib/AST/StmtCXX.cpp Mon Apr  3 14:21:00 2017
@@ -112,4 +112,4 @@ CoroutineBodyStmt::CoroutineBodyStmt(Cor
   Args.ReturnStmtOnAllocFailure;
   std::copy(Args.ParamMoves.begin(), Args.ParamMoves.end(),
 const_cast(getParamMoves().data()));
-}
\ No newline at end of file
+}

Added: cfe/trunk/lib/Sema/CoroutineStmtBuilder.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/CoroutineStmtBuilder.h?rev=299380&view=auto
==
--- cfe/trunk/lib/Sema/CoroutineStmtBuilder.h (added)
+++ cfe/trunk/lib/Sema/CoroutineStmtBuilder.h Mon Apr  3 14:21:00 2017
@@ -0,0 +1,70 @@
+//===- CoroutineStmtBuilder.h - Implicit coroutine stmt builder -*- C++ 
-*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//===--===//
+//
+//  This file defines CoroutineStmtBuilder, a class for building the implicit
+//  statements required for building a coroutine body.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_LIB_SEMA_COROUTINESTMTBUILDER_H
+#define LLVM_CLANG_LIB_SEMA_COROUTINESTMTBUILDER_H
+
+#include "clang/AST/Decl.h"
+#include "clang/AST/ExprCXX.h"
+#include "clang/AST/StmtCXX.h"
+#include "clang/Lex/Preprocessor.h"
+#include "clang/Sema/SemaInternal.h"
+
+namespace clang {
+
+class CoroutineStmtBuilder : public CoroutineBodyStmt::CtorArgs {
+  Sema &S;
+  FunctionDecl &FD;
+  sema::FunctionScopeInfo &Fn;
+  bool IsValid = true;
+  SourceLocation Loc;
+  QualType RetType;
+  SmallVector ParamMovesVector;
+  const bool IsPromiseDependentType;
+  CXXRecordDecl *PromiseRecordDecl = nullptr;
+
+public:
+  /// \brief Construct a CoroutineStmtBuilder and initialize the promise
+  /// statement and initial/final suspends from the FunctionScopeInfo.
+  CoroutineStmtBuilder(Sema &S, FunctionDecl &FD, sema::FunctionScopeInfo &Fn,
+   Stmt *Body);
+
+  /// \brief Build the coroutine body statements, including the
+  /// "promise dependent" statements when the promise type is not dependent.
+  bool buildStatements();
+
+  /// \brief Build the coroutine body statements that require a non-dependent
+  /// promise type in order to construct.
+  ///
+  /// For example different new/delete overloads are selected depending on
+  /// if the promise type provides `unhandled_exception()`, and therefore they
+  /// cannot be built until the promise type is complete so that we can perform
+  /// name lookup.
+  bool buildDependentStatements();
+
+  bool isInvalid() const { return !this->IsValid; 

[libunwind] r299381 - Try to trigger the new docs builder. NFC

2017-04-03 Thread Jonathan Roelofs via cfe-commits
Author: jroelofs
Date: Mon Apr  3 14:23:11 2017
New Revision: 299381

URL: http://llvm.org/viewvc/llvm-project?rev=299381&view=rev
Log:
Try to trigger the new docs builder. NFC

Modified:
libunwind/trunk/docs/index.rst

Modified: libunwind/trunk/docs/index.rst
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/docs/index.rst?rev=299381&r1=299380&r2=299381&view=diff
==
--- libunwind/trunk/docs/index.rst (original)
+++ libunwind/trunk/docs/index.rst Mon Apr  3 14:23:11 2017
@@ -64,6 +64,7 @@ Notes and Known Issues
 
 * TODO
 
+
 Getting Involved
 
 


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


[PATCH] D31394: [X86][Clang] Converting __mm{|256|512}_movm_epi{8|16|32|64} LLVMIR call into generic intrinsics.

2017-04-03 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: lib/CodeGen/CGBuiltin.cpp:7176
+  return CGF.Builder.CreateSExt(
+  Mask, llvm::VectorType::get(IT, NumberOfElements), "vpmovm2");
+}

m_zuckerman wrote:
> craig.topper wrote:
> > Why can't we just use DstTy here to create the SExt?
> You are right Thanks
That makes the IT parameter unnecessary now right? Which means we don't need to 
pass different values at the call site below.


https://reviews.llvm.org/D31394



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


[PATCH] D31404: [OpenCL] Allow alloca return non-zero private pointer

2017-04-03 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 93928.
yaxunl marked 5 inline comments as done.
yaxunl added a comment.

Revised by Tony's and Anastasia's comments.


https://reviews.llvm.org/D31404

Files:
  include/clang/AST/ASTContext.h
  include/clang/AST/Type.h
  include/clang/Basic/AddressSpaces.h
  lib/AST/ASTContext.cpp
  lib/AST/ExprClassification.cpp
  lib/AST/TypePrinter.cpp
  lib/Basic/Targets.cpp
  lib/CodeGen/CGCall.cpp
  lib/CodeGen/CGExpr.cpp
  lib/Sema/SemaExprCXX.cpp
  lib/Sema/SemaOverload.cpp
  lib/Sema/SemaType.cpp
  test/CodeGenOpenCL/address-space-constant-initializers.cl
  test/CodeGenOpenCL/address-spaces.cl
  test/CodeGenOpenCL/amdgpu-env-amdgiz.cl
  test/CodeGenOpenCL/vla.cl
  test/Sema/address_spaces.c
  test/Sema/invalid-assignment-constant-address-space.c
  test/SemaOpenCL/invalid-assignment-constant-address-space.cl

Index: test/SemaOpenCL/invalid-assignment-constant-address-space.cl
===
--- /dev/null
+++ test/SemaOpenCL/invalid-assignment-constant-address-space.cl
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only
+
+int constant c[3] = {0};
+
+void foo() {
+  c[0] = 1; //expected-error{{read-only variable is not assignable}}
+}
Index: test/Sema/invalid-assignment-constant-address-space.c
===
--- test/Sema/invalid-assignment-constant-address-space.c
+++ /dev/null
@@ -1,8 +0,0 @@
-// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only
-
-#define OPENCL_CONSTANT 8388354
-int __attribute__((address_space(OPENCL_CONSTANT))) c[3] = {0};
-
-void foo() {
-  c[0] = 1; //expected-error{{read-only variable is not assignable}}
-}
Index: test/Sema/address_spaces.c
===
--- test/Sema/address_spaces.c
+++ test/Sema/address_spaces.c
@@ -20,7 +20,7 @@
   _AS1 int arrarr[5][5]; // expected-error {{automatic variable qualified with an address space}}
 
   __attribute__((address_space(-1))) int *_boundsA; // expected-error {{address space is negative}}
-  __attribute__((address_space(0x7F))) int *_boundsB;
+  __attribute__((address_space(0x7F))) int *_boundsB; // expected-error {{address space is larger than the maximum supported}}
   __attribute__((address_space(0x100))) int *_boundsC; // expected-error {{address space is larger than the maximum supported}}
   // chosen specifically to overflow 32 bits and come out reasonable
   __attribute__((address_space(4294967500))) int *_boundsD; // expected-error {{address space is larger than the maximum supported}}
Index: test/CodeGenOpenCL/vla.cl
===
--- test/CodeGenOpenCL/vla.cl
+++ test/CodeGenOpenCL/vla.cl
@@ -1,18 +1,26 @@
-// RUN: %clang_cc1 -emit-llvm -triple "spir-unknown-unknown" -O0 -cl-std=CL2.0 -o - %s | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm -triple "spir-unknown-unknown" -O0 -cl-std=CL2.0 -o - %s | FileCheck -check-prefixes=CHECK,SPIR %s
+// RUN: %clang_cc1 -emit-llvm -triple amdgcn-amd-amdhsa-opencl -O0 -cl-std=CL2.0 -o - %s | FileCheck -check-prefixes=CHECK,SPIR %s
+// RUN: %clang_cc1 -emit-llvm -triple amdgcn-amd-amdhsa-amdgizcl -O0 -cl-std=CL2.0 -o - %s | FileCheck -check-prefixes=CHECK,GIZ %s
 
 constant int sz0 = 5;
-// CHECK: @sz0 = addrspace(2) constant i32 5
+// SPIR: @sz0 = addrspace(2) constant i32 5
+// GIZ: @sz0 = addrspace(4) constant i32 5
 const global int sz1 = 16;
 // CHECK: @sz1 = addrspace(1) constant i32 16
 const constant int sz2 = 8;
-// CHECK: @sz2 = addrspace(2) constant i32 8
+// SPIR: @sz2 = addrspace(2) constant i32 8
+// GIZ: @sz2 = addrspace(4) constant i32 8
 // CHECK: @testvla.vla2 = internal addrspace(3) global [8 x i16] undef
 
 kernel void testvla()
 {
   int vla0[sz0];
-// CHECK: %vla0 = alloca [5 x i32]
+// SPIR: %vla0 = alloca [5 x i32]
+// SPIR-NOT: %vla0 = alloca [5 x i32]{{.*}}addrspace
+// GIZ: %vla0 = alloca [5 x i32]{{.*}}addrspace(5)
   char vla1[sz1];
-// CHECK: %vla1 = alloca [16 x i8]
+// SPIR: %vla1 = alloca [16 x i8]
+// SPIR-NOT: %vla1 = alloca [16 x i8]{{.*}}addrspace
+// GIZ: %vla1 = alloca [16 x i8]{{.*}}addrspace(5)
   local short vla2[sz2];
 }
Index: test/CodeGenOpenCL/amdgpu-env-amdgiz.cl
===
--- test/CodeGenOpenCL/amdgpu-env-amdgiz.cl
+++ test/CodeGenOpenCL/amdgpu-env-amdgiz.cl
@@ -4,6 +4,6 @@
 // RUN: %clang_cc1 %s -O0 -triple amdgcn---amdgizcl -emit-llvm -o - | FileCheck -check-prefix=GIZ %s
 
 // CHECK: target datalayout = "e-p:32:32-p1:64:64-p2:64:64-p3:32:32-p4:64:64-p5:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64"
-// GIZ: target datalayout = "e-p:64:64-p1:64:64-p2:64:64-p3:32:32-p4:64:64-p5:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64"
+// GIZ: target datalayout = "e-p:64:64-p1:64:64-p2:64:64-p3:32:32-p4:64:64-p5:32:3

[PATCH] D30435: [clang-import-test] Lookup inside entities

2017-04-03 Thread Sean Callanan via Phabricator via cfe-commits
spyffe updated this revision to Diff 93927.
spyffe added a comment.
Herald added a subscriber: mgorny.

• Broke all the `ASTImporter` and `ExternalASTSource` subclassing logic into 
its own source file, with its API defined in `AST/ExternalASTMerger.h`.
• Cleaned up the API for LLDB's consumption: now rather than a 
`CompilerInstance` a client just has to provide an `ASTContext` and a 
`FileManager` (just like when setting up an `ASTImporter`).  This allows e.g. 
DWARF to be a valid source.


Repository:
  rL LLVM

https://reviews.llvm.org/D30435

Files:
  lib/AST/CMakeLists.txt
  test/Import/forward-declared-struct/Inputs/S1.c
  test/Import/forward-declared-struct/Inputs/S2.c
  test/Import/forward-declared-struct/test.c
  test/Import/member-in-struct/Inputs/S.c
  test/Import/member-in-struct/test.c
  test/Import/multiple-forward-declarations/Inputs/S1.c
  test/Import/multiple-forward-declarations/Inputs/S2.c
  test/Import/multiple-forward-declarations/test.c
  test/Import/overloaded-function/Inputs/F1.c
  test/Import/overloaded-function/Inputs/F2.c
  test/Import/overloaded-function/test.c
  test/Import/struct-in-namespace/Inputs/N1.cpp
  test/Import/struct-in-namespace/Inputs/N2.cpp
  test/Import/struct-in-namespace/Inputs/N3.cpp
  test/Import/struct-in-namespace/test.cpp
  test/Import/template-specialization/Inputs/T.cpp
  test/Import/template-specialization/test.cpp
  tools/clang-import-test/clang-import-test.cpp

Index: tools/clang-import-test/clang-import-test.cpp
===
--- tools/clang-import-test/clang-import-test.cpp
+++ tools/clang-import-test/clang-import-test.cpp
@@ -9,6 +9,8 @@
 
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/ASTImporter.h"
+#include "clang/AST/DeclObjC.h"
+#include "clang/AST/ExternalASTMerger.h"
 #include "clang/Basic/Builtins.h"
 #include "clang/Basic/IdentifierTable.h"
 #include "clang/Basic/SourceLocation.h"
@@ -189,61 +191,18 @@
 } // end namespace
 
 namespace {
-class TestExternalASTSource : public ExternalASTSource {
-private:
-  llvm::ArrayRef> ImportCIs;
-  std::map> ForwardImporters;
-  std::map> ReverseImporters;
-
-public:
-  TestExternalASTSource(
-  CompilerInstance &ExpressionCI,
-  llvm::ArrayRef> ImportCIs)
-  : ImportCIs(ImportCIs) {
-for (const std::unique_ptr &ImportCI : ImportCIs) {
-  ForwardImporters[ImportCI.get()] = llvm::make_unique(
-  ExpressionCI.getASTContext(), ExpressionCI.getFileManager(),
-  ImportCI->getASTContext(), ImportCI->getFileManager(),
-  /*MinimalImport=*/true);
-  ReverseImporters[ImportCI.get()] = llvm::make_unique(
-  ImportCI->getASTContext(), ImportCI->getFileManager(),
-  ExpressionCI.getASTContext(), ExpressionCI.getFileManager(),
-  /*MinimalImport=*/true);
-}
-  }
-
-  bool FindExternalVisibleDeclsByName(const DeclContext *DC,
-  DeclarationName Name) override {
-llvm::SmallVector Decls;
-
-if (isa(DC)) {
-  for (const std::unique_ptr &I : ImportCIs) {
-DeclarationName FromName = ReverseImporters[I.get()]->Import(Name);
-DeclContextLookupResult Result =
-I->getASTContext().getTranslationUnitDecl()->lookup(FromName);
-for (NamedDecl *FromD : Result) {
-  NamedDecl *D =
-  llvm::cast(ForwardImporters[I.get()]->Import(FromD));
-  Decls.push_back(D);
-}
-  }
-}
-if (Decls.empty()) {
-  return false;
-} else {
-  SetExternalVisibleDeclsForName(DC, Name, Decls);
-  return true;
-}
-  }
-};
-
+ 
 void AddExternalSource(
 CompilerInstance &CI,
 llvm::ArrayRef> Imports) {
-  ASTContext &AST = CI.getASTContext();
-  auto ES = llvm::make_unique(CI, Imports);
-  AST.setExternalSource(ES.release());
-  AST.getTranslationUnitDecl()->setHasExternalVisibleStorage();
+  ExternalASTMerger::ImporterEndpoint Target({CI.getASTContext(), CI.getFileManager()});
+  llvm::SmallVector Sources;
+  for (const std::unique_ptr &CI : Imports) {
+Sources.push_back({CI->getASTContext(), CI->getFileManager()});
+  }
+  auto ES = llvm::make_unique(Target, Sources);
+  CI.getASTContext().setExternalSource(ES.release());
+  CI.getASTContext().getTranslationUnitDecl()->setHasExternalVisibleStorage();
 }
 
 llvm::Error ParseSource(const std::string &Path, CompilerInstance &CI,
@@ -292,6 +251,7 @@
 return std::move(CI);
   }
 }
+
 } // end namespace
 
 int main(int argc, const char **argv) {
Index: test/Import/template-specialization/test.cpp
===
--- test/Import/template-specialization/test.cpp
+++ test/Import/template-specialization/test.cpp
@@ -0,0 +1,7 @@
+// RUN: clang-import-test -import %S/Inputs/T.cpp -expression %s
+// XFAIL: *
+void expr() {
+  A::B b1;
+  A::B b2;
+  b1.f + b2.g;
+}
Index: test/Import/template-specialization/Inputs/T.cpp

[PATCH] D30435: [clang-import-test] Lookup inside entities

2017-04-03 Thread Sean Callanan via Phabricator via cfe-commits
spyffe updated this revision to Diff 93929.
spyffe added a comment.

Added the `ExternalASTMerger` implementation/interface, which I hadn't `svn 
add`ed before generating the last diff.


Repository:
  rL LLVM

https://reviews.llvm.org/D30435

Files:
  include/clang/AST/ExternalASTMerger.h
  lib/AST/CMakeLists.txt
  lib/AST/ExternalASTMerger.cpp
  test/Import/forward-declared-struct/Inputs/S1.c
  test/Import/forward-declared-struct/Inputs/S2.c
  test/Import/forward-declared-struct/test.c
  test/Import/member-in-struct/Inputs/S.c
  test/Import/member-in-struct/test.c
  test/Import/multiple-forward-declarations/Inputs/S1.c
  test/Import/multiple-forward-declarations/Inputs/S2.c
  test/Import/multiple-forward-declarations/test.c
  test/Import/overloaded-function/Inputs/F1.c
  test/Import/overloaded-function/Inputs/F2.c
  test/Import/overloaded-function/test.c
  test/Import/struct-in-namespace/Inputs/N1.cpp
  test/Import/struct-in-namespace/Inputs/N2.cpp
  test/Import/struct-in-namespace/Inputs/N3.cpp
  test/Import/struct-in-namespace/test.cpp
  test/Import/template-specialization/Inputs/T.cpp
  test/Import/template-specialization/test.cpp
  tools/clang-import-test/clang-import-test.cpp

Index: tools/clang-import-test/clang-import-test.cpp
===
--- tools/clang-import-test/clang-import-test.cpp
+++ tools/clang-import-test/clang-import-test.cpp
@@ -9,6 +9,8 @@
 
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/ASTImporter.h"
+#include "clang/AST/DeclObjC.h"
+#include "clang/AST/ExternalASTMerger.h"
 #include "clang/Basic/Builtins.h"
 #include "clang/Basic/IdentifierTable.h"
 #include "clang/Basic/SourceLocation.h"
@@ -189,61 +191,18 @@
 } // end namespace
 
 namespace {
-class TestExternalASTSource : public ExternalASTSource {
-private:
-  llvm::ArrayRef> ImportCIs;
-  std::map> ForwardImporters;
-  std::map> ReverseImporters;
-
-public:
-  TestExternalASTSource(
-  CompilerInstance &ExpressionCI,
-  llvm::ArrayRef> ImportCIs)
-  : ImportCIs(ImportCIs) {
-for (const std::unique_ptr &ImportCI : ImportCIs) {
-  ForwardImporters[ImportCI.get()] = llvm::make_unique(
-  ExpressionCI.getASTContext(), ExpressionCI.getFileManager(),
-  ImportCI->getASTContext(), ImportCI->getFileManager(),
-  /*MinimalImport=*/true);
-  ReverseImporters[ImportCI.get()] = llvm::make_unique(
-  ImportCI->getASTContext(), ImportCI->getFileManager(),
-  ExpressionCI.getASTContext(), ExpressionCI.getFileManager(),
-  /*MinimalImport=*/true);
-}
-  }
-
-  bool FindExternalVisibleDeclsByName(const DeclContext *DC,
-  DeclarationName Name) override {
-llvm::SmallVector Decls;
-
-if (isa(DC)) {
-  for (const std::unique_ptr &I : ImportCIs) {
-DeclarationName FromName = ReverseImporters[I.get()]->Import(Name);
-DeclContextLookupResult Result =
-I->getASTContext().getTranslationUnitDecl()->lookup(FromName);
-for (NamedDecl *FromD : Result) {
-  NamedDecl *D =
-  llvm::cast(ForwardImporters[I.get()]->Import(FromD));
-  Decls.push_back(D);
-}
-  }
-}
-if (Decls.empty()) {
-  return false;
-} else {
-  SetExternalVisibleDeclsForName(DC, Name, Decls);
-  return true;
-}
-  }
-};
-
+ 
 void AddExternalSource(
 CompilerInstance &CI,
 llvm::ArrayRef> Imports) {
-  ASTContext &AST = CI.getASTContext();
-  auto ES = llvm::make_unique(CI, Imports);
-  AST.setExternalSource(ES.release());
-  AST.getTranslationUnitDecl()->setHasExternalVisibleStorage();
+  ExternalASTMerger::ImporterEndpoint Target({CI.getASTContext(), CI.getFileManager()});
+  llvm::SmallVector Sources;
+  for (const std::unique_ptr &CI : Imports) {
+Sources.push_back({CI->getASTContext(), CI->getFileManager()});
+  }
+  auto ES = llvm::make_unique(Target, Sources);
+  CI.getASTContext().setExternalSource(ES.release());
+  CI.getASTContext().getTranslationUnitDecl()->setHasExternalVisibleStorage();
 }
 
 llvm::Error ParseSource(const std::string &Path, CompilerInstance &CI,
@@ -292,6 +251,7 @@
 return std::move(CI);
   }
 }
+
 } // end namespace
 
 int main(int argc, const char **argv) {
Index: test/Import/template-specialization/test.cpp
===
--- test/Import/template-specialization/test.cpp
+++ test/Import/template-specialization/test.cpp
@@ -0,0 +1,7 @@
+// RUN: clang-import-test -import %S/Inputs/T.cpp -expression %s
+// XFAIL: *
+void expr() {
+  A::B b1;
+  A::B b2;
+  b1.f + b2.g;
+}
Index: test/Import/template-specialization/Inputs/T.cpp
===
--- test/Import/template-specialization/Inputs/T.cpp
+++ test/Import/template-specialization/Inputs/T.cpp
@@ -0,0 +1,14 @@
+template  struct A {
+};
+
+template <> struct A {
+  struct B {
+int f;
+  };
+};
+
+

r299382 - Revert r299321 '[X86] Add __extension__ to f16c macro intrinsics to suppress warnings about compound literals when compiled for with earlier language standards enabled.' to see if recovers a

2017-04-03 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Mon Apr  3 14:43:47 2017
New Revision: 299382

URL: http://llvm.org/viewvc/llvm-project?rev=299382&view=rev
Log:
Revert r299321 '[X86] Add __extension__ to f16c macro intrinsics to suppress 
warnings about compound literals when compiled for with earlier language 
standards enabled.' to see if recovers a fuzzer bot.

Modified:
cfe/trunk/lib/Headers/f16cintrin.h

Modified: cfe/trunk/lib/Headers/f16cintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/f16cintrin.h?rev=299382&r1=299381&r2=299382&view=diff
==
--- cfe/trunk/lib/Headers/f16cintrin.h (original)
+++ cfe/trunk/lib/Headers/f16cintrin.h Mon Apr  3 14:43:47 2017
@@ -72,9 +72,9 @@ _cvtsh_ss(unsigned short __a)
 ///011: Truncate \n
 ///1XX: Use MXCSR.RC for rounding
 /// \returns The converted 16-bit half-precision float value.
-#define _cvtss_sh(a, imm) __extension__ ({ \
-  (unsigned short)(((__v8hi)__builtin_ia32_vcvtps2ph((__v4sf){a, 0, 0, 0}, \
- (imm)))[0]); })
+#define _cvtss_sh(a, imm)  \
+  ((unsigned short)(((__v8hi)__builtin_ia32_vcvtps2ph((__v4sf){a, 0, 0, 0}, \
+  (imm)))[0]))
 
 /// \brief Converts a 128-bit vector containing 32-bit float values into a
 ///128-bit vector containing 16-bit half-precision float values.
@@ -99,8 +99,8 @@ _cvtsh_ss(unsigned short __a)
 /// \returns A 128-bit vector containing converted 16-bit half-precision float
 ///values. The lower 64 bits are used to store the converted 16-bit
 ///half-precision floating-point values.
-#define _mm_cvtps_ph(a, imm) __extension__ ({ \
-  (__m128i)__builtin_ia32_vcvtps2ph((__v4sf)(__m128)(a), (imm)); })
+#define _mm_cvtps_ph(a, imm) \
+  ((__m128i)__builtin_ia32_vcvtps2ph((__v4sf)(__m128)(a), (imm)))
 
 /// \brief Converts a 128-bit vector containing 16-bit half-precision float
 ///values into a 128-bit vector containing 32-bit float values.


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


[PATCH] D30920: Do not pass -Os and -Oz to the Gold plugin

2017-04-03 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama added a comment.

From the discussion, it seems it is theoretically feasible to make optimization 
for speed a function-level attribute as well.  After looking at the 
PassMangerBuilder for this bug, I think that'll make the optimization passes 
cleaner by keeping the passes and their behavior at various levels in one place.

Circling back to the issue at hand, what is the best way to handle Os and Oz at 
the lto stage?  I think we left off with @mehdi_amini's comment that the driver 
should emit a warning when dropping the Os/Oz.


https://reviews.llvm.org/D30920



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


[PATCH] D31404: [OpenCL] Allow alloca return non-zero private pointer

2017-04-03 Thread Tony Tye via Phabricator via cfe-commits
t-tye accepted this revision.
t-tye added a comment.
This revision is now accepted and ready to land.

LGTM


https://reviews.llvm.org/D31404



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


[PATCH] D31440: PR32382: Adapt to LLVM changes in DIExpression.

2017-04-03 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

In https://reviews.llvm.org/D31440#713396, @aprantl wrote:

> In https://reviews.llvm.org/D31440#713308, @dblaikie wrote:
>
> > I'm a bit confused - the alloca was only emitted at -O0, by the looks of 
> > it. Presumably it's pessimizing in some way at higher optimization levels? 
> > Or is that not the case?
>
>
> I think it is really working around the odd behavior of LLVM here. What gives 
> it away is the we key the addition of the extra DW_OP_deref on whether it is 
> an alloca or not. But note that this is not how dbg.declare works: 
> dbg.declare(%alloca, !DIExpression()) is (kind of) equivalent to 
> dbg.value(%alloca, !DIExpression(DW_OP_deref)). So we are using the presence 
> of the alloca as a proxy for how the backend happens to compile the 
> DwarfExpression here and work around its idiosyncrasy by emitting an extra 
> DW_OP_deref.


I'm still not really following, sorry - perhaps it'd help me if you could 
describe the state of things in ToT currently, the state this change attempts 
to create, and the state (if distinct from the previous) that might be ideal. 
(it's not clear to me if there's still a "workaround" after your change - 
sounds like there should be/is, if previously there was no alloca above O0 but 
after this change there will be... )

> 
> 
>> Also, it looks like this change lost the "if > gmlt" test, so might cause 
>> variable declarations (& thus types) to leak into GMLT, which is undesirable.
> 
> Oh.. that was unintentional collateral damage. Thanks for noticing!




https://reviews.llvm.org/D31440



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


[PATCH] D31562: [coroutines] Fix building of new/delete expressions when get_return_object_on_allocation_failure() is present.

2017-04-03 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF updated this revision to Diff 93939.
EricWF added a comment.

- Merge with master
- Fix `coro-alloc.cpp` test so that it declares new.
- Add FIXME comment regarding assertion about an MaybeODRUsedExpr that hasn't 
been correctly handled. (the VarDecl for `std::nothrow` is broken).


https://reviews.llvm.org/D31562

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/CoroutineBuilder.h
  lib/Sema/SemaCoroutine.cpp
  test/CodeGenCoroutines/coro-alloc.cpp
  test/SemaCXX/coroutines.cpp

Index: test/SemaCXX/coroutines.cpp
===
--- test/SemaCXX/coroutines.cpp
+++ test/SemaCXX/coroutines.cpp
@@ -654,6 +654,18 @@
   co_return; //expected-note {{function is a coroutine due to use of 'co_return' here}}
 }
 
+namespace std {
+  struct nothrow_t {};
+  constexpr nothrow_t nothrow = {};
+}
+
+using SizeT = decltype(sizeof(int));
+
+void* operator new(SizeT __sz, const std::nothrow_t&) noexcept;
+void  operator delete(void* __p, const std::nothrow_t&) noexcept;
+
+
+
 struct promise_on_alloc_failure_tag {};
 
 template<>
@@ -694,3 +706,24 @@
 }
 template coro dependent_private_alloc_failure_handler(bad_promise_11);
 // expected-note@-1 {{requested here}}
+
+struct bad_promise_12 {
+  coro get_return_object();
+  suspend_always initial_suspend();
+  suspend_always final_suspend();
+  void unhandled_exception();
+  void return_void();
+  static coro get_return_object_on_allocation_failure();
+
+  static void* operator new(SizeT);
+  // expected-error@-1 2 {{'operator new' is required to have a non-throwing noexcept specification when the promise type declares 'get_return_object_on_allocation_failure()'}}
+};
+coro throwing_in_class_new() { // expected-note {{call to 'operator new' implicitly required by coroutine function here}}
+  co_return;
+}
+
+template 
+coro dependent_throwing_in_class_new(T) { // expected-note {{call to 'operator new' implicitly required by coroutine function here}}
+   co_return;
+}
+template coro dependent_throwing_in_class_new(bad_promise_12); // expected-note {{requested here}}
Index: test/CodeGenCoroutines/coro-alloc.cpp
===
--- test/CodeGenCoroutines/coro-alloc.cpp
+++ test/CodeGenCoroutines/coro-alloc.cpp
@@ -19,8 +19,19 @@
   coroutine_handle(coroutine_handle) {}
 };
 
-}
-}
+} // end namespace experimental
+
+struct nothrow_t {};
+constexpr nothrow_t nothrow = {};
+
+} // end namespace std
+
+// Required when get_return_object_on_allocation_failure() is defined by
+// the promise.
+using SizeT = decltype(sizeof(int));
+void* operator new(SizeT __sz, const std::nothrow_t&) noexcept;
+void  operator delete(void* __p, const std::nothrow_t&) noexcept;
+
 
 struct suspend_always {
   bool await_ready() { return false; }
Index: lib/Sema/SemaCoroutine.cpp
===
--- lib/Sema/SemaCoroutine.cpp
+++ lib/Sema/SemaCoroutine.cpp
@@ -454,7 +454,7 @@
  /*IsImplicit*/ true);
 Suspend = S.ActOnFinishFullExpr(Suspend.get());
 if (Suspend.isInvalid()) {
-  S.Diag(Loc, diag::note_coroutine_promise_call_implicitly_required)
+  S.Diag(Loc, diag::note_coroutine_promise_suspend_implicitly_required)
   << ((Name == "initial_suspend") ? 0 : 1);
   S.Diag(KWLoc, diag::note_declared_coroutine_here) << Keyword;
   return StmtError();
@@ -660,6 +660,39 @@
   return Res;
 }
 
+/// Look up the std::nothrow object.
+static Expr *buildStdNoThrowDeclRef(Sema &S, SourceLocation Loc) {
+  NamespaceDecl *Std = S.getStdNamespace();
+  assert(Std && "Should already be diagnosed");
+
+  LookupResult Result(S, &S.PP.getIdentifierTable().get("nothrow"), Loc,
+  Sema::LookupOrdinaryName);
+  if (!S.LookupQualifiedName(Result, Std)) {
+// FIXME:  should have been included already.
+// If we require it to include  then this diagnostic is no longer
+// needed.
+S.Diag(Loc, diag::err_implicit_coroutine_std_nothrow_type_not_found);
+return nullptr;
+  }
+
+  // FIXME: Mark the variable as ODR used. This currently does not work
+  // likely due to the scope at in which this function is called.
+  auto *VD = Result.getAsSingle();
+  if (!VD) {
+Result.suppressDiagnostics();
+// We found something weird. Complain about the first thing we found.
+NamedDecl *Found = *Result.begin();
+S.Diag(Found->getLocation(), diag::err_malformed_std_nothrow);
+return nullptr;
+  }
+
+  ExprResult DR = S.BuildDeclRefExpr(VD, VD->getType(), VK_LValue, Loc);
+  if (DR.isInvalid())
+return nullptr;
+
+  return DR.get();
+}
+
 // Find an appropriate delete for the promise.
 static FunctionDecl *findDeleteForPromise(Sema &S, SourceLocation Loc,
   QualType PromiseType) {
@@ -847,23 +880,51 @@
   if (S.RequireCompleteType(Loc, PromiseType, diag::err_incomplete_type))
 return false;
 

[PATCH] D31394: [X86][Clang] Converting __mm{|256|512}_movm_epi{8|16|32|64} LLVMIR call into generic intrinsics.

2017-04-03 Thread michael zuckerman via Phabricator via cfe-commits
m_zuckerman updated this revision to Diff 93941.

https://reviews.llvm.org/D31394

Files:
  lib/CodeGen/CGBuiltin.cpp
  test/CodeGen/avx512bw-builtins.c
  test/CodeGen/avx512dq-builtins.c
  test/CodeGen/avx512vlbw-builtins.c
  test/CodeGen/avx512vldq-builtins.c

Index: test/CodeGen/avx512vldq-builtins.c
===
--- test/CodeGen/avx512vldq-builtins.c
+++ test/CodeGen/avx512vldq-builtins.c
@@ -865,25 +865,32 @@
 
 __m128i test_mm_movm_epi32(__mmask8 __A) {
   // CHECK-LABEL: @test_mm_movm_epi32
-  // CHECK: @llvm.x86.avx512.cvtmask2d.128
+  // CHECK: %2 = bitcast i8 %1 to <8 x i1>
+  // CHECK: %extract.i = shufflevector <8 x i1> %2, <8 x i1> %2, <4 x i32> 
+  // CHECK: %vpmovm2.i = sext <4 x i1> %extract.i to <4 x i32>
   return _mm_movm_epi32(__A); 
 }
 
 __m256i test_mm256_movm_epi32(__mmask8 __A) {
   // CHECK-LABEL: @test_mm256_movm_epi32
-  // CHECK: @llvm.x86.avx512.cvtmask2d.256
+  // CHECK: %2 = bitcast i8 %1 to <8 x i1>
+  // CHECK: %vpmovm2.i = sext <8 x i1> %2 to <8 x i32>
   return _mm256_movm_epi32(__A); 
 }
 
 __m128i test_mm_movm_epi64(__mmask8 __A) {
   // CHECK-LABEL: @test_mm_movm_epi64
-  // CHECK: @llvm.x86.avx512.cvtmask2q.128
+  // CHECK: %2 = bitcast i8 %1 to <8 x i1>
+  // CHECK: %extract.i = shufflevector <8 x i1> %2, <8 x i1> %2, <2 x i32> 
+  // CHECK: %vpmovm2.i = sext <2 x i1> %extract.i to <2 x i64>
   return _mm_movm_epi64(__A); 
 }
 
 __m256i test_mm256_movm_epi64(__mmask8 __A) {
   // CHECK-LABEL: @test_mm256_movm_epi64
-  // CHECK: @llvm.x86.avx512.cvtmask2q.256
+  // CHECK: %2 = bitcast i8 %1 to <8 x i1>
+  // CHECK: %extract.i = shufflevector <8 x i1> %2, <8 x i1> %2, <4 x i32> 
+  // CHECK: %vpmovm2.i = sext <4 x i1> %extract.i to <4 x i64>
   return _mm256_movm_epi64(__A); 
 }
 
Index: test/CodeGen/avx512vlbw-builtins.c
===
--- test/CodeGen/avx512vlbw-builtins.c
+++ test/CodeGen/avx512vlbw-builtins.c
@@ -2521,25 +2521,29 @@
 
 __m128i test_mm_movm_epi8(__mmask16 __A) {
   // CHECK-LABEL: @test_mm_movm_epi8
-  // CHECK: @llvm.x86.avx512.cvtmask2b.128
+  // CHECK: %2 = bitcast i16 %1 to <16 x i1>
+  // CHECK: %vpmovm2.i = sext <16 x i1> %2 to <16 x i8>
   return _mm_movm_epi8(__A); 
 }
 
 __m256i test_mm256_movm_epi8(__mmask32 __A) {
   // CHECK-LABEL: @test_mm256_movm_epi8
-  // CHECK: @llvm.x86.avx512.cvtmask2b.256
+  // CHECK: %2 = bitcast i32 %1 to <32 x i1>
+  // CHECK: %vpmovm2.i = sext <32 x i1> %2 to <32 x i8>
   return _mm256_movm_epi8(__A); 
 }
 
 __m128i test_mm_movm_epi16(__mmask8 __A) {
   // CHECK-LABEL: @test_mm_movm_epi16
-  // CHECK: @llvm.x86.avx512.cvtmask2w.128
+  // CHECK: %2 = bitcast i8 %1 to <8 x i1>
+  // CHECK: %vpmovm2.i = sext <8 x i1> %2 to <8 x i16>
   return _mm_movm_epi16(__A); 
 }
 
 __m256i test_mm256_movm_epi16(__mmask16 __A) {
   // CHECK-LABEL: @test_mm256_movm_epi16
-  // CHECK: @llvm.x86.avx512.cvtmask2w.256
+  // CHECK: %2 = bitcast i16 %1 to <16 x i1>
+  // CHECK: %vpmovm2.i = sext <16 x i1> %2 to <16 x i16>
   return _mm256_movm_epi16(__A); 
 }
 
Index: test/CodeGen/avx512dq-builtins.c
===
--- test/CodeGen/avx512dq-builtins.c
+++ test/CodeGen/avx512dq-builtins.c
@@ -929,13 +929,15 @@
 
 __m512i test_mm512_movm_epi32(__mmask16 __A) {
   // CHECK-LABEL: @test_mm512_movm_epi32
-  // CHECK: @llvm.x86.avx512.cvtmask2d.512
+  // CHECK: %2 = bitcast i16 %1 to <16 x i1>
+  // CHECK: %vpmovm2.i = sext <16 x i1> %2 to <16 x i32>
   return _mm512_movm_epi32(__A); 
 }
 
 __m512i test_mm512_movm_epi64(__mmask8 __A) {
   // CHECK-LABEL: @test_mm512_movm_epi64
-  // CHECK: @llvm.x86.avx512.cvtmask2q.512
+  // CHECK: %2 = bitcast i8 %1 to <8 x i1>
+  // CHECK: %vpmovm2.i = sext <8 x i1> %2 to <8 x i64>
   return _mm512_movm_epi64(__A); 
 }
 
Index: test/CodeGen/avx512bw-builtins.c
===
--- test/CodeGen/avx512bw-builtins.c
+++ test/CodeGen/avx512bw-builtins.c
@@ -1543,13 +1543,15 @@
 
 __m512i test_mm512_movm_epi8(__mmask64 __A) {
   // CHECK-LABEL: @test_mm512_movm_epi8
-  // CHECK: @llvm.x86.avx512.cvtmask2b.512
+  // CHECK:  %2 = bitcast i64 %1 to <64 x i1>
+  // CHECK:  %vpmovm2.i = sext <64 x i1> %2 to <64 x i8>
   return _mm512_movm_epi8(__A); 
 }
 
 __m512i test_mm512_movm_epi16(__mmask32 __A) {
   // CHECK-LABEL: @test_mm512_movm_epi16
-  // CHECK: @llvm.x86.avx512.cvtmask2w.512
+  // CHECK:  %2 = bitcast i32 %1 to <32 x i1>
+  // CHECK:  %vpmovm2.i = sext <32 x i1> %2 to <32 x i16>
   return _mm512_movm_epi16(__A); 
 }
 
Index: lib/CodeGen/CGBuiltin.cpp
===
--- lib/CodeGen/CGBuiltin.cpp
+++ lib/CodeGen/CGBuiltin.cpp
@@ -7168,6 +7168,13 @@
   return EmitX86Select(CGF, Ops[3], Res, Ops[2]);
 }
 
+static Value *EmitX86SExtMask(CodeGenFunction &CGF, Value *Op, 
+  llvm::Type *DstTy) {
+  unsigned NumberOfEl

[PATCH] D31394: [X86][Clang] Converting __mm{|256|512}_movm_epi{8|16|32|64} LLVMIR call into generic intrinsics.

2017-04-03 Thread Craig Topper via Phabricator via cfe-commits
craig.topper accepted this revision.
craig.topper added a comment.
This revision is now accepted and ready to land.

LGTM


https://reviews.llvm.org/D31394



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


[libcxx] r299385 - suppress GCC warning about noexcept functions changing mangling

2017-04-03 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Mon Apr  3 15:53:15 2017
New Revision: 299385

URL: http://llvm.org/viewvc/llvm-project?rev=299385&view=rev
Log:
suppress GCC warning about noexcept functions changing mangling

Modified:
libcxx/trunk/CMakeLists.txt
libcxx/trunk/utils/libcxx/test/config.py

Modified: libcxx/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/CMakeLists.txt?rev=299385&r1=299384&r2=299385&view=diff
==
--- libcxx/trunk/CMakeLists.txt (original)
+++ libcxx/trunk/CMakeLists.txt Mon Apr  3 15:53:15 2017
@@ -466,7 +466,8 @@ if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "
 elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU")
 add_compile_flags_if_supported(
 -Wno-literal-suffix
--Wno-c++14-compat)
+-Wno-c++14-compat
+-Wno-noexcept-type)
 endif()
 if (LIBCXX_ENABLE_WERROR)
   add_compile_flags_if_supported(-Werror)

Modified: libcxx/trunk/utils/libcxx/test/config.py
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/utils/libcxx/test/config.py?rev=299385&r1=299384&r2=299385&view=diff
==
--- libcxx/trunk/utils/libcxx/test/config.py (original)
+++ libcxx/trunk/utils/libcxx/test/config.py Mon Apr  3 15:53:15 2017
@@ -813,6 +813,7 @@ class Configuration(object):
 self.cxx.addWarningFlagIfSupported('-Wno-pessimizing-move')
 self.cxx.addWarningFlagIfSupported('-Wno-c++11-extensions')
 self.cxx.addWarningFlagIfSupported('-Wno-user-defined-literals')
+self.cxx.addWarningFlagIfSupported('-Wno-noexcept-type')
 # These warnings should be enabled in order to support the MSVC
 # team using the test suite; They enable the warnings below and
 # expect the test suite to be clean.


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


[PATCH] D31627: [coroutines] Skip over passthrough operator co_await

2017-04-03 Thread Gor Nishanov via Phabricator via cfe-commits
GorNishanov created this revision.

https://reviews.llvm.org/D31627

Files:
  lib/CodeGen/CGCoroutine.cpp
  test/CodeGenCoroutines/coro-await.cpp


Index: test/CodeGenCoroutines/coro-await.cpp
===
--- test/CodeGenCoroutines/coro-await.cpp
+++ test/CodeGenCoroutines/coro-await.cpp
@@ -228,3 +228,9 @@
   // CHECK: call void @_ZN5MyAggawEv(%struct.MyAgg* %
   // CHECK: call void @_ZN11AggrAwaiter12await_resumeEv(%struct.Aggr* sret %
 }
+
+// Verifies that we don't crash when awaiting on an lvalue.
+void AwaitLValue() {
+  suspend_always lval;
+  co_await lval;
+}
Index: lib/CodeGen/CGCoroutine.cpp
===
--- lib/CodeGen/CGCoroutine.cpp
+++ lib/CodeGen/CGCoroutine.cpp
@@ -142,6 +142,12 @@
 AwaitKind Kind, AggValueSlot aggSlot,
 bool ignoreResult) {
   auto *E = S.getCommonExpr();
+
+  // Skip paththrough operator co_await (present when awaiting on an LValue).
+  if (auto *UO = dyn_cast(E))
+  if (UO->getOpcode() == UO_Coawait)
+E = UO->getSubExpr();
+
   auto Binder =
   CodeGenFunction::OpaqueValueMappingData::bind(CGF, S.getOpaqueValue(), 
E);
   auto UnbindOnExit = llvm::make_scope_exit([&] { Binder.unbind(CGF); });


Index: test/CodeGenCoroutines/coro-await.cpp
===
--- test/CodeGenCoroutines/coro-await.cpp
+++ test/CodeGenCoroutines/coro-await.cpp
@@ -228,3 +228,9 @@
   // CHECK: call void @_ZN5MyAggawEv(%struct.MyAgg* %
   // CHECK: call void @_ZN11AggrAwaiter12await_resumeEv(%struct.Aggr* sret %
 }
+
+// Verifies that we don't crash when awaiting on an lvalue.
+void AwaitLValue() {
+  suspend_always lval;
+  co_await lval;
+}
Index: lib/CodeGen/CGCoroutine.cpp
===
--- lib/CodeGen/CGCoroutine.cpp
+++ lib/CodeGen/CGCoroutine.cpp
@@ -142,6 +142,12 @@
 AwaitKind Kind, AggValueSlot aggSlot,
 bool ignoreResult) {
   auto *E = S.getCommonExpr();
+
+  // Skip paththrough operator co_await (present when awaiting on an LValue).
+  if (auto *UO = dyn_cast(E))
+  if (UO->getOpcode() == UO_Coawait)
+E = UO->getSubExpr();
+
   auto Binder =
   CodeGenFunction::OpaqueValueMappingData::bind(CGF, S.getOpaqueValue(), E);
   auto UnbindOnExit = llvm::make_scope_exit([&] { Binder.unbind(CGF); });
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D31562: [coroutines] Fix building of new/delete expressions when get_return_object_on_allocation_failure() is present.

2017-04-03 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF planned changes to this revision.
EricWF added a comment.

This patch currently triggers an assertion in `SemaDecl.cpp:12290`  
`assert(MaybeODRUseExprs.empty() && "Leftover expressions for odr-use 
checking");`

I'll have to come up with a fix for that before this is committed. 
Unfortunately the easy fix of calling `MakeVarDeclReferenced` or similar 
doesn't work. I suspect this is due to the current active scope when 
`ActOnFinishFunctionBody` is called.


https://reviews.llvm.org/D31562



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


[PATCH] D31394: [X86][Clang] Converting __mm{|256|512}_movm_epi{8|16|32|64} LLVMIR call into generic intrinsics.

2017-04-03 Thread michael zuckerman via Phabricator via cfe-commits
m_zuckerman added a comment.

Thanks :)


https://reviews.llvm.org/D31394



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


r299386 - Revert r299355 "[ASTImporter] Fix for importing unnamed structs"

2017-04-03 Thread Gabor Horvath via cfe-commits
Author: xazax
Date: Mon Apr  3 16:06:45 2017
New Revision: 299386

URL: http://llvm.org/viewvc/llvm-project?rev=299386&view=rev
Log:
Revert r299355 "[ASTImporter] Fix for importing unnamed structs"

It breaks windows bots. 

Modified:
cfe/trunk/lib/AST/ASTImporter.cpp
cfe/trunk/test/ASTMerge/struct/Inputs/struct1.c
cfe/trunk/test/ASTMerge/struct/Inputs/struct2.c
cfe/trunk/test/ASTMerge/struct/test.c

Modified: cfe/trunk/lib/AST/ASTImporter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTImporter.cpp?rev=299386&r1=299385&r2=299386&view=diff
==
--- cfe/trunk/lib/AST/ASTImporter.cpp (original)
+++ cfe/trunk/lib/AST/ASTImporter.cpp Mon Apr  3 16:06:45 2017
@@ -1221,10 +1221,6 @@ static Optional findUntaggedSt
 // If the field looks like this:
 // struct { ... } A;
 QualType FieldType = F->getType();
-// In case of nested structs.
-while (const auto *ElabType = dyn_cast(FieldType)) {
-  FieldType = ElabType->getNamedType();
-}
 if (const auto *RecType = dyn_cast(FieldType)) {
   const RecordDecl *RecDecl = RecType->getDecl();
   if (RecDecl->getDeclContext() == Owner &&
@@ -3024,8 +3020,9 @@ Decl *ASTNodeImporter::VisitRecordDecl(R
   }
   
   if (RecordDecl *FoundRecord = dyn_cast(Found)) {
-if (!SearchName) {
-  // If both unnamed structs/unions are in a record context, make sure
+if (D->isAnonymousStructOrUnion() && 
+FoundRecord->isAnonymousStructOrUnion()) {
+  // If both anonymous structs/unions are in a record context, make 
sure
   // they occur in the same location in the context records.
   if (Optional Index1
   = findUntaggedStructOrUnionIndex(D)) {

Modified: cfe/trunk/test/ASTMerge/struct/Inputs/struct1.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ASTMerge/struct/Inputs/struct1.c?rev=299386&r1=299385&r2=299386&view=diff
==
--- cfe/trunk/test/ASTMerge/struct/Inputs/struct1.c (original)
+++ cfe/trunk/test/ASTMerge/struct/Inputs/struct1.c Mon Apr  3 16:06:45 2017
@@ -77,65 +77,3 @@ typedef struct {
 } S13;
 
 S13 x13;
-
-// Matches
-struct Unnamed {
-  union {
-struct {
-  int i;
-} S;
-struct {
-  float i;
-} R;
-  } U;
-} x14;
-
-// Matches
-struct DeepUnnamed {
-  union {
-union {
-  struct {
-long i;
-  } S;
-  struct {
-int i;
-  } R;
-} U1;
-union {
-  struct {
-long i;
-  } S;
-  struct {
-float i;
-  } T;
-} U2;
-  } U;
-  struct {
-long i;
-  } V;
-} x15;
-
-// Mismatch due to unnamed struct used internally
-struct DeepUnnamedError {
-  union {
-union {
-  struct {
-long i;
-  } S;
-  struct {
-int i;
-  } R;
-} U1;
-union {
-  struct {
-long i; // Mismatch here.
-  } S;
-  struct {
-float i;
-  } T;
-} U2;
-  } U;
-  struct {
-long i;
-  } V;
-} x16;

Modified: cfe/trunk/test/ASTMerge/struct/Inputs/struct2.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ASTMerge/struct/Inputs/struct2.c?rev=299386&r1=299385&r2=299386&view=diff
==
--- cfe/trunk/test/ASTMerge/struct/Inputs/struct2.c (original)
+++ cfe/trunk/test/ASTMerge/struct/Inputs/struct2.c Mon Apr  3 16:06:45 2017
@@ -74,65 +74,3 @@ typedef struct {
 } S13;
 
 S13 x13;
-
-// Matches
-struct Unnamed {
-  union {
-struct {
-  int i;
-} S;
-struct {
-  float i;
-} R;
-  } U;
-} x14;
-
-// Matches
-struct DeepUnnamed {
-  union {
-union {
-  struct {
-long i;
-  } S;
-  struct {
-int i;
-  } R;
-} U1;
-union {
-  struct {
-long i;
-  } S;
-  struct {
-float i;
-  } T;
-} U2;
-  } U;
-  struct {
-long i;
-  } V;
-} x15;
-
-// Mismatch due to unnamed struct used internally
-struct DeepUnnamedError {
-  union {
-union {
-  struct {
-long i;
-  } S;
-  struct {
-int i;
-  } R;
-} U1;
-union {
-  struct {
-float i; // Mismatch here.
-  } S;
-  struct {
-float i;
-  } T;
-} U2;
-  } U;
-  struct {
-long i;
-  } V;
-} x16;

Modified: cfe/trunk/test/ASTMerge/struct/test.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ASTMerge/struct/test.c?rev=299386&r1=299385&r2=299386&view=diff
==
--- cfe/trunk/test/ASTMerge/struct/test.c (original)
+++ cfe/trunk/test/ASTMerge/struct/test.c Mon Apr  3 16:06:45 2017
@@ -44,12 +44,4 @@
 // CHECK: struct2.c:72:7: note: field 'i' has type 'int' here
 // CHECK: struct2.c:76:5: error: external variable 'x13' declared with 
incompatible types in different 

RE: r299355 - [ASTImporter] Fix for importing unnamed structs

2017-04-03 Thread Yung, Douglas via cfe-commits
Hi Peter and Gabor,

This change is causing a failure of the test "Clang :: ASTMerge/struct/test.c" 
on the PS4 Windows bot:

http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/7609

FAIL: Clang :: ASTMerge/struct/test.c (18568 of 32374)
 TEST 'Clang :: ASTMerge/struct/test.c' FAILED 

Script:
--
C:/Buildbot/Slave/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/llvm.obj/./bin/clang.EXE
 -cc1 -internal-isystem 
C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.obj\lib\clang\5.0.0\include
 -nostdsysteminc -emit-pch -o 
C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.obj\tools\clang\test\ASTMerge\struct\Output\test.c.tmp.1.ast
 
C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\tools\clang\test\ASTMerge\struct/Inputs/struct1.c
C:/Buildbot/Slave/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/llvm.obj/./bin/clang.EXE
 -cc1 -internal-isystem 
C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.obj\lib\clang\5.0.0\include
 -nostdsysteminc -emit-pch -o 
C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.obj\tools\clang\test\ASTMerge\struct\Output\test.c.tmp.2.ast
 
C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\tools\clang\test\ASTMerge\struct/Inputs/struct2.c
not 
C:/Buildbot/Slave/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/llvm.obj/./bin/clang.EXE
 -cc1 -internal-isystem 
C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.obj\lib\clang\5.0.0\include
 -nostdsysteminc -ast-merge 
C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.obj\tools\clang\test\ASTMerge\struct\Output\test.c.tmp.1.ast
 -ast-merge 
C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.obj\tools\clang\test\ASTMerge\struct\Output\test.c.tmp.2.ast
 -fsyntax-only 
C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\tools\clang\test\ASTMerge\struct\test.c
 2>&1 | 
C:/Buildbot/Slave/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/llvm.obj/./bin\FileCheck.EXE
 
C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\tools\clang\test\ASTMerge\struct\test.c
--
Exit Code: 1

Command Output (stdout):
--
$ 
"C:/Buildbot/Slave/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/llvm.obj/./bin/clang.EXE"
 "-cc1" "-internal-isystem" 
"C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.obj\lib\clang\5.0.0\include"
 "-nostdsysteminc" "-emit-pch" "-o" 
"C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.obj\tools\clang\test\ASTMerge\struct\Output\test.c.tmp.1.ast"
 
"C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\tools\clang\test\ASTMerge\struct/Inputs/struct1.c"
$ 
"C:/Buildbot/Slave/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/llvm.obj/./bin/clang.EXE"
 "-cc1" "-internal-isystem" 
"C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.obj\lib\clang\5.0.0\include"
 "-nostdsysteminc" "-emit-pch" "-o" 
"C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.obj\tools\clang\test\ASTMerge\struct\Output\test.c.tmp.2.ast"
 
"C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\tools\clang\test\ASTMerge\struct/Inputs/struct2.c"
$ "not" 
"C:/Buildbot/Slave/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/llvm.obj/./bin/clang.EXE"
 "-cc1" "-internal-isystem" 
"C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.obj\lib\clang\5.0.0\include"
 "-nostdsysteminc" "-ast-merge" 
"C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.obj\tools\clang\test\ASTMerge\struct\Output\test.c.tmp.1.ast"
 "-ast-merge" 
"C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.obj\tools\clang\test\ASTMerge\struct\Output\test.c.tmp.2.ast"
 "-fsyntax-only" 
"C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\tools\clang\test\ASTMerge\struct\test.c"
$ 
"C:/Buildbot/Slave/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/llvm.obj/./bin\FileCheck.EXE"
 
"C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\tools\clang\test\ASTMerge\struct\test.c"
# command stderr:
C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\tools\clang\test\ASTMerge\struct\test.c:47:11:
 error: expected string not found in input

// CHECK: struct1.c:130:7: warning: type 'struct DeepUnnamedError::(anonymous 
at [[PATH_TO_INPUTS:.+]]/struct1.c:130:7)' has incompatible definitions in 
different translation units

  ^

:125:1: note: scanning from here

S13 x13;

^


error: command failed with exit status: 1

--



Can you investigate?

Douglas Yung

> -Original Message-
> From: cfe-commits [mailto:cfe-commits-boun...@lists.llvm.org] On Behalf Of
> Gabor Horvath via cfe-commits
> Sent: Monday, April 03, 2017 4

[PATCH] D31447: [Driver] Add option to print the resource directory

2017-04-03 Thread Chris Bieneman via Phabricator via cfe-commits
beanz accepted this revision.
beanz added a comment.
This revision is now accepted and ready to land.

One minor nitpick on the test case, but otherwise this looks fine to me.




Comment at: test/Driver/immediate-options.c:19
+// RUN: %clang -print-resource-dir | FileCheck %s 
-check-prefix=PRINT-RESOURCE-DIR
+// PRINT-RESOURCE-DIR: {{.*}}
+

This should probably be matching `+` instead of `*`. As written this would 
succeed even if the output was empty.


https://reviews.llvm.org/D31447



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


Re: [libcxx] r299385 - suppress GCC warning about noexcept functions changing mangling

2017-04-03 Thread Richard Smith via cfe-commits
On 3 April 2017 at 13:53, Eric Fiselier via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: ericwf
> Date: Mon Apr  3 15:53:15 2017
> New Revision: 299385
>
> URL: http://llvm.org/viewvc/llvm-project?rev=299385&view=rev
> Log:
> suppress GCC warning about noexcept functions changing mangling
>

Clang also has such a warning; can you give an example of a case that GCC
warns on and Clang does not?

Modified:
> libcxx/trunk/CMakeLists.txt
> libcxx/trunk/utils/libcxx/test/config.py
>
> Modified: libcxx/trunk/CMakeLists.txt
> URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/
> CMakeLists.txt?rev=299385&r1=299384&r2=299385&view=diff
> 
> ==
> --- libcxx/trunk/CMakeLists.txt (original)
> +++ libcxx/trunk/CMakeLists.txt Mon Apr  3 15:53:15 2017
> @@ -466,7 +466,8 @@ if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "
>  elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU")
>  add_compile_flags_if_supported(
>  -Wno-literal-suffix
> --Wno-c++14-compat)
> +-Wno-c++14-compat
> +-Wno-noexcept-type)
>  endif()
>  if (LIBCXX_ENABLE_WERROR)
>add_compile_flags_if_supported(-Werror)
>
> Modified: libcxx/trunk/utils/libcxx/test/config.py
> URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/utils/
> libcxx/test/config.py?rev=299385&r1=299384&r2=299385&view=diff
> 
> ==
> --- libcxx/trunk/utils/libcxx/test/config.py (original)
> +++ libcxx/trunk/utils/libcxx/test/config.py Mon Apr  3 15:53:15 2017
> @@ -813,6 +813,7 @@ class Configuration(object):
>  self.cxx.addWarningFlagIfSupported('-Wno-pessimizing-move')
>  self.cxx.addWarningFlagIfSupported('-Wno-c++11-extensions')
>  self.cxx.addWarningFlagIfSupported('-Wno-user-defined-literals')
> +self.cxx.addWarningFlagIfSupported('-Wno-noexcept-type')
>  # These warnings should be enabled in order to support the MSVC
>  # team using the test suite; They enable the warnings below and
>  # expect the test suite to be clean.
>
>
> ___
> 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


r299397 - Recommit r299321 '[X86] Add __extension__ to f16c macro intrinsics to suppress warnings about compound literals when compiled for with earlier language standards enabled.'

2017-04-03 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Mon Apr  3 17:59:30 2017
New Revision: 299397

URL: http://llvm.org/viewvc/llvm-project?rev=299397&view=rev
Log:
Recommit r299321 '[X86] Add __extension__ to f16c macro intrinsics to suppress 
warnings about compound literals when compiled for with earlier language 
standards enabled.'

The bot didn't recover after the revert. So it looks like this wasn't the issue.

Modified:
cfe/trunk/lib/Headers/f16cintrin.h

Modified: cfe/trunk/lib/Headers/f16cintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/f16cintrin.h?rev=299397&r1=299396&r2=299397&view=diff
==
--- cfe/trunk/lib/Headers/f16cintrin.h (original)
+++ cfe/trunk/lib/Headers/f16cintrin.h Mon Apr  3 17:59:30 2017
@@ -72,9 +72,9 @@ _cvtsh_ss(unsigned short __a)
 ///011: Truncate \n
 ///1XX: Use MXCSR.RC for rounding
 /// \returns The converted 16-bit half-precision float value.
-#define _cvtss_sh(a, imm)  \
-  ((unsigned short)(((__v8hi)__builtin_ia32_vcvtps2ph((__v4sf){a, 0, 0, 0}, \
-  (imm)))[0]))
+#define _cvtss_sh(a, imm) __extension__ ({ \
+  (unsigned short)(((__v8hi)__builtin_ia32_vcvtps2ph((__v4sf){a, 0, 0, 0}, \
+ (imm)))[0]); })
 
 /// \brief Converts a 128-bit vector containing 32-bit float values into a
 ///128-bit vector containing 16-bit half-precision float values.
@@ -99,8 +99,8 @@ _cvtsh_ss(unsigned short __a)
 /// \returns A 128-bit vector containing converted 16-bit half-precision float
 ///values. The lower 64 bits are used to store the converted 16-bit
 ///half-precision floating-point values.
-#define _mm_cvtps_ph(a, imm) \
-  ((__m128i)__builtin_ia32_vcvtps2ph((__v4sf)(__m128)(a), (imm)))
+#define _mm_cvtps_ph(a, imm) __extension__ ({ \
+  (__m128i)__builtin_ia32_vcvtps2ph((__v4sf)(__m128)(a), (imm)); })
 
 /// \brief Converts a 128-bit vector containing 16-bit half-precision float
 ///values into a 128-bit vector containing 32-bit float values.


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


Re: [libcxx] r299385 - suppress GCC warning about noexcept functions changing mangling

2017-04-03 Thread Eric Fiselier via cfe-commits
I'll create a reduced reproducer, but it'll take some time because GCC is
quite cryptic about the instantiation stack.

if you want many instances within the libc++ build simply revert this
commit and build with a new GCC.

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


[PATCH] D31276: Add #pragma clang fp

2017-04-03 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

This continues to look good to me with the new name.


https://reviews.llvm.org/D31276



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


Re: [libcxx] r299385 - suppress GCC warning about noexcept functions changing mangling

2017-04-03 Thread Eric Fiselier via cfe-commits
Here is a reduced version.

void glibc_function() throw() {}

template  struct Test {
  Test() {} // expected-error {{mangled name for 'Test::Test()' will
change in C++17}}
  ~Test() {}  // expected-error {{mangled name for 'Test::~Test()' will
change in C++17}}
};

Test t;

/Eric

On Mon, Apr 3, 2017 at 5:17 PM, Eric Fiselier  wrote:

> I'll create a reduced reproducer, but it'll take some time because GCC is
> quite cryptic about the instantiation stack.
>
> if you want many instances within the libc++ build simply revert this
> commit and build with a new GCC.
>
> /Eric
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r299401 - Fix C++17 dylib build

2017-04-03 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Mon Apr  3 18:23:44 2017
New Revision: 299401

URL: http://llvm.org/viewvc/llvm-project?rev=299401&view=rev
Log:
Fix C++17 dylib build

Modified:
libcxx/trunk/include/algorithm

Modified: libcxx/trunk/include/algorithm
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/algorithm?rev=299401&r1=299400&r2=299401&view=diff
==
--- libcxx/trunk/include/algorithm (original)
+++ libcxx/trunk/include/algorithm Mon Apr  3 18:23:44 2017
@@ -3026,7 +3026,8 @@ uniform_int_distribution<_IntType>::oper
 return static_cast(__u + __p.a());
 }
 
-#if _LIBCPP_STD_VER <= 14 || 
defined(_LIBCPP_ENABLE_CXX17_REMOVED_RANDOM_SHUFFLE)
+#if _LIBCPP_STD_VER <= 14 || 
defined(_LIBCPP_ENABLE_CXX17_REMOVED_RANDOM_SHUFFLE) \
+  || defined(_LIBCPP_BUILDING_LIBRARY)
 class _LIBCPP_TYPE_VIS __rs_default;
 
 _LIBCPP_FUNC_VIS __rs_default __rs_get();


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


[PATCH] D28952: [analyzer] Add new Z3 constraint manager backend

2017-04-03 Thread Dominic Chen via Phabricator via cfe-commits
ddcc updated this revision to Diff 93974.
ddcc added a comment.

Fix support for 128-bit APInt creation, drop pkg-config from CMake module


https://reviews.llvm.org/D28952

Files:
  CMakeLists.txt
  cmake/modules/FindZ3.cmake
  include/clang/Config/config.h.cmake
  include/clang/StaticAnalyzer/Core/Analyses.def
  include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h
  lib/StaticAnalyzer/Core/CMakeLists.txt
  lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp
  test/Analysis/expr-inspection.c
  test/Analysis/lit.local.cfg
  test/Analysis/unsupported-types.c
  test/lit.cfg
  test/lit.site.cfg.in

Index: test/lit.site.cfg.in
===
--- test/lit.site.cfg.in
+++ test/lit.site.cfg.in
@@ -18,6 +18,7 @@
 config.clang_arcmt = @CLANG_ENABLE_ARCMT@
 config.clang_default_cxx_stdlib = "@CLANG_DEFAULT_CXX_STDLIB@"
 config.clang_staticanalyzer = @CLANG_ENABLE_STATIC_ANALYZER@
+config.clang_staticanalyzer_z3 = "@CLANG_ANALYZER_WITH_Z3@"
 config.clang_examples = @CLANG_BUILD_EXAMPLES@
 config.enable_shared = @ENABLE_SHARED@
 config.enable_backtrace = @ENABLE_BACKTRACES@
Index: test/lit.cfg
===
--- test/lit.cfg
+++ test/lit.cfg
@@ -361,6 +361,9 @@
 if config.clang_staticanalyzer:
 config.available_features.add("staticanalyzer")
 
+if config.clang_staticanalyzer_z3 == '1':
+config.available_features.add("z3")
+
 # As of 2011.08, crash-recovery tests still do not pass on FreeBSD.
 if platform.system() not in ['FreeBSD']:
 config.available_features.add('crash-recovery')
Index: test/Analysis/unsupported-types.c
===
--- /dev/null
+++ test/Analysis/unsupported-types.c
@@ -0,0 +1,31 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -triple x86_64-unknown-linux -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -triple powerpc64-linux-gnu -verify %s
+
+#define _Complex_I  (__extension__ 1.0iF)
+
+void clang_analyzer_eval(int);
+
+void complex_float(double _Complex x, double _Complex y) {
+  clang_analyzer_eval(x == y); // expected-warning{{UNKNOWN}}
+  if (x != 1.0 + 3.0 * _Complex_I && y != 1.0 - 4.0 * _Complex_I)
+return
+  clang_analyzer_eval(x == y); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(x + y == 2.0 - 1.0 * _Complex_I); // expected-warning{{UNKNOWN}}
+}
+
+void complex_int(int _Complex x, int _Complex y) {
+  clang_analyzer_eval(x == y); // expected-warning{{UNKNOWN}}
+  if (x != 1.0 + 3.0 * _Complex_I && y != 1.0 - 4.0 * _Complex_I)
+return
+  clang_analyzer_eval(x == y); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(x + y == 2.0 - 1.0 * _Complex_I); // expected-warning{{UNKNOWN}}
+}
+
+void longdouble_float(long double x, long double y) {
+  clang_analyzer_eval(x == y); // expected-warning{{UNKNOWN}}
+  if (x != 0.0L && y != 1.0L)
+return
+  clang_analyzer_eval(x == y); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(x + y == 1.0L); // expected-warning{{UNKNOWN}}
+}
Index: test/Analysis/lit.local.cfg
===
--- test/Analysis/lit.local.cfg
+++ test/Analysis/lit.local.cfg
@@ -10,6 +10,10 @@
 if result.code == lit.Test.FAIL:
 return result
 
+# If z3 backend available, add an additional run line for it
+if test.config.clang_staticanalyzer_z3 == '1':
+result = self.executeWithAnalyzeSubstitution(test, litConfig, '-analyzer-constraints=z3 -DANALYZER_CM_Z3')
+
 return result
 
 def executeWithAnalyzeSubstitution(self, test, litConfig, substitution):
Index: test/Analysis/expr-inspection.c
===
--- test/Analysis/expr-inspection.c
+++ test/Analysis/expr-inspection.c
@@ -19,4 +19,4 @@
 
 // CHECK: Expressions:
 // CHECK-NEXT: clang_analyzer_printState : &code{clang_analyzer_printState}
-// CHECK-NEXT: Ranges are empty.
+// CHECK-NEXT: {{(Ranges are empty.)|(Constraints:[[:space:]]*$)}}
Index: lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp
===
--- /dev/null
+++ lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp
@@ -0,0 +1,1618 @@
+//== Z3ConstraintManager.cpp *- C++ -*--==//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "clang/Basic/TargetInfo.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/SimpleCon

[PATCH] D24892: [clang-tidy] Add option "LiteralInitializers" to cppcoreguidelines-pro-type-member-init

2017-04-03 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp:348
 
+static const char *getInitializer(QualType type, bool LiteralInitializers) {
+  const char *DefaultInitializer = "{}";

`type` doesn't follow our usual naming conventions. I would recommend `QT`.



Comment at: clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp:357
+  const BuiltinType *BT =
+  dyn_cast(type->getCanonicalTypeInternal());
+  if (!BT)

You shouldn't be calling an "internal" function here. Instead, you can do 
`dyn_cast(type.getCanonicalType().getTypePtr())`



Comment at: clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp:369
+  case BuiltinType::LongDouble:
+return " = 0.0l";
+  case BuiltinType::SChar:

Some users care deeply about `l` vs `L` because of how hard it is to 
distinguish depending on code fonts. I don't know that we need an option for 
that sort of thing, but my personal preference is to use capital letters rather 
than lowercase ones. (I originally read this as initializing to 0.01, FWIW).



Comment at: 
test/clang-tidy/cppcoreguidelines-pro-type-member-init-literal-initializers.cpp:1
+// RUN: %check_clang_tidy %s cppcoreguidelines-pro-type-member-init %t -- 
-config="{CheckOptions: [{key: 
"cppcoreguidelines-pro-type-member-init.LiteralInitializers", value: 1}]}" -- 
-std=c++11
+

mgehre wrote:
> hokein wrote:
> > `-std=c++11` is not needed. This extra compile argument is added by default 
> > when running check_clang_tidy.
> If I remove ``-std=c++11``, the behavior changes and 
> Context.getLangOpts().CPlusPlus11 is false.
That's because the extra args you specify disable the c++11 specification, so 
this is correct to do.


https://reviews.llvm.org/D24892



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


[PATCH] D31308: [clang-tidy] new check readability-no-alternative-tokens

2017-04-03 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang-tidy/readability/OperatorsRepresentationCheck.cpp:34
+
+  if (const auto *B = Result.Nodes.getNodeAs("binary")) {
+switch (B->getOpcode()) {

alexfh wrote:
> aaron.ballman wrote:
> > mgehre wrote:
> > > aaron.ballman wrote:
> > > > alexfh wrote:
> > > > > aaron.ballman wrote:
> > > > > > I think this would make more sense lifted into an AST matcher -- 
> > > > > > there are bound to be a *lot* of binary operators, so letting the 
> > > > > > matcher memoize things is likely to give better performance.
> > > > > Any reasons not to do this on the lexer level?
> > > > Technical reasons? None.
> > > > User-experience reasons? We wouldn't want this to be on by default (I 
> > > > don't think) and we usually don't implement off-by-default diagnostics 
> > > > in Clang. I think a case could be made for doing it in the Lexer if the 
> > > > performance is really that bad with a clang-tidy check and we couldn't 
> > > > improve it here, though.
> > > Do I correctly understand that "doing this on lexer level" would mean to 
> > > implement this as a warning directly into clang? If yes, would it be 
> > > possible to generate fixits and have them possibly applied automatically 
> > > (as it is the case for clang-tidy)?
> > You are correct, that means implementing it as a warning in Clang. I 
> > believe you can still generate those fixits from lexer-level diagnostics, 
> > but have not verified it.
> > 
> > However, I don't think this diagnostic would be appropriate for Clang 
> > because it would have to be off by default.
> Actually, I was thinking about changing this clang-tidy check to analyze 
> token stream somehow (probably by handling `PPCallbacks` to detect ranges 
> that need to be re-lexed) instead of matching the AST. I didn't intend to 
> propose a new Clang warning (but it looks like the wording was misleading).
There is some value in that -- it means we could support C, for instance. I'm 
not certain how easy or hard it would be, but suspect it's reasonable. However, 
in C, there's still the problem of the include file that introduces those 
macros. Do we have facilities to remove an include in clang-tidy?



Comment at: clang-tidy/readability/OperatorsRepresentationCheck.cpp:68
+  if (PrimarySpelling != Spelling) {
+diag(OpLoc, "operator uses alternative spelling")
+<< FixItHint::CreateReplacement(TokenRange, PrimarySpelling);

aaron.ballman wrote:
> mgehre wrote:
> > aaron.ballman wrote:
> > > This diagnostic doesn't help the user to understand what's wrong with 
> > > their code (especially in the presence of multiple operators). Perhaps 
> > > "'%0' is an alternative token spelling; consider using '%1'"
> > > 
> > > It would be nice if we could say "consider using %1 for ", but 
> > > I'm really not certain why we would diagnose this code in the first place 
> > > (it's purely a matter of stylistic choice, as I understand it).
> > The main rational for this check is to enforce consistency and thus make it 
> > easier to read and comprehend the code.
> > I agree with your proposed diagnostics.
> I think that enforcing consistency is a good rationale for having the check, 
> but would second the suggestion that this check have an option to enforce the 
> consistency one way or the other.
> 
> Then the diagnostic can be:
> 
> "'%0' is %select{an alternative token|a primary token}2; consider using '%1' 
> for consistency"
The diagnostic is improved, but there's still no way to go the opposite 
direction (from primary to alternative).


https://reviews.llvm.org/D31308



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


[PATCH] D31308: [clang-tidy] new check readability-no-alternative-tokens

2017-04-03 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: clang-tidy/readability/OperatorsRepresentationCheck.cpp:34
+
+  if (const auto *B = Result.Nodes.getNodeAs("binary")) {
+switch (B->getOpcode()) {

aaron.ballman wrote:
> alexfh wrote:
> > aaron.ballman wrote:
> > > mgehre wrote:
> > > > aaron.ballman wrote:
> > > > > alexfh wrote:
> > > > > > aaron.ballman wrote:
> > > > > > > I think this would make more sense lifted into an AST matcher -- 
> > > > > > > there are bound to be a *lot* of binary operators, so letting the 
> > > > > > > matcher memoize things is likely to give better performance.
> > > > > > Any reasons not to do this on the lexer level?
> > > > > Technical reasons? None.
> > > > > User-experience reasons? We wouldn't want this to be on by default (I 
> > > > > don't think) and we usually don't implement off-by-default 
> > > > > diagnostics in Clang. I think a case could be made for doing it in 
> > > > > the Lexer if the performance is really that bad with a clang-tidy 
> > > > > check and we couldn't improve it here, though.
> > > > Do I correctly understand that "doing this on lexer level" would mean 
> > > > to implement this as a warning directly into clang? If yes, would it be 
> > > > possible to generate fixits and have them possibly applied 
> > > > automatically (as it is the case for clang-tidy)?
> > > You are correct, that means implementing it as a warning in Clang. I 
> > > believe you can still generate those fixits from lexer-level diagnostics, 
> > > but have not verified it.
> > > 
> > > However, I don't think this diagnostic would be appropriate for Clang 
> > > because it would have to be off by default.
> > Actually, I was thinking about changing this clang-tidy check to analyze 
> > token stream somehow (probably by handling `PPCallbacks` to detect ranges 
> > that need to be re-lexed) instead of matching the AST. I didn't intend to 
> > propose a new Clang warning (but it looks like the wording was misleading).
> There is some value in that -- it means we could support C, for instance. I'm 
> not certain how easy or hard it would be, but suspect it's reasonable. 
> However, in C, there's still the problem of the include file that introduces 
> those macros. Do we have facilities to remove an include in clang-tidy?
Yes, it may make sense in C, but parameter for map from macro name to operator 
is needed.

Product I'm working for, with long history, had alternative operator 
presentation implemented in C.


https://reviews.llvm.org/D31308



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


[PATCH] D31513: [Sema] Add __is_aggregate type-trait and implement LWG 2015

2017-04-03 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: docs/LanguageExtensions.rst:996
 * ``__is_abstract`` (GNU, Microsoft)
+* ``__is_aggregate`` (GNU, Microsoft)
 * ``__is_base_of`` (GNU, Microsoft)

Has Microsoft already implemented this? If not, do we want to wait for them 
before claiming they implement it as well?



Comment at: lib/Sema/SemaExprCXX.cpp:4234
+// support aggregate initialization. GCC mirrors this behavior for vectors
+// but not _Complex.
+return T->isAggregateType() || T->isVectorType() || T->isExtVectorType() ||

Is there benefit to diverging from GCC's behavior here for _Complex types?


https://reviews.llvm.org/D31513



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


[PATCH] D30547: [clang-tidy] Forwarding reference overload in constructors

2017-04-03 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

Aside from some minor nits about newlines, LGTM!




Comment at: docs/clang-tidy/checks/misc-forwarding-reference-overload.rst:51-52
+
+
+

You can remove the empty lines at the end.



Comment at: test/clang-tidy/misc-forwarding-reference-overload.cpp:140
+};
\ No newline at end of file


Please add a newline at the end of the file.


Repository:
  rL LLVM

https://reviews.llvm.org/D30547



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


[PATCH] D31633: test for thinlto handling of internal linkage

2017-04-03 Thread Bob Haarman via Phabricator via cfe-commits
inglorion created this revision.
Herald added a subscriber: Prazek.

https://reviews.llvm.org/D31633

Files:
  test/CodeGenCXX/thinlto-promote-internals.cpp


Index: test/CodeGenCXX/thinlto-promote-internals.cpp
===
--- /dev/null
+++ test/CodeGenCXX/thinlto-promote-internals.cpp
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -triple x86_64-pc-windows-msvc19.0.24215 -emit-llvm \
+// RUN: -flto=thin -flto-unit -o - %s | FileCheck %s
+
+// CHECK: @"\01??_7B@?A@@6B@" = internal unnamed_addr alias
+// CHECK: define internal %"class.(anonymous namespace)::B"
+
+class A {
+public:
+  virtual int foo() { return 0; }
+};
+
+namespace {
+  class B : public A { };
+}
+
+A *makeA() { return new B(); }
+


Index: test/CodeGenCXX/thinlto-promote-internals.cpp
===
--- /dev/null
+++ test/CodeGenCXX/thinlto-promote-internals.cpp
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -triple x86_64-pc-windows-msvc19.0.24215 -emit-llvm \
+// RUN: -flto=thin -flto-unit -o - %s | FileCheck %s
+
+// CHECK: @"\01??_7B@?A@@6B@" = internal unnamed_addr alias
+// CHECK: define internal %"class.(anonymous namespace)::B"
+
+class A {
+public:
+  virtual int foo() { return 0; }
+};
+
+namespace {
+  class B : public A { };
+}
+
+A *makeA() { return new B(); }
+
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D31633: test for thinlto handling of internal linkage

2017-04-03 Thread Bob Haarman via Phabricator via cfe-commits
inglorion added a comment.

This is the test for https://reviews.llvm.org/D31632.


https://reviews.llvm.org/D31633



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


[PATCH] D31513: [Sema] Add __is_aggregate type-trait and implement LWG 2015

2017-04-03 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF added a subscriber: STL_MSFT.
EricWF added inline comments.



Comment at: docs/LanguageExtensions.rst:996
 * ``__is_abstract`` (GNU, Microsoft)
+* ``__is_aggregate`` (GNU, Microsoft)
 * ``__is_base_of`` (GNU, Microsoft)

aaron.ballman wrote:
> Has Microsoft already implemented this? If not, do we want to wait for them 
> before claiming they implement it as well?
I asked @STL_MSFT to ping the frontend team to confirm they were planning on 
implementing it with this name. I was concerned this doc would never get 
updated otherwise. 



Comment at: lib/Sema/SemaExprCXX.cpp:4234
+// support aggregate initialization. GCC mirrors this behavior for vectors
+// but not _Complex.
+return T->isAggregateType() || T->isVectorType() || T->isExtVectorType() ||

aaron.ballman wrote:
> Is there benefit to diverging from GCC's behavior here for _Complex types?
`_Complex` types act as if they are an array of 2 elements, and hence support 
aggregate initialization.

Ironically the GCC maintainer who implemented `is_aggregate` pointed this case 
out to me. I've pinged him to ask why he chose not to support it, or if the 
change is in the works.


https://reviews.llvm.org/D31513



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


[PATCH] D31513: [Sema] Add __is_aggregate type-trait and implement LWG 2015

2017-04-03 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: docs/LanguageExtensions.rst:996
 * ``__is_abstract`` (GNU, Microsoft)
+* ``__is_aggregate`` (GNU, Microsoft)
 * ``__is_base_of`` (GNU, Microsoft)

EricWF wrote:
> aaron.ballman wrote:
> > Has Microsoft already implemented this? If not, do we want to wait for them 
> > before claiming they implement it as well?
> I asked @STL_MSFT to ping the frontend team to confirm they were planning on 
> implementing it with this name. I was concerned this doc would never get 
> updated otherwise. 
Seems reasonable. My concern is that we claim Microsoft implements this when 
they don't (yet) and someone uses this documentation to try to force 
Microsoft's hand. However, it seems that this documentation not being updated 
is the far more likely scenario. ;-)



Comment at: lib/Sema/SemaExprCXX.cpp:4089
+// See LWG 2015
+QualType ElTy = S.Context.getBaseElementType(ArgTy);
 if (ElTy->isVoidType())

If I understand properly, this change is required by LWG 2015 for existing type 
traits *and* is needed for is_aggregate()? If so, it probably should be a 
separate patch doing just LWG 2015 (and tests) and a second one for 
is_aggregate().



Comment at: lib/Sema/SemaExprCXX.cpp:4234
+// support aggregate initialization. GCC mirrors this behavior for vectors
+// but not _Complex.
+return T->isAggregateType() || T->isVectorType() || T->isExtVectorType() ||

EricWF wrote:
> aaron.ballman wrote:
> > Is there benefit to diverging from GCC's behavior here for _Complex types?
> `_Complex` types act as if they are an array of 2 elements, and hence support 
> aggregate initialization.
> 
> Ironically the GCC maintainer who implemented `is_aggregate` pointed this 
> case out to me. I've pinged him to ask why he chose not to support it, or if 
> the change is in the works.
Thanks! I think supporting it makes sense.


https://reviews.llvm.org/D31513



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


[PATCH] D31513: [Sema] Add __is_aggregate type-trait and implement LWG 2015

2017-04-03 Thread Stephan T. Lavavej via Phabricator via cfe-commits
STL_MSFT added inline comments.



Comment at: docs/LanguageExtensions.rst:996
 * ``__is_abstract`` (GNU, Microsoft)
+* ``__is_aggregate`` (GNU, Microsoft)
 * ``__is_base_of`` (GNU, Microsoft)

aaron.ballman wrote:
> EricWF wrote:
> > aaron.ballman wrote:
> > > Has Microsoft already implemented this? If not, do we want to wait for 
> > > them before claiming they implement it as well?
> > I asked @STL_MSFT to ping the frontend team to confirm they were planning 
> > on implementing it with this name. I was concerned this doc would never get 
> > updated otherwise. 
> Seems reasonable. My concern is that we claim Microsoft implements this when 
> they don't (yet) and someone uses this documentation to try to force 
> Microsoft's hand. However, it seems that this documentation not being updated 
> is the far more likely scenario. ;-)
MS intends to implement this hook under this name. No ETA yet.


https://reviews.llvm.org/D31513



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


[PATCH] D28952: [analyzer] Add new Z3 constraint manager backend

2017-04-03 Thread Devin Coughlin via Phabricator via cfe-commits
dcoughlin added a comment.

Dominic: I don't have a bot set up yet, but let's get this committed. Thanks 
for all your hard work on this!


https://reviews.llvm.org/D28952



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


[PATCH] D31513: [Sema] Add __is_aggregate type-trait and implement LWG 2015

2017-04-03 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF added inline comments.



Comment at: lib/Sema/SemaExprCXX.cpp:4089
+// See LWG 2015
+QualType ElTy = S.Context.getBaseElementType(ArgTy);
 if (ElTy->isVoidType())

aaron.ballman wrote:
> If I understand properly, this change is required by LWG 2015 for existing 
> type traits *and* is needed for is_aggregate()? If so, it probably should be 
> a separate patch doing just LWG 2015 (and tests) and a second one for 
> is_aggregate().
Ack. 


https://reviews.llvm.org/D31513



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


[PATCH] D31513: [Sema] Add __is_aggregate type-trait and implement LWG 2015

2017-04-03 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: docs/LanguageExtensions.rst:996
 * ``__is_abstract`` (GNU, Microsoft)
+* ``__is_aggregate`` (GNU, Microsoft)
 * ``__is_base_of`` (GNU, Microsoft)

STL_MSFT wrote:
> aaron.ballman wrote:
> > EricWF wrote:
> > > aaron.ballman wrote:
> > > > Has Microsoft already implemented this? If not, do we want to wait for 
> > > > them before claiming they implement it as well?
> > > I asked @STL_MSFT to ping the frontend team to confirm they were planning 
> > > on implementing it with this name. I was concerned this doc would never 
> > > get updated otherwise. 
> > Seems reasonable. My concern is that we claim Microsoft implements this 
> > when they don't (yet) and someone uses this documentation to try to force 
> > Microsoft's hand. However, it seems that this documentation not being 
> > updated is the far more likely scenario. ;-)
> MS intends to implement this hook under this name. No ETA yet.
Lovely, then I'm happy with the documentation as-is.


https://reviews.llvm.org/D31513



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


[PATCH] D31235: Enhance -Wshadow to warn when shadowing typedefs or type aliases

2017-04-03 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF added a comment.

This started making the libc++ bots fail, and I'm not convinced the case is 
reasonable to warn on. That case is:

  struct path {
using value_type = char;
struct iterator { 
  using value_type = path;
};
  };

Obviously both typedefs are necessary, and according to the standard they are 
both required to have the same name. I would prefer not to have to `#pragma` 
disable this diagnostic within ``


Repository:
  rL LLVM

https://reviews.llvm.org/D31235



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


[libcxx] r299407 - Work around recent -Wshadow changes in Clang

2017-04-03 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Mon Apr  3 20:05:59 2017
New Revision: 299407

URL: http://llvm.org/viewvc/llvm-project?rev=299407&view=rev
Log:
Work around recent -Wshadow changes in Clang

Modified:
libcxx/trunk/include/experimental/filesystem
libcxx/trunk/include/regex

Modified: libcxx/trunk/include/experimental/filesystem
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/experimental/filesystem?rev=299407&r1=299406&r2=299407&view=diff
==
--- libcxx/trunk/include/experimental/filesystem (original)
+++ libcxx/trunk/include/experimental/filesystem Mon Apr  3 20:05:59 2017
@@ -1091,7 +1091,18 @@ class _LIBCPP_TYPE_VIS path::iterator
 {
 public:
 typedef bidirectional_iterator_tag iterator_category;
+
+// FIXME: As of 3/April/2017 Clang warns on `value_type` shadowing the
+// definition in path. Clang should be fixed and this should be removed.
+#if defined(__clang__)
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wshadow"
+#endif
 typedef path   value_type;
+#if defined(__clang__)
+#pragma clang diagnostic pop
+#endif
+
 typedef std::ptrdiff_t difference_type;
 typedef const path*pointer;
 typedef const path&reference;

Modified: libcxx/trunk/include/regex
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/regex?rev=299407&r1=299406&r2=299407&view=diff
==
--- libcxx/trunk/include/regex (original)
+++ libcxx/trunk/include/regex Mon Apr  3 20:05:59 2017
@@ -3957,7 +3957,6 @@ basic_regex<_CharT, _Traits>::__parse_eq
 if (__temp == __last)
 __throw_regex_error();
 // [__first, __temp) contains all text in [= ... =]
-typedef typename _Traits::string_type string_type;
 string_type __collate_name =
 __traits_.lookup_collatename(__first, __temp);
 if (__collate_name.empty())


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


Re: [libcxx] r299385 - suppress GCC warning about noexcept functions changing mangling

2017-04-03 Thread Richard Smith via cfe-commits
Thanks, that makes sense, I forgot to check for noexcept function types in
template arguments. (Though I think GCC's diagnostic is sort of wrong or at
least missing the point in this case, which is that 't' will have a
different type in C++17.)

On 3 Apr 2017 1:33 pm, "Eric Fiselier"  wrote:

Here is a reduced version.

void glibc_function() throw() {}

template  struct Test {
  Test() {} // expected-error {{mangled name for 'Test::Test()' will
change in C++17}}
  ~Test() {}  // expected-error {{mangled name for 'Test::~Test()' will
change in C++17}}
};

Test t;

/Eric

On Mon, Apr 3, 2017 at 5:17 PM, Eric Fiselier  wrote:

> I'll create a reduced reproducer, but it'll take some time because GCC is
> quite cryptic about the instantiation stack.
>
> if you want many instances within the libc++ build simply revert this
> commit and build with a new GCC.
>
> /Eric
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D31637: [Sema] Implement LWG 2015 for the builtin type-traits.

2017-04-03 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF created this revision.

This patch implements LWG 2015 
, which requires than 
arrays used with [meta.unary.prop] traits have a complete element type.

If I'm not mistaken the correct thing to do is to retroactively apply it to 
C++11 even though it first appeared in the C++14 standard.


https://reviews.llvm.org/D31637

Files:
  lib/Sema/SemaExprCXX.cpp
  test/SemaCXX/type-traits-incomplete.cpp


Index: test/SemaCXX/type-traits-incomplete.cpp
===
--- test/SemaCXX/type-traits-incomplete.cpp
+++ test/SemaCXX/type-traits-incomplete.cpp
@@ -1,8 +1,15 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s 
 
-struct S; // expected-note 2 {{forward declaration of 'S'}}
+struct S; // expected-note 4 {{forward declaration of 'S'}}
+typedef S SAr[10];
+typedef S SArNB[];
+typedef S SArMB[10][2];
 
 void f() {
   __is_pod(S); // expected-error{{incomplete type 'S' used in type trait 
expression}}
   __is_pod(S[]); // expected-error{{incomplete type 'S' used in type trait 
expression}}
+  __is_pod(S[10][2]); // expected-error{{incomplete type 'S' used in type 
trait expression}}
+  __is_pod(S[][10]); // expected-error{{incomplete type 'S' used in type trait 
expression}}
+  (void)__is_pod(void); // OK
+  (void)__is_pod(const volatile void); // OK
 }
Index: lib/Sema/SemaExprCXX.cpp
===
--- lib/Sema/SemaExprCXX.cpp
+++ lib/Sema/SemaExprCXX.cpp
@@ -4081,10 +4081,11 @@
   case UTT_HasTrivialCopy:
   case UTT_HasTrivialDestructor:
   case UTT_HasVirtualDestructor:
-// Arrays of unknown bound are expressly allowed.
-QualType ElTy = ArgTy;
-if (ArgTy->isIncompleteArrayType())
-  ElTy = S.Context.getAsArrayType(ArgTy)->getElementType();
+// C++14 [meta.unary.prop]
+//   remove_all_extents_t shall be a complete type or
+//   (possibly cv-qualified) void.
+// See LWG 2015
+QualType ElTy = S.Context.getBaseElementType(ArgTy);
 
 // The void type is expressly allowed.
 if (ElTy->isVoidType())


Index: test/SemaCXX/type-traits-incomplete.cpp
===
--- test/SemaCXX/type-traits-incomplete.cpp
+++ test/SemaCXX/type-traits-incomplete.cpp
@@ -1,8 +1,15 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s 
 
-struct S; // expected-note 2 {{forward declaration of 'S'}}
+struct S; // expected-note 4 {{forward declaration of 'S'}}
+typedef S SAr[10];
+typedef S SArNB[];
+typedef S SArMB[10][2];
 
 void f() {
   __is_pod(S); // expected-error{{incomplete type 'S' used in type trait expression}}
   __is_pod(S[]); // expected-error{{incomplete type 'S' used in type trait expression}}
+  __is_pod(S[10][2]); // expected-error{{incomplete type 'S' used in type trait expression}}
+  __is_pod(S[][10]); // expected-error{{incomplete type 'S' used in type trait expression}}
+  (void)__is_pod(void); // OK
+  (void)__is_pod(const volatile void); // OK
 }
Index: lib/Sema/SemaExprCXX.cpp
===
--- lib/Sema/SemaExprCXX.cpp
+++ lib/Sema/SemaExprCXX.cpp
@@ -4081,10 +4081,11 @@
   case UTT_HasTrivialCopy:
   case UTT_HasTrivialDestructor:
   case UTT_HasVirtualDestructor:
-// Arrays of unknown bound are expressly allowed.
-QualType ElTy = ArgTy;
-if (ArgTy->isIncompleteArrayType())
-  ElTy = S.Context.getAsArrayType(ArgTy)->getElementType();
+// C++14 [meta.unary.prop]
+//   remove_all_extents_t shall be a complete type or
+//   (possibly cv-qualified) void.
+// See LWG 2015
+QualType ElTy = S.Context.getBaseElementType(ArgTy);
 
 // The void type is expressly allowed.
 if (ElTy->isVoidType())
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D31637: [Sema] Implement LWG 2015 for the builtin type-traits.

2017-04-03 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF updated this revision to Diff 93985.
EricWF edited the summary of this revision.

https://reviews.llvm.org/D31637

Files:
  lib/Sema/SemaExprCXX.cpp
  test/SemaCXX/type-traits-incomplete.cpp


Index: test/SemaCXX/type-traits-incomplete.cpp
===
--- test/SemaCXX/type-traits-incomplete.cpp
+++ test/SemaCXX/type-traits-incomplete.cpp
@@ -1,8 +1,20 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s 
 
-struct S; // expected-note 2 {{forward declaration of 'S'}}
+struct S; // expected-note 5 {{forward declaration of 'S'}}
+typedef S SAr[10];
+typedef S SArNB[];
+typedef S SArMB[10][2];
+
+struct C {};
 
 void f() {
   __is_pod(S); // expected-error{{incomplete type 'S' used in type trait 
expression}}
   __is_pod(S[]); // expected-error{{incomplete type 'S' used in type trait 
expression}}
+  __is_pod(S[10]); // expected-error{{incomplete type 'S' used in type trait 
expression}}
+  __is_pod(S[10][2]); // expected-error{{incomplete type 'S' used in type 
trait expression}}
+  __is_pod(S[][10]); // expected-error{{incomplete type 'S' used in type trait 
expression}}
+  (void)__is_pod(C[]);
+  (void)__is_pod(C[][10]);
+  (void)__is_pod(void); // OK
+  (void)__is_pod(const volatile void); // OK
 }
Index: lib/Sema/SemaExprCXX.cpp
===
--- lib/Sema/SemaExprCXX.cpp
+++ lib/Sema/SemaExprCXX.cpp
@@ -4081,10 +4081,11 @@
   case UTT_HasTrivialCopy:
   case UTT_HasTrivialDestructor:
   case UTT_HasVirtualDestructor:
-// Arrays of unknown bound are expressly allowed.
-QualType ElTy = ArgTy;
-if (ArgTy->isIncompleteArrayType())
-  ElTy = S.Context.getAsArrayType(ArgTy)->getElementType();
+// C++14 [meta.unary.prop]
+//   remove_all_extents_t shall be a complete type or
+//   (possibly cv-qualified) void.
+// See LWG 2015
+QualType ElTy = S.Context.getBaseElementType(ArgTy);
 
 // The void type is expressly allowed.
 if (ElTy->isVoidType())


Index: test/SemaCXX/type-traits-incomplete.cpp
===
--- test/SemaCXX/type-traits-incomplete.cpp
+++ test/SemaCXX/type-traits-incomplete.cpp
@@ -1,8 +1,20 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s 
 
-struct S; // expected-note 2 {{forward declaration of 'S'}}
+struct S; // expected-note 5 {{forward declaration of 'S'}}
+typedef S SAr[10];
+typedef S SArNB[];
+typedef S SArMB[10][2];
+
+struct C {};
 
 void f() {
   __is_pod(S); // expected-error{{incomplete type 'S' used in type trait expression}}
   __is_pod(S[]); // expected-error{{incomplete type 'S' used in type trait expression}}
+  __is_pod(S[10]); // expected-error{{incomplete type 'S' used in type trait expression}}
+  __is_pod(S[10][2]); // expected-error{{incomplete type 'S' used in type trait expression}}
+  __is_pod(S[][10]); // expected-error{{incomplete type 'S' used in type trait expression}}
+  (void)__is_pod(C[]);
+  (void)__is_pod(C[][10]);
+  (void)__is_pod(void); // OK
+  (void)__is_pod(const volatile void); // OK
 }
Index: lib/Sema/SemaExprCXX.cpp
===
--- lib/Sema/SemaExprCXX.cpp
+++ lib/Sema/SemaExprCXX.cpp
@@ -4081,10 +4081,11 @@
   case UTT_HasTrivialCopy:
   case UTT_HasTrivialDestructor:
   case UTT_HasVirtualDestructor:
-// Arrays of unknown bound are expressly allowed.
-QualType ElTy = ArgTy;
-if (ArgTy->isIncompleteArrayType())
-  ElTy = S.Context.getAsArrayType(ArgTy)->getElementType();
+// C++14 [meta.unary.prop]
+//   remove_all_extents_t shall be a complete type or
+//   (possibly cv-qualified) void.
+// See LWG 2015
+QualType ElTy = S.Context.getBaseElementType(ArgTy);
 
 // The void type is expressly allowed.
 if (ElTy->isVoidType())
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D31513: [Sema] Add __is_aggregate type-trait

2017-04-03 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF updated this revision to Diff 93987.
EricWF retitled this revision from "[Sema] Add __is_aggregate type-trait and 
implement LWG 2015" to "[Sema] Add __is_aggregate type-trait".
EricWF edited the summary of this revision.
EricWF added a comment.

- Remove LWG 2015 implementation.


https://reviews.llvm.org/D31513

Files:
  docs/LanguageExtensions.rst
  include/clang/Basic/TokenKinds.def
  include/clang/Basic/TypeTraits.h
  lib/Parse/ParseDeclCXX.cpp
  lib/Parse/ParseExpr.cpp
  lib/Sema/SemaExprCXX.cpp
  test/PCH/cxx-traits.cpp
  test/PCH/cxx-traits.h
  test/SemaCXX/type-traits.cpp

Index: test/SemaCXX/type-traits.cpp
===
--- test/SemaCXX/type-traits.cpp
+++ test/SemaCXX/type-traits.cpp
@@ -1,20 +1,28 @@
 // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -verify -std=gnu++11 -fms-extensions -Wno-microsoft %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -verify -std=gnu++14 -fms-extensions -Wno-microsoft %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -verify -std=gnu++1z -fms-extensions -Wno-microsoft %s
+
 #define T(b) (b) ? 1 : -1
 #define F(b) (b) ? -1 : 1
 
 struct NonPOD { NonPOD(int); };
+typedef NonPOD NonPODAr[10];
+typedef NonPOD NonPODArNB[];
+typedef NonPOD NonPODArMB[10][2];
 
 // PODs
 enum Enum { EV };
 struct POD { Enum e; int i; float f; NonPOD* p; };
 struct Empty {};
 typedef Empty EmptyAr[10];
+typedef Empty EmptyArNB[];
+typedef Empty EmptyArMB[1][2];
 typedef int Int;
 typedef Int IntAr[10];
 typedef Int IntArNB[];
 class Statics { static int priv; static NonPOD np; };
 union EmptyUnion {};
-union IncompleteUnion;
+union IncompleteUnion; // expected-note {{forward declaration of 'IncompleteUnion'}}
 union Union { int i; float f; };
 struct HasFunc { void f (); };
 struct HasOp { void operator *(); };
@@ -31,13 +39,20 @@
 typedef int Vector __attribute__((vector_size(16)));
 typedef int VectorExt __attribute__((ext_vector_type(4)));
 
+using ComplexFloat = _Complex float;
+using ComplexInt = _Complex int;
+
 // Not PODs
 typedef const void cvoid;
 struct Derives : POD {};
 typedef Derives DerivesAr[10];
 typedef Derives DerivesArNB[];
 struct DerivesEmpty : Empty {};
 struct HasCons { HasCons(int); };
+struct HasDefaultCons { HasDefaultCons() = default; };
+struct HasExplicitDefaultCons { explicit HasExplicitDefaultCons() = default; };
+struct HasInheritedCons : HasDefaultCons { using HasDefaultCons::HasDefaultCons; };
+struct HasNoInheritedCons : HasCons {};
 struct HasCopyAssign { HasCopyAssign operator =(const HasCopyAssign&); };
 struct HasMoveAssign { HasMoveAssign operator =(const HasMoveAssign&&); };
 struct HasNoThrowMoveAssign { 
@@ -48,8 +63,15 @@
 const HasNoExceptNoThrowMoveAssign&&) noexcept; 
 };
 struct HasThrowMoveAssign { 
-  HasThrowMoveAssign& operator=(
-const HasThrowMoveAssign&&) throw(POD); };
+  HasThrowMoveAssign& operator=(const HasThrowMoveAssign&&)
+#if __cplusplus <= 201402L
+  throw(POD);
+#else
+  noexcept(false);
+#endif
+};
+
+
 struct HasNoExceptFalseMoveAssign { 
   HasNoExceptFalseMoveAssign& operator=(
 const HasNoExceptFalseMoveAssign&&) noexcept(false); };
@@ -81,6 +103,7 @@
 class  HasPriv { int priv; };
 class  HasProt { protected: int prot; };
 struct HasRef { int i; int& ref; HasRef() : i(0), ref(i) {} };
+struct HasRefAggregate { int i; int& ref; };
 struct HasNonPOD { NonPOD np; };
 struct HasVirt { virtual void Virt() {}; };
 typedef NonPOD NonPODAr[10];
@@ -152,7 +175,12 @@
 };
 
 struct ThrowingDtor {
-  ~ThrowingDtor() throw(int);
+  ~ThrowingDtor()
+#if __cplusplus <= 201402L
+  throw(int);
+#else
+  noexcept(false);
+#endif
 };
 
 struct NoExceptDtor {
@@ -163,6 +191,20 @@
   ~NoThrowDtor() throw();
 };
 
+struct ACompleteType {};
+struct AnIncompleteType; // expected-note 1+ {{forward declaration of 'AnIncompleteType'}}
+typedef AnIncompleteType AnIncompleteTypeAr[42];
+typedef AnIncompleteType AnIncompleteTypeArNB[];
+typedef AnIncompleteType AnIncompleteTypeArMB[1][10];
+
+struct HasInClassInit {
+  int x = 42;
+};
+
+struct HasPrivateBase : private ACompleteType {};
+struct HasProtectedBase : protected ACompleteType {};
+struct HasVirtBase : virtual ACompleteType {};
+
 void is_pod()
 {
   { int arr[T(__is_pod(int))]; }
@@ -452,6 +494,83 @@
   int t31[F(__is_floating_point(IntArNB))];
 }
 
+template 
+struct AggregateTemplate {
+  T value;
+};
+
+template 
+struct NonAggregateTemplate {
+  T value;
+  NonAggregateTemplate();
+};
+
+void is_aggregate()
+{
+  constexpr bool TrueAfterCpp11 = __cplusplus > 201103L;
+  constexpr bool TrueAfterCpp14 = __cplusplus > 201402L;
+
+  __is_aggregate(AnIncompleteType); // expected-error {{incomplete type}}
+  __is_aggregate(AnIncompleteTypeAr); // expected-error {{incomplete type}}
+  __is_aggregate(AnIncompleteTypeArNB); // expected-error {{incomplete type}}
+  __is_aggregate(AnIncompleteTypeArMB); // expected-error {{incomplete type}}
+  __is_aggregate(Incomplete

[PATCH] D31637: [Sema] Implement LWG 2015 for the builtin type-traits.

2017-04-03 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

> If I'm not mistaken the correct thing to do is to retroactively apply it to 
> C++11 even though it first appeared in the C++14 standard.

That is how we typically handle DRs.

Do you also need to change the implementation of `EvaluateBinaryTypeTrait()` 
for the changes to `is_base_of()`?




Comment at: lib/Sema/SemaExprCXX.cpp:4083
   case UTT_HasTrivialDestructor:
   case UTT_HasVirtualDestructor:
+// C++14 [meta.unary.prop]

Is this correct for `has_virtual_destructor()`? LWG 2015 treats that the same 
as `is_empty()` and friends.


https://reviews.llvm.org/D31637



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


[PATCH] D27565: [libcxx] Fix __compressed_pair so it doesn't copy the argument multiple times, and add constexpr.

2017-04-03 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF updated this revision to Diff 93991.
EricWF retitled this revision from "[libcxx] Alternative fix for compressed 
pair" to "[libcxx] Fix __compressed_pair so it doesn't copy the argument 
multiple times, and add constexpr.".
EricWF edited the summary of this revision.
EricWF added a comment.

I'm going ahead with this patch instead of https://reviews.llvm.org/D27564


https://reviews.llvm.org/D27565

Files:
  include/__hash_table
  include/memory
  include/string
  
test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default01.fail.cpp

Index: test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default01.fail.cpp
===
--- test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default01.fail.cpp
+++ test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default01.fail.cpp
@@ -21,7 +21,6 @@
 class Deleter
 {
 // expected-error@memory:* {{base class 'Deleter' has private default constructor}}
-// expected-note@memory:* + {{in instantiation of member function}}
 Deleter() {} // expected-note {{implicitly declared private here}}
 
 public:
Index: include/string
===
--- include/string
+++ include/string
@@ -1511,7 +1511,7 @@
 #else
 _NOEXCEPT
 #endif
-: __r_(__a)
+: __r_(__second_tag(), __a)
 {
 #if _LIBCPP_DEBUG_LEVEL >= 2
 __get_db()->__insert_c(this);
@@ -1582,7 +1582,7 @@
 template 
 inline _LIBCPP_INLINE_VISIBILITY
 basic_string<_CharT, _Traits, _Allocator>::basic_string(const _CharT* __s, const _Allocator& __a)
-: __r_(__a)
+: __r_(__second_tag(), __a)
 {
 _LIBCPP_ASSERT(__s != nullptr, "basic_string(const char*, allocator) detected nullptr");
 __init(__s, traits_type::length(__s));
@@ -1605,7 +1605,7 @@
 template 
 inline _LIBCPP_INLINE_VISIBILITY
 basic_string<_CharT, _Traits, _Allocator>::basic_string(const _CharT* __s, size_type __n, const _Allocator& __a)
-: __r_(__a)
+: __r_(__second_tag(), __a)
 {
 _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "basic_string(const char*, n, allocator) detected nullptr");
 __init(__s, __n);
@@ -1616,7 +1616,7 @@
 
 template 
 basic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __str)
-: __r_(__alloc_traits::select_on_container_copy_construction(__str.__alloc()))
+: __r_(__second_tag(), __alloc_traits::select_on_container_copy_construction(__str.__alloc()))
 {
 if (!__str.__is_long())
 __r_.first().__r = __str.__r_.first().__r;
@@ -1630,7 +1630,7 @@
 template 
 basic_string<_CharT, _Traits, _Allocator>::basic_string(
 const basic_string& __str, const allocator_type& __a)
-: __r_(__a)
+: __r_(__second_tag(), __a)
 {
 if (!__str.__is_long())
 __r_.first().__r = __str.__r_.first().__r;
@@ -1664,7 +1664,7 @@
 template 
 inline _LIBCPP_INLINE_VISIBILITY
 basic_string<_CharT, _Traits, _Allocator>::basic_string(basic_string&& __str, const allocator_type& __a)
-: __r_(__a)
+: __r_(__second_tag(), __a)
 {
 if (__str.__is_long() && __a != __str.__alloc()) // copy, not move
 __init(_VSTD::__to_raw_pointer(__str.__get_long_pointer()), __str.__get_long_size());
@@ -1719,7 +1719,7 @@
 template 
 inline _LIBCPP_INLINE_VISIBILITY
 basic_string<_CharT, _Traits, _Allocator>::basic_string(size_type __n, _CharT __c, const _Allocator& __a)
-: __r_(__a)
+: __r_(__second_tag(), __a)
 {
 __init(__n, __c);
 #if _LIBCPP_DEBUG_LEVEL >= 2
@@ -1731,7 +1731,7 @@
 basic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __str,
 size_type __pos, size_type __n,
 const _Allocator& __a)
-: __r_(__a)
+: __r_(__second_tag(), __a)
 {
 size_type __str_sz = __str.size();
 if (__pos > __str_sz)
@@ -1746,7 +1746,7 @@
 inline _LIBCPP_INLINE_VISIBILITY
 basic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __str, size_type __pos,
 const _Allocator& __a)
-: __r_(__a)
+: __r_(__second_tag(), __a)
 {
 size_type __str_sz = __str.size();
 if (__pos > __str_sz)
@@ -1762,7 +1762,7 @@
 basic_string<_CharT, _Traits, _Allocator>::basic_string(
  const _Tp& __t, size_type __pos, size_type __n, const allocator_type& __a,
 			 typename enable_if<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, void>::type *)
-: __r_(__a)
+: __r_(__second_tag(), __a)
 {
 	__self_view __sv = __self_view(__t).substr(__pos, __n);
 __init(__sv.data(), __sv.size());
@@ -1784,7 +1784,7 @@
 template 
 inline _LIBCPP_INLINE_VISIBILITY
 basic_string<_CharT, _Traits, _Allocator>::basic_string(__self_view __sv, const _Allocator& __a)
-: __r_(__a)
+: __r_(__second_tag(), __a)
 {
 __

[PATCH] D27564: [libcxx] Fix __compressed_pair so it doesn't copy the argument multiple times

2017-04-03 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF abandoned this revision.
EricWF added a comment.

Abandoning in favor of https://reviews.llvm.org/D27565


https://reviews.llvm.org/D27564



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


[PATCH] D27565: [libcxx] Fix __compressed_pair so it doesn't copy the argument multiple times, and add constexpr.

2017-04-03 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF added a reviewer: K-ballo.
EricWF added a subscriber: K-ballo.
EricWF added a comment.

@K-ballo if you have time would you do me the favor and looking this over.

In particular that I didn't accidentally change the layout of 
`__compressed_pair`. I don't think I did but I need a second set of eyes.
Here is a standalone header containing the old `__compressed_pair` 
implementation 
, because it's 
harder to read the diff.


https://reviews.llvm.org/D27565



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


  1   2   >