Re: [libcxx] r299734 - Allow a standard library to implement conditional noexcept for optional and unique_ptr hash functions.

2017-04-06 Thread Akira Hatanaka via cfe-commits
It looks like this commit and r299735 are causing bots to fail:

http://green.lab.llvm.org/green/job/libcxx_master_cmake_32/66/ 


The test hash_unique_ptr.pass.cpp doesn’t compile when -std=c++03 is on the 
command line because PointerDeleter defined in deleter_types.h is guarded with 
"TEST_STD_VER >= 11”.

> On Apr 6, 2017, at 4:50 PM, Billy Robert O'Neal III via cfe-commits 
>  wrote:
> 
> Author: bion
> Date: Thu Apr  6 18:50:21 2017
> New Revision: 299734
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=299734=rev
> Log:
> Allow a standard library to implement conditional noexcept for optional and 
> unique_ptr hash functions.
> 
> These tests were unconditionally asserting that optional and unique_ptr 
> declare throwing hashes, but MSVC++ implements conditional noexcept 
> forwarding that of the underlying hash function. As a result we were failing 
> these tests but there's nothing forbidding strengthening noexcept in that way.
> 
> Changed the ASSERT_NOT_NOEXCEPT asserts to use types which themselves have 
> non-noexcept hash functions.
> 
> Modified:
>
> libcxx/trunk/test/std/utilities/memory/util.smartptr/util.smartptr.hash/hash_unique_ptr.pass.cpp
>libcxx/trunk/test/std/utilities/optional/optional.hash/hash.pass.cpp
> 
> Modified: 
> libcxx/trunk/test/std/utilities/memory/util.smartptr/util.smartptr.hash/hash_unique_ptr.pass.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/util.smartptr/util.smartptr.hash/hash_unique_ptr.pass.cpp?rev=299734=299733=299734=diff
> ==
> --- 
> libcxx/trunk/test/std/utilities/memory/util.smartptr/util.smartptr.hash/hash_unique_ptr.pass.cpp
>  (original)
> +++ 
> libcxx/trunk/test/std/utilities/memory/util.smartptr/util.smartptr.hash/hash_unique_ptr.pass.cpp
>  Thu Apr  6 18:50:21 2017
> @@ -67,10 +67,14 @@ int main()
> int* ptr = new int;
> std::unique_ptr p(ptr);
> std::hash f;
> -ASSERT_NOT_NOEXCEPT(f(p));
> std::size_t h = f(p);
> assert(h == std::hash()(ptr));
>   }
> +  {
> +std::unique_ptr> pThrowingHash;
> +std::hash>> fThrowingHash;
> +ASSERT_NOT_NOEXCEPT(fThrowingHash(pThrowingHash));
> +  }
> #if TEST_STD_VER >= 11
>   {
> test_enabled_with_deleter();
> 
> Modified: libcxx/trunk/test/std/utilities/optional/optional.hash/hash.pass.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/optional/optional.hash/hash.pass.cpp?rev=299734=299733=299734=diff
> ==
> --- libcxx/trunk/test/std/utilities/optional/optional.hash/hash.pass.cpp 
> (original)
> +++ libcxx/trunk/test/std/utilities/optional/optional.hash/hash.pass.cpp Thu 
> Apr  6 18:50:21 2017
> @@ -38,9 +38,14 @@ int main()
> std::hash{}(optional{});
> 
> {
> +optional opt;
> +ASSERT_NOT_NOEXCEPT(std::hash()(opt));
> +ASSERT_NOT_NOEXCEPT(std::hash()(opt));
> +}
> +
> +{
> typedef int T;
> optional opt;
> -ASSERT_NOT_NOEXCEPT(std::hash()(opt));
> assert(std::hash{}(opt) == nullopt_hash);
> opt = 2;
> assert(std::hash{}(opt) == std::hash{}(*opt));
> @@ -48,7 +53,6 @@ int main()
> {
> typedef std::string T;
> optional opt;
> -ASSERT_NOT_NOEXCEPT(std::hash()(opt));
> assert(std::hash{}(opt) == nullopt_hash);
> opt = std::string("123");
> assert(std::hash{}(opt) == std::hash{}(*opt));
> @@ -56,7 +60,6 @@ int main()
> {
> typedef std::unique_ptr T;
> optional opt;
> -ASSERT_NOT_NOEXCEPT(std::hash()(opt));
> assert(std::hash{}(opt) == nullopt_hash);
> opt = std::unique_ptr(new int(3));
> assert(std::hash{}(opt) == std::hash{}(*opt));
> 
> 
> ___
> 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] D31401: [clangd] Extract FsPath from file:// uri

2017-04-06 Thread Stanislav Ionascu via Phabricator via cfe-commits
stanionascu marked 2 inline comments as done.
stanionascu added a comment.

Thank you for the review!

If there are no other comments/suggestions, would be great if someone would 
merge it as I'm lacking the permission to do so.


https://reviews.llvm.org/D31401



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


[PATCH] D31673: Allow casting C pointers declared using extern "C" to ObjC pointer types

2017-04-06 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: lib/Sema/SemaExprObjC.cpp:3358
   var &&
-  var->getStorageClass() == SC_Extern &&
+  !var->isThisDeclarationADefinition() &&
   var->getType().isConstQualified()) {

ahatanak wrote:
> rjmccall wrote:
> > Hmm.  Come to think of it, I wonder if we actually care whether the 
> > variable has a definition, given that it's const.
> > 
> > Well, we can consider that later.  I agree that this change is good.
> If we don't care whether the variable is a definition, it's possible to check 
> whether the variable declaration is directly contained in a language linkage 
> instead (using a function like isSingleLineLanguageLinkage in 
> lib/AST/Decl.cpp).
Nah, let's keep it simple for now.

Well, maybe the rule ought to be "does a definition exist?" rather than "is the 
specific declaration that lookup found a definition?"


https://reviews.llvm.org/D31673



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


[PATCH] D31798: [libc++] Drop support for CRTs older than VS 2015

2017-04-06 Thread Shoaib Meenai via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL299743: [libc++] Drop support for CRTs older than VS 2015 
(authored by smeenai).

Changed prior to commit:
  https://reviews.llvm.org/D31798?vs=94468=94476#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D31798

Files:
  libcxx/trunk/include/cmath
  libcxx/trunk/include/cstdio
  libcxx/trunk/include/math.h
  libcxx/trunk/include/support/win32/locale_win32.h
  libcxx/trunk/include/support/win32/support.h
  libcxx/trunk/src/locale.cpp
  libcxx/trunk/src/support/win32/locale_win32.cpp

Index: libcxx/trunk/src/locale.cpp
===
--- libcxx/trunk/src/locale.cpp
+++ libcxx/trunk/src/locale.cpp
@@ -1109,13 +1109,7 @@
 #elif __sun__
 return __ctype_mask;
 #elif defined(_LIBCPP_MSVCRT) || defined(__MINGW32__)
-#if _VC_CRT_MAJOR_VERSION < 14
-// This is assumed to be safe, which is a nonsense assumption because we're
-// going to end up dereferencing it later...
-return _ctype+1; // internal ctype mask table defined in msvcrt.dll
-#else
 return __pctype_func();
-#endif
 #elif defined(__EMSCRIPTEN__)
 return *__ctype_b_loc();
 #elif defined(_NEWLIB_VERSION)
Index: libcxx/trunk/src/support/win32/locale_win32.cpp
===
--- libcxx/trunk/src/support/win32/locale_win32.cpp
+++ libcxx/trunk/src/support/win32/locale_win32.cpp
@@ -13,8 +13,6 @@
 #include 
 #include 
 
-#include 
-
 typedef _VSTD::remove_pointer::type __locale_struct;
 typedef _VSTD::unique_ptr<__locale_struct, decltype()> __locale_raii;
 
@@ -31,9 +29,8 @@
 // uselocale sets the thread's locale by definition, so unconditionally use thread-local locale
 _configthreadlocale( _ENABLE_PER_THREAD_LOCALE );
 // uselocale sets all categories
-#if _VC_CRT_MAJOR_VERSION < 14
-setlocale( LC_ALL, newloc->locinfo->lc_category[LC_ALL].locale );
-#endif
+// disable setting locale on Windows temporarily because the structure is opaque (PR31516)
+//setlocale( LC_ALL, newloc->locinfo->lc_category[LC_ALL].locale );
 // uselocale returns the old locale_t
 return old_locale;
 }
Index: libcxx/trunk/include/support/win32/locale_win32.h
===
--- libcxx/trunk/include/support/win32/locale_win32.h
+++ libcxx/trunk/include/support/win32/locale_win32.h
@@ -11,13 +11,6 @@
 #ifndef _LIBCPP_SUPPORT_WIN32_LOCALE_WIN32_H
 #define _LIBCPP_SUPPORT_WIN32_LOCALE_WIN32_H
 
-#include 
-
-#if _VC_CRT_MAJOR_VERSION < 14
-// ctype mask table defined in msvcrt.dll
-extern "C" unsigned short __declspec(dllimport) _ctype[];
-#endif
-
 #include "support/win32/support.h"
 #include "support/win32/locale_mgmt_win32.h"
 #include 
Index: libcxx/trunk/include/support/win32/support.h
===
--- libcxx/trunk/include/support/win32/support.h
+++ libcxx/trunk/include/support/win32/support.h
@@ -21,9 +21,6 @@
 #if defined(_LIBCPP_COMPILER_MSVC)
 #include 
 #endif
-#if defined(_LIBCPP_MSVCRT)
-#include 
-#endif
 #define swprintf _snwprintf
 #define vswprintf _vsnwprintf
 
@@ -44,11 +41,6 @@
 }
 #endif // __MINGW32__
 
-#if defined(_VC_CRT_MAJOR_VERSION) && _VC_CRT_MAJOR_VERSION < 14
-#define snprintf _snprintf
-#define _Exit _exit
-#endif
-
 #if defined(_LIBCPP_COMPILER_MSVC)
 
 // Bit builtin's make these assumptions when calling _BitScanForward/Reverse
Index: libcxx/trunk/include/math.h
===
--- libcxx/trunk/include/math.h
+++ libcxx/trunk/include/math.h
@@ -293,9 +293,6 @@
 */
 
 #include <__config>
-#if defined(_LIBCPP_MSVCRT)
-#include 
-#endif
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #pragma GCC system_header
@@ -333,7 +330,7 @@
 return __libcpp_signbit((typename std::__promote<_A1>::type)__lcpp_x);
 }
 
-#elif defined(_LIBCPP_MSVCRT) && ((_VC_CRT_MAJOR_VERSION-0) >= 14)
+#elif defined(_LIBCPP_MSVCRT)
 
 template 
 inline _LIBCPP_INLINE_VISIBILITY
@@ -367,7 +364,7 @@
 return __libcpp_fpclassify((typename std::__promote<_A1>::type)__lcpp_x);
 }
 
-#elif defined(_LIBCPP_MSVCRT) && ((_VC_CRT_MAJOR_VERSION-0) >= 14)
+#elif defined(_LIBCPP_MSVCRT)
 
 template 
 inline _LIBCPP_INLINE_VISIBILITY
@@ -673,7 +670,7 @@
 
 // acos
 
-#if !((defined(_LIBCPP_MSVCRT) && (_VC_CRT_MAJOR_VERSION-0) < 14) || defined(_AIX) || defined(__sun__))
+#if !(defined(_AIX) || defined(__sun__))
 inline _LIBCPP_INLINE_VISIBILITY float   acos(float __lcpp_x) _NOEXCEPT   {return ::acosf(__lcpp_x);}
 inline _LIBCPP_INLINE_VISIBILITY long double acos(long double __lcpp_x) _NOEXCEPT {return ::acosl(__lcpp_x);}
 #endif
@@ -685,7 +682,7 @@
 
 // asin
 
-#if !((defined(_LIBCPP_MSVCRT) && (_VC_CRT_MAJOR_VERSION-0) < 14) || defined(_AIX) || defined(__sun__))
+#if !(defined(_AIX) || defined(__sun__))
 inline _LIBCPP_INLINE_VISIBILITY float   asin(float __lcpp_x) 

[libcxx] r299743 - [libc++] Drop support for CRTs older than VS 2015

2017-04-06 Thread Shoaib Meenai via cfe-commits
Author: smeenai
Date: Thu Apr  6 21:20:52 2017
New Revision: 299743

URL: http://llvm.org/viewvc/llvm-project?rev=299743=rev
Log:
[libc++] Drop support for CRTs older than VS 2015

LLVM dropped support for Visual Studio versions older than 2015 quite
some time ago, so I consider it safe to drop libc++'s support for older
CRTs. The CRT in Visual Studio 2015 provides a lot of previously missing
functions, so targeting it requires less special casing.

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

Modified:
libcxx/trunk/include/cmath
libcxx/trunk/include/cstdio
libcxx/trunk/include/math.h
libcxx/trunk/include/support/win32/locale_win32.h
libcxx/trunk/include/support/win32/support.h
libcxx/trunk/src/locale.cpp
libcxx/trunk/src/support/win32/locale_win32.cpp

Modified: libcxx/trunk/include/cmath
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/cmath?rev=299743=299742=299743=diff
==
--- libcxx/trunk/include/cmath (original)
+++ libcxx/trunk/include/cmath Thu Apr  6 21:20:52 2017
@@ -398,7 +398,6 @@ using ::cbrtf;
 using ::copysign;
 using ::copysignf;
 
-#if !(defined(_LIBCPP_MSVCRT) && ((_VC_CRT_MAJOR_VERSION-0) < 14))
 using ::erf;
 using ::erff;
 using ::erfc;
@@ -435,12 +434,10 @@ using ::lrint;
 using ::lrintf;
 using ::lround;
 using ::lroundf;
-#endif // !(defined(_LIBCPP_MSVCRT) && ((_VC_CRT_MAJOR_VERSION-0) < 14))
 
 using ::nan;
 using ::nanf;
 
-#if !(defined(_LIBCPP_MSVCRT) && ((_VC_CRT_MAJOR_VERSION-0) < 14))
 using ::nearbyint;
 using ::nearbyintf;
 using ::nextafter;
@@ -463,7 +460,6 @@ using ::tgamma;
 using ::tgammaf;
 using ::trunc;
 using ::truncf;
-#endif // !(defined(_LIBCPP_MSVCRT) && ((_VC_CRT_MAJOR_VERSION-0) < 14))
 
 using ::acosl;
 using ::asinl;
@@ -495,7 +491,6 @@ using ::cbrtl;
 
 using ::copysignl;
 
-#if !(defined(_LIBCPP_MSVCRT) && ((_VC_CRT_MAJOR_VERSION-0) < 14))
 using ::erfl;
 using ::erfcl;
 using ::exp2l;
@@ -526,7 +521,6 @@ using ::scalblnl;
 using ::scalbnl;
 using ::tgammal;
 using ::truncl;
-#endif // !(defined(_LIBCPP_MSVCRT) && ((_VC_CRT_MAJOR_VERSION-0) < 14))
 
 #if _LIBCPP_STD_VER > 14
 inline _LIBCPP_INLINE_VISIBILITY float   hypot(   float x,   float 
y,   float z ) { return sqrt(x*x + y*y + z*z); }

Modified: libcxx/trunk/include/cstdio
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/cstdio?rev=299743=299742=299743=diff
==
--- libcxx/trunk/include/cstdio (original)
+++ libcxx/trunk/include/cstdio Thu Apr  6 21:20:52 2017
@@ -98,9 +98,6 @@ void perror(const char* s);
 
 #include <__config>
 #include 
-#if defined(_LIBCPP_MSVCRT)
-#include 
-#endif
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #pragma GCC system_header
@@ -156,8 +153,7 @@ using ::tmpnam;
 
 #ifndef _LIBCPP_HAS_NO_STDIN
 using ::getchar;
-#if _LIBCPP_STD_VER <= 11 && \
-(!defined(_VC_CRT_MAJOR_VERSION) || _VC_CRT_MAJOR_VERSION < 14)
+#if _LIBCPP_STD_VER <= 11 && !defined(_LIBCPP_MSVCRT)
 using ::gets;
 #endif
 using ::scanf;

Modified: libcxx/trunk/include/math.h
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/math.h?rev=299743=299742=299743=diff
==
--- libcxx/trunk/include/math.h (original)
+++ libcxx/trunk/include/math.h Thu Apr  6 21:20:52 2017
@@ -293,9 +293,6 @@ long doubletruncl(long double x);
 */
 
 #include <__config>
-#if defined(_LIBCPP_MSVCRT)
-#include 
-#endif
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #pragma GCC system_header
@@ -333,7 +330,7 @@ signbit(_A1 __lcpp_x) _NOEXCEPT
 return __libcpp_signbit((typename std::__promote<_A1>::type)__lcpp_x);
 }
 
-#elif defined(_LIBCPP_MSVCRT) && ((_VC_CRT_MAJOR_VERSION-0) >= 14)
+#elif defined(_LIBCPP_MSVCRT)
 
 template 
 inline _LIBCPP_INLINE_VISIBILITY
@@ -367,7 +364,7 @@ fpclassify(_A1 __lcpp_x) _NOEXCEPT
 return __libcpp_fpclassify((typename std::__promote<_A1>::type)__lcpp_x);
 }
 
-#elif defined(_LIBCPP_MSVCRT) && ((_VC_CRT_MAJOR_VERSION-0) >= 14)
+#elif defined(_LIBCPP_MSVCRT)
 
 template 
 inline _LIBCPP_INLINE_VISIBILITY
@@ -673,7 +670,7 @@ abs(long double __lcpp_x) _NOEXCEPT {ret
 
 // acos
 
-#if !((defined(_LIBCPP_MSVCRT) && (_VC_CRT_MAJOR_VERSION-0) < 14) || 
defined(_AIX) || defined(__sun__))
+#if !(defined(_AIX) || defined(__sun__))
 inline _LIBCPP_INLINE_VISIBILITY float   acos(float __lcpp_x) _NOEXCEPT
   {return ::acosf(__lcpp_x);}
 inline _LIBCPP_INLINE_VISIBILITY long double acos(long double __lcpp_x) 
_NOEXCEPT {return ::acosl(__lcpp_x);}
 #endif
@@ -685,7 +682,7 @@ acos(_A1 __lcpp_x) _NOEXCEPT {return ::a
 
 // asin
 
-#if !((defined(_LIBCPP_MSVCRT) && (_VC_CRT_MAJOR_VERSION-0) < 14) || 
defined(_AIX) || defined(__sun__))
+#if !(defined(_AIX) || defined(__sun__))
 inline _LIBCPP_INLINE_VISIBILITY float   asin(float __lcpp_x) _NOEXCEPT
   {return 

[PATCH] D29654: [OpenMP] Integrate OpenMP target region cubin into host binary

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

Address some of the reviews.


Repository:
  rL LLVM

https://reviews.llvm.org/D29654

Files:
  lib/Driver/Driver.cpp
  lib/Driver/ToolChains/CommonArgs.cpp
  lib/Driver/ToolChains/CommonArgs.h
  lib/Driver/ToolChains/Cuda.cpp
  lib/Driver/ToolChains/Cuda.h
  lib/Driver/ToolChains/Gnu.cpp
  test/Driver/openmp-offload.c

Index: test/Driver/openmp-offload.c
===
--- test/Driver/openmp-offload.c
+++ test/Driver/openmp-offload.c
@@ -590,6 +590,17 @@
 
 /// ###
 
+/// Check cubin file generation and usage by nvlink
+// RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -save-temps -no-canonical-prefixes %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-CUBIN %s
+
+// CHK-CUBIN: clang{{.*}}" "-o" "{{.*}}-openmp-nvptx64-nvidia-cuda.s"
+// CHK-CUBIN-NEXT: ptxas{{.*}}" "--output-file" "{{.*}}-openmp-nvptx64-nvidia-cuda.o" "{{.*}}-openmp-nvptx64-nvidia-cuda.s"
+// CHK-CUBIN-NEXT: cp{{.*}}-openmp-nvptx64-nvidia-cuda.o" "{{.*}}-openmp-nvptx64-nvidia-cuda-{{.*}}.cubin"
+// CHK-CUBIN-NEXT: nvlink" "-o" "{{.*}}-openmp-nvptx64-nvidia-cuda" "{{.*}}" "{{.*}}-openmp-nvptx64-nvidia-cuda-{{.*}}.cubin"
+
+/// ###
+
 /// Check PTXAS is passed -c flag when offloading to an NVIDIA device using OpenMP.
 // RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -save-temps -no-canonical-prefixes %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHK-PTXAS-DEFAULT %s
Index: lib/Driver/ToolChains/Gnu.cpp
===
--- lib/Driver/ToolChains/Gnu.cpp
+++ lib/Driver/ToolChains/Gnu.cpp
@@ -203,131 +203,6 @@
   // The types are (hopefully) good enough.
 }
 
-/// Add OpenMP linker script arguments at the end of the argument list so that
-/// the fat binary is built by embedding each of the device images into the
-/// host. The linker script also defines a few symbols required by the code
-/// generation so that the images can be easily retrieved at runtime by the
-/// offloading library. This should be used only in tool chains that support
-/// linker scripts.
-static void AddOpenMPLinkerScript(const ToolChain , Compilation ,
-  const InputInfo ,
-  const InputInfoList ,
-  const ArgList , ArgStringList ,
-  const JobAction ) {
-
-  // If this is not an OpenMP host toolchain, we don't need to do anything.
-  if (!JA.isHostOffloading(Action::OFK_OpenMP))
-return;
-
-  // Create temporary linker script. Keep it if save-temps is enabled.
-  const char *LKS;
-  SmallString<256> Name = llvm::sys::path::filename(Output.getFilename());
-  if (C.getDriver().isSaveTempsEnabled()) {
-llvm::sys::path::replace_extension(Name, "lk");
-LKS = C.getArgs().MakeArgString(Name.c_str());
-  } else {
-llvm::sys::path::replace_extension(Name, "");
-Name = C.getDriver().GetTemporaryPath(Name, "lk");
-LKS = C.addTempFile(C.getArgs().MakeArgString(Name.c_str()));
-  }
-
-  // Add linker script option to the command.
-  CmdArgs.push_back("-T");
-  CmdArgs.push_back(LKS);
-
-  // Create a buffer to write the contents of the linker script.
-  std::string LksBuffer;
-  llvm::raw_string_ostream LksStream(LksBuffer);
-
-  // Get the OpenMP offload tool chains so that we can extract the triple
-  // associated with each device input.
-  auto OpenMPToolChains = C.getOffloadToolChains();
-  assert(OpenMPToolChains.first != OpenMPToolChains.second &&
- "No OpenMP toolchains??");
-
-  // Track the input file name and device triple in order to build the script,
-  // inserting binaries in the designated sections.
-  SmallVector, 8> InputBinaryInfo;
-
-  // Add commands to embed target binaries. We ensure that each section and
-  // image is 16-byte aligned. This is not mandatory, but increases the
-  // likelihood of data to be aligned with a cache block in several main host
-  // machines.
-  LksStream << "/*\n";
-  LksStream << "   OpenMP Offload Linker Script\n";
-  LksStream << " *** Automatically generated by Clang ***\n";
-  LksStream << "*/\n";
-  LksStream << "TARGET(binary)\n";
-  auto DTC = OpenMPToolChains.first;
-  for (auto  : Inputs) {
-const Action *A = II.getAction();
-// Is this a device linking action?
-if (A && isa(A) &&
-A->isDeviceOffloading(Action::OFK_OpenMP)) {
-  assert(DTC != OpenMPToolChains.second &&
- "More device inputs than device toolchains??");
-  InputBinaryInfo.push_back(std::make_pair(
-  DTC->second->getTriple().normalize(), II.getFilename()));
-  ++DTC;
-  LksStream << "INPUT(" << II.getFilename() << ")\n";
-}
-  }
-

[libcxx] r299735 - Add noexcept(false) to more strongly indicate that not being noexcept is important for hash tests.

2017-04-06 Thread Billy Robert O'Neal III via cfe-commits
Author: bion
Date: Thu Apr  6 18:50:33 2017
New Revision: 299735

URL: http://llvm.org/viewvc/llvm-project?rev=299735=rev
Log:
Add noexcept(false) to more strongly indicate that not being noexcept is 
important for hash tests.

Modified:

libcxx/trunk/test/std/utilities/memory/util.smartptr/util.smartptr.hash/hash_unique_ptr.pass.cpp
libcxx/trunk/test/std/utilities/optional/optional.hash/hash.pass.cpp

Modified: 
libcxx/trunk/test/std/utilities/memory/util.smartptr/util.smartptr.hash/hash_unique_ptr.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/util.smartptr/util.smartptr.hash/hash_unique_ptr.pass.cpp?rev=299735=299734=299735=diff
==
--- 
libcxx/trunk/test/std/utilities/memory/util.smartptr/util.smartptr.hash/hash_unique_ptr.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/utilities/memory/util.smartptr/util.smartptr.hash/hash_unique_ptr.pass.cpp
 Thu Apr  6 18:50:33 2017
@@ -50,7 +50,7 @@ namespace std {
 
 template 
 struct hash<::min_pointer>> {
-  size_t operator()(::min_pointer> p) 
const {
+  size_t operator()(::min_pointer> p) 
const noexcept(false) {
 if (!p) return 0;
 return std::hash{}(std::addressof(*p));
   }

Modified: libcxx/trunk/test/std/utilities/optional/optional.hash/hash.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/optional/optional.hash/hash.pass.cpp?rev=299735=299734=299735=diff
==
--- libcxx/trunk/test/std/utilities/optional/optional.hash/hash.pass.cpp 
(original)
+++ libcxx/trunk/test/std/utilities/optional/optional.hash/hash.pass.cpp Thu 
Apr  6 18:50:33 2017
@@ -26,7 +26,7 @@ namespace std {
 
 template <>
 struct hash {
-  size_t operator()(B const&) { return 0; }
+  size_t operator()(B const&) noexcept(false) { return 0; }
 };
 
 }


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


[libcxx] r299734 - Allow a standard library to implement conditional noexcept for optional and unique_ptr hash functions.

2017-04-06 Thread Billy Robert O'Neal III via cfe-commits
Author: bion
Date: Thu Apr  6 18:50:21 2017
New Revision: 299734

URL: http://llvm.org/viewvc/llvm-project?rev=299734=rev
Log:
Allow a standard library to implement conditional noexcept for optional and 
unique_ptr hash functions.

These tests were unconditionally asserting that optional and unique_ptr declare 
throwing hashes, but MSVC++ implements conditional noexcept forwarding that of 
the underlying hash function. As a result we were failing these tests but 
there's nothing forbidding strengthening noexcept in that way.

Changed the ASSERT_NOT_NOEXCEPT asserts to use types which themselves have 
non-noexcept hash functions.

Modified:

libcxx/trunk/test/std/utilities/memory/util.smartptr/util.smartptr.hash/hash_unique_ptr.pass.cpp
libcxx/trunk/test/std/utilities/optional/optional.hash/hash.pass.cpp

Modified: 
libcxx/trunk/test/std/utilities/memory/util.smartptr/util.smartptr.hash/hash_unique_ptr.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/util.smartptr/util.smartptr.hash/hash_unique_ptr.pass.cpp?rev=299734=299733=299734=diff
==
--- 
libcxx/trunk/test/std/utilities/memory/util.smartptr/util.smartptr.hash/hash_unique_ptr.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/utilities/memory/util.smartptr/util.smartptr.hash/hash_unique_ptr.pass.cpp
 Thu Apr  6 18:50:21 2017
@@ -67,10 +67,14 @@ int main()
 int* ptr = new int;
 std::unique_ptr p(ptr);
 std::hash f;
-ASSERT_NOT_NOEXCEPT(f(p));
 std::size_t h = f(p);
 assert(h == std::hash()(ptr));
   }
+  {
+std::unique_ptr> pThrowingHash;
+std::hash>> fThrowingHash;
+ASSERT_NOT_NOEXCEPT(fThrowingHash(pThrowingHash));
+  }
 #if TEST_STD_VER >= 11
   {
 test_enabled_with_deleter();

Modified: libcxx/trunk/test/std/utilities/optional/optional.hash/hash.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/optional/optional.hash/hash.pass.cpp?rev=299734=299733=299734=diff
==
--- libcxx/trunk/test/std/utilities/optional/optional.hash/hash.pass.cpp 
(original)
+++ libcxx/trunk/test/std/utilities/optional/optional.hash/hash.pass.cpp Thu 
Apr  6 18:50:21 2017
@@ -38,9 +38,14 @@ int main()
 std::hash{}(optional{});
 
 {
+optional opt;
+ASSERT_NOT_NOEXCEPT(std::hash()(opt));
+ASSERT_NOT_NOEXCEPT(std::hash()(opt));
+}
+
+{
 typedef int T;
 optional opt;
-ASSERT_NOT_NOEXCEPT(std::hash()(opt));
 assert(std::hash{}(opt) == nullopt_hash);
 opt = 2;
 assert(std::hash{}(opt) == std::hash{}(*opt));
@@ -48,7 +53,6 @@ int main()
 {
 typedef std::string T;
 optional opt;
-ASSERT_NOT_NOEXCEPT(std::hash()(opt));
 assert(std::hash{}(opt) == nullopt_hash);
 opt = std::string("123");
 assert(std::hash{}(opt) == std::hash{}(*opt));
@@ -56,7 +60,6 @@ int main()
 {
 typedef std::unique_ptr T;
 optional opt;
-ASSERT_NOT_NOEXCEPT(std::hash()(opt));
 assert(std::hash{}(opt) == nullopt_hash);
 opt = std::unique_ptr(new int(3));
 assert(std::hash{}(opt) == std::hash{}(*opt));


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


[PATCH] D31778: [Modules] Implement ODR-like semantics for tag types in C/ObjC

2017-04-06 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno updated this revision to Diff 94471.
bruno added a comment.

Update patch on top of Adrian comments


https://reviews.llvm.org/D31778

Files:
  include/clang/AST/ASTStructuralEquivalence.h
  include/clang/Basic/DiagnosticASTKinds.td
  include/clang/Parse/Parser.h
  include/clang/Sema/Sema.h
  lib/AST/ASTStructuralEquivalence.cpp
  lib/Parse/ParseDecl.cpp
  lib/Parse/ParseDeclCXX.cpp
  lib/Parse/ParseExpr.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaType.cpp
  test/Modules/Inputs/F.framework/Headers/F.h
  test/Modules/Inputs/F.framework/Modules/module.modulemap
  test/Modules/Inputs/F.framework/Modules/module.private.modulemap
  test/Modules/Inputs/F.framework/PrivateHeaders/NS.h
  test/Modules/elaborated-type-specifier-from-hidden-module.m
  test/Modules/redefinition-c-tagtypes.m

Index: test/Modules/redefinition-c-tagtypes.m
===
--- /dev/null
+++ test/Modules/redefinition-c-tagtypes.m
@@ -0,0 +1,48 @@
+// RUN: rm -rf %t.cache
+// RUN: %clang_cc1 -fsyntax-only %s -fmodules -fmodules-cache-path=%t.cache \
+// RUN:   -fimplicit-module-maps -F%S/Inputs -verify
+// RUN: %clang_cc1 -fsyntax-only %s -fmodules -fmodules-cache-path=%t.cache \
+// RUN:   -fimplicit-module-maps -F%S/Inputs -DCHANGE_TAGS -verify
+#include "F/F.h"
+
+#ifndef CHANGE_TAGS
+// expected-no-diagnostics
+#endif
+
+struct NS {
+  int a;
+#ifndef CHANGE_TAGS
+  int b;
+#else
+  int c; // expected-note {{field has name 'c' here}}
+  // expected-error@redefinition-c-tagtypes.m:12 {{type 'struct NS' has incompatible definitions}}
+  // expected-note@Inputs/F.framework/PrivateHeaders/NS.h:3 {{field has name 'b' here}}
+#endif
+};
+
+enum NSE {
+  FST = 22,
+#ifndef CHANGE_TAGS
+  SND = 43,
+#else
+  SND = 44, // expected-note {{enumerator 'SND' with value 44 here}}
+  // expected-error@redefinition-c-tagtypes.m:23 {{type 'enum NSE' has incompatible definitions}}
+  // expected-note@Inputs/F.framework/PrivateHeaders/NS.h:8 {{enumerator 'SND' with value 43 here}}
+#endif
+  TRD = 55
+};
+
+#define NS_ENUM(_type, _name) \
+  enum _name : _type _name;   \
+  enum _name : _type
+
+typedef NS_ENUM(int, NSMyEnum) {
+  MinX = 11,
+#ifndef CHANGE_TAGS
+  MinXOther = MinX,
+#else
+  MinXOther = TRD, // expected-note {{enumerator 'MinXOther' with value 55 here}}
+  // expected-error@redefinition-c-tagtypes.m:39 {{type 'enum NSMyEnum' has incompatible definitions}}
+  // expected-note@Inputs/F.framework/PrivateHeaders/NS.h:18 {{enumerator 'MinXOther' with value 11 here}}
+#endif
+};
Index: test/Modules/elaborated-type-specifier-from-hidden-module.m
===
--- test/Modules/elaborated-type-specifier-from-hidden-module.m
+++ test/Modules/elaborated-type-specifier-from-hidden-module.m
@@ -4,12 +4,11 @@
 @import ElaboratedTypeStructs.Empty; // The structs are now hidden.
 struct S1 *x;
 struct S2 *y;
-// FIXME: compatible definition should not be an error.
-struct S2 { int x; }; // expected-error {{redefinition}}
+struct S2 { int x; };
 struct S3 *z;
 // Incompatible definition.
-struct S3 { float y; }; // expected-error {{redefinition}}
-// expected-note@elaborated-type-structs.h:* 2 {{previous definition is here}}
+struct S3 { float y; }; // expected-error {{has incompatible definitions}} // expected-note {{field has name}}
+// expected-note@Inputs/elaborated-type-structs.h:3 {{field has name}}
 
 @import ElaboratedTypeStructs.Structs;
 
Index: test/Modules/Inputs/F.framework/PrivateHeaders/NS.h
===
--- /dev/null
+++ test/Modules/Inputs/F.framework/PrivateHeaders/NS.h
@@ -0,0 +1,19 @@
+struct NS {
+  int a;
+  int b;
+};
+
+enum NSE {
+  FST = 22,
+  SND = 43,
+  TRD = 55
+};
+
+#define NS_ENUM(_type, _name) \
+  enum _name : _type _name;   \
+  enum _name : _type
+
+typedef NS_ENUM(int, NSMyEnum) {
+  MinX = 11,
+  MinXOther = MinX,
+};
Index: test/Modules/Inputs/F.framework/Modules/module.private.modulemap
===
--- /dev/null
+++ test/Modules/Inputs/F.framework/Modules/module.private.modulemap
@@ -0,0 +1,7 @@
+module F.Private [system] {
+  explicit module NS {
+  header "NS.h"
+  export *
+  }
+  export *
+}
Index: test/Modules/Inputs/F.framework/Modules/module.modulemap
===
--- /dev/null
+++ test/Modules/Inputs/F.framework/Modules/module.modulemap
@@ -0,0 +1,7 @@
+framework module F [extern_c] [system] {
+  umbrella header "F.h"
+  module * {
+  export *
+  }
+  export *
+}
Index: test/Modules/Inputs/F.framework/Headers/F.h
===
--- /dev/null
+++ test/Modules/Inputs/F.framework/Headers/F.h
@@ -0,0 +1 @@
+// F.h
Index: lib/Sema/SemaType.cpp
===
--- lib/Sema/SemaType.cpp
+++ 

[PATCH] D31778: [Modules] Implement ODR-like semantics for tag types in C/ObjC

2017-04-06 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno added inline comments.



Comment at: include/clang/AST/ASTStructuralEquivalence.h:52
 
+  /// \brief Whether warn or error on tag type mismatches.
+  bool ErrorOnTagTypeMismatch;

aprantl wrote:
> No need to use \brief in new code any more. We are compiling with the Doxygen 
> autobrief option.
Sure, updated D31777 to also remove the `\brief`s in the transition



Comment at: lib/Parse/ParseDecl.cpp:4316
+!Actions.hasStructuralCompatLayout(TagDecl, CheckCompatTag.NewDef)) {
+  DS.SetTypeSpecError(); // Bail out...
+  return;

aprantl wrote:
> I think the LLVM coding style wants this to be 
> ```
> {
> // Bail out.
> DS.SetTypeSpecError();
> return;
> }
> ```
> 
> or
> ```
> // Bail out.
> return DS.SetTypeSpecError();
> ```
OK



Comment at: lib/Sema/SemaDecl.cpp:13386
+  bool AllowODR = getLangOpts().CPlusPlus || getLangOpts().ObjC1 ||
+  getLangOpts().C11;
   NamedDecl *Hidden = nullptr;

aprantl wrote:
> Does `ObjC2` imply `ObjC1`?
Yep!


https://reviews.llvm.org/D31778



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


[PATCH] D31798: [libc++] Drop support for CRTs older than VS 2015

2017-04-06 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai created this revision.

LLVM dropped support for Visual Studio versions older than 2015 quite
some time ago, so I consider it safe to drop libc++'s support for older
CRTs. The CRT in Visual Studio 2015 provides a lot of previously missing
functions, so targeting it requires less special casing.


https://reviews.llvm.org/D31798

Files:
  include/cmath
  include/cstdio
  include/math.h
  include/support/win32/locale_win32.h
  include/support/win32/support.h
  src/locale.cpp
  src/support/win32/locale_win32.cpp

Index: src/support/win32/locale_win32.cpp
===
--- src/support/win32/locale_win32.cpp
+++ src/support/win32/locale_win32.cpp
@@ -13,8 +13,6 @@
 #include 
 #include 
 
-#include 
-
 typedef _VSTD::remove_pointer::type __locale_struct;
 typedef _VSTD::unique_ptr<__locale_struct, decltype()> __locale_raii;
 
@@ -31,9 +29,8 @@
 // uselocale sets the thread's locale by definition, so unconditionally use thread-local locale
 _configthreadlocale( _ENABLE_PER_THREAD_LOCALE );
 // uselocale sets all categories
-#if _VC_CRT_MAJOR_VERSION < 14
-setlocale( LC_ALL, newloc->locinfo->lc_category[LC_ALL].locale );
-#endif
+// disable setting locale on Windows temporarily because the structure is opaque (PR31516)
+//setlocale( LC_ALL, newloc->locinfo->lc_category[LC_ALL].locale );
 // uselocale returns the old locale_t
 return old_locale;
 }
Index: src/locale.cpp
===
--- src/locale.cpp
+++ src/locale.cpp
@@ -1109,13 +1109,7 @@
 #elif __sun__
 return __ctype_mask;
 #elif defined(_LIBCPP_MSVCRT) || defined(__MINGW32__)
-#if _VC_CRT_MAJOR_VERSION < 14
-// This is assumed to be safe, which is a nonsense assumption because we're
-// going to end up dereferencing it later...
-return _ctype+1; // internal ctype mask table defined in msvcrt.dll
-#else
 return __pctype_func();
-#endif
 #elif defined(__EMSCRIPTEN__)
 return *__ctype_b_loc();
 #elif defined(_NEWLIB_VERSION)
Index: include/support/win32/support.h
===
--- include/support/win32/support.h
+++ include/support/win32/support.h
@@ -21,9 +21,6 @@
 #if defined(_LIBCPP_COMPILER_MSVC)
 #include 
 #endif
-#if defined(_LIBCPP_MSVCRT)
-#include 
-#endif
 #define swprintf _snwprintf
 #define vswprintf _vsnwprintf
 
@@ -44,11 +41,6 @@
 }
 #endif // __MINGW32__
 
-#if defined(_VC_CRT_MAJOR_VERSION) && _VC_CRT_MAJOR_VERSION < 14
-#define snprintf _snprintf
-#define _Exit _exit
-#endif
-
 #if defined(_LIBCPP_COMPILER_MSVC)
 
 // Bit builtin's make these assumptions when calling _BitScanForward/Reverse
Index: include/support/win32/locale_win32.h
===
--- include/support/win32/locale_win32.h
+++ include/support/win32/locale_win32.h
@@ -11,13 +11,6 @@
 #ifndef _LIBCPP_SUPPORT_WIN32_LOCALE_WIN32_H
 #define _LIBCPP_SUPPORT_WIN32_LOCALE_WIN32_H
 
-#include 
-
-#if _VC_CRT_MAJOR_VERSION < 14
-// ctype mask table defined in msvcrt.dll
-extern "C" unsigned short __declspec(dllimport) _ctype[];
-#endif
-
 #include "support/win32/support.h"
 #include "support/win32/locale_mgmt_win32.h"
 #include 
Index: include/math.h
===
--- include/math.h
+++ include/math.h
@@ -293,9 +293,6 @@
 */
 
 #include <__config>
-#if defined(_LIBCPP_MSVCRT)
-#include 
-#endif
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #pragma GCC system_header
@@ -333,7 +330,7 @@
 return __libcpp_signbit((typename std::__promote<_A1>::type)__lcpp_x);
 }
 
-#elif defined(_LIBCPP_MSVCRT) && ((_VC_CRT_MAJOR_VERSION-0) >= 14)
+#elif defined(_LIBCPP_MSVCRT)
 
 template 
 inline _LIBCPP_INLINE_VISIBILITY
@@ -367,7 +364,7 @@
 return __libcpp_fpclassify((typename std::__promote<_A1>::type)__lcpp_x);
 }
 
-#elif defined(_LIBCPP_MSVCRT) && ((_VC_CRT_MAJOR_VERSION-0) >= 14)
+#elif defined(_LIBCPP_MSVCRT)
 
 template 
 inline _LIBCPP_INLINE_VISIBILITY
@@ -673,7 +670,7 @@
 
 // acos
 
-#if !((defined(_LIBCPP_MSVCRT) && (_VC_CRT_MAJOR_VERSION-0) < 14) || defined(_AIX) || defined(__sun__))
+#if !(defined(_AIX) || defined(__sun__))
 inline _LIBCPP_INLINE_VISIBILITY float   acos(float __lcpp_x) _NOEXCEPT   {return ::acosf(__lcpp_x);}
 inline _LIBCPP_INLINE_VISIBILITY long double acos(long double __lcpp_x) _NOEXCEPT {return ::acosl(__lcpp_x);}
 #endif
@@ -685,7 +682,7 @@
 
 // asin
 
-#if !((defined(_LIBCPP_MSVCRT) && (_VC_CRT_MAJOR_VERSION-0) < 14) || defined(_AIX) || defined(__sun__))
+#if !(defined(_AIX) || defined(__sun__))
 inline _LIBCPP_INLINE_VISIBILITY float   asin(float __lcpp_x) _NOEXCEPT   {return ::asinf(__lcpp_x);}
 inline _LIBCPP_INLINE_VISIBILITY long double asin(long double __lcpp_x) _NOEXCEPT {return ::asinl(__lcpp_x);}
 #endif
@@ -697,7 +694,7 @@
 
 // atan
 
-#if !((defined(_LIBCPP_MSVCRT) && (_VC_CRT_MAJOR_VERSION-0) < 

[PATCH] D31696: Automatically add include-what-you-use for when building in tree

2017-04-06 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added inline comments.



Comment at: clang/tools/.gitignore:12
+#==#
+# The include-what-you-use project, for when building in-tree.
+include-what-you-use

LLVM doesn't currently have any .gitignore files for other projects, and they 
don't show up in `git status`. What's the difference here?



Comment at: clang/tools/CMakeLists.txt:35
+# if include-what-you-use is cloned for building in-tree, add it here.
+if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/include-what-you-use")
+  add_clang_subdirectory(include-what-you-use)

Maybe we should do `llvm_add_implicit_projects(CLANG)` here instead?

Or do we not want clang/tools to be a project extension point? Would IWYU build 
fine if we added it to llvm/projects or llvm/tools? Maybe we should just 
recommend that.


https://reviews.llvm.org/D31696



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


[PATCH] D31702: Append -w when LLVM_ENABLE_WARNINGS is Off.

2017-04-06 Thread Reid Kleckner via Phabricator via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

lgtm


https://reviews.llvm.org/D31702



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


[PATCH] D31673: Allow casting C pointers declared using extern "C" to ObjC pointer types

2017-04-06 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak updated this revision to Diff 94460.
ahatanak marked an inline comment as done.

https://reviews.llvm.org/D31673

Files:
  lib/Sema/SemaExprObjC.cpp
  test/SemaObjCXX/arc-bridged-cast.mm


Index: test/SemaObjCXX/arc-bridged-cast.mm
===
--- test/SemaObjCXX/arc-bridged-cast.mm
+++ test/SemaObjCXX/arc-bridged-cast.mm
@@ -52,3 +52,19 @@
   ref = (__bridge_retained CFAnnotatedObjectRef) CreateSomething();
   ref = (__bridge_retained CFAnnotatedObjectRef) CreateNSString();
 }
+
+struct __CFAnnotatedObject {
+} cf0;
+
+extern const CFAnnotatedObjectRef r0;
+extern const CFAnnotatedObjectRef r1 = 
+extern "C" const CFAnnotatedObjectRef r2;
+extern "C" const CFAnnotatedObjectRef r3 = 
+
+void testExternC() {
+  id obj;
+  obj = (id)r0;
+  obj = (id)r1; // expected-error{{cast of C pointer type 
'CFAnnotatedObjectRef' (aka 'const __CFAnnotatedObject *') to Objective-C 
pointer type 'id' requires a bridged cast}} expected-note{{use __bridge to 
convert directly}} expected-note{{use __bridge_transfer to transfer ownership 
of a +1 'CFAnnotatedObjectRef'}}
+  obj = (id)r2;
+  obj = (id)r3; // expected-error{{cast of C pointer type 
'CFAnnotatedObjectRef' (aka 'const __CFAnnotatedObject *') to Objective-C 
pointer type 'id' requires a bridged cast}} expected-note{{use __bridge to 
convert directly}} expected-note{{use __bridge_transfer to transfer ownership 
of a +1 'CFAnnotatedObjectRef'}}
+}
Index: lib/Sema/SemaExprObjC.cpp
===
--- lib/Sema/SemaExprObjC.cpp
+++ lib/Sema/SemaExprObjC.cpp
@@ -3355,7 +3355,7 @@
   if (isAnyRetainable(TargetClass) &&
   isAnyRetainable(SourceClass) &&
   var &&
-  var->getStorageClass() == SC_Extern &&
+  !var->isThisDeclarationADefinition() &&
   var->getType().isConstQualified()) {
 
 // In system headers, they can also be assumed to be immune to retains.


Index: test/SemaObjCXX/arc-bridged-cast.mm
===
--- test/SemaObjCXX/arc-bridged-cast.mm
+++ test/SemaObjCXX/arc-bridged-cast.mm
@@ -52,3 +52,19 @@
   ref = (__bridge_retained CFAnnotatedObjectRef) CreateSomething();
   ref = (__bridge_retained CFAnnotatedObjectRef) CreateNSString();
 }
+
+struct __CFAnnotatedObject {
+} cf0;
+
+extern const CFAnnotatedObjectRef r0;
+extern const CFAnnotatedObjectRef r1 = 
+extern "C" const CFAnnotatedObjectRef r2;
+extern "C" const CFAnnotatedObjectRef r3 = 
+
+void testExternC() {
+  id obj;
+  obj = (id)r0;
+  obj = (id)r1; // expected-error{{cast of C pointer type 'CFAnnotatedObjectRef' (aka 'const __CFAnnotatedObject *') to Objective-C pointer type 'id' requires a bridged cast}} expected-note{{use __bridge to convert directly}} expected-note{{use __bridge_transfer to transfer ownership of a +1 'CFAnnotatedObjectRef'}}
+  obj = (id)r2;
+  obj = (id)r3; // expected-error{{cast of C pointer type 'CFAnnotatedObjectRef' (aka 'const __CFAnnotatedObject *') to Objective-C pointer type 'id' requires a bridged cast}} expected-note{{use __bridge to convert directly}} expected-note{{use __bridge_transfer to transfer ownership of a +1 'CFAnnotatedObjectRef'}}
+}
Index: lib/Sema/SemaExprObjC.cpp
===
--- lib/Sema/SemaExprObjC.cpp
+++ lib/Sema/SemaExprObjC.cpp
@@ -3355,7 +3355,7 @@
   if (isAnyRetainable(TargetClass) &&
   isAnyRetainable(SourceClass) &&
   var &&
-  var->getStorageClass() == SC_Extern &&
+  !var->isThisDeclarationADefinition() &&
   var->getType().isConstQualified()) {
 
 // In system headers, they can also be assumed to be immune to retains.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D31673: Allow casting C pointers declared using extern "C" to ObjC pointer types

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



Comment at: lib/Sema/SemaExprObjC.cpp:3358
   var &&
-  var->getStorageClass() == SC_Extern &&
+  !var->isThisDeclarationADefinition() &&
   var->getType().isConstQualified()) {

rjmccall wrote:
> Hmm.  Come to think of it, I wonder if we actually care whether the variable 
> has a definition, given that it's const.
> 
> Well, we can consider that later.  I agree that this change is good.
If we don't care whether the variable is a definition, it's possible to check 
whether the variable declaration is directly contained in a language linkage 
instead (using a function like isSingleLineLanguageLinkage in lib/AST/Decl.cpp).



Comment at: test/SemaObjCXX/arc-bridged-cast.mm:59
+extern "C" const CFAnnotatedObjectRef r2;
+extern "C" const CFAnnotatedObjectRef r3 = 0;
+

rjmccall wrote:
> These examples are a little unfortunate because these values are known to be 
> null pointers.
Changed the initializer to be the address of a __CFAnnotatedObject variable.


https://reviews.llvm.org/D31673



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


[PATCH] D31736: Implement _interlockedbittestandset as a builtin

2017-04-06 Thread Reid Kleckner via Phabricator via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

lgtm




Comment at: lib/CodeGen/CGBuiltin.cpp:570
+llvm::AtomicOrdering::SequentiallyConsistent);
+llvm::Value *Shifted = Builder.CreateLShr(RMWI, Bit);
+llvm::Value *Truncated =

hans wrote:
> rnk wrote:
> > Can you comment that this shifts the relevant bit into the low bit, 
> > truncates to i8, and then tests the low bit? At first I was thinking "of 
> > course, we just do AND %old, $constant to test the bit".
> > 
> > Do we successfully pattern match this idiom to `lock bts`? Is there a 
> > pattern match we should target?
> Added the comment.
> 
> No, we generate horrible code for this, but it's the same as we did for the 
> inline version in intrin.h. We have BTS instructions in the .td file, but no 
> patterns for them.
> 
> I thought a bit about adding a pattern match for this, but I'm not sure it 
> would be worth the effort.
Let's file a bug for it and call it a day.


https://reviews.llvm.org/D31736



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


[PATCH] D31652: [clang-format] Recognize Java logical shift assignment operator

2017-04-06 Thread Richard Bradfield via Phabricator via cfe-commits
bradfier added a comment.

Thanks for that @thakis, that's a much better solution than the first attempt!


Repository:
  rL LLVM

https://reviews.llvm.org/D31652



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


[PATCH] D31652: [clang-format] Recognize Java logical shift assignment operator

2017-04-06 Thread Richard Bradfield via Phabricator via cfe-commits
bradfier updated this revision to Diff 94438.
bradfier edited the summary of this revision.
bradfier added a comment.

Switch to a more appropriate (and much simpler) method of identifying these 
Java-specific operators.

Also removed any references to fictitious "logical left shifts", I think I made 
those up while tired...


Repository:
  rL LLVM

https://reviews.llvm.org/D31652

Files:
  lib/Format/FormatTokenLexer.cpp
  unittests/Format/FormatTestJava.cpp


Index: unittests/Format/FormatTestJava.cpp
===
--- unittests/Format/FormatTestJava.cpp
+++ unittests/Format/FormatTestJava.cpp
@@ -522,5 +522,17 @@
"  void f() {}"));
 }
 
+TEST_F(FormatTestJava, RetainsLogicalShifts) {
+verifyFormat("void f() {\n"
+ "  int a = 1;\n"
+ "  a >>>= 1;\n"
+ "}");
+verifyFormat("void f() {\n"
+ "  int a = 1;\n"
+ "  a = a >>> 1;\n"
+ "}");
+}
+
+
 } // end namespace tooling
 } // end namespace clang
Index: lib/Format/FormatTokenLexer.cpp
===
--- lib/Format/FormatTokenLexer.cpp
+++ lib/Format/FormatTokenLexer.cpp
@@ -82,6 +82,19 @@
 if (tryMergeTokens(JSRightArrow, TT_JsFatArrow))
   return;
   }
+
+  if (Style.Language == FormatStyle::LK_Java) {
+static const tok::TokenKind JavaRightLogicalShift[] = {tok::greater,
+   tok::greater,
+   tok::greater};
+static const tok::TokenKind JavaRightLogicalShiftAssign[] = {tok::greater,
+ tok::greater,
+ 
tok::greaterequal};
+if (tryMergeTokens(JavaRightLogicalShift, TT_BinaryOperator))
+  return;
+if (tryMergeTokens(JavaRightLogicalShiftAssign, TT_BinaryOperator))
+  return;
+  }
 }
 
 bool FormatTokenLexer::tryMergeLessLess() {


Index: unittests/Format/FormatTestJava.cpp
===
--- unittests/Format/FormatTestJava.cpp
+++ unittests/Format/FormatTestJava.cpp
@@ -522,5 +522,17 @@
"  void f() {}"));
 }
 
+TEST_F(FormatTestJava, RetainsLogicalShifts) {
+verifyFormat("void f() {\n"
+ "  int a = 1;\n"
+ "  a >>>= 1;\n"
+ "}");
+verifyFormat("void f() {\n"
+ "  int a = 1;\n"
+ "  a = a >>> 1;\n"
+ "}");
+}
+
+
 } // end namespace tooling
 } // end namespace clang
Index: lib/Format/FormatTokenLexer.cpp
===
--- lib/Format/FormatTokenLexer.cpp
+++ lib/Format/FormatTokenLexer.cpp
@@ -82,6 +82,19 @@
 if (tryMergeTokens(JSRightArrow, TT_JsFatArrow))
   return;
   }
+
+  if (Style.Language == FormatStyle::LK_Java) {
+static const tok::TokenKind JavaRightLogicalShift[] = {tok::greater,
+   tok::greater,
+   tok::greater};
+static const tok::TokenKind JavaRightLogicalShiftAssign[] = {tok::greater,
+ tok::greater,
+ tok::greaterequal};
+if (tryMergeTokens(JavaRightLogicalShift, TT_BinaryOperator))
+  return;
+if (tryMergeTokens(JavaRightLogicalShiftAssign, TT_BinaryOperator))
+  return;
+  }
 }
 
 bool FormatTokenLexer::tryMergeLessLess() {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r299711 - [CMake][libcxx] Use check_c_compiler_flag to check for nodefaultlibs

2017-04-06 Thread Petr Hosek via cfe-commits
Author: phosek
Date: Thu Apr  6 16:06:33 2017
New Revision: 299711

URL: http://llvm.org/viewvc/llvm-project?rev=299711=rev
Log:
[CMake][libcxx] Use check_c_compiler_flag to check for nodefaultlibs

We're using -nodefaultlibs to avoid the dependency on C++ library
when using check_cxx_compiler_flag, and as such we cannot use
check_cxx_compiler_flag to check the availability of -nodefaultlibs
itself.

Modified:
libcxx/trunk/cmake/config-ix.cmake

Modified: libcxx/trunk/cmake/config-ix.cmake
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/cmake/config-ix.cmake?rev=299711=299710=299711=diff
==
--- libcxx/trunk/cmake/config-ix.cmake (original)
+++ libcxx/trunk/cmake/config-ix.cmake Thu Apr  6 16:06:33 2017
@@ -1,4 +1,5 @@
 include(CheckLibraryExists)
+include(CheckCCompilerFlag)
 include(CheckCXXCompilerFlag)
 
 if(WIN32 AND NOT MINGW)
@@ -24,7 +25,7 @@ endif()
 # required during compilation (which has the -nodefaultlibs). libc is
 # required for the link to go through. We remove sanitizers from the
 # configuration checks to avoid spurious link errors.
-check_cxx_compiler_flag(-nodefaultlibs LIBCXX_SUPPORTS_NODEFAULTLIBS_FLAG)
+check_c_compiler_flag(-nodefaultlibs LIBCXX_SUPPORTS_NODEFAULTLIBS_FLAG)
 if (LIBCXX_SUPPORTS_NODEFAULTLIBS_FLAG)
   set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -nodefaultlibs")
   if (LIBCXX_HAS_C_LIB)


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


[PATCH] D25866: [Sema] Support implicit scalar to vector conversions

2017-04-06 Thread Simon Dardis via Phabricator via cfe-commits
sdardis updated this revision to Diff 94434.
sdardis marked 7 inline comments as done.
sdardis added a comment.

Addressed review comments.

I've changed InvalidVectorOperands() to not use InvalidOperands() after 
updating some tests. InvalidOperands() was receiving expressions with implicit 
casts, leading to misleading error messages.


https://reviews.llvm.org/D25866

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/Sema.h
  lib/Sema/SemaExpr.cpp
  test/Sema/vector-cast.c
  test/Sema/vector-gcc-compat.c
  test/Sema/vector-gcc-compat.cpp
  test/Sema/vector-ops.c
  test/Sema/zvector.c
  test/SemaCXX/vector-no-lax.cpp

Index: test/SemaCXX/vector-no-lax.cpp
===
--- test/SemaCXX/vector-no-lax.cpp
+++ test/SemaCXX/vector-no-lax.cpp
@@ -4,6 +4,6 @@
 
 vSInt32 foo (vUInt32 a) {
   vSInt32 b = { 0, 0, 0, 0 };
-  b += a; // expected-error{{cannot convert between vector values}}
+  b += a; // expected-error{{cannot convert between vector type 'vUInt32' (vector of 4 'unsigned int' values) and vector type 'vSInt32' (vector of 4 'int' values) as implicit conversion would cause truncation}}
   return b;
 }
Index: test/Sema/zvector.c
===
--- test/Sema/zvector.c
+++ test/Sema/zvector.c
@@ -326,14 +326,14 @@
   bc = bc + sc2; // expected-error {{incompatible type}}
   bc = sc + bc2; // expected-error {{incompatible type}}
 
-  sc = sc + sc_scalar; // expected-error {{cannot convert}}
-  sc = sc + uc_scalar; // expected-error {{cannot convert}}
-  sc = sc_scalar + sc; // expected-error {{cannot convert}}
-  sc = uc_scalar + sc; // expected-error {{cannot convert}}
-  uc = uc + sc_scalar; // expected-error {{cannot convert}}
-  uc = uc + uc_scalar; // expected-error {{cannot convert}}
-  uc = sc_scalar + uc; // expected-error {{cannot convert}}
-  uc = uc_scalar + uc; // expected-error {{cannot convert}}
+  sc = sc + sc_scalar;
+  sc = sc + uc_scalar; // expected-error {{cannot convert between scalar type 'unsigned char' and vector type '__vector signed char' (vector of 16 'signed char' values) as implicit conversion would cause truncation}}
+  sc = sc_scalar + sc;
+  sc = uc_scalar + sc; // expected-error {{cannot convert between scalar type 'unsigned char' and vector type '__vector signed char' (vector of 16 'signed char' values) as implicit conversion would cause truncation}}
+  uc = uc + sc_scalar; // expected-error {{implicit conversion changes signedness: 'signed char' to '__vector unsigned char' (vector of 16 'unsigned char' values)}}
+  uc = uc + uc_scalar;
+  uc = sc_scalar + uc; // expected-error {{implicit conversion changes signedness: 'signed char' to '__vector unsigned char' (vector of 16 'unsigned char' values)}}
+  uc = uc_scalar + uc;
 
   ss = ss + ss2;
   us = us + us2;
@@ -368,10 +368,10 @@
   sc += sl2; // expected-error {{cannot convert}}
   sc += fd2; // expected-error {{cannot convert}}
 
-  sc += sc_scalar; // expected-error {{cannot convert}}
-  sc += uc_scalar; // expected-error {{cannot convert}}
-  uc += sc_scalar; // expected-error {{cannot convert}}
-  uc += uc_scalar; // expected-error {{cannot convert}}
+  sc += sc_scalar;
+  sc += uc_scalar; // expected-error {{cannot convert between scalar type 'unsigned char' and vector type '__vector signed char' (vector of 16 'signed char' values) as implicit conversion would cause truncation}}
+  uc += sc_scalar; // expected-error {{implicit conversion changes signedness: 'signed char' to '__vector unsigned char' (vector of 16 'unsigned char' values)}}
+  uc += uc_scalar;
 
   ss += ss2;
   us += us2;
Index: test/Sema/vector-ops.c
===
--- test/Sema/vector-ops.c
+++ test/Sema/vector-ops.c
@@ -30,106 +30,108 @@
 void testLogicalVecVec(v2u v2ua, v2s v2sa, v2f v2fa) {
 
   // Logical operators
-  v2ua = v2ua && v2ua; // expected-warning {{incompatible vector types assigning to 'v2u' (vector of 2 'unsigned int' values) from '__attribute__((__vector_size__(2 * sizeof(int int' (vector of 2 'int' values)}}
-  v2ua = v2ua || v2ua; // expected-warning {{incompatible vector types assigning to 'v2u' (vector of 2 'unsigned int' values) from '__attribute__((__vector_size__(2 * sizeof(int int' (vector of 2 'int' values)}}
+  v2ua = v2ua && v2ua; // expected-error {{invalid operands to binary expression ('v2u' (vector of 2 'unsigned int' values) and 'v2u')}}
+  v2ua = v2ua || v2ua; // expected-error {{invalid operands to binary expression ('v2u' (vector of 2 'unsigned int' values) and 'v2u')}}
 
-  v2ua = v2sa && v2ua; // expected-warning {{incompatible vector types assigning to 'v2u' (vector of 2 'unsigned int' values) from '__attribute__((__vector_size__(2 * sizeof(int int' (vector of 2 'int' values)}}
-  v2ua = v2sa || v2ua; // expected-warning {{incompatible vector types assigning to 'v2u' (vector of 2 'unsigned int' values) from 

[PATCH] D31778: [Modules] Implement ODR-like semantics for tag types in C/ObjC

2017-04-06 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl added a comment.

Thanks!
Added a couple of superficial coding style comments.

I think there should also be a test for C99 and one for C11 (and potentially 
ObjC2).




Comment at: include/clang/AST/ASTStructuralEquivalence.h:52
 
+  /// \brief Whether warn or error on tag type mismatches.
+  bool ErrorOnTagTypeMismatch;

No need to use \brief in new code any more. We are compiling with the Doxygen 
autobrief option.



Comment at: lib/Parse/ParseDecl.cpp:4316
+!Actions.hasStructuralCompatLayout(TagDecl, CheckCompatTag.NewDef)) {
+  DS.SetTypeSpecError(); // Bail out...
+  return;

I think the LLVM coding style wants this to be 
```
{
// Bail out.
DS.SetTypeSpecError();
return;
}
```

or
```
// Bail out.
return DS.SetTypeSpecError();
```



Comment at: lib/Parse/ParseDeclCXX.cpp:1913
+: TagOrTempResult.get();
+  // Parse the definition body
+  ParseStructUnionBody(StartLoc, TagType, D);

`.`



Comment at: lib/Sema/SemaDecl.cpp:13386
+  bool AllowODR = getLangOpts().CPlusPlus || getLangOpts().ObjC1 ||
+  getLangOpts().C11;
   NamedDecl *Hidden = nullptr;

Does `ObjC2` imply `ObjC1`?



Comment at: lib/Sema/SemaType.cpp:7085
 
+/// \brief Determine if \p D abd \p Suggested have a structurally compatibale
+///layout as described by C11 6.2.7/1.

Comment should go on the declaration.


https://reviews.llvm.org/D31778



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


[PATCH] D31736: Implement _interlockedbittestandset as a builtin

2017-04-06 Thread Hans Wennborg via Phabricator via cfe-commits
hans added inline comments.



Comment at: lib/CodeGen/CGBuiltin.cpp:570
+llvm::AtomicOrdering::SequentiallyConsistent);
+llvm::Value *Shifted = Builder.CreateLShr(RMWI, Bit);
+llvm::Value *Truncated =

rnk wrote:
> Can you comment that this shifts the relevant bit into the low bit, truncates 
> to i8, and then tests the low bit? At first I was thinking "of course, we 
> just do AND %old, $constant to test the bit".
> 
> Do we successfully pattern match this idiom to `lock bts`? Is there a pattern 
> match we should target?
Added the comment.

No, we generate horrible code for this, but it's the same as we did for the 
inline version in intrin.h. We have BTS instructions in the .td file, but no 
patterns for them.

I thought a bit about adding a pattern match for this, but I'm not sure it 
would be worth the effort.


https://reviews.llvm.org/D31736



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


[PATCH] D31736: Implement _interlockedbittestandset as a builtin

2017-04-06 Thread Hans Wennborg via Phabricator via cfe-commits
hans updated this revision to Diff 94433.
hans added a comment.

Add comment.


https://reviews.llvm.org/D31736

Files:
  include/clang/Basic/Builtins.def
  lib/CodeGen/CGBuiltin.cpp
  lib/Headers/intrin.h
  test/CodeGen/ms-intrinsics.c

Index: test/CodeGen/ms-intrinsics.c
===
--- test/CodeGen/ms-intrinsics.c
+++ test/CodeGen/ms-intrinsics.c
@@ -434,6 +434,17 @@
 
 #endif
 
+unsigned char test_interlockedbittestandset(volatile long *ptr, long bit) {
+  return _interlockedbittestandset(ptr, bit);
+}
+// CHECK-LABEL: define{{.*}} i8 @test_interlockedbittestandset
+// CHECK: %0 = shl i32 1, %bit
+// CHECK: %1 = atomicrmw or i32* %ptr, i32 %0 seq_cst
+// CHECK: %2 = lshr i32 %1, %bit
+// CHECK: %3 = trunc i32 %2 to i8
+// CHECK: %4 = and i8 %3, 1
+// CHECK: ret i8 %4
+
 void test__fastfail() {
   __fastfail(42);
 }
Index: lib/Headers/intrin.h
===
--- lib/Headers/intrin.h
+++ lib/Headers/intrin.h
@@ -173,7 +173,6 @@
 void __cdecl _enable(void);
 long _InterlockedAddLargeStatistic(__int64 volatile *_Addend, long _Value);
 unsigned char _interlockedbittestandreset(long volatile *, long);
-static __inline__
 unsigned char _interlockedbittestandset(long volatile *, long);
 long _InterlockedCompareExchange_HLEAcquire(long volatile *, long, long);
 long _InterlockedCompareExchange_HLERelease(long volatile *, long, long);
@@ -369,11 +368,6 @@
   *_BitBase = *_BitBase | (1 << _BitPos);
   return _Res;
 }
-static __inline__ unsigned char __DEFAULT_FN_ATTRS
-_interlockedbittestandset(long volatile *_BitBase, long _BitPos) {
-  long _PrevVal = __atomic_fetch_or(_BitBase, 1l << _BitPos, __ATOMIC_SEQ_CST);
-  return (_PrevVal >> _BitPos) & 1;
-}
 #if defined(__arm__) || defined(__aarch64__)
 static __inline__ unsigned char __DEFAULT_FN_ATTRS
 _interlockedbittestandset_acq(long volatile *_BitBase, long _BitPos) {
Index: lib/CodeGen/CGBuiltin.cpp
===
--- lib/CodeGen/CGBuiltin.cpp
+++ lib/CodeGen/CGBuiltin.cpp
@@ -492,6 +492,7 @@
   _InterlockedIncrement,
   _InterlockedOr,
   _InterlockedXor,
+  _interlockedbittestandset,
   __fastfail,
 };
 
@@ -559,6 +560,22 @@
   case MSVCIntrin::_InterlockedXor:
 return MakeBinaryAtomicValue(*this, AtomicRMWInst::Xor, E);
 
+  case MSVCIntrin::_interlockedbittestandset: {
+llvm::Value *Addr = EmitScalarExpr(E->getArg(0));
+llvm::Value *Bit = EmitScalarExpr(E->getArg(1));
+AtomicRMWInst *RMWI = Builder.CreateAtomicRMW(
+AtomicRMWInst::Or, Addr,
+Builder.CreateShl(ConstantInt::get(Bit->getType(), 1), Bit),
+llvm::AtomicOrdering::SequentiallyConsistent);
+// Shift the relevant bit to the least significant position, truncate to
+// the result type, and test the low bit.
+llvm::Value *Shifted = Builder.CreateLShr(RMWI, Bit);
+llvm::Value *Truncated =
+Builder.CreateTrunc(Shifted, ConvertType(E->getType()));
+return Builder.CreateAnd(Truncated,
+ ConstantInt::get(Truncated->getType(), 1));
+  }
+
   case MSVCIntrin::_InterlockedDecrement: {
 llvm::Type *IntTy = ConvertType(E->getType());
 AtomicRMWInst *RMWI = Builder.CreateAtomicRMW(
@@ -2238,6 +2255,9 @@
   case Builtin::BI_InterlockedXor16:
   case Builtin::BI_InterlockedXor:
 return RValue::get(EmitMSVCBuiltinExpr(MSVCIntrin::_InterlockedXor, E));
+  case Builtin::BI_interlockedbittestandset:
+return RValue::get(
+EmitMSVCBuiltinExpr(MSVCIntrin::_interlockedbittestandset, E));
 
   case Builtin::BI__exception_code:
   case Builtin::BI_exception_code:
@@ -2309,10 +2329,8 @@
 break;
   }
 
-  case Builtin::BI__fastfail: {
+  case Builtin::BI__fastfail:
 return RValue::get(EmitMSVCBuiltinExpr(MSVCIntrin::__fastfail, E));
-break;
-  }
 
   case Builtin::BI__builtin_coro_size: {
 auto & Context = getContext();
Index: include/clang/Basic/Builtins.def
===
--- include/clang/Basic/Builtins.def
+++ include/clang/Basic/Builtins.def
@@ -756,6 +756,7 @@
 LANGBUILTIN(_InterlockedXor8,  "ccD*c",   "n", ALL_MS_LANGUAGES)
 LANGBUILTIN(_InterlockedXor16, "ssD*s",   "n", ALL_MS_LANGUAGES)
 LANGBUILTIN(_InterlockedXor,   "LiLiD*Li","n", ALL_MS_LANGUAGES)
+LANGBUILTIN(_interlockedbittestandset, "UcLiD*Li", "n", ALL_MS_LANGUAGES)
 LANGBUILTIN(__noop,   "i.",  "n", ALL_MS_LANGUAGES)
 LANGBUILTIN(__popcnt16, "UsUs", "nc", ALL_MS_LANGUAGES)
 LANGBUILTIN(__popcnt,   "UiUi", "nc", ALL_MS_LANGUAGES)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r299700 - [clang-tidy] Reuse FileID in getLocation

2017-04-06 Thread Chih-Hung Hsieh via cfe-commits
Author: chh
Date: Thu Apr  6 15:19:26 2017
New Revision: 299700

URL: http://llvm.org/viewvc/llvm-project?rev=299700=rev
Log:
[clang-tidy] Reuse FileID in getLocation

One FileID per warning will increase and overflow NextLocalOffset
when input file is large with many warnings.
Reusing FileID avoids this problem.

This requires changes in getColumnNumber, D31406, rL299681.

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


Modified:
clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp

Modified: clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp?rev=299700=299699=299700=diff
==
--- clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp Thu Apr  6 15:19:26 2017
@@ -239,7 +239,7 @@ private:
   return SourceLocation();
 
 const FileEntry *File = SourceMgr.getFileManager().getFile(FilePath);
-FileID ID = SourceMgr.createFileID(File, SourceLocation(), SrcMgr::C_User);
+FileID ID = SourceMgr.getOrCreateFileID(File, SrcMgr::C_User);
 return SourceMgr.getLocForStartOfFile(ID).getLocWithOffset(Offset);
   }
 


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


[PATCH] D31406: [clang-tidy] Reuse FileID in getLocation

2017-04-06 Thread Chih-Hung Hsieh via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL299700: [clang-tidy] Reuse FileID in getLocation (authored 
by chh).

Repository:
  rL LLVM

https://reviews.llvm.org/D31406

Files:
  clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp


Index: clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
===
--- clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
+++ clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
@@ -239,7 +239,7 @@
   return SourceLocation();
 
 const FileEntry *File = SourceMgr.getFileManager().getFile(FilePath);
-FileID ID = SourceMgr.createFileID(File, SourceLocation(), SrcMgr::C_User);
+FileID ID = SourceMgr.getOrCreateFileID(File, SrcMgr::C_User);
 return SourceMgr.getLocForStartOfFile(ID).getLocWithOffset(Offset);
   }
 


Index: clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
===
--- clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
+++ clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
@@ -239,7 +239,7 @@
   return SourceLocation();
 
 const FileEntry *File = SourceMgr.getFileManager().getFile(FilePath);
-FileID ID = SourceMgr.createFileID(File, SourceLocation(), SrcMgr::C_User);
+FileID ID = SourceMgr.getOrCreateFileID(File, SrcMgr::C_User);
 return SourceMgr.getLocForStartOfFile(ID).getLocWithOffset(Offset);
   }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D31760: [lsan] Enable LSan on arm Linux, clang part

2017-04-06 Thread Evgeniy Stepanov via Phabricator via cfe-commits
eugenis added inline comments.



Comment at: lib/Driver/ToolChains/Linux.cpp:867
  getTriple().getArch() == llvm::Triple::aarch64_be;
+  const bool IsArmArch = getTriple().getArch() == llvm::Triple::arm;
   SanitizerMask Res = ToolChain::getSupportedSanitizers();

I think we should also check for thumb. We allow asan on thumb, it would be 
surprising if lsan was not allowed.


Repository:
  rL LLVM

https://reviews.llvm.org/D31760



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


[PATCH] D30739: [OpenMP] "declare simd" for AArch64 Advanced SIMD.

2017-04-06 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:6818-6819
+ISAData);
+}
+if (CGM.getTriple().getArch() == llvm::Triple::aarch64) {
+  ISADataTy ISAData[] = {

else if



Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:6826
+ISAData);
+}
   }

Maybe it is better to create `SmallVector ISAData` and fill it 
for all architectures independently, but have just one call of 
`emitTargetDeclareSimdFunction()`?


https://reviews.llvm.org/D30739



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


[PATCH] D31696: Automatically add include-what-you-use for when building in tree

2017-04-06 Thread Kim Gräsman via Phabricator via cfe-commits
kimgr added a comment.

> BTW, kimgr@, is there any particular reason you haven't tried to upstream the 
> tool?
>  Maybe even as not a standalone tool but as a set of checks in clang-tidy.

Lack of time, mostly. IWYU was written before there was libtooling, and follows 
Google style, so we've felt it would be an odd bird in clang-tools-extra, for 
example.


https://reviews.llvm.org/D31696



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


[PATCH] D31771: [AMDGPU] Temporarily change constant address space from 4 to 2 for the new address space mapping

2017-04-06 Thread Yaxun Liu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL299691: [AMDGPU] Temporarily change constant address space 
from 4 to 2 for the new… (authored by yaxunl).

Changed prior to commit:
  https://reviews.llvm.org/D31771?vs=94386=94418#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D31771

Files:
  cfe/trunk/lib/Basic/Targets.cpp
  cfe/trunk/test/CodeGenOpenCL/address-space-constant-initializers.cl
  cfe/trunk/test/CodeGenOpenCL/amdgpu-env-amdgiz.cl


Index: cfe/trunk/test/CodeGenOpenCL/address-space-constant-initializers.cl
===
--- cfe/trunk/test/CodeGenOpenCL/address-space-constant-initializers.cl
+++ cfe/trunk/test/CodeGenOpenCL/address-space-constant-initializers.cl
@@ -1,4 +1,6 @@
 // RUN: %clang_cc1 %s -ffake-address-space-map -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 %s -triple amdgcn-amd-amdhsa-opencl -emit-llvm -o - | 
FileCheck %s
+// RUN: %clang_cc1 %s -triple amdgcn-amd-amdhsa-amdgizcl -emit-llvm -o - | 
FileCheck %s
 
 typedef struct {
 int i;
Index: cfe/trunk/test/CodeGenOpenCL/amdgpu-env-amdgiz.cl
===
--- cfe/trunk/test/CodeGenOpenCL/amdgpu-env-amdgiz.cl
+++ cfe/trunk/test/CodeGenOpenCL/amdgpu-env-amdgiz.cl
@@ -4,6 +4,6 @@
 // RUN: %clang_cc1 %s -O0 -triple amdgcn---amdgizcl -emit-llvm -o - | 
FileCheck -check-prefix=GIZ %s
 
 // CHECK: target datalayout = 
"e-p:32:32-p1:64:64-p2:64:64-p3:32:32-p4:64:64-p5:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64"
-// GIZ: target datalayout = 
"e-p:64:64-p1:64:64-p2:64:64-p3:32:32-p4:64:64-p5:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64"
+// GIZ: target datalayout = 
"e-p:64:64-p1:64:64-p2:64:64-p3:32:32-p4:32:32-p5:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64"
 void foo(void) {}
 
Index: cfe/trunk/lib/Basic/Targets.cpp
===
--- cfe/trunk/lib/Basic/Targets.cpp
+++ cfe/trunk/lib/Basic/Targets.cpp
@@ -2042,10 +2042,10 @@
 static const LangAS::Map AMDGPUGenericIsZeroMap = {
 1,  // opencl_global
 3,  // opencl_local
-4,  // opencl_constant
+2,  // opencl_constant
 0,  // opencl_generic
 1,  // cuda_device
-4,  // cuda_constant
+2,  // cuda_constant
 3   // cuda_shared
 };
 
@@ -2062,7 +2062,7 @@
   "-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64";
 
 static const char *const DataLayoutStringSIGenericIsZero =
-  "e-p:64:64-p1:64:64-p2:64:64-p3:32:32-p4:64:64-p5:32:32"
+  "e-p:64:64-p1:64:64-p2:64:64-p3:32:32-p4:32:32-p5:32:32"
   "-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128"
   "-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64";
 
@@ -2077,7 +2077,7 @@
 Generic   = 0;
 Global= 1;
 Local = 3;
-Constant  = 4;
+Constant  = 2;
 Private   = 5;
   } else {
 Generic   = 4;


Index: cfe/trunk/test/CodeGenOpenCL/address-space-constant-initializers.cl
===
--- cfe/trunk/test/CodeGenOpenCL/address-space-constant-initializers.cl
+++ cfe/trunk/test/CodeGenOpenCL/address-space-constant-initializers.cl
@@ -1,4 +1,6 @@
 // RUN: %clang_cc1 %s -ffake-address-space-map -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 %s -triple amdgcn-amd-amdhsa-opencl -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 %s -triple amdgcn-amd-amdhsa-amdgizcl -emit-llvm -o - | FileCheck %s
 
 typedef struct {
 int i;
Index: cfe/trunk/test/CodeGenOpenCL/amdgpu-env-amdgiz.cl
===
--- cfe/trunk/test/CodeGenOpenCL/amdgpu-env-amdgiz.cl
+++ cfe/trunk/test/CodeGenOpenCL/amdgpu-env-amdgiz.cl
@@ -4,6 +4,6 @@
 // RUN: %clang_cc1 %s -O0 -triple amdgcn---amdgizcl -emit-llvm -o - | FileCheck -check-prefix=GIZ %s
 
 // CHECK: target datalayout = "e-p:32:32-p1:64:64-p2:64:64-p3:32:32-p4:64:64-p5:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64"
-// GIZ: target datalayout = "e-p:64:64-p1:64:64-p2:64:64-p3:32:32-p4:64:64-p5:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64"
+// GIZ: target datalayout = "e-p:64:64-p1:64:64-p2:64:64-p3:32:32-p4:32:32-p5:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64"
 void foo(void) {}
 
Index: cfe/trunk/lib/Basic/Targets.cpp
===
--- cfe/trunk/lib/Basic/Targets.cpp
+++ cfe/trunk/lib/Basic/Targets.cpp
@@ -2042,10 +2042,10 @@
 static const LangAS::Map AMDGPUGenericIsZeroMap = {
 1,  // opencl_global
 3,  // opencl_local
-4,  // opencl_constant
+2,  // opencl_constant
  

r299691 - [AMDGPU] Temporarily change constant address space from 4 to 2 for the new address space mapping

2017-04-06 Thread Yaxun Liu via cfe-commits
Author: yaxunl
Date: Thu Apr  6 14:18:36 2017
New Revision: 299691

URL: http://llvm.org/viewvc/llvm-project?rev=299691=rev
Log:
[AMDGPU] Temporarily change constant address space from 4 to 2 for the new 
address space mapping

Change constant address space from 4 to 2 for the new address space mapping in 
Clang.

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

Modified:
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/test/CodeGenOpenCL/address-space-constant-initializers.cl
cfe/trunk/test/CodeGenOpenCL/amdgpu-env-amdgiz.cl

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=299691=299690=299691=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Thu Apr  6 14:18:36 2017
@@ -2042,10 +2042,10 @@ static const LangAS::Map AMDGPUPrivateIs
 static const LangAS::Map AMDGPUGenericIsZeroMap = {
 1,  // opencl_global
 3,  // opencl_local
-4,  // opencl_constant
+2,  // opencl_constant
 0,  // opencl_generic
 1,  // cuda_device
-4,  // cuda_constant
+2,  // cuda_constant
 3   // cuda_shared
 };
 
@@ -2062,7 +2062,7 @@ static const char *const DataLayoutStrin
   "-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64";
 
 static const char *const DataLayoutStringSIGenericIsZero =
-  "e-p:64:64-p1:64:64-p2:64:64-p3:32:32-p4:64:64-p5:32:32"
+  "e-p:64:64-p1:64:64-p2:64:64-p3:32:32-p4:32:32-p5:32:32"
   "-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128"
   "-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64";
 
@@ -2077,7 +2077,7 @@ class AMDGPUTargetInfo final : public Ta
 Generic   = 0;
 Global= 1;
 Local = 3;
-Constant  = 4;
+Constant  = 2;
 Private   = 5;
   } else {
 Generic   = 4;

Modified: cfe/trunk/test/CodeGenOpenCL/address-space-constant-initializers.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/address-space-constant-initializers.cl?rev=299691=299690=299691=diff
==
--- cfe/trunk/test/CodeGenOpenCL/address-space-constant-initializers.cl 
(original)
+++ cfe/trunk/test/CodeGenOpenCL/address-space-constant-initializers.cl Thu Apr 
 6 14:18:36 2017
@@ -1,4 +1,6 @@
 // RUN: %clang_cc1 %s -ffake-address-space-map -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 %s -triple amdgcn-amd-amdhsa-opencl -emit-llvm -o - | 
FileCheck %s
+// RUN: %clang_cc1 %s -triple amdgcn-amd-amdhsa-amdgizcl -emit-llvm -o - | 
FileCheck %s
 
 typedef struct {
 int i;

Modified: cfe/trunk/test/CodeGenOpenCL/amdgpu-env-amdgiz.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/amdgpu-env-amdgiz.cl?rev=299691=299690=299691=diff
==
--- cfe/trunk/test/CodeGenOpenCL/amdgpu-env-amdgiz.cl (original)
+++ cfe/trunk/test/CodeGenOpenCL/amdgpu-env-amdgiz.cl Thu Apr  6 14:18:36 2017
@@ -4,6 +4,6 @@
 // RUN: %clang_cc1 %s -O0 -triple amdgcn---amdgizcl -emit-llvm -o - | 
FileCheck -check-prefix=GIZ %s
 
 // CHECK: target datalayout = 
"e-p:32:32-p1:64:64-p2:64:64-p3:32:32-p4:64:64-p5:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64"
-// GIZ: target datalayout = 
"e-p:64:64-p1:64:64-p2:64:64-p3:32:32-p4:64:64-p5:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64"
+// GIZ: target datalayout = 
"e-p:64:64-p1:64:64-p2:64:64-p3:32:32-p4:32:32-p5:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64"
 void foo(void) {}
 


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


[libcxx] r299686 - Some of Eric's buildbots don't like this test. Disable it while I figure out why.

2017-04-06 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Thu Apr  6 13:54:37 2017
New Revision: 299686

URL: http://llvm.org/viewvc/llvm-project?rev=299686=rev
Log:
Some of Eric's buildbots don't like this test. Disable it while I figure out 
why.

Modified:
libcxx/trunk/test/std/re/re.alg/re.alg.match/awk.pass.cpp

Modified: libcxx/trunk/test/std/re/re.alg/re.alg.match/awk.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/re.alg/re.alg.match/awk.pass.cpp?rev=299686=299685=299686=diff
==
--- libcxx/trunk/test/std/re/re.alg/re.alg.match/awk.pass.cpp (original)
+++ libcxx/trunk/test/std/re/re.alg/re.alg.match/awk.pass.cpp Thu Apr  6 
13:54:37 2017
@@ -26,6 +26,7 @@
 
 int main()
 {
+#if 0
 {
 std::cmatch m;
 const char s[] = "a";
@@ -1388,4 +1389,5 @@ int main()
 assert(m.position(0) == 0);
 assert(m.str(0) == s);
 }
+#endif
 }


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


[PATCH] D31713: [Basic] getColumnNumber returns location of CR+LF on Windows

2017-04-06 Thread Chih-Hung Hsieh via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL299681: [Basic] getColumnNumber returns location of CR+LF on 
Windows (authored by chh).

Changed prior to commit:
  https://reviews.llvm.org/D31713?vs=94402=94410#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D31713

Files:
  cfe/trunk/lib/Basic/SourceManager.cpp


Index: cfe/trunk/lib/Basic/SourceManager.cpp
===
--- cfe/trunk/lib/Basic/SourceManager.cpp
+++ cfe/trunk/lib/Basic/SourceManager.cpp
@@ -1136,19 +1136,28 @@
 return 1;
   }
 
+  const char *Buf = MemBuf->getBufferStart();
   // See if we just calculated the line number for this FilePos and can use
   // that to lookup the start of the line instead of searching for it.
   if (LastLineNoFileIDQuery == FID &&
   LastLineNoContentCache->SourceLineCache != nullptr &&
   LastLineNoResult < LastLineNoContentCache->NumLines) {
 unsigned *SourceLineCache = LastLineNoContentCache->SourceLineCache;
 unsigned LineStart = SourceLineCache[LastLineNoResult - 1];
 unsigned LineEnd = SourceLineCache[LastLineNoResult];
-if (FilePos >= LineStart && FilePos < LineEnd)
+if (FilePos >= LineStart && FilePos < LineEnd) {
+  // LineEnd is the LineStart of the next line.
+  // A line ends with separator LF or CR+LF on Windows.
+  // FilePos might point to the last separator,
+  // but we need a column number at most 1 + the last column.
+  if (FilePos + 1 == LineEnd && FilePos > LineStart) {
+if (Buf[FilePos - 1] == '\r' || Buf[FilePos - 1] == '\n')
+  --FilePos;
+  }
   return FilePos - LineStart + 1;
+}
   }
 
-  const char *Buf = MemBuf->getBufferStart();
   unsigned LineStart = FilePos;
   while (LineStart && Buf[LineStart-1] != '\n' && Buf[LineStart-1] != '\r')
 --LineStart;


Index: cfe/trunk/lib/Basic/SourceManager.cpp
===
--- cfe/trunk/lib/Basic/SourceManager.cpp
+++ cfe/trunk/lib/Basic/SourceManager.cpp
@@ -1136,19 +1136,28 @@
 return 1;
   }
 
+  const char *Buf = MemBuf->getBufferStart();
   // See if we just calculated the line number for this FilePos and can use
   // that to lookup the start of the line instead of searching for it.
   if (LastLineNoFileIDQuery == FID &&
   LastLineNoContentCache->SourceLineCache != nullptr &&
   LastLineNoResult < LastLineNoContentCache->NumLines) {
 unsigned *SourceLineCache = LastLineNoContentCache->SourceLineCache;
 unsigned LineStart = SourceLineCache[LastLineNoResult - 1];
 unsigned LineEnd = SourceLineCache[LastLineNoResult];
-if (FilePos >= LineStart && FilePos < LineEnd)
+if (FilePos >= LineStart && FilePos < LineEnd) {
+  // LineEnd is the LineStart of the next line.
+  // A line ends with separator LF or CR+LF on Windows.
+  // FilePos might point to the last separator,
+  // but we need a column number at most 1 + the last column.
+  if (FilePos + 1 == LineEnd && FilePos > LineStart) {
+if (Buf[FilePos - 1] == '\r' || Buf[FilePos - 1] == '\n')
+  --FilePos;
+  }
   return FilePos - LineStart + 1;
+}
   }
 
-  const char *Buf = MemBuf->getBufferStart();
   unsigned LineStart = FilePos;
   while (LineStart && Buf[LineStart-1] != '\n' && Buf[LineStart-1] != '\r')
 --LineStart;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r299681 - [Basic] getColumnNumber returns location of CR+LF on Windows

2017-04-06 Thread Chih-Hung Hsieh via cfe-commits
Author: chh
Date: Thu Apr  6 13:36:50 2017
New Revision: 299681

URL: http://llvm.org/viewvc/llvm-project?rev=299681=rev
Log:
[Basic] getColumnNumber returns location of CR+LF on Windows

When fixing a Clang-Tidy bug in D31406,
reuse of FileID enabled the missing highlightRange function.
Assertion in highlightRange failed because the end-of-range column
number was 2 + the last column of a line on Windows.
This fix is required to enable D31406.

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


Modified:
cfe/trunk/lib/Basic/SourceManager.cpp

Modified: cfe/trunk/lib/Basic/SourceManager.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/SourceManager.cpp?rev=299681=299680=299681=diff
==
--- cfe/trunk/lib/Basic/SourceManager.cpp (original)
+++ cfe/trunk/lib/Basic/SourceManager.cpp Thu Apr  6 13:36:50 2017
@@ -1136,6 +1136,7 @@ unsigned SourceManager::getColumnNumber(
 return 1;
   }
 
+  const char *Buf = MemBuf->getBufferStart();
   // See if we just calculated the line number for this FilePos and can use
   // that to lookup the start of the line instead of searching for it.
   if (LastLineNoFileIDQuery == FID &&
@@ -1144,11 +1145,19 @@ unsigned SourceManager::getColumnNumber(
 unsigned *SourceLineCache = LastLineNoContentCache->SourceLineCache;
 unsigned LineStart = SourceLineCache[LastLineNoResult - 1];
 unsigned LineEnd = SourceLineCache[LastLineNoResult];
-if (FilePos >= LineStart && FilePos < LineEnd)
+if (FilePos >= LineStart && FilePos < LineEnd) {
+  // LineEnd is the LineStart of the next line.
+  // A line ends with separator LF or CR+LF on Windows.
+  // FilePos might point to the last separator,
+  // but we need a column number at most 1 + the last column.
+  if (FilePos + 1 == LineEnd && FilePos > LineStart) {
+if (Buf[FilePos - 1] == '\r' || Buf[FilePos - 1] == '\n')
+  --FilePos;
+  }
   return FilePos - LineStart + 1;
+}
   }
 
-  const char *Buf = MemBuf->getBufferStart();
   unsigned LineStart = FilePos;
   while (LineStart && Buf[LineStart-1] != '\n' && Buf[LineStart-1] != '\r')
 --LineStart;


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


[libcxx] r299680 - Recommit awk tests with warnings removed. Initial commit r299652, reverted r299656.

2017-04-06 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Thu Apr  6 13:34:36 2017
New Revision: 299680

URL: http://llvm.org/viewvc/llvm-project?rev=299680=rev
Log:
Recommit awk tests with warnings removed. Initial commit r299652, reverted 
r299656.

Modified:
libcxx/trunk/test/std/re/re.alg/re.alg.match/awk.pass.cpp

Modified: libcxx/trunk/test/std/re/re.alg/re.alg.match/awk.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/re.alg/re.alg.match/awk.pass.cpp?rev=299680=299679=299680=diff
==
--- libcxx/trunk/test/std/re/re.alg/re.alg.match/awk.pass.cpp (original)
+++ libcxx/trunk/test/std/re/re.alg/re.alg.match/awk.pass.cpp Thu Apr  6 
13:34:36 2017
@@ -26,7 +26,7 @@
 
 int main()
 {
-/*{
+{
 std::cmatch m;
 const char s[] = "a";
 assert(std::regex_match(s, m, std::regex("a", 
std::regex_constants::awk)));
@@ -263,7 +263,7 @@ int main()
 assert(!m.suffix().matched);
 assert(m.suffix().first == m[0].second);
 assert(m.suffix().second == m[0].second);
-assert(m.length(0) == std::char_traits::length(s));
+assert((size_t)m.length(0) == std::char_traits::length(s));
 assert(m.position(0) == 0);
 assert(m.str(0) == s);
 }
@@ -278,7 +278,7 @@ int main()
 assert(!m.suffix().matched);
 assert(m.suffix().first == m[0].second);
 assert(m.suffix().second == m[0].second);
-assert(m.length(0) == std::char_traits::length(s));
+assert((size_t)m.length(0) == std::char_traits::length(s));
 assert(m.position(0) == 0);
 assert(m.str(0) == s);
 }
@@ -293,7 +293,7 @@ int main()
 assert(!m.suffix().matched);
 assert(m.suffix().first == m[0].second);
 assert(m.suffix().second == m[0].second);
-assert(m.length(0) == std::char_traits::length(s));
+assert((size_t)m.length(0) == std::char_traits::length(s));
 assert(m.position(0) == 0);
 assert(m.str(0) == s);
 }
@@ -326,7 +326,7 @@ int main()
 assert(!m.suffix().matched);
 assert(m.suffix().first == m[0].second);
 assert(m.suffix().second == m[0].second);
-assert(m.length(0) == std::char_traits::length(s));
+assert((size_t)m.length(0) == std::char_traits::length(s));
 assert(m.position(0) == 0);
 assert(m.str(0) == s);
 }
@@ -341,7 +341,7 @@ int main()
 assert(!m.suffix().matched);
 assert(m.suffix().first == m[0].second);
 assert(m.suffix().second == m[0].second);
-assert(m.length(0) == std::char_traits::length(s));
+assert((size_t)m.length(0) == std::char_traits::length(s));
 assert(m.position(0) == 0);
 assert(m.str(0) == s);
 }
@@ -356,7 +356,7 @@ int main()
 assert(!m.suffix().matched);
 assert(m.suffix().first == m[0].second);
 assert(m.suffix().second == m[0].second);
-assert(m.length(0) == std::char_traits::length(s));
+assert((size_t)m.length(0) == std::char_traits::length(s));
 assert(m.position(0) == 0);
 assert(m.str(0) == s);
 }
@@ -378,7 +378,7 @@ int main()
 assert(!m.suffix().matched);
 assert(m.suffix().first == m[0].second);
 assert(m.suffix().second == m[0].second);
-assert(m.length(0) == std::char_traits::length(s));
+assert((size_t)m.length(0) == std::char_traits::length(s));
 assert(m.position(0) == 0);
 assert(m.str(0) == s);
 }
@@ -394,7 +394,7 @@ int main()
 assert(!m.suffix().matched);
 assert(m.suffix().first == m[0].second);
 assert(m.suffix().second == m[0].second);
-assert(m.length(0) == std::char_traits::length(s));
+assert((size_t)m.length(0) == std::char_traits::length(s));
 assert(m.position(0) == 0);
 assert(m.str(0) == s);
 }
@@ -410,7 +410,7 @@ int main()
 assert(!m.suffix().matched);
 assert(m.suffix().first == m[0].second);
 assert(m.suffix().second == m[0].second);
-assert(m.length(0) == std::char_traits::length(s));
+assert((size_t)m.length(0) == std::char_traits::length(s));
 assert(m.position(0) == 0);
 assert(m.str(0) == s);
 assert(m.length(1) == 4);
@@ -434,7 +434,7 @@ int main()
 assert(!m.suffix().matched);
 assert(m.suffix().first == m[0].second);
 assert(m.suffix().second == m[0].second);
-assert(m.length(0) == std::char_traits::length(s));
+assert((size_t)m.length(0) == std::char_traits::length(s));
 assert(m.position(0) == 0);
 assert(m.str(0) == s);
 }
@@ -519,7 +519,7 @@ int main()
 assert(!m.suffix().matched);
 assert(m.suffix().first == m[0].second);
 assert(m.suffix().second == m[0].second);
-assert(m.length(0) == std::char_traits::length(s));
+assert((size_t)m.length(0) == 

[PATCH] D31781: [Modules] Allow local submodule visibility without c++

2017-04-06 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno created this revision.

Removing this restriction will make it handy to explore local submodule 
visibility without c++ being turned on. We're currently testing it out with 
C/ObjC.


https://reviews.llvm.org/D31781

Files:
  lib/Frontend/CompilerInvocation.cpp


Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -2113,12 +2113,6 @@
   Args.hasFlag(OPT_fdeclspec, OPT_fno_declspec,
(Opts.MicrosoftExt || Opts.Borland || Opts.CUDA));
 
-  // For now, we only support local submodule visibility in C++ (because we
-  // heavily depend on the ODR for merging redefinitions).
-  if (Opts.ModulesLocalVisibility && !Opts.CPlusPlus)
-Diags.Report(diag::err_drv_argument_not_allowed_with)
-<< "-fmodules-local-submodule-visibility" << "C";
-
   if (Arg *A = Args.getLastArg(OPT_faddress_space_map_mangling_EQ)) {
 switch (llvm::StringSwitch(A->getValue())
   .Case("target", LangOptions::ASMM_Target)


Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -2113,12 +2113,6 @@
   Args.hasFlag(OPT_fdeclspec, OPT_fno_declspec,
(Opts.MicrosoftExt || Opts.Borland || Opts.CUDA));
 
-  // For now, we only support local submodule visibility in C++ (because we
-  // heavily depend on the ODR for merging redefinitions).
-  if (Opts.ModulesLocalVisibility && !Opts.CPlusPlus)
-Diags.Report(diag::err_drv_argument_not_allowed_with)
-<< "-fmodules-local-submodule-visibility" << "C";
-
   if (Arg *A = Args.getLastArg(OPT_faddress_space_map_mangling_EQ)) {
 switch (llvm::StringSwitch(A->getValue())
   .Case("target", LangOptions::ASMM_Target)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r299678 - [AMDGPU] Translate reqd_work_group_size into amdgpu_flat_work_group_size

2017-04-06 Thread Stanislav Mekhanoshin via cfe-commits
Author: rampitec
Date: Thu Apr  6 13:15:44 2017
New Revision: 299678

URL: http://llvm.org/viewvc/llvm-project?rev=299678=rev
Log:
[AMDGPU] Translate reqd_work_group_size into amdgpu_flat_work_group_size

These two attributes specify the same info in a different way.
AMGPU BE only checks the latter as a target specific attribute
as opposed to language specific reqd_work_group_size.

This change produces amdgpu_flat_work_group_size out of
reqd_work_group_size if specified.

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

Modified:
cfe/trunk/lib/CodeGen/TargetInfo.cpp
cfe/trunk/test/CodeGenOpenCL/amdgpu-attrs.cl

Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=299678=299677=299678=diff
==
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Thu Apr  6 13:15:44 2017
@@ -7302,9 +7302,14 @@ void AMDGPUTargetCodeGenInfo::setTargetA
 
   llvm::Function *F = cast(GV);
 
-  if (const auto *Attr = FD->getAttr()) {
-unsigned Min = Attr->getMin();
-unsigned Max = Attr->getMax();
+  const auto *ReqdWGS = M.getLangOpts().OpenCL ?
+FD->getAttr() : nullptr;
+  const auto *FlatWGS = FD->getAttr();
+  if (ReqdWGS || FlatWGS) {
+unsigned Min = FlatWGS ? FlatWGS->getMin() : 0;
+unsigned Max = FlatWGS ? FlatWGS->getMax() : 0;
+if (ReqdWGS && Min == 0 && Max == 0)
+  Min = Max = ReqdWGS->getXDim() * ReqdWGS->getYDim() * ReqdWGS->getZDim();
 
 if (Min != 0) {
   assert(Min <= Max && "Min must be less than or equal Max");

Modified: cfe/trunk/test/CodeGenOpenCL/amdgpu-attrs.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/amdgpu-attrs.cl?rev=299678=299677=299678=diff
==
--- cfe/trunk/test/CodeGenOpenCL/amdgpu-attrs.cl (original)
+++ cfe/trunk/test/CodeGenOpenCL/amdgpu-attrs.cl Thu Apr  6 13:15:44 2017
@@ -129,6 +129,16 @@ kernel void flat_work_group_size_32_64_w
 // CHECK: define amdgpu_kernel void 
@flat_work_group_size_32_64_waves_per_eu_2_4_num_sgpr_32_num_vgpr_64() 
[[FLAT_WORK_GROUP_SIZE_32_64_WAVES_PER_EU_2_4_NUM_SGPR_32_NUM_VGPR_64:#[0-9]+]]
 }
 
+__attribute__((reqd_work_group_size(32, 2, 1))) // expected-no-diagnostics
+kernel void reqd_work_group_size_32_2_1() {
+// CHECK: define amdgpu_kernel void @reqd_work_group_size_32_2_1() 
[[FLAT_WORK_GROUP_SIZE_64_64:#[0-9]+]]
+}
+__attribute__((reqd_work_group_size(32, 2, 1), amdgpu_flat_work_group_size(16, 
128))) // expected-no-diagnostics
+kernel void reqd_work_group_size_32_2_1_flat_work_group_size_16_128() {
+// CHECK: define amdgpu_kernel void 
@reqd_work_group_size_32_2_1_flat_work_group_size_16_128() 
[[FLAT_WORK_GROUP_SIZE_16_128:#[0-9]+]]
+}
+
+
 // Make sure this is silently accepted on other targets.
 // X86-NOT: "amdgpu-flat-work-group-size"
 // X86-NOT: "amdgpu-waves-per-eu"
@@ -142,6 +152,8 @@ kernel void flat_work_group_size_32_64_w
 // CHECK-NOT: "amdgpu-num-vgpr"="0"
 
 // CHECK-DAG: attributes [[FLAT_WORK_GROUP_SIZE_32_64]] = { noinline nounwind 
"amdgpu-flat-work-group-size"="32,64"
+// CHECK-DAG: attributes [[FLAT_WORK_GROUP_SIZE_64_64]] = { noinline nounwind 
"amdgpu-flat-work-group-size"="64,64"
+// CHECK-DAG: attributes [[FLAT_WORK_GROUP_SIZE_16_128]] = { noinline nounwind 
"amdgpu-flat-work-group-size"="16,128"
 // CHECK-DAG: attributes [[WAVES_PER_EU_2]] = { noinline nounwind 
"amdgpu-waves-per-eu"="2"
 // CHECK-DAG: attributes [[WAVES_PER_EU_2_4]] = { noinline nounwind 
"amdgpu-waves-per-eu"="2,4"
 // CHECK-DAG: attributes [[NUM_SGPR_32]] = { noinline nounwind 
"amdgpu-num-sgpr"="32"


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


[PATCH] D31043: Update for lifetime intrinsic signature change

2017-04-06 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.

LGTM.


https://reviews.llvm.org/D31043



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


[PATCH] D31713: [Basic] getColumnNumber returns location of CR+LF on Windows

2017-04-06 Thread Chih-Hung Hsieh via Phabricator via cfe-commits
chh updated this revision to Diff 94402.
chh marked an inline comment as done.

https://reviews.llvm.org/D31713

Files:
  lib/Basic/SourceManager.cpp


Index: lib/Basic/SourceManager.cpp
===
--- lib/Basic/SourceManager.cpp
+++ lib/Basic/SourceManager.cpp
@@ -1136,19 +1136,28 @@
 return 1;
   }
 
+  const char *Buf = MemBuf->getBufferStart();
   // See if we just calculated the line number for this FilePos and can use
   // that to lookup the start of the line instead of searching for it.
   if (LastLineNoFileIDQuery == FID &&
   LastLineNoContentCache->SourceLineCache != nullptr &&
   LastLineNoResult < LastLineNoContentCache->NumLines) {
 unsigned *SourceLineCache = LastLineNoContentCache->SourceLineCache;
 unsigned LineStart = SourceLineCache[LastLineNoResult - 1];
 unsigned LineEnd = SourceLineCache[LastLineNoResult];
-if (FilePos >= LineStart && FilePos < LineEnd)
+if (FilePos >= LineStart && FilePos < LineEnd) {
+  // LineEnd is the LineStart of the next line.
+  // A line ends with separator LF or CR+LF on Windows.
+  // FilePos might point to the last separator,
+  // but we need a column number at most 1 + the last column.
+  if (FilePos + 1 == LineEnd && FilePos > LineStart) {
+if (Buf[FilePos - 1] == '\r' || Buf[FilePos - 1] == '\n')
+  --FilePos;
+  }
   return FilePos - LineStart + 1;
+}
   }
 
-  const char *Buf = MemBuf->getBufferStart();
   unsigned LineStart = FilePos;
   while (LineStart && Buf[LineStart-1] != '\n' && Buf[LineStart-1] != '\r')
 --LineStart;


Index: lib/Basic/SourceManager.cpp
===
--- lib/Basic/SourceManager.cpp
+++ lib/Basic/SourceManager.cpp
@@ -1136,19 +1136,28 @@
 return 1;
   }
 
+  const char *Buf = MemBuf->getBufferStart();
   // See if we just calculated the line number for this FilePos and can use
   // that to lookup the start of the line instead of searching for it.
   if (LastLineNoFileIDQuery == FID &&
   LastLineNoContentCache->SourceLineCache != nullptr &&
   LastLineNoResult < LastLineNoContentCache->NumLines) {
 unsigned *SourceLineCache = LastLineNoContentCache->SourceLineCache;
 unsigned LineStart = SourceLineCache[LastLineNoResult - 1];
 unsigned LineEnd = SourceLineCache[LastLineNoResult];
-if (FilePos >= LineStart && FilePos < LineEnd)
+if (FilePos >= LineStart && FilePos < LineEnd) {
+  // LineEnd is the LineStart of the next line.
+  // A line ends with separator LF or CR+LF on Windows.
+  // FilePos might point to the last separator,
+  // but we need a column number at most 1 + the last column.
+  if (FilePos + 1 == LineEnd && FilePos > LineStart) {
+if (Buf[FilePos - 1] == '\r' || Buf[FilePos - 1] == '\n')
+  --FilePos;
+  }
   return FilePos - LineStart + 1;
+}
   }
 
-  const char *Buf = MemBuf->getBufferStart();
   unsigned LineStart = FilePos;
   while (LineStart && Buf[LineStart-1] != '\n' && Buf[LineStart-1] != '\r')
 --LineStart;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D31778: [Modules] Implement ODR-like semantics for tag types in C/ObjC

2017-04-06 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno created this revision.

Allow ODR for ObjC/C in the sense that we won't keep more that one definition 
around (merge them). However, ensure the decl pass the structural compatibility 
check in C11 6.2.7/1, for that, reuse the structural equivalence checks used by 
the ASTImporter.

Few other considerations:

- Create error diagnostics for tag types mismatches and thread them into the 
structural equivalence checks.
- Note that by doing this we only support redefinition between types that are 
considered "compatible types" by C11.

This is mixed approach of the suggestions discussed in 
http://lists.llvm.org/pipermail/cfe-dev/2017-March/053257.html


https://reviews.llvm.org/D31778

Files:
  include/clang/AST/ASTStructuralEquivalence.h
  include/clang/Basic/DiagnosticASTKinds.td
  include/clang/Parse/Parser.h
  include/clang/Sema/Sema.h
  lib/AST/ASTStructuralEquivalence.cpp
  lib/Parse/ParseDecl.cpp
  lib/Parse/ParseDeclCXX.cpp
  lib/Parse/ParseExpr.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaType.cpp
  test/Modules/Inputs/F.framework/Headers/F.h
  test/Modules/Inputs/F.framework/Modules/module.modulemap
  test/Modules/Inputs/F.framework/Modules/module.private.modulemap
  test/Modules/Inputs/F.framework/PrivateHeaders/NS.h
  test/Modules/elaborated-type-specifier-from-hidden-module.m
  test/Modules/redefinition-c-tagtypes.m

Index: test/Modules/redefinition-c-tagtypes.m
===
--- /dev/null
+++ test/Modules/redefinition-c-tagtypes.m
@@ -0,0 +1,48 @@
+// RUN: rm -rf %t.cache
+// RUN: %clang_cc1 -fsyntax-only %s -fmodules -fmodules-cache-path=%t.cache \
+// RUN:   -fimplicit-module-maps -F%S/Inputs -verify
+// RUN: %clang_cc1 -fsyntax-only %s -fmodules -fmodules-cache-path=%t.cache \
+// RUN:   -fimplicit-module-maps -F%S/Inputs -DCHANGE_TAGS -verify
+#include "F/F.h"
+
+#ifndef CHANGE_TAGS
+// expected-no-diagnostics
+#endif
+
+struct NS {
+  int a;
+#ifndef CHANGE_TAGS
+  int b;
+#else
+  int c; // expected-note {{field has name 'c' here}}
+  // expected-error@redefinition-c-tagtypes.m:12 {{type 'struct NS' has incompatible definitions}}
+  // expected-note@Inputs/F.framework/PrivateHeaders/NS.h:3 {{field has name 'b' here}}
+#endif
+};
+
+enum NSE {
+  FST = 22,
+#ifndef CHANGE_TAGS
+  SND = 43,
+#else
+  SND = 44, // expected-note {{enumerator 'SND' with value 44 here}}
+  // expected-error@redefinition-c-tagtypes.m:23 {{type 'enum NSE' has incompatible definitions}}
+  // expected-note@Inputs/F.framework/PrivateHeaders/NS.h:8 {{enumerator 'SND' with value 43 here}}
+#endif
+  TRD = 55
+};
+
+#define NS_ENUM(_type, _name) \
+  enum _name : _type _name;   \
+  enum _name : _type
+
+typedef NS_ENUM(int, NSMyEnum) {
+  MinX = 11,
+#ifndef CHANGE_TAGS
+  MinXOther = MinX,
+#else
+  MinXOther = TRD, // expected-note {{enumerator 'MinXOther' with value 55 here}}
+  // expected-error@redefinition-c-tagtypes.m:39 {{type 'enum NSMyEnum' has incompatible definitions}}
+  // expected-note@Inputs/F.framework/PrivateHeaders/NS.h:18 {{enumerator 'MinXOther' with value 11 here}}
+#endif
+};
Index: test/Modules/elaborated-type-specifier-from-hidden-module.m
===
--- test/Modules/elaborated-type-specifier-from-hidden-module.m
+++ test/Modules/elaborated-type-specifier-from-hidden-module.m
@@ -4,12 +4,11 @@
 @import ElaboratedTypeStructs.Empty; // The structs are now hidden.
 struct S1 *x;
 struct S2 *y;
-// FIXME: compatible definition should not be an error.
-struct S2 { int x; }; // expected-error {{redefinition}}
+struct S2 { int x; };
 struct S3 *z;
 // Incompatible definition.
-struct S3 { float y; }; // expected-error {{redefinition}}
-// expected-note@elaborated-type-structs.h:* 2 {{previous definition is here}}
+struct S3 { float y; }; // expected-error {{has incompatible definitions}} // expected-note {{field has name}}
+// expected-note@Inputs/elaborated-type-structs.h:3 {{field has name}}
 
 @import ElaboratedTypeStructs.Structs;
 
Index: test/Modules/Inputs/F.framework/PrivateHeaders/NS.h
===
--- /dev/null
+++ test/Modules/Inputs/F.framework/PrivateHeaders/NS.h
@@ -0,0 +1,19 @@
+struct NS {
+  int a;
+  int b;
+};
+
+enum NSE {
+  FST = 22,
+  SND = 43,
+  TRD = 55
+};
+
+#define NS_ENUM(_type, _name) \
+  enum _name : _type _name;   \
+  enum _name : _type
+
+typedef NS_ENUM(int, NSMyEnum) {
+  MinX = 11,
+  MinXOther = MinX,
+};
Index: test/Modules/Inputs/F.framework/Modules/module.private.modulemap
===
--- /dev/null
+++ test/Modules/Inputs/F.framework/Modules/module.private.modulemap
@@ -0,0 +1,7 @@
+module F.Private [system] {
+  explicit module NS {
+  header "NS.h"
+  export *
+  }
+  export *
+}
Index: test/Modules/Inputs/F.framework/Modules/module.modulemap

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

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

Revised by Anastasia's comments.


https://reviews.llvm.org/D31404

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

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

[PATCH] D31696: Automatically add include-what-you-use for when building in tree

2017-04-06 Thread Zachary Turner via Phabricator via cfe-commits
zturner added reviewers: beanz, rnk, chandlerc.
zturner added a comment.

Not really sure who to add as a reviewer here, so + a few random people.

BTW, kimgr@, is there any particular reason you haven't tried to upstream the 
tool?  Maybe even as not a standalone tool but as a set of checks in 
`clang-tidy`.


https://reviews.llvm.org/D31696



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


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

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



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

Anastasia wrote:
> yaxunl wrote:
> > yaxunl wrote:
> > > Anastasia wrote:
> > > > Anastasia wrote:
> > > > > yaxunl wrote:
> > > > > > Anastasia wrote:
> > > > > > > So we couldn't use the  LangAS::Count instead?
> > > > > > > 
> > > > > > > I have the same comment in other places that use 
> > > > > > > LangAS::target_first. Why couldn't we simply use LangAS::Count? 
> > > > > > > It there any point in having two tags?
> > > > > > > 
> > > > > > > Another comment is why do we need ASes specified by 
> > > > > > > `__attribute__((address_space(n)))` to be unique enum number at 
> > > > > > > the end of named ASes of OpenCL and CUDA? I think conceptually 
> > > > > > > the full range of ASes can be used in C because the ASes from 
> > > > > > > OpenCL and CUDA are not available there anyways.
> > > > > > I will use LangAS::Count instead and remove target_first, since 
> > > > > > their values are the same.
> > > > > > 
> > > > > > For your second question:  the values for 
> > > > > > `__attribute__((address_space(n)))` need to be different from the 
> > > > > > language specific address space values because they are mapped to 
> > > > > > target address space differently.
> > > > > > 
> > > > > > For language specific address space, they are mapped through a 
> > > > > > target defined mapping table.
> > > > > > 
> > > > > > For `__attribute__((address_space(n)))`, the target address space 
> > > > > > should be the same as n, without going through the mapping table.
> > > > > > 
> > > > > > If they are defined in overlapping value ranges, they cannot be 
> > > > > > handled in different ways.
> > > > > > 
> > > > > > 
> > > > > Target address space map currently corresponds to the named address 
> > > > > spaces of OpenCL and CUDA only. So if the idea is to avoid 
> > > > > overlapping with those we should extend the table? Although, I don't 
> > > > > see how this can be done because it will require fixed semantic of 
> > > > > address spaces in C which is currently undefined.
> > > > Perhaps I am missing something but I don't see any change here that 
> > > > makes non-named address spaces follow different path for the target.
> > > > 
> > > > Also does this change relate to alloca extension in some way? I still 
> > > > struggle to understand this fully...
> > > > 
> > > > All I can see is that this change restricts overlapping of named and 
> > > > non-named address spaces but I can't clearly understand the motivation 
> > > > for this.
> > > `__attribute__((address_space(n)))` is used in C and C++ to specify 
> > > target address space for a variable. 
> > > 
> > > For example, 
> > > https://github.com/llvm-mirror/clang/blob/master/test/Sema/address_spaces.c
> > >  
> > > 
> > > Many cases they just need to put a variable in certain target address 
> > > space and do not need specific semantics for these address spaces.
> > In the definition of `ASTContext::getTargetAddressSpace()` you can see how 
> > address space values below and above LangAS::Count are handled differently.
> > 
> > The old definition of address space enum does not differentiate between the 
> > default address space 0 (no address space qualifier) and 
> > `__attribute__((address_space(0)))`.
> > 
> > Before alloca API changes, this does not matter, since address space 0 in 
> > AST is always mapped to target address space 0.
> > 
> > However, after alloca API changes, default address space 0 is mapped to 
> > target alloca address space, which may be non-zero. Therefore it is 
> > necessary to differentiate between `__attribute__((address_space(0)))` and 
> > the default address space 0. Otherwise, if a user specifies 
> > `__attribute__((address_space(0)))`, it may not be mapped to target address 
> > space 0.
> > 
> > 
> > However, after alloca API changes, default address space 0 is mapped to 
> > target alloca address space, which may be non-zero. Therefore it is 
> > necessary to differentiate between __attribute__((address_space(0))) and 
> > the default address space 0. 
>  In your patch the default AS corresponds to value set in the target address 
> space map and not taken from the alloca AS of the DataLayout.
Addr space 0 is mapped to alloca addr space for OpenCL and mapped to 
target-specified addr space for other languages, which is done by 
ASTContext::getTargetAddressSpace.

In either case, it may not be mapped to 0.



Comment at: include/clang/Basic/AddressSpaces.h:32
+  // QualType represents private address space in OpenCL source code.
+  Default = 0,
+

Anastasia wrote:
> The alloca AS is not taken from the target AS map but from the DataLayout. 
> This keep me wonder whether the explicit Default item is actually needed 
> here
For OpenCL, 

[PATCH] D29651: [OpenMP] Consider LIBRARY_PATH when selecting library paths for NVPTX targets in OpenMP mode.

2017-04-06 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: test/Driver/openmp-offload.c:622
+/// Check that the lib folder pointed to by the LIBRARY_PATH is correctly 
passsed to the loader script.
+// RUN:   LIBRARY_PATH=/a/b/c/lib %clang -### -fopenmp=libomp 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -save-temps -no-canonical-prefixes 
%s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-LIB-PATH %s

Will it work on Windows?


Repository:
  rL LLVM

https://reviews.llvm.org/D29651



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


r299671 - Fix unused lambda capture. Follow up to r299653.

2017-04-06 Thread Ivan Krasin via cfe-commits
Author: krasin
Date: Thu Apr  6 12:42:05 2017
New Revision: 299671

URL: http://llvm.org/viewvc/llvm-project?rev=299671=rev
Log:
Fix unused lambda capture. Follow up to r299653.


Modified:
cfe/trunk/lib/Analysis/CloneDetection.cpp

Modified: cfe/trunk/lib/Analysis/CloneDetection.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CloneDetection.cpp?rev=299671=299670=299671=diff
==
--- cfe/trunk/lib/Analysis/CloneDetection.cpp (original)
+++ cfe/trunk/lib/Analysis/CloneDetection.cpp Thu Apr  6 12:42:05 2017
@@ -492,7 +492,7 @@ void RecursiveCloneTypeIIConstraint::con
 
 // Sort hash_codes in StmtsByHash.
 std::stable_sort(StmtsByHash.begin(), StmtsByHash.end(),
- [this](std::pair LHS,
+ [](std::pair LHS,
 std::pair RHS) {
return LHS.first < RHS.first;
  });


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


[libunwind] r299666 - Fix unused typedef. Follow up to r299575.

2017-04-06 Thread Ivan Krasin via cfe-commits
Author: krasin
Date: Thu Apr  6 12:35:35 2017
New Revision: 299666

URL: http://llvm.org/viewvc/llvm-project?rev=299666=rev
Log:
Fix unused typedef. Follow up to r299575.


Modified:
libunwind/trunk/src/AddressSpace.hpp

Modified: libunwind/trunk/src/AddressSpace.hpp
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/AddressSpace.hpp?rev=299666=299665=299666=diff
==
--- libunwind/trunk/src/AddressSpace.hpp (original)
+++ libunwind/trunk/src/AddressSpace.hpp Thu Apr  6 12:35:35 2017
@@ -383,7 +383,7 @@ inline bool LocalAddressSpace::findUnwin
 #if !defined(Elf_Phdr)
 typedef ElfW(Phdr) Elf_Phdr;
 #endif
-#if !defined(Elf_Addr)
+#if !defined(Elf_Addr) && defined(__ANDROID__)
 typedef ElfW(Addr) Elf_Addr;
 #endif
 


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


[PATCH] D26794: [OpenCL] Blocks are allowed to capture arrays in OpenCL 2.0 and higher.

2017-04-06 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

In https://reviews.llvm.org/D26794#598784, @Anastasia wrote:

> I have created a bug to Khronos regarding this, but unfortunately I don't see 
> it being progressed yet.
>  https://cvs.khronos.org/bugzilla/show_bug.cgi?id=15659
>
> The problem here is that I am not sure we should deviate from the ObjC 
> implementation because OpenCL blocks are largely taken from Clang ObjC 
> implementation. My issue is in particular that it's not clear what the 
> capture of array would mean and spec should either state it precisely or 
> disallow using this feature at all to avoid costly operations. In ObjC 
> community itself there were multiple interpretation of this in the past: 
> http://lists.llvm.org/pipermail/cfe-dev/2016-March/047849.html
>
> I am not sure we should go ahead with any implementation without further 
> clarifications. I will ping the Khronos bug to see if the documentation can 
> be improved.
>
> I think this issue has been seen in the OpenCL conformance tests, but was 
> fixed later on?


Sure. Do you have an access to revision with an update? I will ask to publish 
it online too.




Comment at: lib/Sema/SemaExpr.cpp:13481
+  // Only if it's not OpenCL 2.0.
+  if (!(S.getLangOpts().OpenCL && S.getLangOpts().OpenCLVersion >= 200)) {
+if (CaptureType->isArrayType()) {

Can we do this consistently for all OpenCL (Not just v2.0)!


https://reviews.llvm.org/D26794



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


[PATCH] D31745: [OpenCL] Added diagnostic for implicit declaration of function in OpenCL

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



Comment at: include/clang/Basic/DiagnosticSemaKinds.td:8254
   "%0 cannot be used as the type of a kernel parameter">;
+def err_opencl_implicit_function_decl : Error<
+  "implicit declaration of function %0 is invalid in OpenCL">;

Could this be in OpenCL group please?



Comment at: test/SemaOpenCL/clang-builtin-version.cl:32
+  work_group_reserve_write_pipe(tmp, tmp); // expected-error{{implicit 
declaration of function 'work_group_reserve_write_pipe' is invalid in OpenCL}}
+  // expected-note@-1{{did you mean 'work_group_reserve_read_pipe'?}}
+  // expected-note@-2{{'work_group_reserve_write_pipe' declared here}}

Why do we get this note now? I believe work_group_reserve_read_pipe shouldn't 
be available either?


https://reviews.llvm.org/D31745



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


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

2017-04-06 Thread Kelvin Li via Phabricator via cfe-commits
kkwli0 added inline comments.



Comment at: docs/ClangCommandLineReference.rst:1454
 
+.. option:: -fopenmp-simd, -fno-openmp-simd
+

I am not sure if it is target architecture specific or not.  If it is, should 
we be under the target flag instead?


https://reviews.llvm.org/D31417



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


[PATCH] D31757: [clang-tidy] Add a clang-tidy check for possible inefficient vector operations

2017-04-06 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added a comment.

Isn't such analysis is path-sensitive and should be implemented in Static 
Analyzer?

Please mention this check in docs/ReleaseNotes.rst (in alphabetical order).




Comment at: 
docs/clang-tidy/checks/performance-inefficient-vector-operation.rst:6
+
+Finds possible inefficient vector push_back operation that causes unnecessary
+memory reallocation.

I think will be good idea to use std::vector, and enclose it and push_back in 
``.


https://reviews.llvm.org/D31757



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


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

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



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

yaxunl wrote:
> yaxunl wrote:
> > Anastasia wrote:
> > > Anastasia wrote:
> > > > yaxunl wrote:
> > > > > Anastasia wrote:
> > > > > > So we couldn't use the  LangAS::Count instead?
> > > > > > 
> > > > > > I have the same comment in other places that use 
> > > > > > LangAS::target_first. Why couldn't we simply use LangAS::Count? It 
> > > > > > there any point in having two tags?
> > > > > > 
> > > > > > Another comment is why do we need ASes specified by 
> > > > > > `__attribute__((address_space(n)))` to be unique enum number at the 
> > > > > > end of named ASes of OpenCL and CUDA? I think conceptually the full 
> > > > > > range of ASes can be used in C because the ASes from OpenCL and 
> > > > > > CUDA are not available there anyways.
> > > > > I will use LangAS::Count instead and remove target_first, since their 
> > > > > values are the same.
> > > > > 
> > > > > For your second question:  the values for 
> > > > > `__attribute__((address_space(n)))` need to be different from the 
> > > > > language specific address space values because they are mapped to 
> > > > > target address space differently.
> > > > > 
> > > > > For language specific address space, they are mapped through a target 
> > > > > defined mapping table.
> > > > > 
> > > > > For `__attribute__((address_space(n)))`, the target address space 
> > > > > should be the same as n, without going through the mapping table.
> > > > > 
> > > > > If they are defined in overlapping value ranges, they cannot be 
> > > > > handled in different ways.
> > > > > 
> > > > > 
> > > > Target address space map currently corresponds to the named address 
> > > > spaces of OpenCL and CUDA only. So if the idea is to avoid overlapping 
> > > > with those we should extend the table? Although, I don't see how this 
> > > > can be done because it will require fixed semantic of address spaces in 
> > > > C which is currently undefined.
> > > Perhaps I am missing something but I don't see any change here that makes 
> > > non-named address spaces follow different path for the target.
> > > 
> > > Also does this change relate to alloca extension in some way? I still 
> > > struggle to understand this fully...
> > > 
> > > All I can see is that this change restricts overlapping of named and 
> > > non-named address spaces but I can't clearly understand the motivation 
> > > for this.
> > `__attribute__((address_space(n)))` is used in C and C++ to specify target 
> > address space for a variable. 
> > 
> > For example, 
> > https://github.com/llvm-mirror/clang/blob/master/test/Sema/address_spaces.c 
> > 
> > Many cases they just need to put a variable in certain target address space 
> > and do not need specific semantics for these address spaces.
> In the definition of `ASTContext::getTargetAddressSpace()` you can see how 
> address space values below and above LangAS::Count are handled differently.
> 
> The old definition of address space enum does not differentiate between the 
> default address space 0 (no address space qualifier) and 
> `__attribute__((address_space(0)))`.
> 
> Before alloca API changes, this does not matter, since address space 0 in AST 
> is always mapped to target address space 0.
> 
> However, after alloca API changes, default address space 0 is mapped to 
> target alloca address space, which may be non-zero. Therefore it is necessary 
> to differentiate between `__attribute__((address_space(0)))` and the default 
> address space 0. Otherwise, if a user specifies 
> `__attribute__((address_space(0)))`, it may not be mapped to target address 
> space 0.
> 
> 
> However, after alloca API changes, default address space 0 is mapped to 
> target alloca address space, which may be non-zero. Therefore it is necessary 
> to differentiate between __attribute__((address_space(0))) and the default 
> address space 0. 
 In your patch the default AS corresponds to value set in the target address 
space map and not taken from the alloca AS of the DataLayout.



Comment at: include/clang/Basic/AddressSpaces.h:32
+  // QualType represents private address space in OpenCL source code.
+  Default = 0,
+

The alloca AS is not taken from the target AS map but from the DataLayout. This 
keep me wonder whether the explicit Default item is actually needed here



Comment at: lib/Basic/Targets.cpp:8382
 static const unsigned SPIRAddrSpaceMap[] = {
+4, // Default
 1, // opencl_global

This will break use case of compiling for SPIR from C which is needed by some 
frameworks.
We can only use generic if compiled in OpenCL2.0 mode and only for pointer 
types.



Comment at: lib/Sema/SemaExprCXX.cpp:3121
 
-if (unsigned AddressSpace = Pointee.getAddressSpace())
+if 

[PATCH] D31771: [AMDGPU] Temporarily change constant address space from 4 to 2 for the new address space mapping

2017-04-06 Thread Tony Tye via Phabricator via cfe-commits
t-tye added a comment.

LGTM




Comment at: lib/Basic/Targets.cpp:2083
 Local = 3;
-Constant  = 4;
+Constant  = 2;
 Private   = 5;

t-tye wrote:
> Since Constant is now the same regardless of the GIZ setting, should it be 
> moved to be a literal constant like the other values that do not change?
Disregard comment as was thinking of the LLVM way address spaces were being 
handled.


https://reviews.llvm.org/D31771



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


[PATCH] D31771: [AMDGPU] Temporarily change constant address space from 4 to 2 for the new address space mapping

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

Other than one comment:

LGTM




Comment at: lib/Basic/Targets.cpp:2083
 Local = 3;
-Constant  = 4;
+Constant  = 2;
 Private   = 5;

Since Constant is now the same regardless of the GIZ setting, should it be 
moved to be a literal constant like the other values that do not change?


https://reviews.llvm.org/D31771



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


[PATCH] D31756: [cmake] Support Gentoo install for z3

2017-04-06 Thread Dominic Chen via Phabricator via cfe-commits
ddcc accepted this revision.
ddcc added a comment.
This revision is now accepted and ready to land.

Thanks!


Repository:
  rL LLVM

https://reviews.llvm.org/D31756



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


[PATCH] D31771: [AMDGPU] Temporarily change constant address space from 4 to 2 for the new address space mapping

2017-04-06 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl created this revision.
Herald added subscribers: tpr, dstuttard, nhaehnle, wdng, kzhuravl.

Change constant address space from 4 to 2 for the new address space mapping in 
Clang.


https://reviews.llvm.org/D31771

Files:
  lib/Basic/Targets.cpp
  test/CodeGenOpenCL/address-space-constant-initializers.cl
  test/CodeGenOpenCL/address-spaces.cl
  test/CodeGenOpenCL/amdgpu-env-amdgiz.cl
  test/CodeGenOpenCL/vla.cl

Index: test/CodeGenOpenCL/vla.cl
===
--- test/CodeGenOpenCL/vla.cl
+++ test/CodeGenOpenCL/vla.cl
@@ -3,13 +3,11 @@
 // RUN: %clang_cc1 -emit-llvm -triple amdgcn-amd-amdhsa-amdgizcl -O0 -cl-std=CL2.0 -o - %s | FileCheck -check-prefixes=CHECK,GIZ %s
 
 constant int sz0 = 5;
-// SPIR: @sz0 = addrspace(2) constant i32 5
-// GIZ: @sz0 = addrspace(4) constant i32 5
+// CHECK: @sz0 = addrspace(2) constant i32 5
 const global int sz1 = 16;
 // CHECK: @sz1 = addrspace(1) constant i32 16
 const constant int sz2 = 8;
-// SPIR: @sz2 = addrspace(2) constant i32 8
-// GIZ: @sz2 = addrspace(4) constant i32 8
+// CHECK: @sz2 = addrspace(2) constant i32 8
 // CHECK: @testvla.vla2 = internal addrspace(3) global [8 x i16] undef
 
 kernel void testvla()
Index: test/CodeGenOpenCL/amdgpu-env-amdgiz.cl
===
--- test/CodeGenOpenCL/amdgpu-env-amdgiz.cl
+++ test/CodeGenOpenCL/amdgpu-env-amdgiz.cl
@@ -4,6 +4,6 @@
 // RUN: %clang_cc1 %s -O0 -triple amdgcn---amdgizcl -emit-llvm -o - | FileCheck -check-prefix=GIZ %s
 
 // CHECK: target datalayout = "e-p:32:32-p1:64:64-p2:64:64-p3:32:32-p4:64:64-p5:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64"
-// GIZ: target datalayout = "e-p:64:64-p1:64:64-p2:64:64-p3:32:32-p4:64:64-p5:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-A5"
+// GIZ: target datalayout = "e-p:64:64-p1:64:64-p2:64:64-p3:32:32-p4:32:32-p5:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-A5"
 void foo(void) {}
 
Index: test/CodeGenOpenCL/address-spaces.cl
===
--- test/CodeGenOpenCL/address-spaces.cl
+++ test/CodeGenOpenCL/address-spaces.cl
@@ -15,8 +15,7 @@
 // CHECK: i32 addrspace(3)* %arg
 void f__l(__local int *arg) {}
 
-// SPIR: i32 addrspace(2)* %arg
-// GIZ: i32 addrspace(4)* %arg
+// CHECK: i32 addrspace(2)* %arg
 void f__c(__constant int *arg) {}
 
 // SPIR: i32* %arg
@@ -29,8 +28,7 @@
 // CHECK: i32 addrspace(3)* %arg
 void fl(local int *arg) {}
 
-// SPIR: i32 addrspace(2)* %arg
-// GIZ: i32 addrspace(4)* %arg
+// CHECK: i32 addrspace(2)* %arg
 void fc(constant int *arg) {}
 
 #ifdef CL20
Index: test/CodeGenOpenCL/address-space-constant-initializers.cl
===
--- test/CodeGenOpenCL/address-space-constant-initializers.cl
+++ test/CodeGenOpenCL/address-space-constant-initializers.cl
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 %s -ffake-address-space-map -emit-llvm -o - | FileCheck %s
 // RUN: %clang_cc1 %s -triple amdgcn-amd-amdhsa-opencl -emit-llvm -o - | FileCheck %s
-// RUN: %clang_cc1 %s -triple amdgcn-amd-amdhsa-amdgizcl -emit-llvm -o - | FileCheck -check-prefix=GIZ %s
+// RUN: %clang_cc1 %s -triple amdgcn-amd-amdhsa-amdgizcl -emit-llvm -o - | FileCheck %s
 
 typedef struct {
 int i;
@@ -15,8 +15,6 @@
 
 // CHECK: %struct.ConstantArrayPointerStruct = type { float addrspace(2)* }
 // CHECK: addrspace(2) constant %struct.ConstantArrayPointerStruct { float addrspace(2)* bitcast (i8 addrspace(2)* getelementptr (i8, i8 addrspace(2)* bitcast (%struct.ArrayStruct addrspace(2)* @constant_array_struct to i8 addrspace(2)*), i64 4) to float addrspace(2)*) }
-// GIZ: %struct.ConstantArrayPointerStruct = type { float addrspace(4)* }
-// GIZ: addrspace(4) constant %struct.ConstantArrayPointerStruct { float addrspace(4)* bitcast (i8 addrspace(4)* getelementptr (i8, i8 addrspace(4)* bitcast (%struct.ArrayStruct addrspace(4)* @constant_array_struct to i8 addrspace(4)*), i64 4) to float addrspace(4)*) }
 // Bug  18567
 __constant ConstantArrayPointerStruct constant_array_pointer_struct = {
 _array_struct.f
Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -2045,10 +2045,10 @@
 0,  // Default
 1,  // opencl_global
 3,  // opencl_local
-4,  // opencl_constant
+2,  // opencl_constant
 0,  // opencl_generic
 1,  // cuda_device
-4,  // cuda_constant
+2,  // cuda_constant
 3   // cuda_shared
 };
 
@@ -2065,7 +2065,7 @@
   "-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64";
 
 static const char *const DataLayoutStringSIGenericIsZero =
-  "e-p:64:64-p1:64:64-p2:64:64-p3:32:32-p4:64:64-p5:32:32"
+  "e-p:64:64-p1:64:64-p2:64:64-p3:32:32-p4:32:32-p5:32:32"
   

[PATCH] D31769: Remove the binders `bind1st`, `bind2nd`, `men_fun`, etc from C++17

2017-04-06 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists created this revision.

As proposed in http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4190

I'm leaving `unary_function` and `binary_function` in place until I can figure 
out a non-ABI breaking way to remove them.

To get them back in C++17, you can `-D _LIBCPP_ENABLE_CXX17_REMOVED_BINDERS` on 
the command line.


https://reviews.llvm.org/D31769

Files:
  include/__config
  include/functional
  test/libcxx/depr/depr.function.objects/depr.adaptors.cxx1z.pass.cpp
  
test/std/depr/depr.function.objects/depr.adaptors/depr.function.pointer.adaptors/pointer_to_binary_function.cxx1z.fail.cpp
  
test/std/depr/depr.function.objects/depr.adaptors/depr.function.pointer.adaptors/pointer_to_binary_function.pass.cpp
  
test/std/depr/depr.function.objects/depr.adaptors/depr.function.pointer.adaptors/pointer_to_unary_function.cxx1z.fail.cpp
  
test/std/depr/depr.function.objects/depr.adaptors/depr.function.pointer.adaptors/pointer_to_unary_function.pass.cpp
  
test/std/depr/depr.function.objects/depr.adaptors/depr.function.pointer.adaptors/ptr_fun1.cxx1z.fail.cpp
  
test/std/depr/depr.function.objects/depr.adaptors/depr.function.pointer.adaptors/ptr_fun1.pass.cpp
  
test/std/depr/depr.function.objects/depr.adaptors/depr.function.pointer.adaptors/ptr_fun2.cxx1z.fail.cpp
  
test/std/depr/depr.function.objects/depr.adaptors/depr.function.pointer.adaptors/ptr_fun2.pass.cpp
  
test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun.cxx1z.fail.cpp
  
test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun.pass.cpp
  
test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun1.cxx1z.fail.cpp
  
test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun1.pass.cpp
  
test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun1_ref_t.cxx1z.fail.cpp
  
test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun1_ref_t.pass.cpp
  
test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun1_t.cxx1z.fail.cpp
  
test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun1_t.pass.cpp
  
test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun_ref.cxx1z.fail.cpp
  
test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun_ref.pass.cpp
  
test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun_ref1.cxx1z.fail.cpp
  
test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun_ref1.pass.cpp
  
test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun_ref_t.cxx1z.fail.cpp
  
test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun_ref_t.pass.cpp
  
test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun_t.cxx1z.fail.cpp
  
test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun_t.pass.cpp
  
test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun.cxx1z.fail.cpp
  
test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun.pass.cpp
  
test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun1.cxx1z.fail.cpp
  
test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun1.pass.cpp
  
test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun1_ref_t.cxx1z.fail.cpp
  
test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun1_ref_t.pass.cpp
  
test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun1_t.cxx1z.fail.cpp
  
test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun1_t.pass.cpp
  
test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun_ref.cxx1z.fail.cpp
  
test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun_ref.pass.cpp
  
test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun_ref1.cxx1z.fail.cpp
  
test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun_ref1.pass.cpp
  
test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun_ref_t.cxx1z.fail.cpp
  
test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun_ref_t.pass.cpp
  
test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun_t.cxx1z.fail.cpp
  
test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun_t.pass.cpp
  test/std/depr/depr.lib.binders/depr.lib.bind.1st/bind1st.pass.cpp
  

Re: [libcxx] r299652 - Restore Missing awk regex tests. Thanks to dexonsmith for noticing, and proposing this as https://reviews.llvm.org/D16541

2017-04-06 Thread Mehdi Amini via cfe-commits
Hi,

I reverted in r299656. MacOS bot is broken both on 64 and 32 bits:

http://green.lab.llvm.org/green/job/libcxx_master_cmake/83/
http://green.lab.llvm.org/green/job/libcxx_master_cmake_32/61/

It shouldn’t be too hard to fix though, it is full of the same error:

/Users/buildslave/jenkins/sharedspace/libcxx/libcxx.src/test/std/re/re.alg/re.alg.match/awk.pass.cpp:266:28:
 error: comparison of integers of different signs: 'difference_type' (aka 
'long') and 'size_t' (aka 'unsigned long') [-Werror,-Wsign-compare]

assert(m.length(0) == std::char_traits::length(s));
   ~~~ ^  ~


— 
Mehdi






> On Apr 6, 2017, at 7:32 AM, Marshall Clow via cfe-commits 
>  wrote:
> 
> Author: marshall
> Date: Thu Apr  6 09:32:42 2017
> New Revision: 299652
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=299652=rev
> Log:
> Restore Missing awk regex tests. Thanks to dexonsmith for noticing, and 
> proposing this as https://reviews.llvm.org/D16541
> 
> Modified:
>libcxx/trunk/test/std/re/re.alg/re.alg.match/awk.pass.cpp
> 
> Modified: libcxx/trunk/test/std/re/re.alg/re.alg.match/awk.pass.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/re.alg/re.alg.match/awk.pass.cpp?rev=299652=299651=299652=diff
> ==
> --- libcxx/trunk/test/std/re/re.alg/re.alg.match/awk.pass.cpp (original)
> +++ libcxx/trunk/test/std/re/re.alg/re.alg.match/awk.pass.cpp Thu Apr  6 
> 09:32:42 2017
> @@ -26,7 +26,7 @@
> 
> int main()
> {
> -/*{
> +{
> std::cmatch m;
> const char s[] = "a";
> assert(std::regex_match(s, m, std::regex("a", 
> std::regex_constants::awk)));
> @@ -616,13 +616,12 @@ int main()
> assert(m.size() == 0);
> }
> std::locale::global(std::locale(LOCALE_cs_CZ_ISO8859_2));
> -*/{
> -/*
> +{
> std::cmatch m;
> const char s[] = "m";
> -assert(std::regex_match(s, m, std::regex("[a[=M=]z]",
> - std::regex_constants::awk);
> -   assert(m.size() == 1);
> +assert(std::regex_match(s, m, 
> +  std::regex("[a[=M=]z]", std::regex_constants::awk)));
> +assert(m.size() == 1);
> assert(!m.prefix().matched);
> assert(m.prefix().first == s);
> assert(m.prefix().second == m[0].first);
> @@ -632,8 +631,8 @@ int main()
> assert(m.length(0) == std::char_traits::length(s));
> assert(m.position(0) == 0);
> assert(m.str(0) == s);
> -*/}
> -/*{
> +}
> +{
> std::cmatch m;
> const char s[] = "Ch";
> assert(std::regex_match(s, m, std::regex("[a[.ch.]z]",
> @@ -1389,4 +1388,4 @@ int main()
> assert(m.position(0) == 0);
> assert(m.str(0) == s);
> }
> -*/}
> +}
> 
> 
> ___
> 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


[clang-tools-extra] r299657 - [clang-tidy] Temporarily disable a test-case that does not work on windows.

2017-04-06 Thread Gabor Horvath via cfe-commits
Author: xazax
Date: Thu Apr  6 10:58:57 2017
New Revision: 299657

URL: http://llvm.org/viewvc/llvm-project?rev=299657=rev
Log:
[clang-tidy] Temporarily disable a test-case that does not work on windows.

Modified:

clang-tools-extra/trunk/test/clang-tidy/misc-forwarding-reference-overload.cpp

Modified: 
clang-tools-extra/trunk/test/clang-tidy/misc-forwarding-reference-overload.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/misc-forwarding-reference-overload.cpp?rev=299657=299656=299657=diff
==
--- 
clang-tools-extra/trunk/test/clang-tidy/misc-forwarding-reference-overload.cpp 
(original)
+++ 
clang-tools-extra/trunk/test/clang-tidy/misc-forwarding-reference-overload.cpp 
Thu Apr  6 10:58:57 2017
@@ -116,14 +116,15 @@ public:
 };
 
 // Only the (compiler generated) copy constructor can be hidden.
-class Test5 {
-public:
-  template 
-  Test5(T &);
-  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: constructor accepting a 
forwarding reference can hide the copy constructor 
[misc-forwarding-reference-overload]
-
-  Test5(Test5 &) = delete;
-};
+// FIXME: Temporarily disabled due to failer on windows build bots.
+//class Test5 {
+//public:
+//  template 
+//  Test5(T &);
+//  // CM: :[[@LINE-1]]:3: warning: constructor accepting a forwarding 
reference can hide the copy constructor [misc-forwarding-reference-overload]
+//
+//  Test5(Test5 &) = delete;
+//};
 
 // Only the move constructor can be hidden.
 class Test6 {


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


[libcxx] r299656 - Revert "Restore Missing awk regex tests. Thanks to dexonsmith for noticing, and proposing this as https://reviews.llvm.org/D16541"

2017-04-06 Thread Mehdi Amini via cfe-commits
Author: mehdi_amini
Date: Thu Apr  6 10:56:55 2017
New Revision: 299656

URL: http://llvm.org/viewvc/llvm-project?rev=299656=rev
Log:
Revert "Restore Missing awk regex tests. Thanks to dexonsmith for noticing, and 
proposing this as https://reviews.llvm.org/D16541;

This reverts commit r299652, 32bits MacOS is broken.

Modified:
libcxx/trunk/test/std/re/re.alg/re.alg.match/awk.pass.cpp

Modified: libcxx/trunk/test/std/re/re.alg/re.alg.match/awk.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/re.alg/re.alg.match/awk.pass.cpp?rev=299656=299655=299656=diff
==
--- libcxx/trunk/test/std/re/re.alg/re.alg.match/awk.pass.cpp (original)
+++ libcxx/trunk/test/std/re/re.alg/re.alg.match/awk.pass.cpp Thu Apr  6 
10:56:55 2017
@@ -26,7 +26,7 @@
 
 int main()
 {
-{
+/*{
 std::cmatch m;
 const char s[] = "a";
 assert(std::regex_match(s, m, std::regex("a", 
std::regex_constants::awk)));
@@ -616,12 +616,13 @@ int main()
 assert(m.size() == 0);
 }
 std::locale::global(std::locale(LOCALE_cs_CZ_ISO8859_2));
-{
+*/{
+/*
 std::cmatch m;
 const char s[] = "m";
-assert(std::regex_match(s, m, 
-  std::regex("[a[=M=]z]", std::regex_constants::awk)));
-assert(m.size() == 1);
+assert(std::regex_match(s, m, std::regex("[a[=M=]z]",
+ std::regex_constants::awk);
+   assert(m.size() == 1);
 assert(!m.prefix().matched);
 assert(m.prefix().first == s);
 assert(m.prefix().second == m[0].first);
@@ -631,8 +632,8 @@ int main()
 assert(m.length(0) == std::char_traits::length(s));
 assert(m.position(0) == 0);
 assert(m.str(0) == s);
-}
-{
+*/}
+/*{
 std::cmatch m;
 const char s[] = "Ch";
 assert(std::regex_match(s, m, std::regex("[a[.ch.]z]",
@@ -1388,4 +1389,4 @@ int main()
 assert(m.position(0) == 0);
 assert(m.str(0) == s);
 }
-}
+*/}


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


[PATCH] D31766: [Clang][X86][SSE] Update MOVNTDQA non-temporal loads to generic implementation

2017-04-06 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon created this revision.

MOVNTDQA non-temporal aligned vector loads can be correctly represented using 
generic builtin loads, allowing us to remove the existing x86 intrinsics.

The LLVM companion patch will be published shortly.


Repository:
  rL LLVM

https://reviews.llvm.org/D31766

Files:
  include/clang/Basic/BuiltinsX86.def
  lib/Headers/avx2intrin.h
  lib/Headers/avx512fintrin.h
  lib/Headers/smmintrin.h
  test/CodeGen/avx2-builtins.c
  test/CodeGen/avx512f-builtins.c
  test/CodeGen/sse41-builtins.c

Index: test/CodeGen/sse41-builtins.c
===
--- test/CodeGen/sse41-builtins.c
+++ test/CodeGen/sse41-builtins.c
@@ -354,7 +354,7 @@
 
 __m128i test_mm_stream_load_si128(__m128i const *a) {
   // CHECK-LABEL: test_mm_stream_load_si128
-  // CHECK: call <2 x i64> @llvm.x86.sse41.movntdqa(i8* %{{.*}})
+  // CHECK: load <2 x i64>, <2 x i64>* %{{.*}}, align 16, !nontemporal
   return _mm_stream_load_si128(a);
 }
 
Index: test/CodeGen/avx512f-builtins.c
===
--- test/CodeGen/avx512f-builtins.c
+++ test/CodeGen/avx512f-builtins.c
@@ -6251,7 +6251,7 @@
 
 __m512i test_mm512_stream_load_si512(void *__P) {
   // CHECK-LABEL: @test_mm512_stream_load_si512
-  // CHECK: @llvm.x86.avx512.movntdqa
+  // CHECK: load <8 x i64>, <8 x i64>* %{{.*}}, align 64, !nontemporal
   return _mm512_stream_load_si512(__P); 
 }
 
Index: test/CodeGen/avx2-builtins.c
===
--- test/CodeGen/avx2-builtins.c
+++ test/CodeGen/avx2-builtins.c
@@ -1117,7 +1117,7 @@
 
 __m256i test_mm256_stream_load_si256(__m256i const *a) {
   // CHECK-LABEL: test_mm256_stream_load_si256
-  // CHECK: call <4 x i64> @llvm.x86.avx2.movntdqa(i8* %{{.*}})
+  // CHECK: load <4 x i64>, <4 x i64>* %{{.*}}, align 32, !nontemporal
   return _mm256_stream_load_si256(a);
 }
 
Index: lib/Headers/smmintrin.h
===
--- lib/Headers/smmintrin.h
+++ lib/Headers/smmintrin.h
@@ -691,7 +691,7 @@
 static __inline__  __m128i __DEFAULT_FN_ATTRS
 _mm_stream_load_si128 (__m128i const *__V)
 {
-  return (__m128i) __builtin_ia32_movntdqa ((const __v2di *) __V);
+  return (__m128i) __builtin_nontemporal_load ((const __v2di *) __V);
 }
 
 /* SSE4 Packed Integer Min/Max Instructions.  */
Index: lib/Headers/avx512fintrin.h
===
--- lib/Headers/avx512fintrin.h
+++ lib/Headers/avx512fintrin.h
@@ -8931,7 +8931,7 @@
 static __inline__ __m512i __DEFAULT_FN_ATTRS
 _mm512_stream_load_si512 (void *__P)
 {
-  return __builtin_ia32_movntdqa512 ((__v8di *)__P);
+  return (__m512i) __builtin_nontemporal_load((const __v8di *)__P);
 }
 
 static __inline__ void __DEFAULT_FN_ATTRS
Index: lib/Headers/avx2intrin.h
===
--- lib/Headers/avx2intrin.h
+++ lib/Headers/avx2intrin.h
@@ -832,7 +832,7 @@
 static __inline__ __m256i __DEFAULT_FN_ATTRS
 _mm256_stream_load_si256(__m256i const *__V)
 {
-  return (__m256i)__builtin_ia32_movntdqa256((const __v4di *)__V);
+  return (__m256i)__builtin_nontemporal_load((const __v4di *)__V);
 }
 
 static __inline__ __m128 __DEFAULT_FN_ATTRS
Index: include/clang/Basic/BuiltinsX86.def
===
--- include/clang/Basic/BuiltinsX86.def
+++ include/clang/Basic/BuiltinsX86.def
@@ -391,7 +391,6 @@
 TARGET_BUILTIN(__builtin_ia32_roundpd, "V2dV2dIi", "", "sse4.1")
 TARGET_BUILTIN(__builtin_ia32_dpps, "V4fV4fV4fIc", "", "sse4.1")
 TARGET_BUILTIN(__builtin_ia32_dppd, "V2dV2dV2dIc", "", "sse4.1")
-TARGET_BUILTIN(__builtin_ia32_movntdqa, "V2LLiV2LLiC*", "", "sse4.1")
 TARGET_BUILTIN(__builtin_ia32_ptestz128, "iV2LLiV2LLi", "", "sse4.1")
 TARGET_BUILTIN(__builtin_ia32_ptestc128, "iV2LLiV2LLi", "", "sse4.1")
 TARGET_BUILTIN(__builtin_ia32_ptestnzc128, "iV2LLiV2LLi", "", "sse4.1")
@@ -576,7 +575,6 @@
 TARGET_BUILTIN(__builtin_ia32_psrld256, "V8iV8iV4i", "", "avx2")
 TARGET_BUILTIN(__builtin_ia32_psrlqi256, "V4LLiV4LLii", "", "avx2")
 TARGET_BUILTIN(__builtin_ia32_psrlq256, "V4LLiV4LLiV2LLi", "", "avx2")
-TARGET_BUILTIN(__builtin_ia32_movntdqa256, "V4LLiV4LLiC*", "", "avx2")
 TARGET_BUILTIN(__builtin_ia32_permvarsi256, "V8iV8iV8i", "", "avx2")
 TARGET_BUILTIN(__builtin_ia32_permvarsf256, "V8fV8fV8i", "", "avx2")
 TARGET_BUILTIN(__builtin_ia32_permti256, "V4LLiV4LLiV4LLiIc", "", "avx2")
@@ -1747,7 +1745,6 @@
 TARGET_BUILTIN(__builtin_ia32_kunpckhi, "UsUsUs","","avx512f")
 TARGET_BUILTIN(__builtin_ia32_kxnorhi, "UsUsUs","","avx512f")
 TARGET_BUILTIN(__builtin_ia32_kxorhi, "UsUsUs","","avx512f")
-TARGET_BUILTIN(__builtin_ia32_movntdqa512, "V8LLiV8LLi*","","avx512f")
 TARGET_BUILTIN(__builtin_ia32_palignr512_mask, "V64cV64cV64cIiV64cULLi","","avx512bw")
 TARGET_BUILTIN(__builtin_ia32_dbpsadbw128_mask, "V8sV16cV16cIiV8sUc","","avx512bw,avx512vl")
 

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

2017-04-06 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: lib/CodeGen/CodeGenModule.cpp:122-123
 createOpenCLRuntime();
-  if (LangOpts.OpenMP)
+  if (LangOpts.OpenMP || LangOpts.OpenMPSimd)
 createOpenMPRuntime();
   if (LangOpts.CUDA)

I don't think you need to create OpenMP runtime support object if you're not 
going to use it (and you're not going to use it because you don't want to link 
it). You'd better create your own OMPSIMDRuntime class, that supports emission 
of the simd code only.



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

huntergr wrote:
> rengolin wrote:
> > I'd like @ABataev to confirm this is the right semantics.
> Yes, would be good. I don't think there's a formal spec for this feature, but 
> it's possible that directives intended for a different target than the cpu 
> shouldn't apply with this flag.
I don't think you need it here. Instead, you should keep an existing logic in 
Sema/Parsing code, but you need to create your own OpenMPRuntime support class, 
that supports only emission of simd part of the constructs.



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

huntergr wrote:
> rengolin wrote:
> > What if it's really unknown, even to `-fopenmp-simd`?
> I did wonder about handling this case; I defaulted to ignoring it, since we 
> are already filtering out other non-simd constructs.
> 
> If we do want to catch it, then I can think of two options: creating the 
> diagnostic right before the filter switch (possibly messy), or adding a new 
> enum value of OMPD_non_simd_construct (or a similar name) to represent 
> constructs we recognize but don't want to handle and differentiate against a 
> true unknown. I think the latter would be preferable.
Leave it as is, we still have to report errors, even in simd-only mode


https://reviews.llvm.org/D31417



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


[PATCH] D31765: Skip Unicode character expansion in assembly files

2017-04-06 Thread Salman Arif via Phabricator via cfe-commits
salari01 created this revision.

When using the C preprocessor with assembly files, either with a capital `S` 
file extension, or with `-xassembler-with-cpp`, the Unicode escape sequence 
`\u` is ignored. The `\u` pattern can be used for expanding a macro argument 
that starts with `u`.


https://reviews.llvm.org/D31765

Files:
  lib/Lex/Lexer.cpp
  test/Lexer/asm-preproc-no-unicode.s


Index: test/Lexer/asm-preproc-no-unicode.s
===
--- /dev/null
+++ test/Lexer/asm-preproc-no-unicode.s
@@ -0,0 +1,13 @@
+// RUN: %clang --target=arm-arm-none-eabi -c -xassembler-with-cpp %s -o %t 
2>&1 | FileCheck %s --check-prefix=WARNING
+// RUN: llvm-objdump -s %t | FileCheck %s --check-prefix=DATA
+
+// WARNING-NOT: warning: \u used with no following hex digits
+// DATA: Contents of section data:
+// DATA-NEXT:  efbeadde
+
+.warning  // required to avoid FileCheck empty input error
+.macro foo, u, name
+.section \name, "a", %progbits
+.word \u
+.endm
+foo 0xdeadbeef, data
Index: lib/Lex/Lexer.cpp
===
--- lib/Lex/Lexer.cpp
+++ lib/Lex/Lexer.cpp
@@ -3603,17 +3603,19 @@
 
   // UCNs (C99 6.4.3, C++11 [lex.charset]p2)
   case '\\':
-if (uint32_t CodePoint = tryReadUCN(CurPtr, BufferPtr, )) {
-  if (CheckUnicodeWhitespace(Result, CodePoint, CurPtr)) {
-if (SkipWhitespace(Result, CurPtr, TokAtPhysicalStartOfLine))
-  return true; // KeepWhitespaceMode
+if (!LangOpts.AsmPreprocessor) {
+  if (uint32_t CodePoint = tryReadUCN(CurPtr, BufferPtr, )) {
+if (CheckUnicodeWhitespace(Result, CodePoint, CurPtr)) {
+  if (SkipWhitespace(Result, CurPtr, TokAtPhysicalStartOfLine))
+return true; // KeepWhitespaceMode
+
+  // We only saw whitespace, so just try again with this lexer.
+  // (We manually eliminate the tail call to avoid recursion.)
+  goto LexNextToken;
+}
 
-// We only saw whitespace, so just try again with this lexer.
-// (We manually eliminate the tail call to avoid recursion.)
-goto LexNextToken;
+return LexUnicode(Result, CodePoint, CurPtr);
   }
-
-  return LexUnicode(Result, CodePoint, CurPtr);
 }
 
 Kind = tok::unknown;


Index: test/Lexer/asm-preproc-no-unicode.s
===
--- /dev/null
+++ test/Lexer/asm-preproc-no-unicode.s
@@ -0,0 +1,13 @@
+// RUN: %clang --target=arm-arm-none-eabi -c -xassembler-with-cpp %s -o %t 2>&1 | FileCheck %s --check-prefix=WARNING
+// RUN: llvm-objdump -s %t | FileCheck %s --check-prefix=DATA
+
+// WARNING-NOT: warning: \u used with no following hex digits
+// DATA: Contents of section data:
+// DATA-NEXT:  efbeadde
+
+.warning  // required to avoid FileCheck empty input error
+.macro foo, u, name
+.section \name, "a", %progbits
+.word \u
+.endm
+foo 0xdeadbeef, data
Index: lib/Lex/Lexer.cpp
===
--- lib/Lex/Lexer.cpp
+++ lib/Lex/Lexer.cpp
@@ -3603,17 +3603,19 @@
 
   // UCNs (C99 6.4.3, C++11 [lex.charset]p2)
   case '\\':
-if (uint32_t CodePoint = tryReadUCN(CurPtr, BufferPtr, )) {
-  if (CheckUnicodeWhitespace(Result, CodePoint, CurPtr)) {
-if (SkipWhitespace(Result, CurPtr, TokAtPhysicalStartOfLine))
-  return true; // KeepWhitespaceMode
+if (!LangOpts.AsmPreprocessor) {
+  if (uint32_t CodePoint = tryReadUCN(CurPtr, BufferPtr, )) {
+if (CheckUnicodeWhitespace(Result, CodePoint, CurPtr)) {
+  if (SkipWhitespace(Result, CurPtr, TokAtPhysicalStartOfLine))
+return true; // KeepWhitespaceMode
+
+  // We only saw whitespace, so just try again with this lexer.
+  // (We manually eliminate the tail call to avoid recursion.)
+  goto LexNextToken;
+}
 
-// We only saw whitespace, so just try again with this lexer.
-// (We manually eliminate the tail call to avoid recursion.)
-goto LexNextToken;
+return LexUnicode(Result, CodePoint, CurPtr);
   }
-
-  return LexUnicode(Result, CodePoint, CurPtr);
 }
 
 Kind = tok::unknown;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D16541: [libc++] Renable test/std/re/re.alg/re.alg.match/awk.pass.cpp

2017-04-06 Thread Mehdi AMINI via Phabricator via cfe-commits
mehdi_amini added a comment.

This bot is broken: 
http://green.lab.llvm.org/green/job/libcxx_master_cmake_32/61/


https://reviews.llvm.org/D16541



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


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

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

Ping! Any further questions? Thanks.


https://reviews.llvm.org/D31404



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


[PATCH] D29651: [OpenMP] Consider LIBRARY_PATH when selecting library paths for NVPTX targets in OpenMP mode.

2017-04-06 Thread Tom Stellard via Phabricator via cfe-commits
tstellar added a comment.

Why is this necessary?


Repository:
  rL LLVM

https://reviews.llvm.org/D29651



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


[PATCH] D30087: [Driver] Unify linking of OpenMP runtime. NFCI.

2017-04-06 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld updated this revision to Diff 94372.
Hahnfeld marked 2 inline comments as done.
Hahnfeld retitled this revision from "[Driver] Unify linking of OpenMP runtime" 
to "[Driver] Unify linking of OpenMP runtime. NFCI.".
Hahnfeld edited the summary of this revision.

https://reviews.llvm.org/D30087

Files:
  lib/Driver/ToolChains/CommonArgs.cpp
  lib/Driver/ToolChains/CommonArgs.h
  lib/Driver/ToolChains/Gnu.cpp
  test/Driver/fopenmp.c

Index: test/Driver/fopenmp.c
===
--- test/Driver/fopenmp.c
+++ test/Driver/fopenmp.c
@@ -18,29 +18,33 @@
 // CHECK-CC1-NO-OPENMP-NOT: "-fopenmp"
 //
 // RUN: %clang -target x86_64-linux-gnu -fopenmp=libomp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-LD-OMP
-// RUN: %clang -target x86_64-linux-gnu -fopenmp=libgomp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-LD-GOMP
+// RUN: %clang -target x86_64-linux-gnu -fopenmp=libgomp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-LD-GOMP --check-prefix=CHECK-LD-GOMP-RT
 // RUN: %clang -target x86_64-linux-gnu -fopenmp=libiomp5 %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-LD-IOMP5
 //
 // RUN: %clang -nostdlib -target x86_64-linux-gnu -fopenmp=libomp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-OMP
 // RUN: %clang -nostdlib -target x86_64-linux-gnu -fopenmp=libgomp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-GOMP
 // RUN: %clang -nostdlib -target x86_64-linux-gnu -fopenmp=libiomp5 %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-IOMP5
 //
 // RUN: %clang -target x86_64-darwin -fopenmp=libomp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-LD-OMP
-// RUN: %clang -target x86_64-darwin -fopenmp=libgomp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-LD-GOMP
+// RUN: %clang -target x86_64-darwin -fopenmp=libgomp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-LD-GOMP --check-prefix=CHECK-LD-GOMP-NO-RT
 // RUN: %clang -target x86_64-darwin -fopenmp=libiomp5 %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-LD-IOMP5
 //
 // RUN: %clang -nostdlib -target x86_64-darwin -fopenmp=libomp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-OMP
 // RUN: %clang -nostdlib -target x86_64-darwin -fopenmp=libgomp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-GOMP
 // RUN: %clang -nostdlib -target x86_64-darwin -fopenmp=libiomp5 %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-IOMP5
 //
-// RUN: %clang -target x86_64-netbsd -fopenmp=libomp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-LD-OMP
-// RUN: %clang -target x86_64-netbsd -fopenmp=libgomp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-LD-GOMP
-// RUN: %clang -target x86_64-netbsd -fopenmp=libiomp5 %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-LD-IOMP5
+// RUN: %clang -target x86_64-freebsd -fopenmp=libomp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-LD-OMP
+// RUN: %clang -target x86_64-freebsd -fopenmp=libgomp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-LD-GOMP --check-prefix=CHECK-LD-GOMP-NO-RT
+// RUN: %clang -target x86_64-freebsd -fopenmp=libiomp5 %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-LD-IOMP5
 //
 // RUN: %clang -nostdlib -target x86_64-freebsd -fopenmp=libomp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-OMP
 // RUN: %clang -nostdlib -target x86_64-freebsd -fopenmp=libgomp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-GOMP
 // RUN: %clang -nostdlib -target x86_64-freebsd -fopenmp=libiomp5 %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-IOMP5
 //
+// RUN: %clang -target x86_64-netbsd -fopenmp=libomp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-LD-OMP
+// RUN: %clang -target x86_64-netbsd -fopenmp=libgomp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-LD-GOMP --check-prefix=CHECK-LD-GOMP-NO-RT
+// RUN: %clang -target x86_64-netbsd -fopenmp=libiomp5 %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-LD-IOMP5
+//
 // RUN: %clang -nostdlib -target x86_64-netbsd -fopenmp=libomp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-OMP
 // RUN: %clang -nostdlib -target x86_64-netbsd -fopenmp=libgomp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-GOMP
 // RUN: %clang -nostdlib -target x86_64-netbsd -fopenmp=libiomp5 %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-IOMP5
@@ -50,6 +54,8 @@
 //
 // CHECK-LD-GOMP: "{{.*}}ld{{(.exe)?}}"
 // CHECK-LD-GOMP: "-lgomp"
+// CHECK-LD-GOMP-RT: "-lrt"
+// CHECK-LD-GOMP-NO-RT-NOT: "-lrt"
 //
 // CHECK-LD-IOMP5: "{{.*}}ld{{(.exe)?}}"
 // CHECK-LD-IOMP5: "-liomp5"
Index: lib/Driver/ToolChains/Gnu.cpp
===
--- lib/Driver/ToolChains/Gnu.cpp
+++ lib/Driver/ToolChains/Gnu.cpp
@@ -586,37 +586,15 @@
   bool WantPthread = Args.hasArg(options::OPT_pthread) ||
  Args.hasArg(options::OPT_pthreads);
 
-  if (Args.hasFlag(options::OPT_fopenmp, 

[PATCH] D30087: [Driver] Unify linking of OpenMP runtime. NFCI.

2017-04-06 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld added inline comments.



Comment at: lib/Driver/ToolChains/CommonArgs.cpp:430
+bool tools::addOpenMPRuntime(ArgStringList , const ToolChain ,
+ const ArgList , const JobAction ,
+ bool GompNeedsRT) {

ABataev wrote:
> Do you really need to pass a reference to `JobAction` here or it is enough to 
> pass a bool value for `JA.isHostOffloading()`?
Good idea, this even allows this change to become fully NFC


https://reviews.llvm.org/D30087



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


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

2017-04-06 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: lib/Sema/SemaOpenMP.cpp:358-360
+  /// Do the check specified in \a Check to all component lists at a given 
level
+  /// and return true if any issue is found.
+  bool checkMappableExprComponentListsForDeclAtLevel(

Could you join these 2 functions into one?


Repository:
  rL LLVM

https://reviews.llvm.org/D29905



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


r299653 - [analyzer] Reland r299544 "Add a modular constraint system to the CloneDetector"

2017-04-06 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Thu Apr  6 09:34:07 2017
New Revision: 299653

URL: http://llvm.org/viewvc/llvm-project?rev=299653=rev
Log:
[analyzer] Reland r299544 "Add a modular constraint system to the CloneDetector"

Hopefully fix crashes by unshadowing the variable.


Original commit message:

A big part of the clone detection code is functionality for filtering clones and
clone groups based on different criteria. So far this filtering process was
hardcoded into the CloneDetector class, which made it hard to understand and,
ultimately, to extend.

This patch splits the CloneDetector's logic into a sequence of reusable
constraints that are used for filtering clone groups. These constraints
can be turned on and off and reodreder at will, and new constraints are easy
to implement if necessary.

Unit tests are added for the new constraint interface.

This is a refactoring patch - no functional change intended.

Patch by Raphael Isemann!

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

Added:
cfe/trunk/unittests/Analysis/CloneDetectionTest.cpp
Modified:
cfe/trunk/include/clang/Analysis/CloneDetection.h
cfe/trunk/lib/Analysis/CloneDetection.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/CloneChecker.cpp
cfe/trunk/unittests/Analysis/CMakeLists.txt

Modified: cfe/trunk/include/clang/Analysis/CloneDetection.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/CloneDetection.h?rev=299653=299652=299653=diff
==
--- cfe/trunk/include/clang/Analysis/CloneDetection.h (original)
+++ cfe/trunk/include/clang/Analysis/CloneDetection.h Thu Apr  6 09:34:07 2017
@@ -16,9 +16,7 @@
 #define LLVM_CLANG_AST_CLONEDETECTION_H
 
 #include "clang/Basic/SourceLocation.h"
-#include "llvm/ADT/Hashing.h"
-#include "llvm/ADT/StringMap.h"
-
+#include "llvm/ADT/SmallVector.h"
 #include 
 
 namespace clang {
@@ -29,7 +27,7 @@ class VarDecl;
 class ASTContext;
 class CompoundStmt;
 
-/// \brief Identifies a list of statements.
+/// Identifies a list of statements.
 ///
 /// Can either identify a single arbitrary Stmt object, a continuous sequence 
of
 /// child statements inside a CompoundStmt or no statements at all.
@@ -39,8 +37,8 @@ class StmtSequence {
   /// Stmt, then S is a pointer to this Stmt.
   const Stmt *S;
 
-  /// The related ASTContext for S.
-  ASTContext *Context;
+  /// The declaration that contains the statements.
+  const Decl *D;
 
   /// If EndIndex is non-zero, then S is a CompoundStmt and this StmtSequence
   /// instance is representing the CompoundStmt children inside the array
@@ -49,7 +47,7 @@ class StmtSequence {
   unsigned EndIndex;
 
 public:
-  /// \brief Constructs a StmtSequence holding multiple statements.
+  /// Constructs a StmtSequence holding multiple statements.
   ///
   /// The resulting StmtSequence identifies a continuous sequence of statements
   /// in the body of the given CompoundStmt. Which statements of the body 
should
@@ -57,20 +55,20 @@ public:
   /// that describe a non-empty sub-array in the body of the given 
CompoundStmt.
   ///
   /// \param Stmt A CompoundStmt that contains all statements in its body.
-  /// \param Context The ASTContext for the given CompoundStmt.
+  /// \param Decl The Decl containing this Stmt.
   /// \param StartIndex The inclusive start index in the children array of
   ///   \p Stmt
   /// \param EndIndex The exclusive end index in the children array of \p Stmt.
-  StmtSequence(const CompoundStmt *Stmt, ASTContext ,
-   unsigned StartIndex, unsigned EndIndex);
+  StmtSequence(const CompoundStmt *Stmt, const Decl *D, unsigned StartIndex,
+   unsigned EndIndex);
 
-  /// \brief Constructs a StmtSequence holding a single statement.
+  /// Constructs a StmtSequence holding a single statement.
   ///
   /// \param Stmt An arbitrary Stmt.
-  /// \param Context The ASTContext for the given Stmt.
-  StmtSequence(const Stmt *Stmt, ASTContext );
+  /// \param Decl The Decl containing this Stmt.
+  StmtSequence(const Stmt *Stmt, const Decl *D);
 
-  /// \brief Constructs an empty StmtSequence.
+  /// Constructs an empty StmtSequence.
   StmtSequence();
 
   typedef const Stmt *const *iterator;
@@ -110,9 +108,12 @@ public:
   bool empty() const { return size() == 0; }
 
   /// Returns the related ASTContext for the stored Stmts.
-  ASTContext () const {
-assert(Context);
-return *Context;
+  ASTContext () const;
+
+  /// Returns the declaration that contains the stored Stmts.
+  const Decl *getContainingDecl() const {
+assert(D);
+return D;
   }
 
   /// Returns true if this objects holds a list of statements.
@@ -150,106 +151,214 @@ public:
   bool contains(const StmtSequence ) const;
 };
 
-/// \brief Searches for clones in source code.
+/// Searches for similar subtrees in the AST.
 ///
-/// First, this class needs a translation unit which is passed via
-/// \p analyzeTranslationUnit . It will 

[PATCH] D23418: [analyzer] Added a reusable constraint system to the CloneDetector

2017-04-06 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL299653: [analyzer] Reland r299544 "Add a modular constraint 
system to the CloneDetector" (authored by dergachev).

Changed prior to commit:
  https://reviews.llvm.org/D23418?vs=94337=94370#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D23418

Files:
  cfe/trunk/include/clang/Analysis/CloneDetection.h
  cfe/trunk/lib/Analysis/CloneDetection.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/CloneChecker.cpp
  cfe/trunk/unittests/Analysis/CMakeLists.txt
  cfe/trunk/unittests/Analysis/CloneDetectionTest.cpp

Index: cfe/trunk/lib/Analysis/CloneDetection.cpp
===
--- cfe/trunk/lib/Analysis/CloneDetection.cpp
+++ cfe/trunk/lib/Analysis/CloneDetection.cpp
@@ -24,27 +24,27 @@
 
 using namespace clang;
 
-StmtSequence::StmtSequence(const CompoundStmt *Stmt, ASTContext ,
+StmtSequence::StmtSequence(const CompoundStmt *Stmt, const Decl *D,
unsigned StartIndex, unsigned EndIndex)
-: S(Stmt), Context(), StartIndex(StartIndex), EndIndex(EndIndex) {
+: S(Stmt), D(D), StartIndex(StartIndex), EndIndex(EndIndex) {
   assert(Stmt && "Stmt must not be a nullptr");
   assert(StartIndex < EndIndex && "Given array should not be empty");
   assert(EndIndex <= Stmt->size() && "Given array too big for this Stmt");
 }
 
-StmtSequence::StmtSequence(const Stmt *Stmt, ASTContext )
-: S(Stmt), Context(), StartIndex(0), EndIndex(0) {}
+StmtSequence::StmtSequence(const Stmt *Stmt, const Decl *D)
+: S(Stmt), D(D), StartIndex(0), EndIndex(0) {}
 
 StmtSequence::StmtSequence()
-: S(nullptr), Context(nullptr), StartIndex(0), EndIndex(0) {}
+: S(nullptr), D(nullptr), StartIndex(0), EndIndex(0) {}
 
 bool StmtSequence::contains(const StmtSequence ) const {
-  // If both sequences reside in different translation units, they can never
-  // contain each other.
-  if (Context != Other.Context)
+  // If both sequences reside in different declarations, they can never contain
+  // each other.
+  if (D != Other.D)
 return false;
 
-  const SourceManager  = Context->getSourceManager();
+  const SourceManager  = getASTContext().getSourceManager();
 
   // Otherwise check if the start and end locations of the current sequence
   // surround the other sequence.
@@ -76,6 +76,11 @@
   return CS->body_begin() + EndIndex;
 }
 
+ASTContext ::getASTContext() const {
+  assert(D);
+  return D->getASTContext();
+}
+
 SourceLocation StmtSequence::getStartLoc() const {
   return front()->getLocStart();
 }
@@ -86,168 +91,8 @@
   return SourceRange(getStartLoc(), getEndLoc());
 }
 
-namespace {
-
-/// \brief Analyzes the pattern of the referenced variables in a statement.
-class VariablePattern {
-
-  /// \brief Describes an occurence of a variable reference in a statement.
-  struct VariableOccurence {
-/// The index of the associated VarDecl in the Variables vector.
-size_t KindID;
-/// The statement in the code where the variable was referenced.
-const Stmt *Mention;
-
-VariableOccurence(size_t KindID, const Stmt *Mention)
-: KindID(KindID), Mention(Mention) {}
-  };
-
-  /// All occurences of referenced variables in the order of appearance.
-  std::vector Occurences;
-  /// List of referenced variables in the order of appearance.
-  /// Every item in this list is unique.
-  std::vector Variables;
-
-  /// \brief Adds a new variable referenced to this pattern.
-  /// \param VarDecl The declaration of the variable that is referenced.
-  /// \param Mention The SourceRange where this variable is referenced.
-  void addVariableOccurence(const VarDecl *VarDecl, const Stmt *Mention) {
-// First check if we already reference this variable
-for (size_t KindIndex = 0; KindIndex < Variables.size(); ++KindIndex) {
-  if (Variables[KindIndex] == VarDecl) {
-// If yes, add a new occurence that points to the existing entry in
-// the Variables vector.
-Occurences.emplace_back(KindIndex, Mention);
-return;
-  }
-}
-// If this variable wasn't already referenced, add it to the list of
-// referenced variables and add a occurence that points to this new entry.
-Occurences.emplace_back(Variables.size(), Mention);
-Variables.push_back(VarDecl);
-  }
-
-  /// \brief Adds each referenced variable from the given statement.
-  void addVariables(const Stmt *S) {
-// Sometimes we get a nullptr (such as from IfStmts which often have nullptr
-// children). We skip such statements as they don't reference any
-// variables.
-if (!S)
-  return;
-
-// Check if S is a reference to a variable. If yes, add it to the pattern.
-if (auto D = dyn_cast(S)) {
-  if (auto VD = dyn_cast(D->getDecl()->getCanonicalDecl()))
-addVariableOccurence(VD, D);
-}
-
-// Recursively check all children of the given statement.
-for (const Stmt *Child : 

[PATCH] D16541: [libc++] Renable test/std/re/re.alg/re.alg.match/awk.pass.cpp

2017-04-06 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists accepted this revision.
mclow.lists added a comment.
This revision is now accepted and ready to land.

committed as revision 299652


https://reviews.llvm.org/D16541



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


[libcxx] r299652 - Restore Missing awk regex tests. Thanks to dexonsmith for noticing, and proposing this as https://reviews.llvm.org/D16541

2017-04-06 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Thu Apr  6 09:32:42 2017
New Revision: 299652

URL: http://llvm.org/viewvc/llvm-project?rev=299652=rev
Log:
Restore Missing awk regex tests. Thanks to dexonsmith for noticing, and 
proposing this as https://reviews.llvm.org/D16541

Modified:
libcxx/trunk/test/std/re/re.alg/re.alg.match/awk.pass.cpp

Modified: libcxx/trunk/test/std/re/re.alg/re.alg.match/awk.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/re.alg/re.alg.match/awk.pass.cpp?rev=299652=299651=299652=diff
==
--- libcxx/trunk/test/std/re/re.alg/re.alg.match/awk.pass.cpp (original)
+++ libcxx/trunk/test/std/re/re.alg/re.alg.match/awk.pass.cpp Thu Apr  6 
09:32:42 2017
@@ -26,7 +26,7 @@
 
 int main()
 {
-/*{
+{
 std::cmatch m;
 const char s[] = "a";
 assert(std::regex_match(s, m, std::regex("a", 
std::regex_constants::awk)));
@@ -616,13 +616,12 @@ int main()
 assert(m.size() == 0);
 }
 std::locale::global(std::locale(LOCALE_cs_CZ_ISO8859_2));
-*/{
-/*
+{
 std::cmatch m;
 const char s[] = "m";
-assert(std::regex_match(s, m, std::regex("[a[=M=]z]",
- std::regex_constants::awk);
-   assert(m.size() == 1);
+assert(std::regex_match(s, m, 
+  std::regex("[a[=M=]z]", std::regex_constants::awk)));
+assert(m.size() == 1);
 assert(!m.prefix().matched);
 assert(m.prefix().first == s);
 assert(m.prefix().second == m[0].first);
@@ -632,8 +631,8 @@ int main()
 assert(m.length(0) == std::char_traits::length(s));
 assert(m.position(0) == 0);
 assert(m.str(0) == s);
-*/}
-/*{
+}
+{
 std::cmatch m;
 const char s[] = "Ch";
 assert(std::regex_match(s, m, std::regex("[a[.ch.]z]",
@@ -1389,4 +1388,4 @@ int main()
 assert(m.position(0) == 0);
 assert(m.str(0) == s);
 }
-*/}
+}


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


[clang-tools-extra] r299651 - [clang-tidy] Update docs and help message

2017-04-06 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Thu Apr  6 09:27:00 2017
New Revision: 299651

URL: http://llvm.org/viewvc/llvm-project?rev=299651=rev
Log:
[clang-tidy] Update docs and help message

Modified:
clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp
clang-tools-extra/trunk/docs/clang-tidy/index.rst

Modified: clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp?rev=299651=299650=299651=diff
==
--- clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp Thu Apr  6 
09:27:00 2017
@@ -35,12 +35,13 @@ Configuration files:
   option, command-line option takes precedence. The effective
   configuration can be inspected using -dump-config:
 
-$ clang-tidy -dump-config - --
+$ clang-tidy -dump-config
 ---
 Checks:  '-*,some-check'
 WarningsAsErrors: ''
 HeaderFilterRegex: ''
 AnalyzeTemporaryDtors: false
+FormatStyle: none
 User:user
 CheckOptions:
   - key: some-check.SomeOption
@@ -131,6 +132,8 @@ Style for formatting code around applied
   - 'llvm', 'google', 'webkit', 'mozilla'
 See clang-format documentation for the up-to-date
 information about formatting styles and options.
+This option overrides the 'FormatStyle` option in
+.clang-tidy file, if any.
 )"),
cl::init("none"),
cl::cat(ClangTidyCategory));

Modified: clang-tools-extra/trunk/docs/clang-tidy/index.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/index.rst?rev=299651=299650=299651=diff
==
--- clang-tools-extra/trunk/docs/clang-tidy/index.rst (original)
+++ clang-tools-extra/trunk/docs/clang-tidy/index.rst Thu Apr  6 09:27:00 2017
@@ -169,6 +169,8 @@ An overview of all the command-line opti
  - 'llvm', 'google', 'webkit', 'mozilla'
See clang-format documentation for the 
up-to-date
information about formatting styles and 
options.
+   This option overrides the 'FormatStyle` 
option in
+   .clang-tidy file, if any.
 -header-filter=  -
Regular expression matching the names of the
headers to output diagnostics from. 
Diagnostics
@@ -195,9 +197,6 @@ An overview of all the command-line opti
printing statistics about ignored warnings 
and
warnings treated as errors if the respective
options are specified.
--style=  -
-   Fallback style for reformatting after 
inserting fixes
-   if there is no clang-format config file 
found.
 -system-headers  - Display the errors from system headers.
 -warnings-as-errors= -
Upgrades warnings to errors. Same format as
@@ -233,12 +232,13 @@ An overview of all the command-line opti
 option, command-line option takes precedence. The effective
 configuration can be inspected using -dump-config:
 
-  $ clang-tidy -dump-config - --
+  $ clang-tidy -dump-config
   ---
   Checks:  '-*,some-check'
   WarningsAsErrors: ''
   HeaderFilterRegex: ''
   AnalyzeTemporaryDtors: false
+  FormatStyle: none
   User:user
   CheckOptions:
 - key: some-check.SomeOption


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


[PATCH] D31745: [OpenCL] Added diagnostic for implicit declaration of function in OpenCL

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

What happens if user declared a function without parameter as `void f();` 
instead of `void f(void)` then try to use it? Will this be treated as implicit 
declaration and results in an error instead of warning?


https://reviews.llvm.org/D31745



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


r299650 - Avoid the -Wdocumentation-unknown-command warning in Clang's C API docs

2017-04-06 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Thu Apr  6 09:03:25 2017
New Revision: 299650

URL: http://llvm.org/viewvc/llvm-project?rev=299650=rev
Log:
Avoid the -Wdocumentation-unknown-command warning in Clang's C API docs

rdar://20441985

Modified:
cfe/trunk/include/clang-c/Index.h

Modified: cfe/trunk/include/clang-c/Index.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/Index.h?rev=299650=299649=299650=diff
==
--- cfe/trunk/include/clang-c/Index.h (original)
+++ cfe/trunk/include/clang-c/Index.h Thu Apr  6 09:03:25 2017
@@ -4034,8 +4034,8 @@ CINDEX_LINKAGE unsigned clang_Cursor_get
 
 /**
  * \brief Given a cursor that represents an Objective-C method or property
- * declaration, return non-zero if the declaration was affected by "@optional".
- * Returns zero if the cursor is not such a declaration or it is "@required".
+ * declaration, return non-zero if the declaration was affected by 
"\@optional".
+ * Returns zero if the cursor is not such a declaration or it is "\@required".
  */
 CINDEX_LINKAGE unsigned clang_Cursor_isObjCOptional(CXCursor C);
 
@@ -4711,7 +4711,7 @@ enum CXCompletionChunkKind {
*/
   CXCompletionChunk_HorizontalSpace,
   /**
-   * Vertical space ('\n'), after which it is generally a good idea to
+   * Vertical space ('\\n'), after which it is generally a good idea to
* perform indentation.
*/
   CXCompletionChunk_VerticalSpace


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


[PATCH] D31760: [lsan] Enable LSan on arm Linux, clang part

2017-04-06 Thread Maxim Ostapenko via Phabricator via cfe-commits
m.ostapenko created this revision.
Herald added subscribers: rengolin, aemerson.

This is a compiler part of https://reviews.llvm.org/D29586. Enable LSan on arm 
Linux.


Repository:
  rL LLVM

https://reviews.llvm.org/D31760

Files:
  lib/Driver/ToolChains/Linux.cpp
  test/Driver/fsanitize.c


Index: test/Driver/fsanitize.c
===
--- test/Driver/fsanitize.c
+++ test/Driver/fsanitize.c
@@ -234,6 +234,12 @@
 // RUN: %clang -target i686-linux-gnu -fsanitize=leak %s -### 2>&1 | FileCheck 
%s --check-prefix=CHECK-SANL-X86
 // CHECK-SANL-X86: "-fsanitize=leak"
 
+// RUN: %clang -target arm-linux-gnu -fsanitize=leak %s -### 2>&1 | FileCheck 
%s --check-prefix=CHECK-SANL-ARM
+// CHECK-SANL-ARM: "-fsanitize=leak"
+
+// RUN: %clang -target arm-linux-gnu -fsanitize=address,leak 
-fno-sanitize=address %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-SANA-SANL-NO-SANA-ARM
+// CHECK-SANA-SANL-NO-SANA-ARM: "-fsanitize=leak"
+
 // RUN: %clang -target i686-linux-gnu -fsanitize=address,leak 
-fno-sanitize=address %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-SANA-SANL-NO-SANA-X86
 // CHECK-SANA-SANL-NO-SANA-X86: "-fsanitize=leak"
 
Index: lib/Driver/ToolChains/Linux.cpp
===
--- lib/Driver/ToolChains/Linux.cpp
+++ lib/Driver/ToolChains/Linux.cpp
@@ -864,14 +864,15 @@
getTriple().getArch() == llvm::Triple::ppc64le;
   const bool IsAArch64 = getTriple().getArch() == llvm::Triple::aarch64 ||
  getTriple().getArch() == llvm::Triple::aarch64_be;
+  const bool IsArmArch = getTriple().getArch() == llvm::Triple::arm;
   SanitizerMask Res = ToolChain::getSupportedSanitizers();
   Res |= SanitizerKind::Address;
   Res |= SanitizerKind::KernelAddress;
   Res |= SanitizerKind::Vptr;
   Res |= SanitizerKind::SafeStack;
   if (IsX86_64 || IsMIPS64 || IsAArch64)
 Res |= SanitizerKind::DataFlow;
-  if (IsX86_64 || IsMIPS64 || IsAArch64 || IsX86)
+  if (IsX86_64 || IsMIPS64 || IsAArch64 || IsX86 || IsArmArch)
 Res |= SanitizerKind::Leak;
   if (IsX86_64 || IsMIPS64 || IsAArch64 || IsPowerPC64)
 Res |= SanitizerKind::Thread;


Index: test/Driver/fsanitize.c
===
--- test/Driver/fsanitize.c
+++ test/Driver/fsanitize.c
@@ -234,6 +234,12 @@
 // RUN: %clang -target i686-linux-gnu -fsanitize=leak %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANL-X86
 // CHECK-SANL-X86: "-fsanitize=leak"
 
+// RUN: %clang -target arm-linux-gnu -fsanitize=leak %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANL-ARM
+// CHECK-SANL-ARM: "-fsanitize=leak"
+
+// RUN: %clang -target arm-linux-gnu -fsanitize=address,leak -fno-sanitize=address %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANA-SANL-NO-SANA-ARM
+// CHECK-SANA-SANL-NO-SANA-ARM: "-fsanitize=leak"
+
 // RUN: %clang -target i686-linux-gnu -fsanitize=address,leak -fno-sanitize=address %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANA-SANL-NO-SANA-X86
 // CHECK-SANA-SANL-NO-SANA-X86: "-fsanitize=leak"
 
Index: lib/Driver/ToolChains/Linux.cpp
===
--- lib/Driver/ToolChains/Linux.cpp
+++ lib/Driver/ToolChains/Linux.cpp
@@ -864,14 +864,15 @@
getTriple().getArch() == llvm::Triple::ppc64le;
   const bool IsAArch64 = getTriple().getArch() == llvm::Triple::aarch64 ||
  getTriple().getArch() == llvm::Triple::aarch64_be;
+  const bool IsArmArch = getTriple().getArch() == llvm::Triple::arm;
   SanitizerMask Res = ToolChain::getSupportedSanitizers();
   Res |= SanitizerKind::Address;
   Res |= SanitizerKind::KernelAddress;
   Res |= SanitizerKind::Vptr;
   Res |= SanitizerKind::SafeStack;
   if (IsX86_64 || IsMIPS64 || IsAArch64)
 Res |= SanitizerKind::DataFlow;
-  if (IsX86_64 || IsMIPS64 || IsAArch64 || IsX86)
+  if (IsX86_64 || IsMIPS64 || IsAArch64 || IsX86 || IsArmArch)
 Res |= SanitizerKind::Leak;
   if (IsX86_64 || IsMIPS64 || IsAArch64 || IsPowerPC64)
 Res |= SanitizerKind::Thread;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r299649 - [clang-tidy] Add FormatStyle configuration option.

2017-04-06 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Thu Apr  6 08:41:29 2017
New Revision: 299649

URL: http://llvm.org/viewvc/llvm-project?rev=299649=rev
Log:
[clang-tidy] Add FormatStyle configuration option.

Modified:
clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
clang-tools-extra/trunk/clang-tidy/ClangTidy.h
clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.h
clang-tools-extra/trunk/clang-tidy/ClangTidyOptions.cpp
clang-tools-extra/trunk/clang-tidy/ClangTidyOptions.h
clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp

Modified: clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp?rev=299649=299648=299649=diff
==
--- clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp Thu Apr  6 08:41:29 2017
@@ -89,13 +89,13 @@ private:
 
 class ErrorReporter {
 public:
-  ErrorReporter(bool ApplyFixes, StringRef FormatStyle)
+  ErrorReporter(ClangTidyContext , bool ApplyFixes)
   : Files(FileSystemOptions()), DiagOpts(new DiagnosticOptions()),
 DiagPrinter(new TextDiagnosticPrinter(llvm::outs(), &*DiagOpts)),
 Diags(IntrusiveRefCntPtr(new DiagnosticIDs), &*DiagOpts,
   DiagPrinter),
-SourceMgr(Diags, Files), ApplyFixes(ApplyFixes), TotalFixes(0),
-AppliedFixes(0), WarningsAsErrors(0), FormatStyle(FormatStyle) {
+SourceMgr(Diags, Files), Context(Context), ApplyFixes(ApplyFixes),
+TotalFixes(0), AppliedFixes(0), WarningsAsErrors(0) {
 DiagOpts->ShowColors = llvm::sys::Process::StandardOutHasColors();
 DiagPrinter->BeginSourceFile(LangOpts);
   }
@@ -196,7 +196,8 @@ public:
   continue;
 }
 StringRef Code = Buffer.get()->getBuffer();
-auto Style = format::getStyle(FormatStyle, File, "none");
+auto Style = format::getStyle(
+*Context.getOptionsForFile(File).FormatStyle, File, "none");
 if (!Style) {
   llvm::errs() << llvm::toString(Style.takeError()) << "\n";
   continue;
@@ -255,11 +256,11 @@ private:
   DiagnosticsEngine Diags;
   SourceManager SourceMgr;
   llvm::StringMap FileReplacements;
+  ClangTidyContext 
   bool ApplyFixes;
   unsigned TotalFixes;
   unsigned AppliedFixes;
   unsigned WarningsAsErrors;
-  StringRef FormatStyle;
 };
 
 class ClangTidyASTConsumer : public MultiplexConsumer {
@@ -471,13 +472,10 @@ ClangTidyOptions::OptionMap getCheckOpti
   return Factory.getCheckOptions();
 }
 
-ClangTidyStats
-runClangTidy(std::unique_ptr OptionsProvider,
- const CompilationDatabase ,
- ArrayRef InputFiles,
- std::vector *Errors, ProfileData *Profile) {
+void runClangTidy(clang::tidy::ClangTidyContext ,
+  const CompilationDatabase ,
+  ArrayRef InputFiles, ProfileData *Profile) {
   ClangTool Tool(Compilations, InputFiles);
-  clang::tidy::ClangTidyContext Context(std::move(OptionsProvider));
 
   // Add extra arguments passed by the clang-tidy command-line.
   ArgumentsAdjuster PerFileExtraArgumentsInserter =
@@ -545,20 +543,18 @@ runClangTidy(std::unique_ptr , bool Fix,
-  StringRef FormatStyle, unsigned ) {
-  ErrorReporter Reporter(Fix, FormatStyle);
+void handleErrors(ClangTidyContext , bool Fix,
+  unsigned ) {
+  ErrorReporter Reporter(Context, Fix);
   vfs::FileSystem  =
   *Reporter.getSourceManager().getFileManager().getVirtualFileSystem();
   auto InitialWorkingDir = FileSystem.getCurrentWorkingDirectory();
   if (!InitialWorkingDir)
 llvm::report_fatal_error("Cannot get current working path.");
 
-  for (const ClangTidyError  : Errors) {
+  for (const ClangTidyError  : Context.getErrors()) {
 if (!Error.BuildDirectory.empty()) {
   // By default, the working directory of file system is the current
   // clang-tidy running directory.

Modified: clang-tools-extra/trunk/clang-tidy/ClangTidy.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidy.h?rev=299649=299648=299649=diff
==
--- clang-tools-extra/trunk/clang-tidy/ClangTidy.h (original)
+++ clang-tools-extra/trunk/clang-tidy/ClangTidy.h Thu Apr  6 08:41:29 2017
@@ -224,12 +224,10 @@ ClangTidyOptions::OptionMap getCheckOpti
 ///
 /// \param Profile if provided, it enables check profile collection in
 /// MatchFinder, and will contain the result of the profile.
-ClangTidyStats
-runClangTidy(std::unique_ptr OptionsProvider,
- const tooling::CompilationDatabase ,
- ArrayRef InputFiles,
- std::vector *Errors,
- ProfileData *Profile = nullptr);
+void runClangTidy(clang::tidy::ClangTidyContext ,
+  const tooling::CompilationDatabase ,
+  ArrayRef InputFiles,
+   

[PATCH] D31515: [libc++] Implement LWG 2911 - add an is_aggregate type-trait

2017-04-06 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists accepted this revision.
mclow.lists added a comment.
This revision is now accepted and ready to land.

LGTM


https://reviews.llvm.org/D31515



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


[PATCH] D31652: [clang-format] Recognize Java logical shift assignment operator

2017-04-06 Thread Nico Weber via Phabricator via cfe-commits
thakis added inline comments.



Comment at: include/clang/Basic/TokenKinds.def:230
+PUNCTUATOR(greatergreatergreaterequal, ">>>=")
+PUNCTUATOR(lesslesslessequal, "<<<=")
+

I think this is the wrong approach to go about this. clang is a C compiler, and 
its tokenizer shouldn't have to know about Java.  Instead, this should be 
handled in the formatter. See tryMergePreviousTokens() in 
lib/Format/FormatTokenLexer.cpp for how we do this for e.g. => or >>>= etc for 
JavaScript – just do the same for Java.


Repository:
  rL LLVM

https://reviews.llvm.org/D31652



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


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

2017-04-06 Thread Alex Lorenz via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL299648: [ObjC++] Conversions from specialized to 
non-specialized Objective-C generic (authored by arphaman).

Changed prior to commit:
  https://reviews.llvm.org/D31597?vs=93845=94360#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D31597

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


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


Index: cfe/trunk/lib/Sema/SemaOverload.cpp
===
--- cfe/trunk/lib/Sema/SemaOverload.cpp
+++ cfe/trunk/lib/Sema/SemaOverload.cpp
@@ -4047,7 +4047,7 @@
 = S.Context.canAssignObjCInterfaces(ToPtr1, ToPtr2);
   bool ToAssignRight
 = S.Context.canAssignObjCInterfaces(ToPtr2, ToPtr1);
-  
+
   // A conversion to an a non-id object pointer type or qualified 'id' 
   // type is better than a conversion to 'id'.
   if (ToPtr1->isObjCIdType() &&
@@ -4081,11 +4081,25 @@
 return ImplicitConversionSequence::Better;
 
   //   -- "conversion of C* to B* is better than conversion of C* to A*,"
-  if (S.Context.hasSameType(FromType1, FromType2) && 
+  if (S.Context.hasSameType(FromType1, FromType2) &&
   !FromPtr1->isObjCIdType() && !FromPtr1->isObjCClassType() &&
-  (ToAssignLeft != ToAssignRight))
+  (ToAssignLeft != ToAssignRight)) {
+if (FromPtr1->isSpecialized()) {
+  // "conversion of B * to B * is better than conversion of B * to
+  // C *.
+  bool IsFirstSame =
+  FromPtr1->getInterfaceDecl() == ToPtr1->getInterfaceDecl();
+  bool IsSecondSame =
+  FromPtr1->getInterfaceDecl() == ToPtr2->getInterfaceDecl();
+  if (IsFirstSame) {
+if (!IsSecondSame)
+  return ImplicitConversionSequence::Better;
+  } else if (IsSecondSame)
+return ImplicitConversionSequence::Worse;
+}
 return ToAssignLeft? 

r299648 - [ObjC++] Conversions from specialized to non-specialized Objective-C generic

2017-04-06 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Thu Apr  6 08:06:34 2017
New Revision: 299648

URL: http://llvm.org/viewvc/llvm-project?rev=299648=rev
Log:
[ObjC++] Conversions from specialized to non-specialized Objective-C generic
object types should be preferred over conversions to other object pointers

This change ensures that Clang will select the correct overload for the
following code sample:

  void overload(Base *b);
  void overload(Derived *d);
  void test(Base b) {
overload(b); // Select overload(Base *), not overload(Derived *)
  }

rdar://20124827

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

Modified:
cfe/trunk/lib/Sema/SemaOverload.cpp
cfe/trunk/test/SemaObjCXX/overload.mm

Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=299648=299647=299648=diff
==
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Thu Apr  6 08:06:34 2017
@@ -4047,7 +4047,7 @@ CompareDerivedToBaseConversions(Sema ,
 = S.Context.canAssignObjCInterfaces(ToPtr1, ToPtr2);
   bool ToAssignRight
 = S.Context.canAssignObjCInterfaces(ToPtr2, ToPtr1);
-  
+
   // A conversion to an a non-id object pointer type or qualified 'id' 
   // type is better than a conversion to 'id'.
   if (ToPtr1->isObjCIdType() &&
@@ -4081,11 +4081,25 @@ CompareDerivedToBaseConversions(Sema ,
 return ImplicitConversionSequence::Better;
 
   //   -- "conversion of C* to B* is better than conversion of C* to A*,"
-  if (S.Context.hasSameType(FromType1, FromType2) && 
+  if (S.Context.hasSameType(FromType1, FromType2) &&
   !FromPtr1->isObjCIdType() && !FromPtr1->isObjCClassType() &&
-  (ToAssignLeft != ToAssignRight))
+  (ToAssignLeft != ToAssignRight)) {
+if (FromPtr1->isSpecialized()) {
+  // "conversion of B * to B * is better than conversion of B * to
+  // C *.
+  bool IsFirstSame =
+  FromPtr1->getInterfaceDecl() == ToPtr1->getInterfaceDecl();
+  bool IsSecondSame =
+  FromPtr1->getInterfaceDecl() == ToPtr2->getInterfaceDecl();
+  if (IsFirstSame) {
+if (!IsSecondSame)
+  return ImplicitConversionSequence::Better;
+  } else if (IsSecondSame)
+return ImplicitConversionSequence::Worse;
+}
 return ToAssignLeft? ImplicitConversionSequence::Worse
: ImplicitConversionSequence::Better;
+  }
 
   //   -- "conversion of B* to A* is better than conversion of C* to A*,"
   if (S.Context.hasSameUnqualifiedType(ToType1, ToType2) &&

Modified: cfe/trunk/test/SemaObjCXX/overload.mm
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjCXX/overload.mm?rev=299648=299647=299648=diff
==
--- cfe/trunk/test/SemaObjCXX/overload.mm (original)
+++ cfe/trunk/test/SemaObjCXX/overload.mm Thu Apr  6 08:06:34 2017
@@ -174,3 +174,30 @@ namespace class_id {
   void f(Class) { }
   void f(id) { }
 }
+
+@interface NSDictionary<__covariant KeyType, __covariant ObjectType> : A
+@end
+
+@interface NSMutableDictionary : NSDictionary
+@end
+
+namespace rdar20124827 {
+
+int overload(NSDictionary *) { return 1; }
+
+__attribute__((deprecated))  // expected-note {{'overload' has been explicitly 
marked deprecated here}}
+int overload(NSMutableDictionary *) { return 0; }
+
+__attribute__((deprecated))
+void overload2(NSDictionary *); // expected-note {{candidate function}}
+void overload2(NSDictionary *); // expected-note {{candidate 
function}}
+
+void test(NSDictionary *d1, NSDictionary *d2, NSMutableDictionary *m1) {
+  overload(d1);
+  overload(d2); // no warning
+  overload(m1); // expected-warning {{'overload' is deprecated}}
+  overload2(d2); // no warning
+  overload2(m1); // expected-error {{call to 'overload2' is ambiguous}}
+}
+
+}


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


[PATCH] D31669: Fix lambda to block conversion in C++17 by avoiding copy elision for the lambda capture used by the created block

2017-04-06 Thread Alex Lorenz via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL299646: Fix lambda to block conversion in C++17 by avoiding 
copy elision for the (authored by arphaman).

Changed prior to commit:
  https://reviews.llvm.org/D31669?vs=94177=94358#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D31669

Files:
  cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
  cfe/trunk/include/clang/Sema/Initialization.h
  cfe/trunk/lib/Sema/SemaInit.cpp
  cfe/trunk/lib/Sema/SemaLambda.cpp
  cfe/trunk/test/CodeGenObjCXX/lambda-to-block.mm

Index: cfe/trunk/include/clang/Sema/Initialization.h
===
--- cfe/trunk/include/clang/Sema/Initialization.h
+++ cfe/trunk/include/clang/Sema/Initialization.h
@@ -70,6 +70,9 @@
 /// \brief The entity being initialized is a field of block descriptor for
 /// the copied-in c++ object.
 EK_BlockElement,
+/// The entity being initialized is a field of block descriptor for the
+/// copied-in lambda object that's used in the lambda to block conversion.
+EK_LambdaToBlockConversionBlockElement,
 /// \brief The entity being initialized is the real or imaginary part of a
 /// complex number.
 EK_ComplexElement,
@@ -260,7 +263,13 @@
QualType Type, bool NRVO) {
 return InitializedEntity(EK_BlockElement, BlockVarLoc, Type, NRVO);
   }
-  
+
+  static InitializedEntity InitializeLambdaToBlock(SourceLocation BlockVarLoc,
+   QualType Type, bool NRVO) {
+return InitializedEntity(EK_LambdaToBlockConversionBlockElement,
+ BlockVarLoc, Type, NRVO);
+  }
+
   /// \brief Create the initialization entity for an exception object.
   static InitializedEntity InitializeException(SourceLocation ThrowLoc,
QualType Type, bool NRVO) {
Index: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
@@ -1689,8 +1689,8 @@
   "cannot initialize %select{a variable|a parameter|return object|an "
   "exception object|a member subobject|an array element|a new value|a value|a "
   "base class|a constructor delegation|a vector element|a block element|a "
-  "complex element|a lambda capture|a compound literal initializer|a "
-  "related result|a parameter of CF audited function}0 "
+  "block element|a complex element|a lambda capture|a compound literal "
+  "initializer|a related result|a parameter of CF audited function}0 "
   "%diff{of type $ with an %select{rvalue|lvalue}2 of type $|"
   "with an %select{rvalue|lvalue}2 of incompatible type}1,3"
   "%select{|: different classes%diff{ ($ vs $)|}5,6"
Index: cfe/trunk/test/CodeGenObjCXX/lambda-to-block.mm
===
--- cfe/trunk/test/CodeGenObjCXX/lambda-to-block.mm
+++ cfe/trunk/test/CodeGenObjCXX/lambda-to-block.mm
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -x objective-c++ -fblocks -triple x86_64-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 -std=c++1z -emit-llvm -o - %s | FileCheck %s
+
+// rdar://31385153
+// Shouldn't crash!
+
+void takesBlock(void (^)(void));
+
+struct Copyable {
+  Copyable(const Copyable );
+};
+
+void hasLambda(Copyable x) {
+  takesBlock([x] () { });
+}
+// CHECK-LABEL: define internal void @__copy_helper_block_
+// CHECK: call void @"_ZZ9hasLambda8CopyableEN3$_0C1ERKS0_"
+// CHECK-LABEL: define internal void @"_ZZ9hasLambda8CopyableEN3$_0C2ERKS0_"
+// CHECK: call void @_ZN8CopyableC1ERKS_
Index: cfe/trunk/lib/Sema/SemaLambda.cpp
===
--- cfe/trunk/lib/Sema/SemaLambda.cpp
+++ cfe/trunk/lib/Sema/SemaLambda.cpp
@@ -1649,10 +1649,9 @@
   CallOperator->markUsed(Context);
 
   ExprResult Init = PerformCopyInitialization(
-  InitializedEntity::InitializeBlock(ConvLocation, 
- Src->getType(), 
- /*NRVO=*/false),
-  CurrentLocation, Src);
+  InitializedEntity::InitializeLambdaToBlock(ConvLocation, Src->getType(),
+ /*NRVO=*/false),
+  CurrentLocation, Src);
   if (!Init.isInvalid())
 Init = ActOnFinishFullExpr(Init.get());
   
Index: cfe/trunk/lib/Sema/SemaInit.cpp
===
--- cfe/trunk/lib/Sema/SemaInit.cpp
+++ cfe/trunk/lib/Sema/SemaInit.cpp
@@ -950,6 +950,7 @@
   case InitializedEntity::EK_Base:
   case InitializedEntity::EK_Delegating:
   case InitializedEntity::EK_BlockElement:
+  case InitializedEntity::EK_LambdaToBlockConversionBlockElement:
   case InitializedEntity::EK_Binding:
 

r299646 - Fix lambda to block conversion in C++17 by avoiding copy elision for the

2017-04-06 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Thu Apr  6 07:53:43 2017
New Revision: 299646

URL: http://llvm.org/viewvc/llvm-project?rev=299646=rev
Log:
Fix lambda to block conversion in C++17 by avoiding copy elision for the
lambda capture used by the created block

The commit r288866 introduced guaranteed copy elision to C++ 17. This
unfortunately broke the lambda to block conversion in C++17 (the compiler
crashes when performing IRGen). This commit fixes the conversion by avoiding
copy elision for the capture that captures the lambda that's used in the block
created by the lambda to block conversion process.

rdar://31385153

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

Added:
cfe/trunk/test/CodeGenObjCXX/lambda-to-block.mm
Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Sema/Initialization.h
cfe/trunk/lib/Sema/SemaInit.cpp
cfe/trunk/lib/Sema/SemaLambda.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=299646=299645=299646=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Apr  6 07:53:43 
2017
@@ -1689,8 +1689,8 @@ def err_init_conversion_failed : Error<
   "cannot initialize %select{a variable|a parameter|return object|an "
   "exception object|a member subobject|an array element|a new value|a value|a "
   "base class|a constructor delegation|a vector element|a block element|a "
-  "complex element|a lambda capture|a compound literal initializer|a "
-  "related result|a parameter of CF audited function}0 "
+  "block element|a complex element|a lambda capture|a compound literal "
+  "initializer|a related result|a parameter of CF audited function}0 "
   "%diff{of type $ with an %select{rvalue|lvalue}2 of type $|"
   "with an %select{rvalue|lvalue}2 of incompatible type}1,3"
   "%select{|: different classes%diff{ ($ vs $)|}5,6"

Modified: cfe/trunk/include/clang/Sema/Initialization.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Initialization.h?rev=299646=299645=299646=diff
==
--- cfe/trunk/include/clang/Sema/Initialization.h (original)
+++ cfe/trunk/include/clang/Sema/Initialization.h Thu Apr  6 07:53:43 2017
@@ -70,6 +70,9 @@ public:
 /// \brief The entity being initialized is a field of block descriptor for
 /// the copied-in c++ object.
 EK_BlockElement,
+/// The entity being initialized is a field of block descriptor for the
+/// copied-in lambda object that's used in the lambda to block conversion.
+EK_LambdaToBlockConversionBlockElement,
 /// \brief The entity being initialized is the real or imaginary part of a
 /// complex number.
 EK_ComplexElement,
@@ -260,7 +263,13 @@ public:
QualType Type, bool NRVO) {
 return InitializedEntity(EK_BlockElement, BlockVarLoc, Type, NRVO);
   }
-  
+
+  static InitializedEntity InitializeLambdaToBlock(SourceLocation BlockVarLoc,
+   QualType Type, bool NRVO) {
+return InitializedEntity(EK_LambdaToBlockConversionBlockElement,
+ BlockVarLoc, Type, NRVO);
+  }
+
   /// \brief Create the initialization entity for an exception object.
   static InitializedEntity InitializeException(SourceLocation ThrowLoc,
QualType Type, bool NRVO) {

Modified: cfe/trunk/lib/Sema/SemaInit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaInit.cpp?rev=299646=299645=299646=diff
==
--- cfe/trunk/lib/Sema/SemaInit.cpp (original)
+++ cfe/trunk/lib/Sema/SemaInit.cpp Thu Apr  6 07:53:43 2017
@@ -950,6 +950,7 @@ static void warnBracedScalarInit(Sema 
   case InitializedEntity::EK_Base:
   case InitializedEntity::EK_Delegating:
   case InitializedEntity::EK_BlockElement:
+  case InitializedEntity::EK_LambdaToBlockConversionBlockElement:
   case InitializedEntity::EK_Binding:
 llvm_unreachable("unexpected braced scalar init");
   }
@@ -2934,6 +2935,7 @@ DeclarationName InitializedEntity::getNa
   case EK_VectorElement:
   case EK_ComplexElement:
   case EK_BlockElement:
+  case EK_LambdaToBlockConversionBlockElement:
   case EK_CompoundLiteralInit:
   case EK_RelatedResult:
 return DeclarationName();
@@ -2963,6 +2965,7 @@ ValueDecl *InitializedEntity::getDecl()
   case EK_VectorElement:
   case EK_ComplexElement:
   case EK_BlockElement:
+  case EK_LambdaToBlockConversionBlockElement:
   case EK_LambdaCapture:
   case EK_CompoundLiteralInit:
   case EK_RelatedResult:
@@ -2992,6 +2995,7 @@ bool InitializedEntity::allowsNRVO() con
   case EK_VectorElement:
   

[clang-tools-extra] r299645 - Attempt to fix build bots after r299638.

2017-04-06 Thread Gabor Horvath via cfe-commits
Author: xazax
Date: Thu Apr  6 07:49:35 2017
New Revision: 299645

URL: http://llvm.org/viewvc/llvm-project?rev=299645=rev
Log:
Attempt to fix build bots after r299638.

Modified:

clang-tools-extra/trunk/test/clang-tidy/misc-forwarding-reference-overload.cpp

Modified: 
clang-tools-extra/trunk/test/clang-tidy/misc-forwarding-reference-overload.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/misc-forwarding-reference-overload.cpp?rev=299645=299644=299645=diff
==
--- 
clang-tools-extra/trunk/test/clang-tidy/misc-forwarding-reference-overload.cpp 
(original)
+++ 
clang-tools-extra/trunk/test/clang-tidy/misc-forwarding-reference-overload.cpp 
Thu Apr  6 07:49:35 2017
@@ -1,8 +1,8 @@
-// RUN: %check_clang_tidy %s misc-forwarding-reference-overload %t
+// RUN: %check_clang_tidy %s misc-forwarding-reference-overload %t -- -- 
-std=c++14
 
 namespace std {
 template 
-struct enable_if {};
+struct enable_if { typedef T type; };
 
 template 
 struct enable_if { typedef T type; };


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


[PATCH] D31757: [clang-tidy] Add a clang-tidy check for possible inefficient vector operations

2017-04-06 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 94356.
hokein added a comment.

Fix a small nit.


https://reviews.llvm.org/D31757

Files:
  clang-tidy/performance/CMakeLists.txt
  clang-tidy/performance/InefficientVectorOperationCheck.cpp
  clang-tidy/performance/InefficientVectorOperationCheck.h
  clang-tidy/performance/PerformanceTidyModule.cpp
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/performance-inefficient-vector-operation.rst
  test/clang-tidy/performance-inefficient-vector-operation.cpp

Index: test/clang-tidy/performance-inefficient-vector-operation.cpp
===
--- /dev/null
+++ test/clang-tidy/performance-inefficient-vector-operation.cpp
@@ -0,0 +1,102 @@
+// RUN: %check_clang_tidy %s performance-inefficient-vector-operation %t -- -format-style=llvm --
+
+typedef int size_t;
+
+namespace std {
+template 
+class vector {
+ public:
+  typedef T* iterator;
+  typedef const T* const_iterator;
+  typedef T& reference;
+  typedef const T& const_reference;
+  typedef size_t size_type;
+
+  explicit vector();
+  explicit vector(size_type n);
+
+  void push_back(const T& val);
+  void reserve(size_t n);
+  size_t size();
+  const_reference operator[] (size_type) const;
+  reference operator[] (size_type);
+};
+} // namespace std
+
+void f(std::vector& t) {
+  {
+std::vector v;
+// CHECK-FIXES: v.reserve(10);
+for (int i = 0; i < 10; ++i)
+  v.push_back(i);
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: push_back is called inside a loop; consider pre-allocating the vector capacity before the loop
+  }
+  {
+std::vector v;
+// CHECK-FIXES: v.reserve(t.size());
+for (size_t i = 0; i < t.size(); ++i) {
+  v.push_back(t[i]);
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: push_back is called
+}
+  }
+  {
+std::vector v;
+// CHECK-FIXES: v.reserve(t.size() - 1);
+for (size_t i = 0; i < t.size() - 1; ++i) {
+  v.push_back(t[i]);
+} // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: push_back is called
+  }
+
+  //  Non-fixed Cases 
+  {
+std::vector v;
+v.reserve(20);
+// CHECK-FIXES-NOT: v.reserve(10);
+// There is a "reserve" call already.
+for (int i = 0; i < 10; ++i) {
+  v.push_back(i);
+}
+  }
+  {
+std::vector v(20);
+// CHECK-FIXES-NOT: v.reserve(10);
+// v is not constructed with default constructor.
+for (int i = 0; i < 10; ++i) {
+  v.push_back(i);
+}
+  }
+  {
+std::vector v;
+// CHECK-FIXES-NOT: v.reserve(10);
+// For-loop is not started with 0.
+for (int i = 1; i < 10; ++i) {
+  v.push_back(i);
+}
+  }
+  {
+std::vector v;
+// CHECK-FIXES-NOT: v.reserve(t.size());
+// v isn't referenced in for-loop body.
+for (size_t i = 0; i < t.size(); ++i) {
+  t.push_back(i);
+}
+  }
+  {
+std::vector v;
+int k;
+// CHECK-FIXES-NOT: v.reserve(10);
+// For-loop isn't a fixable loop.
+for (size_t i = 0; k < 10; ++i) {
+  v.push_back(t[i]);
+}
+  }
+  {
+std::vector v;
+int k;
+// CHECK-FIXES-NOT: v.reserve(10);
+// For-loop isn't a fixable loop.
+for (size_t i = 0; i < 10; ++k) {
+  v.push_back(t[i]);
+}
+  }
+}
Index: docs/clang-tidy/checks/performance-inefficient-vector-operation.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/performance-inefficient-vector-operation.rst
@@ -0,0 +1,17 @@
+.. title:: clang-tidy - performance-inefficient-vector-operation
+
+performance-inefficient-vector-operation
+
+
+Finds possible inefficient vector push_back operation that causes unnecessary
+memory reallocation.
+
+.. code-block:: c++
+
+  std::vector v;
+  for (int i = 0; i < n; ++i) {
+v.push_back(n);
+// This will trigger the warning since the push_back may cause multiple
+// memory reallocations in v. This can be avoid by inserting a reserve(n)
+// statment before the for statment.
+  }
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -141,6 +141,7 @@
performance-for-range-copy
performance-implicit-cast-in-loop
performance-inefficient-string-concatenation
+   performance-inefficient-vector-operation
performance-type-promotion-in-math-fn
performance-unnecessary-copy-initialization
performance-unnecessary-value-param
Index: clang-tidy/performance/PerformanceTidyModule.cpp
===
--- clang-tidy/performance/PerformanceTidyModule.cpp
+++ clang-tidy/performance/PerformanceTidyModule.cpp
@@ -14,6 +14,7 @@
 #include "ForRangeCopyCheck.h"
 #include "ImplicitCastInLoopCheck.h"
 #include "InefficientStringConcatenationCheck.h"
+#include "InefficientVectorOperationCheck.h"
 #include "TypePromotionInMathFnCheck.h"
 

[PATCH] D31757: [clang-tidy] Add a clang-tidy check for possible inefficient vector operations

2017-04-06 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
Herald added a subscriber: mgorny.

The "performance-inefficient-vector-operation" check finds vector oprations in
for-loop statements which may cause multiple memory reallocations.

This is the first version, only detects typical for-loop:

  std::vector v;
  for (int i = 0; i < n; ++i) {
v.push_back(i);
  }
  
  // or
  
  for (int i = 0; i < v2.size(); ++i) {
v.push_back(v2[i]);
  }

We can extend it to handle more cases like for-range loop in the future.


https://reviews.llvm.org/D31757

Files:
  clang-tidy/performance/CMakeLists.txt
  clang-tidy/performance/InefficientVectorOperationCheck.cpp
  clang-tidy/performance/InefficientVectorOperationCheck.h
  clang-tidy/performance/PerformanceTidyModule.cpp
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/performance-inefficient-vector-operation.rst
  test/clang-tidy/performance-inefficient-vector-operation.cpp

Index: test/clang-tidy/performance-inefficient-vector-operation.cpp
===
--- /dev/null
+++ test/clang-tidy/performance-inefficient-vector-operation.cpp
@@ -0,0 +1,102 @@
+// RUN: %check_clang_tidy %s performance-inefficient-vector-operation %t -- -format-style=llvm --
+
+typedef int size_t;
+
+namespace std {
+template 
+class vector {
+ public:
+  typedef T* iterator;
+  typedef const T* const_iterator;
+  typedef T& reference;
+  typedef const T& const_reference;
+  typedef size_t size_type;
+
+  explicit vector();
+  explicit vector(size_type n);
+
+  void push_back(const T& val);
+  void reserve(size_t n);
+  size_t size();
+  const_reference operator[] (size_type) const;
+  reference operator[] (size_type);
+};
+} // namespace std
+
+void f(std::vector& t) {
+  {
+std::vector v;
+// CHECK-FIXES: v.reserve(10);
+for (int i = 0; i < 10; ++i)
+  v.push_back(i);
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: push_back is called inside a loop; consider pre-allocating the vector capacity before the loop
+  }
+  {
+std::vector v;
+// CHECK-FIXES: v.reserve(t.size());
+for (size_t i = 0; i < t.size(); ++i) {
+  v.push_back(t[i]);
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: push_back is called
+}
+  }
+  {
+std::vector v;
+// CHECK-FIXES: v.reserve(t.size() - 1);
+for (size_t i = 0; i < t.size() - 1; ++i) {
+  v.push_back(t[i]);
+} // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: push_back is called
+  }
+
+  //  Non-fixed Cases 
+  {
+std::vector v;
+v.reserve(20);
+// CHECK-FIXES-NOT: v.reserve(10);
+// There is a "reserve" call already.
+for (int i = 0; i < 10; ++i) {
+  v.push_back(i);
+}
+  }
+  {
+std::vector v(20);
+// CHECK-FIXES-NOT: v.reserve(10);
+// v is not constructed with default constructor.
+for (int i = 0; i < 10; ++i) {
+  v.push_back(i);
+}
+  }
+  {
+std::vector v;
+// CHECK-FIXES-NOT: v.reserve(10);
+// For-loop is not started with 0.
+for (int i = 1; i < 10; ++i) {
+  v.push_back(i);
+}
+  }
+  {
+std::vector v;
+// CHECK-FIXES-NOT: v.reserve(t.size());
+// v isn't referenced in for-loop body.
+for (size_t i = 0; i < t.size(); ++i) {
+  t.push_back(i);
+}
+  }
+  {
+std::vector v;
+int k;
+// CHECK-FIXES-NOT: v.reserve(10);
+// For-loop isn't a fixable loop.
+for (size_t i = 0; k < 10; ++i) {
+  v.push_back(t[i]);
+}
+  }
+  {
+std::vector v;
+int k;
+// CHECK-FIXES-NOT: v.reserve(10);
+// For-loop isn't a fixable loop.
+for (size_t i = 0; i < 10; ++k) {
+  v.push_back(t[i]);
+}
+  }
+}
Index: docs/clang-tidy/checks/performance-inefficient-vector-operation.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/performance-inefficient-vector-operation.rst
@@ -0,0 +1,17 @@
+.. title:: clang-tidy - performance-inefficient-vector-operation
+
+performance-inefficient-vector-operation
+
+
+Finds possible inefficient vector push_back operation that causes unnecessary
+memory reallocation.
+
+.. code-block:: c++
+
+  std::vector v;
+  for (int i = 0; i < n; ++i) {
+v.push_back(n);
+// This will trigger the warning since the push_back may cause multiple
+// memory reallocations in v. This can be avoid by inserting a reserve(n)
+// statment before the for statment.
+  }
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -141,6 +141,7 @@
performance-for-range-copy
performance-implicit-cast-in-loop
performance-inefficient-string-concatenation
+   performance-inefficient-vector-operation
performance-type-promotion-in-math-fn
performance-unnecessary-copy-initialization
performance-unnecessary-value-param
Index: 

[PATCH] D31756: [cmake] Support Gentoo install for z3

2017-04-06 Thread Michał Górny via Phabricator via cfe-commits
mgorny created this revision.

Add the 'z3' subdirectory to the list of possible path suffixes for
libz3 header search. The z3 headers are installed in /usr/include/z3
on Gentoo.


Repository:
  rL LLVM

https://reviews.llvm.org/D31756

Files:
  cmake/modules/FindZ3.cmake


Index: cmake/modules/FindZ3.cmake
===
--- cmake/modules/FindZ3.cmake
+++ cmake/modules/FindZ3.cmake
@@ -1,5 +1,5 @@
 find_path(Z3_INCLUDE_DIR NAMES z3.h
-   PATH_SUFFIXES libz3
+   PATH_SUFFIXES libz3 z3
)
 
 find_library(Z3_LIBRARIES NAMES z3 libz3


Index: cmake/modules/FindZ3.cmake
===
--- cmake/modules/FindZ3.cmake
+++ cmake/modules/FindZ3.cmake
@@ -1,5 +1,5 @@
 find_path(Z3_INCLUDE_DIR NAMES z3.h
-   PATH_SUFFIXES libz3
+   PATH_SUFFIXES libz3 z3
)
 
 find_library(Z3_LIBRARIES NAMES z3 libz3
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D31401: [clangd] Extract FsPath from file:// uri

2017-04-06 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir accepted this revision.
krasimir added a comment.
This revision is now accepted and ready to land.

Looks good!


https://reviews.llvm.org/D31401



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


[PATCH] D29877: Warn about unused static file scope function template declarations.

2017-04-06 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev updated this revision to Diff 94352.
v.g.vassilev marked an inline comment as done.
v.g.vassilev added a comment.

Improve comment.


https://reviews.llvm.org/D29877

Files:
  lib/Sema/Sema.cpp
  lib/Sema/SemaDecl.cpp
  test/SemaCXX/warn-unused-filescoped.cpp

Index: test/SemaCXX/warn-unused-filescoped.cpp
===
--- test/SemaCXX/warn-unused-filescoped.cpp
+++ test/SemaCXX/warn-unused-filescoped.cpp
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -Wunused -Wunused-member-function -Wno-unused-local-typedefs -Wno-c++11-extensions -std=c++98 %s
-// RUN: %clang_cc1 -fsyntax-only -verify -Wunused -Wunused-member-function -Wno-unused-local-typedefs -std=c++11 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wunused -Wunused-member-function -Wno-unused-local-typedefs -std=c++14 %s
 
 #ifdef HEADER
 
@@ -32,6 +32,14 @@
   inline void bar(int, int) { }
 };
 
+namespace test8 {
+// Should ignore overloaded operators.
+template 
+struct S {};
+template 
+static bool operator==(S lhs, S rhs) { }
+}
+
 namespace pr19713 {
 #if __cplusplus >= 201103L
   static constexpr int constexpr1() { return 1; }
@@ -65,7 +73,7 @@
   template <> void TS::m() { }  // expected-warning{{unused}}
 
   template 
-  void tf() { }
+  void tf() { }  // expected-warning{{unused}}
   template <> void tf() { }  // expected-warning{{unused}}
   
   struct VS {
@@ -200,6 +208,18 @@
 static void func() {}
 }
 
+namespace test9 {
+template
+static void completeRedeclChainForTemplateSpecialization() { } // expected-warning {{unused}}
+}
+
+namespace test10 {
+#if __cplusplus >= 201103L
+template
+constexpr T pi = T(3.14); // expected-warning {{unused}}
+#endif
+}
+
 namespace pr19713 {
 #if __cplusplus >= 201103L
   // FIXME: We should warn on both of these.
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -1493,6 +1493,10 @@
   // 'static inline' functions are defined in headers; don't warn.
   if (FD->isInlined() && !isMainFileLoc(*this, FD->getLocation()))
 return false;
+  // 'static operator' functions are defined in headers; don't warn.
+  if (FD->isOverloadedOperator() &&
+  !isMainFileLoc(*this, FD->getLocation()))
+return false;
 }
 
 if (FD->doesThisDeclarationHaveABody() &&
@@ -8887,6 +8891,7 @@
 if (FunctionTemplate) {
   if (NewFD->isInvalidDecl())
 FunctionTemplate->setInvalidDecl();
+  MarkUnusedFileScopedDecl(NewFD);
   return FunctionTemplate;
 }
   }
@@ -10991,8 +10996,7 @@
 
 /// FinalizeDeclaration - called by ParseDeclarationAfterDeclarator to perform
 /// any semantic actions necessary after any initializer has been attached.
-void
-Sema::FinalizeDeclaration(Decl *ThisDecl) {
+void Sema::FinalizeDeclaration(Decl *ThisDecl) {
   // Note that we are no longer parsing the initializer for this declaration.
   ParsingInitForAutoVars.erase(ThisDecl);
 
@@ -11157,9 +11161,8 @@
   if (DC->getRedeclContext()->isFileContext() && VD->isExternallyVisible())
 AddPushedVisibilityAttribute(VD);
 
-  // FIXME: Warn on unused templates.
-  if (VD->isFileVarDecl() && !VD->getDescribedVarTemplate() &&
-  !isa(VD))
+  // FIXME: Warn on unused var template partial specializations.
+  if (VD->isFileVarDecl() && !isa(VD))
 MarkUnusedFileScopedDecl(VD);
 
   // Now we have parsed the initializer and can update the table of magic
Index: lib/Sema/Sema.cpp
===
--- lib/Sema/Sema.cpp
+++ lib/Sema/Sema.cpp
@@ -470,6 +470,12 @@
 return true;
 
   if (const FunctionDecl *FD = dyn_cast(D)) {
+// If this is a function template and neither of its specs is used, warn.
+if (FunctionTemplateDecl *Template = FD->getDescribedFunctionTemplate())
+  for (const auto *Spec : Template->specializations())
+if (ShouldRemoveFromUnused(SemaRef, Spec))
+  return true;
+
 // UnusedFileScopedDecls stores the first declaration.
 // The declaration may have become definition so check again.
 const FunctionDecl *DeclToCheck;
@@ -493,6 +499,12 @@
 VD->isUsableInConstantExpressions(SemaRef->Context))
   return true;
 
+if (VarTemplateDecl *Template = VD->getDescribedVarTemplate())
+  // If this is a variable template and neither of its specs is used, warn.
+  for (const auto *Spec : Template->specializations())
+if (ShouldRemoveFromUnused(SemaRef, Spec))
+  return true;
+
 // UnusedFileScopedDecls stores the first declaration.
 // The declaration may have become definition so check again.
 const VarDecl *DeclToCheck = VD->getDefinition();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D29877: Warn about unused static file scope function template declarations.

2017-04-06 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev updated this revision to Diff 94350.
v.g.vassilev added a comment.

Found out which is the right place to avoid the linkage computation issues.


https://reviews.llvm.org/D29877

Files:
  lib/Sema/Sema.cpp
  lib/Sema/SemaDecl.cpp
  test/SemaCXX/warn-unused-filescoped.cpp

Index: test/SemaCXX/warn-unused-filescoped.cpp
===
--- test/SemaCXX/warn-unused-filescoped.cpp
+++ test/SemaCXX/warn-unused-filescoped.cpp
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -Wunused -Wunused-member-function -Wno-unused-local-typedefs -Wno-c++11-extensions -std=c++98 %s
-// RUN: %clang_cc1 -fsyntax-only -verify -Wunused -Wunused-member-function -Wno-unused-local-typedefs -std=c++11 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wunused -Wunused-member-function -Wno-unused-local-typedefs -std=c++14 %s
 
 #ifdef HEADER
 
@@ -32,6 +32,14 @@
   inline void bar(int, int) { }
 };
 
+namespace test8 {
+// Should ignore overloaded operators.
+template 
+struct S {};
+template 
+static bool operator==(S lhs, S rhs) { }
+}
+
 namespace pr19713 {
 #if __cplusplus >= 201103L
   static constexpr int constexpr1() { return 1; }
@@ -65,7 +73,7 @@
   template <> void TS::m() { }  // expected-warning{{unused}}
 
   template 
-  void tf() { }
+  void tf() { }  // expected-warning{{unused}}
   template <> void tf() { }  // expected-warning{{unused}}
   
   struct VS {
@@ -200,6 +208,18 @@
 static void func() {}
 }
 
+namespace test9 {
+template
+static void completeRedeclChainForTemplateSpecialization() { } // expected-warning {{unused}}
+}
+
+namespace test10 {
+#if __cplusplus >= 201103L
+template
+constexpr T pi = T(3.14); // expected-warning {{unused}}
+#endif
+}
+
 namespace pr19713 {
 #if __cplusplus >= 201103L
   // FIXME: We should warn on both of these.
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -1493,6 +1493,10 @@
   // 'static inline' functions are defined in headers; don't warn.
   if (FD->isInlined() && !isMainFileLoc(*this, FD->getLocation()))
 return false;
+  // 'static operator' functions are defined in headers; don't warn.
+  if (FD->isOverloadedOperator() &&
+  !isMainFileLoc(*this, FD->getLocation()))
+return false;
 }
 
 if (FD->doesThisDeclarationHaveABody() &&
@@ -8887,6 +8891,7 @@
 if (FunctionTemplate) {
   if (NewFD->isInvalidDecl())
 FunctionTemplate->setInvalidDecl();
+  MarkUnusedFileScopedDecl(NewFD);
   return FunctionTemplate;
 }
   }
@@ -10991,8 +10996,7 @@
 
 /// FinalizeDeclaration - called by ParseDeclarationAfterDeclarator to perform
 /// any semantic actions necessary after any initializer has been attached.
-void
-Sema::FinalizeDeclaration(Decl *ThisDecl) {
+void Sema::FinalizeDeclaration(Decl *ThisDecl) {
   // Note that we are no longer parsing the initializer for this declaration.
   ParsingInitForAutoVars.erase(ThisDecl);
 
@@ -11157,9 +11161,8 @@
   if (DC->getRedeclContext()->isFileContext() && VD->isExternallyVisible())
 AddPushedVisibilityAttribute(VD);
 
-  // FIXME: Warn on unused templates.
-  if (VD->isFileVarDecl() && !VD->getDescribedVarTemplate() &&
-  !isa(VD))
+  // FIXME: Warn on unused var template partial specializations.
+  if (VD->isFileVarDecl() && !isa(VD))
 MarkUnusedFileScopedDecl(VD);
 
   // Now we have parsed the initializer and can update the table of magic
Index: lib/Sema/Sema.cpp
===
--- lib/Sema/Sema.cpp
+++ lib/Sema/Sema.cpp
@@ -470,6 +470,13 @@
 return true;
 
   if (const FunctionDecl *FD = dyn_cast(D)) {
+// If this is a function template and neither of its specs is unused we
+// should warn.
+if (FunctionTemplateDecl *Template = FD->getDescribedFunctionTemplate())
+  for (const auto *Spec : Template->specializations())
+if (ShouldRemoveFromUnused(SemaRef, Spec))
+  return true;
+
 // UnusedFileScopedDecls stores the first declaration.
 // The declaration may have become definition so check again.
 const FunctionDecl *DeclToCheck;
@@ -493,6 +500,11 @@
 VD->isUsableInConstantExpressions(SemaRef->Context))
   return true;
 
+if (VarTemplateDecl *Template = VD->getDescribedVarTemplate())
+  for (const auto *Spec : Template->specializations())
+if (ShouldRemoveFromUnused(SemaRef, Spec))
+  return true;
+
 // UnusedFileScopedDecls stores the first declaration.
 // The declaration may have become definition so check again.
 const VarDecl *DeclToCheck = VD->getDefinition();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D31746: Remove ASTUnits for closed documents and cache CompilationDatabase per directory in clangd.

2017-04-06 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir added a comment.

Looks great! I'm wondering, can you think of ways to test the `didClose` method 
similarly to how it's done for other handlers?




Comment at: clangd/ASTManager.cpp:203
+  // TODO(ibiryukov): at this point DocDatasLock can be unlocked in 
asynchronous
+  // mode
 

Why not make the locking explicit here and don't require `handleRequest` and 
`parseFileAndPublishDiagnostics` to be called under a lock?



Comment at: clangd/ASTManager.h:60
+  ASTManagerRequest() = default;
+  ASTManagerRequest(ASTManagerRequestType Type, std::string FileUri,
+DocVersion FileVersion);

I'd call the second parameter just `Uri`.



Comment at: clangd/ASTManager.h:64
+  ASTManagerRequestType type;
+  std::string fileUri;
+  DocVersion fileVersion;

I'd call this `Uri`.



Comment at: clangd/ASTManager.h:65
+  std::string fileUri;
+  DocVersion fileVersion;
+};

I'd capitalize the member variables. In general, this is the llvm/clang style 
and the lowercase member variables in `Protocol.h` are for consistency with the 
Language Server Protocol.



Comment at: clangd/ASTManager.h:112
+  /// thread.
+  /// If RunSynchronously is true, runs the request handler immideately
+  void queueOrRun(ASTManagerRequestType RequestType, StringRef Uri);

nit: `s/immideately/immediately` and add a full stop.



Comment at: clangd/ASTManager.h:117
+  /// Should be called under DocDataLock when RunSynchronously is false
+  void handleRequest(ASTManagerRequestType RequestType, StringRef Uri);
+  /// Should be called under DocDataLock when RunSynchronously is false

It's sad that handle request should be called under the lock :(



Comment at: clangd/ASTManager.h:119
+  /// Should be called under DocDataLock when RunSynchronously is false
+  void parseFileAndPublishDiagnostics(StringRef Uri);
 

Maybe it's worth noting whether the main or the worker thread calls these 
during asynchronous execution.



Comment at: clangd/ASTManager.h:131
   std::shared_ptr PCHs;
+  /// A lock for access to the DocDatas, CompilationDatabases and PCHs
+  std::mutex DocDatasLock;

nit: missing trailing full stop.



Comment at: clangd/ASTManager.h:132
+  /// A lock for access to the DocDatas, CompilationDatabases and PCHs
+  std::mutex DocDatasLock;
 

I'd rename this lock to `ClangObjectLock` or something else; its name currently 
gives the wrong feeling that it's used only for `DocDatas`.


https://reviews.llvm.org/D31746



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


[PATCH] D31652: [clang-format] Recognize Java logical shift assignment operator

2017-04-06 Thread Richard Bradfield via Phabricator via cfe-commits
bradfier added inline comments.



Comment at: include/clang/Basic/LangOptions.def:95
 LANGOPT(ObjC2 , 1, 0, "Objective-C 2")
+LANGOPT(Java  , 1, 0, "Java")
 BENIGN_LANGOPT(ObjCDefaultSynthProperties , 1, 0,

arphaman wrote:
> I don't think we should have a `Java` lang option, since Clang is not 
> actually a Java frontend. Maybe another option like `LogicalShiftOperators` 
> will work better?
That seems reasonable. C and C++ have `>>>` or `<<<` operators as part of CUDA 
extensions though, so maybe the full `LogicalShiftAssignOperators` is more 
precise?


Repository:
  rL LLVM

https://reviews.llvm.org/D31652



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


[PATCH] D31652: [clang-format] Recognize Java logical shift assignment operator

2017-04-06 Thread Richard Bradfield via Phabricator via cfe-commits
bradfier added a comment.

In https://reviews.llvm.org/D31652#719990, @arphaman wrote:

> Are the `<<<` and `>>>` operators handled correctly?


Yes, as a side-effect of CUDA kernel-call syntax which uses `>>>` and `<<<`, 
those tokens are recognised as punctuators.


Repository:
  rL LLVM

https://reviews.llvm.org/D31652



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


[PATCH] D23418: [analyzer] Added a reusable constraint system to the CloneDetector

2017-04-06 Thread Raphael Isemann via Phabricator via cfe-commits
teemperor added a comment.

I think for range loops work differently:

#include 
#include 
#include 

struct Foo {
 int* begin() const { assert(false); }
 int* end() const { assert(false); }
 void bar() const { std::cout << "Different behavior" << std::endl; }
};

int main() {

  std::vector F;
  F.resize(1);
  for (const Foo* F : F) {
  F->bar();
  }

}

teemperor@ftlserver ~/test> clang++ test.cpp -std=c++11 ; and ./a.out 
Different behavior


https://reviews.llvm.org/D23418



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


r299643 - [Sema] Retarget test to a specific platform for consistent datasizes

2017-04-06 Thread Simon Dardis via cfe-commits
Author: sdardis
Date: Thu Apr  6 06:12:14 2017
New Revision: 299643

URL: http://llvm.org/viewvc/llvm-project?rev=299643=rev
Log:
[Sema] Retarget test to a specific platform for consistent datasizes

Attempt to satisfy llvm-clang-x86_64-expensive-checks-win by targeting
x86_64-apple-darwin10 for Sema/vector-ops.c. The underlying failure is
due to datatype differences between platforms.


Modified:
cfe/trunk/test/Sema/vector-ops.c

Modified: cfe/trunk/test/Sema/vector-ops.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/vector-ops.c?rev=299643=299642=299643=diff
==
--- cfe/trunk/test/Sema/vector-ops.c (original)
+++ cfe/trunk/test/Sema/vector-ops.c Thu Apr  6 06:12:14 2017
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -verify -fsyntax-only -Wvector-conversion
+// RUN: %clang_cc1 %s -verify -fsyntax-only -Wvector-conversion -triple 
x86_64-apple-darwin10
 typedef unsigned int v2u __attribute__ ((vector_size (8)));
 typedef int v2s __attribute__ ((vector_size (8)));
 typedef float v2f __attribute__ ((vector_size(8)));


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


[PATCH] D31652: [clang-format] Recognize Java logical shift assignment operator

2017-04-06 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added inline comments.



Comment at: include/clang/Basic/LangOptions.def:95
 LANGOPT(ObjC2 , 1, 0, "Objective-C 2")
+LANGOPT(Java  , 1, 0, "Java")
 BENIGN_LANGOPT(ObjCDefaultSynthProperties , 1, 0,

I don't think we should have a `Java` lang option, since Clang is not actually 
a Java frontend. Maybe another option like `LogicalShiftOperators` will work 
better?


Repository:
  rL LLVM

https://reviews.llvm.org/D31652



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


[PATCH] D31652: [clang-format] Recognize Java logical shift assignment operator

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

Are the `<<<` and `>>>` operators handled correctly?


Repository:
  rL LLVM

https://reviews.llvm.org/D31652



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


[clang-tools-extra] r299642 - Wdocumentation fix

2017-04-06 Thread Simon Pilgrim via cfe-commits
Author: rksimon
Date: Thu Apr  6 05:49:02 2017
New Revision: 299642

URL: http://llvm.org/viewvc/llvm-project?rev=299642=rev
Log:
Wdocumentation fix

Modified:
clang-tools-extra/trunk/clang-rename/USRLocFinder.h

Modified: clang-tools-extra/trunk/clang-rename/USRLocFinder.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-rename/USRLocFinder.h?rev=299642=299641=299642=diff
==
--- clang-tools-extra/trunk/clang-rename/USRLocFinder.h (original)
+++ clang-tools-extra/trunk/clang-rename/USRLocFinder.h Thu Apr  6 05:49:02 2017
@@ -29,9 +29,9 @@ namespace rename {
 /// Create atomic changes for renaming all symbol references which are
 /// identified by the USRs set to a given new name.
 ///
-/// \param USRs: The set containing USRs of a particular old symbol.
-/// \param NewName: The new name to replace old symbol name.
-/// \param TranslationUnitDecl: The translation unit declaration.
+/// \param USRs The set containing USRs of a particular old symbol.
+/// \param NewName The new name to replace old symbol name.
+/// \param TranslationUnitDecl The translation unit declaration.
 ///
 /// \return Atomic changes for renaming.
 std::vector


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


[PATCH] D23418: [analyzer] Added a reusable constraint system to the CloneDetector

2017-04-06 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

  $ cat test.c
  #include 
  int main() {
int i = 5;
{
  int i = i;
  printf("%d\n", i);
}
return 0;
  }
  $ clang test.c
  $ ./a.out
  32767
  $ clang test.c -Xclang -ast-dump
  ...
  `-FunctionDecl 0x7ff82d8eac78  line:2:5 main 'int ()'
`-CompoundStmt 0x7ff82d8eb070 
  |-DeclStmt 0x7ff82d8eadb0 
  | `-VarDecl 0x7ff82d8ead30  col:7 i 'int' cinit
  |   `-IntegerLiteral 0x7ff82d8ead90  'int' 5
  |-CompoundStmt 0x7ff82d8eb010 
  | |-DeclStmt 0x7ff82d8eae78 
  | | `-VarDecl 0x7ff82d8eadd8  col:9 used i 'int' cinit
  | |   `-ImplicitCastExpr 0x7ff82d8eae60  'int' 
  | | `-DeclRefExpr 0x7ff82d8eae38  'int' lvalue Var 
0x7ff82d8eadd
  ...

It seems that in `int i = i;` the `i` in the new `i`, which is already declared 
by now, just not initialized yet, rather than the old `i`.


https://reviews.llvm.org/D23418



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


r299641 - [Sema] Extend GetSignedVectorType to deal with non ExtVector types

2017-04-06 Thread Simon Dardis via cfe-commits
Author: sdardis
Date: Thu Apr  6 05:38:03 2017
New Revision: 299641

URL: http://llvm.org/viewvc/llvm-project?rev=299641=rev
Log:
[Sema] Extend GetSignedVectorType to deal with non ExtVector types

This improves some error messages which would otherwise refer to
ext_vector_type types in contexts where there are no such types.

Factored out from D25866 at reviewer's request.

Reviewers: bruno

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


Modified:
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/Sema/vector-ops.c

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=299641=299640=299641=diff
==
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Thu Apr  6 05:38:03 2017
@@ -9711,24 +9711,45 @@ QualType Sema::CheckCompareOperands(Expr
   return InvalidOperands(Loc, LHS, RHS);
 }
 
-
-// Return a signed type that is of identical size and number of elements.
-// For floating point vectors, return an integer type of identical size 
-// and number of elements.
+// Return a signed ext_vector_type that is of identical size and number of
+// elements. For floating point vectors, return an integer type of identical
+// size and number of elements. In the non ext_vector_type case, search from
+// the largest type to the smallest type to avoid cases where long long == 
long,
+// where long gets picked over long long.
 QualType Sema::GetSignedVectorType(QualType V) {
   const VectorType *VTy = V->getAs();
   unsigned TypeSize = Context.getTypeSize(VTy->getElementType());
-  if (TypeSize == Context.getTypeSize(Context.CharTy))
-return Context.getExtVectorType(Context.CharTy, VTy->getNumElements());
-  else if (TypeSize == Context.getTypeSize(Context.ShortTy))
-return Context.getExtVectorType(Context.ShortTy, VTy->getNumElements());
-  else if (TypeSize == Context.getTypeSize(Context.IntTy))
-return Context.getExtVectorType(Context.IntTy, VTy->getNumElements());
+
+  if (isa(VTy)) {
+if (TypeSize == Context.getTypeSize(Context.CharTy))
+  return Context.getExtVectorType(Context.CharTy, VTy->getNumElements());
+else if (TypeSize == Context.getTypeSize(Context.ShortTy))
+  return Context.getExtVectorType(Context.ShortTy, VTy->getNumElements());
+else if (TypeSize == Context.getTypeSize(Context.IntTy))
+  return Context.getExtVectorType(Context.IntTy, VTy->getNumElements());
+else if (TypeSize == Context.getTypeSize(Context.LongTy))
+  return Context.getExtVectorType(Context.LongTy, VTy->getNumElements());
+assert(TypeSize == Context.getTypeSize(Context.LongLongTy) &&
+   "Unhandled vector element size in vector compare");
+return Context.getExtVectorType(Context.LongLongTy, VTy->getNumElements());
+  }
+
+  if (TypeSize == Context.getTypeSize(Context.LongLongTy))
+return Context.getVectorType(Context.LongLongTy, VTy->getNumElements(),
+ VectorType::GenericVector);
   else if (TypeSize == Context.getTypeSize(Context.LongTy))
-return Context.getExtVectorType(Context.LongTy, VTy->getNumElements());
-  assert(TypeSize == Context.getTypeSize(Context.LongLongTy) &&
+return Context.getVectorType(Context.LongTy, VTy->getNumElements(),
+ VectorType::GenericVector);
+  else if (TypeSize == Context.getTypeSize(Context.IntTy))
+return Context.getVectorType(Context.IntTy, VTy->getNumElements(),
+ VectorType::GenericVector);
+  else if (TypeSize == Context.getTypeSize(Context.ShortTy))
+return Context.getVectorType(Context.ShortTy, VTy->getNumElements(),
+ VectorType::GenericVector);
+  assert(TypeSize == Context.getTypeSize(Context.CharTy) &&
  "Unhandled vector element size in vector compare");
-  return Context.getExtVectorType(Context.LongLongTy, VTy->getNumElements());
+  return Context.getVectorType(Context.CharTy, VTy->getNumElements(),
+   VectorType::GenericVector);
 }
 
 /// CheckVectorCompareOperands - vector comparisons are a clang extension that
@@ -9775,7 +9796,7 @@ QualType Sema::CheckVectorCompareOperand
 assert (RHS.get()->getType()->hasFloatingRepresentation());
 CheckFloatComparison(Loc, LHS.get(), RHS.get());
   }
-  
+
   // Return a signed type for the vector.
   return GetSignedVectorType(vType);
 }
@@ -9792,7 +9813,7 @@ QualType Sema::CheckVectorLogicalOperand
   if (getLangOpts().OpenCL && getLangOpts().OpenCLVersion < 120 &&
   vType->hasFloatingRepresentation())
 return InvalidOperands(Loc, LHS, RHS);
-  
+
   return GetSignedVectorType(LHS.get()->getType());
 }
 

Modified: cfe/trunk/test/Sema/vector-ops.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/vector-ops.c?rev=299641=299640=299641=diff

[PATCH] D31667: [Sema] Extend GetSignedVectorType to deal with non ExtVector types

2017-04-06 Thread Simon Dardis via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL299641: [Sema] Extend GetSignedVectorType to deal with non 
ExtVector types (authored by sdardis).

Changed prior to commit:
  https://reviews.llvm.org/D31667?vs=94205=94344#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D31667

Files:
  cfe/trunk/lib/Sema/SemaExpr.cpp
  cfe/trunk/test/Sema/vector-ops.c

Index: cfe/trunk/lib/Sema/SemaExpr.cpp
===
--- cfe/trunk/lib/Sema/SemaExpr.cpp
+++ cfe/trunk/lib/Sema/SemaExpr.cpp
@@ -9711,24 +9711,45 @@
   return InvalidOperands(Loc, LHS, RHS);
 }
 
-
-// Return a signed type that is of identical size and number of elements.
-// For floating point vectors, return an integer type of identical size 
-// and number of elements.
+// Return a signed ext_vector_type that is of identical size and number of
+// elements. For floating point vectors, return an integer type of identical
+// size and number of elements. In the non ext_vector_type case, search from
+// the largest type to the smallest type to avoid cases where long long == long,
+// where long gets picked over long long.
 QualType Sema::GetSignedVectorType(QualType V) {
   const VectorType *VTy = V->getAs();
   unsigned TypeSize = Context.getTypeSize(VTy->getElementType());
-  if (TypeSize == Context.getTypeSize(Context.CharTy))
-return Context.getExtVectorType(Context.CharTy, VTy->getNumElements());
-  else if (TypeSize == Context.getTypeSize(Context.ShortTy))
-return Context.getExtVectorType(Context.ShortTy, VTy->getNumElements());
-  else if (TypeSize == Context.getTypeSize(Context.IntTy))
-return Context.getExtVectorType(Context.IntTy, VTy->getNumElements());
+
+  if (isa(VTy)) {
+if (TypeSize == Context.getTypeSize(Context.CharTy))
+  return Context.getExtVectorType(Context.CharTy, VTy->getNumElements());
+else if (TypeSize == Context.getTypeSize(Context.ShortTy))
+  return Context.getExtVectorType(Context.ShortTy, VTy->getNumElements());
+else if (TypeSize == Context.getTypeSize(Context.IntTy))
+  return Context.getExtVectorType(Context.IntTy, VTy->getNumElements());
+else if (TypeSize == Context.getTypeSize(Context.LongTy))
+  return Context.getExtVectorType(Context.LongTy, VTy->getNumElements());
+assert(TypeSize == Context.getTypeSize(Context.LongLongTy) &&
+   "Unhandled vector element size in vector compare");
+return Context.getExtVectorType(Context.LongLongTy, VTy->getNumElements());
+  }
+
+  if (TypeSize == Context.getTypeSize(Context.LongLongTy))
+return Context.getVectorType(Context.LongLongTy, VTy->getNumElements(),
+ VectorType::GenericVector);
   else if (TypeSize == Context.getTypeSize(Context.LongTy))
-return Context.getExtVectorType(Context.LongTy, VTy->getNumElements());
-  assert(TypeSize == Context.getTypeSize(Context.LongLongTy) &&
+return Context.getVectorType(Context.LongTy, VTy->getNumElements(),
+ VectorType::GenericVector);
+  else if (TypeSize == Context.getTypeSize(Context.IntTy))
+return Context.getVectorType(Context.IntTy, VTy->getNumElements(),
+ VectorType::GenericVector);
+  else if (TypeSize == Context.getTypeSize(Context.ShortTy))
+return Context.getVectorType(Context.ShortTy, VTy->getNumElements(),
+ VectorType::GenericVector);
+  assert(TypeSize == Context.getTypeSize(Context.CharTy) &&
  "Unhandled vector element size in vector compare");
-  return Context.getExtVectorType(Context.LongLongTy, VTy->getNumElements());
+  return Context.getVectorType(Context.CharTy, VTy->getNumElements(),
+   VectorType::GenericVector);
 }
 
 /// CheckVectorCompareOperands - vector comparisons are a clang extension that
@@ -9775,7 +9796,7 @@
 assert (RHS.get()->getType()->hasFloatingRepresentation());
 CheckFloatComparison(Loc, LHS.get(), RHS.get());
   }
-  
+
   // Return a signed type for the vector.
   return GetSignedVectorType(vType);
 }
@@ -9792,7 +9813,7 @@
   if (getLangOpts().OpenCL && getLangOpts().OpenCLVersion < 120 &&
   vType->hasFloatingRepresentation())
 return InvalidOperands(Loc, LHS, RHS);
-  
+
   return GetSignedVectorType(LHS.get()->getType());
 }
 
Index: cfe/trunk/test/Sema/vector-ops.c
===
--- cfe/trunk/test/Sema/vector-ops.c
+++ cfe/trunk/test/Sema/vector-ops.c
@@ -13,9 +13,9 @@
   (void)(~v2fa); // expected-error{{invalid argument type 'v2f' (vector of 2 'float' values) to unary}}
 
   // Comparison operators
-  v2ua = (v2ua==v2sa); // expected-warning{{incompatible vector types assigning to 'v2u' (vector of 2 'unsigned int' values) from 'int __attribute__((ext_vector_type(2)))' (vector of 2 'int' values)}}
+  v2ua = (v2ua==v2sa); // expected-warning{{incompatible vector types 

  1   2   >