r270822 - [OPENMP] Set '_OPENMP' macro to '201511' value to reflect support for

2016-05-25 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Wed May 25 23:56:05 2016
New Revision: 270822

URL: http://llvm.org/viewvc/llvm-project?rev=270822=rev
Log:
[OPENMP] Set '_OPENMP' macro to '201511' value to reflect support for
OpenMP 4.5.

According to OpenMP 4.5 the _OPENMP macro name is defined to have the decimal 
value mm where  and mm are the year and month designations of the 
version of the OpenMP API that the implementation supports. Clang supports 
OpenMP 4.5 so updated value of _OPENMP macro to 201511.

Modified:
cfe/trunk/lib/Frontend/InitPreprocessor.cpp
cfe/trunk/test/OpenMP/predefined_macro.c

Modified: cfe/trunk/lib/Frontend/InitPreprocessor.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/InitPreprocessor.cpp?rev=270822=270821=270822=diff
==
--- cfe/trunk/lib/Frontend/InitPreprocessor.cpp (original)
+++ cfe/trunk/lib/Frontend/InitPreprocessor.cpp Wed May 25 23:56:05 2016
@@ -928,7 +928,7 @@ static void InitializePredefinedMacros(c
 //   macro name is defined to have the decimal value mm where
 //    and mm are the year and the month designations of the
 //   version of the OpenMP API that the implementation support.
-Builder.defineMacro("_OPENMP", "201307");
+Builder.defineMacro("_OPENMP", "201511");
   }
 
   // CUDA device path compilaton

Modified: cfe/trunk/test/OpenMP/predefined_macro.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/predefined_macro.c?rev=270822=270821=270822=diff
==
--- cfe/trunk/test/OpenMP/predefined_macro.c (original)
+++ cfe/trunk/test/OpenMP/predefined_macro.c Wed May 25 23:56:05 2016
@@ -5,7 +5,7 @@
 // -fopenmp option is specified
 #ifndef _OPENMP
 #error "No _OPENMP macro is defined with -fopenmp option"
-#elsif _OPENMP != 201307
+#elsif _OPENMP != 201511
 #error "_OPENMP has incorrect value"
 #endif //_OPENMP
 #else


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


Re: [PATCH] D20660: Remove `auto_ptr` in C++17.

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

A couple of comments.

1. there's probably a better way to state `_LIBCPP_STD_VER <= 14 || 
defined(_LIBCPP_NO_REMOVE_AUTO_PTR)`. Maybe `_LIBCPP_HAS_NO_AUTO_PTR` which 
`__config` defines if `_LIBCPP_STD_VER > 14 && 
!defined(_LIBCPP_NO_REMOVE_AUTO_PTR)`.

2. `// XFAIL c++1z` is eventually going to be a pain to maintain. I'll  try and 
come up with a better way to state this condition in the test suite.


http://reviews.llvm.org/D20660



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


[PATCH] D20660: Remove `auto_ptr` in C++17.

2016-05-25 Thread Marshall Clow via cfe-commits
mclow.lists created this revision.
mclow.lists added a reviewer: EricWF.
mclow.lists added a subscriber: cfe-commits.

[[ http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4190 | N4190 ]] 
removed `auto_ptr` from C++1z. (and other stuff)

Wrap all the auto_ptr bits in an #ifdef so they disappear when compiling with 
`-std=c++1z` or later.

Introduce a new configuration option, `_LIBCPP_NO_REMOVE_AUTOPTR` which allows 
user code to continue using `auto_ptr` in C++1z mode if desired.

Add a test for `_LIBCPP_NO_REMOVE_AUTOPTR`, and mark all the rest of the 
`auto_ptr` tests to XFAIL for c++1z

http://reviews.llvm.org/D20660

Files:
  include/memory
  test/libcxx/depr/depr.auto.ptr/auto.ptr/auto_ptr.cxx1z.pass.cpp
  test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/assignment.pass.cpp
  test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/convert.pass.cpp
  test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/convert_assignment.pass.cpp
  test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/copy.pass.cpp
  test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/pointer.pass.cpp
  
test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.conv/assign_from_auto_ptr_ref.pass.cpp
  
test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.conv/convert_from_auto_ptr_ref.pass.cpp
  
test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.conv/convert_to_auto_ptr.pass.cpp
  
test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.conv/convert_to_auto_ptr_ref.pass.cpp
  test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.members/arrow.pass.cpp
  test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.members/deref.pass.cpp
  test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.members/release.pass.cpp
  test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.members/reset.pass.cpp
  test/std/depr/depr.auto.ptr/auto.ptr/element_type.pass.cpp

Index: include/memory
===
--- include/memory
+++ include/memory
@@ -180,10 +180,10 @@
 ForwardIterator
 uninitialized_fill_n(ForwardIterator first, Size n, const T& x);
 
-template  struct auto_ptr_ref {};
+template  struct auto_ptr_ref {};  // removed in C++17
 
 template
-class auto_ptr
+class auto_ptr  // removed in C++17
 {
 public:
 typedef X element_type;
@@ -242,7 +242,7 @@
 template 
 unique_ptr(unique_ptr&& u) noexcept;
 template 
-unique_ptr(auto_ptr&& u) noexcept;
+unique_ptr(auto_ptr&& u) noexcept;   // removed in C++17
 
 // destructor
 ~unique_ptr();
@@ -375,7 +375,7 @@
 shared_ptr(shared_ptr&& r) noexcept;
 template shared_ptr(shared_ptr&& r) noexcept;
 template explicit shared_ptr(const weak_ptr& r);
-template shared_ptr(auto_ptr&& r);
+template shared_ptr(auto_ptr&& r);  // removed in C++17
 template  shared_ptr(unique_ptr&& r);
 shared_ptr(nullptr_t) : shared_ptr() { }
 
@@ -387,7 +387,7 @@
 template shared_ptr& operator=(const shared_ptr& r) noexcept;
 shared_ptr& operator=(shared_ptr&& r) noexcept;
 template shared_ptr& operator=(shared_ptr&& r);
-template shared_ptr& operator=(auto_ptr&& r);
+template shared_ptr& operator=(auto_ptr&& r); // removed in C++17
 template  shared_ptr& operator=(unique_ptr&& r);
 
 // modifiers:
@@ -1959,6 +1959,7 @@
 inline _LIBCPP_INLINE_VISIBILITY
 void return_temporary_buffer(_Tp* __p) _NOEXCEPT {::operator delete(__p);}
 
+#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_NO_REMOVE_AUTOPTR)
 template 
 struct auto_ptr_ref
 {
@@ -2015,6 +2016,7 @@
 public:
 typedef void element_type;
 };
+#endif
 
 template ::type,
  typename remove_cv<_T2>::type>::value,
@@ -2639,6 +2641,7 @@
   >::type = __nat()) _NOEXCEPT
 : __ptr_(__u.release(), _VSTD::forward<_Ep>(__u.get_deleter())) {}
 
+#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_NO_REMOVE_AUTOPTR)
 template 
 _LIBCPP_INLINE_VISIBILITY unique_ptr(auto_ptr<_Up>&& __p,
 typename enable_if<
@@ -2649,6 +2652,7 @@
 : __ptr_(__p.release())
 {
 }
+#endif
 
 _LIBCPP_INLINE_VISIBILITY unique_ptr& operator=(unique_ptr&& __u) _NOEXCEPT
 {
@@ -2700,6 +2704,7 @@
 _LIBCPP_INLINE_VISIBILITY unique_ptr(pointer __p, deleter_type __d)
 : __ptr_(_VSTD::move(__p), _VSTD::move(__d)) {}
 
+#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_NO_REMOVE_AUTOPTR)
 template 
 _LIBCPP_INLINE_VISIBILITY
 typename enable_if<
@@ -2709,7 +2714,7 @@
   >::type
 operator=(auto_ptr<_Up> __p)
 {reset(__p.release()); return *this;}
-
+#endif
 #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
 _LIBCPP_INLINE_VISIBILITY ~unique_ptr() {reset();}
 
@@ -3901,6 +3906,7 @@
 #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
 template explicit shared_ptr(const weak_ptr<_Yp>& __r,
typename enable_if

Re: [PATCH] D20617: [X86][SSE] _mm_store1_ps/_mm_store1_pd should require an aligned pointer

2016-05-25 Thread David Majnemer via cfe-commits
majnemer added a subscriber: majnemer.


Comment at: lib/Headers/emmintrin.h:598
@@ -594,3 +597,3 @@
 static __inline__ void __DEFAULT_FN_ATTRS
-_mm_store_pd(double *__dp, __m128d __a)
+_mm_store_pd1(double *__dp, __m128d __a)
 {

You could use `__attribute__((align_value(16)))` no?


Repository:
  rL LLVM

http://reviews.llvm.org/D20617



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


Re: [PATCH] D18488: [OpenMP] Parsing and sema support for the from clause

2016-05-25 Thread Alexey Bataev via cfe-commits
ABataev accepted this revision.
ABataev added a comment.
This revision is now accepted and ready to land.

LG


http://reviews.llvm.org/D18488



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


Re: [PATCH] D20650: [OpenMP] Codegen for target update directive.

2016-05-25 Thread Alexey Bataev via cfe-commits
ABataev accepted this revision.
ABataev added a comment.
This revision is now accepted and ready to land.

LG


http://reviews.llvm.org/D20650



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


Re: [PATCH] D20617: [X86][SSE] _mm_store1_ps/_mm_store1_pd should require an aligned pointer

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

Given that its documented as being aligned. I'm ok with it. LGTM


Repository:
  rL LLVM

http://reviews.llvm.org/D20617



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


Re: [PATCH] D18597: [OpenMP] Parsing and sema support for the to clause

2016-05-25 Thread Alexey Bataev via cfe-commits
ABataev accepted this revision.
ABataev added a comment.
This revision is now accepted and ready to land.

LG, with a small nit.



Comment at: lib/Sema/SemaOpenMP.cpp:10214
@@ +10213,3 @@
+// expressions.
+struct MappableVarListInfo {
+  // The list of expressions.

Mark it as a 'final' struct


http://reviews.llvm.org/D18597



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


Re: [PATCH] D15944: [OpenMP] Parsing and sema support for target update directive

2016-05-25 Thread Alexey Bataev via cfe-commits
ABataev accepted this revision.
ABataev added a comment.
This revision is now accepted and ready to land.

LG


http://reviews.llvm.org/D15944



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


Re: [PATCH] D20632: clang-format: [JS] Support shebang lines on the very first line.

2016-05-25 Thread Alex Eagle via cfe-commits
alexeagle added a subscriber: alexeagle.


Comment at: lib/Format/FormatTokenLexer.cpp:23
@@ -22,1 +22,3 @@
 
+#include "llvm/Support/Debug.h"
+

revert this file


Comment at: lib/Format/TokenAnnotator.cpp:698
@@ +697,3 @@
+
+if (Style.Language == FormatStyle::LK_JavaScript) {
+  // JavaScript files can contain shebang lines of the form:

should we still restrict it to be on the first line?

I suppose if you start some other line with #, that's not valid JS or TS so it 
doesn't matter what clang-format does to it? Maybe it's fine like this.


http://reviews.llvm.org/D20632



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


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

2016-05-25 Thread Alexey Bataev via cfe-commits
ABataev accepted this revision.
ABataev added a comment.
This revision is now accepted and ready to land.

LG


http://reviews.llvm.org/D20112



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


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

2016-05-25 Thread Alexey Bataev via cfe-commits
ABataev accepted this revision.
ABataev added a comment.
This revision is now accepted and ready to land.

LG


http://reviews.llvm.org/D20111



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


r270817 - Don't feed standard error to FileCheck.

2016-05-25 Thread Akira Hatanaka via cfe-commits
Author: ahatanak
Date: Wed May 25 21:32:10 2016
New Revision: 270817

URL: http://llvm.org/viewvc/llvm-project?rev=270817=rev
Log:
Don't feed standard error to FileCheck.

This is an attempt to fix the buildbot that started failing after
r270808.

http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/13141 

Modified:
cfe/trunk/test/SemaObjC/property-atomic-bool.m

Modified: cfe/trunk/test/SemaObjC/property-atomic-bool.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/property-atomic-bool.m?rev=270817=270816=270817=diff
==
--- cfe/trunk/test/SemaObjC/property-atomic-bool.m (original)
+++ cfe/trunk/test/SemaObjC/property-atomic-bool.m Wed May 25 21:32:10 2016
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple x86_64-apple-macosx10.10 -ast-dump "%s" 2>&1 | 
FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.10 -ast-dump "%s" | FileCheck 
%s
 
 // CHECK: TypedefDecl {{.*}} referenced AtomicBool '_Atomic(_Bool)'
 // CHECK:  AtomicType {{.*}} '_Atomic(_Bool)'


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


Re: [PATCH] D15421: [Feature] Add a builtin for indexing into parameter packs

2016-05-25 Thread Louis Dionne via cfe-commits
ldionne added a comment.

No problem for the delay; we're all busy :-). Unfortunately, the patch does not 
apply cleanly on `master` anymore, so I'll rebase it and someone can then 
commit it for me.


http://reviews.llvm.org/D15421



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


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

2016-05-25 Thread Saleem Abdulrasool via cfe-commits
compnerd closed this revision.
compnerd added a comment.

SVN r270816 with the changes.


Repository:
  rL LLVM

http://reviews.llvm.org/D20270



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


[libcxxabi] r270816 - libc++abi: build with -fvisibility=hidden

2016-05-25 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Wed May 25 21:12:20 2016
New Revision: 270816

URL: http://llvm.org/viewvc/llvm-project?rev=270816=rev
Log:
libc++abi: build with -fvisibility=hidden

Enable building libc++abi with hidden visibility by default.  The ABI mandated
interfaces (and a few extra) are already set up to be externally visible.  This
allows us to ensure that any implementation details are not leaked.

Modified:
libcxxabi/trunk/CMakeLists.txt
libcxxabi/trunk/cmake/config-ix.cmake
libcxxabi/trunk/include/__cxxabi_config.h
libcxxabi/trunk/src/cxa_default_handlers.cpp
libcxxabi/trunk/src/cxa_handlers.cpp

Modified: libcxxabi/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/CMakeLists.txt?rev=270816=270815=270816=diff
==
--- libcxxabi/trunk/CMakeLists.txt (original)
+++ libcxxabi/trunk/CMakeLists.txt Wed May 25 21:12:20 2016
@@ -250,6 +250,8 @@ append_if(LIBCXXABI_CXX_FLAGS LIBCXXABI_
 
 append_if(LIBCXXABI_C_FLAGS LIBCXXABI_HAS_FUNWIND_TABLES -funwind-tables)
 
+append_if(LIBCXXABI_COMPILE_FLAGS LIBCXXABI_HAS_FVISIBILITY_HIDDEN_FLAG 
-fvisibility=hidden)
+
 # Assert
 string(TOUPPER "${CMAKE_BUILD_TYPE}" uppercase_CMAKE_BUILD_TYPE)
 if (LIBCXXABI_ENABLE_ASSERTIONS)

Modified: libcxxabi/trunk/cmake/config-ix.cmake
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/cmake/config-ix.cmake?rev=270816=270815=270816=diff
==
--- libcxxabi/trunk/cmake/config-ix.cmake (original)
+++ libcxxabi/trunk/cmake/config-ix.cmake Wed May 25 21:12:20 2016
@@ -8,6 +8,7 @@ check_cxx_compiler_flag(-fPIC
 check_cxx_compiler_flag(-fno-exceptions   LIBCXXABI_HAS_NO_EXCEPTIONS_FLAG)
 check_cxx_compiler_flag(-fno-rtti LIBCXXABI_HAS_NO_RTTI_FLAG)
 check_cxx_compiler_flag(-fstrict-aliasing 
LIBCXXABI_HAS_FSTRICT_ALIASING_FLAG)
+check_cxx_compiler_flag(-fvisibility=hidden   
LIBCXXABI_HAS_FVISIBILITY_HIDDEN_FLAG)
 check_cxx_compiler_flag(-nodefaultlibsLIBCXXABI_HAS_NODEFAULTLIBS_FLAG)
 check_cxx_compiler_flag(-nostdinc++   LIBCXXABI_HAS_NOSTDINCXX_FLAG)
 check_cxx_compiler_flag(-Wall LIBCXXABI_HAS_WALL_FLAG)

Modified: libcxxabi/trunk/include/__cxxabi_config.h
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/include/__cxxabi_config.h?rev=270816=270815=270816=diff
==
--- libcxxabi/trunk/include/__cxxabi_config.h (original)
+++ libcxxabi/trunk/include/__cxxabi_config.h Wed May 25 21:12:20 2016
@@ -24,15 +24,18 @@
 #if defined(_LIBCXXABI_DLL)
  #if defined(cxxabi_EXPORTS)
   #define _LIBCXXABI_HIDDEN
+  #define _LIBCXXABI_DATA_VIS __declspec(dllexport)
   #define _LIBCXXABI_FUNC_VIS __declspec(dllexport)
   #define _LIBCXXABI_TYPE_VIS __declspec(dllexport)
  #else
   #define _LIBCXXABI_HIDDEN
+  #define _LIBCXXABI_DATA_VIS __declspec(dllimport)
   #define _LIBCXXABI_FUNC_VIS __declspec(dllimport)
   #define _LIBCXXABI_TYPE_VIS __declspec(dllimport)
  #endif
 #else
  #define _LIBCXXABI_HIDDEN __attribute__((__visibility__("hidden")))
+ #define _LIBCXXABI_DATA_VIS __attribute__((__visibility__("default")))
  #define _LIBCXXABI_FUNC_VIS __attribute__((__visibility__("default")))
  #if __has_attribute(__type_visibility__)
   #define _LIBCXXABI_TYPE_VIS __attribute__((__type_visibility__("default")))

Modified: libcxxabi/trunk/src/cxa_default_handlers.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/cxa_default_handlers.cpp?rev=270816=270815=270816=diff
==
--- libcxxabi/trunk/src/cxa_default_handlers.cpp (original)
+++ libcxxabi/trunk/src/cxa_default_handlers.cpp Wed May 25 21:12:20 2016
@@ -88,7 +88,10 @@ static void default_unexpected_handler()
 //
 // Global variables that hold the pointers to the current handler
 //
-std::terminate_handler  __cxa_terminate_handler = default_terminate_handler;
+_LIBCXXABI_DATA_VIS
+std::terminate_handler __cxa_terminate_handler = default_terminate_handler;
+
+_LIBCXXABI_DATA_VIS
 std::unexpected_handler __cxa_unexpected_handler = default_unexpected_handler;
 
 // In the future these will become:

Modified: libcxxabi/trunk/src/cxa_handlers.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/cxa_handlers.cpp?rev=270816=270815=270816=diff
==
--- libcxxabi/trunk/src/cxa_handlers.cpp (original)
+++ libcxxabi/trunk/src/cxa_handlers.cpp Wed May 25 21:12:20 2016
@@ -102,9 +102,9 @@ terminate() _NOEXCEPT
 __terminate(get_terminate());
 }
 
-extern "C" new_handler __cxa_new_handler = 0;
-// In the future these will become:
+// In the future this will become:
 // std::atomic  __cxa_new_handler(0);
+extern "C" _LIBCXXABI_DATA_VIS new_handler __cxa_new_handler = 0;
 
 new_handler
 

Re: [PATCH] D20336: [AMDGPU] Remove individual debugger options + update features

2016-05-25 Thread Tom Stellard via cfe-commits
tstellarAMD accepted this revision.
tstellarAMD added a comment.
This revision is now accepted and ready to land.

LGTM.


http://reviews.llvm.org/D20336



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


r270808 - [ObjC] Remove _Atomic from return type and parameter type of

2016-05-25 Thread Akira Hatanaka via cfe-commits
Author: ahatanak
Date: Wed May 25 19:37:30 2016
New Revision: 270808

URL: http://llvm.org/viewvc/llvm-project?rev=270808=rev
Log:
[ObjC] Remove _Atomic from return type and parameter type of
objective-c properties.

This fixes an assert in CodeGen that fires when the getter and setter
functions for an objective-c property of type _Atomic(_Bool) are
synthesized.

rdar://problem/26322972

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

Added:
cfe/trunk/test/CodeGenObjC/property-atomic-bool.m
cfe/trunk/test/SemaObjC/property-atomic-bool.m
Modified:
cfe/trunk/include/clang/AST/Type.h
cfe/trunk/lib/AST/Type.cpp
cfe/trunk/lib/CodeGen/CGObjC.cpp
cfe/trunk/lib/Sema/SemaObjCProperty.cpp

Modified: cfe/trunk/include/clang/AST/Type.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=270808=270807=270808=diff
==
--- cfe/trunk/include/clang/AST/Type.h (original)
+++ cfe/trunk/include/clang/AST/Type.h Wed May 25 19:37:30 2016
@@ -1080,6 +1080,9 @@ public:
   /// Strip Objective-C "__kindof" types from the given type.
   QualType stripObjCKindOfType(const ASTContext ) const;
 
+  /// Remove all qualifiers including _Atomic.
+  QualType getAtomicUnqualifiedType() const;
+
 private:
   // These methods are implemented in a separate translation unit;
   // "static"-ize them to avoid creating temporary QualTypes in the

Modified: cfe/trunk/lib/AST/Type.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Type.cpp?rev=270808=270807=270808=diff
==
--- cfe/trunk/lib/AST/Type.cpp (original)
+++ cfe/trunk/lib/AST/Type.cpp Wed May 25 19:37:30 2016
@@ -1274,6 +1274,12 @@ QualType QualType::stripObjCKindOfType(c
});
 }
 
+QualType QualType::getAtomicUnqualifiedType() const {
+  if (auto AT = getTypePtr()->getAs())
+return AT->getValueType().getUnqualifiedType();
+  return getUnqualifiedType();
+}
+
 Optional Type::getObjCSubstitutions(
const DeclContext *dc) const {
   // Look through method scopes.

Modified: cfe/trunk/lib/CodeGen/CGObjC.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjC.cpp?rev=270808=270807=270808=diff
==
--- cfe/trunk/lib/CodeGen/CGObjC.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjC.cpp Wed May 25 19:37:30 2016
@@ -897,9 +897,8 @@ CodeGenFunction::generateObjCGetterBody(
 
 // Currently, all atomic accesses have to be through integer
 // types, so there's no point in trying to pick a prettier type.
-llvm::Type *bitcastType =
-  llvm::Type::getIntNTy(getLLVMContext(),
-getContext().toBits(strategy.getIvarSize()));
+uint64_t ivarSize = getContext().toBits(strategy.getIvarSize());
+llvm::Type *bitcastType = llvm::Type::getIntNTy(getLLVMContext(), 
ivarSize);
 bitcastType = bitcastType->getPointerTo(); // addrspace 0 okay
 
 // Perform an atomic load.  This does not impose ordering constraints.
@@ -911,7 +910,16 @@ CodeGenFunction::generateObjCGetterBody(
 // Store that value into the return address.  Doing this with a
 // bitcast is likely to produce some pretty ugly IR, but it's not
 // the *most* terrible thing in the world.
-Builder.CreateStore(load, Builder.CreateBitCast(ReturnValue, bitcastType));
+llvm::Type *retTy = ConvertType(getterMethod->getReturnType());
+uint64_t retTySize = CGM.getDataLayout().getTypeSizeInBits(retTy);
+llvm::Value *ivarVal = load;
+if (ivarSize > retTySize) {
+  llvm::Type *newTy = llvm::Type::getIntNTy(getLLVMContext(), retTySize);
+  ivarVal = Builder.CreateTrunc(load, newTy);
+  bitcastType = newTy->getPointerTo();
+}
+Builder.CreateStore(ivarVal,
+Builder.CreateBitCast(ReturnValue, bitcastType));
 
 // Make sure we don't do an autorelease.
 AutoreleaseResult = false;
@@ -1010,7 +1018,6 @@ CodeGenFunction::generateObjCGetterBody(
   AutoreleaseResult = false;
 }
 
-value = Builder.CreateBitCast(value, ConvertType(propType));
 value = Builder.CreateBitCast(
 value, ConvertType(GetterMethodDecl->getReturnType()));
   }

Modified: cfe/trunk/lib/Sema/SemaObjCProperty.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaObjCProperty.cpp?rev=270808=270807=270808=diff
==
--- cfe/trunk/lib/Sema/SemaObjCProperty.cpp (original)
+++ cfe/trunk/lib/Sema/SemaObjCProperty.cpp Wed May 25 19:37:30 2016
@@ -1493,24 +1493,26 @@ bool Sema::DiagnosePropertyAccessorMisma
   if (!GetterMethod)
 return false;
   QualType GetterType = GetterMethod->getReturnType().getNonReferenceType();
-  QualType PropertyIvarType = 

Re: [PATCH] D20407: [CodeGen][ObjC] zero-ext an i1 value to i8

2016-05-25 Thread Akira Hatanaka via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL270808: [ObjC] Remove _Atomic from return type and parameter 
type of (authored by ahatanak).

Changed prior to commit:
  http://reviews.llvm.org/D20407?vs=58544=58549#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D20407

Files:
  cfe/trunk/include/clang/AST/Type.h
  cfe/trunk/lib/AST/Type.cpp
  cfe/trunk/lib/CodeGen/CGObjC.cpp
  cfe/trunk/lib/Sema/SemaObjCProperty.cpp
  cfe/trunk/test/CodeGenObjC/property-atomic-bool.m
  cfe/trunk/test/SemaObjC/property-atomic-bool.m

Index: cfe/trunk/include/clang/AST/Type.h
===
--- cfe/trunk/include/clang/AST/Type.h
+++ cfe/trunk/include/clang/AST/Type.h
@@ -1080,6 +1080,9 @@
   /// Strip Objective-C "__kindof" types from the given type.
   QualType stripObjCKindOfType(const ASTContext ) const;
 
+  /// Remove all qualifiers including _Atomic.
+  QualType getAtomicUnqualifiedType() const;
+
 private:
   // These methods are implemented in a separate translation unit;
   // "static"-ize them to avoid creating temporary QualTypes in the
Index: cfe/trunk/test/SemaObjC/property-atomic-bool.m
===
--- cfe/trunk/test/SemaObjC/property-atomic-bool.m
+++ cfe/trunk/test/SemaObjC/property-atomic-bool.m
@@ -0,0 +1,61 @@
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.10 -ast-dump "%s" 2>&1 | FileCheck %s
+
+// CHECK: TypedefDecl {{.*}} referenced AtomicBool '_Atomic(_Bool)'
+// CHECK:  AtomicType {{.*}} '_Atomic(_Bool)'
+// CHECK:   BuiltinType {{.*}} '_Bool'
+// CHECK: ObjCInterfaceDecl {{.*}} A0
+// CHECK:  ObjCPropertyDecl {{.*}} p '_Atomic(_Bool)' {{.*}} nonatomic
+// CHECK:  ObjCMethodDecl {{.*}} implicit - p '_Bool'
+// CHECK:  ObjCMethodDecl {{.*}} implicit - setP: 'void'
+// CHECK:   ParmVarDecl {{.*}} p '_Bool'
+// CHECK: ObjCInterfaceDecl {{.*}} A1
+// CHECK:  ObjCPropertyDecl {{.*}} p 'AtomicBool':'_Atomic(_Bool)' {{.*}} nonatomic
+// CHECK:  ObjCMethodDecl {{.*}} implicit - p '_Bool'
+// CHECK:  ObjCMethodDecl {{.*}} implicit - setP: 'void'
+// CHECK:   ParmVarDecl {{.*}} p '_Bool'
+// CHECK: ObjCInterfaceDecl {{.*}} A2
+// CHECK:  ObjCIvarDecl {{.*}} p '_Atomic(_Bool)' protected
+// CHECK:  ObjCPropertyDecl {{.*}} p '_Atomic(_Bool)'
+// CHECK:  ObjCMethodDecl {{.*}} implicit - p '_Bool'
+// CHECK:  ObjCMethodDecl {{.*}} implicit - setP: 'void'
+// CHECK:   ParmVarDecl {{.*}} p '_Bool'
+// CHECK: ObjCInterfaceDecl {{.*}} A3
+// CHECK:  ObjCIvarDecl {{.*}} p 'AtomicBool':'_Atomic(_Bool)' protected
+// CHECK:  ObjCPropertyDecl {{.*}} p 'AtomicBool':'_Atomic(_Bool)'
+// CHECK:  ObjCMethodDecl {{.*}} implicit - p '_Bool'
+// CHECK:  ObjCMethodDecl {{.*}} implicit - setP: 'void'
+// CHECK:   ParmVarDecl {{.*}} p '_Bool'
+
+typedef _Atomic(_Bool) AtomicBool;
+
+@interface A0
+@property(nonatomic) _Atomic(_Bool) p;
+@end
+@implementation A0
+@end
+
+@interface A1
+@property(nonatomic) AtomicBool p;
+@end
+@implementation A1
+@end
+
+@interface A2 {
+  _Atomic(_Bool) p;
+}
+@property _Atomic(_Bool) p;
+@end
+
+@implementation A2
+@synthesize p;
+@end
+
+@interface A3 {
+  AtomicBool p;
+}
+@property AtomicBool p;
+@end
+
+@implementation A3
+@synthesize p;
+@end
Index: cfe/trunk/test/CodeGenObjC/property-atomic-bool.m
===
--- cfe/trunk/test/CodeGenObjC/property-atomic-bool.m
+++ cfe/trunk/test/CodeGenObjC/property-atomic-bool.m
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10 -emit-llvm -x objective-c %s -o - | FileCheck %s
+
+// CHECK: define internal zeroext i1 @"\01-[A0 p]"(
+// CHECK:   %[[ATOMIC_LOAD:.*]] = load atomic i8, i8* %{{.*}} seq_cst
+// CHECK:   %[[TOBOOL:.*]] = trunc i8 %[[ATOMIC_LOAD]] to i1
+// CHECK:   ret i1 %[[TOBOOL]]
+
+// CHECK: define internal void @"\01-[A0 setP:]"({{.*}} i1 zeroext {{.*}})
+// CHECK:   store atomic i8 %{{.*}}, i8* %{{.*}} seq_cst
+// CHECK:   ret void
+
+// CHECK: define internal zeroext i1 @"\01-[A1 p]"(
+// CHECK:   %[[ATOMIC_LOAD:.*]] = load atomic i8, i8* %{{.*}} unordered
+// CHECK:   %[[TOBOOL:.*]] = trunc i8 %load to i1
+// CHECK:   ret i1 %[[TOBOOL]]
+
+// CHECK: define internal void @"\01-[A1 setP:]"({{.*}} i1 zeroext %p)
+// CHECK:   store atomic i8 %{{.*}}, i8* %{{.*}} unordered
+// CHECK:   ret void
+
+@interface A0
+@property(nonatomic) _Atomic(_Bool) p;
+@end
+@implementation A0
+@end
+
+@interface A1 {
+  _Atomic(_Bool) p;
+}
+@property _Atomic(_Bool) p;
+@end
+@implementation A1
+@synthesize p;
+@end
Index: cfe/trunk/lib/CodeGen/CGObjC.cpp
===
--- cfe/trunk/lib/CodeGen/CGObjC.cpp
+++ cfe/trunk/lib/CodeGen/CGObjC.cpp
@@ -897,9 +897,8 @@
 
 // Currently, all atomic accesses have to be through integer
 // types, so there's no point in trying to pick a prettier type.
-llvm::Type *bitcastType =
-  llvm::Type::getIntNTy(getLLVMContext(),
-  

Re: [PATCH] D20407: [CodeGen][ObjC] zero-ext an i1 value to i8

2016-05-25 Thread Akira Hatanaka via cfe-commits
ahatanak updated this revision to Diff 58544.
ahatanak added a comment.

Thanks for the review. I've removed parameter ASTContext that was unused.


http://reviews.llvm.org/D20407

Files:
  include/clang/AST/Type.h
  lib/AST/Type.cpp
  lib/CodeGen/CGObjC.cpp
  lib/Sema/SemaObjCProperty.cpp
  test/CodeGenObjC/property-atomic-bool.m
  test/SemaObjC/property-atomic-bool.m

Index: test/SemaObjC/property-atomic-bool.m
===
--- /dev/null
+++ test/SemaObjC/property-atomic-bool.m
@@ -0,0 +1,61 @@
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.10 -ast-dump "%s" 2>&1 | FileCheck %s
+
+// CHECK: TypedefDecl {{.*}} referenced AtomicBool '_Atomic(_Bool)'
+// CHECK:  AtomicType {{.*}} '_Atomic(_Bool)'
+// CHECK:   BuiltinType {{.*}} '_Bool'
+// CHECK: ObjCInterfaceDecl {{.*}} A0
+// CHECK:  ObjCPropertyDecl {{.*}} p '_Atomic(_Bool)' {{.*}} nonatomic
+// CHECK:  ObjCMethodDecl {{.*}} implicit - p '_Bool'
+// CHECK:  ObjCMethodDecl {{.*}} implicit - setP: 'void'
+// CHECK:   ParmVarDecl {{.*}} p '_Bool'
+// CHECK: ObjCInterfaceDecl {{.*}} A1
+// CHECK:  ObjCPropertyDecl {{.*}} p 'AtomicBool':'_Atomic(_Bool)' {{.*}} nonatomic
+// CHECK:  ObjCMethodDecl {{.*}} implicit - p '_Bool'
+// CHECK:  ObjCMethodDecl {{.*}} implicit - setP: 'void'
+// CHECK:   ParmVarDecl {{.*}} p '_Bool'
+// CHECK: ObjCInterfaceDecl {{.*}} A2
+// CHECK:  ObjCIvarDecl {{.*}} p '_Atomic(_Bool)' protected
+// CHECK:  ObjCPropertyDecl {{.*}} p '_Atomic(_Bool)'
+// CHECK:  ObjCMethodDecl {{.*}} implicit - p '_Bool'
+// CHECK:  ObjCMethodDecl {{.*}} implicit - setP: 'void'
+// CHECK:   ParmVarDecl {{.*}} p '_Bool'
+// CHECK: ObjCInterfaceDecl {{.*}} A3
+// CHECK:  ObjCIvarDecl {{.*}} p 'AtomicBool':'_Atomic(_Bool)' protected
+// CHECK:  ObjCPropertyDecl {{.*}} p 'AtomicBool':'_Atomic(_Bool)'
+// CHECK:  ObjCMethodDecl {{.*}} implicit - p '_Bool'
+// CHECK:  ObjCMethodDecl {{.*}} implicit - setP: 'void'
+// CHECK:   ParmVarDecl {{.*}} p '_Bool'
+
+typedef _Atomic(_Bool) AtomicBool;
+
+@interface A0
+@property(nonatomic) _Atomic(_Bool) p;
+@end
+@implementation A0
+@end
+
+@interface A1
+@property(nonatomic) AtomicBool p;
+@end
+@implementation A1
+@end
+
+@interface A2 {
+  _Atomic(_Bool) p;
+}
+@property _Atomic(_Bool) p;
+@end
+
+@implementation A2
+@synthesize p;
+@end
+
+@interface A3 {
+  AtomicBool p;
+}
+@property AtomicBool p;
+@end
+
+@implementation A3
+@synthesize p;
+@end
Index: test/CodeGenObjC/property-atomic-bool.m
===
--- /dev/null
+++ test/CodeGenObjC/property-atomic-bool.m
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10 -emit-llvm -x objective-c %s -o - | FileCheck %s
+
+// CHECK: define internal zeroext i1 @"\01-[A0 p]"(
+// CHECK:   %[[ATOMIC_LOAD:.*]] = load atomic i8, i8* %{{.*}} seq_cst
+// CHECK:   %[[TOBOOL:.*]] = trunc i8 %[[ATOMIC_LOAD]] to i1
+// CHECK:   ret i1 %[[TOBOOL]]
+
+// CHECK: define internal void @"\01-[A0 setP:]"({{.*}} i1 zeroext {{.*}})
+// CHECK:   store atomic i8 %{{.*}}, i8* %{{.*}} seq_cst
+// CHECK:   ret void
+
+// CHECK: define internal zeroext i1 @"\01-[A1 p]"(
+// CHECK:   %[[ATOMIC_LOAD:.*]] = load atomic i8, i8* %{{.*}} unordered
+// CHECK:   %[[TOBOOL:.*]] = trunc i8 %load to i1
+// CHECK:   ret i1 %[[TOBOOL]]
+
+// CHECK: define internal void @"\01-[A1 setP:]"({{.*}} i1 zeroext %p)
+// CHECK:   store atomic i8 %{{.*}}, i8* %{{.*}} unordered
+// CHECK:   ret void
+
+@interface A0
+@property(nonatomic) _Atomic(_Bool) p;
+@end
+@implementation A0
+@end
+
+@interface A1 {
+  _Atomic(_Bool) p;
+}
+@property _Atomic(_Bool) p;
+@end
+@implementation A1
+@synthesize p;
+@end
Index: lib/Sema/SemaObjCProperty.cpp
===
--- lib/Sema/SemaObjCProperty.cpp
+++ lib/Sema/SemaObjCProperty.cpp
@@ -1493,24 +1493,26 @@
   if (!GetterMethod)
 return false;
   QualType GetterType = GetterMethod->getReturnType().getNonReferenceType();
-  QualType PropertyIvarType = property->getType().getNonReferenceType();
-  bool compat = Context.hasSameType(PropertyIvarType, GetterType);
+  QualType PropertyRValueType =
+  property->getType().getNonReferenceType().getAtomicUnqualifiedType();
+  bool compat = Context.hasSameType(PropertyRValueType, GetterType);
   if (!compat) {
 const ObjCObjectPointerType *propertyObjCPtr = nullptr;
 const ObjCObjectPointerType *getterObjCPtr = nullptr;
-if ((propertyObjCPtr = PropertyIvarType->getAs()) && 
+if ((propertyObjCPtr =
+ PropertyRValueType->getAs()) &&
 (getterObjCPtr = GetterType->getAs()))
   compat = Context.canAssignObjCInterfaces(getterObjCPtr, propertyObjCPtr);
-else if (CheckAssignmentConstraints(Loc, GetterType, PropertyIvarType) 
+else if (CheckAssignmentConstraints(Loc, GetterType, PropertyRValueType)
   != Compatible) {
   Diag(Loc, diag::error_property_accessor_type)
-<< 

Re: [PATCH] D20383: PCH + Module: make sure we write out macros associated with builtin identifiers

2016-05-25 Thread Manman Ren via cfe-commits
manmanren added a comment.

Doug and Richard,

Can you take a look at this when you have time?

Thanks,
Manman


http://reviews.llvm.org/D20383



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


Re: [PATCH] D20407: [CodeGen][ObjC] zero-ext an i1 value to i8

2016-05-25 Thread John McCall via cfe-commits
rjmccall added a comment.

One minor improvement to the API and LGTM.



Comment at: include/clang/AST/Type.h:1084
@@ +1083,3 @@
+  /// Remove all qualifiers including _Atomic.
+  QualType getAtomicUnqualifiedType(const ASTContext ) const;
+

This doesn't need an ASTContext.


http://reviews.llvm.org/D20407



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


Re: [PATCH] D20407: [CodeGen][ObjC] zero-ext an i1 value to i8

2016-05-25 Thread John McCall via cfe-commits
rjmccall added a comment.

In http://reviews.llvm.org/D20407#440050, @ahatanak wrote:

> In http://reviews.llvm.org/D20407#439951, @rjmccall wrote:
>
> > The C standard is poorly-written in this area, but I think it would be 
> > reasonable for CheckFunctionReturnType to just silently remove _Atomic.  
> > (You will not be able to just re-use your new method there; removing other 
> > qualifiers is not acceptable, I'm afraid.)
>
>
> Do you mean I should fix those cases in this patch too?


No, sorry, just pointing something out for your other patch.


http://reviews.llvm.org/D20407



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


Re: [PATCH] D19843: Use the name of the file on disk to issue a new diagnostic about non-portable #include and #import paths.

2016-05-25 Thread Eric Niebler via cfe-commits
eric_niebler added a comment.

> Please add some tests for the FixItHint replacement text. See test/FixIt for 
> examples of how to do this.


Thanks for the suggestion. After adding tests for this, I noticed badness with 
the path separators in the FixIt hint when running on Windows. I'm working on a 
fix.


http://reviews.llvm.org/D19843



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


Re: [PATCH] D20602: Add .rgba syntax extension to ext_vector_type types

2016-05-25 Thread Pirama Arumuga Nainar via cfe-commits
pirama updated this revision to Diff 58537.
pirama added a comment.

Renamed diagnostic to use ext_ prefix.


http://reviews.llvm.org/D20602

Files:
  include/clang/AST/Type.h
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/AST/Expr.cpp
  lib/Sema/SemaExprMember.cpp
  test/CodeGen/ext-vector.c
  test/Misc/warning-flags.c
  test/Sema/ext_vector_components.c
  test/SemaOpenCL/ext_vectors.cl

Index: test/SemaOpenCL/ext_vectors.cl
===
--- /dev/null
+++ test/SemaOpenCL/ext_vectors.cl
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL1.1
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL2.0
+
+typedef float float4 __attribute__((ext_vector_type(4)));
+
+void test_ext_vector_accessors(float4 V) {
+  V = V.wzyx;
+  V = V.abgr; // expected-warning {{vector component name 'a' is an OpenCL 2.2 extension}}
+  V = V.xyzr; // expected-warning {{vector component name 'r' is an OpenCL 2.2 extension}} \
+  // expected-error {{illegal vector component name 'r'}}
+}
Index: test/Sema/ext_vector_components.c
===
--- test/Sema/ext_vector_components.c
+++ test/Sema/ext_vector_components.c
@@ -39,6 +39,33 @@
 vec4.x = vec16.sF;
   
 vec4p->yz = vec4p->xy;
+
+vec2.a; // expected-error {{vector component access exceeds type 'float2'}}
+vec2.rgba; // expected-error {{vector component access exceeds type 'float2'}}
+vec4.rgba; // expected-warning {{expression result unused}}
+vec4.rgbz; // expected-error {{illegal vector component name 'z'}}
+vec4.rgbc; // expected-error {{illegal vector component name 'c'}}
+vec4.xyzr; // expected-error {{illegal vector component name 'r'}}
+vec4.s01b; // expected-error {{vector component access exceeds type 'float4'}}
+
+vec3 = vec4.rgb; // legal, shorten
+f = vec2.r; // legal, shorten
+f = vec4.rg.r; // legal, shorten
+vec4_2.rgba = vec4.xyzw; // legal, no intermingling
+
+vec4_2.rgbr = vec4.rgba; // expected-error {{vector is not assignable (contains duplicate components)}}
+vec4_2.rgbb = vec4.rgba; // expected-error {{vector is not assignable (contains duplicate components)}}
+vec4_2.rgga = vec4.rgba; // expected-error {{vector is not assignable (contains duplicate components)}}
+vec2.x = f;
+vec2.rr = vec2_2.rg; // expected-error {{vector is not assignable (contains duplicate components)}}
+vec2.gr = vec2_2.rg;
+vec2.gr.g = vec2_2.r;
+vec4 = (float4){ 1,2,3,4 };
+vec4.rg.b; // expected-error {{vector component access exceeds type 'float2'}}
+vec4.r = vec16.sf;
+vec4.g = vec16.sF;
+
+vec4p->gb = vec4p->rg;
 }
 
 float2 lo(float3 x) { return x.lo; }
Index: test/Misc/warning-flags.c
===
--- test/Misc/warning-flags.c
+++ test/Misc/warning-flags.c
@@ -18,7 +18,7 @@
 
 The list of warnings below should NEVER grow.  It should gradually shrink to 0.
 
-CHECK: Warnings without flags (84):
+CHECK: Warnings without flags (85):
 CHECK-NEXT:   ext_excess_initializers
 CHECK-NEXT:   ext_excess_initializers_in_char_array_initializer
 CHECK-NEXT:   ext_expected_semi_decl_list
@@ -83,6 +83,7 @@
 CHECK-NEXT:   warn_objc_property_copy_missing_on_block
 CHECK-NEXT:   warn_objc_protocol_qualifier_missing_id
 CHECK-NEXT:   warn_on_superclass_use
+CHECK-NEXT:   warn_opencl_ext_vector_type_rgba_selector
 CHECK-NEXT:   warn_partial_specs_not_deducible
 CHECK-NEXT:   warn_pp_convert_to_positive
 CHECK-NEXT:   warn_pp_expr_overflow
Index: test/CodeGen/ext-vector.c
===
--- test/CodeGen/ext-vector.c
+++ test/CodeGen/ext-vector.c
@@ -301,3 +301,40 @@
   char valC;
   char16 destVal = valC ? valA : valB;
 }
+
+typedef __attribute__(( ext_vector_type(16) )) float float16;
+
+float16 vec16, vec16_2;
+
+// CHECK: @test_rgba
+void test_rgba() {
+  // CHECK: fadd <4 x float>
+  vec4_2 = vec4.abgr + vec4;
+
+  // CHECK: shufflevector {{.*}} 
+  vec2 = vec4.rg;
+  // CHECK: shufflevector {{.*}} 
+  vec2_2 = vec4.ba;
+  // CHECK: extractelement {{.*}} 2
+  f = vec4.b;
+  // CHECK: shufflevector {{.*}} 
+  vec4_2 = vec4_2.;
+
+  // CHECK: insertelement {{.*}} 0
+  vec2.r = f;
+  // CHECK: shufflevector {{.*}} 
+  vec2.gr = vec2;
+
+  // CHECK: extractelement {{.*}} 0
+  f = vec4_2.rg.r;
+  // CHECK: shufflevector {{.*}} 
+  // CHECK: shufflevector {{.*}} 
+  // CHECK: shufflevector {{.*}} 
+  vec4.rgb = vec4.bgr;
+
+  // CHECK: extractelement {{.*}} 11
+  // CHECK: insertelement {{.*}} 2
+  vec4.b = vec16.sb;
+  // CHECK: shufflevector {{.*}} 
+  vec4_2 = vec16.sabcd;
+}
Index: lib/Sema/SemaExprMember.cpp
===
--- lib/Sema/SemaExprMember.cpp
+++ lib/Sema/SemaExprMember.cpp
@@ -268,6 +268,20 @@
   llvm_unreachable("unexpected instance member access kind");
 

Re: [PATCH] D20602: Add .rgba syntax extension to ext_vector_type types

2016-05-25 Thread Pirama Arumuga Nainar via cfe-commits
pirama updated this revision to Diff 58535.
pirama added a comment.

Switched to ExtWarn, updated warning's message and made the version check 
strict w.r.t. 2.2.


http://reviews.llvm.org/D20602

Files:
  include/clang/AST/Type.h
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/AST/Expr.cpp
  lib/Sema/SemaExprMember.cpp
  test/CodeGen/ext-vector.c
  test/Misc/warning-flags.c
  test/Sema/ext_vector_components.c
  test/SemaOpenCL/ext_vectors.cl

Index: test/SemaOpenCL/ext_vectors.cl
===
--- /dev/null
+++ test/SemaOpenCL/ext_vectors.cl
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL1.1
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL2.0
+
+typedef float float4 __attribute__((ext_vector_type(4)));
+
+void test_ext_vector_accessors(float4 V) {
+  V = V.wzyx;
+  V = V.abgr; // expected-warning {{vector component name 'a' is an OpenCL 2.2 extension}}
+  V = V.xyzr; // expected-warning {{vector component name 'r' is an OpenCL 2.2 extension}} \
+  // expected-error {{illegal vector component name 'r'}}
+}
Index: test/Sema/ext_vector_components.c
===
--- test/Sema/ext_vector_components.c
+++ test/Sema/ext_vector_components.c
@@ -39,6 +39,33 @@
 vec4.x = vec16.sF;
   
 vec4p->yz = vec4p->xy;
+
+vec2.a; // expected-error {{vector component access exceeds type 'float2'}}
+vec2.rgba; // expected-error {{vector component access exceeds type 'float2'}}
+vec4.rgba; // expected-warning {{expression result unused}}
+vec4.rgbz; // expected-error {{illegal vector component name 'z'}}
+vec4.rgbc; // expected-error {{illegal vector component name 'c'}}
+vec4.xyzr; // expected-error {{illegal vector component name 'r'}}
+vec4.s01b; // expected-error {{vector component access exceeds type 'float4'}}
+
+vec3 = vec4.rgb; // legal, shorten
+f = vec2.r; // legal, shorten
+f = vec4.rg.r; // legal, shorten
+vec4_2.rgba = vec4.xyzw; // legal, no intermingling
+
+vec4_2.rgbr = vec4.rgba; // expected-error {{vector is not assignable (contains duplicate components)}}
+vec4_2.rgbb = vec4.rgba; // expected-error {{vector is not assignable (contains duplicate components)}}
+vec4_2.rgga = vec4.rgba; // expected-error {{vector is not assignable (contains duplicate components)}}
+vec2.x = f;
+vec2.rr = vec2_2.rg; // expected-error {{vector is not assignable (contains duplicate components)}}
+vec2.gr = vec2_2.rg;
+vec2.gr.g = vec2_2.r;
+vec4 = (float4){ 1,2,3,4 };
+vec4.rg.b; // expected-error {{vector component access exceeds type 'float2'}}
+vec4.r = vec16.sf;
+vec4.g = vec16.sF;
+
+vec4p->gb = vec4p->rg;
 }
 
 float2 lo(float3 x) { return x.lo; }
Index: test/Misc/warning-flags.c
===
--- test/Misc/warning-flags.c
+++ test/Misc/warning-flags.c
@@ -18,7 +18,7 @@
 
 The list of warnings below should NEVER grow.  It should gradually shrink to 0.
 
-CHECK: Warnings without flags (84):
+CHECK: Warnings without flags (85):
 CHECK-NEXT:   ext_excess_initializers
 CHECK-NEXT:   ext_excess_initializers_in_char_array_initializer
 CHECK-NEXT:   ext_expected_semi_decl_list
@@ -83,6 +83,7 @@
 CHECK-NEXT:   warn_objc_property_copy_missing_on_block
 CHECK-NEXT:   warn_objc_protocol_qualifier_missing_id
 CHECK-NEXT:   warn_on_superclass_use
+CHECK-NEXT:   warn_opencl_ext_vector_type_rgba_selector
 CHECK-NEXT:   warn_partial_specs_not_deducible
 CHECK-NEXT:   warn_pp_convert_to_positive
 CHECK-NEXT:   warn_pp_expr_overflow
Index: test/CodeGen/ext-vector.c
===
--- test/CodeGen/ext-vector.c
+++ test/CodeGen/ext-vector.c
@@ -301,3 +301,40 @@
   char valC;
   char16 destVal = valC ? valA : valB;
 }
+
+typedef __attribute__(( ext_vector_type(16) )) float float16;
+
+float16 vec16, vec16_2;
+
+// CHECK: @test_rgba
+void test_rgba() {
+  // CHECK: fadd <4 x float>
+  vec4_2 = vec4.abgr + vec4;
+
+  // CHECK: shufflevector {{.*}} 
+  vec2 = vec4.rg;
+  // CHECK: shufflevector {{.*}} 
+  vec2_2 = vec4.ba;
+  // CHECK: extractelement {{.*}} 2
+  f = vec4.b;
+  // CHECK: shufflevector {{.*}} 
+  vec4_2 = vec4_2.;
+
+  // CHECK: insertelement {{.*}} 0
+  vec2.r = f;
+  // CHECK: shufflevector {{.*}} 
+  vec2.gr = vec2;
+
+  // CHECK: extractelement {{.*}} 0
+  f = vec4_2.rg.r;
+  // CHECK: shufflevector {{.*}} 
+  // CHECK: shufflevector {{.*}} 
+  // CHECK: shufflevector {{.*}} 
+  vec4.rgb = vec4.bgr;
+
+  // CHECK: extractelement {{.*}} 11
+  // CHECK: insertelement {{.*}} 2
+  vec4.b = vec16.sb;
+  // CHECK: shufflevector {{.*}} 
+  vec4_2 = vec16.sabcd;
+}
Index: lib/Sema/SemaExprMember.cpp
===
--- lib/Sema/SemaExprMember.cpp
+++ lib/Sema/SemaExprMember.cpp
@@ -268,6 +268,20 @@
   

[PATCH] D20650: [OpenMP] Codegen for target update directive.

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

This patch implements the code generation for the `target update` directive. 
The implemntation relies on the logic already in place for target data 
standalone directives, i.e. target enter/exit data.

http://reviews.llvm.org/D20650

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

Index: test/OpenMP/target_update_codegen.cpp
===
--- /dev/null
+++ test/OpenMP/target_update_codegen.cpp
@@ -0,0 +1,245 @@
+// expected-no-diagnostics
+#ifndef HEADER
+#define HEADER
+
+///==///
+// RUN: %clang_cc1 -DCK1 -verify -fopenmp -fomptargets=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 -fomptargets=powerpc64le-ibm-linux-gnu -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fomptargets=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 -fomptargets=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 -fomptargets=i386-pc-linux-gnu -x c++ -std=c++11 -triple i386-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fomptargets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s  --check-prefix 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 2]
+
+// 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_update(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 update if(1+3-5) device(arg) from(gc)
+  {++arg;}
+
+  // Region 01
+  // CK1: %{{.+}} = add nsw i32 %{{[^,]+}}, 1
+  #pragma omp target update 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_update(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 update to(arg) if(arg) device(4)
+  {++arg;}
+
+  // CK1: %{{.+}} = add nsw i32 %{{[^,]+}}, 1
+  {++arg;}
+
+  // Region 03
+  // CK1-DAG: call void @__tgt_target_data_update(i32 -1, i32 1, i8** [[GEPBP:%.+]], i8** [[GEPP:%.+]], i[[sz]]* [[GEPS:%.+]], 

Re: [PATCH] D20632: clang-format: [JS] Support shebang lines on the very first line.

2016-05-25 Thread Martin Probst via cfe-commits
mprobst updated this revision to Diff 58529.
mprobst added a comment.

- use #include style shebang parsing.


http://reviews.llvm.org/D20632

Files:
  lib/Format/FormatTokenLexer.cpp
  lib/Format/TokenAnnotator.cpp
  unittests/Format/FormatTestJS.cpp

Index: unittests/Format/FormatTestJS.cpp
===
--- unittests/Format/FormatTestJS.cpp
+++ unittests/Format/FormatTestJS.cpp
@@ -1272,5 +1272,12 @@
   verifyFormat("var x = 'foo';", LeaveQuotes);
 }
 
+TEST_F(FormatTestJS, SupportShebangLines) {
+  verifyFormat("#!/usr/bin/env node\n"
+   "var x = hello();",
+   "#!/usr/bin/env node\n"
+   "var x   =  hello();");
+}
+
 } // end namespace tooling
 } // end namespace clang
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -694,6 +694,19 @@
 next();
 if (!CurrentToken)
   return Type;
+
+if (Style.Language == FormatStyle::LK_JavaScript) {
+  // JavaScript files can contain shebang lines of the form:
+  // #!/usr/bin/env node
+  // Treat these like C++ #include directives.
+  while (CurrentToken) {
+// Tokens cannot be comments here.
+CurrentToken->Type = TT_ImplicitStringLiteral;
+next();
+  }
+  return LT_ImportStatement;
+}
+
 if (CurrentToken->Tok.is(tok::numeric_constant)) {
   CurrentToken->SpacesRequiredBefore = 1;
   return Type;
Index: lib/Format/FormatTokenLexer.cpp
===
--- lib/Format/FormatTokenLexer.cpp
+++ lib/Format/FormatTokenLexer.cpp
@@ -20,6 +20,10 @@
 #include "clang/Format/Format.h"
 #include "llvm/Support/Regex.h"
 
+#include "llvm/Support/Debug.h"
+
+#define DEBUG_TYPE "format-formatter"
+
 namespace clang {
 namespace format {
 
@@ -52,6 +56,7 @@
   tryParseTemplateString();
 }
 tryMergePreviousTokens();
+
 if (Tokens.back()->NewlinesBefore > 0 || Tokens.back()->IsMultiline)
   FirstInLineIndex = Tokens.size() - 1;
   } while (Tokens.back()->Tok.isNot(tok::eof));


Index: unittests/Format/FormatTestJS.cpp
===
--- unittests/Format/FormatTestJS.cpp
+++ unittests/Format/FormatTestJS.cpp
@@ -1272,5 +1272,12 @@
   verifyFormat("var x = 'foo';", LeaveQuotes);
 }
 
+TEST_F(FormatTestJS, SupportShebangLines) {
+  verifyFormat("#!/usr/bin/env node\n"
+   "var x = hello();",
+   "#!/usr/bin/env node\n"
+   "var x   =  hello();");
+}
+
 } // end namespace tooling
 } // end namespace clang
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -694,6 +694,19 @@
 next();
 if (!CurrentToken)
   return Type;
+
+if (Style.Language == FormatStyle::LK_JavaScript) {
+  // JavaScript files can contain shebang lines of the form:
+  // #!/usr/bin/env node
+  // Treat these like C++ #include directives.
+  while (CurrentToken) {
+// Tokens cannot be comments here.
+CurrentToken->Type = TT_ImplicitStringLiteral;
+next();
+  }
+  return LT_ImportStatement;
+}
+
 if (CurrentToken->Tok.is(tok::numeric_constant)) {
   CurrentToken->SpacesRequiredBefore = 1;
   return Type;
Index: lib/Format/FormatTokenLexer.cpp
===
--- lib/Format/FormatTokenLexer.cpp
+++ lib/Format/FormatTokenLexer.cpp
@@ -20,6 +20,10 @@
 #include "clang/Format/Format.h"
 #include "llvm/Support/Regex.h"
 
+#include "llvm/Support/Debug.h"
+
+#define DEBUG_TYPE "format-formatter"
+
 namespace clang {
 namespace format {
 
@@ -52,6 +56,7 @@
   tryParseTemplateString();
 }
 tryMergePreviousTokens();
+
 if (Tokens.back()->NewlinesBefore > 0 || Tokens.back()->IsMultiline)
   FirstInLineIndex = Tokens.size() - 1;
   } while (Tokens.back()->Tok.isNot(tok::eof));
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r270784 - [Sema] Use the failure bits introduced by r270781.

2016-05-25 Thread George Burgess IV via cfe-commits
Author: gbiv
Date: Wed May 25 17:38:36 2016
New Revision: 270784

URL: http://llvm.org/viewvc/llvm-project?rev=270784=rev
Log:
[Sema] Use the failure bits introduced by r270781.

r270781 introduced the ability to track whether or not we might have
had unmodeled side-effects during constant expression evaluation. This
patch makes the constexpr evaluator use that tracking.

Reviewed as a part of D18540.

Modified:
cfe/trunk/lib/AST/ExprConstant.cpp

Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=270784=270783=270784=diff
==
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Wed May 25 17:38:36 2016
@@ -3307,7 +3307,7 @@ static const ValueDecl *HandleMemberPoin
   assert(BO->getOpcode() == BO_PtrMemD || BO->getOpcode() == BO_PtrMemI);
 
   if (!EvaluateObjectArgument(Info, BO->getLHS(), LV)) {
-if (Info.keepEvaluatingAfterFailure()) {
+if (Info.noteFailure()) {
   MemberPtr MemPtr;
   EvaluateMemberPointer(BO->getRHS(), MemPtr, Info);
 }
@@ -3603,7 +3603,7 @@ static EvalStmtResult EvaluateStmt(StmtR
   // FIXME: This isn't quite right; if we're performing aggregate
   // initialization, each braced subexpression is its own full-expression.
   FullExpressionRAII Scope(Info);
-  if (!EvaluateDecl(Info, DclIt) && !Info.keepEvaluatingAfterFailure())
+  if (!EvaluateDecl(Info, DclIt) && !Info.noteFailure())
 return ESR_Failed;
 }
 return ESR_Succeeded;
@@ -3878,7 +3878,7 @@ static bool EvaluateArgs(ArrayRefVisit(CAO->getLHS())) {
-if (Info.keepEvaluatingAfterFailure())
+if (Info.noteFailure())
   Evaluate(RHS, this->Info, CAO->getRHS());
 return false;
   }
@@ -4938,7 +4938,7 @@ bool LValueExprEvaluator::VisitBinAssign
   APValue NewVal;
 
   if (!this->Visit(E->getLHS())) {
-if (Info.keepEvaluatingAfterFailure())
+if (Info.noteFailure())
   Evaluate(NewVal, this->Info, E->getRHS());
 return false;
   }
@@ -5026,7 +5026,7 @@ bool PointerExprEvaluator::VisitBinaryOp
 std::swap(PExp, IExp);
 
   bool EvalPtrOK = EvaluatePointer(PExp, Result, Info);
-  if (!EvalPtrOK && !Info.keepEvaluatingAfterFailure())
+  if (!EvalPtrOK && !Info.noteFailure())
 return false;
 
   llvm::APSInt Offset;
@@ -5536,7 +5536,7 @@ bool RecordExprEvaluator::VisitInitListE
 
   APValue  = Result.getStructBase(ElementNo);
   if (!EvaluateInPlace(FieldVal, Info, Subobject, Init)) {
-if (!Info.keepEvaluatingAfterFailure())
+if (!Info.noteFailure())
   return false;
 Success = false;
   }
@@ -5574,7 +5574,7 @@ bool RecordExprEvaluator::VisitInitListE
 if (!EvaluateInPlace(FieldVal, Info, Subobject, Init) ||
 (Field->isBitField() && !truncateBitfieldValue(Info, Init,
FieldVal, Field))) {
-  if (!Info.keepEvaluatingAfterFailure())
+  if (!Info.noteFailure())
 return false;
   Success = false;
 }
@@ -6027,7 +6027,7 @@ bool ArrayExprEvaluator::VisitInitListEx
  Info, Subobject, Init) ||
 !HandleLValueArrayAdjustment(Info, Init, Subobject,
  CAT->getElementType(), 1)) {
-  if (!Info.keepEvaluatingAfterFailure())
+  if (!Info.noteFailure())
 return false;
   Success = false;
 }
@@ -7210,7 +7210,7 @@ bool DataRecursiveIntBinOpEvaluator::
   assert(E->getLHS()->getType()->isIntegralOrEnumerationType() &&
  E->getRHS()->getType()->isIntegralOrEnumerationType());
 
-  if (LHSResult.Failed && !Info.keepEvaluatingAfterFailure())
+  if (LHSResult.Failed && !Info.noteFailure())
 return false; // Ignore RHS;
 
   return true;
@@ -7412,7 +7412,7 @@ bool IntExprEvaluator::VisitBinaryOperat
 } else {
   LHSOK = EvaluateComplex(E->getLHS(), LHS, Info);
 }
-if (!LHSOK && !Info.keepEvaluatingAfterFailure())
+if (!LHSOK && !Info.noteFailure())
   return false;
 
 if (E->getRHS()->getType()->isRealFloatingType()) {
@@ -7460,7 +7460,7 @@ bool IntExprEvaluator::VisitBinaryOperat
 APFloat RHS(0.0), LHS(0.0);
 
 bool LHSOK = EvaluateFloat(E->getRHS(), RHS, Info);
-if (!LHSOK && !Info.keepEvaluatingAfterFailure())
+if (!LHSOK && !Info.noteFailure())
   return false;
 
 if (!EvaluateFloat(E->getLHS(), LHS, Info) || !LHSOK)
@@ -7494,7 +7494,7 @@ bool IntExprEvaluator::VisitBinaryOperat
   LValue LHSValue, RHSValue;
 
   bool LHSOK = EvaluatePointer(E->getLHS(), LHSValue, Info);
-  if (!LHSOK && !Info.keepEvaluatingAfterFailure())
+  if (!LHSOK && !Info.noteFailure())
 return false;
 
   if (!EvaluatePointer(E->getRHS(), RHSValue, Info) || !LHSOK)
@@ -7711,7 +7711,7 @@ bool IntExprEvaluator::VisitBinaryOperat
 MemberPtr LHSValue, RHSValue;
 
 bool LHSOK = 

[PATCH] D20647: Add flag to add InlineHint attribute on implicitly inline functions

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

Add two flags (-finline-implicit-hint and -fno-inline-implicit-hint) to allow 
to add InlineHint on implicitly inline functions (constexpr and member 
functions of class that was defined in the class body).
This is needed to add support for /Ob1 flag on clang-cl, which inlines only 
hinted functions, but considers implicitly inline functions as hinted (as per 
C++ standard).

http://reviews.llvm.org/D20647

Files:
  include/clang/Driver/Options.td
  include/clang/Frontend/CodeGenOptions.def
  lib/CodeGen/CodeGenFunction.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGenCXX/inline-hint.cpp

Index: test/CodeGenCXX/inline-hint.cpp
===
--- test/CodeGenCXX/inline-hint.cpp
+++ test/CodeGenCXX/inline-hint.cpp
@@ -0,0 +1,63 @@
+// RUN: %clang_cc1 %s -std=c++11 -triple=x86_64-linux -fno-inline-implicit-hint -emit-llvm -o - | FileCheck %s --check-prefix=CHECK --check-prefix=EXPLICIT
+// RUN: %clang_cc1 %s -std=c++11 -triple=x86_64-linux -finline-implicit-hint -emit-llvm -o - | FileCheck %s --check-prefix=CHECK --check-prefix=IMPLICIT
+// RUN: %clang_cc1 %s -std=c++11 -triple=x86_64-linux -finline-implicit-hint -fno-inline -emit-llvm -o - | FileCheck %s --check-prefix=CHECK --check-prefix=NOINLINE
+
+// Force non-trivial implicit constructors/destructors/operators for B by having explicit ones for A
+struct A {
+  A() {}
+  A(const A&) {}
+  A& operator=(const A&) { return *this; }
+  ~A() {}
+};
+
+struct B {
+  A member;
+  int implicitFunction(int a) { return a + a; }
+  inline int explicitFunction(int a);
+  int noHintFunction(int a);
+  __attribute__((optnone)) int optNoneFunction(int a) { return a + a; }
+};
+
+int B::explicitFunction(int a) { return a + a; }
+// CHECK: @_ZN1B14noHintFunctionEi({{.*}}) [[NOHINT_ATTR:#[0-9]+]]
+int B::noHintFunction(int a) { return a + a; }
+
+constexpr int constexprFunction(int a) { return a + a; }
+
+void foo()
+{
+// CHECK: @_ZN1BC1Ev({{.*}}) unnamed_addr [[IMPLICIT_CONSTR_ATTR:#[0-9]+]]
+  B b1;
+// CHECK: @_ZN1BC1ERKS_({{.*}}) unnamed_addr [[IMPLICIT_CONSTR_ATTR]]
+  B b2(b1);
+// CHECK: @_ZN1BaSERKS_({{.*}}) [[IMPLICIT_CONSTR_ATTR]]
+  b2 = b1;
+// CHECK: @_ZN1B16implicitFunctionEi({{.*}}) [[IMPLICIT_ATTR:#[0-9]+]]
+  b2.implicitFunction(1);
+// CHECK: @_ZN1B16explicitFunctionEi({{.*}}) [[EXPLICIT_ATTR:#[0-9]+]]
+  b2.explicitFunction(2);
+  b2.noHintFunction(3);
+// CHECK: @_ZN1B15optNoneFunctionEi({{.*}}) [[OPTNONE_ATTR:#[0-9]+]]
+  b2.optNoneFunction(4);
+// CHECK: @_Z17constexprFunctioni({{.*}}) [[IMPLICIT_ATTR]]
+  constexprFunction(5);
+// CHECK: @_ZN1BD2Ev({{.*}}) unnamed_addr [[IMPLICIT_CONSTR_ATTR]]
+}
+
+// EXPLICIT-NOT: attributes [[NOHINT_ATTR]] = { {{.*}}inlinehint{{.*}} }
+// IMPLICIT-NOT: attributes [[NOHINT_ATTR]] = { {{.*}}inlinehint{{.*}} }
+// NOINLINE-DAG: attributes [[NOHINT_ATTR]] = { noinline{{.*}} }
+
+// EXPLICIT-NOT: attributes [[IMPLICIT_ATTR]] = { {{.*}}inlinehint{{.*}} }
+// IMPLICIT-DAG: attributes [[IMPLICIT_ATTR]] = { inlinehint{{.*}} }
+// NOINLINE-DAG: attributes [[IMPLICIT_ATTR]] = { noinline{{.*}} }
+
+// EXPLICIT-DAG: attributes [[IMPLICIT_CONSTR_ATTR]] = { inlinehint{{.*}} }
+// IMPLICIT-DAG: attributes [[IMPLICIT_CONSTR_ATTR]] = { inlinehint{{.*}} }
+// NOINLINE-DAG: attributes [[IMPLICIT_CONSTR_ATTR]] = { noinline{{.*}} }
+
+// EXPLICIT-DAG: attributes [[EXPLICIT_ATTR]] = { inlinehint{{.*}} }
+// IMPLICIT-DAG: attributes [[EXPLICIT_ATTR]] = { inlinehint{{.*}} }
+// NOINLINE-DAG: attributes [[EXPLICIT_ATTR]] = { noinline{{.*}} }
+
+// CHECK-DAG: attributes [[OPTNONE_ATTR]] = { noinline{{.*}} }
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -447,6 +447,8 @@
   InlineArg->getOption().matches(options::OPT_finline_functions) ?
 CodeGenOptions::NormalInlining : CodeGenOptions::OnlyAlwaysInlining);
   }
+  Opts.ImplicitInlineHint = Args.hasFlag(OPT_finline_implicit_hint,
+ OPT_fno_inline_implicit_hint, false);
 
   if (Arg *A = Args.getLastArg(OPT_fveclib)) {
 StringRef Name = A->getValue();
Index: lib/CodeGen/CodeGenFunction.cpp
===
--- lib/CodeGen/CodeGenFunction.cpp
+++ lib/CodeGen/CodeGenFunction.cpp
@@ -699,12 +699,14 @@
 Fn->addFnAttr(llvm::Attribute::SafeStack);
 
   // Pass inline keyword to optimizer if it appears explicitly on any
-  // declaration. Also, in the case of -fno-inline attach NoInline
-  // attribute to all function that are not marked AlwaysInline.
+  // declaration, or implicitly in the case of -finline-implicit-hint.
+  // Also, in the case of -fno-inline attach NoInline attribute to all
+  // function that are not marked AlwaysInline.
   if (const FunctionDecl *FD = dyn_cast_or_null(D)) {
 if 

r270781 - [Sema] Note when we encounter a problem in ExprConstant.

2016-05-25 Thread George Burgess IV via cfe-commits
Author: gbiv
Date: Wed May 25 17:31:54 2016
New Revision: 270781

URL: http://llvm.org/viewvc/llvm-project?rev=270781=rev
Log:
[Sema] Note when we encounter a problem in ExprConstant.

Currently, the constexpr evaluator is very conservative about unmodeled
side-effects when we're evaluating an expression in a mode that allows
such side-effects.

This patch makes us note when we might have actually encountered an
unmodeled side-effect, which allows us to be more accurate when we know
an unmodeled side-effect couldn't have occurred.

This patch has been split into two commits; this one primarily
introduces the bits necessary to track whether we might have potentially
hit such a side-effect. The one that actually does the tracking (which
boils down to more or less a rename of keepEvaluatingAfterFailure to
noteFailure) is coming soon.

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

Added:
cfe/trunk/test/SemaCXX/builtin-object-size-cxx14.cpp
Modified:
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/test/SemaCXX/constant-expression-cxx1y.cpp

Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=270781=270780=270781=diff
==
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Wed May 25 17:31:54 2016
@@ -478,6 +478,9 @@ namespace {
 /// fold (not just why it's not strictly a constant expression)?
 bool HasFoldFailureDiagnostic;
 
+/// \brief Whether or not we're currently speculatively evaluating.
+bool IsSpeculativelyEvaluating;
+
 enum EvaluationMode {
   /// Evaluate as a constant expression. Stop if we find that the 
expression
   /// is not a constant expression.
@@ -542,7 +545,8 @@ namespace {
 BottomFrame(*this, SourceLocation(), nullptr, nullptr, nullptr),
 EvaluatingDecl((const ValueDecl *)nullptr),
 EvaluatingDeclValue(nullptr), HasActiveDiagnostic(false),
-HasFoldFailureDiagnostic(false), EvalMode(Mode) {}
+HasFoldFailureDiagnostic(false), IsSpeculativelyEvaluating(false),
+EvalMode(Mode) {}
 
 void setEvaluatingDecl(APValue::LValueBase Base, APValue ) {
   EvaluatingDecl = Base;
@@ -764,6 +768,29 @@ namespace {
   llvm_unreachable("Missed EvalMode case");
 }
 
+/// Notes that we failed to evaluate an expression that other expressions
+/// directly depend on, and determine if we should keep evaluating. This
+/// should only be called if we actually intend to keep evaluating.
+///
+/// Call noteSideEffect() instead if we may be able to ignore the value 
that
+/// we failed to evaluate, e.g. if we failed to evaluate Foo() in:
+///
+/// (Foo(), 1)  // use noteSideEffect
+/// (Foo() || true) // use noteSideEffect
+/// Foo() + 1   // use noteFailure
+LLVM_ATTRIBUTE_UNUSED_RESULT bool noteFailure() {
+  // Failure when evaluating some expression often means there is some
+  // subexpression whose evaluation was skipped. Therefore, (because we
+  // don't track whether we skipped an expression when unwinding after an
+  // evaluation failure) every evaluation failure that bubbles up from a
+  // subexpression implies that a side-effect has potentially happened. We
+  // skip setting the HasSideEffects flag to true until we decide to
+  // continue evaluating after that point, which happens here.
+  bool KeepGoing = keepEvaluatingAfterFailure();
+  EvalStatus.HasSideEffects |= KeepGoing;
+  return KeepGoing;
+}
+
 bool allowInvalidBaseExpr() const {
   return EvalMode == EM_DesignatorFold;
 }
@@ -812,24 +839,52 @@ namespace {
 ~FoldOffsetRAII() { Info.EvalMode = OldMode; }
   };
 
-  /// RAII object used to suppress diagnostics and side-effects from a
-  /// speculative evaluation.
+  /// RAII object used to optionally suppress diagnostics and side-effects from
+  /// a speculative evaluation.
   class SpeculativeEvaluationRAII {
-EvalInfo 
+/// Pair of EvalInfo, and a bit that stores whether or not we were
+/// speculatively evaluating when we created this RAII.
+llvm::PointerIntPair InfoAndOldSpecEval;
 Expr::EvalStatus Old;
 
+void moveFromAndCancel(SpeculativeEvaluationRAII &) {
+  InfoAndOldSpecEval = Other.InfoAndOldSpecEval;
+  Old = Other.Old;
+  Other.InfoAndOldSpecEval.setPointer(nullptr);
+}
+
+void maybeRestoreState() {
+  EvalInfo *Info = InfoAndOldSpecEval.getPointer();
+  if (!Info)
+return;
+
+  Info->EvalStatus = Old;
+  Info->IsSpeculativelyEvaluating = InfoAndOldSpecEval.getInt();
+}
+
   public:
-SpeculativeEvaluationRAII(EvalInfo ,
-SmallVectorImpl *NewDiag = 
nullptr)
-  : Info(Info), Old(Info.EvalStatus) {
+SpeculativeEvaluationRAII() = default;
+
+SpeculativeEvaluationRAII(
+   

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

2016-05-25 Thread George Burgess IV via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL270781: [Sema] Note when we encounter a problem in 
ExprConstant. (authored by gbiv).

Changed prior to commit:
  http://reviews.llvm.org/D18540?vs=52834=58526#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D18540

Files:
  cfe/trunk/lib/AST/ExprConstant.cpp
  cfe/trunk/test/SemaCXX/builtin-object-size-cxx14.cpp
  cfe/trunk/test/SemaCXX/constant-expression-cxx1y.cpp

Index: cfe/trunk/lib/AST/ExprConstant.cpp
===
--- cfe/trunk/lib/AST/ExprConstant.cpp
+++ cfe/trunk/lib/AST/ExprConstant.cpp
@@ -478,6 +478,9 @@
 /// fold (not just why it's not strictly a constant expression)?
 bool HasFoldFailureDiagnostic;
 
+/// \brief Whether or not we're currently speculatively evaluating.
+bool IsSpeculativelyEvaluating;
+
 enum EvaluationMode {
   /// Evaluate as a constant expression. Stop if we find that the expression
   /// is not a constant expression.
@@ -542,7 +545,8 @@
 BottomFrame(*this, SourceLocation(), nullptr, nullptr, nullptr),
 EvaluatingDecl((const ValueDecl *)nullptr),
 EvaluatingDeclValue(nullptr), HasActiveDiagnostic(false),
-HasFoldFailureDiagnostic(false), EvalMode(Mode) {}
+HasFoldFailureDiagnostic(false), IsSpeculativelyEvaluating(false),
+EvalMode(Mode) {}
 
 void setEvaluatingDecl(APValue::LValueBase Base, APValue ) {
   EvaluatingDecl = Base;
@@ -764,6 +768,29 @@
   llvm_unreachable("Missed EvalMode case");
 }
 
+/// Notes that we failed to evaluate an expression that other expressions
+/// directly depend on, and determine if we should keep evaluating. This
+/// should only be called if we actually intend to keep evaluating.
+///
+/// Call noteSideEffect() instead if we may be able to ignore the value that
+/// we failed to evaluate, e.g. if we failed to evaluate Foo() in:
+///
+/// (Foo(), 1)  // use noteSideEffect
+/// (Foo() || true) // use noteSideEffect
+/// Foo() + 1   // use noteFailure
+LLVM_ATTRIBUTE_UNUSED_RESULT bool noteFailure() {
+  // Failure when evaluating some expression often means there is some
+  // subexpression whose evaluation was skipped. Therefore, (because we
+  // don't track whether we skipped an expression when unwinding after an
+  // evaluation failure) every evaluation failure that bubbles up from a
+  // subexpression implies that a side-effect has potentially happened. We
+  // skip setting the HasSideEffects flag to true until we decide to
+  // continue evaluating after that point, which happens here.
+  bool KeepGoing = keepEvaluatingAfterFailure();
+  EvalStatus.HasSideEffects |= KeepGoing;
+  return KeepGoing;
+}
+
 bool allowInvalidBaseExpr() const {
   return EvalMode == EM_DesignatorFold;
 }
@@ -812,24 +839,52 @@
 ~FoldOffsetRAII() { Info.EvalMode = OldMode; }
   };
 
-  /// RAII object used to suppress diagnostics and side-effects from a
-  /// speculative evaluation.
+  /// RAII object used to optionally suppress diagnostics and side-effects from
+  /// a speculative evaluation.
   class SpeculativeEvaluationRAII {
-EvalInfo 
+/// Pair of EvalInfo, and a bit that stores whether or not we were
+/// speculatively evaluating when we created this RAII.
+llvm::PointerIntPair InfoAndOldSpecEval;
 Expr::EvalStatus Old;
 
+void moveFromAndCancel(SpeculativeEvaluationRAII &) {
+  InfoAndOldSpecEval = Other.InfoAndOldSpecEval;
+  Old = Other.Old;
+  Other.InfoAndOldSpecEval.setPointer(nullptr);
+}
+
+void maybeRestoreState() {
+  EvalInfo *Info = InfoAndOldSpecEval.getPointer();
+  if (!Info)
+return;
+
+  Info->EvalStatus = Old;
+  Info->IsSpeculativelyEvaluating = InfoAndOldSpecEval.getInt();
+}
+
   public:
-SpeculativeEvaluationRAII(EvalInfo ,
-SmallVectorImpl *NewDiag = nullptr)
-  : Info(Info), Old(Info.EvalStatus) {
+SpeculativeEvaluationRAII() = default;
+
+SpeculativeEvaluationRAII(
+EvalInfo , SmallVectorImpl *NewDiag = nullptr)
+: InfoAndOldSpecEval(, Info.IsSpeculativelyEvaluating),
+  Old(Info.EvalStatus) {
   Info.EvalStatus.Diag = NewDiag;
-  // If we're speculatively evaluating, we may have skipped over some
-  // evaluations and missed out a side effect.
-  Info.EvalStatus.HasSideEffects = true;
+  Info.IsSpeculativelyEvaluating = true;
 }
-~SpeculativeEvaluationRAII() {
-  Info.EvalStatus = Old;
+
+SpeculativeEvaluationRAII(const SpeculativeEvaluationRAII ) = delete;
+SpeculativeEvaluationRAII(SpeculativeEvaluationRAII &) {
+  moveFromAndCancel(std::move(Other));
 }
+
+SpeculativeEvaluationRAII =(SpeculativeEvaluationRAII &) {
+  maybeRestoreState();
+  moveFromAndCancel(std::move(Other));

Re: [PATCH] D20602: Add .rgba syntax extension to ext_vector_type types

2016-05-25 Thread Richard Smith via cfe-commits
rsmith added a comment.

Looks good other than the recent information about the version of OpenCL that 
actually specifies this.



Comment at: include/clang/Basic/DiagnosticSemaKinds.td:7899
@@ +7898,3 @@
+// OpenCL v2.2 s2.1.2.3 - Vector Component Access
+def warn_opencl_ext_vector_type_rgba_selector: Warning <
+  "vector component name '%0' is not part of OpenCL 2.0 and earlier">;

This should be an `ExtWarn`, not a `Warning`, and should be named `ext_...`. 
That way we'll reject it under `-cl-std=CL2.0 -pedantic-errors`.


Comment at: include/clang/Basic/DiagnosticSemaKinds.td:7900
@@ -7897,1 +7899,3 @@
+def warn_opencl_ext_vector_type_rgba_selector: Warning <
+  "vector component name '%0' is not part of OpenCL 2.0 and earlier">;
 } // end of sema category

I think the result of the discussion was that this is added in OpenCL 2.2. The 
way we phrase this in other diagnostics is:

  "vector component name '%0' is an OpenCL 2.2 extension"


Comment at: lib/Sema/SemaExprMember.cpp:334-336
@@ +333,5 @@
+
+// Emit a warning if an rgba selector is used in OpenCL 2.0 and below.
+if (HasRGBA || (*compStr && IsRGBA(*compStr))) {
+  if (S.getLangOpts().OpenCL && S.getLangOpts().OpenCLVersion <= 200) {
+const char *diagBegin = HasRGBA ? CompName->getNameStart() : compStr;

This should presumably be `OpenCLVersion < 220`.


http://reviews.llvm.org/D20602



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


Re: [PATCH] D20602: Add .rgba syntax extension to ext_vector_type types

2016-05-25 Thread Pirama Arumuga Nainar via cfe-commits
pirama added a comment.

> > > I'm not suggesting it be treated as invalid. This extension is part of at 
> > > least OpenCL 2.1, but it's not part of OpenCL 1.0. `ext_vector_type` is 
> > > Clang's implementation of the OpenCL vector type. Therefore if the user 
> > > asks us to support OpenCL 1.0, we should give them a warning if they use 
> > > this syntax.

> 

> > 

> 

> 

> 

> 

> - use of ext_vector_type in OpenCL 1.0 and earlier.


Looks like OpenCL 1.0 also has vector data types (Section 6.1.2 
https://www.khronos.org/registry/cl/specs/opencl-1.0.pdf).  So, I don't think 
it is necessary to emit warnings for ext_vector_types at all.


http://reviews.llvm.org/D20602



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


Re: [PATCH] D20602: Add .rgba syntax extension to ext_vector_type types

2016-05-25 Thread Pirama Arumuga Nainar via cfe-commits
pirama updated this revision to Diff 58525.
pirama added a comment.

Added warnings when rgba is used with OpenCL


http://reviews.llvm.org/D20602

Files:
  include/clang/AST/Type.h
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/AST/Expr.cpp
  lib/Sema/SemaExprMember.cpp
  test/CodeGen/ext-vector.c
  test/Misc/warning-flags.c
  test/Sema/ext_vector_components.c
  test/SemaOpenCL/ext_vectors.cl

Index: test/SemaOpenCL/ext_vectors.cl
===
--- /dev/null
+++ test/SemaOpenCL/ext_vectors.cl
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL1.1
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL2.0
+
+typedef float float4 __attribute__((ext_vector_type(4)));
+
+void test_ext_vector_accessors(float4 V) {
+  V = V.wzyx;
+  V = V.abgr; // expected-warning {{vector component name 'a' is not part of OpenCL 2.0 and earlier}}
+  V = V.xyzr; // expected-warning {{vector component name 'r' is not part of OpenCL 2.0 and earlier}} \
+  // expected-error {{illegal vector component name 'r'}}
+}
Index: test/Sema/ext_vector_components.c
===
--- test/Sema/ext_vector_components.c
+++ test/Sema/ext_vector_components.c
@@ -39,6 +39,33 @@
 vec4.x = vec16.sF;
   
 vec4p->yz = vec4p->xy;
+
+vec2.a; // expected-error {{vector component access exceeds type 'float2'}}
+vec2.rgba; // expected-error {{vector component access exceeds type 'float2'}}
+vec4.rgba; // expected-warning {{expression result unused}}
+vec4.rgbz; // expected-error {{illegal vector component name 'z'}}
+vec4.rgbc; // expected-error {{illegal vector component name 'c'}}
+vec4.xyzr; // expected-error {{illegal vector component name 'r'}}
+vec4.s01b; // expected-error {{vector component access exceeds type 'float4'}}
+
+vec3 = vec4.rgb; // legal, shorten
+f = vec2.r; // legal, shorten
+f = vec4.rg.r; // legal, shorten
+vec4_2.rgba = vec4.xyzw; // legal, no intermingling
+
+vec4_2.rgbr = vec4.rgba; // expected-error {{vector is not assignable (contains duplicate components)}}
+vec4_2.rgbb = vec4.rgba; // expected-error {{vector is not assignable (contains duplicate components)}}
+vec4_2.rgga = vec4.rgba; // expected-error {{vector is not assignable (contains duplicate components)}}
+vec2.x = f;
+vec2.rr = vec2_2.rg; // expected-error {{vector is not assignable (contains duplicate components)}}
+vec2.gr = vec2_2.rg;
+vec2.gr.g = vec2_2.r;
+vec4 = (float4){ 1,2,3,4 };
+vec4.rg.b; // expected-error {{vector component access exceeds type 'float2'}}
+vec4.r = vec16.sf;
+vec4.g = vec16.sF;
+
+vec4p->gb = vec4p->rg;
 }
 
 float2 lo(float3 x) { return x.lo; }
Index: test/Misc/warning-flags.c
===
--- test/Misc/warning-flags.c
+++ test/Misc/warning-flags.c
@@ -18,7 +18,7 @@
 
 The list of warnings below should NEVER grow.  It should gradually shrink to 0.
 
-CHECK: Warnings without flags (84):
+CHECK: Warnings without flags (85):
 CHECK-NEXT:   ext_excess_initializers
 CHECK-NEXT:   ext_excess_initializers_in_char_array_initializer
 CHECK-NEXT:   ext_expected_semi_decl_list
@@ -83,6 +83,7 @@
 CHECK-NEXT:   warn_objc_property_copy_missing_on_block
 CHECK-NEXT:   warn_objc_protocol_qualifier_missing_id
 CHECK-NEXT:   warn_on_superclass_use
+CHECK-NEXT:   warn_opencl_ext_vector_type_rgba_selector
 CHECK-NEXT:   warn_partial_specs_not_deducible
 CHECK-NEXT:   warn_pp_convert_to_positive
 CHECK-NEXT:   warn_pp_expr_overflow
Index: test/CodeGen/ext-vector.c
===
--- test/CodeGen/ext-vector.c
+++ test/CodeGen/ext-vector.c
@@ -301,3 +301,40 @@
   char valC;
   char16 destVal = valC ? valA : valB;
 }
+
+typedef __attribute__(( ext_vector_type(16) )) float float16;
+
+float16 vec16, vec16_2;
+
+// CHECK: @test_rgba
+void test_rgba() {
+  // CHECK: fadd <4 x float>
+  vec4_2 = vec4.abgr + vec4;
+
+  // CHECK: shufflevector {{.*}} 
+  vec2 = vec4.rg;
+  // CHECK: shufflevector {{.*}} 
+  vec2_2 = vec4.ba;
+  // CHECK: extractelement {{.*}} 2
+  f = vec4.b;
+  // CHECK: shufflevector {{.*}} 
+  vec4_2 = vec4_2.;
+
+  // CHECK: insertelement {{.*}} 0
+  vec2.r = f;
+  // CHECK: shufflevector {{.*}} 
+  vec2.gr = vec2;
+
+  // CHECK: extractelement {{.*}} 0
+  f = vec4_2.rg.r;
+  // CHECK: shufflevector {{.*}} 
+  // CHECK: shufflevector {{.*}} 
+  // CHECK: shufflevector {{.*}} 
+  vec4.rgb = vec4.bgr;
+
+  // CHECK: extractelement {{.*}} 11
+  // CHECK: insertelement {{.*}} 2
+  vec4.b = vec16.sb;
+  // CHECK: shufflevector {{.*}} 
+  vec4_2 = vec16.sabcd;
+}
Index: lib/Sema/SemaExprMember.cpp
===
--- lib/Sema/SemaExprMember.cpp
+++ lib/Sema/SemaExprMember.cpp
@@ -268,6 +268,20 @@
   llvm_unreachable("unexpected 

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

2016-05-25 Thread Richard Smith via cfe-commits
rsmith added a comment.

In http://reviews.llvm.org/D18035#437715, @rengolin wrote:

> The 3.8.1 deadline is tomorrow and I'd really like to see these two patches 
> (plus the related fixes) in it,


Realistically, this seems unlikely to make it in time.

> or some LTS Linux distributions will live without them, and thus with 
> completely broken copies of LLVM.


No, they'll be shipping with a broken copy of their C++ standard library, and 
will fail to conform to the Linux Standards Base specifications due to 
deviating from the Itanium C++ ABI. This patch is working around another 
popular implementation's failure to follow the relevant specification, nothing 
more. Please try to appropriately apportion the responsibility here; if your 
distribution opted into a non-standard ABI for their C++ standard library, you 
should point out to them that they made a mistake.


http://reviews.llvm.org/D18035



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


Re: [PATCH] D19708: [CGDebugInfo] Generate debug info for member calls in the context of the callee expression

2016-05-25 Thread Hal Finkel via cfe-commits
- Original Message -

> From: "David Blaikie" 
> To: "Hal Finkel" 
> Cc: "Richard Smith" , "Adrian Prantl"
> , "Duncan P. N. Exon Smith"
> , "Eric Christopher" ,
> "Jun Bum Lim" , "cfe-commits"
> ,
> reviews+d19708+public+e9ddc42503732...@reviews.llvm.org
> Sent: Thursday, May 12, 2016 2:54:26 PM
> Subject: Re: [PATCH] D19708: [CGDebugInfo] Generate debug info for
> member calls in the context of the callee expression

> On Mon, May 2, 2016 at 1:17 PM, Hal Finkel < hfin...@anl.gov > wrote:

> > - Original Message -
> 

> > > From: "David Blaikie" < dblai...@gmail.com >
> 
> > > To: reviews+d19708+public+e9ddc42503732...@reviews.llvm.org ,
> > > "Hal
> > > Finkel" < hfin...@anl.gov >
> 
> > > Cc: "Richard Smith" < rich...@metafoo.co.uk >, "Adrian Prantl" <
> > > apra...@apple.com >, "Duncan P. N. Exon Smith"
> 
> > > < dexonsm...@apple.com >, "Eric Christopher" < echri...@gmail.com
> > > >, "Jun Bum Lim" < junb...@codeaurora.org >,
> 
> > > "cfe-commits" < cfe-commits@lists.llvm.org >
> 
> > > Sent: Friday, April 29, 2016 4:52:26 PM
> 
> > > Subject: Re: [PATCH] D19708: [CGDebugInfo] Generate debug info
> > > for
> > > member calls in the context of the callee
> 
> > > expression
> 
> > >
> 
> > >
> 
> > > You could simplify the test case further, down to just:
> 
> > >
> 
> > > struct foo { void bar(); };
> 
> > > void f(foo *f) {
> 
> > > f->bar();
> 
> > > }
> 
> > >
> 
> > > and check that the call instruction has the desired column (or if
> > > you
> 
> > > want a test that doesn't depend on column info (you can force it
> > > on
> 
> > > with a flag, but we might vary whether it's on by default based
> > > on
> 
> > > target, etc, I'm not sure) you could put 'bar();' on a separate
> > > line
> 
> > > from 'f->' and check the call was on the second line and not the
> 
> > > first).
> 

> > Certainly. I'm not sure much we want to reduce the test case,
> > however, because I particularly want to cover the case of two calls
> > on the same line with column info.
> 
> Why is it helpful to cover two calls? That's certainly where the
> issue was observed, but it's not the bug/fix as such. Once we put
> the location at the start of the function name we incidentally
> improve the situation where there are two calls.
True. My underlying thought process here is: Do I think it is plausible that 
someone might break this in such a way that all of the calls on one line would 
end up pointing at the first call expression? This does not seem outside the 
realm of what is possible, as far as such bugs go, and so I'd like to 
explicitly cover this case. Given that the test is still relatively simple, it 
seems worthwhile. I certainly see your point, however. 

> > Given that this is still pretty simple, I think that covering it
> > directly seems reasonable.
> 

> I think it can make tests more confusing when it comes to tracking
> the actual behavior change/intent of the test, etc.

> > > Richard might be able to tell us whether there's a preferred
> > > place
> 
> > > for a test for a change like this - should it be a debug info
> > > test,
> 
> > > a diagnostic test,
> 

> > At least for the test you suggested in a previous e-mail, this
> > patch
> > has no effect on the output diagnostics (although it certainly does
> > have the desired effect on the debug info). Specifically, even with
> > this patch, we still have:
> 

> > $ cat /tmp/loc.cpp
> 
> > struct foo {
> 
> > const foo *x() const;
> 
> > void y();
> 
> > };
> 

> > void f(const foo *g) {
> 
> > g->x()->y();
> 
> > g->x()->x()->y();
> 
> > }
> 

> > $ clang /tmp/loc.cpp -fsyntax-only
> 
> > /tmp/loc.cpp:7:3: error: member function 'y' not viable: 'this'
> > argument has type 'const foo', but function is not marked const
> 
> > g->x()->y();
> 
> > ^~
> 
> > /tmp/loc.cpp:3:8: note: 'y' declared here
> 
> > void y();
> 
> > ^
> 
> > /tmp/loc.cpp:8:3: error: member function 'y' not viable: 'this'
> > argument has type 'const foo', but function is not marked const
> 
> > g->x()->x()->y();
> 
> > ^~~
> 
> > /tmp/loc.cpp:3:8: note: 'y' declared here
> 
> > void y();
> 
> > ^
> 
> > 2 errors generated.
> 

> Curious - perhaps we should fix the diagnostic too? I guess it's
> using the start location instead of the preferred location?

> Hmm, yeah, maybe that's not right anyway - it's specifically trying
> to describe the left operand, though that's different from any case
> where a normal operand is mismatched by constness. Then it just says
> it can't call the function & points to the function (with a note
> explaining)

> Anyway - seems OK. Please commit.

r270775, thanks! 

-Hal 

> - David

> > Thanks again,
> 
> > Hal
> 

> > > or perhaps just an ast dump test?
> 
> > >
> 
> > > Perhaps a test for the case where there is no valid callee would
> > > be
> 
> > > 

Re: [PATCH] D19708: [CGDebugInfo] Generate debug info for member calls in the context of the callee expression

2016-05-25 Thread Hal Finkel via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL270775: [CGDebugInfo] Modify the preferred expression 
location for member calls. (authored by hfinkel).

Changed prior to commit:
  http://reviews.llvm.org/D19708?vs=55610=58521#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D19708

Files:
  cfe/trunk/include/clang/AST/ExprCXX.h
  cfe/trunk/test/CodeGenCXX/debug-info-member-call.cpp

Index: cfe/trunk/include/clang/AST/ExprCXX.h
===
--- cfe/trunk/include/clang/AST/ExprCXX.h
+++ cfe/trunk/include/clang/AST/ExprCXX.h
@@ -143,6 +143,14 @@
   /// FIXME: Returns 0 for member pointer call exprs.
   CXXRecordDecl *getRecordDecl() const;
 
+  SourceLocation getExprLoc() const LLVM_READONLY {
+SourceLocation CLoc = getCallee()->getExprLoc();
+if (CLoc.isValid())
+  return CLoc;
+
+return getLocStart();
+  }
+
   static bool classof(const Stmt *T) {
 return T->getStmtClass() == CXXMemberCallExprClass;
   }
Index: cfe/trunk/test/CodeGenCXX/debug-info-member-call.cpp
===
--- cfe/trunk/test/CodeGenCXX/debug-info-member-call.cpp
+++ cfe/trunk/test/CodeGenCXX/debug-info-member-call.cpp
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -triple x86_64-unknown_unknown -emit-llvm 
-debug-info-kind=standalone -dwarf-column-info %s -o - | FileCheck %s
+void ext();
+
+struct Bar {
+  void bar() { ext(); }
+};
+
+struct Foo {
+  Bar *b;
+
+  Bar *foo() { return b; }
+};
+
+void test(Foo *f) {
+  f->foo()->bar();
+}
+
+// CHECK-LABEL: @_Z4testP3Foo
+// CHECK: call {{.*}} @_ZN3Foo3fooEv{{.*}}, !dbg ![[CALL1LOC:.*]]
+// CHECK: call void @_ZN3Bar3barEv{{.*}}, !dbg ![[CALL2LOC:.*]]
+
+// CHECK: ![[CALL1LOC]] = !DILocation(line: [[LINE:[0-9]+]], column: 6,
+// CHECK: ![[CALL2LOC]] = !DILocation(line: [[LINE]], column: 13,
+


Index: cfe/trunk/include/clang/AST/ExprCXX.h
===
--- cfe/trunk/include/clang/AST/ExprCXX.h
+++ cfe/trunk/include/clang/AST/ExprCXX.h
@@ -143,6 +143,14 @@
   /// FIXME: Returns 0 for member pointer call exprs.
   CXXRecordDecl *getRecordDecl() const;
 
+  SourceLocation getExprLoc() const LLVM_READONLY {
+SourceLocation CLoc = getCallee()->getExprLoc();
+if (CLoc.isValid())
+  return CLoc;
+
+return getLocStart();
+  }
+
   static bool classof(const Stmt *T) {
 return T->getStmtClass() == CXXMemberCallExprClass;
   }
Index: cfe/trunk/test/CodeGenCXX/debug-info-member-call.cpp
===
--- cfe/trunk/test/CodeGenCXX/debug-info-member-call.cpp
+++ cfe/trunk/test/CodeGenCXX/debug-info-member-call.cpp
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -triple x86_64-unknown_unknown -emit-llvm -debug-info-kind=standalone -dwarf-column-info %s -o - | FileCheck %s
+void ext();
+
+struct Bar {
+  void bar() { ext(); }
+};
+
+struct Foo {
+  Bar *b;
+
+  Bar *foo() { return b; }
+};
+
+void test(Foo *f) {
+  f->foo()->bar();
+}
+
+// CHECK-LABEL: @_Z4testP3Foo
+// CHECK: call {{.*}} @_ZN3Foo3fooEv{{.*}}, !dbg ![[CALL1LOC:.*]]
+// CHECK: call void @_ZN3Bar3barEv{{.*}}, !dbg ![[CALL2LOC:.*]]
+
+// CHECK: ![[CALL1LOC]] = !DILocation(line: [[LINE:[0-9]+]], column: 6,
+// CHECK: ![[CALL2LOC]] = !DILocation(line: [[LINE]], column: 13,
+
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r270775 - [CGDebugInfo] Modify the preferred expression location for member calls.

2016-05-25 Thread Hal Finkel via cfe-commits
Author: hfinkel
Date: Wed May 25 17:08:27 2016
New Revision: 270775

URL: http://llvm.org/viewvc/llvm-project?rev=270775=rev
Log:
[CGDebugInfo] Modify the preferred expression location for member calls.

If the callee has a valid location (not all do), then use that. Otherwise, fall
back to the starting location. This makes sure that the debug info for calls
points to the call (not the start of the expression providing the object on
which the member function is being called).

For example, given this:

  f->foo()->bar();

we don't want both calls to point to the 'f', but rather to the 'foo()' and
the 'bar()'.

Fixes PR27567.

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

Added:
cfe/trunk/test/CodeGenCXX/debug-info-member-call.cpp
Modified:
cfe/trunk/include/clang/AST/ExprCXX.h

Modified: cfe/trunk/include/clang/AST/ExprCXX.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ExprCXX.h?rev=270775=270774=270775=diff
==
--- cfe/trunk/include/clang/AST/ExprCXX.h (original)
+++ cfe/trunk/include/clang/AST/ExprCXX.h Wed May 25 17:08:27 2016
@@ -143,6 +143,14 @@ public:
   /// FIXME: Returns 0 for member pointer call exprs.
   CXXRecordDecl *getRecordDecl() const;
 
+  SourceLocation getExprLoc() const LLVM_READONLY {
+SourceLocation CLoc = getCallee()->getExprLoc();
+if (CLoc.isValid())
+  return CLoc;
+
+return getLocStart();
+  }
+
   static bool classof(const Stmt *T) {
 return T->getStmtClass() == CXXMemberCallExprClass;
   }

Added: cfe/trunk/test/CodeGenCXX/debug-info-member-call.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-member-call.cpp?rev=270775=auto
==
--- cfe/trunk/test/CodeGenCXX/debug-info-member-call.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/debug-info-member-call.cpp Wed May 25 17:08:27 
2016
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -triple x86_64-unknown_unknown -emit-llvm 
-debug-info-kind=standalone -dwarf-column-info %s -o - | FileCheck %s
+void ext();
+
+struct Bar {
+  void bar() { ext(); }
+};
+
+struct Foo {
+  Bar *b;
+
+  Bar *foo() { return b; }
+};
+
+void test(Foo *f) {
+  f->foo()->bar();
+}
+
+// CHECK-LABEL: @_Z4testP3Foo
+// CHECK: call {{.*}} @_ZN3Foo3fooEv{{.*}}, !dbg ![[CALL1LOC:.*]]
+// CHECK: call void @_ZN3Bar3barEv{{.*}}, !dbg ![[CALL2LOC:.*]]
+
+// CHECK: ![[CALL1LOC]] = !DILocation(line: [[LINE:[0-9]+]], column: 6,
+// CHECK: ![[CALL2LOC]] = !DILocation(line: [[LINE]], column: 13,
+


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


r270774 - Fix rejects-valid on constexpr function that accesses a not-yet-defined 'extern

2016-05-25 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Wed May 25 17:06:25 2016
New Revision: 270774

URL: http://llvm.org/viewvc/llvm-project?rev=270774=rev
Log:
Fix rejects-valid on constexpr function that accesses a not-yet-defined 'extern
const' variable. That variable might be defined as 'constexpr', so we cannot
prove that a use of it could never be a constant expression.

Modified:
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/test/SemaCXX/constant-expression-cxx11.cpp

Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=270774=270773=270774=diff
==
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Wed May 25 17:06:25 2016
@@ -2706,7 +2706,11 @@ static CompleteObject findCompleteObject
 }
   } else {
 // FIXME: Allow folding of values of any literal type in all languages.
-if (Info.getLangOpts().CPlusPlus11) {
+if (Info.checkingPotentialConstantExpression() &&
+VD->getType().isConstQualified() && !VD->hasDefinition(Info.Ctx)) {
+  // The definition of this variable could be constexpr. We can't
+  // access it right now, but may be able to in future.
+} else if (Info.getLangOpts().CPlusPlus11) {
   Info.Diag(E, diag::note_constexpr_ltor_non_constexpr, 1) << VD;
   Info.Note(VD->getLocation(), diag::note_declared_at);
 } else {
@@ -5456,8 +5460,9 @@ bool RecordExprEvaluator::VisitInitListE
   }
 
   auto *CXXRD = dyn_cast(RD);
-  Result = APValue(APValue::UninitStruct(), CXXRD ? CXXRD->getNumBases() : 0,
-   std::distance(RD->field_begin(), RD->field_end()));
+  if (Result.isUninit())
+Result = APValue(APValue::UninitStruct(), CXXRD ? CXXRD->getNumBases() : 0,
+ std::distance(RD->field_begin(), RD->field_end()));
   unsigned ElementNo = 0;
   bool Success = true;
 

Modified: cfe/trunk/test/SemaCXX/constant-expression-cxx11.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/constant-expression-cxx11.cpp?rev=270774=270773=270774=diff
==
--- cfe/trunk/test/SemaCXX/constant-expression-cxx11.cpp (original)
+++ cfe/trunk/test/SemaCXX/constant-expression-cxx11.cpp Wed May 25 17:06:25 
2016
@@ -1181,6 +1181,20 @@ namespace ExternConstexpr {
 constexpr int j = 0;
 constexpr int k; // expected-error {{default initialization of an object 
of const type}}
   }
+
+  extern const int q;
+  constexpr int g() { return q; }
+  constexpr int q = g();
+  static_assert(q == 0, "zero-initialization should precede static 
initialization");
+
+  extern int r; // expected-note {{here}}
+  constexpr int h() { return r; } // expected-error {{never produces a 
constant}} expected-note {{read of non-const}}
+
+  struct S { int n; };
+  extern const S s;
+  constexpr int x() { return s.n; }
+  constexpr S s = {x()};
+  static_assert(s.n == 0, "zero-initialization should precede static 
initialization");
 }
 
 namespace ComplexConstexpr {


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


Re: [PATCH] D20602: Add .rgba syntax extension to ext_vector_type types

2016-05-25 Thread Richard Smith via cfe-commits
On Wed, May 25, 2016 at 2:20 PM, Aleksey Bader 
wrote:

> On Wed, May 25, 2016 at 11:53 PM, Richard Smith 
> wrote:
>
>> On Wed, May 25, 2016 at 2:20 AM, Alexey Bader via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> bader added a subscriber: bader.
>>> bader added a comment.
>>>
>>> In http://reviews.llvm.org/D20602#438667, @rsmith wrote:
>>>
>>> > I'm not suggesting it be treated as invalid. This extension is part of
>>> at least OpenCL 2.1, but it's not part of OpenCL 1.0. `ext_vector_type` is
>>> Clang's implementation of the OpenCL vector type. Therefore if the user
>>> asks us to support OpenCL 1.0, we should give them a warning if they use
>>> this syntax.
>>> >
>>> > If we're not building an OpenCL source file, then yes, this is our
>>> extension and it makes sense for it to be available unconditionally
>>> (without a warning).
>>>
>>>
>>> To avoid confusion, I'd like to note that rgba selector was first
>>> introduced in OpenCL C++ kernel language, which is currently in provisional
>>> state and will be part of OpenCL version 2.2.
>>> https://www.khronos.org/registry/cl/specs/opencl-2.2-cplusplus.pdf
>>> (page 18).
>>>
>>
>> https://www.khronos.org/registry/cl/specs/opencl-2.1-openclc++.pdf page
>> 12-13 document it. Is that not OpenCL version 2.1?
>>
>>
>
> Not quite. OpenCL C++ kernel language was planned to be ratified with
> OpenCL 2.1 standard, but it did happen.
> It's still listed as provisional although OpenCL 2.1 specification was
> released last year. https://www.khronos.org/opencl/
> Ratified OpenCL 2.1 standard requires to support only OpenCL C 2.0 and
> SPIR-V 1.0 kernel languages.
> There is no much sense to support provisional specification that will
> never be ratified.
>

Thanks for the explanation.

It seems to me that the right way to handle this is the same way we'd
handle any feature that's part of an upcoming language standard:
 - add a flag to enable the OpenCL 2.2 language mode
 - if an OpenCL compilation uses this extension and doesn't specify that
version or newer, produce an `ExtWarn`

BTW, Khronos provided open source implementation of OpenCL C++ compiler and
> since OpenCL C++ is a new kernel language and specification (
> https://www.khronos.org/registry/cl/specs/opencl-2.2-cplusplus.pdf) is
> version 1.0, the numbering of standard versions is different from OpenCL C.
> Current std version is 'c++'.
> Here is usage example:
> https://github.com/KhronosGroup/SPIR/blob/spirv-1.1/test/OpenCL/OpenCL22/opencl_cplusplus.cl
>

That's a really weird way to specify a version number.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D19739: Add a loop's debug location to its llvm.loop metadata

2016-05-25 Thread Hal Finkel via cfe-commits
hfinkel closed this revision.
hfinkel added a comment.

r270772, thanks!


http://reviews.llvm.org/D19739



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


Re: [PATCH] D20630: [OpenCL] Allow -std=cl|CL1.1|CL1.2|CL2.0 in driver

2016-05-25 Thread Richard Smith via cfe-commits
rsmith added inline comments.


Comment at: lib/Frontend/CompilerInvocation.cpp:1587-1589
@@ -1579,3 +1586,4 @@
+.Case("cl", LangStandard::lang_opencl)
 .Case("CL1.1", LangStandard::lang_opencl11)
 .Case("CL1.2", LangStandard::lang_opencl12)
 .Case("CL2.0", LangStandard::lang_opencl20)

yaxunl wrote:
> rsmith wrote:
> > How about changing these to the lowercase form too, and treating the 
> > uppercase versions as (deprecated) synonyms? (And likewise changing 
> > LangStandards.def to list the lowercase versions, perhaps with the 
> > uppercase versions as aliases.)
> -cl-std=CL1.1|CL1.2|CL2.0 is defined by OpenCL spec. Allowing lower case may 
> cause some confusion.
> 
> -cl-std=cl is not part of OpenCL spec.
> 
> How about keeping all -cl-std= options big letters and all -std= options 
> small letters?
What? The OpenCL spec does not get to dictate our command-line argument syntax. 
If they think they do, they're just mistaken.


http://reviews.llvm.org/D20630



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


r270772 - Add a loop's debug location to its llvm.loop metadata

2016-05-25 Thread Hal Finkel via cfe-commits
Author: hfinkel
Date: Wed May 25 16:53:24 2016
New Revision: 270772

URL: http://llvm.org/viewvc/llvm-project?rev=270772=rev
Log:
Add a loop's debug location to its llvm.loop metadata

Getting accurate locations for loops is important, because those locations are
used by the frontend to generate optimization remarks. Currently, optimization
remarks for loops often appear on the wrong line, often the first line of the
loop body instead of the loop itself. This is confusing because that line might
itself be another loop, or might be somewhere else completely if the body was
an inlined function call. This happens because of the way we find the loop's
starting location. First, we look for a preheader, and if we find one, and its
terminator has a debug location, then we use that. Otherwise, we look for a
location on an instruction in the loop header.

The fallback heuristic is not bad, but will almost always find the beginning of
the body, and not the loop statement itself. The preheader location search
often fails because there's often not a preheader, and even when there is a
preheader, depending on how it was formed, it sometimes carries the location of
some preceeding code.

I don't see any good theoretical way to fix this problem. On the other hand,
this seems like a straightforward solution: Put the debug location in the
loop's llvm.loop metadata. When emitting debug information, this commit causes
us to add the debug location as an operand to each loop's llvm.loop metadata.
Thus, we now generate this metadata for all loops (not just loops with
optimization hints) when we're otherwise generating debug information.

The remark test case changes depend on the companion LLVM commit r270771.

Modified:
cfe/trunk/lib/CodeGen/CGLoopInfo.cpp
cfe/trunk/lib/CodeGen/CGLoopInfo.h
cfe/trunk/lib/CodeGen/CGStmt.cpp
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
cfe/trunk/test/CodeGenCXX/debug-info-line-if.cpp
cfe/trunk/test/Frontend/optimization-remark-options.c
cfe/trunk/test/Misc/backend-optimization-failure.cpp

Modified: cfe/trunk/lib/CodeGen/CGLoopInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGLoopInfo.cpp?rev=270772=270771=270772=diff
==
--- cfe/trunk/lib/CodeGen/CGLoopInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGLoopInfo.cpp Wed May 25 16:53:24 2016
@@ -19,12 +19,14 @@
 using namespace clang::CodeGen;
 using namespace llvm;
 
-static MDNode *createMetadata(LLVMContext , const LoopAttributes ) {
+static MDNode *createMetadata(LLVMContext , const LoopAttributes ,
+  llvm::DebugLoc Location) {
 
   if (!Attrs.IsParallel && Attrs.VectorizeWidth == 0 &&
   Attrs.InterleaveCount == 0 && Attrs.UnrollCount == 0 &&
   Attrs.VectorizeEnable == LoopAttributes::Unspecified &&
-  Attrs.UnrollEnable == LoopAttributes::Unspecified)
+  Attrs.UnrollEnable == LoopAttributes::Unspecified &&
+  !Location)
 return nullptr;
 
   SmallVector Args;
@@ -32,6 +34,10 @@ static MDNode *createMetadata(LLVMContex
   auto TempNode = MDNode::getTemporary(Ctx, None);
   Args.push_back(TempNode.get());
 
+  // If we have a valid debug location for the loop, add it.
+  if (Location)
+Args.push_back(Location.getAsMDNode());
+
   // Setting vectorize.width
   if (Attrs.VectorizeWidth > 0) {
 Metadata *Vals[] = {MDString::get(Ctx, "llvm.loop.vectorize.width"),
@@ -98,19 +104,21 @@ void LoopAttributes::clear() {
   UnrollEnable = LoopAttributes::Unspecified;
 }
 
-LoopInfo::LoopInfo(BasicBlock *Header, const LoopAttributes )
+LoopInfo::LoopInfo(BasicBlock *Header, const LoopAttributes ,
+   llvm::DebugLoc Location)
 : LoopID(nullptr), Header(Header), Attrs(Attrs) {
-  LoopID = createMetadata(Header->getContext(), Attrs);
+  LoopID = createMetadata(Header->getContext(), Attrs, Location);
 }
 
-void LoopInfoStack::push(BasicBlock *Header) {
-  Active.push_back(LoopInfo(Header, StagedAttrs));
+void LoopInfoStack::push(BasicBlock *Header, llvm::DebugLoc Location) {
+  Active.push_back(LoopInfo(Header, StagedAttrs, Location));
   // Clear the attributes so nested loops do not inherit them.
   StagedAttrs.clear();
 }
 
 void LoopInfoStack::push(BasicBlock *Header, clang::ASTContext ,
- ArrayRef Attrs) {
+ ArrayRef Attrs,
+ llvm::DebugLoc Location) {
 
   // Identify loop hint attributes from Attrs.
   for (const auto *Attr : Attrs) {
@@ -239,7 +247,7 @@ void LoopInfoStack::push(BasicBlock *Hea
   }
 
   /// Stage the attributes.
-  push(Header);
+  push(Header, Location);
 }
 
 void LoopInfoStack::pop() {

Modified: cfe/trunk/lib/CodeGen/CGLoopInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGLoopInfo.h?rev=270772=270771=270772=diff
==
--- cfe/trunk/lib/CodeGen/CGLoopInfo.h (original)

Re: [PATCH] D20407: [CodeGen][ObjC] zero-ext an i1 value to i8

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

In http://reviews.llvm.org/D20407#439951, @rjmccall wrote:

> The C standard is poorly-written in this area, but I think it would be 
> reasonable for CheckFunctionReturnType to just silently remove _Atomic.  (You 
> will not be able to just re-use your new method there; removing other 
> qualifiers is not acceptable, I'm afraid.)


Do you mean I should fix those cases in this patch too?


http://reviews.llvm.org/D20407



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


Re: [PATCH] D20630: [OpenCL] Allow -std=cl|CL1.1|CL1.2|CL2.0 in driver

2016-05-25 Thread Yaxun Liu via cfe-commits
yaxunl added inline comments.


Comment at: lib/Frontend/CompilerInvocation.cpp:1587-1589
@@ -1579,3 +1586,4 @@
+.Case("cl", LangStandard::lang_opencl)
 .Case("CL1.1", LangStandard::lang_opencl11)
 .Case("CL1.2", LangStandard::lang_opencl12)
 .Case("CL2.0", LangStandard::lang_opencl20)

rsmith wrote:
> How about changing these to the lowercase form too, and treating the 
> uppercase versions as (deprecated) synonyms? (And likewise changing 
> LangStandards.def to list the lowercase versions, perhaps with the uppercase 
> versions as aliases.)
-cl-std=CL1.1|CL1.2|CL2.0 is defined by OpenCL spec. Allowing lower case may 
cause some confusion.

-cl-std=cl is not part of OpenCL spec.

How about keeping all -cl-std= options big letters and all -std= options small 
letters?


http://reviews.llvm.org/D20630



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


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

2016-05-25 Thread David Majnemer via cfe-commits
majnemer added a comment.

In http://reviews.llvm.org/D18035#434095, @DmitryPolukhin wrote:

> One more friendly ping.. :(


I think the best way to make progress on this is to refactor this patch along 
the lines @rsmith suggested back on May 3.


http://reviews.llvm.org/D18035



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


Re: [PATCH] D20602: Add .rgba syntax extension to ext_vector_type types

2016-05-25 Thread Aleksey Bader via cfe-commits
On Wed, May 25, 2016 at 11:53 PM, Richard Smith 
wrote:

> On Wed, May 25, 2016 at 2:20 AM, Alexey Bader via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> bader added a subscriber: bader.
>> bader added a comment.
>>
>> In http://reviews.llvm.org/D20602#438667, @rsmith wrote:
>>
>> > I'm not suggesting it be treated as invalid. This extension is part of
>> at least OpenCL 2.1, but it's not part of OpenCL 1.0. `ext_vector_type` is
>> Clang's implementation of the OpenCL vector type. Therefore if the user
>> asks us to support OpenCL 1.0, we should give them a warning if they use
>> this syntax.
>> >
>> > If we're not building an OpenCL source file, then yes, this is our
>> extension and it makes sense for it to be available unconditionally
>> (without a warning).
>>
>>
>> To avoid confusion, I'd like to note that rgba selector was first
>> introduced in OpenCL C++ kernel language, which is currently in provisional
>> state and will be part of OpenCL version 2.2.
>> https://www.khronos.org/registry/cl/specs/opencl-2.2-cplusplus.pdf (page
>> 18).
>>
>
> https://www.khronos.org/registry/cl/specs/opencl-2.1-openclc++.pdf page
> 12-13 document it. Is that not OpenCL version 2.1?
>
>

Not quite. OpenCL C++ kernel language was planned to be ratified with
OpenCL 2.1 standard, but it did happen.
It's still listed as provisional although OpenCL 2.1 specification was
released last year. https://www.khronos.org/opencl/
Ratified OpenCL 2.1 standard requires to support only OpenCL C 2.0 and
SPIR-V 1.0 kernel languages.
There is no much sense to support provisional specification that will never
be ratified.

BTW, Khronos provided open source implementation of OpenCL C++ compiler and
since OpenCL C++ is a new kernel language and specification (
https://www.khronos.org/registry/cl/specs/opencl-2.2-cplusplus.pdf) is
version 1.0, the numbering of standard versions is different from OpenCL C.
Current std version is 'c++'.
Here is usage example:
https://github.com/KhronosGroup/SPIR/blob/spirv-1.1/test/OpenCL/OpenCL22/opencl_cplusplus.cl


> OpenCL version 2.1 uses OpenCL C 2.0 kernel language, which doesn't
>> support rgba selector.
>>
>> https://www.khronos.org/registry/cl/ - latest versions of OpenCL specs.
>>
>>
>> http://reviews.llvm.org/D20602
>>
>>
>>
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20407: [CodeGen][ObjC] zero-ext an i1 value to i8

2016-05-25 Thread Akira Hatanaka via cfe-commits
ahatanak updated this revision to Diff 58512.
ahatanak added a comment.

Rename variables.


http://reviews.llvm.org/D20407

Files:
  include/clang/AST/Type.h
  lib/AST/Type.cpp
  lib/CodeGen/CGObjC.cpp
  lib/Sema/SemaObjCProperty.cpp
  test/CodeGenObjC/property-atomic-bool.m
  test/SemaObjC/property-atomic-bool.m

Index: test/SemaObjC/property-atomic-bool.m
===
--- /dev/null
+++ test/SemaObjC/property-atomic-bool.m
@@ -0,0 +1,61 @@
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.10 -ast-dump "%s" 2>&1 | FileCheck %s
+
+// CHECK: TypedefDecl {{.*}} referenced AtomicBool '_Atomic(_Bool)'
+// CHECK:  AtomicType {{.*}} '_Atomic(_Bool)'
+// CHECK:   BuiltinType {{.*}} '_Bool'
+// CHECK: ObjCInterfaceDecl {{.*}} A0
+// CHECK:  ObjCPropertyDecl {{.*}} p '_Atomic(_Bool)' {{.*}} nonatomic
+// CHECK:  ObjCMethodDecl {{.*}} implicit - p '_Bool'
+// CHECK:  ObjCMethodDecl {{.*}} implicit - setP: 'void'
+// CHECK:   ParmVarDecl {{.*}} p '_Bool'
+// CHECK: ObjCInterfaceDecl {{.*}} A1
+// CHECK:  ObjCPropertyDecl {{.*}} p 'AtomicBool':'_Atomic(_Bool)' {{.*}} nonatomic
+// CHECK:  ObjCMethodDecl {{.*}} implicit - p '_Bool'
+// CHECK:  ObjCMethodDecl {{.*}} implicit - setP: 'void'
+// CHECK:   ParmVarDecl {{.*}} p '_Bool'
+// CHECK: ObjCInterfaceDecl {{.*}} A2
+// CHECK:  ObjCIvarDecl {{.*}} p '_Atomic(_Bool)' protected
+// CHECK:  ObjCPropertyDecl {{.*}} p '_Atomic(_Bool)'
+// CHECK:  ObjCMethodDecl {{.*}} implicit - p '_Bool'
+// CHECK:  ObjCMethodDecl {{.*}} implicit - setP: 'void'
+// CHECK:   ParmVarDecl {{.*}} p '_Bool'
+// CHECK: ObjCInterfaceDecl {{.*}} A3
+// CHECK:  ObjCIvarDecl {{.*}} p 'AtomicBool':'_Atomic(_Bool)' protected
+// CHECK:  ObjCPropertyDecl {{.*}} p 'AtomicBool':'_Atomic(_Bool)'
+// CHECK:  ObjCMethodDecl {{.*}} implicit - p '_Bool'
+// CHECK:  ObjCMethodDecl {{.*}} implicit - setP: 'void'
+// CHECK:   ParmVarDecl {{.*}} p '_Bool'
+
+typedef _Atomic(_Bool) AtomicBool;
+
+@interface A0
+@property(nonatomic) _Atomic(_Bool) p;
+@end
+@implementation A0
+@end
+
+@interface A1
+@property(nonatomic) AtomicBool p;
+@end
+@implementation A1
+@end
+
+@interface A2 {
+  _Atomic(_Bool) p;
+}
+@property _Atomic(_Bool) p;
+@end
+
+@implementation A2
+@synthesize p;
+@end
+
+@interface A3 {
+  AtomicBool p;
+}
+@property AtomicBool p;
+@end
+
+@implementation A3
+@synthesize p;
+@end
Index: test/CodeGenObjC/property-atomic-bool.m
===
--- /dev/null
+++ test/CodeGenObjC/property-atomic-bool.m
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10 -emit-llvm -x objective-c %s -o - | FileCheck %s
+
+// CHECK: define internal zeroext i1 @"\01-[A0 p]"(
+// CHECK:   %[[ATOMIC_LOAD:.*]] = load atomic i8, i8* %{{.*}} seq_cst
+// CHECK:   %[[TOBOOL:.*]] = trunc i8 %[[ATOMIC_LOAD]] to i1
+// CHECK:   ret i1 %[[TOBOOL]]
+
+// CHECK: define internal void @"\01-[A0 setP:]"({{.*}} i1 zeroext {{.*}})
+// CHECK:   store atomic i8 %{{.*}}, i8* %{{.*}} seq_cst
+// CHECK:   ret void
+
+// CHECK: define internal zeroext i1 @"\01-[A1 p]"(
+// CHECK:   %[[ATOMIC_LOAD:.*]] = load atomic i8, i8* %{{.*}} unordered
+// CHECK:   %[[TOBOOL:.*]] = trunc i8 %load to i1
+// CHECK:   ret i1 %[[TOBOOL]]
+
+// CHECK: define internal void @"\01-[A1 setP:]"({{.*}} i1 zeroext %p)
+// CHECK:   store atomic i8 %{{.*}}, i8* %{{.*}} unordered
+// CHECK:   ret void
+
+@interface A0
+@property(nonatomic) _Atomic(_Bool) p;
+@end
+@implementation A0
+@end
+
+@interface A1 {
+  _Atomic(_Bool) p;
+}
+@property _Atomic(_Bool) p;
+@end
+@implementation A1
+@synthesize p;
+@end
Index: lib/Sema/SemaObjCProperty.cpp
===
--- lib/Sema/SemaObjCProperty.cpp
+++ lib/Sema/SemaObjCProperty.cpp
@@ -1493,24 +1493,27 @@
   if (!GetterMethod)
 return false;
   QualType GetterType = GetterMethod->getReturnType().getNonReferenceType();
-  QualType PropertyIvarType = property->getType().getNonReferenceType();
-  bool compat = Context.hasSameType(PropertyIvarType, GetterType);
+  QualType PropertyRValueType =
+  property->getType().getNonReferenceType().getAtomicUnqualifiedType(
+  Context);
+  bool compat = Context.hasSameType(PropertyRValueType, GetterType);
   if (!compat) {
 const ObjCObjectPointerType *propertyObjCPtr = nullptr;
 const ObjCObjectPointerType *getterObjCPtr = nullptr;
-if ((propertyObjCPtr = PropertyIvarType->getAs()) && 
+if ((propertyObjCPtr =
+ PropertyRValueType->getAs()) &&
 (getterObjCPtr = GetterType->getAs()))
   compat = Context.canAssignObjCInterfaces(getterObjCPtr, propertyObjCPtr);
-else if (CheckAssignmentConstraints(Loc, GetterType, PropertyIvarType) 
+else if (CheckAssignmentConstraints(Loc, GetterType, PropertyRValueType)
   != Compatible) {
   Diag(Loc, diag::error_property_accessor_type)
-<< property->getDeclName() << PropertyIvarType
+

Re: [PATCH] D20407: [CodeGen][ObjC] zero-ext an i1 value to i8

2016-05-25 Thread John McCall via cfe-commits
rjmccall added a comment.

In http://reviews.llvm.org/D20407#439887, @ahatanak wrote:

> I reverted the changes I made in SemaDeclObjC.cpp as they weren't needed to 
> pass the regression tests I added. clang still asserts when it compiles an 
> objective-c method returning _Atomic and those changes will become necessary 
> when I fix that later. Normal functions returning _Atomic doesn't compile 
> either.


The C standard is poorly-written in this area, but I think it would be 
reasonable for CheckFunctionReturnType to just silently remove _Atomic.  (You 
will not be able to just re-use your new method there; removing other 
qualifiers is not acceptable, I'm afraid.)


http://reviews.llvm.org/D20407



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


Re: [PATCH] D20347: Add support to clang-cl driver for /GS switch

2016-05-25 Thread Etienne Bergeron via cfe-commits
etienneb added a comment.

This patch needs land after http://reviews.llvm.org/D20346.
thx for the review.


http://reviews.llvm.org/D20347



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


Re: [PATCH] D20347: Add support to clang-cl driver for /GS switch

2016-05-25 Thread Etienne Bergeron via cfe-commits
etienneb updated this revision to Diff 58502.
etienneb marked an inline comment as done.
etienneb added a comment.

more tests


http://reviews.llvm.org/D20347

Files:
  include/clang/Driver/CLCompatOptions.td
  lib/Driver/Tools.cpp
  test/Driver/cl-fallback.c
  test/Driver/cl-options.c

Index: test/Driver/cl-options.c
===
--- test/Driver/cl-options.c
+++ test/Driver/cl-options.c
@@ -59,6 +59,16 @@
 // RUN: %clang_cl /GR- -### -- %s 2>&1 | FileCheck -check-prefix=GR_ %s
 // GR_: -fno-rtti
 
+// Security Buffer Check is on by default.
+// RUN: %clang_cl -### -- %s 2>&1 | FileCheck -check-prefix=GS-default %s
+// GS-default: "-stack-protector" "2"
+
+// RUN: %clang_cl /GS -### -- %s 2>&1 | FileCheck -check-prefix=GS %s
+// GS: "-stack-protector" "2"
+
+// RUN: %clang_cl /GS- -### -- %s 2>&1 | FileCheck -check-prefix=GS_ %s
+// GS_-NOT: -stack-protector
+
 // RUN: %clang_cl /Gy -### -- %s 2>&1 | FileCheck -check-prefix=Gy %s
 // Gy: -ffunction-sections
 
Index: test/Driver/cl-fallback.c
===
--- test/Driver/cl-fallback.c
+++ test/Driver/cl-fallback.c
@@ -1,7 +1,7 @@
 // Note: %s must be preceded by --, otherwise it may be interpreted as a
 // command-line option, e.g. on Mac where %s is commonly under /Users.
 
-// RUN: %clang_cl --target=i686-pc-win32 /fallback /Dfoo=bar /Ubaz /Ifoo /O0 /Ox /GR /GR- /Gy /Gy- \
+// RUN: %clang_cl --target=i686-pc-win32 /fallback /Dfoo=bar /Ubaz /Ifoo /O0 /Ox /GR /GR- /GS /GS- /Gy /Gy- \
 // RUN:   /Gw /Gw- /LD /LDd /EHs /EHs- /Zl /MD /MDd /MTd /MT /FImyheader.h /Zi \
 // RUN:   -garbage -moregarbage \
 // RUN:   -### -- %s 2>&1 \
@@ -22,6 +22,7 @@
 // CHECK: "/Oy"
 // CHECK: "/GF"
 // CHECK: "/GR-"
+// CHECK: "/GS-"
 // CHECK: "/Gy-"
 // CHECK: "/Gw-"
 // CHECK: "/Z7"
@@ -41,6 +42,10 @@
 // GR: cl.exe
 // GR: "/GR-"
 
+// RUN: %clang_cl /fallback /GS- -### -- %s 2>&1 | FileCheck -check-prefix=GS %s
+// GS: cl.exe
+// GS: "/GS-"
+
 // RUN: %clang_cl /fallback /Od -### -- %s 2>&1 | FileCheck -check-prefix=O0 %s
 // O0: cl.exe
 // O0: "/Od"
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -6146,6 +6146,14 @@
/*default=*/false))
 CmdArgs.push_back("-fno-rtti-data");
 
+  // This controls whether or not we emit stack-protector instrumentation.
+  // In MSVC, Buffer Security Check (/GS) is on by default.
+  if (Args.hasFlag(options::OPT__SLASH_GS, options::OPT__SLASH_GS_,
+   /*default=*/true)) {
+CmdArgs.push_back("-stack-protector");
+CmdArgs.push_back(Args.MakeArgString(Twine(LangOptions::SSPStrong)));
+  }
+
   // Emit CodeView if -Z7 is present.
   *EmitCodeView = Args.hasArg(options::OPT__SLASH_Z7);
   if (*EmitCodeView)
@@ -9976,6 +9984,11 @@
   if (Args.hasFlag(options::OPT__SLASH_GR_, options::OPT__SLASH_GR,
/*default=*/false))
 CmdArgs.push_back("/GR-");
+
+  if (Args.hasFlag(options::OPT__SLASH_GS_, options::OPT__SLASH_GS,
+   /*default=*/false))
+CmdArgs.push_back("/GS-");
+
   if (Arg *A = Args.getLastArg(options::OPT_ffunction_sections,
options::OPT_fno_function_sections))
 CmdArgs.push_back(A->getOption().getID() == options::OPT_ffunction_sections
Index: include/clang/Driver/CLCompatOptions.td
===
--- include/clang/Driver/CLCompatOptions.td
+++ include/clang/Driver/CLCompatOptions.td
@@ -77,6 +77,8 @@
 def _SLASH_GR_ : CLFlag<"GR-">, HelpText<"Disable emission of RTTI data">;
 def _SLASH_GF_ : CLFlag<"GF-">, HelpText<"Disable string pooling">,
   Alias;
+def _SLASH_GS : CLFlag<"GS">, HelpText<"Enable buffer security check">;
+def _SLASH_GS_ : CLFlag<"GS-">, HelpText<"Disable buffer security check">;
 def _SLASH_Gs : CLJoined<"Gs">, HelpText<"Set stack probe size">,
   Alias;
 def _SLASH_Gy : CLFlag<"Gy">, HelpText<"Put each function in its own section">,
@@ -287,7 +289,6 @@
 def _SLASH_FC : CLIgnoredFlag<"FC">;
 def _SLASH_FS : CLIgnoredFlag<"FS">, HelpText<"Force synchronous PDB writes">;
 def _SLASH_GF : CLIgnoredFlag<"GF">;
-def _SLASH_GS_ : CLIgnoredFlag<"GS-">;
 def _SLASH_kernel_ : CLIgnoredFlag<"kernel-">;
 def _SLASH_nologo : CLIgnoredFlag<"nologo">;
 def _SLASH_Ob1 : CLIgnoredFlag<"Ob1">;
@@ -329,7 +330,6 @@
 def _SLASH_GL_ : CLFlag<"GL-">;
 def _SLASH_Gm : CLFlag<"Gm">;
 def _SLASH_Gm_ : CLFlag<"Gm-">;
-def _SLASH_GS : CLFlag<"GS">;
 def _SLASH_GT : CLFlag<"GT">;
 def _SLASH_Guard : CLJoined<"guard:">;
 def _SLASH_GZ : CLFlag<"GZ">;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20407: [CodeGen][ObjC] zero-ext an i1 value to i8

2016-05-25 Thread John McCall via cfe-commits
rjmccall added inline comments.


Comment at: lib/AST/Type.cpp:1282
@@ -1277,1 +1281,3 @@
+}
+
 Optional Type::getObjCSubstitutions(

ahatanak wrote:
> I added getTypePtr() because the code didn't compile.
Sure.


Comment at: lib/CodeGen/CGObjC.cpp:901
@@ -903,1 +900,3 @@
+uint64_t ivarSize = getContext().toBits(strategy.getIvarSize());
+llvm::Type *bitcastType = llvm::Type::getIntNTy(getLLVMContext(), 
ivarSize);
 bitcastType = bitcastType->getPointerTo(); // addrspace 0 okay

ahatanak wrote:
> I've only changed ivarSize. I can change the variable names defined below 
> (RetTy and RetTySize) too if that is necesasry.
Please do.


Comment at: lib/Sema/SemaObjCProperty.cpp:1497
@@ -1496,2 +1496,3 @@
   QualType PropertyIvarType = property->getType().getNonReferenceType();
-  bool compat = Context.hasSameType(PropertyIvarType, GetterType);
+  QualType AtomicUnquailifiedType =
+  PropertyIvarType.getAtomicUnqualifiedType(Context);

You know what, I'm sorry, I didn't look closely enough at the context.  Please 
just rename PropertyIvarType to something like PropertyRValueType.


http://reviews.llvm.org/D20407



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


Re: [PATCH] D20407: [CodeGen][ObjC] zero-ext an i1 value to i8

2016-05-25 Thread Akira Hatanaka via cfe-commits
ahatanak marked 2 inline comments as done.
ahatanak added a comment.

I reverted the changes I made in SemaDeclObjC.cpp as they weren't needed to 
pass the regression tests I added. clang still asserts when it compiles an 
objective-c method returning _Atomic and those changes will become necessary 
when I fix that later. Normal functions returning _Atomic doesn't compile 
either.


http://reviews.llvm.org/D20407



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


r270754 - Revert r270748 "clang-cl: Treat dllimport explicit template instantiation definitions as declarations (PR27810, PR27811)"

2016-05-25 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Wed May 25 15:49:14 2016
New Revision: 270754

URL: http://llvm.org/viewvc/llvm-project?rev=270754=rev
Log:
Revert r270748 "clang-cl: Treat dllimport explicit template instantiation 
definitions as declarations (PR27810, PR27811)"

It seems to have broken the sanitizer-windows bot.
Reverting while investigating.

Modified:
cfe/trunk/lib/Sema/SemaTemplate.cpp
cfe/trunk/test/CodeGenCXX/dllexport.cpp
cfe/trunk/test/CodeGenCXX/dllimport.cpp

Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=270754=270753=270754=diff
==
--- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp Wed May 25 15:49:14 2016
@@ -7367,29 +7367,6 @@ Sema::ActOnExplicitInstantiation(Scope *
 }
   }
 
-  // In MSVC mode, dllimported explicit instantiation definitions are treated 
as
-  // instantiation declarations for most purposes.
-  bool DLLImportExplicitInstantiationDef = false;
-  if (TSK == TSK_ExplicitInstantiationDefinition &&
-  Context.getTargetInfo().getCXXABI().isMicrosoft()) {
-// Check for dllimport class template instantiation definitions.
-bool DLLImport =
-ClassTemplate->getTemplatedDecl()->getAttr();
-for (AttributeList *A = Attr; A; A = A->getNext()) {
-  if (A->getKind() == AttributeList::AT_DLLImport)
-DLLImport = true;
-  if (A->getKind() == AttributeList::AT_DLLExport) {
-// dllexport trumps dllimport here.
-DLLImport = false;
-break;
-  }
-}
-if (DLLImport) {
-  TSK = TSK_ExplicitInstantiationDeclaration;
-  DLLImportExplicitInstantiationDef = true;
-}
-  }
-
   // Translate the parser's template argument list in our AST format.
   TemplateArgumentListInfo TemplateArgs(LAngleLoc, RAngleLoc);
   translateTemplateArguments(TemplateArgsIn, TemplateArgs);
@@ -7443,12 +7420,6 @@ Sema::ActOnExplicitInstantiation(Scope *
   Specialization->setLocation(TemplateNameLoc);
   PrevDecl = nullptr;
 }
-
-if (PrevDecl_TSK == TSK_ExplicitInstantiationDeclaration &&
-DLLImportExplicitInstantiationDef) {
-  // The new specialization might add a dllimport attribute.
-  HasNoEffect = false;
-}
   }
 
   if (!Specialization) {
@@ -7526,11 +7497,11 @@ Sema::ActOnExplicitInstantiation(Scope *
Specialization->getDefinition());
   if (Def) {
 TemplateSpecializationKind Old_TSK = Def->getTemplateSpecializationKind();
+
 // Fix a TSK_ExplicitInstantiationDeclaration followed by a
 // TSK_ExplicitInstantiationDefinition
 if (Old_TSK == TSK_ExplicitInstantiationDeclaration &&
-(TSK == TSK_ExplicitInstantiationDefinition ||
- DLLImportExplicitInstantiationDef)) {
+TSK == TSK_ExplicitInstantiationDefinition) {
   // FIXME: Need to notify the ASTMutationListener that we did this.
   Def->setTemplateSpecializationKind(TSK);
 

Modified: cfe/trunk/test/CodeGenCXX/dllexport.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/dllexport.cpp?rev=270754=270753=270754=diff
==
--- cfe/trunk/test/CodeGenCXX/dllexport.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/dllexport.cpp Wed May 25 15:49:14 2016
@@ -844,11 +844,6 @@ struct __declspec(dllexport) B {
 // M32-DAG: define weak_odr dllexport x86_thiscallcc void 
@"\01??_FB@pr26490@@QAEXXZ"
 }
 
-// dllexport trumps dllexport on an explicit instantiation.
-template  struct ExplicitInstantiationTwoAttributes { void f() {} 
};
-template struct __declspec(dllexport) __declspec(dllimport) 
ExplicitInstantiationTwoAttributes;
-// M32-DAG: define weak_odr dllexport x86_thiscallcc void 
@"\01?f@?$ExplicitInstantiationTwoAttributes@H@@QAEXXZ"
-
 
 
//===--===//
 // Classes with template base classes
@@ -963,6 +958,14 @@ template struct ExplicitInstantiationDec
 // M32-DAG: define weak_odr dllexport x86_thiscallcc void 
@"\01?func@?$ExplicitInstantiationDeclTemplateBase@H@@QAEXXZ"
 // G32-DAG: define weak_odr x86_thiscallcc void 
@_ZN37ExplicitInstantiationDeclTemplateBaseIiE4funcEv
 
+template  struct ExplicitInstantiationDeclTemplateBase2 { void 
func() {} };
+extern template struct ExplicitInstantiationDeclTemplateBase2;
+struct __declspec(dllexport) DerivedFromExplicitInstantiationDeclTemplateBase2 
: public ExplicitInstantiationDeclTemplateBase2 {};
+template struct __declspec(dllimport) 
ExplicitInstantiationDeclTemplateBase2;
+USEMEMFUNC(ExplicitInstantiationDeclTemplateBase2, func)
+// M32-DAG: define weak_odr dllexport x86_thiscallcc void 
@"\01?func@?$ExplicitInstantiationDeclTemplateBase2@H@@QAEXXZ"
+// G32-DAG: define weak_odr x86_thiscallcc void 
@_ZN38ExplicitInstantiationDeclTemplateBase2IiE4funcEv
+
 // PR26076
 

Re: [PATCH] D20602: Add .rgba syntax extension to ext_vector_type types

2016-05-25 Thread Richard Smith via cfe-commits
On Wed, May 25, 2016 at 2:20 AM, Alexey Bader via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> bader added a subscriber: bader.
> bader added a comment.
>
> In http://reviews.llvm.org/D20602#438667, @rsmith wrote:
>
> > I'm not suggesting it be treated as invalid. This extension is part of
> at least OpenCL 2.1, but it's not part of OpenCL 1.0. `ext_vector_type` is
> Clang's implementation of the OpenCL vector type. Therefore if the user
> asks us to support OpenCL 1.0, we should give them a warning if they use
> this syntax.
> >
> > If we're not building an OpenCL source file, then yes, this is our
> extension and it makes sense for it to be available unconditionally
> (without a warning).
>
>
> To avoid confusion, I'd like to note that rgba selector was first
> introduced in OpenCL C++ kernel language, which is currently in provisional
> state and will be part of OpenCL version 2.2.
> https://www.khronos.org/registry/cl/specs/opencl-2.2-cplusplus.pdf (page
> 18).
>

https://www.khronos.org/registry/cl/specs/opencl-2.1-openclc++.pdf page
12-13 document it. Is that not OpenCL version 2.1?


> OpenCL version 2.1 uses OpenCL C 2.0 kernel language, which doesn't
> support rgba selector.
>
> https://www.khronos.org/registry/cl/ - latest versions of OpenCL specs.
>
>
> http://reviews.llvm.org/D20602
>
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20407: [CodeGen][ObjC] zero-ext an i1 value to i8

2016-05-25 Thread Akira Hatanaka via cfe-commits
ahatanak marked 7 inline comments as done.


Comment at: lib/AST/Type.cpp:1282
@@ -1277,1 +1281,3 @@
+}
+
 Optional Type::getObjCSubstitutions(

I added getTypePtr() because the code didn't compile.


Comment at: lib/CodeGen/CGObjC.cpp:901
@@ -903,1 +900,3 @@
+uint64_t ivarSize = getContext().toBits(strategy.getIvarSize());
+llvm::Type *bitcastType = llvm::Type::getIntNTy(getLLVMContext(), 
ivarSize);
 bitcastType = bitcastType->getPointerTo(); // addrspace 0 okay

I've only changed ivarSize. I can change the variable names defined below 
(RetTy and RetTySize) too if that is necesasry.


http://reviews.llvm.org/D20407



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


Re: [PATCH] D20407: [CodeGen][ObjC] zero-ext an i1 value to i8

2016-05-25 Thread Akira Hatanaka via cfe-commits
ahatanak updated this revision to Diff 58495.
ahatanak added a comment.

Address John's review comments.


http://reviews.llvm.org/D20407

Files:
  include/clang/AST/Type.h
  lib/AST/Type.cpp
  lib/CodeGen/CGObjC.cpp
  lib/Sema/SemaObjCProperty.cpp
  test/CodeGenObjC/property-atomic-bool.m
  test/SemaObjC/property-atomic-bool.m

Index: test/SemaObjC/property-atomic-bool.m
===
--- /dev/null
+++ test/SemaObjC/property-atomic-bool.m
@@ -0,0 +1,61 @@
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.10 -ast-dump "%s" 2>&1 | FileCheck %s
+
+// CHECK: TypedefDecl {{.*}} referenced AtomicBool '_Atomic(_Bool)'
+// CHECK:  AtomicType {{.*}} '_Atomic(_Bool)'
+// CHECK:   BuiltinType {{.*}} '_Bool'
+// CHECK: ObjCInterfaceDecl {{.*}} A0
+// CHECK:  ObjCPropertyDecl {{.*}} p '_Atomic(_Bool)' {{.*}} nonatomic
+// CHECK:  ObjCMethodDecl {{.*}} implicit - p '_Bool'
+// CHECK:  ObjCMethodDecl {{.*}} implicit - setP: 'void'
+// CHECK:   ParmVarDecl {{.*}} p '_Bool'
+// CHECK: ObjCInterfaceDecl {{.*}} A1
+// CHECK:  ObjCPropertyDecl {{.*}} p 'AtomicBool':'_Atomic(_Bool)' {{.*}} nonatomic
+// CHECK:  ObjCMethodDecl {{.*}} implicit - p '_Bool'
+// CHECK:  ObjCMethodDecl {{.*}} implicit - setP: 'void'
+// CHECK:   ParmVarDecl {{.*}} p '_Bool'
+// CHECK: ObjCInterfaceDecl {{.*}} A2
+// CHECK:  ObjCIvarDecl {{.*}} p '_Atomic(_Bool)' protected
+// CHECK:  ObjCPropertyDecl {{.*}} p '_Atomic(_Bool)'
+// CHECK:  ObjCMethodDecl {{.*}} implicit - p '_Bool'
+// CHECK:  ObjCMethodDecl {{.*}} implicit - setP: 'void'
+// CHECK:   ParmVarDecl {{.*}} p '_Bool'
+// CHECK: ObjCInterfaceDecl {{.*}} A3
+// CHECK:  ObjCIvarDecl {{.*}} p 'AtomicBool':'_Atomic(_Bool)' protected
+// CHECK:  ObjCPropertyDecl {{.*}} p 'AtomicBool':'_Atomic(_Bool)'
+// CHECK:  ObjCMethodDecl {{.*}} implicit - p '_Bool'
+// CHECK:  ObjCMethodDecl {{.*}} implicit - setP: 'void'
+// CHECK:   ParmVarDecl {{.*}} p '_Bool'
+
+typedef _Atomic(_Bool) AtomicBool;
+
+@interface A0
+@property(nonatomic) _Atomic(_Bool) p;
+@end
+@implementation A0
+@end
+
+@interface A1
+@property(nonatomic) AtomicBool p;
+@end
+@implementation A1
+@end
+
+@interface A2 {
+  _Atomic(_Bool) p;
+}
+@property _Atomic(_Bool) p;
+@end
+
+@implementation A2
+@synthesize p;
+@end
+
+@interface A3 {
+  AtomicBool p;
+}
+@property AtomicBool p;
+@end
+
+@implementation A3
+@synthesize p;
+@end
Index: test/CodeGenObjC/property-atomic-bool.m
===
--- /dev/null
+++ test/CodeGenObjC/property-atomic-bool.m
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10 -emit-llvm -x objective-c %s -o - | FileCheck %s
+
+// CHECK: define internal zeroext i1 @"\01-[A0 p]"(
+// CHECK:   %[[ATOMIC_LOAD:.*]] = load atomic i8, i8* %{{.*}} seq_cst
+// CHECK:   %[[TOBOOL:.*]] = trunc i8 %[[ATOMIC_LOAD]] to i1
+// CHECK:   ret i1 %[[TOBOOL]]
+
+// CHECK: define internal void @"\01-[A0 setP:]"({{.*}} i1 zeroext {{.*}})
+// CHECK:   store atomic i8 %{{.*}}, i8* %{{.*}} seq_cst
+// CHECK:   ret void
+
+// CHECK: define internal zeroext i1 @"\01-[A1 p]"(
+// CHECK:   %[[ATOMIC_LOAD:.*]] = load atomic i8, i8* %{{.*}} unordered
+// CHECK:   %[[TOBOOL:.*]] = trunc i8 %load to i1
+// CHECK:   ret i1 %[[TOBOOL]]
+
+// CHECK: define internal void @"\01-[A1 setP:]"({{.*}} i1 zeroext %p)
+// CHECK:   store atomic i8 %{{.*}}, i8* %{{.*}} unordered
+// CHECK:   ret void
+
+@interface A0
+@property(nonatomic) _Atomic(_Bool) p;
+@end
+@implementation A0
+@end
+
+@interface A1 {
+  _Atomic(_Bool) p;
+}
+@property _Atomic(_Bool) p;
+@end
+@implementation A1
+@synthesize p;
+@end
Index: lib/Sema/SemaObjCProperty.cpp
===
--- lib/Sema/SemaObjCProperty.cpp
+++ lib/Sema/SemaObjCProperty.cpp
@@ -1494,23 +1494,26 @@
 return false;
   QualType GetterType = GetterMethod->getReturnType().getNonReferenceType();
   QualType PropertyIvarType = property->getType().getNonReferenceType();
-  bool compat = Context.hasSameType(PropertyIvarType, GetterType);
+  QualType AtomicUnquailifiedType =
+  PropertyIvarType.getAtomicUnqualifiedType(Context);
+  bool compat = Context.hasSameType(AtomicUnquailifiedType, GetterType);
   if (!compat) {
 const ObjCObjectPointerType *propertyObjCPtr = nullptr;
 const ObjCObjectPointerType *getterObjCPtr = nullptr;
-if ((propertyObjCPtr = PropertyIvarType->getAs()) && 
+if ((propertyObjCPtr =
+ AtomicUnquailifiedType->getAs()) &&
 (getterObjCPtr = GetterType->getAs()))
   compat = Context.canAssignObjCInterfaces(getterObjCPtr, propertyObjCPtr);
-else if (CheckAssignmentConstraints(Loc, GetterType, PropertyIvarType) 
+else if (CheckAssignmentConstraints(Loc, GetterType, AtomicUnquailifiedType)
   != Compatible) {
   Diag(Loc, diag::error_property_accessor_type)
 << property->getDeclName() << PropertyIvarType
 << 

Re: [PATCH] D20630: [OpenCL] Allow -std=cl|CL1.1|CL1.2|CL2.0 in driver

2016-05-25 Thread Richard Smith via cfe-commits
rsmith added inline comments.


Comment at: lib/Frontend/CompilerInvocation.cpp:1587-1589
@@ -1579,3 +1586,4 @@
+.Case("cl", LangStandard::lang_opencl)
 .Case("CL1.1", LangStandard::lang_opencl11)
 .Case("CL1.2", LangStandard::lang_opencl12)
 .Case("CL2.0", LangStandard::lang_opencl20)

How about changing these to the lowercase form too, and treating the uppercase 
versions as (deprecated) synonyms? (And likewise changing LangStandards.def to 
list the lowercase versions, perhaps with the uppercase versions as aliases.)


http://reviews.llvm.org/D20630



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


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

2016-05-25 Thread Richard Smith via cfe-commits
rsmith added inline comments.


Comment at: lib/Basic/FileManager.cpp:389
@@ -383,2 +388,3 @@
   UFE->File.reset();
+  UFE->IsVirtual = true;
   return UFE;

Rather than adding this `IsVirtual` flag, could you just set `UFE->IsValid` to 
`true` here?  It looks like a simple oversight that this code fails to set the 
`IsValid` flag properly.


Repository:
  rL LLVM

http://reviews.llvm.org/D20338



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


Re: [PATCH] D18488: [OpenMP] Parsing and sema support for the from clause

2016-05-25 Thread Samuel Antao via cfe-commits
sfantao added a comment.

Hi Alexey,

Thanks for the review!

In http://reviews.llvm.org/D18488#438841, @ABataev wrote:

> Missed a test for printing and serialization/deserialization


Maybe it is `test/OpenMP/target_update_ast_print.cpp` what you were looking 
for? Let me know if not.

Thanks again,
Samuel



Comment at: test/OpenMP/nesting_of_regions.cpp:1832
@@ -1831,3 +1831,3 @@
   for (int i = 0; i < 10; ++i) {
-#pragma omp target update to(a)
+#pragma omp target update from(a)
   }

ABataev wrote:
> Again, this test must be updated only for new directives, not clauses
Ok, I'm not touching this test in this patch anymore.


http://reviews.llvm.org/D18488



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


Re: [PATCH] D18488: [OpenMP] Parsing and sema support for the from clause

2016-05-25 Thread Samuel Antao via cfe-commits
sfantao updated this revision to Diff 58490.
sfantao marked an inline comment as done.
sfantao added a comment.

- Rebase and remove changes from the nesting tests.


http://reviews.llvm.org/D18488

Files:
  include/clang/AST/OpenMPClause.h
  include/clang/AST/RecursiveASTVisitor.h
  include/clang/Basic/OpenMPKinds.def
  include/clang/Sema/Sema.h
  lib/AST/OpenMPClause.cpp
  lib/AST/StmtPrinter.cpp
  lib/AST/StmtProfile.cpp
  lib/Basic/OpenMPKinds.cpp
  lib/CodeGen/CGStmtOpenMP.cpp
  lib/Parse/ParseOpenMP.cpp
  lib/Sema/SemaOpenMP.cpp
  lib/Sema/TreeTransform.h
  lib/Serialization/ASTReaderStmt.cpp
  lib/Serialization/ASTWriterStmt.cpp
  test/OpenMP/target_update_ast_print.cpp
  test/OpenMP/target_update_device_messages.cpp
  test/OpenMP/target_update_from_messages.cpp
  test/OpenMP/target_update_if_messages.cpp
  test/OpenMP/target_update_messages.cpp
  test/OpenMP/target_update_to_messages.cpp
  tools/libclang/CIndex.cpp

Index: tools/libclang/CIndex.cpp
===
--- tools/libclang/CIndex.cpp
+++ tools/libclang/CIndex.cpp
@@ -2249,6 +2249,9 @@
 void OMPClauseEnqueue::VisitOMPToClause(const OMPToClause *C) {
   VisitOMPClauseList(C);
 }
+void OMPClauseEnqueue::VisitOMPFromClause(const OMPFromClause *C) {
+  VisitOMPClauseList(C);
+}
 }
 
 void EnqueueVisitor::EnqueueChildren(const OMPClause *S) {
Index: test/OpenMP/target_update_to_messages.cpp
===
--- test/OpenMP/target_update_to_messages.cpp
+++ test/OpenMP/target_update_to_messages.cpp
@@ -97,7 +97,7 @@
 #pragma omp target update to(a, b, c, d, f) // expected-error {{incomplete type 'S1' where a complete type is required}} expected-error 2 {{type 'S2' is not mappable to target}}
 #pragma omp target update to(ba) // expected-error 2 {{type 'S2' is not mappable to target}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
 #pragma omp target update to(h) // expected-error {{threadprivate variables are not allowed in 'to' clause}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
-#pragma omp target update to(k), to(k) // expected-error 2 {{variable can appear only once in OpenMP 'target update' construct}} expected-note 2 {{used here}}
+#pragma omp target update to(k), from(k) // expected-error 2 {{variable can appear only once in OpenMP 'target update' construct}} expected-note 2 {{used here}}
 #pragma omp target update to(t), to(t[:5]) // expected-error 2 {{variable can appear only once in OpenMP 'target update' construct}} expected-note 2 {{used here}}
 #pragma omp target update to(da)
 #pragma omp target update to(da[:4])
@@ -150,7 +150,7 @@
 #pragma omp target update to(a, b, c, d, f) // expected-error {{incomplete type 'S1' where a complete type is required}} expected-error 2 {{type 'S2' is not mappable to target}}
 #pragma omp target update to(ba) // expected-error 2 {{type 'S2' is not mappable to target}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
 #pragma omp target update to(h) // expected-error {{threadprivate variables are not allowed in 'to' clause}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
-#pragma omp target update to(k), to(k) // expected-error {{variable can appear only once in OpenMP 'target update' construct}} expected-note {{used here}}
+#pragma omp target update to(k), from(k) // expected-error {{variable can appear only once in OpenMP 'target update' construct}} expected-note {{used here}}
 #pragma omp target update to(t), to(t[:5]) // expected-error {{variable can appear only once in OpenMP 'target update' construct}} expected-note {{used here}}
 #pragma omp target update to(da)
 #pragma omp target update to(da[:4])
Index: test/OpenMP/target_update_messages.cpp
===
--- test/OpenMP/target_update_messages.cpp
+++ test/OpenMP/target_update_messages.cpp
@@ -24,7 +24,7 @@
   #pragma omp target update to(m) ] // expected-warning {{extra tokens at the end of '#pragma omp target update' are ignored}}
   #pragma omp target update to(m) ) // expected-warning {{extra tokens at the end of '#pragma omp target update' are ignored}}
 
-  #pragma omp target update to(m) // OK
+  #pragma omp target update from(m) // OK
   {
 foo();
   }
Index: test/OpenMP/target_update_if_messages.cpp
===
--- test/OpenMP/target_update_if_messages.cpp
+++ test/OpenMP/target_update_if_messages.cpp
@@ -13,46 +13,46 @@
 int tmain(T argc, S **argv) {
   int n;
 #pragma omp target update to(n) if // expected-error {{expected '(' after 'if'}}
-#pragma omp target update if ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to 

Re: [PATCH] D20608: clang-cl: Treat dllimport explicit template instantiation definitions as declarations (PR27810, PR27811)

2016-05-25 Thread Hans Wennborg via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL270748: clang-cl: Treat dllimport explicit template 
instantiation definitions as… (authored by hans).

Changed prior to commit:
  http://reviews.llvm.org/D20608?vs=58484=58488#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D20608

Files:
  cfe/trunk/lib/Sema/SemaTemplate.cpp
  cfe/trunk/test/CodeGenCXX/dllexport.cpp
  cfe/trunk/test/CodeGenCXX/dllimport.cpp

Index: cfe/trunk/lib/Sema/SemaTemplate.cpp
===
--- cfe/trunk/lib/Sema/SemaTemplate.cpp
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp
@@ -7367,6 +7367,29 @@
 }
   }
 
+  // In MSVC mode, dllimported explicit instantiation definitions are treated as
+  // instantiation declarations for most purposes.
+  bool DLLImportExplicitInstantiationDef = false;
+  if (TSK == TSK_ExplicitInstantiationDefinition &&
+  Context.getTargetInfo().getCXXABI().isMicrosoft()) {
+// Check for dllimport class template instantiation definitions.
+bool DLLImport =
+ClassTemplate->getTemplatedDecl()->getAttr();
+for (AttributeList *A = Attr; A; A = A->getNext()) {
+  if (A->getKind() == AttributeList::AT_DLLImport)
+DLLImport = true;
+  if (A->getKind() == AttributeList::AT_DLLExport) {
+// dllexport trumps dllimport here.
+DLLImport = false;
+break;
+  }
+}
+if (DLLImport) {
+  TSK = TSK_ExplicitInstantiationDeclaration;
+  DLLImportExplicitInstantiationDef = true;
+}
+  }
+
   // Translate the parser's template argument list in our AST format.
   TemplateArgumentListInfo TemplateArgs(LAngleLoc, RAngleLoc);
   translateTemplateArguments(TemplateArgsIn, TemplateArgs);
@@ -7420,6 +7443,12 @@
   Specialization->setLocation(TemplateNameLoc);
   PrevDecl = nullptr;
 }
+
+if (PrevDecl_TSK == TSK_ExplicitInstantiationDeclaration &&
+DLLImportExplicitInstantiationDef) {
+  // The new specialization might add a dllimport attribute.
+  HasNoEffect = false;
+}
   }
 
   if (!Specialization) {
@@ -7497,11 +7526,11 @@
Specialization->getDefinition());
   if (Def) {
 TemplateSpecializationKind Old_TSK = Def->getTemplateSpecializationKind();
-
 // Fix a TSK_ExplicitInstantiationDeclaration followed by a
 // TSK_ExplicitInstantiationDefinition
 if (Old_TSK == TSK_ExplicitInstantiationDeclaration &&
-TSK == TSK_ExplicitInstantiationDefinition) {
+(TSK == TSK_ExplicitInstantiationDefinition ||
+ DLLImportExplicitInstantiationDef)) {
   // FIXME: Need to notify the ASTMutationListener that we did this.
   Def->setTemplateSpecializationKind(TSK);
 
Index: cfe/trunk/test/CodeGenCXX/dllimport.cpp
===
--- cfe/trunk/test/CodeGenCXX/dllimport.cpp
+++ cfe/trunk/test/CodeGenCXX/dllimport.cpp
@@ -656,7 +656,7 @@
 
 namespace Vtordisp {
   // Don't dllimport the vtordisp.
-  // MO1-DAG: define linkonce_odr x86_thiscallcc void @"\01?f@?$C@D@Vtordisp@@$4PPPM@A@AEXXZ"
+  // MO1-DAG: define linkonce_odr x86_thiscallcc void @"\01?f@?$C@H@Vtordisp@@$4PPPM@A@AEXXZ"
 
   class Base {
 virtual void f() {}
@@ -667,7 +667,7 @@
 C() {}
 virtual void f() {}
   };
-  template class C;
+  USECLASS(C);
 }
 
 namespace ClassTemplateStaticDef {
@@ -698,26 +698,31 @@
   template  struct A { static NonPOD x; };
   template  NonPOD A::x;
   template struct __declspec(dllimport) A;
-  // MSC-DAG: @"\01?x@?$A@H@PR19933@@2UNonPOD@2@A" = available_externally dllimport global %"struct.PR19933::NonPOD" zeroinitializer
+  USEVARTYPE(NonPOD, A::x);
+  // MSC-DAG: @"\01?x@?$A@H@PR19933@@2UNonPOD@2@A" = external dllimport global %"struct.PR19933::NonPOD"
 
   int f();
   template  struct B { static int x; };
   template  int B::x = f();
   template struct __declspec(dllimport) B;
-  // MSC-DAG: @"\01?x@?$B@H@PR19933@@2HA" = available_externally dllimport global i32 0
+  USEVAR(B::x);
+  // MSC-DAG: @"\01?x@?$B@H@PR19933@@2HA" = external dllimport global i32
 
   constexpr int g() { return 42; }
   template  struct C { static int x; };
   template  int C::x = g();
   template struct __declspec(dllimport) C;
-  // MSC-DAG: @"\01?x@?$C@H@PR19933@@2HA" = available_externally dllimport global i32 42
+  USEVAR(C::x);
+  // MSC-DAG: @"\01?x@?$C@H@PR19933@@2HA" = external dllimport global i32
 
   template  struct D { static int x, y; };
   template  int D::x = I + 1;
   template  int D::y = I + f();
   template struct __declspec(dllimport) D<42>;
-  // MSC-DAG: @"\01?x@?$D@$0CK@@PR19933@@2HA" = available_externally dllimport global i32 43
-  // MSC-DAG: @"\01?y@?$D@$0CK@@PR19933@@2HA" = available_externally dllimport global i32 0
+  USEVAR(D<42>::x);
+  USEVAR(D<42>::y);
+  // MSC-DAG: @"\01?x@?$D@$0CK@@PR19933@@2HA" = external dllimport global i32
+  // MSC-DAG: @"\01?y@?$D@$0CK@@PR19933@@2HA" 

r270748 - clang-cl: Treat dllimport explicit template instantiation definitions as declarations (PR27810, PR27811)

2016-05-25 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Wed May 25 15:16:43 2016
New Revision: 270748

URL: http://llvm.org/viewvc/llvm-project?rev=270748=rev
Log:
clang-cl: Treat dllimport explicit template instantiation definitions as 
declarations (PR27810, PR27811)

This matches what MSVC does, and should make compiles faster by avoiding to
unnecessarily emit a lot of code.

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

Modified:
cfe/trunk/lib/Sema/SemaTemplate.cpp
cfe/trunk/test/CodeGenCXX/dllexport.cpp
cfe/trunk/test/CodeGenCXX/dllimport.cpp

Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=270748=270747=270748=diff
==
--- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp Wed May 25 15:16:43 2016
@@ -7367,6 +7367,29 @@ Sema::ActOnExplicitInstantiation(Scope *
 }
   }
 
+  // In MSVC mode, dllimported explicit instantiation definitions are treated 
as
+  // instantiation declarations for most purposes.
+  bool DLLImportExplicitInstantiationDef = false;
+  if (TSK == TSK_ExplicitInstantiationDefinition &&
+  Context.getTargetInfo().getCXXABI().isMicrosoft()) {
+// Check for dllimport class template instantiation definitions.
+bool DLLImport =
+ClassTemplate->getTemplatedDecl()->getAttr();
+for (AttributeList *A = Attr; A; A = A->getNext()) {
+  if (A->getKind() == AttributeList::AT_DLLImport)
+DLLImport = true;
+  if (A->getKind() == AttributeList::AT_DLLExport) {
+// dllexport trumps dllimport here.
+DLLImport = false;
+break;
+  }
+}
+if (DLLImport) {
+  TSK = TSK_ExplicitInstantiationDeclaration;
+  DLLImportExplicitInstantiationDef = true;
+}
+  }
+
   // Translate the parser's template argument list in our AST format.
   TemplateArgumentListInfo TemplateArgs(LAngleLoc, RAngleLoc);
   translateTemplateArguments(TemplateArgsIn, TemplateArgs);
@@ -7420,6 +7443,12 @@ Sema::ActOnExplicitInstantiation(Scope *
   Specialization->setLocation(TemplateNameLoc);
   PrevDecl = nullptr;
 }
+
+if (PrevDecl_TSK == TSK_ExplicitInstantiationDeclaration &&
+DLLImportExplicitInstantiationDef) {
+  // The new specialization might add a dllimport attribute.
+  HasNoEffect = false;
+}
   }
 
   if (!Specialization) {
@@ -7497,11 +7526,11 @@ Sema::ActOnExplicitInstantiation(Scope *
Specialization->getDefinition());
   if (Def) {
 TemplateSpecializationKind Old_TSK = Def->getTemplateSpecializationKind();
-
 // Fix a TSK_ExplicitInstantiationDeclaration followed by a
 // TSK_ExplicitInstantiationDefinition
 if (Old_TSK == TSK_ExplicitInstantiationDeclaration &&
-TSK == TSK_ExplicitInstantiationDefinition) {
+(TSK == TSK_ExplicitInstantiationDefinition ||
+ DLLImportExplicitInstantiationDef)) {
   // FIXME: Need to notify the ASTMutationListener that we did this.
   Def->setTemplateSpecializationKind(TSK);
 

Modified: cfe/trunk/test/CodeGenCXX/dllexport.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/dllexport.cpp?rev=270748=270747=270748=diff
==
--- cfe/trunk/test/CodeGenCXX/dllexport.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/dllexport.cpp Wed May 25 15:16:43 2016
@@ -844,6 +844,11 @@ struct __declspec(dllexport) B {
 // M32-DAG: define weak_odr dllexport x86_thiscallcc void 
@"\01??_FB@pr26490@@QAEXXZ"
 }
 
+// dllexport trumps dllexport on an explicit instantiation.
+template  struct ExplicitInstantiationTwoAttributes { void f() {} 
};
+template struct __declspec(dllexport) __declspec(dllimport) 
ExplicitInstantiationTwoAttributes;
+// M32-DAG: define weak_odr dllexport x86_thiscallcc void 
@"\01?f@?$ExplicitInstantiationTwoAttributes@H@@QAEXXZ"
+
 
 
//===--===//
 // Classes with template base classes
@@ -958,14 +963,6 @@ template struct ExplicitInstantiationDec
 // M32-DAG: define weak_odr dllexport x86_thiscallcc void 
@"\01?func@?$ExplicitInstantiationDeclTemplateBase@H@@QAEXXZ"
 // G32-DAG: define weak_odr x86_thiscallcc void 
@_ZN37ExplicitInstantiationDeclTemplateBaseIiE4funcEv
 
-template  struct ExplicitInstantiationDeclTemplateBase2 { void 
func() {} };
-extern template struct ExplicitInstantiationDeclTemplateBase2;
-struct __declspec(dllexport) DerivedFromExplicitInstantiationDeclTemplateBase2 
: public ExplicitInstantiationDeclTemplateBase2 {};
-template struct __declspec(dllimport) 
ExplicitInstantiationDeclTemplateBase2;
-USEMEMFUNC(ExplicitInstantiationDeclTemplateBase2, func)
-// M32-DAG: define weak_odr dllexport x86_thiscallcc void 
@"\01?func@?$ExplicitInstantiationDeclTemplateBase2@H@@QAEXXZ"
-// G32-DAG: define weak_odr x86_thiscallcc void 

Re: [PATCH] D18597: [OpenMP] Parsing and sema support for the to clause

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

- Address comments from the last review by Alexey.


http://reviews.llvm.org/D18597

Files:
  include/clang/AST/OpenMPClause.h
  include/clang/AST/RecursiveASTVisitor.h
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Basic/OpenMPKinds.def
  include/clang/Sema/Sema.h
  lib/AST/OpenMPClause.cpp
  lib/AST/StmtPrinter.cpp
  lib/AST/StmtProfile.cpp
  lib/Basic/OpenMPKinds.cpp
  lib/CodeGen/CGStmtOpenMP.cpp
  lib/Parse/ParseOpenMP.cpp
  lib/Sema/SemaOpenMP.cpp
  lib/Sema/TreeTransform.h
  lib/Serialization/ASTReaderStmt.cpp
  lib/Serialization/ASTWriterStmt.cpp
  test/OpenMP/nesting_of_regions.cpp
  test/OpenMP/target_map_messages.cpp
  test/OpenMP/target_parallel_for_map_messages.cpp
  test/OpenMP/target_parallel_map_messages.cpp
  test/OpenMP/target_update_ast_print.cpp
  test/OpenMP/target_update_device_messages.cpp
  test/OpenMP/target_update_if_messages.cpp
  test/OpenMP/target_update_messages.cpp
  test/OpenMP/target_update_to_messages.cpp
  tools/libclang/CIndex.cpp

Index: tools/libclang/CIndex.cpp
===
--- tools/libclang/CIndex.cpp
+++ tools/libclang/CIndex.cpp
@@ -2246,6 +2246,9 @@
 }
 void OMPClauseEnqueue::VisitOMPDefaultmapClause(
 const OMPDefaultmapClause * /*C*/) {}
+void OMPClauseEnqueue::VisitOMPToClause(const OMPToClause *C) {
+  VisitOMPClauseList(C);
+}
 }
 
 void EnqueueVisitor::EnqueueChildren(const OMPClause *S) {
Index: test/OpenMP/target_update_to_messages.cpp
===
--- /dev/null
+++ test/OpenMP/target_update_to_messages.cpp
@@ -0,0 +1,175 @@
+// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 %s
+
+void foo() {
+}
+
+bool foobool(int argc) {
+  return argc;
+}
+
+struct S1; // expected-note 2 {{declared here}}
+extern S1 a;
+class S2 {
+  mutable int a;
+public:
+  S2():a(0) { }
+  S2(S2 ):a(s2.a) { }
+  static float S2s; // expected-note 4 {{mappable type cannot contain static members}}
+  static const float S2sc; // expected-note 4 {{mappable type cannot contain static members}}
+};
+const float S2::S2sc = 0;
+const S2 b;
+const S2 ba[5];
+class S3 {
+  int a;
+public:
+  S3():a(0) { }
+  S3(S3 ):a(s3.a) { }
+};
+const S3 c;
+const S3 ca[5];
+extern const int f;
+class S4 {
+  int a;
+  S4();
+  S4(const S4 );
+public:
+  S4(int v):a(v) { }
+};
+class S5 {
+  int a;
+  S5():a(0) {}
+  S5(const S5 ):a(s5.a) { }
+public:
+  S5(int v):a(v) { }
+};
+struct S6 {
+  int ii;
+  int aa[30];
+  float xx;
+  double *pp;
+};
+struct S7 {
+  int i;
+  int a[50];
+  float x;
+  S6 s6[5];
+  double *p;
+  unsigned bfa : 4;
+};
+
+S3 h;
+#pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}}
+
+typedef int from;
+
+template  // expected-note {{declared here}}
+T tmain(T argc) {
+  const T d = 5;
+  const T da[5] = { 0 };
+  S4 e(4);
+  S5 g(5);
+  T *m;
+  T i, t[20];
+  T  = i;
+  T *k = 
+  T x;
+  T y;
+  T to;
+  const T ()[5] = da;
+  S7 s7;
+
+#pragma omp target update to // expected-error {{expected '(' after 'to'}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
+#pragma omp target update to( // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected expression}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
+#pragma omp target update to() // expected-error {{expected expression}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
+#pragma omp target update() // expected-warning {{extra tokens at the end of '#pragma omp target update' are ignored}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
+#pragma omp target update to(alloc) // expected-error {{use of undeclared identifier 'alloc'}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
+#pragma omp target update to(x)
+#pragma omp target update to(t[:I])
+#pragma omp target update to(T) // expected-error {{'T' does not refer to a value}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
+#pragma omp target update to(I) // expected-error 2 {{expected expression containing only member accesses and/or array sections based on named variables}}
+#pragma omp target update to(S2::S2s)
+#pragma omp target update to(S2::S2sc)
+#pragma omp target update to(to)
+#pragma omp target update to(y x) // expected-error {{expected ',' or ')' in 'to' clause}}
+#pragma omp target update to(argc > 0 ? x : y) // expected-error 2 {{expected expression containing only member accesses and/or array sections based on named variables}} 
+#pragma omp target update to(S1) 

Re: [PATCH] D18597: [OpenMP] Parsing and sema support for the to clause

2016-05-25 Thread Samuel Antao via cfe-commits
sfantao added a comment.

Hi Alexey,

Thanks for the review.



Comment at: lib/Sema/SemaOpenMP.cpp:10218-10220
@@ +10217,5 @@
+Sema , DSAStackTy *DSAS, OpenMPClauseKind CKind,
+ArrayRef VarList, SmallVector ,
+OMPClauseMappableExprCommon::MappableExprComponentLists ,
+SmallVector ,
+SourceLocation StartLoc, OpenMPMapClauseKind MapType = OMPC_MAP_unknown,

ABataev wrote:
> 1. Use SmallVectorImpl instead of SmallVector.
> 2. Is it possible to reduce number of arguments of this function by gathering 
> them into a record?
Ok, I created a new container that I named `MappableVarListInfo` to keep all 
the required lists. I now pass that container instead of the four lists. Hope 
this is more or less what you had in mind.


Comment at: lib/Sema/SemaOpenMP.cpp:10226-10235
@@ -10196,13 +10225,12 @@
+ "Unexpected clause kind with mappable expressions!");
 
   // Keep track of the mappable components and base declarations in this 
clause.
   // Each entry in the list is going to have a list of components associated. 
We
   // record each set of the components so that we can build the clause later 
on.
   // In the end we should have the same amount of declarations and component
   // lists.
-  OMPClauseMappableExprCommon::MappableExprComponentLists ClauseComponents;
-  SmallVector ClauseBaseDeclarations;
-
   ClauseComponents.reserve(VarList.size());
   ClauseBaseDeclarations.reserve(VarList.size());
 
   for (auto  : VarList) {
+assert(RE && "Null expr in omp to/map clause");

Just noticed these things were unanswered. This comment was prior to the map 
clause patch, so now all data members cases are tested in the upstreamed 
regression tests.


Comment at: lib/Sema/SemaOpenMP.cpp:10237-10241
@@ -10210,6 +10236,7 @@
+assert(RE && "Null expr in omp to/map clause");
 if (isa(RE)) {
   // It will be analyzed later.
   Vars.push_back(RE);
   continue;
 }
 SourceLocation ELoc = RE->getExprLoc();

ABataev wrote:
> Still think that this check is not required.
Correct, this is not needed. Sorry, forgot to remove that in the previous diff.


Comment at: lib/Sema/SemaOpenMP.cpp:10353
@@ +10352,3 @@
+  // from, release, or delete.
+  DKind = DSAS->getCurrentDirective();
+  if (DKind == OMPD_target_exit_data &&

ABataev wrote:
> You already get DKind few lines above, why need to update it?
Right, I don't. I removed the latest diff.


Comment at: test/OpenMP/nesting_of_regions.cpp:136
@@ -135,1 +135,3 @@
   }
+#pragma omp parallel
+  {

ABataev wrote:
> Test 'nesting_of_regions.cpp' should be updated only when adding a new 
> directive, not a clause.
Ok, I added the nesting tests to the dependence patch 
http://reviews.llvm.org/D15944.

I only do a few changes in this patch to use a clause because that allows me to 
remove the expected errors "need to/from clause" that are unrelated with 
nesting. These errors are already checked by the other tests.


http://reviews.llvm.org/D18597



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


Re: [PATCH] D20608: clang-cl: Treat dllimport explicit template instantiation definitions as declarations (PR27810, PR27811)

2016-05-25 Thread Hans Wennborg via cfe-commits
hans updated this revision to Diff 58484.
hans added a comment.

Fix the "dllexport trumps" comment, and add a test.


http://reviews.llvm.org/D20608

Files:
  lib/Sema/SemaTemplate.cpp
  test/CodeGenCXX/dllexport.cpp
  test/CodeGenCXX/dllimport.cpp

Index: test/CodeGenCXX/dllimport.cpp
===
--- test/CodeGenCXX/dllimport.cpp
+++ test/CodeGenCXX/dllimport.cpp
@@ -656,7 +656,7 @@
 
 namespace Vtordisp {
   // Don't dllimport the vtordisp.
-  // MO1-DAG: define linkonce_odr x86_thiscallcc void @"\01?f@?$C@D@Vtordisp@@$4PPPM@A@AEXXZ"
+  // MO1-DAG: define linkonce_odr x86_thiscallcc void @"\01?f@?$C@H@Vtordisp@@$4PPPM@A@AEXXZ"
 
   class Base {
 virtual void f() {}
@@ -667,7 +667,7 @@
 C() {}
 virtual void f() {}
   };
-  template class C;
+  USECLASS(C);
 }
 
 namespace ClassTemplateStaticDef {
@@ -698,26 +698,31 @@
   template  struct A { static NonPOD x; };
   template  NonPOD A::x;
   template struct __declspec(dllimport) A;
-  // MSC-DAG: @"\01?x@?$A@H@PR19933@@2UNonPOD@2@A" = available_externally dllimport global %"struct.PR19933::NonPOD" zeroinitializer
+  USEVARTYPE(NonPOD, A::x);
+  // MSC-DAG: @"\01?x@?$A@H@PR19933@@2UNonPOD@2@A" = external dllimport global %"struct.PR19933::NonPOD"
 
   int f();
   template  struct B { static int x; };
   template  int B::x = f();
   template struct __declspec(dllimport) B;
-  // MSC-DAG: @"\01?x@?$B@H@PR19933@@2HA" = available_externally dllimport global i32 0
+  USEVAR(B::x);
+  // MSC-DAG: @"\01?x@?$B@H@PR19933@@2HA" = external dllimport global i32
 
   constexpr int g() { return 42; }
   template  struct C { static int x; };
   template  int C::x = g();
   template struct __declspec(dllimport) C;
-  // MSC-DAG: @"\01?x@?$C@H@PR19933@@2HA" = available_externally dllimport global i32 42
+  USEVAR(C::x);
+  // MSC-DAG: @"\01?x@?$C@H@PR19933@@2HA" = external dllimport global i32
 
   template  struct D { static int x, y; };
   template  int D::x = I + 1;
   template  int D::y = I + f();
   template struct __declspec(dllimport) D<42>;
-  // MSC-DAG: @"\01?x@?$D@$0CK@@PR19933@@2HA" = available_externally dllimport global i32 43
-  // MSC-DAG: @"\01?y@?$D@$0CK@@PR19933@@2HA" = available_externally dllimport global i32 0
+  USEVAR(D<42>::x);
+  USEVAR(D<42>::y);
+  // MSC-DAG: @"\01?x@?$D@$0CK@@PR19933@@2HA" = external dllimport global i32
+  // MSC-DAG: @"\01?y@?$D@$0CK@@PR19933@@2HA" = external dllimport global i32
 }
 
 namespace PR21355 {
@@ -805,6 +810,36 @@
 USEMEMFUNC(PR23770BaseTemplate, f);
 // M32-DAG: declare dllimport x86_thiscallcc void @"\01?f@?$PR23770BaseTemplate@H@@QAEXXZ"
 
+namespace PR27810 {
+  template 
+  struct basic_ostream {
+struct sentry {
+  sentry() { }
+  void foo() { }
+};
+  };
+  template class __declspec(dllimport) basic_ostream;
+  // The explicit instantiation definition acts as an explicit instantiation
+  // *declaration*, dllimport is not inherited by the inner class, and no
+  // functions are emitted unless they are used.
+
+  USEMEMFUNC(basic_ostream::sentry, foo);
+  // M32-DAG: {{declare|define available_externally}} x86_thiscallcc void @"\01?foo@sentry@?$basic_ostream@D@PR27810@@QAEXXZ"
+  // M32-NOT: ??0sentry@?$basic_ostream@D@PR27810@@QAE@XZ
+}
+
+namespace PR27811 {
+  template  struct codecvt {
+virtual ~codecvt() { }
+  };
+  template class __declspec(dllimport) codecvt;
+
+  // dllimport means this explicit instantiation definition gets treated as a
+  // declaration. Thus, the vtable should not be marked used, and in fact
+  // nothing for this class should be emitted at all since it's not used.
+  // M32-NOT: codecvt
+}
+
 //===--===//
 // Classes with template base classes
 //===--===//
Index: test/CodeGenCXX/dllexport.cpp
===
--- test/CodeGenCXX/dllexport.cpp
+++ test/CodeGenCXX/dllexport.cpp
@@ -844,6 +844,11 @@
 // M32-DAG: define weak_odr dllexport x86_thiscallcc void @"\01??_FB@pr26490@@QAEXXZ"
 }
 
+// dllexport trumps dllexport on an explicit instantiation.
+template  struct ExplicitInstantiationTwoAttributes { void f() {} };
+template struct __declspec(dllexport) __declspec(dllimport) ExplicitInstantiationTwoAttributes;
+// M32-DAG: define weak_odr dllexport x86_thiscallcc void @"\01?f@?$ExplicitInstantiationTwoAttributes@H@@QAEXXZ"
+
 
 //===--===//
 // Classes with template base classes
@@ -958,14 +963,6 @@
 // M32-DAG: define weak_odr dllexport x86_thiscallcc void @"\01?func@?$ExplicitInstantiationDeclTemplateBase@H@@QAEXXZ"
 // G32-DAG: define weak_odr x86_thiscallcc void @_ZN37ExplicitInstantiationDeclTemplateBaseIiE4funcEv
 
-template  struct ExplicitInstantiationDeclTemplateBase2 { void func() {} };
-extern template struct 

Re: [PATCH] D20608: clang-cl: Treat dllimport explicit template instantiation definitions as declarations (PR27810, PR27811)

2016-05-25 Thread Hans Wennborg via cfe-commits
hans added inline comments.


Comment at: lib/Sema/SemaTemplate.cpp:7382
@@ +7381,3 @@
+  if (A->getKind() == AttributeList::AT_DLLExport) {
+// dllexport trumps dllexport here.
+DLLImport = false;

thakis wrote:
> trumps _dllimport_ here
> 
> (test?)
Done. Adding a test to dllexport.cpp.


Comment at: lib/Sema/SemaTemplate.cpp:7451
@@ -7423,1 +7450,3 @@
+  HasNoEffect = false;
+}
   }

thakis wrote:
> does moving this here change behavior? if so, maybe add a test for that too.
Nope, this doesn't change anything.


http://reviews.llvm.org/D20608



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


[PATCH] D20640: [AMDGPU] Set default dwarf version to 2

2016-05-25 Thread Konstantin Zhuravlyov via cfe-commits
kzhuravl created this revision.
kzhuravl added a reviewer: tstellarAMD.
kzhuravl added a subscriber: cfe-commits.
Herald added a subscriber: kzhuravl.

http://reviews.llvm.org/D20640

Files:
  lib/Driver/ToolChains.h
  test/Driver/amdgpu-toolchain.c

Index: test/Driver/amdgpu-toolchain.c
===
--- test/Driver/amdgpu-toolchain.c
+++ test/Driver/amdgpu-toolchain.c
@@ -1,3 +1,6 @@
 // RUN: %clang -### -target amdgcn--amdhsa -x assembler -mcpu=kaveri %s 2>&1 | 
FileCheck -check-prefix=AS_LINK %s
 // AS_LINK: clang{{.*}} "-cc1as"
 // AS_LINK: ld.lld{{.*}} "-shared"
+
+// RUN: %clang -### -g -target amdgcn--amdhsa -mcpu=kaveri %s 2>&1 | FileCheck 
-check-prefix=DWARF_VER %s
+// DWARF_VER: "-dwarf-version=2"
Index: lib/Driver/ToolChains.h
===
--- lib/Driver/ToolChains.h
+++ lib/Driver/ToolChains.h
@@ -943,6 +943,7 @@
 public:
   AMDGPUToolChain(const Driver , const llvm::Triple ,
 const llvm::opt::ArgList );
+  unsigned GetDefaultDwarfVersion() const override { return 2; }
   bool IsIntegratedAssemblerDefault() const override { return true; }
 };
 


Index: test/Driver/amdgpu-toolchain.c
===
--- test/Driver/amdgpu-toolchain.c
+++ test/Driver/amdgpu-toolchain.c
@@ -1,3 +1,6 @@
 // RUN: %clang -### -target amdgcn--amdhsa -x assembler -mcpu=kaveri %s 2>&1 | FileCheck -check-prefix=AS_LINK %s
 // AS_LINK: clang{{.*}} "-cc1as"
 // AS_LINK: ld.lld{{.*}} "-shared"
+
+// RUN: %clang -### -g -target amdgcn--amdhsa -mcpu=kaveri %s 2>&1 | FileCheck -check-prefix=DWARF_VER %s
+// DWARF_VER: "-dwarf-version=2"
Index: lib/Driver/ToolChains.h
===
--- lib/Driver/ToolChains.h
+++ lib/Driver/ToolChains.h
@@ -943,6 +943,7 @@
 public:
   AMDGPUToolChain(const Driver , const llvm::Triple ,
 const llvm::opt::ArgList );
+  unsigned GetDefaultDwarfVersion() const override { return 2; }
   bool IsIntegratedAssemblerDefault() const override { return true; }
 };
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20632: clang-format: [JS] Support shebang lines on the very first line.

2016-05-25 Thread Daniel Jasper via cfe-commits
djasper added a comment.

That's the same for #include directives (with <>). Just turn the tokens into 
TT_ImplicitStringLiteral, same as is done for #includes. I am not saying it's 
better, but I don't think we should have to different approaches..


http://reviews.llvm.org/D20632



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


Re: [PATCH] D20608: clang-cl: Treat dllimport explicit template instantiation definitions as declarations (PR27810, PR27811)

2016-05-25 Thread Nico Weber via cfe-commits
thakis accepted this revision.
This revision is now accepted and ready to land.


Comment at: lib/Sema/SemaTemplate.cpp:7382
@@ +7381,3 @@
+  if (A->getKind() == AttributeList::AT_DLLExport) {
+// dllexport trumps dllexport here.
+DLLImport = false;

trumps _dllimport_ here

(test?)


Comment at: lib/Sema/SemaTemplate.cpp:7451
@@ -7423,1 +7450,3 @@
+  HasNoEffect = false;
+}
   }

does moving this here change behavior? if so, maybe add a test for that too.


http://reviews.llvm.org/D20608



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


Re: [PATCH] D20614: Remove trailing spaces in x86 intrinsic headers

2016-05-25 Thread Katya Romanova via cfe-commits
kromanova updated this revision to Diff 58472.
kromanova added a comment.

I attached full svn diff. Thank you Michael!

I had to clean up the trailing spaces from doxygen comments (because it mess up 
our post-processing scripts), but since I was doing it, I decided to clean up 
the rest of the header files in the intrinsics header directory. That's why 
some of the files that you recently touched were affected.


Repository:
  rL LLVM

http://reviews.llvm.org/D20614

Files:
  __wmmintrin_aes.h
  __wmmintrin_pclmul.h
  avx512fintrin.h
  avx512vldqintrin.h
  mwaitxintrin.h
  pmmintrin.h

Index: pmmintrin.h
===
--- pmmintrin.h
+++ pmmintrin.h
@@ -31,9 +31,9 @@
   __attribute__((__always_inline__, __nodebug__, __target__("sse3")))
 
 /// \brief Loads data from an unaligned memory location to elements in a 128-bit
-///vector. If the address of the data is not 16-byte aligned, the 
-///instruction may read two adjacent aligned blocks of memory to retrieve 
-///the requested data. 
+///vector. If the address of the data is not 16-byte aligned, the
+///instruction may read two adjacent aligned blocks of memory to retrieve
+///the requested data.
 ///
 /// \headerfile 
 ///
@@ -75,14 +75,14 @@
 /// This intrinsic corresponds to the \c VHADDPS instruction.
 ///
 /// \param __a
-///A 128-bit vector of [4 x float] containing one of the source operands. 
-///The horizontal sums of the values are stored in the lower bits of the 
+///A 128-bit vector of [4 x float] containing one of the source operands.
+///The horizontal sums of the values are stored in the lower bits of the
 ///destination.
 /// \param __b
-///A 128-bit vector of [4 x float] containing one of the source operands. 
-///The horizontal sums of the values are stored in the upper bits of the 
+///A 128-bit vector of [4 x float] containing one of the source operands.
+///The horizontal sums of the values are stored in the upper bits of the
 ///destination.
-/// \returns A 128-bit vector of [4 x float] containing the horizontal sums of 
+/// \returns A 128-bit vector of [4 x float] containing the horizontal sums of
 ///both operands.
 static __inline__ __m128 __DEFAULT_FN_ATTRS
 _mm_hadd_ps(__m128 __a, __m128 __b)
@@ -98,14 +98,14 @@
 /// This intrinsic corresponds to the \c VHSUBPS instruction.
 ///
 /// \param __a
-///A 128-bit vector of [4 x float] containing one of the source operands. 
-///The horizontal differences between the values are stored in the lower 
+///A 128-bit vector of [4 x float] containing one of the source operands.
+///The horizontal differences between the values are stored in the lower
 ///bits of the destination.
 /// \param __b
-///A 128-bit vector of [4 x float] containing one of the source operands. 
-///The horizontal differences between the values are stored in the upper 
+///A 128-bit vector of [4 x float] containing one of the source operands.
+///The horizontal differences between the values are stored in the upper
 ///bits of the destination.
-/// \returns A 128-bit vector of [4 x float] containing the horizontal 
+/// \returns A 128-bit vector of [4 x float] containing the horizontal
 ///differences of both operands.
 static __inline__ __m128 __DEFAULT_FN_ATTRS
 _mm_hsub_ps(__m128 __a, __m128 __b)
@@ -168,28 +168,28 @@
 ///A 128-bit vector of [2 x double] containing the left source operand.
 /// \param __b
 ///A 128-bit vector of [2 x double] containing the right source operand.
-/// \returns A 128-bit vector of [2 x double] containing the alternating sums 
+/// \returns A 128-bit vector of [2 x double] containing the alternating sums
 ///and differences of both operands.
 static __inline__ __m128d __DEFAULT_FN_ATTRS
 _mm_addsub_pd(__m128d __a, __m128d __b)
 {
   return __builtin_ia32_addsubpd((__v2df)__a, (__v2df)__b);
 }
 
-/// \brief Horizontally adds the pairs of values contained in two 128-bit 
+/// \brief Horizontally adds the pairs of values contained in two 128-bit
 ///vectors of [2 x double].
 ///
 /// \headerfile 
 ///
 /// This intrinsic corresponds to the \c VHADDPD instruction.
 ///
 /// \param __a
-///A 128-bit vector of [2 x double] containing one of the source operands. 
-///The horizontal sum of the values is stored in the lower bits of the 
+///A 128-bit vector of [2 x double] containing one of the source operands.
+///The horizontal sum of the values is stored in the lower bits of the
 ///destination.
 /// \param __b
-///A 128-bit vector of [2 x double] containing one of the source operands. 
-///The horizontal sum of the values is stored in the upper bits of the 
+///A 128-bit vector of [2 x double] containing one of the source operands.
+///The horizontal sum of the values is stored in the upper bits of the
 ///destination.
 /// \returns A 128-bit vector of [2 x double] 

Re: [PATCH] D20630: [OpenCL] Allow -std=cl|CL1.1|CL1.2|CL2.0 in driver

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

Revised as Richard suggested.


http://reviews.llvm.org/D20630

Files:
  lib/Frontend/CompilerInvocation.cpp
  test/Driver/opencl.cl
  test/Frontend/stdlang.c

Index: test/Frontend/stdlang.c
===
--- test/Frontend/stdlang.c
+++ test/Frontend/stdlang.c
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 -x cuda -std=c++11 -DCUDA %s
 // RUN: %clang_cc1 -x cl -DOPENCL %s
-// RUN: %clang_cc1 -x cl -cl-std=CL -DOPENCL %s
+// RUN: %clang_cc1 -x cl -cl-std=cl -DOPENCL %s
 // RUN: %clang_cc1 -x cl -cl-std=CL1.1 -DOPENCL %s
 // RUN: %clang_cc1 -x cl -cl-std=CL1.2 -DOPENCL %s
 // RUN: %clang_cc1 -x cl -cl-std=CL2.0 -DOPENCL %s
Index: test/Driver/opencl.cl
===
--- /dev/null
+++ test/Driver/opencl.cl
@@ -0,0 +1,11 @@
+// RUN: %clang -S %s
+// RUN: %clang -S -std=cl %s
+// RUN: %clang -S -std=CL1.1 %s
+// RUN: %clang -S -std=CL1.2 %s
+// RUN: %clang -S -std=CL2.0 %s
+// RUN: not %clang -S -std=c99 -DOPENCL %s 2>&1 | FileCheck 
--check-prefix=CHECK-C99 %s
+// RUN: not %clang -S  -std=invalid -DOPENCL %s 2>&1 | FileCheck 
--check-prefix=CHECK-INVALID %s
+// CHECK-C99: error: invalid argument '-std=c99' not allowed with 'OpenCL'
+// CHECK-INVALID: error: invalid value 'invalid' in '-std=invalid'
+
+kernel void func(void){}
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -1398,6 +1398,13 @@
 Opts.AddVFSOverlayFile(A->getValue());
 }
 
+bool isOpenCL(LangStandard::Kind LangStd) {
+  return LangStd == LangStandard::lang_opencl
+|| LangStd == LangStandard::lang_opencl11
+|| LangStd == LangStandard::lang_opencl12
+|| LangStd == LangStandard::lang_opencl20;
+}
+
 void CompilerInvocation::setLangDefaults(LangOptions , InputKind IK,
  const llvm::Triple ,
  LangStandard::Kind LangStd) {
@@ -1462,7 +1469,7 @@
   Opts.ImplicitInt = Std.hasImplicitInt();
 
   // Set OpenCL Version.
-  Opts.OpenCL = LangStd == LangStandard::lang_opencl || IK == IK_OpenCL;
+  Opts.OpenCL = isOpenCL(LangStd) || IK == IK_OpenCL;
   if (LangStd == LangStandard::lang_opencl)
 Opts.OpenCLVersion = 100;
   else if (LangStd == LangStandard::lang_opencl11)
@@ -1555,8 +1562,9 @@
 << A->getAsString(Args) << "C++/ObjC++";
 break;
   case IK_OpenCL:
-Diags.Report(diag::err_drv_argument_not_allowed_with)
-  << A->getAsString(Args) << "OpenCL";
+if (!isOpenCL(LangStd))
+  Diags.Report(diag::err_drv_argument_not_allowed_with)
+<< A->getAsString(Args) << "OpenCL";
 break;
   case IK_CUDA:
   case IK_PreprocessedCuda:
@@ -1575,7 +1583,7 @@
   if (const Arg *A = Args.getLastArg(OPT_cl_std_EQ)) {
 LangStandard::Kind OpenCLLangStd
 = llvm::StringSwitch(A->getValue())
-.Case("CL", LangStandard::lang_opencl)
+.Case("cl", LangStandard::lang_opencl)
 .Case("CL1.1", LangStandard::lang_opencl11)
 .Case("CL1.2", LangStandard::lang_opencl12)
 .Case("CL2.0", LangStandard::lang_opencl20)


Index: test/Frontend/stdlang.c
===
--- test/Frontend/stdlang.c
+++ test/Frontend/stdlang.c
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 -x cuda -std=c++11 -DCUDA %s
 // RUN: %clang_cc1 -x cl -DOPENCL %s
-// RUN: %clang_cc1 -x cl -cl-std=CL -DOPENCL %s
+// RUN: %clang_cc1 -x cl -cl-std=cl -DOPENCL %s
 // RUN: %clang_cc1 -x cl -cl-std=CL1.1 -DOPENCL %s
 // RUN: %clang_cc1 -x cl -cl-std=CL1.2 -DOPENCL %s
 // RUN: %clang_cc1 -x cl -cl-std=CL2.0 -DOPENCL %s
Index: test/Driver/opencl.cl
===
--- /dev/null
+++ test/Driver/opencl.cl
@@ -0,0 +1,11 @@
+// RUN: %clang -S %s
+// RUN: %clang -S -std=cl %s
+// RUN: %clang -S -std=CL1.1 %s
+// RUN: %clang -S -std=CL1.2 %s
+// RUN: %clang -S -std=CL2.0 %s
+// RUN: not %clang -S -std=c99 -DOPENCL %s 2>&1 | FileCheck --check-prefix=CHECK-C99 %s
+// RUN: not %clang -S  -std=invalid -DOPENCL %s 2>&1 | FileCheck --check-prefix=CHECK-INVALID %s
+// CHECK-C99: error: invalid argument '-std=c99' not allowed with 'OpenCL'
+// CHECK-INVALID: error: invalid value 'invalid' in '-std=invalid'
+
+kernel void func(void){}
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -1398,6 +1398,13 @@
 Opts.AddVFSOverlayFile(A->getValue());
 }
 
+bool isOpenCL(LangStandard::Kind LangStd) {
+  return LangStd == LangStandard::lang_opencl
+|| LangStd == LangStandard::lang_opencl11
+|| LangStd == LangStandard::lang_opencl12
+|| LangStd == LangStandard::lang_opencl20;
+}
+
 void 

Re: Builder llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast is back to normal

2016-05-25 Thread Galina Kistanova via cfe-commits
A factory required a successful step of removing the llvm.obj directory,
which could be missing in some cases.

The fix is committed as r270773

Thanks

Galina

On Wed, May 25, 2016 at 12:22 PM, Sean Silva  wrote:

> What was the issue?
>
> On Wed, May 25, 2016 at 12:17 PM, Galina Kistanova via llvm-commits <
> llvm-comm...@lists.llvm.org> wrote:
>
>> Hello,
>>
>> Builder
>> http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast
>> is back to normal.
>> Sorry for the noise.
>>
>> Thanks
>>
>> Galina
>>
>> ___
>> llvm-commits mailing list
>> llvm-comm...@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>>
>>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20621: [include-fixer] Create a mode in vim integration to show multiple potential headers.

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


Comment at: include-fixer/tool/clang-include-fixer.py:84
@@ +83,3 @@
+index = 1;
+for header in lines[1:]:
+  choices_message += "&" + str(index) + header + "\n"

ioeric wrote:
> If there is only one candidate, it doesn't make sense to ask users to choose 
> it IMO. We can simply insert the header in this case.
> 
> And I think we should make users pick the correct header if there are 
> multiple candidates by default. What do you think, Ben? @bkramer
I agree, we should ask by default when there is more than one suggested header.


http://reviews.llvm.org/D20621



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


Re: [PATCH] D20621: [include-fixer] Create a mode in vim integration to show multiple potential headers.

2016-05-25 Thread Eric Liu via cfe-commits
ioeric added inline comments.


Comment at: include-fixer/IncludeFixer.cpp:241
@@ +240,3 @@
+  IncludeFixerContext
+  GetIncludeFixerContext(const clang::SourceManager ,
+ clang::HeaderSearch ) {

I think function name should start with lower case in llvm. 


Comment at: include-fixer/IncludeFixer.h:70
@@ +69,3 @@
+/// \return Replacements for inserting and sorting headers.
+std::vector CreateReplacementsForHeader(
+StringRef Code, StringRef FilePath, StringRef FallbackStyle,

Function name should start with lower case.


Comment at: include-fixer/tool/ClangIncludeFixer.cpp:211
@@ +210,3 @@
+
+  if (OuputHeaders) {
+// FIXME: Output IncludeFixerContext as YAML.

I'd put this before creating replacements and right after you get the context 
since those replacements are not used here. And the "Added #include..." message 
above doesn't make sense in this mode.


Comment at: include-fixer/tool/clang-include-fixer.py:49
@@ +48,3 @@
+  default_choice_index)
+  return int(vim.eval(to_eval));
+

Maybe handle cases where `to_eval` is not a valid index?


Comment at: include-fixer/tool/clang-include-fixer.py:84
@@ +83,3 @@
+index = 1;
+for header in lines[1:]:
+  choices_message += "&" + str(index) + header + "\n"

If there is only one candidate, it doesn't make sense to ask users to choose it 
IMO. We can simply insert the header in this case.

And I think we should make users pick the correct header if there are multiple 
candidates by default. What do you think, Ben? @bkramer


http://reviews.llvm.org/D20621



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


Re: [PATCH] D20632: clang-format: [JS] Support shebang lines on the very first line.

2016-05-25 Thread Martin Probst via cfe-commits
mprobst added a comment.

How would I disable the formatting using that way?

When I special case `parsePreprocessorDirective()`, consume the line, and 
return `LT_ImportStatement`, clang-format still tries to format tokens within 
the shebang. E.g. I get `#!/usr/bin / env node`, note the whitespace after 
`bin`.

Turning the shebang into a comment seems like it has the advantage of being 
safe, its contents should simply never be touched.


http://reviews.llvm.org/D20632



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


Re: Builder llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast is back to normal

2016-05-25 Thread Sean Silva via cfe-commits
What was the issue?

On Wed, May 25, 2016 at 12:17 PM, Galina Kistanova via llvm-commits <
llvm-comm...@lists.llvm.org> wrote:

> Hello,
>
> Builder
> http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast
> is back to normal.
> Sorry for the noise.
>
> Thanks
>
> Galina
>
> ___
> llvm-commits mailing list
> llvm-comm...@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Builder llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast is back to normal

2016-05-25 Thread Galina Kistanova via cfe-commits
Hello,

Builder
http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast
is back to normal.
Sorry for the noise.

Thanks

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


RE: [PATCH] D20630: [OpenCL] Allow -std=CL|CL1.1|CL1.2|CL2.0 in driver

2016-05-25 Thread Liu, Yaxun (Sam) via cfe-commits
I will fix that. Thanks.

Sam

From: meta...@gmail.com [mailto:meta...@gmail.com] On Behalf Of Richard Smith
Sent: Wednesday, May 25, 2016 2:54 PM
To: Liu, Yaxun (Sam) ; 
reviews+d20630+public+1c58d99d1f368...@reviews.llvm.org
Cc: alexey.ba...@intel.com; Anastasia Stulova ; 
cfe-commits 
Subject: Re: [PATCH] D20630: [OpenCL] Allow -std=CL|CL1.1|CL1.2|CL2.0 in driver


On 25 May 2016 9:13 a.m., "Yaxun Liu via cfe-commits" 
> wrote:
>
> yaxunl created this revision.
> yaxunl added a reviewer: Anastasia.
> yaxunl added subscribers: pxli168, bader, tstellarAMD, cfe-commits.
>
> Fix a regression which forbids using -std=CL|CL1.1|CL1.2|CL2.0 in driver.
>
> Changed -std=cl to -std=CL to match -cl-std=CL.

This is inconsistent with our existing command-line interface. It would be more 
consistent to change -cl-std= to accept lowercase cl instead.

> http://reviews.llvm.org/D20630
>
> Files:
>   include/clang/Frontend/LangStandards.def
>   lib/Frontend/CompilerInvocation.cpp
>   test/Driver/opencl.cl
>
> Index: test/Driver/opencl.cl
> ===
> --- /dev/null
> +++ test/Driver/opencl.cl
> @@ -0,0 +1,11 @@
> +// RUN: %clang %s
> +// RUN: %clang -std=CL %s
> +// RUN: %clang -std=CL1.1 %s
> +// RUN: %clang -std=CL1.2 %s
> +// RUN: %clang -std=CL2.0 %s
> +// RUN: not %clang_cc1 -std=c99 -DOPENCL %s 2>&1 | FileCheck 
> --check-prefix=CHECK-C99 %s
> +// RUN: not %clang_cc1 -std=invalid -DOPENCL %s 2>&1 | FileCheck 
> --check-prefix=CHECK-INVALID %s
> +// CHECK-C99: error: invalid argument '-std=c99' not allowed with 'OpenCL'
> +// CHECK-INVALID: error: invalid value 'invalid' in '-std=invalid'
> +
> +kernel void func(void);
> Index: lib/Frontend/CompilerInvocation.cpp
> ===
> --- lib/Frontend/CompilerInvocation.cpp
> +++ lib/Frontend/CompilerInvocation.cpp
> @@ -1398,6 +1398,13 @@
>  Opts.AddVFSOverlayFile(A->getValue());
>  }
>
> +bool isOpenCL(LangStandard::Kind LangStd) {
> +  return LangStd == LangStandard::lang_opencl
> +|| LangStd == LangStandard::lang_opencl11
> +|| LangStd == LangStandard::lang_opencl12
> +|| LangStd == LangStandard::lang_opencl20;
> +}
> +
>  void CompilerInvocation::setLangDefaults(LangOptions , InputKind IK,
>   const llvm::Triple ,
>   LangStandard::Kind LangStd) {
> @@ -1462,7 +1469,7 @@
>Opts.ImplicitInt = Std.hasImplicitInt();
>
>// Set OpenCL Version.
> -  Opts.OpenCL = LangStd == LangStandard::lang_opencl || IK == IK_OpenCL;
> +  Opts.OpenCL = isOpenCL(LangStd) || IK == IK_OpenCL;
>if (LangStd == LangStandard::lang_opencl)
>  Opts.OpenCLVersion = 100;
>else if (LangStd == LangStandard::lang_opencl11)
> @@ -1555,8 +1562,9 @@
>  << A->getAsString(Args) << "C++/ObjC++";
>  break;
>case IK_OpenCL:
> -Diags.Report(diag::err_drv_argument_not_allowed_with)
> -  << A->getAsString(Args) << "OpenCL";
> +if (!isOpenCL(LangStd))
> +  Diags.Report(diag::err_drv_argument_not_allowed_with)
> +<< A->getAsString(Args) << "OpenCL";
>  break;
>case IK_CUDA:
>case IK_PreprocessedCuda:
> Index: include/clang/Frontend/LangStandards.def
> ===
> --- include/clang/Frontend/LangStandards.def
> +++ include/clang/Frontend/LangStandards.def
> @@ -132,7 +132,7 @@
>   Digraphs | HexFloat | GNUMode)
>
>  // OpenCL
> -LANGSTANDARD(opencl, "cl",
> +LANGSTANDARD(opencl, "CL",
>   "OpenCL 1.0",
>   LineComment | C99 | Digraphs | HexFloat)
>  LANGSTANDARD(opencl11, "CL1.1",
>
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D15944: [OpenMP] Parsing and sema support for target update directive

2016-05-25 Thread Samuel Antao via cfe-commits
sfantao updated this revision to Diff 58469.
sfantao marked an inline comment as done.
sfantao added a comment.

- Add nestings test.


http://reviews.llvm.org/D15944

Files:
  include/clang-c/Index.h
  include/clang/AST/RecursiveASTVisitor.h
  include/clang/AST/StmtOpenMP.h
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Basic/OpenMPKinds.def
  include/clang/Basic/StmtNodes.td
  include/clang/Sema/Sema.h
  include/clang/Serialization/ASTBitCodes.h
  lib/AST/StmtOpenMP.cpp
  lib/AST/StmtPrinter.cpp
  lib/AST/StmtProfile.cpp
  lib/Basic/OpenMPKinds.cpp
  lib/CodeGen/CGStmt.cpp
  lib/CodeGen/CGStmtOpenMP.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/Parse/ParseOpenMP.cpp
  lib/Sema/SemaOpenMP.cpp
  lib/Sema/TreeTransform.h
  lib/Serialization/ASTReaderStmt.cpp
  lib/Serialization/ASTWriterStmt.cpp
  lib/StaticAnalyzer/Core/ExprEngine.cpp
  test/OpenMP/nesting_of_regions.cpp
  test/OpenMP/target_update_device_messages.cpp
  test/OpenMP/target_update_if_messages.cpp
  test/OpenMP/target_update_messages.cpp
  tools/libclang/CIndex.cpp
  tools/libclang/CXCursor.cpp

Index: tools/libclang/CXCursor.cpp
===
--- tools/libclang/CXCursor.cpp
+++ tools/libclang/CXCursor.cpp
@@ -612,6 +612,9 @@
   case Stmt::OMPTargetParallelForDirectiveClass:
 K = CXCursor_OMPTargetParallelForDirective;
 break;
+  case Stmt::OMPTargetUpdateDirectiveClass:
+K = CXCursor_OMPTargetUpdateDirective;
+break;
   case Stmt::OMPTeamsDirectiveClass:
 K = CXCursor_OMPTeamsDirective;
 break;
Index: tools/libclang/CIndex.cpp
===
--- tools/libclang/CIndex.cpp
+++ tools/libclang/CIndex.cpp
@@ -4798,6 +4798,8 @@
 return cxstring::createRef("OMPTargetParallelDirective");
   case CXCursor_OMPTargetParallelForDirective:
 return cxstring::createRef("OMPTargetParallelForDirective");
+  case CXCursor_OMPTargetUpdateDirective:
+return cxstring::createRef("OMPTargetUpdateDirective");
   case CXCursor_OMPTeamsDirective:
 return cxstring::createRef("OMPTeamsDirective");
   case CXCursor_OMPCancellationPointDirective:
Index: test/OpenMP/target_update_messages.cpp
===
--- /dev/null
+++ test/OpenMP/target_update_messages.cpp
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 %s
+
+void foo() {
+}
+
+bool foobool(int argc) {
+  return argc;
+}
+
+struct S1; // Aexpected-note {{declared here}}
+
+template  // Aexpected-note {{declared here}}
+int tmain(T argc, S **argv) {
+  int n;
+  return 0;
+}
+
+int main(int argc, char **argv) {
+  int m;
+  #pragma omp target update // expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
+  #pragma omp target update { // expected-warning {{extra tokens at the end of '#pragma omp target update' are ignored}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
+  #pragma omp target update ( // expected-warning {{extra tokens at the end of '#pragma omp target update' are ignored}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
+  #pragma omp target update [ // expected-warning {{extra tokens at the end of '#pragma omp target update' are ignored}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
+  #pragma omp target update ] // expected-warning {{extra tokens at the end of '#pragma omp target update' are ignored}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
+  #pragma omp target update ) // expected-warning {{extra tokens at the end of '#pragma omp target update' are ignored}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
+
+  #pragma omp target update // expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
+  {
+foo();
+  }
+  return tmain(argc, argv);
+}
Index: test/OpenMP/target_update_if_messages.cpp
===
--- /dev/null
+++ test/OpenMP/target_update_if_messages.cpp
@@ -0,0 +1,58 @@
+// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 %s
+
+void foo() {
+}
+
+bool foobool(int argc) {
+  return argc;
+}
+
+struct S1; // expected-note {{declared here}}
+
+template  // expected-note {{declared here}}
+int tmain(T argc, S **argv) {
+  int n;
+#pragma omp target update if // expected-error {{expected '(' after 'if'}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
+#pragma omp target update if ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error 

Re: [PATCH] D20407: [CodeGen][ObjC] zero-ext an i1 value to i8

2016-05-25 Thread John McCall via cfe-commits
rjmccall added inline comments.


Comment at: include/clang/AST/Type.h:1084
@@ +1083,3 @@
+  /// Strip typedefs and atomic from the given type.
+  QualType getDesugaredAtomicValueType(const ASTContext ) const;
+

Please name this getAtomicUnqualifiedType() and have it promise to remove all 
qualifiers including _Atomic.  It should not promise to remove type sugar.


Comment at: lib/AST/Type.cpp:1282
@@ +1281,3 @@
+  return *this;
+}
+

This should just be:
  if (auto AT = getAs()) {
return AT->getValueType().getUnqualifiedType();
  } else {
return getUnqualifiedType();
  }


Comment at: lib/CodeGen/CGObjC.cpp:901
@@ -903,1 +900,3 @@
+uint64_t IVarSize = getContext().toBits(strategy.getIvarSize());
+llvm::Type *bitcastType = llvm::Type::getIntNTy(getLLVMContext(), 
IVarSize);
 bitcastType = bitcastType->getPointerTo(); // addrspace 0 okay

The code around here uses lowercase identifiers, please be consistent.


Comment at: lib/CodeGen/CGObjC.cpp:1023
@@ -1014,1 +1022,3 @@
+value,
+ConvertType(propType.getDesugaredAtomicValueType(getContext(;
 value = Builder.CreateBitCast(

I don't understand the purpose of doing two bitcasts here, so let's just drop 
this first one.


Comment at: lib/Sema/SemaDeclObjC.cpp:4319
@@ +4318,3 @@
+  Context, MethodLoc, EndLoc, Sel,
+  resultDeclType.getDesugaredAtomicValueType(Context),
+  ReturnTInfo, CurContext, MethodType == tok::minus, isVariadic,

Hmm.  I'm not sure you should be doing this here; or at least, if we're going 
to do it, we should probably be doing it consistently in 
CheckFunctionReturnType.


Comment at: lib/Sema/SemaDeclObjC.cpp:4361
@@ -4361,1 +4360,3 @@
+ObjCMethod, StartLoc, ArgInfo[i].NameLoc, ArgInfo[i].Name,
+ArgType.getDesugaredAtomicValueType(Context), DI, SC_None);
 

Same thing.  If the user wants to explicitly declare a parameter _Atomic, they 
can do so.


Comment at: lib/Sema/SemaObjCProperty.cpp:1497
@@ -1496,2 +1496,3 @@
   QualType PropertyIvarType = property->getType().getNonReferenceType();
+  PropertyIvarType = PropertyIvarType.getDesugaredAtomicValueType(Context);
   bool compat = Context.hasSameType(PropertyIvarType, GetterType);

This is incorrect.  The property ivar type should definitely remain _Atomic if 
the property was declared that way.


Comment at: lib/Sema/SemaObjCProperty.cpp:2210
@@ -2209,1 +2209,3 @@
+QualType resultTy =
+property->getType().getDesugaredAtomicValueType(Context);
 if (property->getPropertyAttributes() &

Please pull this above the comment and give it its own comment, something like:
  // The getter returns the declared property type with all qualifiers removed.


Comment at: lib/Sema/SemaObjCProperty.cpp:2282
@@ -2279,2 +2281,3 @@
   QualType paramTy = property->getType().getUnqualifiedType();
+  paramTy = paramTy.getDesugaredAtomicValueType(Context);
   if (property->getPropertyAttributes() &

Same thing: please pull this above and give it its own comment.


http://reviews.llvm.org/D20407



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


Re: [PATCH] D20630: [OpenCL] Allow -std=CL|CL1.1|CL1.2|CL2.0 in driver

2016-05-25 Thread Richard Smith via cfe-commits
On 25 May 2016 9:13 a.m., "Yaxun Liu via cfe-commits" <
cfe-commits@lists.llvm.org> wrote:
>
> yaxunl created this revision.
> yaxunl added a reviewer: Anastasia.
> yaxunl added subscribers: pxli168, bader, tstellarAMD, cfe-commits.
>
> Fix a regression which forbids using -std=CL|CL1.1|CL1.2|CL2.0 in driver.
>
> Changed -std=cl to -std=CL to match -cl-std=CL.

This is inconsistent with our existing command-line interface. It would be
more consistent to change -cl-std= to accept lowercase cl instead.

> http://reviews.llvm.org/D20630
>
> Files:
>   include/clang/Frontend/LangStandards.def
>   lib/Frontend/CompilerInvocation.cpp
>   test/Driver/opencl.cl
>
> Index: test/Driver/opencl.cl
> ===
> --- /dev/null
> +++ test/Driver/opencl.cl
> @@ -0,0 +1,11 @@
> +// RUN: %clang %s
> +// RUN: %clang -std=CL %s
> +// RUN: %clang -std=CL1.1 %s
> +// RUN: %clang -std=CL1.2 %s
> +// RUN: %clang -std=CL2.0 %s
> +// RUN: not %clang_cc1 -std=c99 -DOPENCL %s 2>&1 | FileCheck
--check-prefix=CHECK-C99 %s
> +// RUN: not %clang_cc1 -std=invalid -DOPENCL %s 2>&1 | FileCheck
--check-prefix=CHECK-INVALID %s
> +// CHECK-C99: error: invalid argument '-std=c99' not allowed with
'OpenCL'
> +// CHECK-INVALID: error: invalid value 'invalid' in '-std=invalid'
> +
> +kernel void func(void);
> Index: lib/Frontend/CompilerInvocation.cpp
> ===
> --- lib/Frontend/CompilerInvocation.cpp
> +++ lib/Frontend/CompilerInvocation.cpp
> @@ -1398,6 +1398,13 @@
>  Opts.AddVFSOverlayFile(A->getValue());
>  }
>
> +bool isOpenCL(LangStandard::Kind LangStd) {
> +  return LangStd == LangStandard::lang_opencl
> +|| LangStd == LangStandard::lang_opencl11
> +|| LangStd == LangStandard::lang_opencl12
> +|| LangStd == LangStandard::lang_opencl20;
> +}
> +
>  void CompilerInvocation::setLangDefaults(LangOptions , InputKind IK,
>   const llvm::Triple ,
>   LangStandard::Kind LangStd) {
> @@ -1462,7 +1469,7 @@
>Opts.ImplicitInt = Std.hasImplicitInt();
>
>// Set OpenCL Version.
> -  Opts.OpenCL = LangStd == LangStandard::lang_opencl || IK == IK_OpenCL;
> +  Opts.OpenCL = isOpenCL(LangStd) || IK == IK_OpenCL;
>if (LangStd == LangStandard::lang_opencl)
>  Opts.OpenCLVersion = 100;
>else if (LangStd == LangStandard::lang_opencl11)
> @@ -1555,8 +1562,9 @@
>  << A->getAsString(Args) << "C++/ObjC++";
>  break;
>case IK_OpenCL:
> -Diags.Report(diag::err_drv_argument_not_allowed_with)
> -  << A->getAsString(Args) << "OpenCL";
> +if (!isOpenCL(LangStd))
> +  Diags.Report(diag::err_drv_argument_not_allowed_with)
> +<< A->getAsString(Args) << "OpenCL";
>  break;
>case IK_CUDA:
>case IK_PreprocessedCuda:
> Index: include/clang/Frontend/LangStandards.def
> ===
> --- include/clang/Frontend/LangStandards.def
> +++ include/clang/Frontend/LangStandards.def
> @@ -132,7 +132,7 @@
>   Digraphs | HexFloat | GNUMode)
>
>  // OpenCL
> -LANGSTANDARD(opencl, "cl",
> +LANGSTANDARD(opencl, "CL",
>   "OpenCL 1.0",
>   LineComment | C99 | Digraphs | HexFloat)
>  LANGSTANDARD(opencl11, "CL1.1",
>
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D20635: clang-rename: fix renaming heap allocations

2016-05-25 Thread Miklos Vajna via cfe-commits
vmiklos created this revision.
vmiklos added reviewers: klimek, cfe-commits.

The check failed, 'Cla *C = new Cla();' was renamed 'D *C = new Cla();'.

http://reviews.llvm.org/D20635

Files:
  clang-rename/USRLocFinder.cpp
  test/clang-rename/ConstructExpr.cpp

Index: test/clang-rename/ConstructExpr.cpp
===
--- /dev/null
+++ test/clang-rename/ConstructExpr.cpp
@@ -0,0 +1,14 @@
+// RUN: cat %s > %t.cpp
+// RUN: clang-rename -offset=133 -new-name=D %t.cpp -i --
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
+class Cla
+{
+};
+
+int main()
+{
+  Cla *C = new Cla(); // CHECK: D *C = new D();
+}
+
+// Use grep -FUbo 'Cla'  to get the correct offset of foo when changing
+// this file.
Index: clang-rename/USRLocFinder.cpp
===
--- clang-rename/USRLocFinder.cpp
+++ clang-rename/USRLocFinder.cpp
@@ -112,6 +112,17 @@
 return true;
   }
 
+  bool VisitCXXConstructExpr(const CXXConstructExpr *Expr) {
+CXXConstructorDecl *Decl = Expr->getConstructor();
+
+if (getUSRForDecl(Decl) == USR) {
+  // This takes care of 'new ' expressions.
+  LocationsFound.push_back(Expr->getLocation());
+}
+
+return true;
+  }
+
   // Non-visitors:
 
   // \brief Returns a list of unique locations. Duplicate or overlapping


Index: test/clang-rename/ConstructExpr.cpp
===
--- /dev/null
+++ test/clang-rename/ConstructExpr.cpp
@@ -0,0 +1,14 @@
+// RUN: cat %s > %t.cpp
+// RUN: clang-rename -offset=133 -new-name=D %t.cpp -i --
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
+class Cla
+{
+};
+
+int main()
+{
+  Cla *C = new Cla(); // CHECK: D *C = new D();
+}
+
+// Use grep -FUbo 'Cla'  to get the correct offset of foo when changing
+// this file.
Index: clang-rename/USRLocFinder.cpp
===
--- clang-rename/USRLocFinder.cpp
+++ clang-rename/USRLocFinder.cpp
@@ -112,6 +112,17 @@
 return true;
   }
 
+  bool VisitCXXConstructExpr(const CXXConstructExpr *Expr) {
+CXXConstructorDecl *Decl = Expr->getConstructor();
+
+if (getUSRForDecl(Decl) == USR) {
+  // This takes care of 'new ' expressions.
+  LocationsFound.push_back(Expr->getLocation());
+}
+
+return true;
+  }
+
   // Non-visitors:
 
   // \brief Returns a list of unique locations. Duplicate or overlapping
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20608: clang-cl: Treat dllimport explicit template instantiation definitions as declarations (PR27810, PR27811)

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

Thanks for the review!

In http://reviews.llvm.org/D20608#439480, @thakis wrote:

> Do we have test coverage for `template class __declspec(dllexport) 
> codecvt;` somewhere already?


Yes, that's covered by tests in CodeGenCXX/dllexport.cpp



Comment at: lib/Sema/SemaTemplate.cpp:7382
@@ +7381,3 @@
+  if (A->getKind() == AttributeList::AT_DLLExport)
+DLLImport = false;
+}

thakis wrote:
> If there are multiple dllexports and dllimports on an explicit instantiation, 
> cl.exe just silently picks the last one?
The intention here was really just to reset the DLLImport value if it were set 
on line 7376, i.e. the attribute on the instantiation should override any 
attribute on the template.

I didn't even consider putting both dllimport and dllexport on the 
specialization. What does MSVC do? Well..

```
template  struct S { void f() {} };
template struct __declspec(dllimport) __declspec(dllexport) S;
d:\src\tmp\a.cc(2) : warning C4141: 'dllexport' : used more than once
```

That diagnostic seems a little bit confused, but the effect on codegen is even 
more so. S::f() does not get defined here, which would suggest the 
instantiation def is treated as an instantiation decl on account of the 
dllimport. On the other hand, if I reference S::f, it gets defined and 
*exported*. We probably don't want to reproduce this.

Clang will generally let dllexport take precedence over dllimport when they're 
on the same declaration, and has a nice warning for it, so let's do that here 
too.


Comment at: lib/Sema/SemaTemplate.cpp:7467
@@ +7466,3 @@
+// The new specialization might add a dllimport attribute.
+HasNoEffect = false;
+  }

thakis wrote:
> HasNoEffect is read two times before it's updated here. Is it intentional 
> that you only change it after it's been read twice? If so, maybe add a 
> comment why, since it looks not intentional else. (And make sure there's test 
> coverage for setting it at the right time)
I wanted to do this after PrevDecl_TSK has been defined, but we can move this a 
little earlier. I'll do that.


http://reviews.llvm.org/D20608



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


Re: [PATCH] D20608: clang-cl: Treat dllimport explicit template instantiation definitions as declarations (PR27810, PR27811)

2016-05-25 Thread Hans Wennborg via cfe-commits
hans updated this revision to Diff 58461.
hans added a comment.

tweaks


http://reviews.llvm.org/D20608

Files:
  lib/Sema/SemaTemplate.cpp
  test/CodeGenCXX/dllexport.cpp
  test/CodeGenCXX/dllimport.cpp

Index: test/CodeGenCXX/dllimport.cpp
===
--- test/CodeGenCXX/dllimport.cpp
+++ test/CodeGenCXX/dllimport.cpp
@@ -656,7 +656,7 @@
 
 namespace Vtordisp {
   // Don't dllimport the vtordisp.
-  // MO1-DAG: define linkonce_odr x86_thiscallcc void @"\01?f@?$C@D@Vtordisp@@$4PPPM@A@AEXXZ"
+  // MO1-DAG: define linkonce_odr x86_thiscallcc void @"\01?f@?$C@H@Vtordisp@@$4PPPM@A@AEXXZ"
 
   class Base {
 virtual void f() {}
@@ -667,7 +667,7 @@
 C() {}
 virtual void f() {}
   };
-  template class C;
+  USECLASS(C);
 }
 
 namespace ClassTemplateStaticDef {
@@ -698,26 +698,31 @@
   template  struct A { static NonPOD x; };
   template  NonPOD A::x;
   template struct __declspec(dllimport) A;
-  // MSC-DAG: @"\01?x@?$A@H@PR19933@@2UNonPOD@2@A" = available_externally dllimport global %"struct.PR19933::NonPOD" zeroinitializer
+  USEVARTYPE(NonPOD, A::x);
+  // MSC-DAG: @"\01?x@?$A@H@PR19933@@2UNonPOD@2@A" = external dllimport global %"struct.PR19933::NonPOD"
 
   int f();
   template  struct B { static int x; };
   template  int B::x = f();
   template struct __declspec(dllimport) B;
-  // MSC-DAG: @"\01?x@?$B@H@PR19933@@2HA" = available_externally dllimport global i32 0
+  USEVAR(B::x);
+  // MSC-DAG: @"\01?x@?$B@H@PR19933@@2HA" = external dllimport global i32
 
   constexpr int g() { return 42; }
   template  struct C { static int x; };
   template  int C::x = g();
   template struct __declspec(dllimport) C;
-  // MSC-DAG: @"\01?x@?$C@H@PR19933@@2HA" = available_externally dllimport global i32 42
+  USEVAR(C::x);
+  // MSC-DAG: @"\01?x@?$C@H@PR19933@@2HA" = external dllimport global i32
 
   template  struct D { static int x, y; };
   template  int D::x = I + 1;
   template  int D::y = I + f();
   template struct __declspec(dllimport) D<42>;
-  // MSC-DAG: @"\01?x@?$D@$0CK@@PR19933@@2HA" = available_externally dllimport global i32 43
-  // MSC-DAG: @"\01?y@?$D@$0CK@@PR19933@@2HA" = available_externally dllimport global i32 0
+  USEVAR(D<42>::x);
+  USEVAR(D<42>::y);
+  // MSC-DAG: @"\01?x@?$D@$0CK@@PR19933@@2HA" = external dllimport global i32
+  // MSC-DAG: @"\01?y@?$D@$0CK@@PR19933@@2HA" = external dllimport global i32
 }
 
 namespace PR21355 {
@@ -805,6 +810,36 @@
 USEMEMFUNC(PR23770BaseTemplate, f);
 // M32-DAG: declare dllimport x86_thiscallcc void @"\01?f@?$PR23770BaseTemplate@H@@QAEXXZ"
 
+namespace PR27810 {
+  template 
+  struct basic_ostream {
+struct sentry {
+  sentry() { }
+  void foo() { }
+};
+  };
+  template class __declspec(dllimport) basic_ostream;
+  // The explicit instantiation definition acts as an explicit instantiation
+  // *declaration*, dllimport is not inherited by the inner class, and no
+  // functions are emitted unless they are used.
+
+  USEMEMFUNC(basic_ostream::sentry, foo);
+  // M32-DAG: {{declare|define available_externally}} x86_thiscallcc void @"\01?foo@sentry@?$basic_ostream@D@PR27810@@QAEXXZ"
+  // M32-NOT: ??0sentry@?$basic_ostream@D@PR27810@@QAE@XZ
+}
+
+namespace PR27811 {
+  template  struct codecvt {
+virtual ~codecvt() { }
+  };
+  template class __declspec(dllimport) codecvt;
+
+  // dllimport means this explicit instantiation definition gets treated as a
+  // declaration. Thus, the vtable should not be marked used, and in fact
+  // nothing for this class should be emitted at all since it's not used.
+  // M32-NOT: codecvt
+}
+
 //===--===//
 // Classes with template base classes
 //===--===//
Index: test/CodeGenCXX/dllexport.cpp
===
--- test/CodeGenCXX/dllexport.cpp
+++ test/CodeGenCXX/dllexport.cpp
@@ -958,14 +958,6 @@
 // M32-DAG: define weak_odr dllexport x86_thiscallcc void @"\01?func@?$ExplicitInstantiationDeclTemplateBase@H@@QAEXXZ"
 // G32-DAG: define weak_odr x86_thiscallcc void @_ZN37ExplicitInstantiationDeclTemplateBaseIiE4funcEv
 
-template  struct ExplicitInstantiationDeclTemplateBase2 { void func() {} };
-extern template struct ExplicitInstantiationDeclTemplateBase2;
-struct __declspec(dllexport) DerivedFromExplicitInstantiationDeclTemplateBase2 : public ExplicitInstantiationDeclTemplateBase2 {};
-template struct __declspec(dllimport) ExplicitInstantiationDeclTemplateBase2;
-USEMEMFUNC(ExplicitInstantiationDeclTemplateBase2, func)
-// M32-DAG: define weak_odr dllexport x86_thiscallcc void @"\01?func@?$ExplicitInstantiationDeclTemplateBase2@H@@QAEXXZ"
-// G32-DAG: define weak_odr x86_thiscallcc void @_ZN38ExplicitInstantiationDeclTemplateBase2IiE4funcEv
-
 // PR26076
 struct LayerSelectionBound;
 template  struct Selection {};
Index: 

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

2016-05-25 Thread Bruno Cardoso Lopes via cfe-commits
bruno added a comment.

You can probably find a way to test this by taking a look at 
unittests/Basic/VirtualFileSystemTest.cpp


Repository:
  rL LLVM

http://reviews.llvm.org/D20338



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


Re: [PATCH] D19274: Compilation for Intel MCU (Part 2/3)

2016-05-25 Thread Bruno Cardoso Lopes via cfe-commits
bruno added a comment.

Hi,



Comment at: lib/Driver/Tools.cpp:3657
@@ +3656,3 @@
+  if (IsIAMCU && types::isCXX(Input.getType()))
+D.Diag(diag::err_drv_cxx_not_supported) << 
getToolChain().getTriple().str();
+

Taking a look at this again I don't think there's a real need for a new 
diagnostic here; instead of adding diag::err_drv_cxx_not_supported, you can do 
something similar to:

D.Diag(diag::err_drv_clang_unsupported) << "C++ is not supported with -miamcu"

Otherwise, LGTM!


http://reviews.llvm.org/D19274



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


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

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

r270735


http://reviews.llvm.org/D20573



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


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

2016-05-25 Thread Ben Craig via cfe-commits
bcraig closed this revision.
bcraig added a comment.

r270732


http://reviews.llvm.org/D20574



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


Re: [PATCH] D20602: Add .rgba syntax extension to ext_vector_type types

2016-05-25 Thread Pirama Arumuga Nainar via cfe-commits
pirama added a comment.

To summarize, there are two scenarios where a warning is warranted when the 
source language is OpenCL:

> > I'm not suggesting it be treated as invalid. This extension is part of at 
> > least OpenCL 2.1, but it's not part of OpenCL 1.0. `ext_vector_type` is 
> > Clang's implementation of the OpenCL vector type. Therefore if the user 
> > asks us to support OpenCL 1.0, we should give them a warning if they use 
> > this syntax.

> 




- use of ext_vector_type in OpenCL 1.0 and earlier.

> To avoid confusion, I'd like to note that rgba selector was first introduced 
> in OpenCL C++ kernel language, which is currently in provisional state and 
> will be part of OpenCL version 2.2.




- use of rgba selector in OpenCL 2.1 and earlier.

I'll look at how to add the first warning.  I'll most probably upload a 
separate CL for this.

I can easily add the second warning in this CL - to emit one on *any* OpenCL 
source.  Alexey: can you take care of revising this warning when OpenCL2.2 is 
added as a langugage standard?


http://reviews.llvm.org/D20602



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


LLVM buildmaster will be restarted tonight

2016-05-25 Thread Galina Kistanova via cfe-commits
Hello everyone,

LLVM buildmaster will be updated and restarted after 6 PM Pacific time
today.

Thanks

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


Re: [PATCH] D20632: clang-format: [JS] Support shebang lines on the very first line.

2016-05-25 Thread Daniel Jasper via cfe-commits
djasper added a comment.

Thinking some more, I think this is actually very close to what we do for 
#include(-like) statements. That is done in TokenAnnotator::parseLine() and 
TokenAnnotator::parseIncludeDirective(). Could you move the logic there?


http://reviews.llvm.org/D20632



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


[libcxx] r270735 - [libcxx] Allow explicit pthread opt-in

2016-05-25 Thread Ben Craig via cfe-commits
Author: bcraig
Date: Wed May 25 12:40:09 2016
New Revision: 270735

URL: http://llvm.org/viewvc/llvm-project?rev=270735=rev
Log:
[libcxx] Allow explicit pthread opt-in

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

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

http://reviews.llvm.org/D20573

Modified:
libcxx/trunk/CMakeLists.txt
libcxx/trunk/include/__config
libcxx/trunk/include/__config_site.in
libcxx/trunk/include/__threading_support

Modified: libcxx/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/CMakeLists.txt?rev=270735=270734=270735=diff
==
--- libcxx/trunk/CMakeLists.txt (original)
+++ libcxx/trunk/CMakeLists.txt Wed May 25 12:40:09 2016
@@ -126,6 +126,7 @@ option(LIBCXX_ENABLE_MONOTONIC_CLOCK
   "Build libc++ with support for a monotonic clock.
This option may only be set to OFF when LIBCXX_ENABLE_THREADS=OFF." ON)
 option(LIBCXX_HAS_MUSL_LIBC "Build libc++ with support for the Musl C library" 
OFF)
+option(LIBCXX_HAS_PTHREAD_API "Ignore auto-detection and force use of pthread 
API" OFF)
 
 # Misc options 
 # FIXME: Turn -pedantic back ON. It is currently off because it warns
@@ -172,6 +173,11 @@ if(LIBCXX_ENABLE_THREADS AND NOT LIBCXX_
   " when LIBCXX_ENABLE_THREADS is also set to OFF.")
 endif()
 
+if(LIBCXX_HAS_PTHREAD_API AND NOT LIBCXX_ENABLE_THREADS)
+  message(FATAL_ERROR "LIBCXX_HAS_PTHREAD_API can only be set to ON"
+  " when LIBCXX_ENABLE_THREADS is also set to ON.")
+endif()
+
 # Ensure LLVM_USE_SANITIZER is not specified when LIBCXX_GENERATE_COVERAGE
 # is ON.
 if (LLVM_USE_SANITIZER AND LIBCXX_GENERATE_COVERAGE)
@@ -384,6 +390,7 @@ config_define_if_not(LIBCXX_ENABLE_THREA
 config_define_if_not(LIBCXX_ENABLE_MONOTONIC_CLOCK 
_LIBCPP_HAS_NO_MONOTONIC_CLOCK)
 config_define_if_not(LIBCXX_ENABLE_THREAD_UNSAFE_C_FUNCTIONS 
_LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS)
 
+config_define_if(LIBCXX_HAS_PTHREAD_API _LIBCPP_HAS_THREAD_API_PTHREAD)
 config_define_if(LIBCXX_HAS_MUSL_LIBC _LIBCPP_HAS_MUSL_LIBC)
 
 if (LIBCXX_NEEDS_SITE_CONFIG)

Modified: libcxx/trunk/include/__config
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=270735=270734=270735=diff
==
--- libcxx/trunk/include/__config (original)
+++ libcxx/trunk/include/__config Wed May 25 12:40:09 2016
@@ -813,19 +813,23 @@ extern "C" void __sanitizer_annotate_con
 #endif
 
 // Thread API
-#ifndef _LIBCPP_HAS_NO_THREADS
+#if !defined(_LIBCPP_HAS_NO_THREADS) && 
!defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
 # if defined(__FreeBSD__) || \
 defined(__NetBSD__) || \
 defined(__linux__) || \
 defined(__APPLE__) || \
 defined(__CloudABI__) || \
 defined(__sun__)
-#  define _LIBCPP_THREAD_API_PTHREAD
+#  define _LIBCPP_HAS_THREAD_API_PTHREAD
 # else
 #  error "No thread API"
-# endif // _LIBCPP_THREAD_API
+# endif // _LIBCPP_HAS_THREAD_API
 #endif // _LIBCPP_HAS_NO_THREADS
 
+#if defined(_LIBCPP_HAS_NO_THREADS) && defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
+#  error _LIBCPP_HAS_THREAD_API_PTHREAD may only be defined when \
+ _LIBCPP_HAS_NO_THREADS is not defined.
+#endif
 
 #if defined(_LIBCPP_HAS_NO_MONOTONIC_CLOCK) && !defined(_LIBCPP_HAS_NO_THREADS)
 #  error _LIBCPP_HAS_NO_MONOTONIC_CLOCK may only be defined when \

Modified: libcxx/trunk/include/__config_site.in
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config_site.in?rev=270735=270734=270735=diff
==
--- libcxx/trunk/include/__config_site.in (original)
+++ libcxx/trunk/include/__config_site.in Wed May 25 12:40:09 2016
@@ -19,5 +19,6 @@
 #cmakedefine _LIBCPP_HAS_NO_MONOTONIC_CLOCK
 #cmakedefine _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS
 #cmakedefine _LIBCPP_HAS_MUSL_LIBC
+#cmakedefine _LIBCPP_HAS_THREAD_API_PTHREAD
 
 #endif // _LIBCPP_CONFIG_SITE

Modified: libcxx/trunk/include/__threading_support
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__threading_support?rev=270735=270734=270735=diff
==
--- libcxx/trunk/include/__threading_support (original)
+++ libcxx/trunk/include/__threading_support Wed May 25 12:40:09 2016
@@ -19,14 +19,14 @@
 
 #ifndef _LIBCPP_HAS_NO_THREADS
 
-#if defined(_LIBCPP_THREAD_API_PTHREAD)
+#if defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
 #include 
 #include 
 #endif
 
 

Re: [PATCH] D20168: [CodeGen] Handle structs directly in AMDGPUABIInfo

2016-05-25 Thread Matt Arsenault via cfe-commits
arsenm added a comment.

Also some tests for non-kernel functions. We might want to keep this as byval 
for calling those


http://reviews.llvm.org/D20168



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


[libcxxabi] r270732 - Allow explicit pthread opt-in

2016-05-25 Thread Ben Craig via cfe-commits
Author: bcraig
Date: Wed May 25 12:37:38 2016
New Revision: 270732

URL: http://llvm.org/viewvc/llvm-project?rev=270732=rev
Log:
Allow explicit pthread opt-in

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

http://reviews.llvm.org/D20574

Modified:
libcxxabi/trunk/CMakeLists.txt

Modified: libcxxabi/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/CMakeLists.txt?rev=270732=270731=270732=diff
==
--- libcxxabi/trunk/CMakeLists.txt (original)
+++ libcxxabi/trunk/CMakeLists.txt Wed May 25 12:37:38 2016
@@ -113,6 +113,7 @@ option(LIBCXXABI_ENABLE_PEDANTIC "Compil
 option(LIBCXXABI_ENABLE_WERROR "Fail and stop if a warning is triggered." OFF)
 option(LIBCXXABI_USE_LLVM_UNWINDER "Build and use the LLVM unwinder." OFF)
 option(LIBCXXABI_ENABLE_THREADS "Build with threads enabled" ON)
+option(LIBCXXABI_HAS_PTHREAD_API "Ignore auto-detection and force use of 
pthread API" OFF)
 set(LIBCXXABI_GCC_TOOLCHAIN "" CACHE STRING "GCC toolchain for cross 
compiling.")
 set(LIBCXXABI_SYSROOT "" CACHE STRING "Sysroot for cross compiling.")
 set(LIBCXXABI_LIBCXX_LIBRARY_PATH "" CACHE STRING "The path to libc++ 
library.")
@@ -272,9 +273,18 @@ if (NOT LIBCXXABI_ENABLE_SHARED)
 endif()
 
 if (NOT LIBCXXABI_ENABLE_THREADS)
+  if (LIBCXXABI_HAS_PTHREAD_API)
+message(FATAL_ERROR "LIBCXXABI_HAS_PTHREAD_API can only"
+" be set to ON when LIBCXXABI_ENABLE_THREADS"
+" is also set to ON.")
+  endif()
   add_definitions(-DLIBCXXABI_HAS_NO_THREADS=1)
 endif()
 
+if (LIBCXXABI_HAS_PTHREAD_API)
+  add_definitions(-D_LIBCPP_HAS_THREAD_API_PTHREAD)
+endif()
+
 # This is the _ONLY_ place where add_definitions is called.
 if (MSVC)
   add_definitions(-D_CRT_SECURE_NO_WARNINGS)


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


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

2016-05-25 Thread Samuel Antao via cfe-commits
sfantao added a comment.

Hi Alexey,

Thanks for the review!



Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:5630-5639
@@ -5599,6 +5629,12 @@
   // type, the default is 'tofrom'.
   CurMapTypes.push_back(ElementType->isAggregateType()
 ? (MappableExprsHandler::OMP_MAP_TO |
MappableExprsHandler::OMP_MAP_FROM)
 : MappableExprsHandler::OMP_MAP_TO);
+
+  // If we have a capture by reference we may need to add the private
+  // pointer flag if the base declaration shows in some first-private
+  // clause.
+  CurMapTypes.back() = MCHandler.adjustMapModifiersForPrivateClauses(
+  CI, CurMapTypes.back());
 }

ABataev wrote:
> Maybe it is better to join all this code into a single function?
I agree. Moved all the default map information generation to a new function in 
the mappable expressions handler.


http://reviews.llvm.org/D20112



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


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

2016-05-25 Thread Samuel Antao via cfe-commits
sfantao updated this revision to Diff 58453.
sfantao marked an inline comment as done.
sfantao added a comment.

- Create function for the generation of the default map information.


http://reviews.llvm.org/D20112

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

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

r270728 - Use new triple API to check comdat /NFC

2016-05-25 Thread Xinliang David Li via cfe-commits
Author: davidxl
Date: Wed May 25 12:25:57 2016
New Revision: 270728

URL: http://llvm.org/viewvc/llvm-project?rev=270728=rev
Log:
Use new triple API to check comdat /NFC

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

Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=270728=270727=270728=diff
==
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Wed May 25 12:25:57 2016
@@ -7818,7 +7818,7 @@ const llvm::Triple ::getTr
 }
 
 bool CodeGenModule::supportsCOMDAT() const {
-  return !getTriple().isOSBinFormatMachO();
+  return getTriple().supportsCOMDAT();
 }
 
 const TargetCodeGenInfo ::getTargetCodeGenInfo() {


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


[PATCH] D20632: clang-format: [JS] Support shebang lines on the very first line.

2016-05-25 Thread Martin Probst via cfe-commits
mprobst created this revision.
mprobst added a reviewer: djasper.
mprobst added a subscriber: cfe-commits.
Herald added a subscriber: klimek.

Shebang lines (`#!/bin/blah`) can be used in JavaScript scripts to indicate
they should be run using e.g. node. This change treats # lines on the first line
as line comments.

http://reviews.llvm.org/D20632

Files:
  lib/Format/FormatTokenLexer.cpp
  lib/Format/FormatTokenLexer.h
  unittests/Format/FormatTestJS.cpp

Index: unittests/Format/FormatTestJS.cpp
===
--- unittests/Format/FormatTestJS.cpp
+++ unittests/Format/FormatTestJS.cpp
@@ -1272,5 +1272,12 @@
   verifyFormat("var x = 'foo';", LeaveQuotes);
 }
 
+TEST_F(FormatTestJS, SupportShebangLines) {
+  verifyFormat("#!/usr/bin/env node\n"
+   "var x = hello();",
+   "#!/usr/bin/env node\n"
+   "var x   =  hello();");
+}
+
 } // end namespace tooling
 } // end namespace clang
Index: lib/Format/FormatTokenLexer.h
===
--- lib/Format/FormatTokenLexer.h
+++ lib/Format/FormatTokenLexer.h
@@ -55,6 +55,8 @@
 
   void tryParseTemplateString();
 
+  void tryParseShebangLine();
+
   bool tryMerge_TMacro();
 
   bool tryMergeConflictMarkers();
Index: lib/Format/FormatTokenLexer.cpp
===
--- lib/Format/FormatTokenLexer.cpp
+++ lib/Format/FormatTokenLexer.cpp
@@ -20,6 +20,10 @@
 #include "clang/Format/Format.h"
 #include "llvm/Support/Regex.h"
 
+#include "llvm/Support/Debug.h"
+
+#define DEBUG_TYPE "format-formatter"
+
 namespace clang {
 namespace format {
 
@@ -50,8 +54,10 @@
 if (Style.Language == FormatStyle::LK_JavaScript) {
   tryParseJSRegexLiteral();
   tryParseTemplateString();
+  tryParseShebangLine();
 }
 tryMergePreviousTokens();
+
 if (Tokens.back()->NewlinesBefore > 0 || Tokens.back()->IsMultiline)
   FirstInLineIndex = Tokens.size() - 1;
   } while (Tokens.back()->Tok.isNot(tok::eof));
@@ -265,6 +271,31 @@
   resetLexer(SourceMgr.getFileOffset(Lex->getSourceLocation(Offset + 1)));
 }
 
+void FormatTokenLexer::tryParseShebangLine() {
+  if (Tokens.size() > 1)
+// Must be the first token of the file.
+return;
+  FormatToken *HashToken = Tokens.back();
+  if (!HashToken->is(tok::hash) || HashToken->TokenText != "#")
+return;
+
+  // 'Manually' lex ahead in the current file buffer.
+  const char *Offset = Lex->getBufferLocation();
+  const char *ShebangBegin = Offset - HashToken->TokenText.size(); // at "#"
+  for (; Offset != Lex->getBuffer().end() && *Offset != '\n';)
+++Offset;
+
+  // ShebangText does *not* include the terminating '\n' so that the comment
+  // gets properly terminated.
+  StringRef ShebangText(ShebangBegin, Offset - ShebangBegin);
+  HashToken->Type = TT_Unknown;
+  HashToken->Tok.setKind(tok::comment);
+  HashToken->TokenText = ShebangText;
+  HashToken->ColumnWidth = ShebangText.size();
+
+  resetLexer(SourceMgr.getFileOffset(Lex->getSourceLocation(Offset)));
+}
+
 bool FormatTokenLexer::tryMerge_TMacro() {
   if (Tokens.size() < 4)
 return false;


Index: unittests/Format/FormatTestJS.cpp
===
--- unittests/Format/FormatTestJS.cpp
+++ unittests/Format/FormatTestJS.cpp
@@ -1272,5 +1272,12 @@
   verifyFormat("var x = 'foo';", LeaveQuotes);
 }
 
+TEST_F(FormatTestJS, SupportShebangLines) {
+  verifyFormat("#!/usr/bin/env node\n"
+   "var x = hello();",
+   "#!/usr/bin/env node\n"
+   "var x   =  hello();");
+}
+
 } // end namespace tooling
 } // end namespace clang
Index: lib/Format/FormatTokenLexer.h
===
--- lib/Format/FormatTokenLexer.h
+++ lib/Format/FormatTokenLexer.h
@@ -55,6 +55,8 @@
 
   void tryParseTemplateString();
 
+  void tryParseShebangLine();
+
   bool tryMerge_TMacro();
 
   bool tryMergeConflictMarkers();
Index: lib/Format/FormatTokenLexer.cpp
===
--- lib/Format/FormatTokenLexer.cpp
+++ lib/Format/FormatTokenLexer.cpp
@@ -20,6 +20,10 @@
 #include "clang/Format/Format.h"
 #include "llvm/Support/Regex.h"
 
+#include "llvm/Support/Debug.h"
+
+#define DEBUG_TYPE "format-formatter"
+
 namespace clang {
 namespace format {
 
@@ -50,8 +54,10 @@
 if (Style.Language == FormatStyle::LK_JavaScript) {
   tryParseJSRegexLiteral();
   tryParseTemplateString();
+  tryParseShebangLine();
 }
 tryMergePreviousTokens();
+
 if (Tokens.back()->NewlinesBefore > 0 || Tokens.back()->IsMultiline)
   FirstInLineIndex = Tokens.size() - 1;
   } while (Tokens.back()->Tok.isNot(tok::eof));
@@ -265,6 +271,31 @@
   resetLexer(SourceMgr.getFileOffset(Lex->getSourceLocation(Offset + 1)));
 }
 
+void FormatTokenLexer::tryParseShebangLine() {
+  if (Tokens.size() > 1)
+// Must 

  1   2   >