r261192 - Sema: provide an extension warning for enable_if

2016-02-17 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Thu Feb 18 00:49:31 2016
New Revision: 261192

URL: http://llvm.org/viewvc/llvm-project?rev=261192=rev
Log:
Sema: provide an extension warning for enable_if

Clang implements an enable_if attribute as an extension.  Hook up `-Wpedantic`
to issue an extension usage warning when __enable_if__ is used.

Added:
cfe/trunk/test/Sema/enable_if-ext.c
Modified:
cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td
cfe/trunk/lib/Sema/SemaDeclAttr.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td?rev=261192=261191=261192=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td Thu Feb 18 00:49:31 
2016
@@ -157,6 +157,8 @@ def ext_old_implicitly_unsigned_long_cxx
   "this literal will %select{have type 'long long'|be ill-formed}0 "
   "in C++11 onwards">,
   InGroup;
+def ext_clang_enable_if : Extension<"'enable_if' is a clang extension">,
+  InGroup;
 
 // SEH
 def err_seh_expected_handler : Error<

Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=261192=261191=261192=diff
==
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Thu Feb 18 00:49:31 2016
@@ -804,6 +804,8 @@ static void handleLocksExcludedAttr(Sema
 }
 
 static void handleEnableIfAttr(Sema , Decl *D, const AttributeList ) {
+  S.Diag(Attr.getLoc(), diag::ext_clang_enable_if);
+
   Expr *Cond = Attr.getArgAsExpr(0);
   if (!Cond->isTypeDependent()) {
 ExprResult Converted = S.PerformContextuallyConvertToBool(Cond);

Added: cfe/trunk/test/Sema/enable_if-ext.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/enable_if-ext.c?rev=261192=auto
==
--- cfe/trunk/test/Sema/enable_if-ext.c (added)
+++ cfe/trunk/test/Sema/enable_if-ext.c Thu Feb 18 00:49:31 2016
@@ -0,0 +1,50 @@
+// RUN: %clang_cc1 -fsyntax-only %s -include %s -verify
+// RUN: %clang_cc1 -Wpedantic -fsyntax-only %s -include %s -verify 
-DWARN_PEDANTIC
+
+#ifndef enable_if_ext_included
+#define enable_if_ext_included
+
+#if !defined(WARN_PEDANTIC)
+// expected-no-diagnostics
+#endif
+
+__attribute__ (( enable_if(1, "") ))
+#if defined(WARN_PEDANTIC)
+// expected-warning@-2 {{'enable_if' is a clang extension}}
+#endif
+void f() { }
+
+__attribute__ (( __enable_if__(1, "") ))
+#if defined(WARN_PEDANTIC)
+// expected-warning@-2 {{'enable_if' is a clang extension}}
+#endif
+void g() { }
+
+__attribute__ (( enable_if(0, "") ))
+#if defined(WARN_PEDANTIC)
+// expected-warning@-2 {{'enable_if' is a clang extension}}
+#endif
+void h() { }
+
+__attribute__ (( __enable_if__(0, "") ))
+#if defined(WARN_PEDANTIC)
+// expected-warning@-2 {{'enable_if' is a clang extension}}
+#endif
+void i() { }
+
+#pragma clang system_header
+
+__attribute__ (( enable_if(1, "") ))
+void j() { }
+
+__attribute__ (( __enable_if__(1, "") ))
+void k() { }
+
+__attribute__ (( enable_if(0, "") ))
+void l() { }
+
+__attribute__ (( __enable_if__(0, "") ))
+void m() { }
+
+#endif
+


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


r261191 - [Parse] Make sure we don't forget to diagnose typos in exprs

2016-02-17 Thread David Majnemer via cfe-commits
Author: majnemer
Date: Thu Feb 18 00:37:44 2016
New Revision: 261191

URL: http://llvm.org/viewvc/llvm-project?rev=261191=rev
Log:
[Parse] Make sure we don't forget to diagnose typos in exprs

If ActOn*Op fails, we will forget to diagnose typos in the LHS of
expressions.

Modified:
cfe/trunk/lib/Parse/ParseExpr.cpp
cfe/trunk/test/SemaCXX/typo-correction.cpp

Modified: cfe/trunk/lib/Parse/ParseExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExpr.cpp?rev=261191=261190=261191=diff
==
--- cfe/trunk/lib/Parse/ParseExpr.cpp (original)
+++ cfe/trunk/lib/Parse/ParseExpr.cpp Thu Feb 18 00:37:44 2016
@@ -431,6 +431,7 @@ Parser::ParseRHSOfBinaryExpression(ExprR
   }
 }
 
+ExprResult OrigLHS = LHS;
 if (!LHS.isInvalid()) {
   // Combine the LHS and RHS into the LHS (e.g. build AST).
   if (TernaryMiddle.isInvalid()) {
@@ -445,12 +446,15 @@ Parser::ParseRHSOfBinaryExpression(ExprR
 
 LHS = Actions.ActOnBinOp(getCurScope(), OpToken.getLocation(),
  OpToken.getKind(), LHS.get(), RHS.get());
-  } else
+  } else {
 LHS = Actions.ActOnConditionalOp(OpToken.getLocation(), ColonLoc,
  LHS.get(), TernaryMiddle.get(),
  RHS.get());
-} else {
-  // Ensure potential typos aren't left undiagnosed.
+  }
+}
+// Ensure potential typos aren't left undiagnosed.
+if (LHS.isInvalid()) {
+  Actions.CorrectDelayedTyposInExpr(OrigLHS);
   Actions.CorrectDelayedTyposInExpr(TernaryMiddle);
   Actions.CorrectDelayedTyposInExpr(RHS);
 }

Modified: cfe/trunk/test/SemaCXX/typo-correction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/typo-correction.cpp?rev=261191=261190=261191=diff
==
--- cfe/trunk/test/SemaCXX/typo-correction.cpp (original)
+++ cfe/trunk/test/SemaCXX/typo-correction.cpp Thu Feb 18 00:37:44 2016
@@ -665,3 +665,8 @@ using C::D::Foofoo;  // expected-error {
 }
 
 int d = ? L : d; // expected-error {{expected expression}} expected-error 
{{undeclared identifier}}
+
+struct B0 {
+  int : 0 | // expected-error {{invalid operands to binary expression}}
+  (struct B0)e; // expected-error {{use of undeclared identifier}}
+};


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


Re: [PATCH] D16843: [Sema] Fix bug in TypeLocBuilder::pushImpl

2016-02-17 Thread Akira Hatanaka via cfe-commits
ahatanak added a comment.

OK, I now understand what you meant.

> How about the following?

> 

>   else if (LocalAlignment == 8) {

> if (NumBytesAtAlign8 == 0) {

>   // We have not seen any 8-byte aligned element yet. There is no padding 
> and we are either 4-byte

>   // aligned or 8-byte aligned depending on NumBytesAtAlign4.

>   // Add in 4 bytes padding if we are not 8-byte aligned including this 
> element.

>   if ((LocalSize + NumBytesAtAlign4) % 8 != 0) {

> memmove([Index - 4], [Index], NumBytesAtAlign4);

> Index -= 4;

>   }


If Capacity is not a multiple of 8, (LocalSize + NumBytesAtAlign4) % 8 doesn't 
tell you whether the new element will be 8-byte aligned. For example, if 
Capacity==36, NumBytesAtAlign4==4, and LocalSize==8, (LocalSize + 
NumBytesAtAlign4) equals 12 but padding is not needed as the new element can 
start at Index=24. Note that it's possible to have a Capacity that isn't a 
multiple of 8 by calling TypeLocBuilder::reserve. I think padding is needed if 
the new index (Index - LocalSize) is not a multiple of 8.


http://reviews.llvm.org/D16843



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


Re: [libcxx] r260431 - Recommit r260012 - Cleanup node-type handling in the unordered containers.

2016-02-17 Thread Evgenii Stepanov via cfe-commits
Thank you!

On Wed, Feb 17, 2016 at 9:23 PM, Eric Fiselier  wrote:
> Hopefully fixed in r261180.
>
> On Sat, Feb 13, 2016 at 2:08 PM, Evgenii Stepanov
>  wrote:
>>
>> Hi,
>>
>> this is my error message:
>>
>> In file included from z.cc:1:
>> /code/build-llvm/bin/../include/c++/v1/ext/hash_map:213:5: warning:
>> Use of the header  is deprecated. Migrate to
>>  [-W#warnings]
>> #   warning Use of the header  is deprecated.  Migrate
>> to 
>> ^
>> /code/build-llvm/bin/../include/c++/v1/ext/hash_map:432:57: error:
>> '__non_const_iterator' is a private member of
>>
>> 'std::__1::__hash_const_iterator> int>, void *> *>'
>> __hash_map_iterator> _HashIterator::__non_const_iterator> __i)
>> ^
>> /code/build-llvm/bin/../include/c++/v1/ext/hash_map:659:16: note: in
>> instantiation of template class
>>
>> '__gnu_cxx::__hash_map_const_iterator> int>, void *> *> >' requested here
>> insert(__u.begin(), __u.end());
>>^
>> z.cc:4:16: note: in instantiation of member function
>> '__gnu_cxx::hash_map> std::__1::equal_to, std::__1::allocator   int, int> > >::hash_map' requested here
>> template class hash_map;
>>^
>> /code/build-llvm/bin/../include/c++/v1/__hash_table:383:39: note:
>> implicitly declared private here
>> typedef __hash_iterator<_NodePtr> __non_const_iterator;
>>   ^
>> 1 warning and 1 error generated.
>>
>>
>> and this is my test case:
>>
>> #include 
>>
>> namespace __gnu_cxx {
>> template class hash_map;
>> }
>>
>>
>> On Sat, Feb 13, 2016 at 12:17 AM, Eric Fiselier  wrote:
>> >> The "hash_map" part of the name means they belong to "",
>> >> and the actual type is defined in that header.
>> >
>> > Woops, Sorry I guess the name is used in both "std::__1::" in
>> > unordered_map
>> > and "__gnu_cxx::" in . My intention in the changes was to
>> > forward declare "std::__1::__hash_map_iterator".
>> >
>> > On Sat, Feb 13, 2016 at 1:11 AM, Eric Fiselier  wrote:
>> >>
>> >> > hash_map still looks broken to me.
>> >>
>> >> Uh oh, Sorry :-S. The original breakage was caused by the removal of a
>> >> typedef "hash_map" used, but I'm sure I fixed that.
>> >>
>> >> > should not they be prefixed with __gnu_cxx:: ?
>> >>
>> >> No, they are in the correct namespace. The "hash_map" part of the name
>> >> means they belong to "", and the actual type is defined
>> >> in
>> >> that header.
>> >>
>> >> Could you give me more information about the breakage your seeing? The
>> >> actual compiler diagnostics if possible? I also committed other sizable
>> >> changes to <__hash_table> in r260513 so that may be related.
>> >>
>> >> Let me know if you need this reverted. If possible I would like to hold
>> >> off, at least until more is known.
>> >>
>> >> /Eric
>> >>
>> >> On Fri, Feb 12, 2016 at 1:31 PM, Evgenii Stepanov
>> >>  wrote:
>> >>>
>> >>> Hi,
>> >>>
>> >>> hash_map still looks broken to me.
>> >>> I don't have a simple reproducer, but these declarations in
>> >>> __hash_table:
>> >>>
>> >>> template  class _LIBCPP_TYPE_VIS_ONLY
>> >>> __hash_map_iterator;
>> >>>  template  class _LIBCPP_TYPE_VIS_ONLY
>> >>> __hash_map_const_iterator;
>> >>>
>> >>> should not they be prefixed with __gnu_cxx:: ?
>> >>>
>> >>> Clang says that std::__1::__hash_const_iterator and
>> >>> __gnu_cxx::__hash_map_const_iterator are not friends and
>> >>> __non_const_iterator at ext/hash_map:432 is private.
>> >>>
>> >>>
>> >>> On Wed, Feb 10, 2016 at 12:46 PM, Eric Fiselier via cfe-commits
>> >>>  wrote:
>> >>> > Author: ericwf
>> >>> > Date: Wed Feb 10 14:46:23 2016
>> >>> > New Revision: 260431
>> >>> >
>> >>> > URL: http://llvm.org/viewvc/llvm-project?rev=260431=rev
>> >>> > Log:
>> >>> > Recommit r260012 - Cleanup node-type handling in the unordered
>> >>> > containers.
>> >>> >
>> >>> > This time I kept  working!
>> >>> >
>> >>> > This patch is the first in a series of patches that's meant to
>> >>> > better
>> >>> > support unordered_map. unordered_map has a special "value_type" that
>> >>> > differs from pair. In order to meet the
>> >>> > EmplaceConstructible
>> >>> > and CopyInsertable requirements we need to teach __hash_table about
>> >>> > this
>> >>> > special value_type.
>> >>> >
>> >>> > This patch creates a "__hash_node_types" traits class that contains
>> >>> > all of the typedefs needed by the unordered containers and it's
>> >>> > iterators.
>> >>> > These typedefs include ones for each node type and  node pointer
>> >>> > type,
>> >>> > as well as special typedefs for "unordered_map"'s value type.
>> >>> >
>> >>> > As a result of this change all of the unordered containers 

[PATCH] D17369: [OpenMP] Code generation for target exit data directive

2016-02-17 Thread Samuel Antao via cfe-commits
sfantao created this revision.
sfantao added reviewers: ABataev, hfinkel, carlo.bertolli, arpith-jacob, kkwli0.
sfantao added subscribers: caomhin, fraggamuffin, cfe-commits.

This patch adds support for the target exit data directive code generation.

Given that, apart from the employed runtime call, target exit data requires the 
same code generation pattern as target enter data, the OpenMP codegen entry 
point was renamed and reused for both.

http://reviews.llvm.org/D17369

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

Index: test/OpenMP/target_exit_data_codegen.cpp
===
--- /dev/null
+++ test/OpenMP/target_exit_data_codegen.cpp
@@ -0,0 +1,221 @@
+// expected-no-diagnostics
+#ifndef HEADER
+#define HEADER
+
+///==///
+// RUN: %clang_cc1 -DCK1 -verify -fopenmp -omptargets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck %s --check-prefix CK1 --check-prefix CK1-64
+// RUN: %clang_cc1 -DCK1 -fopenmp -omptargets=powerpc64le-ibm-linux-gnu -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -omptargets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s  --check-prefix CK1 --check-prefix CK1-64
+// RUN: %clang_cc1 -DCK1 -verify -fopenmp -omptargets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck %s  --check-prefix CK1 --check-prefix CK1-32
+// RUN: %clang_cc1 -DCK1 -fopenmp -omptargets=i386-pc-linux-gnu -x c++ -std=c++11 -triple i386-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -omptargets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s  --check-prefix CK1 --check-prefix CK1-32
+#ifdef CK1
+
+// CK1: [[ST:%.+]] = type { i32, double* }
+template 
+struct ST {
+  T a;
+  double *b;
+};
+
+ST gb;
+double gc[100];
+
+// CK1: [[SIZE00:@.+]] = {{.+}}constant [1 x i[[sz:64|32]]] [i{{64|32}} 800]
+// CK1: [[MTYPE00:@.+]] = {{.+}}constant [1 x i32] [i32 2]
+
+// CK1: [[SIZE02:@.+]] = {{.+}}constant [1 x i[[sz]]] [i[[sz]] 4]
+// CK1: [[MTYPE02:@.+]] = {{.+}}constant [1 x i32] [i32 8]
+
+// CK1: [[MTYPE03:@.+]] = {{.+}}constant [1 x i32] [i32 6]
+
+// CK1: [[SIZE04:@.+]] = {{.+}}constant [2 x i[[sz]]] [i[[sz]] {{8|4}}, i[[sz]] 24]
+// CK1: [[MTYPE04:@.+]] = {{.+}}constant [2 x i32] [i32 8, i32 104]
+
+// CK1-LABEL: _Z3fooi
+void foo(int arg) {
+  int la;
+  float lb[arg];
+
+  // Region 00
+  // CK1-NOT: __tgt_target_data_begin
+  // CK1-DAG: call void @__tgt_target_data_end(i32 [[DEV:%[^,]+]], i32 1, i8** [[GEPBP:%.+]], i8** [[GEPP:%.+]], {{.+}}getelementptr {{.+}}[1 x i{{.+}}]* [[SIZE00]], {{.+}}getelementptr {{.+}}[1 x i{{.+}}]* [[MTYPE00]]{{.+}})
+  // CK1-DAG: [[DEV]] = load i32, i32* %{{[^,]+}},
+  // CK1-DAG: [[GEPBP]] = getelementptr inbounds {{.+}}[[BP:%[^,]+]]
+  // CK1-DAG: [[GEPP]] = getelementptr inbounds {{.+}}[[P:%[^,]+]]
+
+  // CK1-DAG: [[BP0:%.+]] = getelementptr inbounds {{.+}}[[BP]], i{{.+}} 0, i{{.+}} 0
+  // CK1-DAG: [[P0:%.+]] = getelementptr inbounds {{.+}}[[P]], i{{.+}} 0, i{{.+}} 0
+  // CK1-DAG: store i8* bitcast ([100 x double]* @gc to i8*), i8** [[BP0]]
+  // CK1-DAG: store i8* bitcast ([100 x double]* @gc to i8*), i8** [[P0]]
+
+  // CK1: %{{.+}} = add nsw i32 %{{[^,]+}}, 1
+  #pragma omp target exit data if(1+3-5) device(arg) map(from: gc)
+  {++arg;}
+
+  // Region 01
+  // CK1: %{{.+}} = add nsw i32 %{{[^,]+}}, 1
+  #pragma omp target exit data map(release: la) if(1+3-4)
+  {++arg;}
+
+  // Region 02
+  // CK1-NOT: __tgt_target_data_begin
+  // CK1: br i1 %{{[^,]+}}, label %[[IFTHEN:[^,]+]], label %[[IFELSE:[^,]+]]
+  // CK1: [[IFTHEN]]
+  // CK1-DAG: call void @__tgt_target_data_end(i32 4, i32 1, i8** [[GEPBP:%.+]], i8** [[GEPP:%.+]], {{.+}}getelementptr {{.+}}[1 x i{{.+}}]* [[SIZE02]], {{.+}}getelementptr {{.+}}[1 x i{{.+}}]* [[MTYPE02]]{{.+}})
+  // CK1-DAG: [[GEPBP]] = getelementptr inbounds {{.+}}[[BP:%[^,]+]]
+  // CK1-DAG: [[GEPP]] = getelementptr inbounds {{.+}}[[P:%[^,]+]]
+
+  // CK1-DAG: [[BP0:%.+]] = getelementptr inbounds {{.+}}[[BP]], i{{.+}} 0, i{{.+}} 0
+  // CK1-DAG: [[P0:%.+]] = getelementptr inbounds {{.+}}[[P]], i{{.+}} 0, i{{.+}} 0
+  // CK1-DAG: store i8* [[CBPVAL0:%[^,]+]], i8** [[BP0]]
+  // CK1-DAG: store i8* [[CPVAL0:%[^,]+]], i8** [[P0]]
+  // CK1-DAG: [[CBPVAL0]] = bitcast i32* [[VAR0:%.+]] to i8*
+  // CK1-DAG: [[CPVAL0]] = bitcast i32* [[VAR0]] to i8*
+  // CK1: br label %[[IFEND:[^,]+]]
+
+  // CK1: [[IFELSE]]
+  // CK1: br label %[[IFEND]]
+  // CK1: [[IFEND]]
+  // CK1: %{{.+}} = add nsw i32 %{{[^,]+}}, 1
+  #pragma omp target exit data map(release: arg) if(arg) device(4)
+  {++arg;}
+
+  // CK1: %{{.+}} = 

Re: [PATCH] D16821: Add whole-program vtable optimization feature to Clang.

2016-02-17 Thread Peter Collingbourne via cfe-commits
pcc added a reviewer: rsmith.
pcc added a comment.

Hi Richard, can you take a look please?


http://reviews.llvm.org/D16821



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


[PATCH] D17368: [OpenMP] Code generation for target enter data directive

2016-02-17 Thread Samuel Antao via cfe-commits
sfantao created this revision.
sfantao added reviewers: ABataev, hfinkel, carlo.bertolli, arpith-jacob, kkwli0.
sfantao added subscribers: caomhin, fraggamuffin, cfe-commits.

This patch adds support for the target enter data directive code generation.

http://reviews.llvm.org/D17368

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

Index: test/OpenMP/target_enter_data_codegen.cpp
===
--- /dev/null
+++ test/OpenMP/target_enter_data_codegen.cpp
@@ -0,0 +1,221 @@
+// expected-no-diagnostics
+#ifndef HEADER
+#define HEADER
+
+///==///
+// RUN: %clang_cc1 -DCK1 -verify -fopenmp -omptargets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck %s --check-prefix CK1 --check-prefix CK1-64
+// RUN: %clang_cc1 -DCK1 -fopenmp -omptargets=powerpc64le-ibm-linux-gnu -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -omptargets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s  --check-prefix CK1 --check-prefix CK1-64
+// RUN: %clang_cc1 -DCK1 -verify -fopenmp -omptargets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck %s  --check-prefix CK1 --check-prefix CK1-32
+// RUN: %clang_cc1 -DCK1 -fopenmp -omptargets=i386-pc-linux-gnu -x c++ -std=c++11 -triple i386-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -omptargets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s  --check-prefix CK1 --check-prefix CK1-32
+#ifdef CK1
+
+// CK1: [[ST:%.+]] = type { i32, double* }
+template 
+struct ST {
+  T a;
+  double *b;
+};
+
+ST gb;
+double gc[100];
+
+// CK1: [[SIZE00:@.+]] = {{.+}}constant [1 x i[[sz:64|32]]] [i{{64|32}} 800]
+// CK1: [[MTYPE00:@.+]] = {{.+}}constant [1 x i32] zeroinitializer
+
+// CK1: [[SIZE02:@.+]] = {{.+}}constant [1 x i[[sz]]] [i[[sz]] 4]
+// CK1: [[MTYPE02:@.+]] = {{.+}}constant [1 x i32] [i32 1]
+
+// CK1: [[MTYPE03:@.+]] = {{.+}}constant [1 x i32] [i32 5]
+
+// CK1: [[SIZE04:@.+]] = {{.+}}constant [2 x i[[sz]]] [i[[sz]] {{8|4}}, i[[sz]] 24]
+// CK1: [[MTYPE04:@.+]] = {{.+}}constant [2 x i32] [i32 1, i32 97]
+
+// CK1-LABEL: _Z3fooi
+void foo(int arg) {
+  int la;
+  float lb[arg];
+
+  // Region 00
+  // CK1-DAG: call void @__tgt_target_data_begin(i32 [[DEV:%[^,]+]], i32 1, i8** [[GEPBP:%.+]], i8** [[GEPP:%.+]], {{.+}}getelementptr {{.+}}[1 x i{{.+}}]* [[SIZE00]], {{.+}}getelementptr {{.+}}[1 x i{{.+}}]* [[MTYPE00]]{{.+}})
+  // CK1-DAG: [[DEV]] = load i32, i32* %{{[^,]+}},
+  // CK1-DAG: [[GEPBP]] = getelementptr inbounds {{.+}}[[BP:%[^,]+]]
+  // CK1-DAG: [[GEPP]] = getelementptr inbounds {{.+}}[[P:%[^,]+]]
+
+  // CK1-DAG: [[BP0:%.+]] = getelementptr inbounds {{.+}}[[BP]], i{{.+}} 0, i{{.+}} 0
+  // CK1-DAG: [[P0:%.+]] = getelementptr inbounds {{.+}}[[P]], i{{.+}} 0, i{{.+}} 0
+  // CK1-DAG: store i8* bitcast ([100 x double]* @gc to i8*), i8** [[BP0]]
+  // CK1-DAG: store i8* bitcast ([100 x double]* @gc to i8*), i8** [[P0]]
+
+  // CK1: %{{.+}} = add nsw i32 %{{[^,]+}}, 1
+  // CK1-NOT: __tgt_target_data_end
+  #pragma omp target enter data if(1+3-5) device(arg) map(alloc: gc)
+  {++arg;}
+
+  // Region 01
+  // CK1: %{{.+}} = add nsw i32 %{{[^,]+}}, 1
+  #pragma omp target enter data map(to: la) if(1+3-4)
+  {++arg;}
+
+  // Region 02
+  // CK1: br i1 %{{[^,]+}}, label %[[IFTHEN:[^,]+]], label %[[IFELSE:[^,]+]]
+  // CK1: [[IFTHEN]]
+  // CK1-DAG: call void @__tgt_target_data_begin(i32 4, i32 1, i8** [[GEPBP:%.+]], i8** [[GEPP:%.+]], {{.+}}getelementptr {{.+}}[1 x i{{.+}}]* [[SIZE02]], {{.+}}getelementptr {{.+}}[1 x i{{.+}}]* [[MTYPE02]]{{.+}})
+  // CK1-DAG: [[GEPBP]] = getelementptr inbounds {{.+}}[[BP:%[^,]+]]
+  // CK1-DAG: [[GEPP]] = getelementptr inbounds {{.+}}[[P:%[^,]+]]
+
+  // CK1-DAG: [[BP0:%.+]] = getelementptr inbounds {{.+}}[[BP]], i{{.+}} 0, i{{.+}} 0
+  // CK1-DAG: [[P0:%.+]] = getelementptr inbounds {{.+}}[[P]], i{{.+}} 0, i{{.+}} 0
+  // CK1-DAG: store i8* [[CBPVAL0:%[^,]+]], i8** [[BP0]]
+  // CK1-DAG: store i8* [[CPVAL0:%[^,]+]], i8** [[P0]]
+  // CK1-DAG: [[CBPVAL0]] = bitcast i32* [[VAR0:%.+]] to i8*
+  // CK1-DAG: [[CPVAL0]] = bitcast i32* [[VAR0]] to i8*
+  // CK1: br label %[[IFEND:[^,]+]]
+
+  // CK1: [[IFELSE]]
+  // CK1: br label %[[IFEND]]
+  // CK1: [[IFEND]]
+  // CK1: %{{.+}} = add nsw i32 %{{[^,]+}}, 1
+  // CK1-NOT: __tgt_target_data_end
+  #pragma omp target enter data map(to: arg) if(arg) device(4)
+  {++arg;}
+
+  // CK1: %{{.+}} = add nsw i32 %{{[^,]+}}, 1
+  {++arg;}
+
+  // Region 03
+  // CK1-DAG: call void @__tgt_target_data_begin(i32 -1, i32 1, i8** [[GEPBP:%.+]], i8** [[GEPP:%.+]], i[[sz]]* [[GEPS:%.+]], 

[PATCH] D17367: [OpenMP] Code generation for target data directive

2016-02-17 Thread Samuel Antao via cfe-commits
sfantao created this revision.
sfantao added reviewers: ABataev, hfinkel, carlo.bertolli, arpith-jacob, kkwli0.
sfantao added subscribers: caomhin, fraggamuffin, cfe-commits.

This patch adds support for the target data directive code generation.

Part of the already existent functionality related with data maps is moved to a 
new function so that it could be reused. 

http://reviews.llvm.org/D17367

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

Index: test/OpenMP/target_data_codegen.cpp
===
--- /dev/null
+++ test/OpenMP/target_data_codegen.cpp
@@ -0,0 +1,248 @@
+// expected-no-diagnostics
+#ifndef HEADER
+#define HEADER
+
+///==///
+// RUN: %clang_cc1 -DCK1 -verify -fopenmp -omptargets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck %s --check-prefix CK1 --check-prefix CK1-64
+// RUN: %clang_cc1 -DCK1 -fopenmp -omptargets=powerpc64le-ibm-linux-gnu -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -omptargets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s  --check-prefix CK1 --check-prefix CK1-64
+// RUN: %clang_cc1 -DCK1 -verify -fopenmp -omptargets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck %s  --check-prefix CK1 --check-prefix CK1-32
+// RUN: %clang_cc1 -DCK1 -fopenmp -omptargets=i386-pc-linux-gnu -x c++ -std=c++11 -triple i386-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -omptargets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s  --check-prefix CK1 --check-prefix CK1-32
+#ifdef CK1
+
+// CK1: [[ST:%.+]] = type { i32, double* }
+template 
+struct ST {
+  T a;
+  double *b;
+};
+
+ST gb;
+double gc[100];
+
+// CK1: [[SIZE00:@.+]] = {{.+}}constant [1 x i[[sz:64|32]]] [i{{64|32}} 800]
+// CK1: [[MTYPE00:@.+]] = {{.+}}constant [1 x i32] [i32 2]
+
+// CK1: [[SIZE02:@.+]] = {{.+}}constant [1 x i[[sz]]] [i[[sz]] 4]
+// CK1: [[MTYPE02:@.+]] = {{.+}}constant [1 x i32] [i32 1]
+
+// CK1: [[MTYPE03:@.+]] = {{.+}}constant [1 x i32] [i32 5]
+
+// CK1: [[SIZE04:@.+]] = {{.+}}constant [2 x i[[sz]]] [i[[sz]] {{8|4}}, i[[sz]] 24]
+// CK1: [[MTYPE04:@.+]] = {{.+}}constant [2 x i32] [i32 1, i32 97]
+
+// CK1-LABEL: _Z3fooi
+void foo(int arg) {
+  int la;
+  float lb[arg];
+
+  // Region 00
+  // CK1-DAG: call void @__tgt_target_data_begin(i32 [[DEV:%[^,]+]], i32 1, i8** [[GEPBP:%.+]], i8** [[GEPP:%.+]], {{.+}}getelementptr {{.+}}[1 x i{{.+}}]* [[SIZE00]], {{.+}}getelementptr {{.+}}[1 x i{{.+}}]* [[MTYPE00]]{{.+}})
+  // CK1-DAG: [[DEV]] = load i32, i32* %{{[^,]+}},
+  // CK1-DAG: [[GEPBP]] = getelementptr inbounds {{.+}}[[BP:%[^,]+]]
+  // CK1-DAG: [[GEPP]] = getelementptr inbounds {{.+}}[[P:%[^,]+]]
+
+  // CK1-DAG: [[BP0:%.+]] = getelementptr inbounds {{.+}}[[BP]], i{{.+}} 0, i{{.+}} 0
+  // CK1-DAG: [[P0:%.+]] = getelementptr inbounds {{.+}}[[P]], i{{.+}} 0, i{{.+}} 0
+  // CK1-DAG: store i8* bitcast ([100 x double]* @gc to i8*), i8** [[BP0]]
+  // CK1-DAG: store i8* bitcast ([100 x double]* @gc to i8*), i8** [[P0]]
+
+  // CK1: %{{.+}} = add nsw i32 %{{[^,]+}}, 1
+
+  // CK1-DAG: call void @__tgt_target_data_end(i32 [[DEV:%[^,]+]], i32 1, i8** [[GEPBP:%.+]], i8** [[GEPP:%.+]], {{.+}}getelementptr {{.+}}[1 x i{{.+}}]* [[SIZE00]], {{.+}}getelementptr {{.+}}[1 x i{{.+}}]* [[MTYPE00]]{{.+}})
+  // CK1-DAG: [[DEV]] = load i32, i32* %{{[^,]+}},
+  // CK1-DAG: [[GEPBP]] = getelementptr inbounds {{.+}}[[BP]]
+  // CK1-DAG: [[GEPP]] = getelementptr inbounds {{.+}}[[P]]
+  #pragma omp target data if(1+3-5) device(arg) map(from: gc)
+  {++arg;}
+
+  // Region 01
+  // CK1: %{{.+}} = add nsw i32 %{{[^,]+}}, 1
+  #pragma omp target data map(la) if(1+3-4)
+  {++arg;}
+
+  // Region 02
+  // CK1: br i1 %{{[^,]+}}, label %[[IFTHEN:[^,]+]], label %[[IFELSE:[^,]+]]
+  // CK1: [[IFTHEN]]
+  // CK1-DAG: call void @__tgt_target_data_begin(i32 4, i32 1, i8** [[GEPBP:%.+]], i8** [[GEPP:%.+]], {{.+}}getelementptr {{.+}}[1 x i{{.+}}]* [[SIZE02]], {{.+}}getelementptr {{.+}}[1 x i{{.+}}]* [[MTYPE02]]{{.+}})
+  // CK1-DAG: [[GEPBP]] = getelementptr inbounds {{.+}}[[BP:%[^,]+]]
+  // CK1-DAG: [[GEPP]] = getelementptr inbounds {{.+}}[[P:%[^,]+]]
+
+  // CK1-DAG: [[BP0:%.+]] = getelementptr inbounds {{.+}}[[BP]], i{{.+}} 0, i{{.+}} 0
+  // CK1-DAG: [[P0:%.+]] = getelementptr inbounds {{.+}}[[P]], i{{.+}} 0, i{{.+}} 0
+  // CK1-DAG: store i8* [[CBPVAL0:%[^,]+]], i8** [[BP0]]
+  // CK1-DAG: store i8* [[CPVAL0:%[^,]+]], i8** [[P0]]
+  // CK1-DAG: [[CBPVAL0]] = bitcast i32* [[VAR0:%.+]] to i8*
+  // CK1-DAG: [[CPVAL0]] = bitcast i32* [[VAR0]] to i8*
+  // CK1: br label %[[IFEND:[^,]+]]
+
+  // 

Re: [libcxx] r260012 - Cleanup node-type handling in the unordered containers

2016-02-17 Thread Eric Fiselier via cfe-commits
> How big a maintenance burden is it?  Is there a way to reduce the burden?

It's actually not *that* big of a maintenance burden because it's mostly
just a shallow wrapper around <__hash_table>.

What's been frustrating me is that there were *NO TESTS*. So modifying
<__hash_table> is a stab in the dark. I checked in a "breathing" tests
in r261181. Hopefully
that will help a bit.

/Eric

On Mon, Feb 15, 2016 at 5:26 PM, Duncan P. N. Exon Smith <
dexonsm...@apple.com> wrote:

>
> > On 2016-Feb-10, at 19:10, Marshall Clow  wrote:
> >
> > On Wed, Feb 10, 2016 at 2:46 PM, Duncan P. N. Exon Smith via cfe-commits
>  wrote:
> > I'm hoping only a year or two (or three...)?
> >
> > As I pointed out to Eric on IRC, those files have had a "deprecation
> warning" every time they are included ... since 2010.
>
> Yes, anyone that has already transitioned to libc++ has no excuse.  They
> should just stop using ext/hash_map.
>
> Unfortunately we also ship this:
>
> http://www.opensource.apple.com/source/libstdcxx/libstdcxx-104.1/include/c++/4.2.1/ext/hash_map
>
> ^ It doesn't have any such #warning.  Keeping ext/hash_map around makes it
> easier to transition people over to libc++.
>
> How big a maintenance burden is it?  Is there a way to reduce the burden?
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17349: ARM: fix VFP asm constraints

2016-02-17 Thread Saleem Abdulrasool via cfe-commits
compnerd added a subscriber: compnerd.
compnerd added a comment.

Test cases?  It seems that 't' and 'w' are not available in thumb-1 mode.


http://reviews.llvm.org/D17349



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


Re: [libcxx] r260431 - Recommit r260012 - Cleanup node-type handling in the unordered containers.

2016-02-17 Thread Eric Fiselier via cfe-commits
Hopefully fixed in r261180.

On Sat, Feb 13, 2016 at 2:08 PM, Evgenii Stepanov  wrote:

> Hi,
>
> this is my error message:
>
> In file included from z.cc:1:
> /code/build-llvm/bin/../include/c++/v1/ext/hash_map:213:5: warning:
> Use of the header  is deprecated. Migrate to
>  [-W#warnings]
> #   warning Use of the header  is deprecated.  Migrate
> to 
> ^
> /code/build-llvm/bin/../include/c++/v1/ext/hash_map:432:57: error:
> '__non_const_iterator' is a private member of
>
> 'std::__1::__hash_const_iterator int>, void *> *>'
> __hash_map_iterator _HashIterator::__non_const_iterator> __i)
> ^
> /code/build-llvm/bin/../include/c++/v1/ext/hash_map:659:16: note: in
> instantiation of template class
>
> '__gnu_cxx::__hash_map_const_iterator int>, void *> *> >' requested here
> insert(__u.begin(), __u.end());
>^
> z.cc:4:16: note: in instantiation of member function
> '__gnu_cxx::hash_map std::__1::equal_to, std::__1::allocator > >::hash_map' requested here
> template class hash_map;
>^
> /code/build-llvm/bin/../include/c++/v1/__hash_table:383:39: note:
> implicitly declared private here
> typedef __hash_iterator<_NodePtr> __non_const_iterator;
>   ^
> 1 warning and 1 error generated.
>
>
> and this is my test case:
>
> #include 
>
> namespace __gnu_cxx {
> template class hash_map;
> }
>
>
> On Sat, Feb 13, 2016 at 12:17 AM, Eric Fiselier  wrote:
> >> The "hash_map" part of the name means they belong to "",
> >> and the actual type is defined in that header.
> >
> > Woops, Sorry I guess the name is used in both "std::__1::" in
> unordered_map
> > and "__gnu_cxx::" in . My intention in the changes was to
> > forward declare "std::__1::__hash_map_iterator".
> >
> > On Sat, Feb 13, 2016 at 1:11 AM, Eric Fiselier  wrote:
> >>
> >> > hash_map still looks broken to me.
> >>
> >> Uh oh, Sorry :-S. The original breakage was caused by the removal of a
> >> typedef "hash_map" used, but I'm sure I fixed that.
> >>
> >> > should not they be prefixed with __gnu_cxx:: ?
> >>
> >> No, they are in the correct namespace. The "hash_map" part of the name
> >> means they belong to "", and the actual type is defined
> in
> >> that header.
> >>
> >> Could you give me more information about the breakage your seeing? The
> >> actual compiler diagnostics if possible? I also committed other sizable
> >> changes to <__hash_table> in r260513 so that may be related.
> >>
> >> Let me know if you need this reverted. If possible I would like to hold
> >> off, at least until more is known.
> >>
> >> /Eric
> >>
> >> On Fri, Feb 12, 2016 at 1:31 PM, Evgenii Stepanov
> >>  wrote:
> >>>
> >>> Hi,
> >>>
> >>> hash_map still looks broken to me.
> >>> I don't have a simple reproducer, but these declarations in
> __hash_table:
> >>>
> >>> template  class _LIBCPP_TYPE_VIS_ONLY
> >>> __hash_map_iterator;
> >>>  template  class _LIBCPP_TYPE_VIS_ONLY
> >>> __hash_map_const_iterator;
> >>>
> >>> should not they be prefixed with __gnu_cxx:: ?
> >>>
> >>> Clang says that std::__1::__hash_const_iterator and
> >>> __gnu_cxx::__hash_map_const_iterator are not friends and
> >>> __non_const_iterator at ext/hash_map:432 is private.
> >>>
> >>>
> >>> On Wed, Feb 10, 2016 at 12:46 PM, Eric Fiselier via cfe-commits
> >>>  wrote:
> >>> > Author: ericwf
> >>> > Date: Wed Feb 10 14:46:23 2016
> >>> > New Revision: 260431
> >>> >
> >>> > URL: http://llvm.org/viewvc/llvm-project?rev=260431=rev
> >>> > Log:
> >>> > Recommit r260012 - Cleanup node-type handling in the unordered
> >>> > containers.
> >>> >
> >>> > This time I kept  working!
> >>> >
> >>> > This patch is the first in a series of patches that's meant to better
> >>> > support unordered_map. unordered_map has a special "value_type" that
> >>> > differs from pair. In order to meet the
> >>> > EmplaceConstructible
> >>> > and CopyInsertable requirements we need to teach __hash_table about
> >>> > this
> >>> > special value_type.
> >>> >
> >>> > This patch creates a "__hash_node_types" traits class that contains
> >>> > all of the typedefs needed by the unordered containers and it's
> >>> > iterators.
> >>> > These typedefs include ones for each node type and  node pointer
> type,
> >>> > as well as special typedefs for "unordered_map"'s value type.
> >>> >
> >>> > As a result of this change all of the unordered containers now all
> >>> > support
> >>> > incomplete types.
> >>> >
> >>> > As a drive-by fix I changed the difference_type in __hash_table to
> >>> > always
> >>> > be ptrdiff_t. There is a corresponding change to size_type but it
> >>> > cannot
> >>> > 

Re: [libcxx] r260514 - Teach __hash_table how to handle unordered_map's __hash_value_type.

2016-02-17 Thread Eric Fiselier via cfe-commits
On Feb 14, 2016 2:02 PM, "Duncan P. N. Exon Smith" 
wrote:

> (For anyone else trying to line up this commit message with the
> patch: it looks like this message is a dup of r260513, and this
> patch is one of its described follow-ups:
>
> > On 2016-Feb-11, at 04:25, Eric Fiselier via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
> >
> > The following changes are planed for future revisions:
> >
> >  * Fix LWG issue #2469 by delegating 'unordered_map::operator[]' to use
> >'__emplace_unique_key_args'.
>
> ^ This one.)


Thanks Duncan. FYI I reverted and recommitted this with a meaningful commit
message in r260601.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r259874 - CodeGen: correct Windows ARM C++ assertion

2016-02-17 Thread Saleem Abdulrasool via cfe-commits
On Wed, Feb 17, 2016 at 1:33 PM, Hans Wennborg  wrote:

> On Wed, Feb 17, 2016 at 8:55 AM, Hans Wennborg  wrote:
> > On Tue, Feb 16, 2016 at 9:03 PM, Saleem Abdulrasool
> >  wrote:
> >> On Thu, Feb 4, 2016 at 8:12 PM, Saleem Abdulrasool via cfe-commits
> >>  wrote:
> >>>
> >>> Author: compnerd
> >>> Date: Thu Feb  4 22:12:40 2016
> >>> New Revision: 259874
> >>>
> >>> URL: http://llvm.org/viewvc/llvm-project?rev=259874=rev
> >>> Log:
> >>> CodeGen: correct Windows ARM C++ assertion
> >>
> >>
> >> Id like to merge this to the 3.8 release.  It only effects Windows ARM
> code
> >> generation, so should be quite safe.
> >
> > Sounds good to me. Go ahead and merge with utils/release/merge.sh, or
> > let me know if you'd prefer me to do it.
>
> Merged in r261158.
>

Thanks!

-- 
Saleem Abdulrasool
compnerd (at) compnerd (dot) org
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17170: [OPENMP] Codegen for distribute directive

2016-02-17 Thread Carlo Bertolli via cfe-commits
carlo.bertolli updated this revision to Diff 48273.
carlo.bertolli added a comment.

Update to new version of http://reviews.llvm.org/D17148, integrating changes 
from the trunk.


Repository:
  rL LLVM

http://reviews.llvm.org/D17170

Files:
  include/clang/AST/StmtOpenMP.h
  lib/CodeGen/CGOpenMPRuntime.cpp
  lib/CodeGen/CGOpenMPRuntime.h
  lib/CodeGen/CGStmtOpenMP.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/Serialization/ASTReaderStmt.cpp
  lib/Serialization/ASTWriterStmt.cpp
  test/OpenMP/distribute_codegen.cpp

Index: test/OpenMP/distribute_codegen.cpp
===
--- /dev/null
+++ test/OpenMP/distribute_codegen.cpp
@@ -0,0 +1,239 @@
+// Test host codegen.
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -omptargets=powerpc64le-ibm-linux-gnu -emit-llvm %s -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-64
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -omptargets=powerpc64le-ibm-linux-gnu -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -x c++ -triple powerpc64le-unknown-unknown -omptargets=powerpc64le-ibm-linux-gnu -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-64  --check-prefix HCHECK
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple i386-unknown-unknown -omptargets=i386-pc-linux-gnu -emit-llvm %s -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-32  --check-prefix HCHECK
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple i386-unknown-unknown -omptargets=i386-pc-linux-gnu -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -x c++ -triple i386-unknown-unknown -omptargets=i386-pc-linux-gnu -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-32 --check-prefix HCHECK
+
+// Test target codegen - host bc file has to be created first. (no significant differences with host version of target region)
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -omptargets=powerpc64le-ibm-linux-gnu -emit-llvm-bc %s -o %t-ppc-host.bc
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -omptargets=powerpc64le-ibm-linux-gnu -emit-llvm %s -fopenmp-is-device -omp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -omptargets=powerpc64le-ibm-linux-gnu -emit-pch -fopenmp-is-device -omp-host-ir-file-path %t-ppc-host.bc -o %t %s
+// RUN: %clang_cc1 -fopenmp -x c++ -triple powerpc64le-unknown-unknown -omptargets=powerpc64le-ibm-linux-gnu -std=c++11 -fopenmp-is-device -omp-host-ir-file-path %t-ppc-host.bc -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple i386-unknown-unknown -omptargets=i386-pc-linux-gnu -emit-llvm-bc %s -o %t-x86-host.bc
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple i386-unknown-unknown -omptargets=i386-pc-linux-gnu -emit-llvm %s -fopenmp-is-device -omp-host-ir-file-path %t-x86-host.bc -o - | FileCheck %s
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple i386-unknown-unknown -omptargets=i386-pc-linux-gnu -emit-pch -fopenmp-is-device -omp-host-ir-file-path %t-x86-host.bc -o %t %s
+// RUN: %clang_cc1 -fopenmp -x c++ -triple i386-unknown-unknown -omptargets=i386-pc-linux-gnu -std=c++11 -fopenmp-is-device -omp-host-ir-file-path %t-x86-host.bc -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
+
+// expected-no-diagnostics
+#ifndef HEADER
+#define HEADER
+
+// CHECK-DAG: %ident_t = type { i32, i32, i32, i32, i8* }
+// CHECK-DAG: [[STR:@.+]] = private unnamed_addr constant [23 x i8] c";unknown;unknown;0;0;;\00"
+// CHECK-DAG: [[DEF_LOC_0:@.+]] = private unnamed_addr constant %ident_t { i32 0, i32 2, i32 0, i32 0, i8* getelementptr inbounds ([23 x i8], [23 x i8]* [[STR]], i32 0, i32 0) }
+
+// CHECK-LABEL: define {{.*void}} @{{.*}}without_schedule_clause{{.*}}(float* {{.+}}, float* {{.+}}, float* {{.+}}, float* {{.+}})
+void without_schedule_clause(float *a, float *b, float *c, float *d) {
+  #pragma omp target
+  #pragma omp teams
+  #pragma omp distribute
+  for (int i = 33; i < 3200; i += 7) {
+a[i] = b[i] * c[i] * d[i];
+  }
+}
+
+// CHECK: define {{.*}}void @.omp_outlined.(i32* noalias [[GBL_TIDP:%.+]], i32* noalias [[BND_TID:%.+]], float** dereferenceable({{[0-9]+}}) [[APTR:%.+]], float** dereferenceable({{[0-9]+}}) [[BPTR:%.+]], float** dereferenceable({{[0-9]+}}) [[CPTR:%.+]], float** dereferenceable({{[0-9]+}}) [[DPTR:%.+]])
+// CHECK:  [[TID_ADDR:%.+]] = alloca i32*
+// CHECK:  [[IV:%.+iv]] = alloca i32
+// CHECK:  [[LB:%.+lb]] = alloca i32
+// CHECK:  [[UB:%.+ub]] = alloca i32
+// CHECK:  [[ST:%.+stride]] = alloca i32
+// CHECK:  [[LAST:%.+last]] = alloca i32
+// CHECK-DAG:  store i32* [[GBL_TIDP]], i32** [[TID_ADDR]]
+// CHECK-DAG:  store i32 0, i32* [[LB]]
+// CHECK-DAG:  store i32 4571423, i32* [[UB]]
+// CHECK-DAG: 

Re: [PATCH] D15883: Add ARM EHABI-related constants to unwind.h.

2016-02-17 Thread Saleem Abdulrasool via cfe-commits
compnerd added inline comments.


Comment at: lib/Headers/unwind.h:61
@@ +60,3 @@
+#define _UNWIND_ARM_EHABI 0
+#endif
+

logan wrote:
> compnerd wrote:
> > logan wrote:
> > > Since this is `unwind.h`, I feel that we can get a step further and use 
> > > `__ARM_EABI_UNWINDER__` to get more compatibility to GCC's unwind.h.
> > > 
> > > Here's the change:
> > > 
> > > ```
> > > #if defined(__arm__) && !defined(__USING_SJLJ_EXCEPTIONS__) && \
> > > !defined(__ARM_DWARF_EH__)
> > > #define __ARM_EABI_UNWINDER__ 1
> > > #endif
> > > ```
> > I dont know if we really need to imitate GCC's macros here.  Am I mistaken 
> > in that they assume that `__ARM_EABI_UNWINDER__` has been set to 1 
> > externally if targeting such an environment?  I think that it is better to 
> > use the reserved namespace and intrude into libunwind's namespace as 
> > already done here.
> > Am I mistaken in that they assume that `__ARM_EABI_UNWINDER__` has been set 
> > to 1 externally if targeting such an environment?
> 
> Although this is an implementation detail, it was defined by `unwind.h` in 
> the implementation of GCC.
> 
> Remark: `__ARM_EABI_UNWINDER__` is not a pre-defined macro in GCC and Clang 
> (can be checked with ` gcc -dM -E - < /dev/null`.)
> 
> BTW, some applications or libraries need this macro to be defined after 
> including `` (such as uclibc, boost, or libc++abi 3.0.)  I 
> remembered that someone suggested to use `__ARM_EABI_UNWINDER__` instead of  
> `LIBCXXABI_ARM_EHABI` when I was fixing libc++abi several years ago.  I chose 
> `LIBCXXABI_ARM_EHABI` simply because `__ARM_EABI_UNWINDER__` wasn't provided 
> by clang at that time.
> 
> I am less concerned to namespace pollution, because this is already the de 
> facto implementation in GCC world and the macro names start with underscores 
> are reserved for compiler or standard libraries by convention.
> 
> Since this is file a public header and will be used for a long time, I 
> personally believe that it will be better to use an existing name with the 
> same meaning instead of introducing a new name.  In addition, this will make 
> it easier to port the application between gcc and clang.
I just checked, libc++abi has no use of this macro, nor does boost 1.60.  
uclibc only defines `__ARM_EABI_UNWINDER__`, but does not use it.  I also 
checked glibc and musl, and glibc like uclibc defines it while musl has no 
references to it.  This is injecting itself into the compiler namespace and is 
misleading, so I think I would really rather prefer the current patch as is.


http://reviews.llvm.org/D15883



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


Re: [PATCH] D17148: [OPENMP] Basic teams directive implementation

2016-02-17 Thread Carlo Bertolli via cfe-commits
carlo.bertolli updated this revision to Diff 48271.
carlo.bertolli added a comment.

Update against dependence http://reviews.llvm.org/D17019.


Repository:
  rL LLVM

http://reviews.llvm.org/D17148

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

Index: test/OpenMP/teams_codegen.cpp
===
--- test/OpenMP/teams_codegen.cpp
+++ test/OpenMP/teams_codegen.cpp
@@ -208,4 +208,142 @@
 
 }
 #endif // CK3
+
+// Test target codegen - host bc file has to be created first.
+// RUN: %clang_cc1 -DCK4 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -omptargets=powerpc64le-ibm-linux-gnu -emit-llvm-bc %s -o %t-ppc-host.bc
+// RUN: %clang_cc1 -DCK4 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -omptargets=powerpc64le-ibm-linux-gnu -emit-llvm %s -fopenmp-is-device -omp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s --check-prefix CK4 --check-prefix CK4-64
+// RUN: %clang_cc1 -DCK4 -fopenmp -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -omptargets=powerpc64le-ibm-linux-gnu -emit-pch -fopenmp-is-device -omp-host-ir-file-path %t-ppc-host.bc -o %t %s
+// RUN: %clang_cc1 -DCK4 -fopenmp -x c++ -triple powerpc64le-unknown-unknown -omptargets=powerpc64le-ibm-linux-gnu -std=c++11 -fopenmp-is-device -omp-host-ir-file-path %t-ppc-host.bc -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix CK4 --check-prefix CK4-64
+// RUN: %clang_cc1 -DCK4 -verify -fopenmp -x c++ -triple i386-unknown-unknown -omptargets=i386-pc-linux-gnu -emit-llvm-bc %s -o %t-x86-host.bc
+// RUN: %clang_cc1 -DCK4 -verify -fopenmp -x c++ -triple i386-unknown-unknown -omptargets=i386-pc-linux-gnu -emit-llvm %s -fopenmp-is-device -omp-host-ir-file-path %t-x86-host.bc -o - | FileCheck %s --check-prefix CK4 --check-prefix CK4-32
+// RUN: %clang_cc1 -DCK4 -fopenmp -x c++ -std=c++11 -triple i386-unknown-unknown -omptargets=i386-pc-linux-gnu -emit-pch -fopenmp-is-device -omp-host-ir-file-path %t-x86-host.bc -o %t %s
+// RUN: %clang_cc1 -DCK4 -fopenmp -x c++ -triple i386-unknown-unknown -omptargets=i386-pc-linux-gnu -std=c++11 -fopenmp-is-device -omp-host-ir-file-path %t-x86-host.bc -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix CK4 --check-prefix CK4-32
+
+#ifdef CK4
+
+// CK4-DAG: %ident_t = type { i32, i32, i32, i32, i8* }
+// CK4-DAG: [[STR:@.+]] = private unnamed_addr constant [23 x i8] c";unknown;unknown;0;0;;\00"
+// CK4-DAG: [[DEF_LOC_0:@.+]] = private unnamed_addr constant %ident_t { i32 0, i32 2, i32 0, i32 0, i8* getelementptr inbounds ([23 x i8], [23 x i8]* [[STR]], i32 0, i32 0) }
+// CK4-DEBUG-DAG: [[LOC1:@.+]] = private unnamed_addr constant [{{.+}} x i8] c";{{.*}}teams_codegen.cpp;main;[[@LINE+14]];9;;\00"
+// CK4-DEBUG-DAG: [[LOC2:@.+]] = private unnamed_addr constant [{{.+}} x i8] c";{{.*}}teams_codegen.cpp;tmain;[[@LINE+7]];9;;\00"
+
+template 
+int tmain(T argc) {
+#pragma omp target
+#pragma omp teams
+  argc = 0;
+  return 0;
+}
+
+int main (int argc, char **argv) {
+#pragma omp target
+#pragma omp teams
+  argc = 0;
+  return tmain(argv);
+}
+
+// CK4:  define {{.*}}void @{{[^,]+}}(i{{.+}} %[[ARGC:.+]])
+// CK4:  [[ARGCADDR:%.+]] = alloca i{{.+}}
+// CK4:  store i{{.+}} %[[ARGC]], i{{.+}}* [[ARGCADDR]]
+// CK4-64:  [[CONV:%.+]] = bitcast i64* [[ARGCADDR]] to i32*
+// CK4-64:  call {{.*}}void (%ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_teams(%ident_t* [[DEF_LOC_0]], i32 1, void (i32*, i32*, ...)* bitcast (void (i32*, i32*, i32*)* {{.+}} to void (i32*, i32*, ...)*), i32* [[CONV]])
+// CK4-32:  call {{.*}}void (%ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_teams(%ident_t* [[DEF_LOC_0]], i32 1, void (i32*, i32*, ...)* bitcast (void (i32*, i32*, i32*)* {{.+}} to void (i32*, i32*, ...)*), i32* [[ARGCADDR]])
+// CK4:  ret void
+// CK4-NEXT: }
+
+// CK4:  define {{.*}}void @{{[^,]+}}(i8*** dereferenceable({{.}}) [[ARGC1:%.+]])
+// CK4:  [[ARGCADDR1:%.+]] = alloca i8***
+// CK4:  store i8*** [[ARGC1]], i8 [[ARGCADDR1]]
+// CK4:  [[CONV1:%.+]] = load i8***, i8 [[ARGCADDR1]]
+// CK4:  call {{.*}}void (%ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_teams(%ident_t* [[DEF_LOC_0]], i32 1, void (i32*, i32*, ...)* bitcast (void (i32*, i32*, i8***)* {{.+}} to void (i32*, i32*, ...)*), i8*** [[CONV1]])
+
+
+#endif // CK4
+
+// Test target codegen - host bc file has to be created first.
+// RUN: %clang_cc1 -DCK5 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -omptargets=powerpc64le-ibm-linux-gnu -emit-llvm-bc %s -o %t-ppc-host.bc
+// RUN: %clang_cc1 -DCK5 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -omptargets=powerpc64le-ibm-linux-gnu -emit-llvm %s -fopenmp-is-device -omp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s --check-prefix CK5 --check-prefix CK5-64
+// RUN: %clang_cc1 -DCK5 -fopenmp -x c++ -std=c++11 -triple powerpc64le-unknown-unknown 

Re: [PATCH] D17362: [Sema] PR23090 Crash when return type or parameter types for extern "C" functions don't have external linkage

2016-02-17 Thread don hinton via cfe-commits
hintonda added a comment.

This also causes a few other test failures (~8) which will need to be fixed if 
this patch is accepted.


http://reviews.llvm.org/D17362



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


Re: [PATCH] D17362: [Sema] PR23090 Crash when return type or parameter types for extern "C" functions don't have external linkage

2016-02-17 Thread don hinton via cfe-commits
hintonda added a comment.

Here's an example of when this will cause a crash:

namespace {
Struct G;
extern "C" G *f(); // has external linkage
G *f();// will assert since it has internal linkage because of G 
and doesn't match previous declaration
}


http://reviews.llvm.org/D17362



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


[PATCH] D17362: [Sema] PR23090 Crash when return type or parameter types for extern "C" functions don't have external linkage

2016-02-17 Thread don hinton via cfe-commits
hintonda created this revision.
hintonda added reviewers: majnemer, rsmith.
hintonda added a subscriber: cfe-commits.

Added checks to make sure the return type and parameter types for functions
declared as extern "C" have external linkage.

http://reviews.llvm.org/D17362

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaDecl.cpp
  test/Sema/pr23090-crash-on-invalid.cpp

Index: test/Sema/pr23090-crash-on-invalid.cpp
===
--- /dev/null
+++ test/Sema/pr23090-crash-on-invalid.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// Don't crash (PR23090).
+
+namespace {
+
+// check return type
+struct A;
+extern "C" A *foo(); // expected-error {{'foo' has C-linkage specified, but 
return type '(anonymous namespace)::A *' has internal linkage}}
+A *foo();
+
+// check parameter
+struct B;
+extern "C" void bar(B*); // expected-error {{'bar' has C-linkage specified, 
but parameter type '(anonymous namespace)::B *' has internal linkage}}
+void bar(B*);
+
+}
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -8206,6 +8206,25 @@
   Diag(NewFD->getLocation(), diag::ext_out_of_line_declaration)
 << D.getCXXScopeSpec().getRange();
 }
+
+if (NewFD->isExternC()) {
+  // Check return type linkage
+  QualType R = NewFD->getReturnType();
+  if (R.getTypePtr()->getLinkage() != Linkage::ExternalLinkage) {
+Diag(NewFD->getLocation(), diag::err_return_value_linkage)
+  << NewFD << R;
+NewFD->setInvalidDecl();
+  }
+  // Check parameter type linkage
+  for (auto param : NewFD->parameters()) {
+QualType P = param->getOriginalType();
+if (P.getTypePtr()->getLinkage() != Linkage::ExternalLinkage) {
+  Diag(NewFD->getLocation(), diag::err_parameter_value_linkage)
+<< NewFD << P;
+  NewFD->setInvalidDecl();
+}
+  }
+}
   }
 
   ProcessPragmaWeak(S, NewFD);
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -319,6 +319,11 @@
 def warn_unused_private_field: Warning<"private field %0 is not used">,
   InGroup, DefaultIgnore;
 
+def err_return_value_linkage: Error<
+  "%0 has C-linkage specified, but return type %1 has internal linkage">;
+def err_parameter_value_linkage: Error<
+  "%0 has C-linkage specified, but parameter type %1 has internal linkage">;
+
 def warn_parameter_size: Warning<
   "%0 is a large (%1 bytes) pass-by-value argument; "
   "pass it by reference instead ?">, InGroup;


Index: test/Sema/pr23090-crash-on-invalid.cpp
===
--- /dev/null
+++ test/Sema/pr23090-crash-on-invalid.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// Don't crash (PR23090).
+
+namespace {
+
+// check return type
+struct A;
+extern "C" A *foo(); // expected-error {{'foo' has C-linkage specified, but return type '(anonymous namespace)::A *' has internal linkage}}
+A *foo();
+
+// check parameter
+struct B;
+extern "C" void bar(B*); // expected-error {{'bar' has C-linkage specified, but parameter type '(anonymous namespace)::B *' has internal linkage}}
+void bar(B*);
+
+}
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -8206,6 +8206,25 @@
   Diag(NewFD->getLocation(), diag::ext_out_of_line_declaration)
 << D.getCXXScopeSpec().getRange();
 }
+
+if (NewFD->isExternC()) {
+  // Check return type linkage
+  QualType R = NewFD->getReturnType();
+  if (R.getTypePtr()->getLinkage() != Linkage::ExternalLinkage) {
+Diag(NewFD->getLocation(), diag::err_return_value_linkage)
+  << NewFD << R;
+NewFD->setInvalidDecl();
+  }
+  // Check parameter type linkage
+  for (auto param : NewFD->parameters()) {
+QualType P = param->getOriginalType();
+if (P.getTypePtr()->getLinkage() != Linkage::ExternalLinkage) {
+  Diag(NewFD->getLocation(), diag::err_parameter_value_linkage)
+<< NewFD << P;
+  NewFD->setInvalidDecl();
+}
+  }
+}
   }
 
   ProcessPragmaWeak(S, NewFD);
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -319,6 +319,11 @@
 def warn_unused_private_field: Warning<"private field %0 is not used">,
   InGroup, DefaultIgnore;
 
+def err_return_value_linkage: Error<
+  "%0 has C-linkage specified, but return type %1 has internal linkage">;
+def err_parameter_value_linkage: Error<
+  "%0 has C-linkage specified, 

Re: r258524 - Merge templated static member variables, fixes http://llvm.org/pr26179.

2016-02-17 Thread Richard Smith via cfe-commits
+  // TODO: Check visibility. New is hidden but has a complete type. If New
+  // has no array bound, it should not inherit one from Old, if Old is not
+  // visible.

I think this is in the wrong place: it should be attached to the "old
is complete and new is not" case. Also, our convention is to use
FIXME, not TODO.

Speaking of which, you can now delete the "FIXME: Even if this merging
succeeds, [...]" comment now, and add its example as a testcase. With
your change we should reliably diagnose it.

On Wed, Feb 17, 2016 at 2:32 PM, Vassil Vassilev  wrote:
> On 16/02/16 22:20, Richard Smith wrote:
>
> --- a/lib/Sema/SemaLookup.cpp
> +++ b/lib/Sema/SemaLookup.cpp
> @@ -419,6 +419,25 @@ static bool isPreferredLookupResult(Sema ,
> Sema::LookupNameKind Kind,
>  }
>}
>
> +  // VarDecl can have incomplete array types, prefer the one with more
> complete
> +  // array type.
> +  if (VarDecl *DVD = dyn_cast(DUnderlying)) {
> +VarDecl *EVD = cast(EUnderlying);
> +// Skip local VarDecls with incomplete array type.
> +if ((!DVD->isLocalVarDecl() && DVD->hasExternalStorage()) ||
> +(!EVD->isLocalVarDecl() && EVD->hasExternalStorage())) {
>
> Why do you need this special case?
>
> No reason, I decided to be conservative. All comments should be addressed in
> the new version of the patch.
>
> +
> +  ASTContext  = S.getASTContext();
> +
> +  if (const ArrayType *DVDTy = C.getAsArrayType(DVD->getType())) {
> +const ArrayType *EVDTy = C.getAsArrayType(EVD->getType());
> +// Prefer the decl with more complete type if visible.
> +return !DVDTy->isIncompleteArrayType() &&
> EVDTy->isIncompleteArrayType()
>
> Checking for an array type here seems unnecessary -- it'd be simpler to
> check EVD->getType()->isIncompleteType() &&
> !DVD->getType()->isIncompleteType().
>
> + && S.isVisible(D);
>
> This seems like a very subtle case: we're performing redeclaration lookup
> for a variable declaration X, and we find two results D and E. D is hidden
> but has a complete type. E is visible but has an incomplete type. If X has
> no array bound, it should not inherit one from D. But if it does have an
> array bound, and that bound differs from E's bound, we should diagnose the
> mismatch.
>
> Please add another test to the end of merge-incomplete-array-vars.cpp to
> check this is working:
> int c[2]; // expected-error {{different type: 'int [2]' vs 'int [1]'}}
>
> That said, I think this test will fail if you reorder c1 and c2 in the
> module map, but that's a pre-existing bug (see the last FIXME in
> Sema::MergeVarDeclTypes).
>
> +  }
> +}
> +  }
>
>
> On Tue, Feb 16, 2016 at 11:12 AM, Vassil Vassilev 
> wrote:
>>
>> ping...
>>
>> On 07/02/16 22:33, Vassil Vassilev wrote:
>>
>> Improve a comment.
>> --Vassil
>> On 07/02/16 20:48, Vassil Vassilev wrote:
>>
>> Would this patch be any better?
>> --Vassil
>> On 05/02/16 21:49, Richard Smith wrote:
>>
>> This belongs in ASTDeclReader::attachPreviousDecl[Impl]. That's where we
>> propagate data that's supposed to be consistent across a redeclaration chain
>> from earlier declarations to later ones.
>>
>> There's another wrinkle here: we should only be propagating the type from
>> a previous declaration that's declared in the same scope (in particular, we
>> should skip over declarations declared as local extern declarations within a
>> function). This may in some cases require walking backwards along the
>> redeclaration chain to find the previous declaration that was not a local
>> extern declaration. That'd be observable in a case like this:
>>
>> modulemap:
>> module A { module A1 { header "a1.h" } module A2 { header "a2.h" } }
>> module B { header "b.h" }
>>
>> a1.h:
>> int a[];
>>
>> b.h:
>> void g(int(*)[], int);
>> void g(int(*)[1], int) = delete;
>> template void f(T t) {
>>   extern int a[];
>>   g(, t);
>> }
>>
>> a2.h:
>> int a[1];
>>
>> x.cc:
>> #include "a1.h"
>> #include "b.h"
>> void h() { f(0); } // should not produce an error; type of 'a' within 'f'
>> should not have been updated
>>
>> That example actually reveals another problem: we really don't want the
>> completed type to be visible unless there is a visible declaration with the
>> completed type. That suggests that propagating the type across the
>> redeclaration chain may be the wrong approach, and we should instead handle
>> this by changing isPreferredLookupResult (in SemaLookup.cpp) to prefer a
>> VarDecl with a complete type over one with an incomplete type.
>>
>> On Fri, Feb 5, 2016 at 12:27 PM, Vassil Vassilev 
>> wrote:
>>>
>>> I am not sure where else to put this logic if not in isSameEntity...
>>> Could you point me to a better place?
>>> --Vassil
>>>
>>> On 05/02/16 19:56, Richard Smith wrote:
>>>
>>> On Fri, Feb 5, 2016 at 7:04 AM, Vassil Vassilev 
>>> wrote:

 Good point. Do you have in mind calling 

Re: r258524 - Merge templated static member variables, fixes http://llvm.org/pr26179.

2016-02-17 Thread Richard Smith via cfe-commits
(And otherwise this LGTM.)

On Wed, Feb 17, 2016 at 5:24 PM, Richard Smith  wrote:
> +  // TODO: Check visibility. New is hidden but has a complete type. If 
> New
> +  // has no array bound, it should not inherit one from Old, if Old is 
> not
> +  // visible.
>
> I think this is in the wrong place: it should be attached to the "old
> is complete and new is not" case. Also, our convention is to use
> FIXME, not TODO.
>
> Speaking of which, you can now delete the "FIXME: Even if this merging
> succeeds, [...]" comment now, and add its example as a testcase. With
> your change we should reliably diagnose it.
>
> On Wed, Feb 17, 2016 at 2:32 PM, Vassil Vassilev  
> wrote:
>> On 16/02/16 22:20, Richard Smith wrote:
>>
>> --- a/lib/Sema/SemaLookup.cpp
>> +++ b/lib/Sema/SemaLookup.cpp
>> @@ -419,6 +419,25 @@ static bool isPreferredLookupResult(Sema ,
>> Sema::LookupNameKind Kind,
>>  }
>>}
>>
>> +  // VarDecl can have incomplete array types, prefer the one with more
>> complete
>> +  // array type.
>> +  if (VarDecl *DVD = dyn_cast(DUnderlying)) {
>> +VarDecl *EVD = cast(EUnderlying);
>> +// Skip local VarDecls with incomplete array type.
>> +if ((!DVD->isLocalVarDecl() && DVD->hasExternalStorage()) ||
>> +(!EVD->isLocalVarDecl() && EVD->hasExternalStorage())) {
>>
>> Why do you need this special case?
>>
>> No reason, I decided to be conservative. All comments should be addressed in
>> the new version of the patch.
>>
>> +
>> +  ASTContext  = S.getASTContext();
>> +
>> +  if (const ArrayType *DVDTy = C.getAsArrayType(DVD->getType())) {
>> +const ArrayType *EVDTy = C.getAsArrayType(EVD->getType());
>> +// Prefer the decl with more complete type if visible.
>> +return !DVDTy->isIncompleteArrayType() &&
>> EVDTy->isIncompleteArrayType()
>>
>> Checking for an array type here seems unnecessary -- it'd be simpler to
>> check EVD->getType()->isIncompleteType() &&
>> !DVD->getType()->isIncompleteType().
>>
>> + && S.isVisible(D);
>>
>> This seems like a very subtle case: we're performing redeclaration lookup
>> for a variable declaration X, and we find two results D and E. D is hidden
>> but has a complete type. E is visible but has an incomplete type. If X has
>> no array bound, it should not inherit one from D. But if it does have an
>> array bound, and that bound differs from E's bound, we should diagnose the
>> mismatch.
>>
>> Please add another test to the end of merge-incomplete-array-vars.cpp to
>> check this is working:
>> int c[2]; // expected-error {{different type: 'int [2]' vs 'int [1]'}}
>>
>> That said, I think this test will fail if you reorder c1 and c2 in the
>> module map, but that's a pre-existing bug (see the last FIXME in
>> Sema::MergeVarDeclTypes).
>>
>> +  }
>> +}
>> +  }
>>
>>
>> On Tue, Feb 16, 2016 at 11:12 AM, Vassil Vassilev 
>> wrote:
>>>
>>> ping...
>>>
>>> On 07/02/16 22:33, Vassil Vassilev wrote:
>>>
>>> Improve a comment.
>>> --Vassil
>>> On 07/02/16 20:48, Vassil Vassilev wrote:
>>>
>>> Would this patch be any better?
>>> --Vassil
>>> On 05/02/16 21:49, Richard Smith wrote:
>>>
>>> This belongs in ASTDeclReader::attachPreviousDecl[Impl]. That's where we
>>> propagate data that's supposed to be consistent across a redeclaration chain
>>> from earlier declarations to later ones.
>>>
>>> There's another wrinkle here: we should only be propagating the type from
>>> a previous declaration that's declared in the same scope (in particular, we
>>> should skip over declarations declared as local extern declarations within a
>>> function). This may in some cases require walking backwards along the
>>> redeclaration chain to find the previous declaration that was not a local
>>> extern declaration. That'd be observable in a case like this:
>>>
>>> modulemap:
>>> module A { module A1 { header "a1.h" } module A2 { header "a2.h" } }
>>> module B { header "b.h" }
>>>
>>> a1.h:
>>> int a[];
>>>
>>> b.h:
>>> void g(int(*)[], int);
>>> void g(int(*)[1], int) = delete;
>>> template void f(T t) {
>>>   extern int a[];
>>>   g(, t);
>>> }
>>>
>>> a2.h:
>>> int a[1];
>>>
>>> x.cc:
>>> #include "a1.h"
>>> #include "b.h"
>>> void h() { f(0); } // should not produce an error; type of 'a' within 'f'
>>> should not have been updated
>>>
>>> That example actually reveals another problem: we really don't want the
>>> completed type to be visible unless there is a visible declaration with the
>>> completed type. That suggests that propagating the type across the
>>> redeclaration chain may be the wrong approach, and we should instead handle
>>> this by changing isPreferredLookupResult (in SemaLookup.cpp) to prefer a
>>> VarDecl with a complete type over one with an incomplete type.
>>>
>>> On Fri, Feb 5, 2016 at 12:27 PM, Vassil Vassilev 
>>> wrote:

 I am not sure where else to put this logic if not in 

Re: [PATCH] D17360: [cfi] Fix handling of sanitize trap/recover flags in the cross-DSO CFI mode.

2016-02-17 Thread Peter Collingbourne via cfe-commits
pcc added a comment.

Why can't we make it so that a trap flag doesn't affect the behaviour if a 
sanitizer is disabled (this looks like what 
`CodeGenModule::NeedAllVtablesBitSet` is already doing?)


Repository:
  rL LLVM

http://reviews.llvm.org/D17360



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


[PATCH] D17360: [cfi] Fix handling of sanitize trap/recover flags in the cross-DSO CFI mode.

2016-02-17 Thread Evgeniy Stepanov via cfe-commits
eugenis created this revision.
eugenis added reviewers: pcc, krasin.
eugenis added a subscriber: cfe-commits.
eugenis set the repository for this revision to rL LLVM.

In the cross-DSO CFI mode a module may be asked to handle any type of
CFI error, even if the module itself is not checked for that type of
error. Therefore, trap/recover flags should be preserved all CFI
checkers and not just for the ones that are enabled.

This fixes a linker error caused by the missing cfi_diag runtime
library with certain combinations of CFI flags (see the new test
case).


Repository:
  rL LLVM

http://reviews.llvm.org/D17360

Files:
  lib/Driver/SanitizerArgs.cpp
  test/Driver/fsanitize.c

Index: test/Driver/fsanitize.c
===
--- test/Driver/fsanitize.c
+++ test/Driver/fsanitize.c
@@ -272,6 +272,21 @@
 // CHECK-CFI-NO-CROSS-DSO: -emit-llvm-bc
 // CHECK-CFI-NO-CROSS-DSO-NOT: -fsanitize-cfi-cross-dso
 
+// In the non-cross-dso CFI mode, -fsanitize-trap only appears for enabled CFI 
checkers.
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=cfi-vcall -c %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-CFI-VCALL-TRAP
+// CHECK-CFI-VCALL-TRAP: "-fsanitize=cfi-vcall" "-fsanitize-trap=cfi-vcall"
+
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=cfi-vcall 
-fno-sanitize-trap=cfi-vcall -c %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-CFI-VCALL-NO-TRAP
+// CHECK-CFI-VCALL-NO-TRAP: "-fsanitize=cfi-vcall"
+// CHECK-CFI-VCALL-NO-TRAP-NOT: -fsanitize-trap=
+
+// In the cross-dso CFI mode, -fsanitize-trap appears for all CFI checkers.
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=cfi-vcall 
-fsanitize-cfi-cross-dso -flto -c %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-CFI-CROSS-DSO-VCALL-TRAP
+// CHECK-CFI-CROSS-DSO-VCALL-TRAP: "-fsanitize=cfi-vcall" 
"-fsanitize-trap=cfi-derived-cast,cfi-icall,cfi-unrelated-cast,cfi-nvcall,cfi-vcall"
+
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=cfi-vcall 
-fno-sanitize-trap=cfi-vcall -fsanitize-cfi-cross-dso -flto -c %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-CFI-CROSS-DSO-VCALL-NO-TRAP
+// CHECK-CFI-CROSS-DSO-VCALL-NO-TRAP: "-fsanitize=cfi-vcall" 
"-fsanitize-trap=cfi-derived-cast,cfi-icall,cfi-unrelated-cast,cfi-nvcall"
+
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=cfi -fsanitize-stats -flto 
-c %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-CFI-STATS
 // CHECK-CFI-STATS: -fsanitize-stats
 
Index: lib/Driver/SanitizerArgs.cpp
===
--- lib/Driver/SanitizerArgs.cpp
+++ lib/Driver/SanitizerArgs.cpp
@@ -166,11 +166,11 @@
 }
 
 bool SanitizerArgs::needsCfiRt() const {
-  return !(Sanitizers.Mask & CFI & ~TrapSanitizers.Mask) && CfiCrossDso;
+  return !(CFI & ~TrapSanitizers.Mask) && CfiCrossDso;
 }
 
 bool SanitizerArgs::needsCfiDiagRt() const {
-  return (Sanitizers.Mask & CFI & ~TrapSanitizers.Mask) && CfiCrossDso;
+  return (CFI & ~TrapSanitizers.Mask) && CfiCrossDso;
 }
 
 bool SanitizerArgs::requiresPIE() const {
@@ -361,10 +361,27 @@
 << DeprecatedReplacement;
 }
   }
-  RecoverableKinds &= Kinds;
-  RecoverableKinds &= ~Unrecoverable;
 
-  TrappingKinds &= Kinds;
+  if (AllAddedKinds & CFI) {
+CfiCrossDso = Args.hasFlag(options::OPT_fsanitize_cfi_cross_dso,
+   options::OPT_fno_sanitize_cfi_cross_dso, false);
+// Without PIE, external function address may resolve to a PLT record, 
which
+// can not be verified by the target module.
+NeedPIE |= CfiCrossDso;
+  }
+
+  // In the cross-DSO CFI mode a module may be asked to handle any type of CFI
+  // error, even if the module itself is not checked for that type of error.
+  // Therefore, trap/recover flags should be preserved all CFI checkers.
+  if (CfiCrossDso) {
+TrappingKinds &= (Kinds | CFI);
+RecoverableKinds &= (Kinds | CFI);
+  } else {
+TrappingKinds &= Kinds;
+RecoverableKinds &= Kinds;
+  }
+
+  RecoverableKinds &= ~Unrecoverable;
 
   // Setup blacklist files.
   // Add default blacklist from resource directory.
@@ -424,14 +441,6 @@
  TC.getTriple().getArch() == llvm::Triple::x86_64);
   }
 
-  if (AllAddedKinds & CFI) {
-CfiCrossDso = Args.hasFlag(options::OPT_fsanitize_cfi_cross_dso,
-   options::OPT_fno_sanitize_cfi_cross_dso, false);
-// Without PIE, external function address may resolve to a PLT record, 
which
-// can not be verified by the target module.
-NeedPIE |= CfiCrossDso;
-  }
-
   Stats = Args.hasFlag(options::OPT_fsanitize_stats,
options::OPT_fno_sanitize_stats, false);
 


Index: test/Driver/fsanitize.c
===
--- test/Driver/fsanitize.c
+++ test/Driver/fsanitize.c
@@ -272,6 +272,21 @@
 // CHECK-CFI-NO-CROSS-DSO: -emit-llvm-bc
 // CHECK-CFI-NO-CROSS-DSO-NOT: -fsanitize-cfi-cross-dso
 
+// In the 

Re: [PATCH] D15883: Add ARM EHABI-related constants to unwind.h.

2016-02-17 Thread Logan Chien via cfe-commits
logan added inline comments.


Comment at: lib/Headers/unwind.h:61
@@ +60,3 @@
+#define _UNWIND_ARM_EHABI 0
+#endif
+

compnerd wrote:
> logan wrote:
> > Since this is `unwind.h`, I feel that we can get a step further and use 
> > `__ARM_EABI_UNWINDER__` to get more compatibility to GCC's unwind.h.
> > 
> > Here's the change:
> > 
> > ```
> > #if defined(__arm__) && !defined(__USING_SJLJ_EXCEPTIONS__) && \
> > !defined(__ARM_DWARF_EH__)
> > #define __ARM_EABI_UNWINDER__ 1
> > #endif
> > ```
> I dont know if we really need to imitate GCC's macros here.  Am I mistaken in 
> that they assume that `__ARM_EABI_UNWINDER__` has been set to 1 externally if 
> targeting such an environment?  I think that it is better to use the reserved 
> namespace and intrude into libunwind's namespace as already done here.
> Am I mistaken in that they assume that `__ARM_EABI_UNWINDER__` has been set 
> to 1 externally if targeting such an environment?

Although this is an implementation detail, it was defined by `unwind.h` in the 
implementation of GCC.

Remark: `__ARM_EABI_UNWINDER__` is not a pre-defined macro in GCC and Clang 
(can be checked with ` gcc -dM -E - < /dev/null`.)

BTW, some applications or libraries need this macro to be defined after 
including `` (such as uclibc, boost, or libc++abi 3.0.)  I remembered 
that someone suggested to use `__ARM_EABI_UNWINDER__` instead of  
`LIBCXXABI_ARM_EHABI` when I was fixing libc++abi several years ago.  I chose 
`LIBCXXABI_ARM_EHABI` simply because `__ARM_EABI_UNWINDER__` wasn't provided by 
clang at that time.

I am less concerned to namespace pollution, because this is already the de 
facto implementation in GCC world and the macro names start with underscores 
are reserved for compiler or standard libraries by convention.

Since this is file a public header and will be used for a long time, I 
personally believe that it will be better to use an existing name with the same 
meaning instead of introducing a new name.  In addition, this will make it 
easier to port the application between gcc and clang.


http://reviews.llvm.org/D15883



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


Re: [PATCH] D17056: Mark all CUDA device-side function defs and decls as convergent.

2016-02-17 Thread Justin Lebar via cfe-commits
jlebar updated this revision to Diff 48261.
jlebar added a comment.

Move code into ConstructAttributeList.  Now it applies to both functions and 
calls.


http://reviews.llvm.org/D17056

Files:
  lib/CodeGen/CGCall.cpp
  test/CodeGenCUDA/convergent.cu
  test/CodeGenCUDA/device-var-init.cu

Index: test/CodeGenCUDA/device-var-init.cu
===
--- test/CodeGenCUDA/device-var-init.cu
+++ test/CodeGenCUDA/device-var-init.cu
@@ -382,7 +382,7 @@
 // CHECK:   call void @_ZN4NETCC1IJEEEDpT_(%struct.NETC* %netc)
 // CHECK:   call void @_ZN7EC_I_ECC1Ev(%struct.EC_I_EC* %ec_i_ec)
 // CHECK:   call void @_ZN8EC_I_EC1C1Ev(%struct.EC_I_EC1* %ec_i_ec1)
-// CHECK:   call void @_ZN5T_V_TC1Ev(%struct.T_V_T* %t_v_t) #3
+// CHECK:   call void @_ZN5T_V_TC1Ev(%struct.T_V_T* %t_v_t)
 // CHECK:   call void @_ZN7T_B_NECC1Ev(%struct.T_B_NEC* %t_b_nec)
 // CHECK:   call void @_ZN7T_F_NECC1Ev(%struct.T_F_NEC* %t_f_nec)
 // CHECK:   call void @_ZN8T_FA_NECC1Ev(%struct.T_FA_NEC* %t_fa_nec)
Index: test/CodeGenCUDA/convergent.cu
===
--- /dev/null
+++ test/CodeGenCUDA/convergent.cu
@@ -0,0 +1,39 @@
+// REQUIRES: x86-registered-target
+// REQUIRES: nvptx-registered-target
+
+// RUN: %clang_cc1 -fcuda-is-device -triple nvptx-nvidia-cuda -emit-llvm \
+// RUN:   -disable-llvm-passes -o - %s | FileCheck -check-prefix DEVICE %s
+
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm \
+// RUN:   -disable-llvm-passes -o - %s | \
+// RUN:  FileCheck -check-prefix HOST %s
+
+#include "Inputs/cuda.h"
+
+// DEVICE: Function Attrs:
+// DEVICE-SAME: convergent
+// DEVICE-NEXT: define void @_Z3foov
+__device__ void foo() {}
+
+// HOST: Function Attrs:
+// HOST-NOT: convergent
+// HOST-NEXT: define void @_Z3barv
+// DEVICE: Function Attrs:
+// DEVICE-SAME: convergent
+// DEVICE-NEXT: define void @_Z3barv
+__host__ __device__ void baz();
+__host__ __device__ void bar() {
+  // DEVICE: call void @_Z3bazv() [[CALL_ATTR:#[0-9]+]]
+  baz();
+}
+
+// DEVICE: declare void @_Z3bazv() [[BAZ_ATTR:#[0-9]+]]
+// DEVICE: attributes [[BAZ_ATTR]] = {
+// DEVICE-SAME: convergent
+// DEVICE-SAME: }
+// DEVICE: attributes [[CALL_ATTR]] = { convergent }
+
+// HOST: declare void @_Z3bazv() [[BAZ_ATTR:#[0-9]+]]
+// HOST: attributes [[BAZ_ATTR]] = {
+// HOST-NOT: convergent
+// NOST-SAME: }
Index: lib/CodeGen/CGCall.cpp
===
--- lib/CodeGen/CGCall.cpp
+++ lib/CodeGen/CGCall.cpp
@@ -1595,6 +1595,14 @@
 }
   }
 
+  if (getLangOpts().CUDA && getLangOpts().CUDAIsDevice) {
+// Conservatively, mark all functions and calls in CUDA as convergent
+// (meaning, they may call an intrinsically convergent op, such as
+// __syncthreads(), and so can't have certain optimizations applied around
+// them).  LLVM will remove this attribute where it safely can.
+FuncAttrs.addAttribute(llvm::Attribute::Convergent);
+  }
+
   ClangToLLVMArgMapping IRFunctionArgs(getContext(), FI);
 
   QualType RetTy = FI.getReturnType();


Index: test/CodeGenCUDA/device-var-init.cu
===
--- test/CodeGenCUDA/device-var-init.cu
+++ test/CodeGenCUDA/device-var-init.cu
@@ -382,7 +382,7 @@
 // CHECK:   call void @_ZN4NETCC1IJEEEDpT_(%struct.NETC* %netc)
 // CHECK:   call void @_ZN7EC_I_ECC1Ev(%struct.EC_I_EC* %ec_i_ec)
 // CHECK:   call void @_ZN8EC_I_EC1C1Ev(%struct.EC_I_EC1* %ec_i_ec1)
-// CHECK:   call void @_ZN5T_V_TC1Ev(%struct.T_V_T* %t_v_t) #3
+// CHECK:   call void @_ZN5T_V_TC1Ev(%struct.T_V_T* %t_v_t)
 // CHECK:   call void @_ZN7T_B_NECC1Ev(%struct.T_B_NEC* %t_b_nec)
 // CHECK:   call void @_ZN7T_F_NECC1Ev(%struct.T_F_NEC* %t_f_nec)
 // CHECK:   call void @_ZN8T_FA_NECC1Ev(%struct.T_FA_NEC* %t_fa_nec)
Index: test/CodeGenCUDA/convergent.cu
===
--- /dev/null
+++ test/CodeGenCUDA/convergent.cu
@@ -0,0 +1,39 @@
+// REQUIRES: x86-registered-target
+// REQUIRES: nvptx-registered-target
+
+// RUN: %clang_cc1 -fcuda-is-device -triple nvptx-nvidia-cuda -emit-llvm \
+// RUN:   -disable-llvm-passes -o - %s | FileCheck -check-prefix DEVICE %s
+
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm \
+// RUN:   -disable-llvm-passes -o - %s | \
+// RUN:  FileCheck -check-prefix HOST %s
+
+#include "Inputs/cuda.h"
+
+// DEVICE: Function Attrs:
+// DEVICE-SAME: convergent
+// DEVICE-NEXT: define void @_Z3foov
+__device__ void foo() {}
+
+// HOST: Function Attrs:
+// HOST-NOT: convergent
+// HOST-NEXT: define void @_Z3barv
+// DEVICE: Function Attrs:
+// DEVICE-SAME: convergent
+// DEVICE-NEXT: define void @_Z3barv
+__host__ __device__ void baz();
+__host__ __device__ void bar() {
+  // DEVICE: call void @_Z3bazv() [[CALL_ATTR:#[0-9]+]]
+  baz();
+}
+
+// DEVICE: declare void @_Z3bazv() [[BAZ_ATTR:#[0-9]+]]
+// DEVICE: attributes [[BAZ_ATTR]] = {
+// DEVICE-SAME: 

Re: [PATCH] D17056: Mark all CUDA device-side function defs and decls as convergent.

2016-02-17 Thread David Majnemer via cfe-commits
majnemer added inline comments.


Comment at: lib/CodeGen/CodeGenModule.cpp:817-823
@@ -816,1 +816,9 @@
+
+  if (getLangOpts().CUDA && getLangOpts().CUDAIsDevice) {
+// Conservatively, mark all functions in CUDA as convergent (meaning, they
+// may call an intrinsically convergent op, such as __syncthreads(), and so
+// can't have certain optimizations applied around them).  LLVM will remove
+// this attribute where it safely can.
+F->addFnAttr(llvm::Attribute::Convergent);
+  }
 }

Sorry for the goose chase...

`ConstructAttributeList` seems better.


http://reviews.llvm.org/D17056



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


Re: [PATCH] D16686: [OpenCL] Generate metadata for opencl_unroll_hint attribute

2016-02-17 Thread Xiuli PAN via cfe-commits
pxli168 accepted this revision.
pxli168 added a comment.

Sorry for the late reply, I was on a break.
LGTM!


http://reviews.llvm.org/D16686



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


Re: [PATCH] D17056: Mark all CUDA device-side function defs and decls as convergent.

2016-02-17 Thread Justin Lebar via cfe-commits
jlebar added a comment.

In http://reviews.llvm.org/D17056#355228, @jlebar wrote:

> Move coded into SetLLVMFunctionAttributes (not ForDefinition).


Much better.  :)


http://reviews.llvm.org/D17056



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


Re: [PATCH] D17056: Mark all CUDA device-side function defs and decls as convergent.

2016-02-17 Thread Justin Lebar via cfe-commits
jlebar updated this revision to Diff 48260.
jlebar added a comment.

Move coded into SetLLVMFunctionAttributes (not ForDefinition).


http://reviews.llvm.org/D17056

Files:
  lib/CodeGen/CodeGenModule.cpp
  test/CodeGenCUDA/convergent.cu

Index: test/CodeGenCUDA/convergent.cu
===
--- /dev/null
+++ test/CodeGenCUDA/convergent.cu
@@ -0,0 +1,35 @@
+// REQUIRES: x86-registered-target
+// REQUIRES: nvptx-registered-target
+
+// RUN: %clang_cc1 -fcuda-is-device -triple nvptx-nvidia-cuda -emit-llvm \
+// RUN:   -disable-llvm-passes -o - %s | FileCheck -check-prefix DEVICE %s
+
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm \
+// RUN:   -disable-llvm-passes -o - %s | \
+// RUN:  FileCheck -check-prefix HOST %s
+
+#include "Inputs/cuda.h"
+
+// DEVICE: Function Attrs:
+// DEVICE-SAME: convergent
+// DEVICE-NEXT: define void @_Z3foov
+__device__ void foo() {}
+
+// HOST: Function Attrs:
+// HOST-NOT: convergent
+// HOST-NEXT: define void @_Z3barv
+// DEVICE: Function Attrs:
+// DEVICE-SAME: convergent
+// DEVICE-NEXT: define void @_Z3barv
+__host__ __device__ void baz();
+__host__ __device__ void bar() { baz(); }
+
+// DEVICE: declare void @_Z3bazv() [[BAZ_ATTR:#[0-9]+]]
+// DEVICE: attributes [[BAZ_ATTR]] = {
+// DEVICE-SAME: convergent
+// DEVICE-SAME: }
+
+// HOST: declare void @_Z3bazv() [[BAZ_ATTR:#[0-9]+]]
+// HOST: attributes [[BAZ_ATTR]] = {
+// HOST-NOT: convergent
+// NOST-SAME: }
Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -813,6 +813,14 @@
  false);
   F->setAttributes(llvm::AttributeSet::get(getLLVMContext(), AttributeList));
   F->setCallingConv(static_cast(CallingConv));
+
+  if (getLangOpts().CUDA && getLangOpts().CUDAIsDevice) {
+// Conservatively, mark all functions in CUDA as convergent (meaning, they
+// may call an intrinsically convergent op, such as __syncthreads(), and so
+// can't have certain optimizations applied around them).  LLVM will remove
+// this attribute where it safely can.
+F->addFnAttr(llvm::Attribute::Convergent);
+  }
 }
 
 /// Determines whether the language options require us to model


Index: test/CodeGenCUDA/convergent.cu
===
--- /dev/null
+++ test/CodeGenCUDA/convergent.cu
@@ -0,0 +1,35 @@
+// REQUIRES: x86-registered-target
+// REQUIRES: nvptx-registered-target
+
+// RUN: %clang_cc1 -fcuda-is-device -triple nvptx-nvidia-cuda -emit-llvm \
+// RUN:   -disable-llvm-passes -o - %s | FileCheck -check-prefix DEVICE %s
+
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm \
+// RUN:   -disable-llvm-passes -o - %s | \
+// RUN:  FileCheck -check-prefix HOST %s
+
+#include "Inputs/cuda.h"
+
+// DEVICE: Function Attrs:
+// DEVICE-SAME: convergent
+// DEVICE-NEXT: define void @_Z3foov
+__device__ void foo() {}
+
+// HOST: Function Attrs:
+// HOST-NOT: convergent
+// HOST-NEXT: define void @_Z3barv
+// DEVICE: Function Attrs:
+// DEVICE-SAME: convergent
+// DEVICE-NEXT: define void @_Z3barv
+__host__ __device__ void baz();
+__host__ __device__ void bar() { baz(); }
+
+// DEVICE: declare void @_Z3bazv() [[BAZ_ATTR:#[0-9]+]]
+// DEVICE: attributes [[BAZ_ATTR]] = {
+// DEVICE-SAME: convergent
+// DEVICE-SAME: }
+
+// HOST: declare void @_Z3bazv() [[BAZ_ATTR:#[0-9]+]]
+// HOST: attributes [[BAZ_ATTR]] = {
+// HOST-NOT: convergent
+// NOST-SAME: }
Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -813,6 +813,14 @@
  false);
   F->setAttributes(llvm::AttributeSet::get(getLLVMContext(), AttributeList));
   F->setCallingConv(static_cast(CallingConv));
+
+  if (getLangOpts().CUDA && getLangOpts().CUDAIsDevice) {
+// Conservatively, mark all functions in CUDA as convergent (meaning, they
+// may call an intrinsically convergent op, such as __syncthreads(), and so
+// can't have certain optimizations applied around them).  LLVM will remove
+// this attribute where it safely can.
+F->addFnAttr(llvm::Attribute::Convergent);
+  }
 }
 
 /// Determines whether the language options require us to model
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17056: Mark all CUDA device-side function defs and decls as convergent.

2016-02-17 Thread Justin Lebar via cfe-commits
jlebar added a comment.

In http://reviews.llvm.org/D17056#355198, @jlebar wrote:

> Move code into SetLLVMFunctionAttributesForDefinition.


Actually, this doesn't work -- we don't annotate

  __host__ __device__ void baz();

as convergent.  (I ran the tests, but of course I didn't notice it failing...)


http://reviews.llvm.org/D17056



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


[libcxx] r261181 - Commit tests missing from r261180.

2016-02-17 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Wed Feb 17 18:21:09 2016
New Revision: 261181

URL: http://llvm.org/viewvc/llvm-project?rev=261181=rev
Log:
Commit tests missing from r261180.

Added:
libcxx/trunk/test/libcxx/containers/gnu_cxx/
libcxx/trunk/test/libcxx/containers/gnu_cxx/hash_map.pass.cpp
libcxx/trunk/test/libcxx/containers/gnu_cxx/hash_set.pass.cpp

Added: libcxx/trunk/test/libcxx/containers/gnu_cxx/hash_map.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/containers/gnu_cxx/hash_map.pass.cpp?rev=261181=auto
==
--- libcxx/trunk/test/libcxx/containers/gnu_cxx/hash_map.pass.cpp (added)
+++ libcxx/trunk/test/libcxx/containers/gnu_cxx/hash_map.pass.cpp Wed Feb 17 
18:21:09 2016
@@ -0,0 +1,21 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include 
+
+namespace __gnu_cxx {
+template class hash_map;
+}
+
+int main() {
+  typedef __gnu_cxx::hash_map Map;
+  Map m;
+  Map m2(m);
+  ((void)m2);
+}

Added: libcxx/trunk/test/libcxx/containers/gnu_cxx/hash_set.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/containers/gnu_cxx/hash_set.pass.cpp?rev=261181=auto
==
--- libcxx/trunk/test/libcxx/containers/gnu_cxx/hash_set.pass.cpp (added)
+++ libcxx/trunk/test/libcxx/containers/gnu_cxx/hash_set.pass.cpp Wed Feb 17 
18:21:09 2016
@@ -0,0 +1,21 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include 
+
+namespace __gnu_cxx {
+template class hash_set;
+}
+
+int main() {
+  typedef __gnu_cxx::hash_set Set;
+  Set s;
+  Set s2(s);
+  ((void)s2);
+}


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


[libcxx] r261180 - Get working again

2016-02-17 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Wed Feb 17 18:20:34 2016
New Revision: 261180

URL: http://llvm.org/viewvc/llvm-project?rev=261180=rev
Log:
Get  working again

Modified:
libcxx/trunk/include/__hash_table

Modified: libcxx/trunk/include/__hash_table
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__hash_table?rev=261180=261179=261180=diff
==
--- libcxx/trunk/include/__hash_table (original)
+++ libcxx/trunk/include/__hash_table Wed Feb 17 18:20:34 2016
@@ -380,10 +380,12 @@ class _LIBCPP_TYPE_VIS_ONLY __hash_const
 static_assert(!is_const::element_type>::value, "");
 typedef __hash_node_types<_NodePtr> _NodeTypes;
 typedef _NodePtr __node_pointer;
-typedef __hash_iterator<_NodePtr> __non_const_iterator;
+
 __node_pointer __node_;
 
 public:
+typedef __hash_iterator<_NodePtr> __non_const_iterator;
+
 typedef forward_iterator_tag 
iterator_category;
 typedef typename _NodeTypes::__node_value_type   value_type;
 typedef typename _NodeTypes::difference_type 
difference_type;
@@ -655,10 +657,10 @@ class _LIBCPP_TYPE_VIS_ONLY __hash_const
 typedef typename remove_const<__node>::type __non_const_node;
 typedef typename __rebind_pointer<__node_pointer, __non_const_node>::type
 __non_const_node_pointer;
-
+public:
 typedef __hash_local_iterator<__non_const_node_pointer>
 __non_const_iterator;
-public:
+
 typedef forward_iterator_tag 
iterator_category;
 typedef typename _NodeTypes::__node_value_type   value_type;
 typedef typename _NodeTypes::difference_type 
difference_type;


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


Re: [PATCH] D17056: Mark all CUDA device-side function defs and decls as convergent.

2016-02-17 Thread Justin Lebar via cfe-commits
jlebar updated this revision to Diff 48255.
jlebar added a comment.

Move code into SetLLVMFunctionAttributesForDefinition.


http://reviews.llvm.org/D17056

Files:
  lib/CodeGen/CodeGenModule.cpp
  test/CodeGenCUDA/convergent.cu

Index: test/CodeGenCUDA/convergent.cu
===
--- /dev/null
+++ test/CodeGenCUDA/convergent.cu
@@ -0,0 +1,35 @@
+// REQUIRES: x86-registered-target
+// REQUIRES: nvptx-registered-target
+
+// RUN: %clang_cc1 -fcuda-is-device -triple nvptx-nvidia-cuda -emit-llvm \
+// RUN:   -disable-llvm-passes -o - %s | FileCheck -check-prefix DEVICE %s
+
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm \
+// RUN:   -disable-llvm-passes -o - %s | \
+// RUN:  FileCheck -check-prefix HOST %s
+
+#include "Inputs/cuda.h"
+
+// DEVICE: Function Attrs:
+// DEVICE-SAME: convergent
+// DEVICE-NEXT: define void @_Z3foov
+__device__ void foo() {}
+
+// HOST: Function Attrs:
+// HOST-NOT: convergent
+// HOST-NEXT: define void @_Z3barv
+// DEVICE: Function Attrs:
+// DEVICE-SAME: convergent
+// DEVICE-NEXT: define void @_Z3barv
+__host__ __device__ void baz();
+__host__ __device__ void bar() { baz(); }
+
+// DEVICE: declare void @_Z3bazv() [[BAZ_ATTR:#[0-9]+]]
+// DEVICE: attributes [[BAZ_ATTR]] = {
+// DEVICE-SAME: convergent
+// DEVICE-SAME: }
+
+// HOST: declare void @_Z3bazv() [[BAZ_ATTR:#[0-9]+]]
+// HOST: attributes [[BAZ_ATTR]] = {
+// HOST-NOT: convergent
+// NOST-SAME: }
Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -922,6 +922,14 @@
 if (F->getAlignment() < 2 && isa(D))
   F->setAlignment(2);
   }
+
+  if (getLangOpts().CUDA && getLangOpts().CUDAIsDevice) {
+// Conservatively, mark all functions in CUDA as convergent (meaning, they
+// may call an intrinsically convergent op, such as __syncthreads(), and so
+// can't have certain optimizations applied around them).  LLVM will remove
+// this attribute where it safely can.
+F->addFnAttr(llvm::Attribute::Convergent);
+  }
 }
 
 void CodeGenModule::SetCommonAttributes(const Decl *D,


Index: test/CodeGenCUDA/convergent.cu
===
--- /dev/null
+++ test/CodeGenCUDA/convergent.cu
@@ -0,0 +1,35 @@
+// REQUIRES: x86-registered-target
+// REQUIRES: nvptx-registered-target
+
+// RUN: %clang_cc1 -fcuda-is-device -triple nvptx-nvidia-cuda -emit-llvm \
+// RUN:   -disable-llvm-passes -o - %s | FileCheck -check-prefix DEVICE %s
+
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm \
+// RUN:   -disable-llvm-passes -o - %s | \
+// RUN:  FileCheck -check-prefix HOST %s
+
+#include "Inputs/cuda.h"
+
+// DEVICE: Function Attrs:
+// DEVICE-SAME: convergent
+// DEVICE-NEXT: define void @_Z3foov
+__device__ void foo() {}
+
+// HOST: Function Attrs:
+// HOST-NOT: convergent
+// HOST-NEXT: define void @_Z3barv
+// DEVICE: Function Attrs:
+// DEVICE-SAME: convergent
+// DEVICE-NEXT: define void @_Z3barv
+__host__ __device__ void baz();
+__host__ __device__ void bar() { baz(); }
+
+// DEVICE: declare void @_Z3bazv() [[BAZ_ATTR:#[0-9]+]]
+// DEVICE: attributes [[BAZ_ATTR]] = {
+// DEVICE-SAME: convergent
+// DEVICE-SAME: }
+
+// HOST: declare void @_Z3bazv() [[BAZ_ATTR:#[0-9]+]]
+// HOST: attributes [[BAZ_ATTR]] = {
+// HOST-NOT: convergent
+// NOST-SAME: }
Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -922,6 +922,14 @@
 if (F->getAlignment() < 2 && isa(D))
   F->setAlignment(2);
   }
+
+  if (getLangOpts().CUDA && getLangOpts().CUDAIsDevice) {
+// Conservatively, mark all functions in CUDA as convergent (meaning, they
+// may call an intrinsically convergent op, such as __syncthreads(), and so
+// can't have certain optimizations applied around them).  LLVM will remove
+// this attribute where it safely can.
+F->addFnAttr(llvm::Attribute::Convergent);
+  }
 }
 
 void CodeGenModule::SetCommonAttributes(const Decl *D,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r261178 - [sanitizer-coverage] add a deprecation warning for -fsanitize-coverage=[1234]

2016-02-17 Thread Kostya Serebryany via cfe-commits
Author: kcc
Date: Wed Feb 17 17:57:17 2016
New Revision: 261178

URL: http://llvm.org/viewvc/llvm-project?rev=261178=rev
Log:
[sanitizer-coverage] add a deprecation warning for -fsanitize-coverage=[1234]

Modified:
cfe/trunk/lib/Driver/SanitizerArgs.cpp
cfe/trunk/test/Driver/fsanitize-coverage.c

Modified: cfe/trunk/lib/Driver/SanitizerArgs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/SanitizerArgs.cpp?rev=261178=261177=261178=diff
==
--- cfe/trunk/lib/Driver/SanitizerArgs.cpp (original)
+++ cfe/trunk/lib/Driver/SanitizerArgs.cpp Wed Feb 17 17:57:17 2016
@@ -446,6 +446,8 @@ SanitizerArgs::SanitizerArgs(const ToolC
 !StringRef(Arg->getValue(0))
  .getAsInteger(0, LegacySanitizeCoverage) &&
 LegacySanitizeCoverage >= 0 && LegacySanitizeCoverage <= 4) {
+  D.Diag(diag::warn_drv_deprecated_arg)
+  << Arg->getAsString(Args) << 
"-fsanitize-coverage=[func,bb,edge]";
   // TODO: Add deprecation notice for this form.
   switch (LegacySanitizeCoverage) {
   case 0:

Modified: cfe/trunk/test/Driver/fsanitize-coverage.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/fsanitize-coverage.c?rev=261178=261177=261178=diff
==
--- cfe/trunk/test/Driver/fsanitize-coverage.c (original)
+++ cfe/trunk/test/Driver/fsanitize-coverage.c Wed Feb 17 17:57:17 2016
@@ -3,32 +3,35 @@
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=address %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-SANITIZE-COVERAGE-0
 // CHECK-SANITIZE-COVERAGE-0-NOT: fsanitize-coverage-type
 
-// RUN: %clang -target x86_64-linux-gnu -fsanitize=address 
-fsanitize-coverage=1 %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-SANITIZE-COVERAGE-1
-// RUN: %clang -target x86_64-linux-gnu -fsanitize=memory 
-fsanitize-coverage=1 %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-SANITIZE-COVERAGE-1
-// RUN: %clang -target x86_64-linux-gnu -fsanitize=leak -fsanitize-coverage=1 
%s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANITIZE-COVERAGE-1
-// RUN: %clang -target x86_64-linux-gnu -fsanitize=undefined 
-fsanitize-coverage=1 %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-SANITIZE-COVERAGE-1
-// RUN: %clang -target x86_64-linux-gnu -fsanitize=bool -fsanitize-coverage=1 
%s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANITIZE-COVERAGE-1
-// RUN: %clang -target x86_64-linux-gnu -fsanitize=dataflow 
-fsanitize-coverage=1 %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-SANITIZE-COVERAGE-1
-// CHECK-SANITIZE-COVERAGE-1: fsanitize-coverage-type=1
-
-// RUN: %clang -target x86_64-linux-gnu -fsanitize=address 
-fsanitize-coverage=2 %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-SANITIZE-COVERAGE-2
-// CHECK-SANITIZE-COVERAGE-2: fsanitize-coverage-type=2
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=address 
-fsanitize-coverage=func %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-SANITIZE-COVERAGE-FUNC
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=memory 
-fsanitize-coverage=func %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-SANITIZE-COVERAGE-FUNC
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=leak 
-fsanitize-coverage=func %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-SANITIZE-COVERAGE-FUNC
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=undefined 
-fsanitize-coverage=func %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-SANITIZE-COVERAGE-FUNC
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=bool 
-fsanitize-coverage=func %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-SANITIZE-COVERAGE-FUNC
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=dataflow 
-fsanitize-coverage=func %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-SANITIZE-COVERAGE-FUNC
+// CHECK-SANITIZE-COVERAGE-FUNC: fsanitize-coverage-type=1
+
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=address 
-fsanitize-coverage=bb %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-SANITIZE-COVERAGE-BB
+// CHECK-SANITIZE-COVERAGE-BB: fsanitize-coverage-type=2
+
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=address 
-fsanitize-coverage=edge %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-SANITIZE-COVERAGE-EDGE
+// CHECK-SANITIZE-COVERAGE-EDGE: fsanitize-coverage-type=3
+
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=address 
-fsanitize-coverage=edge,indirect-calls %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-SANITIZE-COVERAGE-FUNC_INDIR
+// CHECK-SANITIZE-COVERAGE-FUNC_INDIR: fsanitize-coverage-type=3
+// CHECK-SANITIZE-COVERAGE-FUNC_INDIR: fsanitize-coverage-indirect-calls
 
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=address 
-fsanitize-coverage=3 %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-SANITIZE-COVERAGE-3
-// CHECK-SANITIZE-COVERAGE-3: fsanitize-coverage-type=3
-
-// RUN: %clang -target x86_64-linux-gnu -fsanitize=address 
-fsanitize-coverage=4 %s 

Re: [PATCH] D16843: [Sema] Fix bug in TypeLocBuilder::pushImpl

2016-02-17 Thread Manman Ren via cfe-commits
manmanren added a comment.

Hi Akira,

How about the following?

  else if (LocalAlignment == 8) {
if (NumBytesAtAlign8 == 0) {
  // We have not seen any 8-byte aligned element yet. There is no padding 
and we are either 4-byte
  // aligned or 8-byte aligned depending on NumBytesAtAlign4.
  // Add in 4 bytes padding if we are not 8-byte aligned including this 
element.
  if ((LocalSize + NumBytesAtAlign4) % 8 != 0) {
memmove([Index - 4], [Index], NumBytesAtAlign4);
Index -= 4;
  }
} else {
  unsigned Padding = NumBytesAtAlign4 % 8;
  if (Padding == 0) { 
if (LocalSize % 8 == 0) {
  // Everything is set: there's no padding and we don't need to add
  // any.
} else {
  assert(LocalSize % 8 == 4);
  // No existing padding; add in 4 bytes padding
  memmove([Index - 4], [Index], NumBytesAtAlign4);
  Index -= 4;
}
  } else {
assert(Padding == 4);
if (LocalSize % 8 == 0) {
  // Everything is set: there's 4 bytes padding and we don't need
  // to add any.
} else {
  assert(LocalSize % 8 == 4);
  // There are 4 bytes padding, but we don't need any; remove it.
  memmove([Index + 4], [Index], NumBytesAtAlign4);
  Index += 4;
}
  }
}
// Forget about any padding.
NumBytesAtAlign4 = 0;
NumBytesAtAlign8 += LocalSize;
  }

Note that the handling of NumBytesAtAlign8 != 0 is the same for LocalAlignment 
== 4 vs. LocalAlignment == 8.
Also mention in the commit message that the original code seems to assume 
LocalSize is a multiple of 8 when LocalAlignment is 8.

Cheers,
Manman


http://reviews.llvm.org/D16843



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


Re: [PATCH] D17355: [Sema] Remove assert in TreeTransform::TransformObjCObjectType

2016-02-17 Thread Akira Hatanaka via cfe-commits
ahatanak added a comment.

Note that the test case currently asserts. The patch that is currently under 
review in http://reviews.llvm.org/D16843 has to be applied first.


http://reviews.llvm.org/D17355



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


[PATCH] D17355: [Sema] Remove assert in TreeTransform::TransformObjCObjectType

2016-02-17 Thread Akira Hatanaka via cfe-commits
ahatanak created this revision.
ahatanak added a reviewer: doug.gregor.
ahatanak added a subscriber: cfe-commits.

The assert is triggered when there is a template function whose return type is 
a protocol without an object type (e.g., ""). clang treats such a protocol 
as a synonym for "id" and sets ObjCObjectTypeLocInfo::HasBaseTypeAsWritten 
to false in Sema::actOnObjCProtocolQualifierType, which later causes an assert 
in TreeTransform::TransformObjCObjectType.

assert(TL.hasBaseTypeAsWritten() && "Can't be dependent");

I'm not sure what hasBaseTypeAsWritten is used for. But it seemed to me that it 
doesn't necessarily indicate whether the type is a dependent type, so I've 
removed the assert.

http://reviews.llvm.org/D17355

Files:
  lib/Sema/TreeTransform.h
  test/SemaObjCXX/base-type-as-written.mm

Index: test/SemaObjCXX/base-type-as-written.mm
===
--- /dev/null
+++ test/SemaObjCXX/base-type-as-written.mm
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// Make sure we don't crash in TreeTransform::TransformObjCObjectType.
+
+@protocol P1
+@end
+
+template  foo1(T1) { // expected-warning {{protocol has no 
object type specified; defaults to qualified 'id'}}
+  foo1(0);
+}
Index: lib/Sema/TreeTransform.h
===
--- lib/Sema/TreeTransform.h
+++ lib/Sema/TreeTransform.h
@@ -5932,7 +5932,6 @@
   }
 
   ObjCObjectTypeLoc NewT = TLB.push(Result);
-  assert(TL.hasBaseTypeAsWritten() && "Can't be dependent");
   NewT.setHasBaseTypeAsWritten(true);
   NewT.setTypeArgsLAngleLoc(TL.getTypeArgsLAngleLoc());
   for (unsigned i = 0, n = TL.getNumTypeArgs(); i != n; ++i)


Index: test/SemaObjCXX/base-type-as-written.mm
===
--- /dev/null
+++ test/SemaObjCXX/base-type-as-written.mm
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// Make sure we don't crash in TreeTransform::TransformObjCObjectType.
+
+@protocol P1
+@end
+
+template  foo1(T1) { // expected-warning {{protocol has no object type specified; defaults to qualified 'id'}}
+  foo1(0);
+}
Index: lib/Sema/TreeTransform.h
===
--- lib/Sema/TreeTransform.h
+++ lib/Sema/TreeTransform.h
@@ -5932,7 +5932,6 @@
   }
 
   ObjCObjectTypeLoc NewT = TLB.push(Result);
-  assert(TL.hasBaseTypeAsWritten() && "Can't be dependent");
   NewT.setHasBaseTypeAsWritten(true);
   NewT.setTypeArgsLAngleLoc(TL.getTypeArgsLAngleLoc());
   for (unsigned i = 0, n = TL.getNumTypeArgs(); i != n; ++i)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D16552: Implement the likely resolution of core issue 253.

2016-02-17 Thread Nico Weber via cfe-commits
thakis updated this revision to Diff 48248.
thakis added a comment.

Ok, now cleaned up and caches the "is this ok?" state on a per-record level.


http://reviews.llvm.org/D16552

Files:
  include/clang/AST/DeclCXX.h
  lib/AST/ASTImporter.cpp
  lib/AST/DeclCXX.cpp
  lib/Sema/SemaInit.cpp
  lib/Serialization/ASTReaderDecl.cpp
  lib/Serialization/ASTWriter.cpp
  test/CXX/dcl.decl/dcl.fct.def/dcl.fct.def.default/p2.cpp
  test/CXX/dcl.decl/dcl.init/p6.cpp
  test/SemaCXX/attr-selectany.cpp
  test/SemaCXX/constexpr-value-init.cpp
  test/SemaCXX/cxx0x-cursory-default-delete.cpp
  test/SemaCXX/illegal-member-initialization.cpp

Index: lib/Serialization/ASTWriter.cpp
===
--- lib/Serialization/ASTWriter.cpp
+++ lib/Serialization/ASTWriter.cpp
@@ -5554,6 +5554,7 @@
   Record.push_back(Data.DefaultedMoveAssignmentIsDeleted);
   Record.push_back(Data.DefaultedDestructorIsDeleted);
   Record.push_back(Data.HasTrivialSpecialMembers);
+  Record.push_back(Data.AllowConstDefaultInit);
   Record.push_back(Data.DeclaredNonTrivialSpecialMembers);
   Record.push_back(Data.HasIrrelevantDestructor);
   Record.push_back(Data.HasConstexprNonCopyMoveConstructor);
Index: lib/Serialization/ASTReaderDecl.cpp
===
--- lib/Serialization/ASTReaderDecl.cpp
+++ lib/Serialization/ASTReaderDecl.cpp
@@ -1419,6 +1419,7 @@
   Data.DefaultedMoveAssignmentIsDeleted = Record[Idx++];
   Data.DefaultedDestructorIsDeleted = Record[Idx++];
   Data.HasTrivialSpecialMembers = Record[Idx++];
+  Data.AllowConstDefaultInit = Record[Idx++];
   Data.DeclaredNonTrivialSpecialMembers = Record[Idx++];
   Data.HasIrrelevantDestructor = Record[Idx++];
   Data.HasConstexprNonCopyMoveConstructor = Record[Idx++];
Index: include/clang/AST/DeclCXX.h
===
--- include/clang/AST/DeclCXX.h
+++ include/clang/AST/DeclCXX.h
@@ -402,6 +402,19 @@
 /// which have been declared but not yet defined.
 unsigned HasTrivialSpecialMembers : 6;
 
+enum AllowConstDefInitKind {
+   ACDI_Unknown,
+   ACDI_Yes,
+   ACDI_No,
+};
+unsigned AllowConstDefaultInit : 3;
+AllowConstDefInitKind allowConstDefInitKind() {
+  return static_cast(AllowConstDefaultInit);
+}
+void setAllowConstDefInitKind(AllowConstDefInitKind Allow) {
+  AllowConstDefaultInit = Allow;
+}
+
 /// \brief The declared special members of this class which are known to be
 /// non-trivial.
 ///
@@ -1270,6 +1283,15 @@
 return !(data().HasTrivialSpecialMembers & SMF_Destructor);
   }
 
+  /// \brief Determine whether declaring a const with this type is ok per
+  /// core issue 253.
+  bool allowConstDefaultInitSlow() const;
+  bool allowConstDefaultInit() const {
+if (data().allowConstDefInitKind() != DefinitionData::ACDI_Unknown)
+  return data().allowConstDefInitKind() == DefinitionData::ACDI_Yes;
+return allowConstDefaultInitSlow();
+  }
+
   /// \brief Determine whether this class has a destructor which has no
   /// semantic effect.
   ///
Index: lib/AST/DeclCXX.cpp
===
--- lib/AST/DeclCXX.cpp
+++ lib/AST/DeclCXX.cpp
@@ -59,6 +59,7 @@
 DefaultedMoveAssignmentIsDeleted(false),
 DefaultedDestructorIsDeleted(false),
 HasTrivialSpecialMembers(SMF_All),
+AllowConstDefaultInit(ACDI_Unknown),
 DeclaredNonTrivialSpecialMembers(0),
 HasIrrelevantDestructor(true),
 HasConstexprNonCopyMoveConstructor(false),
@@ -392,6 +393,37 @@
   return !forallBases([](const CXXRecordDecl *) { return true; });
 }
 
+bool CXXRecordDecl::allowConstDefaultInitSlow() const {
+  assert(getDefinition() && "only call this on completed records");
+  if (hasUserProvidedDefaultConstructor()) {
+data().setAllowConstDefInitKind(DefinitionData::ACDI_Yes);
+return true;
+  }
+  for (const auto *F : fields()) {
+if (F->hasInClassInitializer() || F->isUnnamedBitfield())
+  continue;
+if (CXXRecordDecl *FieldType = F->getType()->getAsCXXRecordDecl()) {
+  if (!FieldType->allowConstDefaultInit()) {
+data().setAllowConstDefInitKind(DefinitionData::ACDI_No);
+return false;
+  }
+} else {
+  data().setAllowConstDefInitKind(DefinitionData::ACDI_No);
+  return false;
+}
+  }
+  for (const auto& BI : bases()) {
+const RecordType *RT = BI.getType()->getAs();
+CXXRecordDecl *Base = cast(RT->getDecl());
+if (!Base->allowConstDefaultInit()) {
+  data().setAllowConstDefInitKind(DefinitionData::ACDI_No);
+  return false;
+}
+  }
+  data().setAllowConstDefInitKind(DefinitionData::ACDI_Yes);
+  return true;
+}
+
 bool CXXRecordDecl::isTriviallyCopyable() const {
   // C++0x [class]p5:
   //   A trivially copyable class is a class that:
Index: lib/AST/ASTImporter.cpp
===
--- 

r261171 - Don't crash w/ a diagnostic range containing a null byte

2016-02-17 Thread David Majnemer via cfe-commits
Author: majnemer
Date: Wed Feb 17 16:37:45 2016
New Revision: 261171

URL: http://llvm.org/viewvc/llvm-project?rev=261171=rev
Log:
Don't crash w/ a diagnostic range containing a null byte

We prematurely ended the line at the null byte which caused us to crash
down stream because we tried to reason about columns beyond the end of
the line.

Added:
cfe/trunk/test/Misc/diag-null-bytes-in-line.cpp
Modified:
cfe/trunk/lib/Frontend/TextDiagnostic.cpp

Modified: cfe/trunk/lib/Frontend/TextDiagnostic.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/TextDiagnostic.cpp?rev=261171=261170=261171=diff
==
--- cfe/trunk/lib/Frontend/TextDiagnostic.cpp (original)
+++ cfe/trunk/lib/Frontend/TextDiagnostic.cpp Wed Feb 17 16:37:45 2016
@@ -1082,10 +1082,13 @@ void TextDiagnostic::emitSnippetAndCaret
 
   // Get information about the buffer it points into.
   bool Invalid = false;
-  const char *BufStart = SM.getBufferData(FID, ).data();
+  StringRef BufData = SM.getBufferData(FID, );
   if (Invalid)
 return;
 
+  const char *BufStart = BufData.data();
+  const char *BufEnd = BufStart + BufData.size();
+
   unsigned LineNo = SM.getLineNumber(FID, FileOffset);
   unsigned ColNo = SM.getColumnNumber(FID, FileOffset);
   
@@ -1101,15 +1104,20 @@ void TextDiagnostic::emitSnippetAndCaret
   // Compute the line end.  Scan forward from the error position to the end of
   // the line.
   const char *LineEnd = TokPtr;
-  while (*LineEnd != '\n' && *LineEnd != '\r' && *LineEnd != '\0')
+  while (*LineEnd != '\n' && *LineEnd != '\r' && LineEnd != BufEnd)
 ++LineEnd;
 
   // Arbitrarily stop showing snippets when the line is too long.
   if (size_t(LineEnd - LineStart) > MaxLineLengthToPrint)
 return;
 
+  // Trim trailing null-bytes.
+  StringRef Line(LineStart, LineEnd - LineStart);
+  while (Line.size() > ColNo && Line.back() == '\0')
+Line = Line.drop_back();
+
   // Copy the line of code into an std::string for ease of manipulation.
-  std::string SourceLine(LineStart, LineEnd);
+  std::string SourceLine(Line.begin(), Line.end());
 
   // Build the byte to column map.
   const SourceColumnMap sourceColMap(SourceLine, DiagOpts->TabStop);

Added: cfe/trunk/test/Misc/diag-null-bytes-in-line.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/diag-null-bytes-in-line.cpp?rev=261171=auto
==
Binary files cfe/trunk/test/Misc/diag-null-bytes-in-line.cpp (added) and 
cfe/trunk/test/Misc/diag-null-bytes-in-line.cpp Wed Feb 17 16:37:45 2016 differ


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


Re: [PATCH] D16843: [Sema] Fix bug in TypeLocBuilder::pushImpl

2016-02-17 Thread Akira Hatanaka via cfe-commits
ahatanak updated this revision to Diff 48241.
ahatanak added a comment.

Address some of Manman's review comments.

- Add comments that explain what the code is doing (I should add some 
high-level comments too later).
- Simplify the if-else statement.

I haven't implemented the other changes you've suggested, because I wasn't sure 
whether imitating the code in "LocalAlignment == 4" would improve readability 
of the code. For example, I can declare variable "unsigned Padding = 
NumBytesAtAlign4  %8", but the variable alone doesn't tell you whether there is 
padding or not (if we haven't inserted any 8-byte elements, we won't have any 
paddings, but NumBytesAtAlign4 % 8 can still be non-zero).

Maybe I didn't understand what you were suggesting. Could you elaborate a bit 
more on which part of this code is perhaps hard to understand and how we can 
improve it?


http://reviews.llvm.org/D16843

Files:
  lib/Sema/TypeLocBuilder.cpp
  test/SemaObjCXX/typeloc-data-alignment.mm

Index: test/SemaObjCXX/typeloc-data-alignment.mm
===
--- /dev/null
+++ test/SemaObjCXX/typeloc-data-alignment.mm
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// expected-no-diagnostics
+
+// Make sure this doesn't crash.
+
+@protocol P
+@end
+template 
+id foo(T) {
+  int i;
+  foo(i);
+}
Index: lib/Sema/TypeLocBuilder.cpp
===
--- lib/Sema/TypeLocBuilder.cpp
+++ lib/Sema/TypeLocBuilder.cpp
@@ -115,11 +115,32 @@
   NumBytesAtAlign4 += LocalSize;
 }
   } else if (LocalAlignment == 8) {
-if (!NumBytesAtAlign8 && NumBytesAtAlign4 % 8 != 0) {
-  // No existing padding and misaligned members; add in 4 bytes padding
-  memmove([Index - 4], [Index], NumBytesAtAlign4);
-  Index -= 4;
+// If the new index is not aligned on an 8-byte boundary, adjust the
+// current index.
+bool AdjustIndex = (Index - LocalSize) % 8;
+
+if (AdjustIndex) {
+  // We know there is a 4-byte padding if an 8-byte aligned element has 
been
+  // inserted and the total size of the 4-byte aligned elements that have
+  // been inserted since the last 8-byte aligned element was inserted is 
not
+  // a multiple of 4.
+  bool CurrentlyHasPadding = NumBytesAtAlign8 && NumBytesAtAlign4 % 8;
+
+  if (CurrentlyHasPadding) {
+// There is a 4-byte padding that starts at Index+NumBytesAtAlign4, so
+// we can remove it and shift the 4-byte elements backwards to make 
sure
+// the new element is 8-byte aligned.
+memmove([Index + 4], [Index], NumBytesAtAlign4);
+Index += 4;
+  } else {
+// There is no 4-byte padding we can remove, so we have to insert a
+// 4-byte padding and shift the 4-byte elements forward to make sure
+// the new element is 8-byte aligned.
+memmove([Index - 4], [Index], NumBytesAtAlign4);
+Index -= 4;
+  }
 }
+
 // Forget about any padding.
 NumBytesAtAlign4 = 0;
 NumBytesAtAlign8 += LocalSize;


Index: test/SemaObjCXX/typeloc-data-alignment.mm
===
--- /dev/null
+++ test/SemaObjCXX/typeloc-data-alignment.mm
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// expected-no-diagnostics
+
+// Make sure this doesn't crash.
+
+@protocol P
+@end
+template 
+id foo(T) {
+  int i;
+  foo(i);
+}
Index: lib/Sema/TypeLocBuilder.cpp
===
--- lib/Sema/TypeLocBuilder.cpp
+++ lib/Sema/TypeLocBuilder.cpp
@@ -115,11 +115,32 @@
   NumBytesAtAlign4 += LocalSize;
 }
   } else if (LocalAlignment == 8) {
-if (!NumBytesAtAlign8 && NumBytesAtAlign4 % 8 != 0) {
-  // No existing padding and misaligned members; add in 4 bytes padding
-  memmove([Index - 4], [Index], NumBytesAtAlign4);
-  Index -= 4;
+// If the new index is not aligned on an 8-byte boundary, adjust the
+// current index.
+bool AdjustIndex = (Index - LocalSize) % 8;
+
+if (AdjustIndex) {
+  // We know there is a 4-byte padding if an 8-byte aligned element has been
+  // inserted and the total size of the 4-byte aligned elements that have
+  // been inserted since the last 8-byte aligned element was inserted is not
+  // a multiple of 4.
+  bool CurrentlyHasPadding = NumBytesAtAlign8 && NumBytesAtAlign4 % 8;
+
+  if (CurrentlyHasPadding) {
+// There is a 4-byte padding that starts at Index+NumBytesAtAlign4, so
+// we can remove it and shift the 4-byte elements backwards to make sure
+// the new element is 8-byte aligned.
+memmove([Index + 4], [Index], NumBytesAtAlign4);
+Index += 4;
+  } else {
+// There is no 4-byte padding we can remove, so we have to insert a
+// 4-byte padding and shift the 4-byte elements forward to make sure
+// the new element 

Re: r258524 - Merge templated static member variables, fixes http://llvm.org/pr26179.

2016-02-17 Thread Vassil Vassilev via cfe-commits

On 16/02/16 22:20, Richard Smith wrote:

--- a/lib/Sema/SemaLookup.cpp
+++ b/lib/Sema/SemaLookup.cpp
@@ -419,6 +419,25 @@ static bool isPreferredLookupResult(Sema , 
Sema::LookupNameKind Kind,
  }
}
  
+  // VarDecl can have incomplete array types, prefer the one with more complete

+  // array type.
+  if (VarDecl *DVD = dyn_cast(DUnderlying)) {
+VarDecl *EVD = cast(EUnderlying);
+// Skip local VarDecls with incomplete array type.
+if ((!DVD->isLocalVarDecl() && DVD->hasExternalStorage()) ||
+(!EVD->isLocalVarDecl() && EVD->hasExternalStorage())) {
Why do you need this special case?
No reason, I decided to be conservative. All comments should be 
addressed in the new version of the patch.

+
+  ASTContext  = S.getASTContext();
+
+  if (const ArrayType *DVDTy = C.getAsArrayType(DVD->getType())) {
+const ArrayType *EVDTy = C.getAsArrayType(EVD->getType());
+// Prefer the decl with more complete type if visible.
+return !DVDTy->isIncompleteArrayType() && 
EVDTy->isIncompleteArrayType()
Checking for an array type here seems unnecessary -- it'd be simpler 
to check EVD->getType()->isIncompleteType() && 
!DVD->getType()->isIncompleteType().

+ && S.isVisible(D);
This seems like a very subtle case: we're performing redeclaration 
lookup for a variable declaration X, and we find two results D and E. 
D is hidden but has a complete type. E is visible but has an 
incomplete type. If X has no array bound, it should not inherit one 
from D. But if it does have an array bound, and that bound differs 
from E's bound, we should diagnose the mismatch.


Please add another test to the end of 
merge-incomplete-array-vars.cpp to check this is working:

int c[2]; // expected-error {{different type: 'int [2]' vs 'int [1]'}}
That said, I think this test will fail if you reorder c1 and c2 in the 
module map, but that's a pre-existing bug (see the last FIXME in 
Sema::MergeVarDeclTypes).

+  }
+}
+  }

On Tue, Feb 16, 2016 at 11:12 AM, Vassil Vassilev 
> wrote:


ping...

On 07/02/16 22:33, Vassil Vassilev wrote:

Improve a comment.
--Vassil
On 07/02/16 20:48, Vassil Vassilev wrote:

Would this patch be any better?
--Vassil
On 05/02/16 21:49, Richard Smith wrote:

This belongs in ASTDeclReader::attachPreviousDecl[Impl]. That's
where we propagate data that's supposed to be consistent across
a redeclaration chain from earlier declarations to later ones.

There's another wrinkle here: we should only be propagating the
type from a previous declaration that's declared in the same
scope (in particular, we should skip over declarations declared
as local extern declarations within a function). This may in
some cases require walking backwards along the redeclaration
chain to find the previous declaration that was not a local
extern declaration. That'd be observable in a case like this:

modulemap:
module A { module A1 { header "a1.h" } module A2 { header
"a2.h" } }
module B { header "b.h" }

a1.h:
int a[];

b.h:
void g(int(*)[], int);
void g(int(*)[1], int) = delete;
template void f(T t) {
  extern int a[];
  g(, t);
}

a2.h:
int a[1];

x.cc:
#include "a1.h"
#include "b.h"
void h() { f(0); } // should not produce an error; type of 'a'
within 'f' should not have been updated

That example actually reveals another problem: we really don't
want the completed type to be visible unless there is a visible
declaration with the completed type. That suggests that
propagating the type across the redeclaration chain may be the
wrong approach, and we should instead handle this by changing
isPreferredLookupResult (in SemaLookup.cpp) to prefer a VarDecl
with a complete type over one with an incomplete type.

On Fri, Feb 5, 2016 at 12:27 PM, Vassil Vassilev
> wrote:

I am not sure where else to put this logic if not in
isSameEntity... Could you point me to a better place?
--Vassil

On 05/02/16 19:56, Richard Smith wrote:

On Fri, Feb 5, 2016 at 7:04 AM, Vassil Vassilev
>
wrote:

Good point. Do you have in mind calling
'clang::Sema::MergeVarDeclTypes' or we to just
"duplicate" the logic in
clang::ASTDeclReader::mergeRedeclarable?


It's not safe to call into Sema while we're in a
partially-deserialized state. We know the only interesting
case here is complete versus incomplete array types, so we
don't need anything like the complexity of
MergeVarDeclTypes -- something as easy as "if (new type is
incomplete and old type is not) set new type to old type"
should work.


Re: [PATCH] D17349: ARM: fix VFP asm constraints

2016-02-17 Thread JF Bastien via cfe-commits
jfb added a comment.

As a reference, here's the GCC source (instead of the docs): 
https://raw.githubusercontent.com/gcc-mirror/gcc/master/gcc/config/arm/constraints.md


http://reviews.llvm.org/D17349



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


[PATCH] D17349: ARM: fix VFP asm constraints

2016-02-17 Thread JF Bastien via cfe-commits
jfb created this revision.
jfb added a subscriber: cfe-commits.
Herald added subscribers: rengolin, aemerson.

Rich Felker was sad that clang used 'w' and 'P' for VFP constraints when GCC 
documents them as 't' and 'w':
  https://gcc.gnu.org/onlinedocs/gcc/Machine-Constraints.html

This was added way back in 2008:
  http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20080421/005393.html

http://reviews.llvm.org/D17349

Files:
  lib/Basic/Targets.cpp

Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -4939,8 +4939,8 @@
 default: break;
 case 'l': // r0-r7
 case 'h': // r8-r15
-case 'w': // VFP Floating point register single precision
-case 'P': // VFP Floating point register double precision
+case 't': // VFP Floating point register single precision
+case 'w': // VFP Floating point register double precision
   Info.setAllowsRegister();
   return true;
 case 'I':


Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -4939,8 +4939,8 @@
 default: break;
 case 'l': // r0-r7
 case 'h': // r8-r15
-case 'w': // VFP Floating point register single precision
-case 'P': // VFP Floating point register double precision
+case 't': // VFP Floating point register single precision
+case 'w': // VFP Floating point register double precision
   Info.setAllowsRegister();
   return true;
 case 'I':
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r261163 - Add 'nopartial' qualifier for availability attributes.

2016-02-17 Thread Manman Ren via cfe-commits
Author: mren
Date: Wed Feb 17 16:05:48 2016
New Revision: 261163

URL: http://llvm.org/viewvc/llvm-project?rev=261163=rev
Log:
Add 'nopartial' qualifier for availability attributes.

An optional nopartial can be placed after the platform name.
int bar() __attribute__((availability(macosx,nopartial,introduced=10.12))

When deploying back to a platform version prior to when the declaration was
introduced, with 'nopartial', Clang emits an error specifying that the function
is not introduced yet; without 'nopartial', the behavior stays the same: the
declaration is `weakly linked`.

A member is added to the end of AttributeList to save the location of the
'nopartial' keyword. A bool member is added to AvailabilityAttr.

The diagnostics for 'nopartial' not-yet-introduced is handled in the same way as
we handle unavailable cases.

Reviewed by Doug Gregor and Jordan Rose.

rdar://23791325

Modified:
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/include/clang/Basic/AttrDocs.td
cfe/trunk/include/clang/Basic/DiagnosticGroups.td
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Parse/Parser.h
cfe/trunk/include/clang/Sema/AttributeList.h
cfe/trunk/include/clang/Sema/DelayedDiagnostic.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Parse/ParseDecl.cpp
cfe/trunk/lib/Parse/Parser.cpp
cfe/trunk/lib/Sema/DelayedDiagnostic.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/Sema/attr-availability-macosx.c

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=261163=261162=261163=diff
==
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Wed Feb 17 16:05:48 2016
@@ -450,7 +450,8 @@ def Availability : InheritableAttr {
   let Spellings = [GNU<"availability">];
   let Args = [IdentifierArgument<"platform">, VersionArgument<"introduced">,
   VersionArgument<"deprecated">, VersionArgument<"obsoleted">,
-  BoolArgument<"unavailable">, StringArgument<"message">];
+  BoolArgument<"unavailable">, StringArgument<"message">,
+  BoolArgument<"nopartial">];
   let AdditionalMembers =
 [{static llvm::StringRef getPrettyPlatformName(llvm::StringRef Platform) {
 return llvm::StringSwitch(Platform)

Modified: cfe/trunk/include/clang/Basic/AttrDocs.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AttrDocs.td?rev=261163=261162=261163=diff
==
--- cfe/trunk/include/clang/Basic/AttrDocs.td (original)
+++ cfe/trunk/include/clang/Basic/AttrDocs.td Wed Feb 17 16:05:48 2016
@@ -685,9 +685,14 @@ are:
   Apple's watchOS operating system.  The minimum deployment target is 
specified by
   the ``-mwatchos-version-min=*version*`` command-line argument.
 
-A declaration can be used even when deploying back to a platform version prior
-to when the declaration was introduced.  When this happens, the declaration is
-`weakly linked
+An optional nopartial can be placed after the platform name.
+With the optional nopartial, when deploying back to a platform version prior to
+when the declaration was introduced, Clang emits an error specifying that the
+function is not introduced yet.
+
+Without the optional nopartial, a declaration can be used even when deploying 
back
+to a platform version prior to when the declaration was introduced.  When this
+happens, the declaration is `weakly linked
 
`_,
 as if the ``weak_import`` attribute were added to the declaration.  A
 weakly-linked declaration may or may not be present a run-time, and a program

Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=261163=261162=261163=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Wed Feb 17 16:05:48 2016
@@ -87,6 +87,7 @@ def DeprecatedAttributes : DiagGroup<"de
 def DeprecatedDeclarations : DiagGroup<"deprecated-declarations">;
 def UnavailableDeclarations : DiagGroup<"unavailable-declarations">;
 def PartialAvailability : DiagGroup<"partial-availability">;
+def NotYetIntroducedDeclarations : 
DiagGroup<"not-yet-introduced-declarations">;
 def DeprecatedImplementations :DiagGroup<"deprecated-implementations">;
 def DeprecatedIncrementBool : DiagGroup<"deprecated-increment-bool">;
 def DeprecatedRegister : DiagGroup<"deprecated-register">;

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 

r261161 - [modules] Cache 'acceptable decl' lookups for namespaces. In projects with

2016-02-17 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Wed Feb 17 15:52:44 2016
New Revision: 261161

URL: http://llvm.org/viewvc/llvm-project?rev=261161=rev
Log:
[modules] Cache 'acceptable decl' lookups for namespaces. In projects with
thousands of modules, each of which declares the same namespace, linearly
scanning the redecl chain looking for a visible declaration (once for each leaf
module, for each use) performs very poorly. Namespace visibility can only
decrease when we leave a module during a module build step, and we never care
*which* visible declaration of a namespace we find, so we can cache this very
effectively.

This results in a 35x speedup on one of our internal build steps (2m -> 3.5s),
but is hard to unit test because it requires a very large number of modules.
Ideas for a test appreciated! No functionality change intended other than the
speedup.

Modified:
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaLookup.cpp

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=261161=261160=261161=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Wed Feb 17 15:52:44 2016
@@ -6617,6 +6617,10 @@ public:
   /// template defined within it.
   llvm::DenseSet ();
 
+  /// \brief Map from the most recent declaration of a namespace to the most
+  /// recent visible declaration of that namespace.
+  llvm::DenseMap VisibleNamespaceCache;
+
   /// \brief Whether we are in a SFINAE context that is not associated with
   /// template instantiation.
   ///

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=261161=261160=261161=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Wed Feb 17 15:52:44 2016
@@ -14826,6 +14826,9 @@ void Sema::ActOnModuleEnd(SourceLocation
 VisibleModules = std::move(VisibleModulesStack.back());
 VisibleModulesStack.pop_back();
 VisibleModules.setVisible(Mod, DirectiveLoc);
+// Leaving a module hides namespace names, so our visible namespace cache
+// is now out of date.
+VisibleNamespaceCache.clear();
   }
 }
 

Modified: cfe/trunk/lib/Sema/SemaLookup.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaLookup.cpp?rev=261161=261160=261161=diff
==
--- cfe/trunk/lib/Sema/SemaLookup.cpp (original)
+++ cfe/trunk/lib/Sema/SemaLookup.cpp Wed Feb 17 15:52:44 2016
@@ -1566,6 +1566,10 @@ static NamedDecl *findAcceptableDecl(Sem
   assert(!LookupResult::isVisible(SemaRef, D) && "not in slow case");
 
   for (auto RD : D->redecls()) {
+// Don't bother with extra checks if we already know this one isn't 
visible.
+if (RD == D)
+  continue;
+
 if (auto ND = dyn_cast(RD)) {
   // FIXME: This is wrong in the case where the previous declaration is not
   // visible in the same scope as D. This needs to be done much more
@@ -1579,6 +1583,23 @@ static NamedDecl *findAcceptableDecl(Sem
 }
 
 NamedDecl *LookupResult::getAcceptableDeclSlow(NamedDecl *D) const {
+  if (auto *ND = dyn_cast(D)) {
+// Namespaces are a bit of a special case: we expect there to be a lot of
+// redeclarations of some namespaces, all declarations of a namespace are
+// essentially interchangeable, all declarations are found by name lookup
+// if any is, and namespaces are never looked up during template
+// instantiation. So we benefit from caching the check in this case, and
+// it is correct to do so.
+auto *Key = ND->getCanonicalDecl();
+if (auto *Acceptable = getSema().VisibleNamespaceCache.lookup(Key))
+  return Acceptable;
+auto *Acceptable =
+isVisible(getSema(), Key) ? Key : findAcceptableDecl(getSema(), Key);
+if (Acceptable)
+  getSema().VisibleNamespaceCache.insert(std::make_pair(Key, Acceptable));
+return Acceptable;
+  }
+
   return findAcceptableDecl(getSema(), D);
 }
 


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


Re: [PATCH] D17348: Add -Wcast-calling-convention to warn when casting away calling conventions

2016-02-17 Thread Nico Weber via cfe-commits
thakis added a comment.

Nice!



Comment at: include/clang/Basic/DiagnosticGroups.td:294
@@ -293,2 +293,3 @@
 def SelTypeCast : DiagGroup<"cast-of-sel-type">;
+def CastCallingConvention : DiagGroup<"cast-calling-convention">;
 def FunctionDefInObjCContainer : DiagGroup<"function-def-in-objc-container">;

nit: since this isn't referenced in this file, consider using an unnamed inline 
`InGroup` in the other file instead


Comment at: include/clang/Basic/DiagnosticSemaKinds.td:6515
@@ +6514,3 @@
+def warn_cast_calling_conv : Warning<
+  "cast between incompatible calling conventions '%0' and '%1'">,
+  InGroup, DefaultIgnore;

Maybe add ", likely to abort at runtime" to communicate the gravity of the 
situation better.


Comment at: include/clang/Basic/DiagnosticSemaKinds.td:6516
@@ +6515,3 @@
+  "cast between incompatible calling conventions '%0' and '%1'">,
+  InGroup, DefaultIgnore;
+def note_change_calling_conv_fixit : Note<

I'd build a large codebase of your choice with this enabled and see how it 
does. If it does well I'd land it default-on. (I spent some time enabling 
DefaultIgnore warnings that nobody turned on after they landed recently, and 
I'd prefer to not having to do this for this warning too :-) )


Comment at: lib/Sema/SemaCast.cpp:1762
@@ +1761,3 @@
+
+  // The source expression is a pointer to a known function defined in this TU.
+  // Diagnose this cast, as it is probably bad.

If it's an inline function in a header, would we want to warn? Should this 
check if the body's SourceLocation is from the main file?


Comment at: lib/Sema/SemaCast.cpp:1775
@@ +1774,3 @@
+  Self.Diag(NameLoc, diag::note_change_calling_conv_fixit)
+  << FD << DstCCName << FixItHint::CreateInsertion(NameLoc, CCAttrText);
+}

Consider doing something like r164858 did to see if there's a define for the 
calling convention (WINAPI or what have you) and suggest that instead


http://reviews.llvm.org/D17348



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


[PATCH] D17348: Add -Wcast-calling-convention to warn when casting away calling conventions

2016-02-17 Thread Reid Kleckner via cfe-commits
rnk created this revision.
rnk added reviewers: thakis, rtrieu.
rnk added a subscriber: cfe-commits.

This only warns on casts of the address of a function defined in the
current TU. In this case, the fix is likely to be local and the warning
useful.

Here are some things we could experiment with in the future:
- Fire on declarations as well as definitions
- Limit the warning to non-void function prototypes
- Limit the warning to mismatches of caller and callee cleanup CCs

This warning is currently off by default while we study its usefulness.

http://reviews.llvm.org/D17348

Files:
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaCast.cpp
  test/Sema/callingconv-cast.c

Index: test/Sema/callingconv-cast.c
===
--- /dev/null
+++ test/Sema/callingconv-cast.c
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -verify -triple i686-pc-windows-msvc -Wcast-calling-convention -x c %s
+// RUN: %clang_cc1 -verify -triple i686-pc-windows-msvc -Wcast-calling-convention -x c++ %s
+
+// expected-note@+1 2 {{consider defining 'mismatched' with the 'stdcall' calling convention}}
+void mismatched(int x) {}
+
+typedef void (__stdcall *callback_t)(int);
+void take_callback(callback_t callback);
+
+int main() {
+  // expected-warning@+1 {{cast between incompatible calling conventions 'cdecl' and 'stdcall'}}
+  take_callback((callback_t)mismatched);
+
+  // expected-warning@+1 {{cast between incompatible calling conventions 'cdecl' and 'stdcall'}}
+  callback_t callback = (callback_t)mismatched; // warns
+  (void)callback;
+
+  // Probably a bug, but we don't warn.
+  void (*callback2)(int) = mismatched;
+  take_callback((callback_t)callback2);
+
+  // Another way to suppress the warning.
+  take_callback((callback_t)(void*)mismatched);
+}
Index: lib/Sema/SemaCast.cpp
===
--- lib/Sema/SemaCast.cpp
+++ lib/Sema/SemaCast.cpp
@@ -1724,6 +1724,57 @@
 }
 }
 
+/// Diagnose casts that change the calling convention of a pointer to a function
+/// defined in the current TU.
+static void diagnoseCallingConvCast(Sema , const ExprResult ,
+QualType DstType, SourceRange OpRange) {
+  if (Self.Diags.isIgnored(diag::warn_cast_calling_conv, OpRange.getBegin()))
+return;
+
+  // Check if this cast would change the calling convention of a function
+  // pointer type.
+  QualType SrcType = SrcExpr.get()->getType();
+  if (Self.Context.hasSameType(SrcType, DstType) ||
+  !SrcType->isFunctionPointerType() || !DstType->isFunctionPointerType())
+return;
+  const auto *SrcFTy =
+  SrcType->castAs()->getPointeeType()->castAs();
+  const auto *DstFTy =
+  DstType->castAs()->getPointeeType()->castAs();
+  CallingConv SrcCC = SrcFTy->getCallConv();
+  CallingConv DstCC = DstFTy->getCallConv();
+  if (SrcCC == DstCC)
+return;
+
+  // We have a calling convention cast. Check if the source is a pointer to a
+  // known, specific function that has already been defined.
+  Expr *Src = SrcExpr.get()->IgnoreParenImpCasts();
+  if (auto *AddrOf = dyn_cast(Src))
+Src = AddrOf->getSubExpr()->IgnoreParenImpCasts();
+  auto *DRE = dyn_cast(Src);
+  if (!DRE)
+return;
+  auto *FD = dyn_cast(DRE->getDecl());
+  const FunctionDecl *Definition;
+  if (!FD || !FD->hasBody(Definition))
+return;
+
+  // The source expression is a pointer to a known function defined in this TU.
+  // Diagnose this cast, as it is probably bad.
+  StringRef SrcCCName = FunctionType::getNameForCallConv(SrcCC);
+  StringRef DstCCName = FunctionType::getNameForCallConv(DstCC);
+  Self.Diag(OpRange.getBegin(), diag::warn_cast_calling_conv)
+  << SrcCCName << DstCCName << OpRange;
+  SourceLocation NameLoc = Definition->getNameInfo().getLoc();
+  SmallString<64> CCAttrText;
+  if (Self.getLangOpts().MicrosoftExt)
+(Twine("__") + DstCCName + " ").toVector(CCAttrText);
+  else
+(Twine("__attribute__((") + DstCCName + ")) ").toVector(CCAttrText);
+  Self.Diag(NameLoc, diag::note_change_calling_conv_fixit)
+  << FD << DstCCName << FixItHint::CreateInsertion(NameLoc, CCAttrText);
+}
+
 static void checkIntToPointerCast(bool CStyle, SourceLocation Loc,
   const Expr *SrcExpr, QualType DestType,
   Sema ) {
@@ -2008,7 +2059,9 @@
   }
   if (CStyle)
 DiagnoseCastOfObjCSEL(Self, SrcExpr, DestType);
-  
+
+  diagnoseCallingConvCast(Self, SrcExpr, DestType, OpRange);
+
   // Not casting away constness, so the only remaining check is for compatible
   // pointer categories.
 
@@ -2427,6 +2480,7 @@
   }
   
   DiagnoseCastOfObjCSEL(Self, SrcExpr, DestType);
+  diagnoseCallingConvCast(Self, SrcExpr, DestType, OpRange);
   DiagnoseBadFunctionCast(Self, SrcExpr, DestType);
   Kind = Self.PrepareScalarCast(SrcExpr, DestType);
   if (SrcExpr.isInvalid())
Index: 

Re: [PATCH] D16686: [OpenCL] Generate metadata for opencl_unroll_hint attribute

2016-02-17 Thread Yaxun Liu via cfe-commits
yaxunl added a comment.

ping


http://reviews.llvm.org/D16686



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


Re: [PATCH] D16914: [CodeGen] Fix an assert in CodeGenFunction::EmitFunctionEpilog

2016-02-17 Thread Akira Hatanaka via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL261151: [CodeGen] Fix an assert in 
CodeGenFunction::EmitFunctionEpilog (authored by ahatanak).

Changed prior to commit:
  http://reviews.llvm.org/D16914?vs=47062=48232#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D16914

Files:
  cfe/trunk/lib/CodeGen/CGCall.cpp
  cfe/trunk/test/CodeGenObjCXX/auto-release-result-assert.mm

Index: cfe/trunk/test/CodeGenObjCXX/auto-release-result-assert.mm
===
--- cfe/trunk/test/CodeGenObjCXX/auto-release-result-assert.mm
+++ cfe/trunk/test/CodeGenObjCXX/auto-release-result-assert.mm
@@ -0,0 +1,35 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -fblocks 
-fobjc-arc -o - %s | FileCheck %s
+
+// CHECK-LABEL: define %struct.S1* @_Z4foo1i(
+// CHECK: %[[CALL:[a-z0-9]+]] = call %struct.S1* @_Z4foo0i
+// CHECK: ret %struct.S1* %[[CALL]]
+
+// CHECK-LABEL: define %struct.S1* @_ZN2S22m1Ev(
+// CHECK: %[[CALL:[a-z0-9]+]] = call %struct.S1* @_Z4foo0i
+// CHECK: ret %struct.S1* %[[CALL]]
+
+// CHECK-LABEL: define internal %struct.S1* @Block1_block_invoke(
+// CHECK: %[[CALL:[a-z0-9]+]] = call %struct.S1* @_Z4foo0i
+// CHECK: ret %struct.S1* %[[CALL]]
+
+struct S1;
+
+typedef __attribute__((NSObject)) struct __attribute__((objc_bridge(id))) S1 * 
S1Ref;
+
+S1Ref foo0(int);
+
+struct S2 {
+  S1Ref m1();
+};
+
+S1Ref foo1(int a) {
+  return foo0(a);
+}
+
+S1Ref S2::m1() {
+  return foo0(0);
+}
+
+S1Ref (^Block1)(void) = ^{
+  return foo0(0);
+};
Index: cfe/trunk/lib/CodeGen/CGCall.cpp
===
--- cfe/trunk/lib/CodeGen/CGCall.cpp
+++ cfe/trunk/lib/CodeGen/CGCall.cpp
@@ -14,6 +14,7 @@
 
 #include "CGCall.h"
 #include "ABIInfo.h"
+#include "CGBlocks.h"
 #include "CGCXXABI.h"
 #include "CGCleanup.h"
 #include "CodeGenFunction.h"
@@ -2462,9 +2463,26 @@
 // In ARC, end functions that return a retainable type with a call
 // to objc_autoreleaseReturnValue.
 if (AutoreleaseResult) {
+#ifndef NDEBUG
+  // Type::isObjCRetainabletype has to be called on a QualType that hasn't
+  // been stripped of the typedefs, so we cannot use RetTy here. Get the
+  // original return type of FunctionDecl, CurCodeDecl, and BlockDecl from
+  // CurCodeDecl or BlockInfo.
+  QualType RT;
+
+  if (auto *FD = dyn_cast(CurCodeDecl))
+RT = FD->getReturnType();
+  else if (auto *MD = dyn_cast(CurCodeDecl))
+RT = MD->getReturnType();
+  else if (isa(CurCodeDecl))
+RT = BlockInfo->BlockExpression->getFunctionType()->getReturnType();
+  else
+llvm_unreachable("Unexpected function/method type");
+
   assert(getLangOpts().ObjCAutoRefCount &&
  !FI.isReturnsRetained() &&
- RetTy->isObjCRetainableType());
+ RT->isObjCRetainableType());
+#endif
   RV = emitAutoreleaseOfResult(*this, RV);
 }
 


Index: cfe/trunk/test/CodeGenObjCXX/auto-release-result-assert.mm
===
--- cfe/trunk/test/CodeGenObjCXX/auto-release-result-assert.mm
+++ cfe/trunk/test/CodeGenObjCXX/auto-release-result-assert.mm
@@ -0,0 +1,35 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -fblocks -fobjc-arc -o - %s | FileCheck %s
+
+// CHECK-LABEL: define %struct.S1* @_Z4foo1i(
+// CHECK: %[[CALL:[a-z0-9]+]] = call %struct.S1* @_Z4foo0i
+// CHECK: ret %struct.S1* %[[CALL]]
+
+// CHECK-LABEL: define %struct.S1* @_ZN2S22m1Ev(
+// CHECK: %[[CALL:[a-z0-9]+]] = call %struct.S1* @_Z4foo0i
+// CHECK: ret %struct.S1* %[[CALL]]
+
+// CHECK-LABEL: define internal %struct.S1* @Block1_block_invoke(
+// CHECK: %[[CALL:[a-z0-9]+]] = call %struct.S1* @_Z4foo0i
+// CHECK: ret %struct.S1* %[[CALL]]
+
+struct S1;
+
+typedef __attribute__((NSObject)) struct __attribute__((objc_bridge(id))) S1 * S1Ref;
+
+S1Ref foo0(int);
+
+struct S2 {
+  S1Ref m1();
+};
+
+S1Ref foo1(int a) {
+  return foo0(a);
+}
+
+S1Ref S2::m1() {
+  return foo0(0);
+}
+
+S1Ref (^Block1)(void) = ^{
+  return foo0(0);
+};
Index: cfe/trunk/lib/CodeGen/CGCall.cpp
===
--- cfe/trunk/lib/CodeGen/CGCall.cpp
+++ cfe/trunk/lib/CodeGen/CGCall.cpp
@@ -14,6 +14,7 @@
 
 #include "CGCall.h"
 #include "ABIInfo.h"
+#include "CGBlocks.h"
 #include "CGCXXABI.h"
 #include "CGCleanup.h"
 #include "CodeGenFunction.h"
@@ -2462,9 +2463,26 @@
 // In ARC, end functions that return a retainable type with a call
 // to objc_autoreleaseReturnValue.
 if (AutoreleaseResult) {
+#ifndef NDEBUG
+  // Type::isObjCRetainabletype has to be called on a QualType that hasn't
+  // been stripped of the typedefs, so we cannot use RetTy here. Get the
+  // original return type of FunctionDecl, CurCodeDecl, and BlockDecl from
+  // CurCodeDecl or BlockInfo.
+  QualType RT;
+
+  if (auto *FD = dyn_cast(CurCodeDecl))
+

r261151 - [CodeGen] Fix an assert in CodeGenFunction::EmitFunctionEpilog

2016-02-17 Thread Akira Hatanaka via cfe-commits
Author: ahatanak
Date: Wed Feb 17 15:09:50 2016
New Revision: 261151

URL: http://llvm.org/viewvc/llvm-project?rev=261151=rev
Log:
[CodeGen] Fix an assert in CodeGenFunction::EmitFunctionEpilog

The assert is triggered because isObjCRetainableType() is called on the
canonicalized return type that has been stripped of the typedefs and
attributes attached to it. To fix this assert, this commit gets the
original return type from CurCodeDecl or BlockInfo and uses it instead
of the canoicalized type.

rdar://problem/24470031

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

Added:
cfe/trunk/test/CodeGenObjCXX/auto-release-result-assert.mm
Modified:
cfe/trunk/lib/CodeGen/CGCall.cpp

Modified: cfe/trunk/lib/CodeGen/CGCall.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=261151=261150=261151=diff
==
--- cfe/trunk/lib/CodeGen/CGCall.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCall.cpp Wed Feb 17 15:09:50 2016
@@ -14,6 +14,7 @@
 
 #include "CGCall.h"
 #include "ABIInfo.h"
+#include "CGBlocks.h"
 #include "CGCXXABI.h"
 #include "CGCleanup.h"
 #include "CodeGenFunction.h"
@@ -2462,9 +2463,26 @@ void CodeGenFunction::EmitFunctionEpilog
 // In ARC, end functions that return a retainable type with a call
 // to objc_autoreleaseReturnValue.
 if (AutoreleaseResult) {
+#ifndef NDEBUG
+  // Type::isObjCRetainabletype has to be called on a QualType that hasn't
+  // been stripped of the typedefs, so we cannot use RetTy here. Get the
+  // original return type of FunctionDecl, CurCodeDecl, and BlockDecl from
+  // CurCodeDecl or BlockInfo.
+  QualType RT;
+
+  if (auto *FD = dyn_cast(CurCodeDecl))
+RT = FD->getReturnType();
+  else if (auto *MD = dyn_cast(CurCodeDecl))
+RT = MD->getReturnType();
+  else if (isa(CurCodeDecl))
+RT = BlockInfo->BlockExpression->getFunctionType()->getReturnType();
+  else
+llvm_unreachable("Unexpected function/method type");
+
   assert(getLangOpts().ObjCAutoRefCount &&
  !FI.isReturnsRetained() &&
- RetTy->isObjCRetainableType());
+ RT->isObjCRetainableType());
+#endif
   RV = emitAutoreleaseOfResult(*this, RV);
 }
 

Added: cfe/trunk/test/CodeGenObjCXX/auto-release-result-assert.mm
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjCXX/auto-release-result-assert.mm?rev=261151=auto
==
--- cfe/trunk/test/CodeGenObjCXX/auto-release-result-assert.mm (added)
+++ cfe/trunk/test/CodeGenObjCXX/auto-release-result-assert.mm Wed Feb 17 
15:09:50 2016
@@ -0,0 +1,35 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -fblocks 
-fobjc-arc -o - %s | FileCheck %s
+
+// CHECK-LABEL: define %struct.S1* @_Z4foo1i(
+// CHECK: %[[CALL:[a-z0-9]+]] = call %struct.S1* @_Z4foo0i
+// CHECK: ret %struct.S1* %[[CALL]]
+
+// CHECK-LABEL: define %struct.S1* @_ZN2S22m1Ev(
+// CHECK: %[[CALL:[a-z0-9]+]] = call %struct.S1* @_Z4foo0i
+// CHECK: ret %struct.S1* %[[CALL]]
+
+// CHECK-LABEL: define internal %struct.S1* @Block1_block_invoke(
+// CHECK: %[[CALL:[a-z0-9]+]] = call %struct.S1* @_Z4foo0i
+// CHECK: ret %struct.S1* %[[CALL]]
+
+struct S1;
+
+typedef __attribute__((NSObject)) struct __attribute__((objc_bridge(id))) S1 * 
S1Ref;
+
+S1Ref foo0(int);
+
+struct S2 {
+  S1Ref m1();
+};
+
+S1Ref foo1(int a) {
+  return foo0(a);
+}
+
+S1Ref S2::m1() {
+  return foo0(0);
+}
+
+S1Ref (^Block1)(void) = ^{
+  return foo0(0);
+};


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


Re: [PATCH] D17345: [OpenCL] Improve diagnostics of address spaces for variables inside function

2016-02-17 Thread Yaxun Liu via cfe-commits
yaxunl added inline comments.


Comment at: include/clang/Basic/DiagnosticSemaKinds.td:7653
@@ -7654,1 +7652,3 @@
+def err_opencl_function_variable : Error<
+  "%select{non-kernel function|non-program scope}0 variable cannot be declared 
in %1 address space">;
 def err_static_function_scope : Error<

is it better to use 'function scope' instead of 'non-program scope' ?


Comment at: test/SemaOpenCL/storageclass-cl20.cl:1
@@ -1,2 +1,2 @@
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -DCL20 -cl-std=CL2.0
 

remove -DCL20


Comment at: test/SemaOpenCL/storageclass-cl20.cl:23
@@ -19,1 +22,3 @@
+  extern global int G5;
+  extern int G6; // expected-error{{program scope variable must reside in 
global or constant address space}}
 }

'extern int G6' refers to a program-scope variable 'int G6', since the default 
addr space of program-scope var is global, shouldn't 'extern int G6' have 
global addr space by default instead of private addr space?


http://reviews.llvm.org/D17345



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


Re: [PATCH] D17244: [clang-tidy] readability-ternary-operator new check

2016-02-17 Thread Kirill Bobyrev via cfe-commits
omtcyf0 updated this revision to Diff 48231.
omtcyf0 added a comment.

Followed some suggestions Richard has kindly given me; fixed the nonsense in 
SourceRanges' extracting code


http://reviews.llvm.org/D17244

Files:
  clang-tidy/readability/BracesAroundStatementsCheck.cpp
  clang-tidy/readability/CMakeLists.txt
  clang-tidy/readability/ReadabilityTidyModule.cpp
  clang-tidy/readability/TernaryOperatorCheck.cpp
  clang-tidy/readability/TernaryOperatorCheck.h
  clang-tidy/utils/LexerUtils.cpp
  clang-tidy/utils/LexerUtils.h
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/readability-ternary-operator.rst
  test/clang-tidy/readability-ternary-operator.cpp

Index: test/clang-tidy/readability-ternary-operator.cpp
===
--- /dev/null
+++ test/clang-tidy/readability-ternary-operator.cpp
@@ -0,0 +1,134 @@
+// RUN: %check_clang_tidy %s readability-ternary-operator %t
+
+bool Condition = true;
+int Variable = 0;
+
+void call_me(int value);
+void or_me(int value);
+
+//===--===//
+// Section #0: warnings without autofixes
+//===--===//
+
+int foo() {
+  // regular expressions
+  if (Condition) {
+Variable++; // comment
+  } else {
+Variable--;
+  }
+  // CHECK-MESSAGES: :[[@LINE-5]]:3: warning: use ternary operator
+
+  if (Condition) {
+call_me(0);
+  } else {
+/* something */or_me(1);
+  }
+  // CHECK-MESSAGES: :[[@LINE-5]]:3: warning: use ternary operator
+
+  // autofixing is not currently supported for ReturnStmt's
+  if (Condition) {
+return 0;
+  } else {
+return 1;
+  }
+  // CHECK-MESSAGES: :[[@LINE-5]]:3: warning: use ternary operator
+
+  if (true || /* whatever */ false) {
+call_me(0);
+  } else {
+or_me(/* whoops; */ 0);
+  }
+  // CHECK-MESSAGES: :[[@LINE-5]]:3: warning: use ternary operator
+
+  if (Condition) {
+#define BLAH 1
+Variable++;
+  } else {
+Variable--;
+  }
+  // CHECK-MESSAGES: :[[@LINE-6]]:3: warning: use ternary operator
+}
+
+//===--===//
+// Section #1: warnings with autofixes
+//===--===//
+
+void boo() {
+  // regular expressions
+  if (Condition) {
+Variable++;
+  } else {
+Variable--;
+  }
+  // CHECK-MESSAGES: :[[@LINE-5]]:3: warning: use ternary operator
+  // CHECK-FIXES: (Condition) ? Variable++ : Variable--;
+
+  if (Condition)
+Variable++;
+  else {
+Variable--;
+  }
+  // CHECK-MESSAGES: :[[@LINE-5]]:3: warning: use ternary operator
+  // CHECK-FIXES: (Condition) ? Variable++ : Variable--;
+
+  if (Condition) {
+Variable++;
+  } else
+Variable--;
+  // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use ternary operator
+  // CHECK-FIXES: (Condition) ? Variable++ : Variable--;
+
+  if (Condition)
+Variable++;
+  else
+Variable--;
+  // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use ternary operator
+  // CHECK-FIXES: (Condition) ? Variable++ : Variable--;
+
+  if (Condition) {
+call_me(0);
+  } else {
+or_me(0);
+  }
+  // CHECK-MESSAGES: :[[@LINE-5]]:3: warning: use ternary operator
+  // CHECK-FIXES: (Condition) ? call_me(0) : or_me(0);
+
+  // p00rly f0rm4tt3d c0d3
+  if ( true || false ) {true;} else false;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use ternary operator
+  // CHECK-FIXES: ( true || false ) ?true : false;
+
+  if (true)true;else false;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use ternary operator
+  // CHECK-FIXES: (true) ?true : false;
+
+  if (true){true;}else false;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use ternary operator
+  // CHECK-FIXES: (true) ?true : false;
+
+  if (true)true;else{false;}
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use ternary operator
+  // CHECK-FIXES: (true) ?true :false;
+}
+
+//===--===//
+// Section #2: no warnings and autofixes
+//===--===//
+
+void baz() {
+  if (Condition) {
+Variable = 0;
+  } else if (!Condition) {
+Variable = 1;
+  } else {
+Variable = 2;
+  }
+
+  if (Condition) {
+Variable++;
+Variable--;
+  } else {
+Variable++;
+  }
+}
Index: docs/clang-tidy/checks/readability-ternary-operator.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/readability-ternary-operator.rst
@@ -0,0 +1,26 @@
+.. title:: clang-tidy - readability-ternary-operator
+
+readability-ternary-operator
+
+
+This check suggests using ternary operator in where it's possible to do so.
+A typical case where it might improve readability follows this pattern::
+  if (condition) expression0; else expression1;
+And it gets transformed into::
+  (condition ? 

Re: [PATCH] D17343: [OpenCL] Diagnose program scope pointers

2016-02-17 Thread Yaxun Liu via cfe-commits
yaxunl added a comment.

I am not sure about the restriction that program scope pointer must point to 
global or constant addr space. Can you provide reference to the OpenCL 2.0 spec?

https://www.khronos.org/registry/cl/specs/opencl-2.0-openclc.pdf

On page 36 there are examples for program-scope pointers:

int *foo; // OK. foo is allocated in global address space.

  // pointer to foo in generic address space

int * global ptr; // OK.

It seems at least program-scope pointers pointing to generic addr space is also 
allowed.


http://reviews.llvm.org/D17343



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


Re: [PATCH] D15314: Fix a bug in unavailable checking

2016-02-17 Thread Manman Ren via cfe-commits
manmanren added a comment.

Doug,

Thanks for reviewing! I updated the patch to use TreatUnavailableAsInvalid.

Cheers,
Manman


http://reviews.llvm.org/D15314



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


Re: [PATCH] D17019: [OpenMP] Code generation for teams - kernel launching

2016-02-17 Thread Samuel Antao via cfe-commits
sfantao added a comment.

Hi Alexey,

Thanks for the review!



Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:3811-3818
@@ -3789,1 +3810,10 @@
   DeviceID, FileID, ParentName, Line, Column, OutlinedFn, OutlinedFnID);
+
+  // If the current target region has a teams region enclosed, we need to get
+  // the number of teams and thread limit to pass to the runtime function call
+  // later on. This is done through a function that returns the value. This is
+  // required because the expression is captured in the enclosing target
+  // environment when the teams directive is not combined with target. This 
only
+  // has to be done for the host.
+  //
+  // FIXME: Accommodate other combined directives with teams when they become

ABataev wrote:
> It is better to use OMPCapturedExprDecl for this, just like it is done for 
> schedule clause
I don't think that would completel solve the problem in this case. In my 
understanding the problem I have here is slightly differetn than the one 
`OMPCapturedExprDecl` attempts to solve:

I have a clause (num_teams/thread_limit) that is part of an enclosed directive 
(teams) that I need to emit in the outer scope (target). If I create a 
OMPCapturedExprDecl, that would have to go with some dummy clause for the 
target  so that the initializer is emitted at the target lexical scope, and 
that emission would only work because in most directives the captures are local 
variables of the enclosing scope, and emission on the locals takes precedence 
over declaration that "refer to enclosing capture". However, target directive 
is special in the sense that it also captures global variables. So if I use 
OMPCapturedExprDecl on a expression that refers to globals that will cause a 
crash during the emission of the initializer because the capture of the target 
directive was not created yet. The patch has regression tests exactly to test 
this subtle difference in the target directive.

I am not saying that there are no other ways of doing this, but this approach 
seemed to me as the least disruptive as it is self-contained in the target 
codegen.

Let me know if you disagree.


Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:3822-3857
@@ -3790,1 +3821,38 @@
+  if (!CGM.getLangOpts().OpenMPIsDevice)
+if (auto *TeamsDir = dyn_cast(CS.getCapturedStmt())) {
+  if (auto *NTE = TeamsDir->getSingleClause()) {
+auto & = [NTE](CodeGenFunction ) {
+  auto *V = CGF.EmitScalarExpr(NTE->getNumTeams());
+  CGF.Builder.CreateRet(
+  CGF.Builder.CreateIntCast(V, CGF.Int32Ty, /*isSigned=*/true));
+  CGF.EmitBlock(CGF.createBasicBlock());
+};
+
+CodeGenFunction CGF(CGM, true);
+CGOpenMPTargetRegionInfo CGInfo(CS, CodeGen,
+".omp_offload.get_num_teams");
+CodeGenFunction::CGCapturedStmtRAII CapInfoRAII(CGF, );
+
+NestedNumTeamsFn =
+CGF.GenerateOpenMPCapturedStmtFunction(CS, CGM.getContext().IntTy);
+NestedNumTeamsFn->addFnAttr(llvm::Attribute::AlwaysInline);
+  }
+  if (auto *TLE = TeamsDir->getSingleClause()) {
+auto & = [TLE](CodeGenFunction ) {
+  auto *V = CGF.EmitScalarExpr(TLE->getThreadLimit());
+  CGF.Builder.CreateRet(
+  CGF.Builder.CreateIntCast(V, CGF.Int32Ty, /*isSigned=*/true));
+  CGF.EmitBlock(CGF.createBasicBlock());
+};
+
+CodeGenFunction CGF(CGM, true);
+CGOpenMPTargetRegionInfo CGInfo(CS, CodeGen,
+".omp_offload.get_thread_limit");
+CodeGenFunction::CGCapturedStmtRAII CapInfoRAII(CGF, );
+
+NestedThreadLimitFn =
+CGF.GenerateOpenMPCapturedStmtFunction(CS, CGM.getContext().IntTy);
+NestedThreadLimitFn->addFnAttr(llvm::Attribute::AlwaysInline);
+  }
+}
   return;

ABataev wrote:
> Please, do it in separate functions
I centralized the emission of num_teams and thread_limit in a function.


Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:4148-4161
@@ +4147,16 @@
+  llvm::Value *ThreadLimit = nullptr;
+  if (TD->getSingleClause()) {
+assert(NestedNumTeamsFn && "Helper function is required to get the "
+   "number of teams of an enclosed teams "
+   "directive.");
+NumTeams = CGF.Builder.CreateCall(NestedNumTeamsFn, BasePointers);
+  } else
+NumTeams = CGF.Builder.getInt32(0);
+  if (TD->getSingleClause()) {
+assert(NestedThreadLimitFn && "Helper function is required to get the "
+  "thread limit of an enclosed teams "
+  "directive.");
+ThreadLimit = CGF.Builder.CreateCall(NestedThreadLimitFn, 
BasePointers);
+  } else
+ThreadLimit = CGF.Builder.getInt32(0);
+

ABataev wrote:
> Again, all 

Re: [PATCH] D17019: [OpenMP] Code generation for teams - kernel launching

2016-02-17 Thread Samuel Antao via cfe-commits
sfantao updated this revision to Diff 48229.
sfantao marked 4 inline comments as done.
sfantao updated the summary for this revision.
sfantao added a comment.

Separate emission of num_teams and thread_limit into functions.


http://reviews.llvm.org/D17019

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

Index: test/OpenMP/teams_codegen.cpp
===
--- /dev/null
+++ test/OpenMP/teams_codegen.cpp
@@ -0,0 +1,211 @@
+// expected-no-diagnostics
+#ifndef HEADER
+#define HEADER
+// Test host codegen.
+// RUN: %clang_cc1 -DCK1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -omptargets=powerpc64le-ibm-linux-gnu -emit-llvm %s -o - | FileCheck %s --check-prefix CK1 --check-prefix CK1-64
+// RUN: %clang_cc1 -DCK1 -fopenmp -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -omptargets=powerpc64le-ibm-linux-gnu -emit-pch -o %t %s
+// RUN: %clang_cc1 -DCK1 -fopenmp -x c++ -triple powerpc64le-unknown-unknown -omptargets=powerpc64le-ibm-linux-gnu -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix CK1 --check-prefix CK1-64
+// RUN: %clang_cc1 -DCK1 -verify -fopenmp -x c++ -triple i386-unknown-unknown -omptargets=i386-pc-linux-gnu -emit-llvm %s -o - | FileCheck %s --check-prefix CK1 --check-prefix CK1-32
+// RUN: %clang_cc1 -DCK1 -fopenmp -x c++ -std=c++11 -triple i386-unknown-unknown -omptargets=i386-pc-linux-gnu -emit-pch -o %t %s
+// RUN: %clang_cc1 -DCK1 -fopenmp -x c++ -triple i386-unknown-unknown -omptargets=i386-pc-linux-gnu -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix CK1 --check-prefix CK1-32
+#ifdef CK1
+
+int Gbla;
+long long Gblb;
+
+// CK1-LABEL: teams_argument_global_local
+int teams_argument_global_local(int a){
+  int comp = 1;
+
+  int la = 23;
+  float lc = 25.0;
+
+  // CK1: call i32 @__tgt_target_teams(i32 -1, i8* @{{[^,]+}}, i32 1, i8** %{{[^,]+}}, i8** %{{[^,]+}}, i{{64|32}}* {{.+}}@{{[^,]+}}, i32 0, i32 0), i32* {{.+}}@{{[^,]+}}, i32 0, i32 0), i32 0, i32 0)
+  // CK1: call void @{{.+}}(i{{64|32}} %{{.+}})
+  #pragma omp target
+  #pragma omp teams
+  {
+++comp;
+  }
+
+  // CK1-DAG: call i32 @__tgt_target_teams(i32 -1, i8* @{{[^,]+}}, i32 2, i8** %{{[^,]+}}, i8** %{{[^,]+}}, i{{64|32}}* {{.+}}@{{[^,]+}}, i32 0, i32 0), i32* {{.+}}@{{[^,]+}}, i32 0, i32 0), i32 [[NT:%[^,]+]], i32 0)
+  // CK1-DAG: [[NT]] = load i32, i32* [[NTA:%[^,]+]],
+  // CK1-64-DAG: [[NTA]] = bitcast i64* [[NTB:%[^,]+]] to i32*
+  // CK1-64-DAG: store i64 [[NTC:%[^,]+]], i64* [[NTB]],
+  // CK1-64-DAG: [[NTC]] = load i64, i64* [[NTD:%[^,]+]],
+  // CK1-64-DAG: [[NTE:%[^,]+]] = bitcast i64* [[NTD]] to i32*
+  // CK1-64-DAG: store i32 [[NTF:%[^,]+]], i32* [[NTE]],
+  // CK1-64-DAG: [[NTF]] = load i32, i32* {{%[^,]+}},
+
+
+  // CK1: call void @{{.+}}(i{{64|32}} %{{.+}})
+  #pragma omp target
+  #pragma omp teams num_teams(la)
+  {
+++comp;
+  }
+
+  // CK1-DAG: call i32 @__tgt_target_teams(i32 -1, i8* @{{[^,]+}}, i32 2, i8** %{{[^,]+}}, i8** %{{[^,]+}}, i{{64|32}}* {{.+}}@{{[^,]+}}, i32 0, i32 0), i32* {{.+}}@{{[^,]+}}, i32 0, i32 0), i32 0, i32 [[NT:%[^,]+]])
+  // CK1-DAG: [[NT]] = load i32, i32* [[NTA:%[^,]+]],
+  // CK1-64-DAG: [[NTA]] = bitcast i64* [[NTB:%[^,]+]] to i32*
+  // CK1-64-DAG: store i64 [[NTC:%[^,]+]], i64* [[NTB]],
+  // CK1-64-DAG: [[NTC]] = load i64, i64* [[NTD:%[^,]+]],
+  // CK1-64-DAG: [[NTE:%[^,]+]] = bitcast i64* [[NTD]] to i32*
+  // CK1-64-DAG: store i32 [[NTF:%[^,]+]], i32* [[NTE]],
+  // CK1-64-DAG: [[NTF]] = load i32, i32* {{%[^,]+}},
+  // CK1: call void @{{.+}}(i{{64|32}} %{{.+}})
+  #pragma omp target
+  #pragma omp teams thread_limit(la)
+  {
+++comp;
+  }
+
+  // CK1-DAG: call i32 @__tgt_target_teams(i32 -1, i8* @{{[^,]+}}, i32 5, i8** %{{[^,]+}}, i8** %{{[^,]+}}, i{{64|32}}* {{.+}}@{{[^,]+}}, i32 0, i32 0), i32* {{.+}}@{{[^,]+}}, i32 0, i32 0), i32 [[NT:%[^,]+]], i32 [[TL:%[^,]+]])
+
+  // CK1-DAG: [[NT]] = add nsw i32 [[NTA:%[^,]+]], [[NTB:%[^,]+]]
+  // CK1-64-DAG: [[NTB]] = load i32, i32* %c{{.+}},
+  // CK1-64-DAG: [[NTA]] = load i32, i32* %c{{.+}},
+
+  // CK1-DAG: [[TL]] = trunc i64 [[TLA:%[^,]+]] to i32
+  // CK1-DAG: [[TLA]] = add nsw i64 [[TLB:%[^,]+]], [[TLC:%[^,]+]]
+  // CK1-DAG: [[TLC]] = fptosi float [[TLD:%[^,]+]] to i64
+  // CK1-DAG: [[TLD]] = load float, float* %{{.+}},
+  // CK1-DAG: [[TLB]] = load i64, i64* %{{.+}},
+
+  // CK1: call void @{{.+}}(i{{.+}} {{.+}}, i{{.+}} {{.+}}, i{{.+}} {{.+}}, i{{.+}} {{.+}}, i{{.+}} {{.+}})
+  #pragma omp target
+  #pragma omp teams num_teams(Gbla+a) thread_limit(Gblb+(long long)lc)
+  {
+++comp;
+  }
+
+  return comp;
+}
+
+#endif // CK1
+
+// Test host codegen.
+// RUN: %clang_cc1 -DCK2 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -omptargets=powerpc64le-ibm-linux-gnu -emit-llvm %s -o - | FileCheck %s --check-prefix CK2 --check-prefix CK2-64

Re: [PATCH] D15314: Fix a bug in unavailable checking

2016-02-17 Thread Manman Ren via cfe-commits
manmanren updated this revision to Diff 48228.

http://reviews.llvm.org/D15314

Files:
  include/clang/Sema/Initialization.h
  include/clang/Sema/Sema.h
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaInit.cpp
  test/SemaObjC/Inputs/arc-system-header.h
  test/SemaObjC/arc-system-header.m

Index: test/SemaObjC/arc-system-header.m
===
--- test/SemaObjC/arc-system-header.m
+++ test/SemaObjC/arc-system-header.m
@@ -46,6 +46,13 @@
 // expected-note@arc-system-header.h:41 4 {{declaration uses type that is ill-formed in ARC}}
 // expected-note@arc-system-header.h:41 2 {{property 'prop' is declared unavailable here}}
 }
+
+extern void doSomething(Test9 arg);
+void test9() {
+Test9 foo2 = {0, 0}; // expected-error {{'field' is unavailable in ARC}}
+ // expected-note@arc-system-header.h:56 {{field has non-trivial ownership qualification}}
+doSomething(foo2);
+}
 #endif
 
 // test8 in header
Index: test/SemaObjC/Inputs/arc-system-header.h
===
--- test/SemaObjC/Inputs/arc-system-header.h
+++ test/SemaObjC/Inputs/arc-system-header.h
@@ -50,3 +50,8 @@
 static inline void *test8(id ptr) {
   return (__bridge_retain void*) ptr;
 }
+
+typedef struct {
+  const char *name;
+  id field;
+} Test9;
Index: lib/Sema/SemaInit.cpp
===
--- lib/Sema/SemaInit.cpp
+++ lib/Sema/SemaInit.cpp
@@ -238,6 +238,7 @@
   Sema 
   bool hadError;
   bool VerifyOnly; // no diagnostics, no structure building
+  bool TreatUnavailableAsInvalid; // Used only in VerifyOnly mode.
   llvm::DenseMap SyntacticToSemantic;
   InitListExpr *FullyStructuredList;
 
@@ -319,7 +320,8 @@
   static ExprResult PerformEmptyInit(Sema ,
  SourceLocation Loc,
  const InitializedEntity ,
- bool VerifyOnly);
+ bool VerifyOnly,
+ bool TreatUnavailableAsInvalid);
 
   // Explanation on the "FillWithNoInit" mode:
   //
@@ -355,7 +357,8 @@
 
 public:
   InitListChecker(Sema , const InitializedEntity ,
-  InitListExpr *IL, QualType , bool VerifyOnly);
+  InitListExpr *IL, QualType , bool VerifyOnly,
+  bool TreatUnavailableAsInvalid);
   bool HadError() { return hadError; }
 
   // @brief Retrieves the fully-structured initializer list used for
@@ -368,7 +371,8 @@
 ExprResult InitListChecker::PerformEmptyInit(Sema ,
  SourceLocation Loc,
  const InitializedEntity ,
- bool VerifyOnly) {
+ bool VerifyOnly,
+ bool TreatUnavailableAsInvalid) {
   InitializationKind Kind = InitializationKind::CreateValue(Loc, Loc, Loc,
 true);
   MultiExprArg SubInit;
@@ -438,7 +442,8 @@
 InitSeq.InitializeFrom(
 SemaRef, Entity,
 InitializationKind::CreateValue(Loc, Loc, Loc, true),
-MultiExprArg(), /*TopLevelOfInitList=*/false);
+MultiExprArg(), /*TopLevelOfInitList=*/false,
+TreatUnavailableAsInvalid);
 // Emit a warning for this.  System header warnings aren't shown
 // by default, but people working on system headers should see it.
 if (!VerifyOnly) {
@@ -475,7 +480,8 @@
   SourceLocation Loc) {
   assert(VerifyOnly &&
  "CheckEmptyInitializable is only inteded for verification mode.");
-  if (PerformEmptyInit(SemaRef, Loc, Entity, /*VerifyOnly*/true).isInvalid())
+  if (PerformEmptyInit(SemaRef, Loc, Entity, /*VerifyOnly*/true,
+   TreatUnavailableAsInvalid).isInvalid())
 hadError = true;
 }
 
@@ -536,7 +542,8 @@
 }
 
 ExprResult MemberInit = PerformEmptyInit(SemaRef, Loc, MemberEntity,
- /*VerifyOnly*/false);
+ /*VerifyOnly*/false,
+ TreatUnavailableAsInvalid);
 if (MemberInit.isInvalid()) {
   hadError = true;
   return;
@@ -662,7 +669,8 @@
   else {
 ExprResult ElementInit = PerformEmptyInit(SemaRef, ILE->getLocEnd(),
   ElementEntity,
-  /*VerifyOnly*/false);
+  /*VerifyOnly*/false,
+  TreatUnavailableAsInvalid);
 if (ElementInit.isInvalid()) {
   hadError = true;
   return;
@@ -710,8 +718,10 @@
 
 

Re: [PATCH] D16914: [CodeGen] Fix an assert in CodeGenFunction::EmitFunctionEpilog

2016-02-17 Thread Manman Ren via cfe-commits
manmanren added a comment.

LGTM otherwise.

Cheers,
Manman



Comment at: lib/CodeGen/CGCall.cpp:2468
@@ +2467,3 @@
+  QualType RT;
+
+  if (auto *FD = dyn_cast(CurCodeDecl))

Maybe add comments here on the if else block?


http://reviews.llvm.org/D16914



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


Re: [PATCH] D17345: [OpenCL] Improve diagnostics of address spaces for variables inside function

2016-02-17 Thread Mandeep Singh Grang via cfe-commits
mgrang added a subscriber: mgrang.


Comment at: test/SemaOpenCL/storageclass-cl20.cl:9
@@ -8,2 +8,3 @@
 global int *global GP6 = 0;
+global int * GP7 = 0;
 

Pointers should align to the right. Like:

global int *GP7 = 0;


http://reviews.llvm.org/D17345



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


Re: [PATCH] D17343: [OpenCL] Diagnose program scope pointers

2016-02-17 Thread Mandeep Singh Grang via cfe-commits
mgrang added a subscriber: mgrang.


Comment at: lib/Sema/SemaDecl.cpp:6605
@@ +6604,3 @@
+  // Program scope pointers can only point to data at the constant or 
global
+   // address space.
+  const PointerType *PT = nullptr;

Check alignment of comments.


Comment at: lib/Sema/SemaDecl.cpp:6625
@@ +6624,3 @@
+PT = dyn_cast(T.getTypePtr());
+if (PT) {
+  T = PT->getPointeeType();

Can you combine the assignment to PT inside the if condition? Like:

if (foo = something())


Comment at: lib/Sema/SemaDecl.cpp:6629
@@ -6617,1 +6628,3 @@
+}
+  } while (PT);
 } else {

Any reason why this cannot be a while loop instead of a do..while loop?


http://reviews.llvm.org/D17343



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


[PATCH] D17345: [OpenCL] Improve diagnostics of address spaces for variables inside function

2016-02-17 Thread Anastasia Stulova via cfe-commits
Anastasia created this revision.
Anastasia added reviewers: pekka.jaaskelainen, yaxunl.
Anastasia added a subscriber: cfe-commits.

This patch:
1. Prevents local variables to be declared in global AS
2. Diagnoses AS of local variables with an extern storage class as if they 
would be in a program scope

http://reviews.llvm.org/D17345

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaDecl.cpp
  test/Parser/opencl-storage-class.cl
  test/SemaOpenCL/storageclass-cl20.cl
  test/SemaOpenCL/storageclass.cl

Index: test/SemaOpenCL/storageclass.cl
===
--- test/SemaOpenCL/storageclass.cl
+++ test/SemaOpenCL/storageclass.cl
@@ -21,6 +21,8 @@
   local int L2;
 
   auto int L3 = 7; // expected-error{{OpenCL does not support the 'auto' storage class specifier}}
+  global int L4;   // expected-error{{non-program scope variable cannot be declared in global address space}}
+  global int *L5;
 }
 
 static void kernel bar() { // expected-error{{kernel functions cannot be declared static}}
@@ -33,4 +35,6 @@
 constant int L1 = 0; // expected-error{{non-kernel function variable cannot be declared in constant address space}}
 local int L2;// expected-error{{non-kernel function variable cannot be declared in local address space}}
   }
+  global int L3; // expected-error{{non-program scope variable cannot be declared in global address space}}
+  extern constant float L4;
 }
Index: test/SemaOpenCL/storageclass-cl20.cl
===
--- test/SemaOpenCL/storageclass-cl20.cl
+++ test/SemaOpenCL/storageclass-cl20.cl
@@ -6,6 +6,7 @@
 local int G4 = 0;  // expected-error{{program scope variable must reside in global or constant address space}}
 global int **constant GP5 = 0; // expected-error{{program scope pointer must point to global or constant address space}}
 global int *global GP6 = 0;
+global int * GP7 = 0;
 
 void kernel foo() {
   static int S1 = 5;
@@ -16,4 +17,8 @@
 
   constant int L1 = 0;
   local int L2;
+  global int L3; // expected-error{{non-program scope variable cannot be declared in global address space}}
+
+  extern global int G5;
+  extern int G6; // expected-error{{program scope variable must reside in global or constant address space}}
 }
Index: test/Parser/opencl-storage-class.cl
===
--- test/Parser/opencl-storage-class.cl
+++ test/Parser/opencl-storage-class.cl
@@ -10,6 +10,6 @@
 #pragma OPENCL EXTENSION cl_clang_storage_class_specifiers : enable
   static int e; // expected-error {{program scope variable must reside in constant address space}}
   register int f;
-  extern int g;
+  extern int g; // expected-error {{program scope variable must reside in constant address space}}
   auto int h;
 }
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -6600,7 +6600,8 @@
 // OpenCL v2.0 s6.5.1 - Variables defined at program scope and static
 // variables inside a function can also be declared in the global
 // address space.
-if (NewVD->isFileVarDecl() || NewVD->isStaticLocal()) {
+if (NewVD->isFileVarDecl() || NewVD->isStaticLocal() ||
+NewVD->hasExternalStorage()) {
   // Program scope pointers can only point to data at the constant or global
// address space.
   const PointerType *PT = nullptr;
@@ -6628,18 +6629,24 @@
 }
   } while (PT);
 } else {
+  if (T.getAddressSpace() == LangAS::opencl_global) {
+Diag(NewVD->getLocation(), diag::err_opencl_function_variable)
+<< 1 /*is any function*/ << "global";
+NewVD->setInvalidDecl();
+return;
+  }
   // OpenCL v1.1 s6.5.2 and s6.5.3 no local or constant variables
   // in functions.
   if (T.getAddressSpace() == LangAS::opencl_constant ||
   T.getAddressSpace() == LangAS::opencl_local) {
 FunctionDecl *FD = getCurFunctionDecl();
 if (FD && !FD->hasAttr()) {
   if (T.getAddressSpace() == LangAS::opencl_constant)
-Diag(NewVD->getLocation(), diag::err_opencl_non_kernel_variable)
-<< "constant";
+Diag(NewVD->getLocation(), diag::err_opencl_function_variable)
+<< 0 /*non-kernel only*/ << "constant";
   else
-Diag(NewVD->getLocation(), diag::err_opencl_non_kernel_variable)
-<< "local";
+Diag(NewVD->getLocation(), diag::err_opencl_function_variable)
+<< 0 /*non-kernel only*/ << "local";
   NewVD->setInvalidDecl();
   return;
 }
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -7649,8 +7649,8 @@
   "kernel 

[PATCH] D17343: [OpenCL] Diagnose program scope pointers

2016-02-17 Thread Anastasia Stulova via cfe-commits
Anastasia created this revision.
Anastasia added reviewers: pekka.jaaskelainen, yaxunl.
Anastasia added a subscriber: cfe-commits.

Programs scope pointers should point to objects in constant AS or for OpenCL 
2.0 in global AS.

http://reviews.llvm.org/D17343

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaDecl.cpp
  test/CodeGenOpenCL/address-spaces.cl
  test/SemaOpenCL/storageclass-cl20.cl
  test/SemaOpenCL/storageclass.cl

Index: test/SemaOpenCL/storageclass.cl
===
--- test/SemaOpenCL/storageclass.cl
+++ test/SemaOpenCL/storageclass.cl
@@ -5,6 +5,13 @@
 int G3 = 0;// expected-error{{program scope variable must reside in constant address space}}
 global int G4 = 0; // expected-error{{program scope variable must reside in constant address space}}
 
+int *constant GP1 = 0;   // expected-error{{program scope pointer must point to constant address space}}
+int *constant *constant GP2 = 0; // expected-error{{program scope pointer must point to constant address space}}
+int **constant GP3 = 0;  // expected-error{{program scope pointer must point to constant address space}}
+constant int **constant GP4 = 0; // expected-error{{program scope pointer must point to constant address space}}
+global int *constant GP5 = 0;// expected-error{{program scope pointer must point to constant address space}}
+constant int *constant GP6 = 0;
+
 void kernel foo() {
   // static is not allowed at local scope before CL2.0
   static int S1 = 5;  // expected-error{{variables in function scope cannot be declared static}}
Index: test/SemaOpenCL/storageclass-cl20.cl
===
--- test/SemaOpenCL/storageclass-cl20.cl
+++ test/SemaOpenCL/storageclass-cl20.cl
@@ -3,12 +3,16 @@
 static constant int G1 = 0;
 int G2 = 0;
 global int G3 = 0;
-local int G4 = 0;// expected-error{{program scope variable must reside in global or constant address space}}
+local int G4 = 0;  // expected-error{{program scope variable must reside in global or constant address space}}
+global int **constant GP5 = 0; // expected-error{{program scope pointer must point to global or constant address space}}
+global int *global GP6 = 0;
 
 void kernel foo() {
   static int S1 = 5;
   static global int S2 = 5;
-  static private int S3 = 5;// expected-error{{program scope variable must reside in global or constant address space}}
+  static private int S3 = 5;   // expected-error{{program scope variable must reside in global or constant address space}}
+  static local int *global S4; // expected-error{{program scope pointer must point to global or constant address space}}
+  static constant int *global S5;
 
   constant int L1 = 0;
   local int L2;
Index: test/CodeGenOpenCL/address-spaces.cl
===
--- test/CodeGenOpenCL/address-spaces.cl
+++ test/CodeGenOpenCL/address-spaces.cl
@@ -28,8 +28,8 @@
 #ifdef CL20
 int i;
 // CL20-DAG: @i = common addrspace(1) global i32 0
-int *ptr;
-// CL20-DAG: @ptr = common addrspace(1) global i32 addrspace(4)* null
+global int *ptr;
+// CL20-DAG: @ptr = common addrspace(1) global i32 addrspace(1)* null
 #endif
 
 // CHECK: i32* %arg
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -6600,37 +6600,34 @@
 // OpenCL v2.0 s6.5.1 - Variables defined at program scope and static
 // variables inside a function can also be declared in the global
 // address space.
-if (NewVD->isFileVarDecl()) {
-  if (!T->isSamplerT() &&
-  !(T.getAddressSpace() == LangAS::opencl_constant ||
-(T.getAddressSpace() == LangAS::opencl_global &&
- getLangOpts().OpenCLVersion == 200))) {
-if (getLangOpts().OpenCLVersion == 200)
-  Diag(NewVD->getLocation(), diag::err_opencl_global_invalid_addr_space)
-  << "global or constant";
-else
-  Diag(NewVD->getLocation(), diag::err_opencl_global_invalid_addr_space)
-  << "constant";
-NewVD->setInvalidDecl();
-return;
-  }
+if (NewVD->isFileVarDecl() || NewVD->isStaticLocal()) {
+  // Program scope pointers can only point to data at the constant or global
+   // address space.
+  const PointerType *PT = nullptr;
+  bool IsPointerDecl = false;
+  do {
+if (!T->isSamplerT() &&
+!(T.getAddressSpace() == LangAS::opencl_constant ||
+  (T.getAddressSpace() == LangAS::opencl_global &&
+   getLangOpts().OpenCLVersion == 200))) {
+  if (getLangOpts().OpenCLVersion == 200)
+Diag(NewVD->getLocation(),
+ diag::err_opencl_global_invalid_addr_space)
+<< IsPointerDecl << "global or constant";
+  else
+Diag(NewVD->getLocation(),
+   

Re: [PATCH] D16928: [OpenCL] Apply missing restrictions for Blocks in OpenCL v2.0

2016-02-17 Thread Mats Petersson via cfe-commits
MatsPetersson added a comment.

I think adding printf as a builtin function is a good idea.

If not, I feel that the error message should distinguish between (for example):

  int printf(global char* fmt, ...);

and

  void myfunc(int n, ...);

since the former is "incorrect prototype of printf" and the latter is "not a 
valid opencl function".


http://reviews.llvm.org/D16928



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


Re: [PATCH] D16928: [OpenCL] Apply missing restrictions for Blocks in OpenCL v2.0

2016-02-17 Thread Anastasia Stulova via cfe-commits
Anastasia updated this revision to Diff 48219.
Anastasia added a comment.

Drafted code for printf handling.

Made me think about:

1. How much signature check should we do i.e. should we check the pointer AS 
itself (generic for CL2.0, any other otherwise) or qualifiers being used for 
the first parameter (const, volatile ...)?
2. Would it be nicer to just add printf as a Clang OpenCL builitin to prevent 
it being declared in various ways and avoid writing custom signature check as 
in this change?


http://reviews.llvm.org/D16928

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaType.cpp
  test/CodeGen/blocks-opencl.cl
  test/SemaOpenCL/event_t.cl
  test/SemaOpenCL/invalid-blocks-cl20.cl
  test/SemaOpenCL/invalid-func.cl
  test/SemaOpenCL/invalid-kernel-parameters.cl
  test/SemaOpenCL/sampler_t.cl

Index: test/SemaOpenCL/sampler_t.cl
===
--- test/SemaOpenCL/sampler_t.cl
+++ test/SemaOpenCL/sampler_t.cl
@@ -2,7 +2,11 @@
 
 constant sampler_t glb_smp = 5;
 
-void foo(sampler_t); 
+void foo(sampler_t);
+
+constant struct sampler_s {
+  sampler_t smp; // expected-error {{the 'sampler_t' type cannot be used to declare a structure or union field}}
+} sampler_str = {0};
 
 void kernel ker(sampler_t argsmp) {
   local sampler_t smp; // expected-error {{sampler type cannot be used with the __local and __global address space qualifiers}}
Index: test/SemaOpenCL/invalid-kernel-parameters.cl
===
--- test/SemaOpenCL/invalid-kernel-parameters.cl
+++ test/SemaOpenCL/invalid-kernel-parameters.cl
@@ -24,7 +24,10 @@
 
 typedef struct FooImage2D // expected-note{{within field of type 'FooImage2D' declared here}}
 {
-  image2d_t imageField; // expected-note{{field of illegal type 'image2d_t' declared here}}
+  // TODO: Clean up needed - we don't really need to check for image, event, etc
+  // as a note here any longer.
+  // They are diagnosed as an error for all struct fields (OpenCL v1.2 s6.9b,r).
+  image2d_t imageField; // expected-note{{field of illegal type 'image2d_t' declared here}} expected-error{{the 'image2d_t' type cannot be used to declare a structure or union field}}
 } FooImage2D;
 
 kernel void image_in_struct_arg(FooImage2D arg) { } // expected-error{{struct kernel parameters may not contain pointers}}
Index: test/SemaOpenCL/invalid-func.cl
===
--- /dev/null
+++ test/SemaOpenCL/invalid-func.cl
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only -cl-std=CL2.0 -DCL20
+
+void foo(int, ...); // expected-error{{OpenCL does not allow variadic arguments}}
+int printf(constant const char *, ...);
Index: test/SemaOpenCL/invalid-blocks-cl20.cl
===
--- /dev/null
+++ test/SemaOpenCL/invalid-blocks-cl20.cl
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only -cl-std=CL2.0 -fblocks
+
+// OpenCL v2.0 s6.12.5
+
+// All blocks declarations must be const qualified and initialized.
+void f1() {
+  int (^bl1)() = ^() {}; // expected-error{{invalid block variable declaration - must be const qualified}}
+  int (^const bl2)(); // expected-error{{invalid block variable declaration - must be initialized}}
+  int (^const bl3)() = ^const(){
+  };
+}
+
+// A block with extern storage class is not allowed.
+extern int (^const bl)() = ^const(){}; // expected-error{{invalid block variable declaration - using 'extern' storage class is disallowed}}
+void f2() {
+  extern int (^const bl)() = ^const(){}; // expected-error{{invalid block variable declaration - using 'extern' storage class is disallowed}}
+}
+
+// A block with variadic argument is not allowed.
+typedef int (^const bl_t)(int, ...); // expected-error{{OpenCL does not allow variadic arguments}}
+
+// A block cannot be the return value of a function.
+typedef int (^bl_t)(void);
+bl_t f3(bl_t bl); // expected-error{{declaring function return value of type 'bl_t' (aka 'int (^const)(int, ...)') is not allowed}}
+
+struct bl_s {
+  int (^bl)(void); // expected-error {{the 'int (^)(void)' type cannot be used to declare a structure or union field}}
+};
+
+void f4() {
+  __block int a = 10; // expected-error {{the __block storage type is not permitted}}
+}
Index: test/SemaOpenCL/event_t.cl
===
--- test/SemaOpenCL/event_t.cl
+++ test/SemaOpenCL/event_t.cl
@@ -3,7 +3,7 @@
 event_t glb_evt; // expected-error {{the event_t type cannot be used to declare a program scope variable}}
 
 constant struct evt_s {
-  event_t evt;  // expected-error {{the event_t type cannot be used to declare a structure or union field}}
+  event_t evt; // expected-error {{the 'event_t' type cannot be used to declare a structure or union field}}
 } evt_str = {0};
 
 void foo(event_t evt); // expected-note {{passing argument to parameter 'evt' 

Re: [PATCH] D17272: Teach clang to use the ThinLTO pipeline

2016-02-17 Thread Mehdi AMINI via cfe-commits
joker.eph closed this revision.
joker.eph added a comment.

r261045


http://reviews.llvm.org/D17272



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


Re: [PATCH] D16154: Default vaarg lowering should support indirect struct types.

2016-02-17 Thread Dan Gohman via cfe-commits
sunfish added a subscriber: sunfish.
sunfish added a comment.

For WebAssembly, I'm expecting we'll switch to emitVoidPtrVAArg and eschew 
LLVM's vaarg instruction too, as other targets do. This exposes the expanded 
code to the full optimizer, which seems preferable.


http://reviews.llvm.org/D16154



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


Re: [PATCH] D17330: PR26648: "inline" shouldn't be recognized as a C keyword in MSVC 2013 compatibility mode

2016-02-17 Thread Reid Kleckner via cfe-commits
rnk added a comment.

Thanks, but I don't think we should do this. There's already a lot of code out 
there (ffmpeg) that is already using clang its current form and it does stuff 
like this:

  #if defined(_MSC_VER) && !defined(__clang__)
  # define inline __inline
  // More MSVC compatibility hacks unnecessary with clang here...
  #endif

Any code using 'inline' as an identifier is going to have a hard time going 
forward. I think our current behavior is better for the majority of our users.


http://reviews.llvm.org/D17330



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


Re: [PATCH] D17056: Mark all CUDA device-side function defs and decls as convergent.

2016-02-17 Thread David Majnemer via cfe-commits
majnemer added a subscriber: majnemer.
majnemer added a comment.

SetLLVMFunctionAttributesForDefinition seems like the more obvious place
for this logic.


http://reviews.llvm.org/D17056



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


r261135 - Enable SafeStack for CloudABI.

2016-02-17 Thread Ed Schouten via cfe-commits
Author: ed
Date: Wed Feb 17 12:56:20 2016
New Revision: 261135

URL: http://llvm.org/viewvc/llvm-project?rev=261135=rev
Log:
Enable SafeStack for CloudABI.

Summary:
I've got a patchset in my home directory to integrate support for
SafeStack into CloudABI's C library. All of the CloudABI unit tests
still seem to pass. Pretty sweet!

This change adds the necessary changes to Clang to make
-fsanitize=safe-stack work on CloudABI. Without it, passing this command
line flag throws an error.

Reviewers: eugenis, samsonov

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

Modified:
cfe/trunk/lib/Driver/ToolChains.cpp
cfe/trunk/lib/Driver/ToolChains.h
cfe/trunk/test/Driver/fsanitize.c

Modified: cfe/trunk/lib/Driver/ToolChains.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=261135=261134=261135=diff
==
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains.cpp Wed Feb 17 12:56:20 2016
@@ -3000,6 +3000,12 @@ Tool *CloudABI::buildLinker() const {
   return new tools::cloudabi::Linker(*this);
 }
 
+SanitizerMask CloudABI::getSupportedSanitizers() const {
+  SanitizerMask Res = ToolChain::getSupportedSanitizers();
+  Res |= SanitizerKind::SafeStack;
+  return Res;
+}
+
 /// OpenBSD - OpenBSD tool chain which can call as(1) and ld(1) directly.
 
 OpenBSD::OpenBSD(const Driver , const llvm::Triple ,

Modified: cfe/trunk/lib/Driver/ToolChains.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.h?rev=261135=261134=261135=diff
==
--- cfe/trunk/lib/Driver/ToolChains.h (original)
+++ cfe/trunk/lib/Driver/ToolChains.h Wed Feb 17 12:56:20 2016
@@ -617,6 +617,8 @@ public:
 
   bool isPIEDefault() const override { return false; }
 
+  SanitizerMask getSupportedSanitizers() const override;
+
 protected:
   Tool *buildLinker() const override;
 };

Modified: cfe/trunk/test/Driver/fsanitize.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/fsanitize.c?rev=261135=261134=261135=diff
==
--- cfe/trunk/test/Driver/fsanitize.c (original)
+++ cfe/trunk/test/Driver/fsanitize.c Wed Feb 17 12:56:20 2016
@@ -311,6 +311,10 @@
 // RUN: %clang -target powerpc64le-unknown-linux-gnu -fsanitize=memory %s -### 
2>&1 | FileCheck %s -check-prefix=CHECK-SANM
 // CHECK-SANM: "-fsanitize=memory"
 
+// RUN: %clang -target aarch64-unknown-cloudabi -fsanitize=safe-stack %s -### 
2>&1 | FileCheck %s -check-prefix=SAFESTACK-CLOUDABI
+// RUN: %clang -target x86_64-unknown-cloudabi -fsanitize=safe-stack %s -### 
2>&1 | FileCheck %s -check-prefix=SAFESTACK-CLOUDABI
+// SAFESTACK-CLOUDABI: "-fsanitize=safe-stack"
+
 // RUN: %clang -target x86_64-scei-ps4 -fsanitize=function 
-fsanitize=undefined %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-FSAN-UBSAN-PS4
 // CHECK-FSAN-UBSAN-PS4: unsupported option '-fsanitize=function' for target 
'x86_64-scei-ps4'
 // RUN: %clang -target x86_64-scei-ps4 -fsanitize=function %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-FSAN-PS4


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


Re: [PATCH] D16154: Default vaarg lowering should support indirect struct types.

2016-02-17 Thread Derek Schuff via cfe-commits
dschuff added a comment.

This LGTM for PNaCl and WebAssembly.

It's possible that for wasm we may still end up doing our own thing for varargs 
instead of using the default, but this still looks like strictly an 
improvement, (and it makes bootstrapping a backend simpler).


http://reviews.llvm.org/D16154



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


Re: [PATCH] D16914: [CodeGen] Fix an assert in CodeGenFunction::EmitFunctionEpilog

2016-02-17 Thread Akira Hatanaka via cfe-commits
ahatanak added a reviewer: manmanren.
ahatanak added a comment.

ping


http://reviews.llvm.org/D16914



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


Re: [PATCH] D17091: [analyzer][scan-build-py] Non-existing directory for scan-build output.

2016-02-17 Thread Anton Yartsev via cfe-commits
ayartsev added a comment.

Ping.


http://reviews.llvm.org/D17091



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


r261109 - Correct more typos in conditional expressions

2016-02-17 Thread David Majnemer via cfe-commits
Author: majnemer
Date: Wed Feb 17 11:19:00 2016
New Revision: 261109

URL: http://llvm.org/viewvc/llvm-project?rev=261109=rev
Log:
Correct more typos in conditional expressions

We didn't correctly handle some edge cases, causing us to bail out
before correcting all the typos.

Modified:
cfe/trunk/lib/Parse/ParseExpr.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/Sema/typo-correction.c
cfe/trunk/test/SemaCXX/typo-correction.cpp

Modified: cfe/trunk/lib/Parse/ParseExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExpr.cpp?rev=261109=261108=261109=diff
==
--- cfe/trunk/lib/Parse/ParseExpr.cpp (original)
+++ cfe/trunk/lib/Parse/ParseExpr.cpp Wed Feb 17 11:19:00 2016
@@ -449,9 +449,11 @@ Parser::ParseRHSOfBinaryExpression(ExprR
 LHS = Actions.ActOnConditionalOp(OpToken.getLocation(), ColonLoc,
  LHS.get(), TernaryMiddle.get(),
  RHS.get());
-} else
-  // Ensure potential typos in the RHS aren't left undiagnosed.
+} else {
+  // Ensure potential typos aren't left undiagnosed.
+  Actions.CorrectDelayedTyposInExpr(TernaryMiddle);
   Actions.CorrectDelayedTyposInExpr(RHS);
+}
   }
 }
 

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=261109=261108=261109=diff
==
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Wed Feb 17 11:19:00 2016
@@ -6838,8 +6838,23 @@ ExprResult Sema::ActOnConditionalOp(Sour
 // doesn't handle dependent types properly, so make sure any TypoExprs have
 // been dealt with before checking the operands.
 ExprResult CondResult = CorrectDelayedTyposInExpr(CondExpr);
-if (!CondResult.isUsable()) return ExprError();
+ExprResult LHSResult = CorrectDelayedTyposInExpr(LHSExpr);
+ExprResult RHSResult = CorrectDelayedTyposInExpr(RHSExpr);
+
+if (!CondResult.isUsable())
+  return ExprError();
+
+if (LHSExpr) {
+  if (!LHSResult.isUsable())
+return ExprError();
+}
+
+if (!RHSResult.isUsable())
+  return ExprError();
+
 CondExpr = CondResult.get();
+LHSExpr = LHSResult.get();
+RHSExpr = RHSResult.get();
   }
 
   // If this is the gnu "x ?: y" extension, analyze the types as though the LHS

Modified: cfe/trunk/test/Sema/typo-correction.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/typo-correction.c?rev=261109=261108=261109=diff
==
--- cfe/trunk/test/Sema/typo-correction.c (original)
+++ cfe/trunk/test/Sema/typo-correction.c Wed Feb 17 11:19:00 2016
@@ -55,3 +55,5 @@ void fn2() {
   f(THIS_IS_AN_ERROR, // expected-error {{use of undeclared identifier 
'THIS_IS_AN_ERROR'}}
 afunction(afunction_));  // expected-error {{use of undeclared identifier 
'afunction_'; did you mean 'afunction'?}}
 }
+
+int d = X ? d : L; // expected-error 2 {{use of undeclared identifier}}

Modified: cfe/trunk/test/SemaCXX/typo-correction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/typo-correction.cpp?rev=261109=261108=261109=diff
==
--- cfe/trunk/test/SemaCXX/typo-correction.cpp (original)
+++ cfe/trunk/test/SemaCXX/typo-correction.cpp Wed Feb 17 11:19:00 2016
@@ -663,3 +663,5 @@ class Bar : public A::B::Foofoo {};
 
 using C::D::Foofoo;  // expected-error {{no member named 'Foofoo' in namespace 
'PR24781_using_crash::C::D'; did you mean 'A::B::Foofoo'?}}
 }
+
+int d = ? L : d; // expected-error {{expected expression}} expected-error 
{{undeclared identifier}}


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


Re: [PATCH] D17170: [OPENMP] Codegen for distribute directive

2016-02-17 Thread Carlo Bertolli via cfe-commits
carlo.bertolli updated this revision to Diff 48200.
carlo.bertolli added a comment.

Updated diff reflecting comments.
Note that having the emission of the runtime kmpc_for_static_init function in a 
static function (instead of a method of CGOpenMPRuntime) required moving to 
public some fields in CGOpenMPRuntime used when calling the runtime function.
This is painful and comments are welcome on how to overcome this, if needed.


Repository:
  rL LLVM

http://reviews.llvm.org/D17170

Files:
  include/clang/AST/StmtOpenMP.h
  lib/CodeGen/CGOpenMPRuntime.cpp
  lib/CodeGen/CGOpenMPRuntime.h
  lib/CodeGen/CGStmtOpenMP.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/Serialization/ASTReaderStmt.cpp
  lib/Serialization/ASTWriterStmt.cpp
  test/OpenMP/distribute_codegen.cpp

Index: test/OpenMP/distribute_codegen.cpp
===
--- /dev/null
+++ test/OpenMP/distribute_codegen.cpp
@@ -0,0 +1,239 @@
+// Test host codegen.
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -omptargets=powerpc64le-ibm-linux-gnu -emit-llvm %s -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-64
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -omptargets=powerpc64le-ibm-linux-gnu -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -x c++ -triple powerpc64le-unknown-unknown -omptargets=powerpc64le-ibm-linux-gnu -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-64  --check-prefix HCHECK
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple i386-unknown-unknown -omptargets=i386-pc-linux-gnu -emit-llvm %s -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-32  --check-prefix HCHECK
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple i386-unknown-unknown -omptargets=i386-pc-linux-gnu -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -x c++ -triple i386-unknown-unknown -omptargets=i386-pc-linux-gnu -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-32 --check-prefix HCHECK
+
+// Test target codegen - host bc file has to be created first. (no significant differences with host version of target region)
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -omptargets=powerpc64le-ibm-linux-gnu -emit-llvm-bc %s -o %t-ppc-host.bc
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -omptargets=powerpc64le-ibm-linux-gnu -emit-llvm %s -fopenmp-is-device -omp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -omptargets=powerpc64le-ibm-linux-gnu -emit-pch -fopenmp-is-device -omp-host-ir-file-path %t-ppc-host.bc -o %t %s
+// RUN: %clang_cc1 -fopenmp -x c++ -triple powerpc64le-unknown-unknown -omptargets=powerpc64le-ibm-linux-gnu -std=c++11 -fopenmp-is-device -omp-host-ir-file-path %t-ppc-host.bc -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple i386-unknown-unknown -omptargets=i386-pc-linux-gnu -emit-llvm-bc %s -o %t-x86-host.bc
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple i386-unknown-unknown -omptargets=i386-pc-linux-gnu -emit-llvm %s -fopenmp-is-device -omp-host-ir-file-path %t-x86-host.bc -o - | FileCheck %s
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple i386-unknown-unknown -omptargets=i386-pc-linux-gnu -emit-pch -fopenmp-is-device -omp-host-ir-file-path %t-x86-host.bc -o %t %s
+// RUN: %clang_cc1 -fopenmp -x c++ -triple i386-unknown-unknown -omptargets=i386-pc-linux-gnu -std=c++11 -fopenmp-is-device -omp-host-ir-file-path %t-x86-host.bc -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
+
+// expected-no-diagnostics
+#ifndef HEADER
+#define HEADER
+
+// CHECK-DAG: %ident_t = type { i32, i32, i32, i32, i8* }
+// CHECK-DAG: [[STR:@.+]] = private unnamed_addr constant [23 x i8] c";unknown;unknown;0;0;;\00"
+// CHECK-DAG: [[DEF_LOC_0:@.+]] = private unnamed_addr constant %ident_t { i32 0, i32 2, i32 0, i32 0, i8* getelementptr inbounds ([23 x i8], [23 x i8]* [[STR]], i32 0, i32 0) }
+
+// CHECK-LABEL: define {{.*void}} @{{.*}}without_schedule_clause{{.*}}(float* {{.+}}, float* {{.+}}, float* {{.+}}, float* {{.+}})
+void without_schedule_clause(float *a, float *b, float *c, float *d) {
+  #pragma omp target
+  #pragma omp teams
+  #pragma omp distribute
+  for (int i = 33; i < 3200; i += 7) {
+a[i] = b[i] * c[i] * d[i];
+  }
+}
+
+// CHECK: define {{.*}}void @.omp_outlined.(i32* noalias [[GBL_TIDP:%.+]], i32* noalias [[BND_TID:%.+]], float** dereferenceable({{[0-9]+}}) [[APTR:%.+]], float** dereferenceable({{[0-9]+}}) [[BPTR:%.+]], float** dereferenceable({{[0-9]+}}) [[CPTR:%.+]], float** dereferenceable({{[0-9]+}}) [[DPTR:%.+]])
+// CHECK:  [[TID_ADDR:%.+]] = alloca i32*
+// CHECK:  [[IV:%.+iv]] = alloca i32
+// CHECK:  [[LB:%.+lb]] = alloca i32
+// CHECK:  [[UB:%.+ub]] = 

Re: [PATCH] D17170: [OPENMP] Codegen for distribute directive

2016-02-17 Thread Carlo Bertolli via cfe-commits
carlo.bertolli marked 4 inline comments as done.


Comment at: lib/CodeGen/CGStmtOpenMP.cpp:2914
@@ -2713,4 +2913,3 @@
   if (NT || TL) {
-NumTeamsVal = (NT) ? CGF.EmitScalarExpr(NT->getNumTeams(),
-/* IgnoreResultAssign = */ true) :
+NumTeamsVal = (NT) ? CGF.EmitScalarExpr(NT->getNumTeams(), true) :
 NumTeamsVal = CGF.Builder.getInt32(0);

ABataev wrote:
> Comment for 'true' arg? 
I was missing a merge against my own connected patch..sorry!


Repository:
  rL LLVM

http://reviews.llvm.org/D17170



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


Re: [PATCH] D17330: PR26648: "inline" shouldn't be recognized as a C keyword in MSVC 2013 compatibility mode

2016-02-17 Thread Andrey Bokhanko via cfe-commits
OK, so is initial patch a good one? ;-)

Andrey


On Wed, Feb 17, 2016 at 8:06 PM, David Majnemer
 wrote:
> majnemer added a comment.
>
> In http://reviews.llvm.org/D17330#354755, @andreybokhanko wrote:
>
>> In http://reviews.llvm.org/D17330#354730, @majnemer wrote:
>>
>> > Why not just stick clang in C90 mode when targeting C if the 
>> > -fms-compatibility-version is 18?
>> >
>> > We have similar code for the C++ mode in 
>> > https://github.com/llvm-mirror/clang/blob/master/lib/Driver/Tools.cpp#l5069
>>
>>
>> David, thanks for looking into this!
>>
>> MSVC18 doesn't support a set C standard; it adds some things from C99 as 
>> well. For example, it supports _Bool. So, I tried not to throw away baby 
>> along with bathwater and cause too much disruption.
>>
>> OK -- will implement a driver fix that sets C90 for MSVC18 tomorrow and will 
>> update the patch.
>>
>> Andrey
>
>
> _Bool is fine, our C90 support is a superset of C90: it includes things which 
> a conforming implementation is permitted to provide.
>
> However, the following test case is problematic:
>
>   void f() {
> for (int x = 0; x < 10; ++x) {}
> for (int x = 0; x < 10; ++x) {}
>   }
>
> This is supported by MSVC 2013 but would be (correctly) rejected by a 
> compiler in C90 mode...
> I have a feeling that sticking us in C90 mode would break code...
>
>
> http://reviews.llvm.org/D17330
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17330: PR26648: "inline" shouldn't be recognized as a C keyword in MSVC 2013 compatibility mode

2016-02-17 Thread Andrey Bokhanko via cfe-commits
andreybokhanko added a comment.

In http://reviews.llvm.org/D17330#354730, @majnemer wrote:

> Why not just stick clang in C90 mode when targeting C if the 
> -fms-compatibility-version is 18?
>
> We have similar code for the C++ mode in 
> https://github.com/llvm-mirror/clang/blob/master/lib/Driver/Tools.cpp#l5069


David, thanks for looking into this!

MSVC18 doesn't support a set C standard; it adds some things from C99 as well. 
For example, it supports _Bool. So, I tried not to throw away baby along with 
bathwater and cause too much disruption.

OK -- will implement a driver fix that sets C90 for MSVC18 tomorrow and will 
update the patch.

Andrey


http://reviews.llvm.org/D17330



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


Re: r259874 - CodeGen: correct Windows ARM C++ assertion

2016-02-17 Thread Hans Wennborg via cfe-commits
On Tue, Feb 16, 2016 at 9:03 PM, Saleem Abdulrasool
 wrote:
> On Thu, Feb 4, 2016 at 8:12 PM, Saleem Abdulrasool via cfe-commits
>  wrote:
>>
>> Author: compnerd
>> Date: Thu Feb  4 22:12:40 2016
>> New Revision: 259874
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=259874=rev
>> Log:
>> CodeGen: correct Windows ARM C++ assertion
>
>
> Id like to merge this to the 3.8 release.  It only effects Windows ARM code
> generation, so should be quite safe.

Sounds good to me. Go ahead and merge with utils/release/merge.sh, or
let me know if you'd prefer me to do it.

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


Re: [PATCH] D15332: new clang-tidy checker readability-non-const-parameter

2016-02-17 Thread Richard via cfe-commits
LegalizeAdulthood added inline comments.


Comment at: test/clang-tidy/readability-non-const-parameter.cpp:3
@@ +2,3 @@
+
+// Currently the checker only warns about pointer arguments.
+//

danielmarjamaki wrote:
> LegalizeAdulthood wrote:
> > How hard is it to extend it to references?
> > 
> > Certainly the confusion about what is const is easier to resolve in the 
> > case of references because the references themselves are immutable.
> If a "int &" reference parameter is not written then probably it's better to 
> pass it by value than making it const. I would prefer that unless it has to 
> use "int &" to comply with some interface.
> 
> I realize that the same can be said about pointers. If there is a "int *p" 
> and you just read the value that p points at .. maybe sometimes it would be 
> preferable to pass it by value.
I thought the point of this check was to identify stuff passed by 
reference/pointer that could instead be passed by const reference/pointer.

Passing a read-only number type (`short`, `char`, `int`, `float`, `double`, 
etc.) parameter by pointer or by reference/pointer is a code smell, but this 
check isn't trying to identify that situation.

I'm more interested in things like:

```
void foo(std::string );
```

becoming

```
void foo(const std::string );
```

when `s` is treated as a read-only value within the implementation of `foo`.


http://reviews.llvm.org/D15332



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


[clang-tools-extra] r261102 - [clang-tidy] Match the type against the get() method we are calling,

2016-02-17 Thread Samuel Benzaquen via cfe-commits
Author: sbenza
Date: Wed Feb 17 10:13:14 2016
New Revision: 261102

URL: http://llvm.org/viewvc/llvm-project?rev=261102=rev
Log:
[clang-tidy] Match the type against the get() method we are calling,
instead of a get() method we find in the class.

The duck typed smart pointer class could have overloaded get() methods
and we should only skip the one that matches.

Modified:
clang-tools-extra/trunk/clang-tidy/readability/RedundantSmartptrGetCheck.cpp

clang-tools-extra/trunk/test/clang-tidy/readability-redundant-smartptr-get.cpp

Modified: 
clang-tools-extra/trunk/clang-tidy/readability/RedundantSmartptrGetCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/RedundantSmartptrGetCheck.cpp?rev=261102=261101=261102=diff
==
--- 
clang-tools-extra/trunk/clang-tidy/readability/RedundantSmartptrGetCheck.cpp 
(original)
+++ 
clang-tools-extra/trunk/clang-tidy/readability/RedundantSmartptrGetCheck.cpp 
Wed Feb 17 10:13:14 2016
@@ -25,7 +25,9 @@ internal::Matcher callToGet(intern
pointsTo(decl(OnClass).bind("ptr_to_ptr"))
 .bind("smart_pointer")),
  unless(callee(memberExpr(hasObjectExpression(cxxThisExpr(),
- callee(cxxMethodDecl(hasName("get"
+ callee(cxxMethodDecl(
+ hasName("get"),
+ returns(qualType(pointsTo(type().bind("getType")))
   .bind("redundant_get");
 }
 
@@ -35,10 +37,8 @@ void registerMatchersForGetArrowStart(Ma
   recordDecl().bind("duck_typing"),
   has(cxxMethodDecl(hasName("operator->"),
 returns(qualType(pointsTo(type().bind("op->Type")),
-  has(cxxMethodDecl(hasName("operator*"),
-
returns(qualType(references(type().bind("op*Type")),
-  has(cxxMethodDecl(hasName("get"),
-returns(qualType(pointsTo(type().bind("getType")));
+  has(cxxMethodDecl(hasName("operator*"), returns(qualType(references(
+  type().bind("op*Type")));
 
   // Catch 'ptr.get()->Foo()'
   Finder->addMatcher(memberExpr(expr().bind("memberExpr"), isArrow(),

Modified: 
clang-tools-extra/trunk/test/clang-tidy/readability-redundant-smartptr-get.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/readability-redundant-smartptr-get.cpp?rev=261102=261101=261102=diff
==
--- 
clang-tools-extra/trunk/test/clang-tidy/readability-redundant-smartptr-get.cpp 
(original)
+++ 
clang-tools-extra/trunk/test/clang-tidy/readability-redundant-smartptr-get.cpp 
Wed Feb 17 10:13:14 2016
@@ -44,6 +44,14 @@ struct Fail2 {
   int& operator*();
 };
 
+struct PointerWithOverloadedGet {
+  int* get();
+  template 
+  T* get();
+  int* operator->();
+  int& operator*();
+};
+
 void Positive() {
   BarPtr u;
   // CHECK-FIXES: BarPtr u;
@@ -100,6 +108,11 @@ void Positive() {
   // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: redundant get() call
   // CHECK-MESSAGES: nullptr != ss->get();
   // CHECK-FIXES: bb = nullptr != *ss;
+
+  i = *PointerWithOverloadedGet().get();
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: redundant get() call
+  // CHECK-MESSAGES: i = *PointerWithOverloadedGet().get();
+  // CHECK-FIXES: i = *PointerWithOverloadedGet();
 }
 
 void Negative() {
@@ -113,6 +126,8 @@ void Negative() {
 }
   };
 
+  long l = *PointerWithOverloadedGet().get();
+
   std::unique_ptr* u;
   u->get()->Do();
 


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


Re: [PATCH] D17330: PR26648: "inline" shouldn't be recognized as a C keyword in MSVC 2013 compatibility mode

2016-02-17 Thread David Majnemer via cfe-commits
majnemer added a comment.

Why not just stick clang in C90 mode when targeting C if the 
-fms-compatibility-version is 18?

We have similar code for the C++ mode in 
https://github.com/llvm-mirror/clang/blob/master/lib/Driver/Tools.cpp#l5069


http://reviews.llvm.org/D17330



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


Re: [PATCH] D15450: Avoid double deletion in Clang driver.

2016-02-17 Thread Yaron Keren via cfe-commits
yaron.keren accepted this revision.
yaron.keren added a reviewer: yaron.keren.
yaron.keren added a comment.
This revision is now accepted and ready to land.

Would be nice to have CodeGenAction::TheModule redirect to CodeGeneratorImpl::M 
if possible, but that's for another patch. LGTM.


http://reviews.llvm.org/D15450



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


Re: [PATCH] D15450: Avoid double deletion in Clang driver.

2016-02-17 Thread Serge Pavlov via cfe-commits
sepavloff added a comment.

In http://reviews.llvm.org/D15450#354606, @yaron.keren wrote:

> It certainly makes sense to redirect the module request to its owner instead 
> of duplicating it in a local copy.


It is not even a duplication, it is simultaneous sharing by two unique_ptr's.

> There may be a change in behaviour here, pre-patch 
> CodeGenAction::EndSourceFileAction() would take the BackendConsumer Module, 
> keeping CodeGen Module intact whereas post-patch it takes the CodeGen Module.

>  How does this work out?


It should not be a problem. CodeGenAction::EndSourceFileAction() is called when 
code generation is finished, so taking ownership from GodeGen looks safe. 
Anyway, module must not be owned by two unique_ptr's.

There are at least 3 unique_ptr's that owns the same module object:

- CodeGenAction::TheModule
- BackendConsumer::TheModule
- CodeGeneratorImpl::M

It looks like CodeGenAction::TheModule does not cause any problem, it takes 
ownership according to usual unique_ptr semantics. But the last two variables 
owns the same object simultaneously, which violates semantics of unique_ptr. 
The patch fixes ownership by allowing only CodeGeneratorImpl::M to be an owner.


http://reviews.llvm.org/D15450



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


Re: [PATCH] D16749: [OpenMP] Map clause codegeneration.

2016-02-17 Thread Samuel Antao via cfe-commits
sfantao marked an inline comment as done.


Comment at: test/OpenMP/target_map_codegen.cpp:1705
@@ +1704,3 @@
+  // CK19-DAG: [[SEC000]] = getelementptr {{.*}}[4 x [5 x [6 x i32]]]* 
[[VAR0]], i{{.+}} 0, i{{.+}} 1
+
+  // CK19: call void [[CALL25:@.+]]([4 x [5 x [6 x i32]]]* {{[^,]+}})

Regression tests for array sections start here.


http://reviews.llvm.org/D16749



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


Re: [PATCH] D16749: [OpenMP] Map clause codegeneration.

2016-02-17 Thread Samuel Antao via cfe-commits
sfantao marked an inline comment as done.
sfantao added a comment.

Hi Alexey,



Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:3901-3932
@@ +3900,34 @@
+// Reference types are ignored for mapping purposes.
+if (auto *RefTy = ExprTy->getAs())
+  ExprTy = RefTy->getPointeeType().getCanonicalType();
+
+// Given that an array section is considered a built-in type, we need to
+// do the calculation based on the length of the section instead of relying
+// on CGF.getTypeSize(E->getType()).
+if (const auto *OAE = dyn_cast(E)) {
+  auto BaseTy =
+  OAE->getBase()->IgnoreParenImpCasts()->getType().getCanonicalType();
+  // Reference types are ignored for mapping purposes.
+  if (auto *RefTy = BaseTy->getAs())
+BaseTy = RefTy->getPointeeType().getCanonicalType();
+
+  // If there is no length associated with the expression, that means we
+  // are using the whole length of the base.
+  if (!OAE->getLength())
+return CGF.getTypeSize(BaseTy);
+
+  llvm::Value *ElemSize;
+  if (auto *PTy = BaseTy->getAs()) {
+ElemSize = CGF.getTypeSize(PTy->getPointeeType().getCanonicalType());
+  } else {
+auto *ATy = cast(BaseTy.getTypePtr());
+assert(ATy && "Expecting array type if not a pointer type.");
+ElemSize = CGF.getTypeSize(ATy->getElementType().getCanonicalType());
+  }
+
+  auto *LengthVal = CGF.EmitScalarExpr(OAE->getLength());
+  LengthVal =
+  CGF.Builder.CreateIntCast(LengthVal, CGF.SizeTy, /*isSigned=*/false);
+  return CGF.Builder.CreateNUWMul(LengthVal, ElemSize);
+}
+return CGF.getTypeSize(ExprTy);

ABataev wrote:
> What if the base is OMPArraySectionExpr? Will it work in this case?
Yes, it will work. There are a few regression tests for that in this patch 
already.


http://reviews.llvm.org/D16749



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


Re: [PATCH] D13622: Add call to find_package to load LLVM dependencies

2016-02-17 Thread don hinton via cfe-commits
hintonda added a comment.

Ping,..

Could someone commit this for me?


http://reviews.llvm.org/D13622



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


[libcxx] r261097 - Merging r261088:

2016-02-17 Thread Daniel Sanders via cfe-commits
Author: dsanders
Date: Wed Feb 17 09:02:33 2016
New Revision: 261097

URL: http://llvm.org/viewvc/llvm-project?rev=261097=rev
Log:
Merging r261088:

r261088 | dsanders | 2016-02-17 13:16:31 + (Wed, 17 Feb 2016) | 21 lines

[libcxx] Fix definition of regex_traits::__regex_word on big-endian glibc 
systems

Summary:
On glibc, the bits used for the various character classes is endian dependant
(see _ISbit() in ctypes.h) but __regex_word does not account for this and uses
a spare bit that isn't spare on big-endian. On big-endian, it overlaps with the
bit for graphic characters which causes '-', '@', etc. to be considered a word
character.

Fixed this by defining the value using _ISbit(15) on MIPS glibc systems. We've
restricted this to MIPS for now to avoid the risk of introducing failures in
other targets.

Fixes PR26476.

Reviewers: hans, mclow.lists

Subscribers: dsanders, cfe-commits

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



Modified:
libcxx/branches/release_38/include/regex

Modified: libcxx/branches/release_38/include/regex
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/branches/release_38/include/regex?rev=261097=261096=261097=diff
==
--- libcxx/branches/release_38/include/regex (original)
+++ libcxx/branches/release_38/include/regex Wed Feb 17 09:02:33 2016
@@ -976,7 +976,12 @@ public:
 typedef locale  locale_type;
 typedef ctype_base::maskchar_class_type;
 
+#if defined(__mips__) && defined(__GLIBC__)
+static const char_class_type __regex_word = 
static_cast(_ISbit(15));
+#else
 static const char_class_type __regex_word = 0x80;
+#endif
+
 private:
 locale __loc_;
 const ctype* __ct_;


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


Re: [PATCH] D16139: [MIPS] initFeatureMap() to handle empty string argument

2016-02-17 Thread Vasileios Kalintiris via cfe-commits
vkalintiris accepted this revision.
vkalintiris added a comment.
This revision is now accepted and ready to land.

LGTM. However, I'm curious to learn which case triggered this behaviour.


Repository:
  rL LLVM

http://reviews.llvm.org/D16139



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


Re: [PATCH] D16012: Carry raw string literal information through to the AST StringLiteral representation

2016-02-17 Thread Aaron Ballman via cfe-commits
aaron.ballman abandoned this revision.
aaron.ballman added a comment.

Your logic makes sense to me. I am abandoning this revision while I think about 
alternatives. Thanks!


http://reviews.llvm.org/D16012



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


Re: [PATCH] D15450: Avoid double deletion in Clang driver.

2016-02-17 Thread Yaron Keren via cfe-commits
yaron.keren added a comment.

It certainly makes sense to redirect the module request to its owner instead of 
duplicating it in a local copy.

There may be a change in behaviour here, pre-patch 
CodeGenAction::EndSourceFileAction() would take the BackendConsumer Module, 
keeping CodeGen Module intact whereas post-patch it takes the CodeGen Module.
How does this work out?


http://reviews.llvm.org/D15450



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


Re: [PATCH] D16579: Warn if friend function depends on template parameters.

2016-02-17 Thread Serge Pavlov via cfe-commits
Any feedback?

Thanks,
--Serge

2016-01-26 20:55 GMT+06:00 Serge Pavlov :

> sepavloff created this revision.
> sepavloff added a subscriber: cfe-commits.
>
> Declaration of friend function may depend on template parameters,
> however it does not become a template function:
>
> template class C1 {
>   friend void func(T x);
> };
>
> It may be not obvious for user, so compiler could emit a warning in
> such case. This patch implements appropriate warning, the wording is
> taken from GCC message. The patch fixes PR23342.
>
> http://reviews.llvm.org/D16579
>
> Files:
>   include/clang/Basic/DiagnosticGroups.td
>   include/clang/Basic/DiagnosticSemaKinds.td
>   lib/Sema/SemaDecl.cpp
>   test/CXX/drs/dr3xx.cpp
>   test/CXX/drs/dr5xx.cpp
>   test/CXX/temp/temp.decls/temp.friend/p1.cpp
>   test/PCH/cxx-templates.cpp
>   test/PCH/cxx-templates.h
>   test/SemaCXX/friend.cpp
>   test/SemaCXX/overload-call.cpp
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r261089 - [OPENMP 4.5] Codegen support for data members in 'firstprivate' clause.

2016-02-17 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Wed Feb 17 07:19:37 2016
New Revision: 261089

URL: http://llvm.org/viewvc/llvm-project?rev=261089=rev
Log:
[OPENMP 4.5] Codegen support for data members in 'firstprivate' clause.

Added codegen for captured data members in non-static member functions.

Modified:
cfe/trunk/include/clang/AST/OpenMPClause.h
cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
cfe/trunk/lib/AST/OpenMPClause.cpp
cfe/trunk/lib/AST/StmtProfile.cpp
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/lib/Serialization/ASTReaderStmt.cpp
cfe/trunk/lib/Serialization/ASTWriterStmt.cpp
cfe/trunk/test/OpenMP/parallel_firstprivate_codegen.cpp
cfe/trunk/tools/libclang/CIndex.cpp

Modified: cfe/trunk/include/clang/AST/OpenMPClause.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/OpenMPClause.h?rev=261089=261088=261089=diff
==
--- cfe/trunk/include/clang/AST/OpenMPClause.h (original)
+++ cfe/trunk/include/clang/AST/OpenMPClause.h Wed Feb 17 07:19:37 2016
@@ -1253,6 +1253,7 @@ public:
 ///
 class OMPFirstprivateClause final
 : public OMPVarListClause,
+  public OMPClauseWithPreInit,
   private llvm::TrailingObjects {
   friend TrailingObjects;
   friend OMPVarListClause;
@@ -1268,7 +1269,8 @@ class OMPFirstprivateClause final
   OMPFirstprivateClause(SourceLocation StartLoc, SourceLocation LParenLoc,
 SourceLocation EndLoc, unsigned N)
   : OMPVarListClause(OMPC_firstprivate, StartLoc,
-LParenLoc, EndLoc, N) {}
+LParenLoc, EndLoc, N),
+OMPClauseWithPreInit(this) {}
 
   /// \brief Build an empty clause.
   ///
@@ -1277,7 +1279,8 @@ class OMPFirstprivateClause final
   explicit OMPFirstprivateClause(unsigned N)
   : OMPVarListClause(
 OMPC_firstprivate, SourceLocation(), SourceLocation(),
-SourceLocation(), N) {}
+SourceLocation(), N),
+OMPClauseWithPreInit(this) {}
   /// \brief Sets the list of references to private copies with initializers 
for
   /// new private variables.
   /// \param VL List of references.
@@ -1318,11 +1321,13 @@ public:
   /// \param InitVL List of references to auto generated variables used for
   /// initialization of a single array element. Used if firstprivate variable 
is
   /// of array type.
+  /// \param PreInit Statement that must be executed before entering the OpenMP
+  /// region with this clause.
   ///
   static OMPFirstprivateClause *
   Create(const ASTContext , SourceLocation StartLoc, SourceLocation 
LParenLoc,
  SourceLocation EndLoc, ArrayRef VL, ArrayRef 
PrivateVL,
- ArrayRef InitVL);
+ ArrayRef InitVL, Stmt *PreInit);
   /// \brief Creates an empty clause with the place for \a N variables.
   ///
   /// \param C AST context.

Modified: cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/RecursiveASTVisitor.h?rev=261089=261088=261089=diff
==
--- cfe/trunk/include/clang/AST/RecursiveASTVisitor.h (original)
+++ cfe/trunk/include/clang/AST/RecursiveASTVisitor.h Wed Feb 17 07:19:37 2016
@@ -492,6 +492,8 @@ private:
 #include "clang/Basic/OpenMPKinds.def"
   /// \brief Process clauses with list of variables.
   template  bool VisitOMPClauseList(T *Node);
+  /// Process clauses with pre-initis.
+  bool VisitOMPClauseWithPreInit(OMPClauseWithPreInit *Node);
 
   bool dataTraverseNode(Stmt *S, DataRecursionQueue *Queue);
 };
@@ -2498,6 +2500,13 @@ bool RecursiveASTVisitor::Trave
 }
 
 template 
+bool RecursiveASTVisitor::VisitOMPClauseWithPreInit(
+OMPClauseWithPreInit *Node) {
+  TRY_TO(TraverseStmt(Node->getPreInitStmt()));
+  return true;
+}
+
+template 
 bool RecursiveASTVisitor::VisitOMPIfClause(OMPIfClause *C) {
   TRY_TO(TraverseStmt(C->getCondition()));
   return true;
@@ -2548,8 +2557,8 @@ bool RecursiveASTVisitor::Visit
 template 
 bool
 RecursiveASTVisitor::VisitOMPScheduleClause(OMPScheduleClause *C) {
+  TRY_TO(VisitOMPClauseWithPreInit(C));
   TRY_TO(TraverseStmt(C->getChunkSize()));
-  TRY_TO(TraverseStmt(C->getPreInitStmt()));
   return true;
 }
 
@@ -2637,6 +2646,7 @@ template 
 bool RecursiveASTVisitor::VisitOMPFirstprivateClause(
 OMPFirstprivateClause *C) {
   TRY_TO(VisitOMPClauseList(C));
+  TRY_TO(VisitOMPClauseWithPreInit(C));
   for (auto *E : C->private_copies()) {
 TRY_TO(TraverseStmt(E));
   }
@@ -2818,8 +2828,8 @@ bool RecursiveASTVisitor::Visit
 template 
 bool RecursiveASTVisitor::VisitOMPDistScheduleClause(
 OMPDistScheduleClause *C) {
+  TRY_TO(VisitOMPClauseWithPreInit(C));
   TRY_TO(TraverseStmt(C->getChunkSize()));
-  TRY_TO(TraverseStmt(C->getPreInitStmt()));
   return true;
 }
 


[libcxx] r261088 - [libcxx] Fix definition of regex_traits::__regex_word on big-endian glibc systems

2016-02-17 Thread Daniel Sanders via cfe-commits
Author: dsanders
Date: Wed Feb 17 07:16:31 2016
New Revision: 261088

URL: http://llvm.org/viewvc/llvm-project?rev=261088=rev
Log:
[libcxx] Fix definition of regex_traits::__regex_word on big-endian glibc 
systems

Summary:
On glibc, the bits used for the various character classes is endian dependant
(see _ISbit() in ctypes.h) but __regex_word does not account for this and uses
a spare bit that isn't spare on big-endian. On big-endian, it overlaps with the
bit for graphic characters which causes '-', '@', etc. to be considered a word
character.

Fixed this by defining the value using _ISbit(15) on MIPS glibc systems. We've
restricted this to MIPS for now to avoid the risk of introducing failures in
other targets.

Fixes PR26476.

Reviewers: hans, mclow.lists

Subscribers: dsanders, cfe-commits

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

Modified:
libcxx/trunk/include/regex

Modified: libcxx/trunk/include/regex
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/regex?rev=261088=261087=261088=diff
==
--- libcxx/trunk/include/regex (original)
+++ libcxx/trunk/include/regex Wed Feb 17 07:16:31 2016
@@ -976,7 +976,12 @@ public:
 typedef locale  locale_type;
 typedef ctype_base::maskchar_class_type;
 
+#if defined(__mips__) && defined(__GLIBC__)
+static const char_class_type __regex_word = 
static_cast(_ISbit(15));
+#else
 static const char_class_type __regex_word = 0x80;
+#endif
+
 private:
 locale __loc_;
 const ctype* __ct_;


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


Re: [PATCH] D15332: new clang-tidy checker readability-non-const-parameter

2016-02-17 Thread Aaron Ballman via cfe-commits
On Wed, Feb 17, 2016 at 2:39 AM, Daniel Marjamäki
 wrote:
> danielmarjamaki marked 2 inline comments as done.
>
> 
> Comment at: docs/clang-tidy/checks/readability-non-const-parameter.rst:15
> @@ +14,3 @@
> +
> +  // warning here; p should be const
> +  char f1(char *p) {
> 
> LegalizeAdulthood wrote:
>> With pointers, there are always two layers of constness:
>>
>>
>>   - Whether the pointer itself is modified
>>   - Whether the data pointed to is modified
>>
>> When you say "p should be const", I read that as the former.
>>
>> I am pretty sure you intended the latter.  You should be more explicit in 
>> your documentation.  The ambiguity would have been resolved if you showed 
>> the "after" version of the code that would eliminate the warning.  This is 
>> semi-implied by your next example, but it's kinder to the reader to resolve 
>> this ambiguity immediately.
>>
>>
> ok I understand, will try to improve
>
> 
> Comment at: test/clang-tidy/readability-non-const-parameter.cpp:3
> @@ +2,3 @@
> +
> +// Currently the checker only warns about pointer arguments.
> +//
> 
> LegalizeAdulthood wrote:
>> How hard is it to extend it to references?
>>
>> Certainly the confusion about what is const is easier to resolve in the case 
>> of references because the references themselves are immutable.
> If a "int &" reference parameter is not written then probably it's better to 
> pass it by value than making it const. I would prefer that unless it has to 
> use "int &" to comply with some interface.

I think it makes sense to pass it by value only if it is not an
expensive-to-copy type (we have an AST matcher helper for that in
TypeTraits.h), or to comply with an interface.

~Aaron

>
> I realize that the same can be said about pointers. If there is a "int *p" 
> and you just read the value that p points at .. maybe sometimes it would be 
> preferable to pass it by value.
>
>
> http://reviews.llvm.org/D15332
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r261084 - [OpenCL] Added half type literal with suffix h.

2016-02-17 Thread Anastasia Stulova via cfe-commits
Author: stulova
Date: Wed Feb 17 05:34:37 2016
New Revision: 261084

URL: http://llvm.org/viewvc/llvm-project?rev=261084=rev
Log:
[OpenCL] Added half type literal with suffix h.

OpenCL Extension v1.2 s9.5 allows half precision floating point
type literals with suffices h or H when cl_khr_fp16 is enabled.

Example:  half x = 1.0h;

Patch by Liu Yaxun (Sam)!

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


Added:
cfe/trunk/test/Lexer/half-literal.cpp
cfe/trunk/test/Lexer/opencl-half-literal.cl
Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Lex/LiteralSupport.h
cfe/trunk/lib/Lex/LiteralSupport.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/SemaOpenCL/half.cl

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=261084=261083=261084=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Wed Feb 17 05:34:37 
2016
@@ -124,6 +124,8 @@ def warn_float_underflow : Warning<
   InGroup;
 def warn_double_const_requires_fp64 : Warning<
   "double precision constant requires cl_khr_fp64, casting to single 
precision">;
+def err_half_const_requires_fp16 : Error<
+  "half precision constant requires cl_khr_fp16">;
 
 // C99 variable-length arrays
 def ext_vla : Extension<"variable length arrays are a C99 feature">,

Modified: cfe/trunk/include/clang/Lex/LiteralSupport.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/LiteralSupport.h?rev=261084=261083=261084=diff
==
--- cfe/trunk/include/clang/Lex/LiteralSupport.h (original)
+++ cfe/trunk/include/clang/Lex/LiteralSupport.h Wed Feb 17 05:34:37 2016
@@ -61,6 +61,7 @@ public:
   bool isUnsigned : 1;
   bool isLong : 1;  // This is *not* set for long long.
   bool isLongLong : 1;
+  bool isHalf : 1;  // 1.0h
   bool isFloat : 1; // 1.0f
   bool isImaginary : 1; // 1.0i
   uint8_t MicrosoftInteger; // Microsoft suffix extension i8, i16, i32, or i64.

Modified: cfe/trunk/lib/Lex/LiteralSupport.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/LiteralSupport.cpp?rev=261084=261083=261084=diff
==
--- cfe/trunk/lib/Lex/LiteralSupport.cpp (original)
+++ cfe/trunk/lib/Lex/LiteralSupport.cpp Wed Feb 17 05:34:37 2016
@@ -522,6 +522,7 @@ NumericLiteralParser::NumericLiteralPars
   isLong = false;
   isUnsigned = false;
   isLongLong = false;
+  isHalf = false;
   isFloat = false;
   isImaginary = false;
   MicrosoftInteger = 0;
@@ -555,10 +556,18 @@ NumericLiteralParser::NumericLiteralPars
   // we break out of the loop.
   for (; s != ThisTokEnd; ++s) {
 switch (*s) {
+case 'h':  // FP Suffix for "half".
+case 'H':
+  // OpenCL Extension v1.2 s9.5 - h or H suffix for half type.
+  if (!PP.getLangOpts().Half) break;
+  if (!isFPConstant) break;  // Error for integer constant.
+  if (isHalf || isFloat || isLong) break; // HH, FH, LH invalid.
+  isHalf = true;
+  continue;  // Success.
 case 'f':  // FP Suffix for "float"
 case 'F':
   if (!isFPConstant) break;  // Error for integer constant.
-  if (isFloat || isLong) break; // FF, LF invalid.
+  if (isHalf || isFloat || isLong) break; // HF, FF, LF invalid.
   isFloat = true;
   continue;  // Success.
 case 'u':
@@ -570,7 +579,7 @@ NumericLiteralParser::NumericLiteralPars
 case 'l':
 case 'L':
   if (isLong || isLongLong) break;  // Cannot be repeated.
-  if (isFloat) break;   // LF invalid.
+  if (isHalf || isFloat) break; // LH, LF invalid.
 
   // Check for long long.  The L's need to be adjacent and the same case.
   if (s[1] == s[0]) {
@@ -647,6 +656,7 @@ NumericLiteralParser::NumericLiteralPars
   isUnsigned = false;
   isLongLong = false;
   isFloat = false;
+  isHalf = false;
   isImaginary = false;
   MicrosoftInteger = 0;
 

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=261084=261083=261084=diff
==
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Wed Feb 17 05:34:37 2016
@@ -3295,7 +3295,14 @@ ExprResult Sema::ActOnNumericConstant(co
 
   if (Literal.isFloatingLiteral()) {
 QualType Ty;
-if (Literal.isFloat)
+if (Literal.isHalf){
+  if (getOpenCLOptions().cl_khr_fp16)
+Ty = Context.HalfTy;
+  else {
+Diag(Tok.getLocation(), diag::err_half_const_requires_fp16);
+return ExprError();
+  }
+} else if 

[PATCH] D17330: PR26648: "inline" shouldn't be recognized as a C keyword in MSVC 2013 compatibility mode

2016-02-17 Thread Andrey Bokhanko via cfe-commits
andreybokhanko created this revision.
andreybokhanko added reviewers: rnk, majnemer, thakis.
andreybokhanko added a subscriber: cfe-commits.

See PR26648 for full description of the problem.

Here I added a new keyword flag (KEYNOMS18_C) for keywords that shouldn't be 
enabled in MSVC 2013 mode for C programs and set it for "inline".

Andrey


http://reviews.llvm.org/D17330

Files:
  include/clang/Basic/TokenKinds.def
  lib/Basic/IdentifierTable.cpp
  test/Sema/inline-ms.c

Index: lib/Basic/IdentifierTable.cpp
===
--- lib/Basic/IdentifierTable.cpp
+++ lib/Basic/IdentifierTable.cpp
@@ -106,14 +106,15 @@
 KEYC11 = 0x400,
 KEYARC = 0x800,
 KEYNOMS18 = 0x01000,
-KEYNOOPENCL = 0x02000,
-WCHARSUPPORT = 0x04000,
-HALFSUPPORT = 0x08000,
-KEYCONCEPTS = 0x1,
-KEYOBJC2= 0x2,
-KEYZVECTOR  = 0x4,
-KEYCOROUTINES = 0x8,
-KEYALL = (0xf & ~KEYNOMS18 &
+KEYNOMS18_C = 0x02000,
+KEYNOOPENCL = 0x04000,
+WCHARSUPPORT = 0x08000,
+HALFSUPPORT = 0x1,
+KEYCONCEPTS = 0x2,
+KEYOBJC2= 0x4,
+KEYZVECTOR  = 0x8,
+KEYCOROUTINES = 0x10,
+KEYALL = (0xf & ~KEYNOMS18 & ~KEYNOMS18_C &
   ~KEYNOOPENCL) // KEYNOMS18 and KEYNOOPENCL are used to exclude.
   };
 
@@ -167,6 +168,12 @@
   !LangOpts.isCompatibleWithMSVC(LangOptions::MSVC2015))
 return;
 
+  // Don't add this keyword under MSVCCompat in C language.
+  if (LangOpts.MSVCCompat && (Flags & KEYNOMS18_C) &&
+  !LangOpts.isCompatibleWithMSVC(LangOptions::MSVC2015) &&
+  !LangOpts.CPlusPlus)
+return;
+
   // Don't add this keyword under OpenCL.
   if (LangOpts.OpenCL && (Flags & KEYNOOPENCL))
 return;
Index: include/clang/Basic/TokenKinds.def
===
--- include/clang/Basic/TokenKinds.def
+++ include/clang/Basic/TokenKinds.def
@@ -239,6 +239,8 @@
 //   KEYMS- This is a keyword if Microsoft extensions are enabled
 //   KEYNOMS18 - This is a keyword that must never be enabled under
 //   MSVC <= v18.
+//   KEYNOMS18_C - This is a keyword that must never be enabled under
+// MSVC <= v18 in C.
 //   KEYOPENCL  - This is a keyword in OpenCL
 //   KEYNOOPENCL  - This is a keyword that is not supported in OpenCL
 //   KEYALTIVEC - This is a keyword in AltiVec
@@ -267,7 +269,7 @@
 KEYWORD(for , KEYALL)
 KEYWORD(goto, KEYALL)
 KEYWORD(if  , KEYALL)
-KEYWORD(inline  , KEYC99|KEYCXX|KEYGNU)
+KEYWORD(inline  , KEYC99|KEYCXX|KEYGNU|KEYNOMS18_C)
 KEYWORD(int , KEYALL)
 KEYWORD(long, KEYALL)
 KEYWORD(register, KEYALL)
Index: test/Sema/inline-ms.c
===
--- test/Sema/inline-ms.c
+++ test/Sema/inline-ms.c
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -fms-compatibility 
-fms-compatibility-version=18 -triple=x86_64-windows-msvc -DV18 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -fms-compatibility 
-fms-compatibility-version=19 -triple=x86_64-windows-msvc -DV19 %s
+
+// expected-no-diagnostics
+
+#if V18
+// MSVC 12.0 doesn't recognize "inline" in C programs and allows its usage as 
an
+// identifier.
+int inline = 0;
+
+#elif V19
+// MSVC 14.0 recognizes "inline" as a keyword.
+inline int foo();
+
+#else
+
+#error Unknown test mode
+
+#endif
+


Index: lib/Basic/IdentifierTable.cpp
===
--- lib/Basic/IdentifierTable.cpp
+++ lib/Basic/IdentifierTable.cpp
@@ -106,14 +106,15 @@
 KEYC11 = 0x400,
 KEYARC = 0x800,
 KEYNOMS18 = 0x01000,
-KEYNOOPENCL = 0x02000,
-WCHARSUPPORT = 0x04000,
-HALFSUPPORT = 0x08000,
-KEYCONCEPTS = 0x1,
-KEYOBJC2= 0x2,
-KEYZVECTOR  = 0x4,
-KEYCOROUTINES = 0x8,
-KEYALL = (0xf & ~KEYNOMS18 &
+KEYNOMS18_C = 0x02000,
+KEYNOOPENCL = 0x04000,
+WCHARSUPPORT = 0x08000,
+HALFSUPPORT = 0x1,
+KEYCONCEPTS = 0x2,
+KEYOBJC2= 0x4,
+KEYZVECTOR  = 0x8,
+KEYCOROUTINES = 0x10,
+KEYALL = (0xf & ~KEYNOMS18 & ~KEYNOMS18_C &
   ~KEYNOOPENCL) // KEYNOMS18 and KEYNOOPENCL are used to exclude.
   };
 
@@ -167,6 +168,12 @@
   !LangOpts.isCompatibleWithMSVC(LangOptions::MSVC2015))
 return;
 
+  // Don't add this keyword under MSVCCompat in C language.
+  if (LangOpts.MSVCCompat && (Flags & KEYNOMS18_C) &&
+  !LangOpts.isCompatibleWithMSVC(LangOptions::MSVC2015) &&
+  !LangOpts.CPlusPlus)
+return;
+
   // Don't add this keyword under OpenCL.
   if (LangOpts.OpenCL && (Flags & KEYNOOPENCL))
 return;
Index: include/clang/Basic/TokenKinds.def
===
--- 

r261080 - [OPENMP] Fix handling loop-based directives with arrays.

2016-02-17 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Wed Feb 17 04:29:05 2016
New Revision: 261080

URL: http://llvm.org/viewvc/llvm-project?rev=261080=rev
Log:
[OPENMP] Fix handling loop-based directives with arrays.
Patch fixes possible problems with correct handling arrays as
expressions in initialization, conditions etc in loop-based constructs.

Modified:
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/test/OpenMP/for_ast_print.cpp

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=261080=261079=261080=diff
==
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Wed Feb 17 04:29:05 2016
@@ -3628,7 +3628,7 @@ public:
 NewVD->setInitStyle(VD->getInitStyle());
 NewVD->setExceptionVariable(VD->isExceptionVariable());
 NewVD->setNRVOVariable(VD->isNRVOVariable());
-NewVD->setCXXForRangeDecl(VD->isInExternCXXContext());
+NewVD->setCXXForRangeDecl(VD->isCXXForRangeDecl());
 NewVD->setConstexpr(VD->isConstexpr());
 NewVD->setInitCapture(VD->isInitCapture());
 NewVD->setPreviousDeclInSameBlockScope(
@@ -3673,14 +3673,20 @@ OpenMPIterationSpaceChecker::BuildNumIte
 Expr *Lower = Transform.TransformExpr(LBExpr).get();
 if (!Upper || !Lower)
   return nullptr;
-Upper = SemaRef.PerformImplicitConversion(Upper, UBExpr->getType(),
-Sema::AA_Converting,
-/*AllowExplicit=*/true)
-  .get();
-Lower = SemaRef.PerformImplicitConversion(Lower, LBExpr->getType(),
-  Sema::AA_Converting,
-  /*AllowExplicit=*/true)
-.get();
+if (!SemaRef.Context.hasSameType(Upper->getType(), UBExpr->getType())) {
+  Upper = SemaRef
+  .PerformImplicitConversion(Upper, UBExpr->getType(),
+ Sema::AA_Converting,
+ /*AllowExplicit=*/true)
+  .get();
+}
+if (!SemaRef.Context.hasSameType(Lower->getType(), LBExpr->getType())) {
+  Lower = SemaRef
+  .PerformImplicitConversion(Lower, LBExpr->getType(),
+ Sema::AA_Converting,
+ /*AllowExplicit=*/true)
+  .get();
+}
 if (!Upper || !Lower)
   return nullptr;
 
@@ -3707,14 +3713,18 @@ OpenMPIterationSpaceChecker::BuildNumIte
 return nullptr;
 
   // Upper - Lower [- 1] + Step
-  auto NewStep = Transform.TransformExpr(Step->IgnoreImplicit());
-  if (NewStep.isInvalid())
-return nullptr;
-  NewStep = SemaRef.PerformImplicitConversion(
-  NewStep.get(), Step->IgnoreImplicit()->getType(), Sema::AA_Converting,
-  /*AllowExplicit=*/true);
+  auto *StepNoImp = Step->IgnoreImplicit();
+  auto NewStep = Transform.TransformExpr(StepNoImp);
   if (NewStep.isInvalid())
 return nullptr;
+  if (!SemaRef.Context.hasSameType(NewStep.get()->getType(),
+   StepNoImp->getType())) {
+NewStep = SemaRef.PerformImplicitConversion(
+NewStep.get(), StepNoImp->getType(), Sema::AA_Converting,
+/*AllowExplicit=*/true);
+if (NewStep.isInvalid())
+  return nullptr;
+  }
   Diff = SemaRef.BuildBinOp(S, DefaultLoc, BO_Add, Diff.get(), NewStep.get());
   if (!Diff.isUsable())
 return nullptr;
@@ -3725,14 +3735,17 @@ OpenMPIterationSpaceChecker::BuildNumIte
 return nullptr;
 
   // (Upper - Lower [- 1] + Step) / Step
-  NewStep = Transform.TransformExpr(Step->IgnoreImplicit());
-  if (NewStep.isInvalid())
-return nullptr;
-  NewStep = SemaRef.PerformImplicitConversion(
-  NewStep.get(), Step->IgnoreImplicit()->getType(), Sema::AA_Converting,
-  /*AllowExplicit=*/true);
+  NewStep = Transform.TransformExpr(StepNoImp);
   if (NewStep.isInvalid())
 return nullptr;
+  if (!SemaRef.Context.hasSameType(NewStep.get()->getType(),
+   StepNoImp->getType())) {
+NewStep = SemaRef.PerformImplicitConversion(
+NewStep.get(), StepNoImp->getType(), Sema::AA_Converting,
+/*AllowExplicit=*/true);
+if (NewStep.isInvalid())
+  return nullptr;
+  }
   Diff = SemaRef.BuildBinOp(S, DefaultLoc, BO_Div, Diff.get(), NewStep.get());
   if (!Diff.isUsable())
 return nullptr;
@@ -3748,10 +3761,12 @@ OpenMPIterationSpaceChecker::BuildNumIte
 bool IsSigned = UseVarType ? VarType->hasSignedIntegerRepresentation()
: Type->hasSignedIntegerRepresentation();
 Type = C.getIntTypeForBitwidth(NewSize, IsSigned);
-Diff = SemaRef.PerformImplicitConversion(
-Diff.get(), Type, Sema::AA_Converting, /*AllowExplicit=*/true);
-if 

[PATCH] Tiny optimization of atomic operations

2016-02-17 Thread Eugene Kosov via cfe-commits
Hi.

This patch reduces some unneeded atomic inc/dec ops in std::shared_ptr and 
IntrusiveRefCntPtr which pointer types are inhevited from 
ThreadSafeRefCountedBase. Namely, patch replaces some copying with moves.

Diff is placed inline and attached as a separate file.

diff --git a/include/clang/Frontend/CompilerInstance.h 
b/include/clang/Frontend/CompilerInstance.h
index 83eed2c..4a6be47 100644
--- a/include/clang/Frontend/CompilerInstance.h
+++ b/include/clang/Frontend/CompilerInstance.h
@@ -380,7 +380,7 @@ public:
   /// \note Most clients should use setFileManager, which will implicitly reset
   /// the virtual file system to the one contained in the file manager.
   void setVirtualFileSystem(IntrusiveRefCntPtr FS) {
-VirtualFileSystem = FS;
+VirtualFileSystem = std::move(FS);
   }
 
   /// }
diff --git a/lib/Basic/FileManager.cpp b/lib/Basic/FileManager.cpp
index ba016db..437f9bb 100644
--- a/lib/Basic/FileManager.cpp
+++ b/lib/Basic/FileManager.cpp
@@ -47,14 +47,14 @@ using namespace clang;
 
 FileManager::FileManager(const FileSystemOptions ,
  IntrusiveRefCntPtr FS)
-  : FS(FS), FileSystemOpts(FSO),
+  : FS(std::move(FS)), FileSystemOpts(FSO),
 SeenDirEntries(64), SeenFileEntries(64), NextFileUID(0) {
   NumDirLookups = NumFileLookups = 0;
   NumDirCacheMisses = NumFileCacheMisses = 0;
 
   // If the caller doesn't provide a virtual file system, just grab the real
   // file system.
-  if (!FS)
+  if (!this->FS)
 this->FS = vfs::getRealFileSystem();
 }
 
diff --git a/lib/Basic/VirtualFileSystem.cpp b/lib/Basic/VirtualFileSystem.cpp
index 6977f40..94e4de1 100644
--- a/lib/Basic/VirtualFileSystem.cpp
+++ b/lib/Basic/VirtualFileSystem.cpp
@@ -271,14 +271,14 @@ directory_iterator RealFileSystem::dir_begin(const Twine 
,
 // OverlayFileSystem implementation
 
//===---===/
 OverlayFileSystem::OverlayFileSystem(IntrusiveRefCntPtr BaseFS) {
-  FSList.push_back(BaseFS);
+  FSList.push_back(std::move(BaseFS));
 }
 
 void OverlayFileSystem::pushOverlay(IntrusiveRefCntPtr FS) {
-  FSList.push_back(FS);
+  FSList.push_back(std::move(FS));
   // Synchronize added file systems by duplicating the working directory from
   // the first one in the list.
-  FS->setCurrentWorkingDirectory(getCurrentWorkingDirectory().get());
+  
FSList.back()->setCurrentWorkingDirectory(getCurrentWorkingDirectory().get());
 }
 
 ErrorOr OverlayFileSystem::status(const Twine ) {
@@ -833,7 +833,8 @@ class RedirectingFileSystem : public vfs::FileSystem {
 
 private:
   RedirectingFileSystem(IntrusiveRefCntPtr ExternalFS)
-  : ExternalFS(ExternalFS), CaseSensitive(true), UseExternalNames(true) {}
+  : ExternalFS(std::move(ExternalFS)), CaseSensitive(true),
+UseExternalNames(true) {}
 
   /// \brief Looks up \p Path in \c Roots.
   ErrorOr lookupPath(const Twine );
@@ -1223,7 +1224,7 @@ RedirectingFileSystem *RedirectingFileSystem::create(
   RedirectingFileSystemParser P(Stream);
 
   std::unique_ptr FS(
-  new RedirectingFileSystem(ExternalFS));
+  new RedirectingFileSystem(std::move(ExternalFS)));
   if (!P.parse(Root, FS.get()))
 return nullptr;
 
@@ -1365,7 +1366,7 @@ vfs::getVFSFromYAML(std::unique_ptr Buffer,
 SourceMgr::DiagHandlerTy DiagHandler, void *DiagContext,
 IntrusiveRefCntPtr ExternalFS) {
   return RedirectingFileSystem::create(std::move(Buffer), DiagHandler,
-   DiagContext, ExternalFS);
+   DiagContext, std::move(ExternalFS));
 }
 
 UniqueID vfs::getNextVirtualUniqueID() {
@@ -1548,7 +1549,7 @@ 
vfs::recursive_directory_iterator::recursive_directory_iterator(FileSystem _,
   directory_iterator I = FS->dir_begin(Path, EC);
   if (!EC && I != directory_iterator()) {
 State = std::make_shared();
-State->push(I);
+State->push(std::move(I));
   }
 }
 
@@ -1562,7 +1563,7 @@ recursive_directory_iterator::increment(std::error_code 
) {
 if (EC)
   return *this;
 if (I != End) {
-  State->push(I);
+  State->push(std::move(I));
   return *this;
 }
   }
diff --git a/lib/Driver/Driver.cpp b/lib/Driver/Driver.cpp
index 766c56d..402faf3 100644
--- a/lib/Driver/Driver.cpp
+++ b/lib/Driver/Driver.cpp
@@ -49,11 +49,10 @@ using namespace llvm::opt;
 Driver::Driver(StringRef ClangExecutable, StringRef DefaultTargetTriple,
DiagnosticsEngine ,
IntrusiveRefCntPtr VFS)
-: Opts(createDriverOptTable()), Diags(Diags), VFS(VFS), Mode(GCCMode),
-  SaveTemps(SaveTempsNone), LTOMode(LTOK_None),
-  ClangExecutable(ClangExecutable),
-  SysRoot(DEFAULT_SYSROOT), UseStdLib(true),
-  DefaultTargetTriple(DefaultTargetTriple),
+: Opts(createDriverOptTable()), Diags(Diags), VFS(std::move(VFS)),
+  Mode(GCCMode), SaveTemps(SaveTempsNone), LTOMode(LTOK_None),
+  ClangExecutable(ClangExecutable),