Buildmaster restart

2017-08-04 Thread Victor Leschuk via cfe-commits
Hello everyone,
LLVM buildmaster was updated and restarted, downtime was about 2 minutes.

-- 
Best Regards,

Victor Leschuk | Software Engineer |Access Softek

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


[PATCH] D36349: [CMake] Build sanitized C++ runtimes for Fuchsia

2017-08-04 Thread Petr Hosek via Phabricator via cfe-commits
phosek updated this revision to Diff 109852.

Repository:
  rL LLVM

https://reviews.llvm.org/D36349

Files:
  cmake/caches/Fuchsia-stage2.cmake


Index: cmake/caches/Fuchsia-stage2.cmake
===
--- cmake/caches/Fuchsia-stage2.cmake
+++ cmake/caches/Fuchsia-stage2.cmake
@@ -36,7 +36,7 @@
   list(APPEND LLVM_BUILTIN_TARGETS "default")
 endif()
 
-set(LLVM_RUNTIME_TARGETS "default;x86_64-fuchsia;aarch64-fuchsia" CACHE STRING 
"")
+set(LLVM_RUNTIME_TARGETS 
"default;x86_64-fuchsia;aarch64-fuchsia;x86_64-fuchsia-asan:x86_64-fuchsia;aarch64-fuchsia-asan:aarch64-fuchsia"
 CACHE STRING "")
 foreach(target x86_64;aarch64)
   set(RUNTIMES_${target}-fuchsia_CMAKE_BUILD_WITH_INSTALL_RPATH ON CACHE BOOL 
"")
   set(RUNTIMES_${target}-fuchsia_CMAKE_SYSROOT ${FUCHSIA_${target}_SYSROOT} 
CACHE PATH "")
@@ -53,6 +53,24 @@
   set(RUNTIMES_${target}-fuchsia_SANITIZER_USE_COMPILER_RT ON CACHE BOOL "")
 endforeach()
 
+foreach(target x86_64;aarch64)
+  set(RUNTIMES_${target}-fuchsia-asan_CMAKE_BUILD_WITH_INSTALL_RPATH ON CACHE 
BOOL "")
+  set(RUNTIMES_${target}-fuchsia-asan_CMAKE_SYSROOT 
${FUCHSIA_${target}_SYSROOT} CACHE PATH "")
+  set(RUNTIMES_${target}-fuchsia-asan_CMAKE_SYSTEM_NAME Fuchsia CACHE STRING 
"")
+  set(RUNTIMES_${target}-fuchsia-asan_LLVM_USE_SANITIZER Address CACHE STRING 
"")
+  set(RUNTIMES_${target}-fuchsia-asan_LLVM_BUILD_COMPILER_RT OFF CACHE BOOL "")
+  set(RUNTIMES_${target}-fuchsia-asan_LLVM_RUNTIMES_PREFIX 
"${target}-fuchsia/asan" CACHE STRING "")
+  set(RUNTIMES_${target}-fuchsia-asan_UNIX 1 CACHE BOOL "")
+  set(RUNTIMES_${target}-fuchsia-asan_LLVM_ENABLE_LIBCXX ON CACHE BOOL "")
+  set(RUNTIMES_${target}-fuchsia-asan_LIBUNWIND_USE_COMPILER_RT ON CACHE BOOL 
"")
+  set(RUNTIMES_${target}-fuchsia-asan_LIBCXXABI_USE_COMPILER_RT ON CACHE BOOL 
"")
+  set(RUNTIMES_${target}-fuchsia-asan_LIBCXXABI_USE_LLVM_UNWINDER ON CACHE 
BOOL "")
+  set(RUNTIMES_${target}-fuchsia-asan_LIBCXXABI_ENABLE_STATIC OFF CACHE BOOL 
"")
+  set(RUNTIMES_${target}-fuchsia-asan_LIBCXX_USE_COMPILER_RT ON CACHE BOOL "")
+  set(RUNTIMES_${target}-fuchsia-asan_LIBCXX_ABI_VERSION 2 CACHE STRING "")
+  set(RUNTIMES_${target}-fuchsia-asan_LIBCXX_ENABLE_STATIC OFF CACHE BOOL "")
+endforeach()
+
 # Setup toolchain.
 set(LLVM_INSTALL_TOOLCHAIN_ONLY ON CACHE BOOL "")
 set(LLVM_TOOLCHAIN_TOOLS


Index: cmake/caches/Fuchsia-stage2.cmake
===
--- cmake/caches/Fuchsia-stage2.cmake
+++ cmake/caches/Fuchsia-stage2.cmake
@@ -36,7 +36,7 @@
   list(APPEND LLVM_BUILTIN_TARGETS "default")
 endif()
 
-set(LLVM_RUNTIME_TARGETS "default;x86_64-fuchsia;aarch64-fuchsia" CACHE STRING "")
+set(LLVM_RUNTIME_TARGETS "default;x86_64-fuchsia;aarch64-fuchsia;x86_64-fuchsia-asan:x86_64-fuchsia;aarch64-fuchsia-asan:aarch64-fuchsia" CACHE STRING "")
 foreach(target x86_64;aarch64)
   set(RUNTIMES_${target}-fuchsia_CMAKE_BUILD_WITH_INSTALL_RPATH ON CACHE BOOL "")
   set(RUNTIMES_${target}-fuchsia_CMAKE_SYSROOT ${FUCHSIA_${target}_SYSROOT} CACHE PATH "")
@@ -53,6 +53,24 @@
   set(RUNTIMES_${target}-fuchsia_SANITIZER_USE_COMPILER_RT ON CACHE BOOL "")
 endforeach()
 
+foreach(target x86_64;aarch64)
+  set(RUNTIMES_${target}-fuchsia-asan_CMAKE_BUILD_WITH_INSTALL_RPATH ON CACHE BOOL "")
+  set(RUNTIMES_${target}-fuchsia-asan_CMAKE_SYSROOT ${FUCHSIA_${target}_SYSROOT} CACHE PATH "")
+  set(RUNTIMES_${target}-fuchsia-asan_CMAKE_SYSTEM_NAME Fuchsia CACHE STRING "")
+  set(RUNTIMES_${target}-fuchsia-asan_LLVM_USE_SANITIZER Address CACHE STRING "")
+  set(RUNTIMES_${target}-fuchsia-asan_LLVM_BUILD_COMPILER_RT OFF CACHE BOOL "")
+  set(RUNTIMES_${target}-fuchsia-asan_LLVM_RUNTIMES_PREFIX "${target}-fuchsia/asan" CACHE STRING "")
+  set(RUNTIMES_${target}-fuchsia-asan_UNIX 1 CACHE BOOL "")
+  set(RUNTIMES_${target}-fuchsia-asan_LLVM_ENABLE_LIBCXX ON CACHE BOOL "")
+  set(RUNTIMES_${target}-fuchsia-asan_LIBUNWIND_USE_COMPILER_RT ON CACHE BOOL "")
+  set(RUNTIMES_${target}-fuchsia-asan_LIBCXXABI_USE_COMPILER_RT ON CACHE BOOL "")
+  set(RUNTIMES_${target}-fuchsia-asan_LIBCXXABI_USE_LLVM_UNWINDER ON CACHE BOOL "")
+  set(RUNTIMES_${target}-fuchsia-asan_LIBCXXABI_ENABLE_STATIC OFF CACHE BOOL "")
+  set(RUNTIMES_${target}-fuchsia-asan_LIBCXX_USE_COMPILER_RT ON CACHE BOOL "")
+  set(RUNTIMES_${target}-fuchsia-asan_LIBCXX_ABI_VERSION 2 CACHE STRING "")
+  set(RUNTIMES_${target}-fuchsia-asan_LIBCXX_ENABLE_STATIC OFF CACHE BOOL "")
+endforeach()
+
 # Setup toolchain.
 set(LLVM_INSTALL_TOOLCHAIN_ONLY ON CACHE BOOL "")
 set(LLVM_TOOLCHAIN_TOOLS
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D36347: Add new script to launch lldb and set breakpoints for diagnostics all diagnostics seen.

2017-08-04 Thread John McCall via Phabricator via cfe-commits
rjmccall edited reviewers, added: jasonmolenda, spyffe; removed: rjmccall.
rjmccall added a comment.

Since this is fundamentally an LLDB script, I've tagged a couple of LLDB people 
to review it.

Jason, Sean: the idea here is to make it easier for clang developers to debug 
unexpected diagnostics by automatically setting breakpoints on the places that 
originate the observed diagnostics.


https://reviews.llvm.org/D36347



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


[PATCH] D36349: [CMake] Build sanitized C++ runtimes for Fuchsia

2017-08-04 Thread Petr Hosek via Phabricator via cfe-commits
phosek created this revision.
Herald added a subscriber: mgorny.

Repository:
  rL LLVM

https://reviews.llvm.org/D36349

Files:
  cmake/caches/Fuchsia-stage2.cmake


Index: cmake/caches/Fuchsia-stage2.cmake
===
--- cmake/caches/Fuchsia-stage2.cmake
+++ cmake/caches/Fuchsia-stage2.cmake
@@ -53,6 +53,25 @@
   set(RUNTIMES_${target}-fuchsia_SANITIZER_USE_COMPILER_RT ON CACHE BOOL "")
 endforeach()
 
+list(APPEND LLVM_RUNTIME_TARGETS "x86_64-fuchsia-asan=x86_64-fuchsia" 
"aarch64-fuchsia-asan=aarch64-fuchsia")
+foreach(target x86_64;aarch64)
+  set(RUNTIMES_${target}-fuchsia-asan_CMAKE_BUILD_WITH_INSTALL_RPATH ON CACHE 
BOOL "")
+  set(RUNTIMES_${target}-fuchsia-asan_CMAKE_SYSROOT 
${FUCHSIA_${target}_SYSROOT} CACHE PATH "")
+  set(RUNTIMES_${target}-fuchsia-asan_CMAKE_SYSTEM_NAME Fuchsia CACHE STRING 
"")
+  set(RUNTIMES_${target}-fuchsia-asan_LLVM_USE_SANITIZER Address CACHE STRING 
"")
+  set(RUNTIMES_${target}-fuchsia-asan_LLVM_BUILD_COMPILER_RT OFF CACHE BOOL "")
+  set(RUNTIMES_${target}-fuchsia-asan_LLVM_RUNTIMES_PREFIX 
"${target}-fuchsia/asan" CACHE STRING "")
+  set(RUNTIMES_${target}-fuchsia-asan_UNIX 1 CACHE BOOL "")
+  set(RUNTIMES_${target}-fuchsia-asan_LLVM_ENABLE_LIBCXX ON CACHE BOOL "")
+  set(RUNTIMES_${target}-fuchsia-asan_LIBUNWIND_USE_COMPILER_RT ON CACHE BOOL 
"")
+  set(RUNTIMES_${target}-fuchsia-asan_LIBCXXABI_USE_COMPILER_RT ON CACHE BOOL 
"")
+  set(RUNTIMES_${target}-fuchsia-asan_LIBCXXABI_USE_LLVM_UNWINDER ON CACHE 
BOOL "")
+  set(RUNTIMES_${target}-fuchsia-asan_LIBCXXABI_ENABLE_STATIC OFF CACHE BOOL 
"")
+  set(RUNTIMES_${target}-fuchsia-asan_LIBCXX_USE_COMPILER_RT ON CACHE BOOL "")
+  set(RUNTIMES_${target}-fuchsia-asan_LIBCXX_ABI_VERSION 2 CACHE STRING "")
+  set(RUNTIMES_${target}-fuchsia-asan_LIBCXX_ENABLE_STATIC OFF CACHE BOOL "")
+endforeach()
+
 # Setup toolchain.
 set(LLVM_INSTALL_TOOLCHAIN_ONLY ON CACHE BOOL "")
 set(LLVM_TOOLCHAIN_TOOLS


Index: cmake/caches/Fuchsia-stage2.cmake
===
--- cmake/caches/Fuchsia-stage2.cmake
+++ cmake/caches/Fuchsia-stage2.cmake
@@ -53,6 +53,25 @@
   set(RUNTIMES_${target}-fuchsia_SANITIZER_USE_COMPILER_RT ON CACHE BOOL "")
 endforeach()
 
+list(APPEND LLVM_RUNTIME_TARGETS "x86_64-fuchsia-asan=x86_64-fuchsia" "aarch64-fuchsia-asan=aarch64-fuchsia")
+foreach(target x86_64;aarch64)
+  set(RUNTIMES_${target}-fuchsia-asan_CMAKE_BUILD_WITH_INSTALL_RPATH ON CACHE BOOL "")
+  set(RUNTIMES_${target}-fuchsia-asan_CMAKE_SYSROOT ${FUCHSIA_${target}_SYSROOT} CACHE PATH "")
+  set(RUNTIMES_${target}-fuchsia-asan_CMAKE_SYSTEM_NAME Fuchsia CACHE STRING "")
+  set(RUNTIMES_${target}-fuchsia-asan_LLVM_USE_SANITIZER Address CACHE STRING "")
+  set(RUNTIMES_${target}-fuchsia-asan_LLVM_BUILD_COMPILER_RT OFF CACHE BOOL "")
+  set(RUNTIMES_${target}-fuchsia-asan_LLVM_RUNTIMES_PREFIX "${target}-fuchsia/asan" CACHE STRING "")
+  set(RUNTIMES_${target}-fuchsia-asan_UNIX 1 CACHE BOOL "")
+  set(RUNTIMES_${target}-fuchsia-asan_LLVM_ENABLE_LIBCXX ON CACHE BOOL "")
+  set(RUNTIMES_${target}-fuchsia-asan_LIBUNWIND_USE_COMPILER_RT ON CACHE BOOL "")
+  set(RUNTIMES_${target}-fuchsia-asan_LIBCXXABI_USE_COMPILER_RT ON CACHE BOOL "")
+  set(RUNTIMES_${target}-fuchsia-asan_LIBCXXABI_USE_LLVM_UNWINDER ON CACHE BOOL "")
+  set(RUNTIMES_${target}-fuchsia-asan_LIBCXXABI_ENABLE_STATIC OFF CACHE BOOL "")
+  set(RUNTIMES_${target}-fuchsia-asan_LIBCXX_USE_COMPILER_RT ON CACHE BOOL "")
+  set(RUNTIMES_${target}-fuchsia-asan_LIBCXX_ABI_VERSION 2 CACHE STRING "")
+  set(RUNTIMES_${target}-fuchsia-asan_LIBCXX_ENABLE_STATIC OFF CACHE BOOL "")
+endforeach()
+
 # Setup toolchain.
 set(LLVM_INSTALL_TOOLCHAIN_ONLY ON CACHE BOOL "")
 set(LLVM_TOOLCHAIN_TOOLS
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D36259: [OpenCL] Remove extra select functions from opencl-c.h

2017-08-04 Thread Yaxun Liu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL310160: [OpenCL] Remove extra select functions from 
opencl-c.h (authored by yaxunl).

Changed prior to commit:
  https://reviews.llvm.org/D36259?vs=109486=109845#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D36259

Files:
  cfe/trunk/lib/Headers/opencl-c.h

Index: cfe/trunk/lib/Headers/opencl-c.h
===
--- cfe/trunk/lib/Headers/opencl-c.h
+++ cfe/trunk/lib/Headers/opencl-c.h
@@ -11381,6 +11381,8 @@
  * For each component of a vector type,
  * result[i] = if MSB of c[i] is set ? b[i] : a[i].
  * For a scalar type, result = c ? b : a.
+ * b and a must have the same type.
+ * c must have the same number of elements and bits as a.
  */
 char __ovld __cnfn select(char a, char b, char c);
 uchar __ovld __cnfn select(uchar a, uchar b, char c);
@@ -11394,60 +11396,7 @@
 uchar8 __ovld __cnfn select(uchar8 a, uchar8 b, char8 c);
 char16 __ovld __cnfn select(char16 a, char16 b, char16 c);
 uchar16 __ovld __cnfn select(uchar16 a, uchar16 b, char16 c);
-short __ovld __cnfn select(short a, short b, char c);
-ushort __ovld __cnfn select(ushort a, ushort b, char c);
-short2 __ovld __cnfn select(short2 a, short2 b, char2 c);
-ushort2 __ovld __cnfn select(ushort2 a, ushort2 b, char2 c);
-short3 __ovld __cnfn select(short3 a, short3 b, char3 c);
-ushort3 __ovld __cnfn select(ushort3 a, ushort3 b, char3 c);
-short4 __ovld __cnfn select(short4 a, short4 b, char4 c);
-ushort4 __ovld __cnfn select(ushort4 a, ushort4 b, char4 c);
-short8 __ovld __cnfn select(short8 a, short8 b, char8 c);
-ushort8 __ovld __cnfn select(ushort8 a, ushort8 b, char8 c);
-short16 __ovld __cnfn select(short16 a, short16 b, char16 c);
-ushort16 __ovld __cnfn select(ushort16 a, ushort16 b, char16 c);
-int __ovld __cnfn select(int a, int b, char c);
-uint __ovld __cnfn select(uint a, uint b, char c);
-int2 __ovld __cnfn select(int2 a, int2 b, char2 c);
-uint2 __ovld __cnfn select(uint2 a, uint2 b, char2 c);
-int3 __ovld __cnfn select(int3 a, int3 b, char3 c);
-uint3 __ovld __cnfn select(uint3 a, uint3 b, char3 c);
-int4 __ovld __cnfn select(int4 a, int4 b, char4 c);
-uint4 __ovld __cnfn select(uint4 a, uint4 b, char4 c);
-int8 __ovld __cnfn select(int8 a, int8 b, char8 c);
-uint8 __ovld __cnfn select(uint8 a, uint8 b, char8 c);
-int16 __ovld __cnfn select(int16 a, int16 b, char16 c);
-uint16 __ovld __cnfn select(uint16 a, uint16 b, char16 c);
-long __ovld __cnfn select(long a, long b, char c);
-ulong __ovld __cnfn select(ulong a, ulong b, char c);
-long2 __ovld __cnfn select(long2 a, long2 b, char2 c);
-ulong2 __ovld __cnfn select(ulong2 a, ulong2 b, char2 c);
-long3 __ovld __cnfn select(long3 a, long3 b, char3 c);
-ulong3 __ovld __cnfn select(ulong3 a, ulong3 b, char3 c);
-long4 __ovld __cnfn select(long4 a, long4 b, char4 c);
-ulong4 __ovld __cnfn select(ulong4 a, ulong4 b, char4 c);
-long8 __ovld __cnfn select(long8 a, long8 b, char8 c);
-ulong8 __ovld __cnfn select(ulong8 a, ulong8 b, char8 c);
-long16 __ovld __cnfn select(long16 a, long16 b, char16 c);
-ulong16 __ovld __cnfn select(ulong16 a, ulong16 b, char16 c);
-float __ovld __cnfn select(float a, float b, char c);
-float2 __ovld __cnfn select(float2 a, float2 b, char2 c);
-float3 __ovld __cnfn select(float3 a, float3 b, char3 c);
-float4 __ovld __cnfn select(float4 a, float4 b, char4 c);
-float8 __ovld __cnfn select(float8 a, float8 b, char8 c);
-float16 __ovld __cnfn select(float16 a, float16 b, char16 c);
-char __ovld __cnfn select(char a, char b, short c);
-uchar __ovld __cnfn select(uchar a, uchar b, short c);
-char2 __ovld __cnfn select(char2 a, char2 b, short2 c);
-uchar2 __ovld __cnfn select(uchar2 a, uchar2 b, short2 c);
-char3 __ovld __cnfn select(char3 a, char3 b, short3 c);
-uchar3 __ovld __cnfn select(uchar3 a, uchar3 b, short3 c);
-char4 __ovld __cnfn select(char4 a, char4 b, short4 c);
-uchar4 __ovld __cnfn select(uchar4 a, uchar4 b, short4 c);
-char8 __ovld __cnfn select(char8 a, char8 b, short8 c);
-uchar8 __ovld __cnfn select(uchar8 a, uchar8 b, short8 c);
-char16 __ovld __cnfn select(char16 a, char16 b, short16 c);
-uchar16 __ovld __cnfn select(uchar16 a, uchar16 b, short16 c);
+
 short __ovld __cnfn select(short a, short b, short c);
 ushort __ovld __cnfn select(ushort a, ushort b, short c);
 short2 __ovld __cnfn select(short2 a, short2 b, short2 c);
@@ -11460,60 +11409,7 @@
 ushort8 __ovld __cnfn select(ushort8 a, ushort8 b, short8 c);
 short16 __ovld __cnfn select(short16 a, short16 b, short16 c);
 ushort16 __ovld __cnfn select(ushort16 a, ushort16 b, short16 c);
-int __ovld __cnfn select(int a, int b, short c);
-uint __ovld __cnfn select(uint a, uint b, short c);
-int2 __ovld __cnfn select(int2 a, int2 b, short2 c);
-uint2 __ovld __cnfn select(uint2 a, uint2 b, short2 c);
-int3 __ovld __cnfn select(int3 a, int3 b, short3 c);
-uint3 __ovld __cnfn select(uint3 a, uint3 b, short3 c);
-int4 __ovld __cnfn select(int4 

r310160 - [OpenCL] Remove extra select functions from opencl-c.h

2017-08-04 Thread Yaxun Liu via cfe-commits
Author: yaxunl
Date: Fri Aug  4 19:23:47 2017
New Revision: 310160

URL: http://llvm.org/viewvc/llvm-project?rev=310160=rev
Log:
[OpenCL] Remove extra select functions from opencl-c.h

OpenCL spec v2.0 s6.13.6:

gentype select (gentype a,
gentype b,
igentype c)

gentype select (gentype a,
gentype b,
ugentype c)

igentype and ugentype must have the same number
of elements and bits as gentype.

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

Modified:
cfe/trunk/lib/Headers/opencl-c.h

Modified: cfe/trunk/lib/Headers/opencl-c.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/opencl-c.h?rev=310160=310159=310160=diff
==
--- cfe/trunk/lib/Headers/opencl-c.h (original)
+++ cfe/trunk/lib/Headers/opencl-c.h Fri Aug  4 19:23:47 2017
@@ -11381,6 +11381,8 @@ half16 __ovld __cnfn bitselect(half16 a,
  * For each component of a vector type,
  * result[i] = if MSB of c[i] is set ? b[i] : a[i].
  * For a scalar type, result = c ? b : a.
+ * b and a must have the same type.
+ * c must have the same number of elements and bits as a.
  */
 char __ovld __cnfn select(char a, char b, char c);
 uchar __ovld __cnfn select(uchar a, uchar b, char c);
@@ -11394,60 +11396,7 @@ char8 __ovld __cnfn select(char8 a, char
 uchar8 __ovld __cnfn select(uchar8 a, uchar8 b, char8 c);
 char16 __ovld __cnfn select(char16 a, char16 b, char16 c);
 uchar16 __ovld __cnfn select(uchar16 a, uchar16 b, char16 c);
-short __ovld __cnfn select(short a, short b, char c);
-ushort __ovld __cnfn select(ushort a, ushort b, char c);
-short2 __ovld __cnfn select(short2 a, short2 b, char2 c);
-ushort2 __ovld __cnfn select(ushort2 a, ushort2 b, char2 c);
-short3 __ovld __cnfn select(short3 a, short3 b, char3 c);
-ushort3 __ovld __cnfn select(ushort3 a, ushort3 b, char3 c);
-short4 __ovld __cnfn select(short4 a, short4 b, char4 c);
-ushort4 __ovld __cnfn select(ushort4 a, ushort4 b, char4 c);
-short8 __ovld __cnfn select(short8 a, short8 b, char8 c);
-ushort8 __ovld __cnfn select(ushort8 a, ushort8 b, char8 c);
-short16 __ovld __cnfn select(short16 a, short16 b, char16 c);
-ushort16 __ovld __cnfn select(ushort16 a, ushort16 b, char16 c);
-int __ovld __cnfn select(int a, int b, char c);
-uint __ovld __cnfn select(uint a, uint b, char c);
-int2 __ovld __cnfn select(int2 a, int2 b, char2 c);
-uint2 __ovld __cnfn select(uint2 a, uint2 b, char2 c);
-int3 __ovld __cnfn select(int3 a, int3 b, char3 c);
-uint3 __ovld __cnfn select(uint3 a, uint3 b, char3 c);
-int4 __ovld __cnfn select(int4 a, int4 b, char4 c);
-uint4 __ovld __cnfn select(uint4 a, uint4 b, char4 c);
-int8 __ovld __cnfn select(int8 a, int8 b, char8 c);
-uint8 __ovld __cnfn select(uint8 a, uint8 b, char8 c);
-int16 __ovld __cnfn select(int16 a, int16 b, char16 c);
-uint16 __ovld __cnfn select(uint16 a, uint16 b, char16 c);
-long __ovld __cnfn select(long a, long b, char c);
-ulong __ovld __cnfn select(ulong a, ulong b, char c);
-long2 __ovld __cnfn select(long2 a, long2 b, char2 c);
-ulong2 __ovld __cnfn select(ulong2 a, ulong2 b, char2 c);
-long3 __ovld __cnfn select(long3 a, long3 b, char3 c);
-ulong3 __ovld __cnfn select(ulong3 a, ulong3 b, char3 c);
-long4 __ovld __cnfn select(long4 a, long4 b, char4 c);
-ulong4 __ovld __cnfn select(ulong4 a, ulong4 b, char4 c);
-long8 __ovld __cnfn select(long8 a, long8 b, char8 c);
-ulong8 __ovld __cnfn select(ulong8 a, ulong8 b, char8 c);
-long16 __ovld __cnfn select(long16 a, long16 b, char16 c);
-ulong16 __ovld __cnfn select(ulong16 a, ulong16 b, char16 c);
-float __ovld __cnfn select(float a, float b, char c);
-float2 __ovld __cnfn select(float2 a, float2 b, char2 c);
-float3 __ovld __cnfn select(float3 a, float3 b, char3 c);
-float4 __ovld __cnfn select(float4 a, float4 b, char4 c);
-float8 __ovld __cnfn select(float8 a, float8 b, char8 c);
-float16 __ovld __cnfn select(float16 a, float16 b, char16 c);
-char __ovld __cnfn select(char a, char b, short c);
-uchar __ovld __cnfn select(uchar a, uchar b, short c);
-char2 __ovld __cnfn select(char2 a, char2 b, short2 c);
-uchar2 __ovld __cnfn select(uchar2 a, uchar2 b, short2 c);
-char3 __ovld __cnfn select(char3 a, char3 b, short3 c);
-uchar3 __ovld __cnfn select(uchar3 a, uchar3 b, short3 c);
-char4 __ovld __cnfn select(char4 a, char4 b, short4 c);
-uchar4 __ovld __cnfn select(uchar4 a, uchar4 b, short4 c);
-char8 __ovld __cnfn select(char8 a, char8 b, short8 c);
-uchar8 __ovld __cnfn select(uchar8 a, uchar8 b, short8 c);
-char16 __ovld __cnfn select(char16 a, char16 b, short16 c);
-uchar16 __ovld __cnfn select(uchar16 a, uchar16 b, short16 c);
+
 short __ovld __cnfn select(short a, short b, short c);
 ushort __ovld __cnfn select(ushort a, ushort b, short c);
 short2 __ovld __cnfn select(short2 a, short2 b, short2 c);
@@ -11460,60 +11409,7 @@ short8 __ovld __cnfn select(short8 a, sh
 ushort8 __ovld __cnfn select(ushort8 a, ushort8 b, short8 c);
 short16 __ovld __cnfn select(short16 a, short16 b, short16 c);
 

Re: r305903 - Function with unparsed body is a definition

2017-08-04 Thread Alexander Kornienko via cfe-commits
Thank you for the analysis! It would be nice if you could implement a short
term workaround to avoid crashes. Maybe Richard has ideas on what a proper
solution should look like.

On Wed, Aug 2, 2017 at 8:05 PM, Serge Pavlov  wrote:

> At first thank you for the nice test case.
>
> This crash is not caused by r305903. The root cause is that instantiation
> of f is triggered when parse of f is not finished yet. This is the
> case just addressed by that change.
> The instantiation is requested by the code (https://github.com/llvm-mirro
> r/clang/blob/master/lib/Sema/SemaExpr.cpp#L13622):
>
> else if (Func->isConstexpr())
> // Do not defer instantiations of constexpr functions, to avoid the
> // expression evaluator needing to call back into Sema if it sees a
> // call to such a function.
> InstantiateFunctionDefinition(PointOfInstantiation, Func);
>
>
> It looks like a violation of C++ Standard, as function is instantiated
> when there is no use of it. However if this check is removed and
> instantiation is postponed as for non-constexpr functions, lots of tests
> fail.
>
> Without r305903 the call to `getDefinition` for templated declaration of
> f returned null, declaration f was moved to the list of pending
> instantiations and crash is not observed. It does not mean however that
> original source code would be compiled correctly.
>
> It this is urgent problem, I can prepare a patch that will mimic behavior
> before r305903 for instantiation of constexpr functions. If there is some
> time I would investigate this problem in depth, as it manifests itself in
> number of cases, for instance in https://bugs.llvm.org/show_
> bug.cgi?id=33561.
>
> Thanks,
> --Serge
>
> 2017-08-01 23:28 GMT+07:00 Serge Pavlov :
>
>> Yes, sure, I will investigate it.
>>
>> Thanks,
>> --Serge
>>
>> 2017-08-01 21:32 GMT+07:00 Alexander Kornienko :
>>
>>> This change causes an assertion failure on valid code. Could you take a
>>> look at fixing this?
>>>
>>> A reduced test case:
>>>
>>> $ cat /tmp/SemaTemplateInstantiateDecl-crash2.cpp
>>> template 
>>> constexpr void f(T) {
>>>   f(0);
>>> }
>>> $ clang -fsyntax-only -std=c++11 /tmp/SemaTemplateInstantiateDe
>>> cl-crash2.cpp
>>> assert.h assertion failed at llvm/tools/clang/lib/Sema/Sema
>>> TemplateInstantiateDecl.cpp:3840 in void clang::Sema::InstantiateFuncti
>>> onDefinition(clang::SourceLocation, clang::FunctionDecl *, bool, bool,
>>> bool): (Pattern |
>>> | PatternDecl->isDefaulted()) && "unexpected kind of function template
>>> definition"
>>> *** Check failure stack trace: ***
>>> @  0x6094c4a  __assert_fail
>>> @  0x2705bfe  clang::Sema::InstantiateFunctionDefinition()
>>> @  0x2c1fb13  clang::Sema::MarkFunctionReferenced()
>>> @  0x2bec07b  clang::Sema::MarkAnyDeclReferenced()
>>> @  0x2c2327f  MarkExprReferenced()
>>> @  0x2be8f0a  clang::Sema::MarkDeclRefReferenced()
>>> @  0x2980ac0  clang::Sema::FixOverloadedFunctionReference()
>>> @  0x2982e66  FinishOverloadedCallExpr()
>>> @  0x2982b39  clang::Sema::BuildOverloadedCallExpr()
>>> @  0x2be461b  clang::Sema::ActOnCallExpr()
>>> @  0x2571e90  clang::Parser::ParsePostfixExpressionSuffix()
>>> @  0x25784cb  clang::Parser::ParseCastExpression()
>>> @  0x2570865  clang::Parser::ParseCastExpression()
>>> @  0x256f1e3  clang::Parser::ParseAssignmentExpression()
>>> @  0x256f0bf  clang::Parser::ParseExpression()
>>> @  0x2517eeb  clang::Parser::ParseExprStatement()
>>> @  0x2517074  clang::Parser::ParseStatement
>>> OrDeclarationAfterAttributes()
>>> @  0x2516b50  clang::Parser::ParseStatementOrDeclaration()
>>> @  0x251deb4  clang::Parser::ParseCompoundStatementBody()
>>> @  0x251ea53  clang::Parser::ParseFunctionStatementBody()
>>> @  0x24f5b23  clang::Parser::ParseFunctionDefinition()
>>> @  0x25082a5  clang::Parser::ParseSingleDec
>>> larationAfterTemplate()
>>> @  0x2507652  clang::Parser::ParseTemplateD
>>> eclarationOrSpecialization()
>>> @  0x2506fa5  clang::Parser::ParseDeclarati
>>> onStartingWithTemplate()
>>> @  0x25b6853  clang::Parser::ParseDeclaration()
>>> @  0x24f36d5  clang::Parser::ParseExternalDeclaration()
>>> @  0x24f2739  clang::Parser::ParseTopLevelDecl()
>>> @  0x24f220e  clang::Parser::ParseFirstTopLevelDecl()
>>> @  0x24ed582  clang::ParseAST()
>>>
>>> On Wed, Jun 21, 2017 at 2:46 PM, Serge Pavlov via cfe-commits <
>>> cfe-commits@lists.llvm.org> wrote:
>>>
 Author: sepavloff
 Date: Wed Jun 21 07:46:57 2017
 New Revision: 305903

 URL: http://llvm.org/viewvc/llvm-project?rev=305903=rev
 Log:
 Function with unparsed body is a definition

[PATCH] D30748: [Lexer] Finding beginning of token with escaped new line

2017-08-04 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh accepted this revision.
alexfh added a comment.
This revision is now accepted and ready to land.

Looks good with one nit.

Do you need someone to commit the patch for you after you address the comment?




Comment at: lib/Lex/Lexer.cpp:469-477
+if (!isVerticalWhitespace(LexStart[0]))
+  continue;
 
-  const char *LexStart = StrData;
-  while (LexStart != BufStart) {
-if (LexStart[0] == '\n' || LexStart[0] == '\r') {
-  ++LexStart;
-  break;
-}
+if (Lexer::isNewLineEscaped(BufStart, LexStart))
+  continue;
 
+// LexStart should point at first character of logical line.

The logic is hard to get here. I'd use a single `if` and reverse the condition 
to get rid of the `continue`s:

  if (isVerticalWhitespace(*LexStart) && !Lexer::isNewLineEscaped(BufStart, 
LexStart)) {
++LexStart;
break;
  }


https://reviews.llvm.org/D30748



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


r310158 - [ODRHash] Treat some non-templated classes as templated.

2017-08-04 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Fri Aug  4 17:54:19 2017
New Revision: 310158

URL: http://llvm.org/viewvc/llvm-project?rev=310158=rev
Log:
[ODRHash] Treat some non-templated classes as templated.

When using nested classes, if the inner class is not templated, but the outer
class is templated, the inner class will not be templated, but may have some
traits as if it were.  This is particularly evident if the inner class
refers to the outer class in some fashion.  Treat any class that is in the
context of a templated class as also a templated class.

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

Modified: cfe/trunk/lib/AST/ODRHash.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ODRHash.cpp?rev=310158=310157=310158=diff
==
--- cfe/trunk/lib/AST/ODRHash.cpp (original)
+++ cfe/trunk/lib/AST/ODRHash.cpp Fri Aug  4 17:54:19 2017
@@ -378,8 +378,12 @@ void ODRHash::AddCXXRecordDecl(const CXX
   assert(Record && Record->hasDefinition() &&
  "Expected non-null record to be a definition.");
 
-  if (isa(Record)) {
-return;
+  const DeclContext *DC = Record;
+  while (DC) {
+if (isa(DC)) {
+  return;
+}
+DC = DC->getParent();
   }
 
   AddDecl(Record);


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


[PATCH] D36250: [coverage] Special-case calls to noreturn functions.

2017-08-04 Thread Vedant Kumar via Phabricator via cfe-commits
vsk added a comment.

I tested this out on clang's ItaniumMangle.cpp and the crash is resolved.




Comment at: lib/CodeGen/CoverageMappingGen.cpp:723
+  this->Visit(Child);
+handleFileExit(getEnd(E));
+

This is doing the right thing. I think it should just be replaced by a call to 
VisitStmt(E), though, as that's clearer.


Repository:
  rL LLVM

https://reviews.llvm.org/D36250



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


[libcxx] r310156 - [libcxx] [test] Fix URLs in comments and make them HTTPS. NFC.

2017-08-04 Thread Stephan T. Lavavej via cfe-commits
Author: stl_msft
Date: Fri Aug  4 17:44:24 2017
New Revision: 310156

URL: http://llvm.org/viewvc/llvm-project?rev=310156=rev
Log:
[libcxx] [test] Fix URLs in comments and make them HTTPS. NFC.

Modified:

libcxx/trunk/test/libcxx/thread/thread.condition/PR30202_notify_from_pthread_created_thread.pass.cpp
libcxx/trunk/test/std/re/re.iter/re.regiter/re.regiter.incr/post.pass.cpp
libcxx/trunk/test/std/thread/futures/futures.async/async_race.pass.cpp
libcxx/trunk/test/std/utilities/function.objects/func.not_fn/not_fn.pass.cpp

libcxx/trunk/test/std/utilities/function.objects/unord.hash/non_enum.pass.cpp

libcxx/trunk/test/std/utilities/memory/util.smartptr/util.smartptr.enab/enable_shared_from_this.pass.cpp
libcxx/trunk/test/std/utilities/tuple/tuple.general/tuple.smartptr.pass.cpp
libcxx/trunk/test/std/utilities/variant/variant.visit/visit.pass.cpp
libcxx/trunk/test/support/platform_support.h

Modified: 
libcxx/trunk/test/libcxx/thread/thread.condition/PR30202_notify_from_pthread_created_thread.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/thread/thread.condition/PR30202_notify_from_pthread_created_thread.pass.cpp?rev=310156=310155=310156=diff
==
--- 
libcxx/trunk/test/libcxx/thread/thread.condition/PR30202_notify_from_pthread_created_thread.pass.cpp
 (original)
+++ 
libcxx/trunk/test/libcxx/thread/thread.condition/PR30202_notify_from_pthread_created_thread.pass.cpp
 Fri Aug  4 17:44:24 2017
@@ -20,7 +20,7 @@
 //   notify_all_at_thread_exit(condition_variable& cond, unique_lock 
lk);
 
 // Test that this function works with threads that were not created by
-// std::thread. See http://llvm.org/PR30202.
+// std::thread. See: https://bugs.llvm.org/show_bug.cgi?id=30202
 
 
 #include 

Modified: 
libcxx/trunk/test/std/re/re.iter/re.regiter/re.regiter.incr/post.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/re.iter/re.regiter/re.regiter.incr/post.pass.cpp?rev=310156=310155=310156=diff
==
--- libcxx/trunk/test/std/re/re.iter/re.regiter/re.regiter.incr/post.pass.cpp 
(original)
+++ libcxx/trunk/test/std/re/re.iter/re.regiter/re.regiter.incr/post.pass.cpp 
Fri Aug  4 17:44:24 2017
@@ -95,7 +95,7 @@ int main()
 assert((*i2).position() == 0);
 assert((*i2).str() == "555-1234");
 }
-{ // http://llvm.org/PR33681
+{ // https://bugs.llvm.org/show_bug.cgi?id=33681
 std::regex rex(".*");
 const char foo[] = "foo";
 //  The -1 is because we don't want the implicit null from the array.

Modified: libcxx/trunk/test/std/thread/futures/futures.async/async_race.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/futures/futures.async/async_race.pass.cpp?rev=310156=310155=310156=diff
==
--- libcxx/trunk/test/std/thread/futures/futures.async/async_race.pass.cpp 
(original)
+++ libcxx/trunk/test/std/thread/futures/futures.async/async_race.pass.cpp Fri 
Aug  4 17:44:24 2017
@@ -21,7 +21,7 @@
 // async(launch policy, F&& f, Args&&... args);
 
 // This test is designed to cause and allow TSAN to detect the race condition
-// reported in PR23293. (http://llvm.org/PR23293).
+// reported in PR23293: https://bugs.llvm.org/show_bug.cgi?id=23293
 
 #include 
 #include 

Modified: 
libcxx/trunk/test/std/utilities/function.objects/func.not_fn/not_fn.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/func.not_fn/not_fn.pass.cpp?rev=310156=310155=310156=diff
==
--- 
libcxx/trunk/test/std/utilities/function.objects/func.not_fn/not_fn.pass.cpp 
(original)
+++ 
libcxx/trunk/test/std/utilities/function.objects/func.not_fn/not_fn.pass.cpp 
Fri Aug  4 17:44:24 2017
@@ -587,7 +587,7 @@ void call_operator_noexcept_test()
 }
 
 void test_lwg2767() {
-// See http://wg21.link/LWG2767
+// See https://cplusplus.github.io/LWG/lwg-defects.html#2767
 struct Abstract { virtual void f() const = 0; };
 struct Derived : public Abstract { void f() const {} };
 struct F { bool operator()(Abstract&&) { return false; } };

Modified: 
libcxx/trunk/test/std/utilities/function.objects/unord.hash/non_enum.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/unord.hash/non_enum.pass.cpp?rev=310156=310155=310156=diff
==
--- 
libcxx/trunk/test/std/utilities/function.objects/unord.hash/non_enum.pass.cpp 
(original)
+++ 
libcxx/trunk/test/std/utilities/function.objects/unord.hash/non_enum.pass.cpp 
Fri Aug  4 17:44:24 2017
@@ -13,7 +13,7 @@
 
 //  Hashing a struct w/o a defined hash should *not* fail, but it should
 // 

[libcxx] r310157 - [libcxx] [test] Untabify stringstream.cons/string.pass.cpp. NFC.

2017-08-04 Thread Stephan T. Lavavej via cfe-commits
Author: stl_msft
Date: Fri Aug  4 17:44:27 2017
New Revision: 310157

URL: http://llvm.org/viewvc/llvm-project?rev=310157=rev
Log:
[libcxx] [test] Untabify stringstream.cons/string.pass.cpp. NFC.

Modified:

libcxx/trunk/test/std/input.output/string.streams/stringstream.cons/string.pass.cpp

Modified: 
libcxx/trunk/test/std/input.output/string.streams/stringstream.cons/string.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/input.output/string.streams/stringstream.cons/string.pass.cpp?rev=310157=310156=310157=diff
==
--- 
libcxx/trunk/test/std/input.output/string.streams/stringstream.cons/string.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/input.output/string.streams/stringstream.cons/string.pass.cpp
 Fri Aug  4 17:44:27 2017
@@ -57,12 +57,12 @@ int main()
 assert(ss.str() == L"456 1236 ");
 }
 { // This is https://bugs.llvm.org/show_bug.cgi?id=33727
-   typedef std::basic_string    S;
-   typedef std::basic_stringbuf SB;
+typedef std::basic_string    S;
+typedef std::basic_stringbuf SB;
 
-   S s(NoDefaultAllocator(1));
-   SB sb(s);
-   //  This test is not required by the standard, but *where else* 
could it get the allocator?
-   assert(sb.str().get_allocator() == s.get_allocator());
+S s(NoDefaultAllocator(1));
+SB sb(s);
+//  This test is not required by the standard, but *where else* could it 
get the allocator?
+assert(sb.str().get_allocator() == s.get_allocator());
 }
 }


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


[libcxx] r310155 - [libcxx] [test] Consistently list "c++98, c++03" in chronological order. NFC.

2017-08-04 Thread Stephan T. Lavavej via cfe-commits
Author: stl_msft
Date: Fri Aug  4 17:44:19 2017
New Revision: 310155

URL: http://llvm.org/viewvc/llvm-project?rev=310155=rev
Log:
[libcxx] [test] Consistently list "c++98, c++03" in chronological order. NFC.

Modified:
libcxx/trunk/test/std/iterators/iterator.range/begin-end.pass.cpp

libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.shared_mutex.requirements/thread.shared_mutex.class/default.pass.cpp

libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.shared_mutex.requirements/thread.shared_mutex.class/lock.pass.cpp

libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.shared_mutex.requirements/thread.shared_mutex.class/lock_shared.pass.cpp

libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.shared_mutex.requirements/thread.shared_mutex.class/try_lock.pass.cpp

libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.shared_mutex.requirements/thread.shared_mutex.class/try_lock_shared.pass.cpp

libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/default.pass.cpp

libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/lock.pass.cpp

libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/lock_shared.pass.cpp

libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock.pass.cpp

libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock_for.pass.cpp

libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock_shared.pass.cpp

libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock_shared_for.pass.cpp

libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock_shared_until.pass.cpp

libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock_until.pass.cpp

libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock_until_deadlock_bug.pass.cpp

Modified: libcxx/trunk/test/std/iterators/iterator.range/begin-end.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/iterators/iterator.range/begin-end.pass.cpp?rev=310155=310154=310155=diff
==
--- libcxx/trunk/test/std/iterators/iterator.range/begin-end.pass.cpp (original)
+++ libcxx/trunk/test/std/iterators/iterator.range/begin-end.pass.cpp Fri Aug  
4 17:44:19 2017
@@ -7,7 +7,7 @@
 //
 
//===--===//
 
-// XFAIL: c++03, c++98
+// XFAIL: c++98, c++03
 
 // 
 // template  constexpr auto begin(C& c) -> decltype(c.begin());

Modified: 
libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.shared_mutex.requirements/thread.shared_mutex.class/default.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.shared_mutex.requirements/thread.shared_mutex.class/default.pass.cpp?rev=310155=310154=310155=diff
==
--- 
libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.shared_mutex.requirements/thread.shared_mutex.class/default.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.shared_mutex.requirements/thread.shared_mutex.class/default.pass.cpp
 Fri Aug  4 17:44:19 2017
@@ -8,7 +8,7 @@
 
//===--===//
 //
 // UNSUPPORTED: libcpp-has-no-threads
-// UNSUPPORTED: c++03, c++98, c++11, c++14
+// UNSUPPORTED: c++98, c++03, c++11, c++14
 
 // 
 

Modified: 
libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.shared_mutex.requirements/thread.shared_mutex.class/lock.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.shared_mutex.requirements/thread.shared_mutex.class/lock.pass.cpp?rev=310155=310154=310155=diff
==
--- 
libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.shared_mutex.requirements/thread.shared_mutex.class/lock.pass.cpp
 

[PATCH] D35925: [Coverage] Precise region termination with deferred regions

2017-08-04 Thread Vedant Kumar via Phabricator via cfe-commits
vsk added a comment.

Reverted in r310154, because llvm-cov isn't doing a good job of displaying the 
new regions properly. I'll re-land this after llvm-cov is fixed.


https://reviews.llvm.org/D35925



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


r310154 - Revert "[Coverage] Precise region termination with deferred regions"

2017-08-04 Thread Vedant Kumar via cfe-commits
Author: vedantk
Date: Fri Aug  4 17:34:10 2017
New Revision: 310154

URL: http://llvm.org/viewvc/llvm-project?rev=310154=rev
Log:
Revert "[Coverage] Precise region termination with deferred regions"

This reverts commit r310010. I don't think there's anything wrong with
this commit, but it's causing clang to generate output that llvm-cov
doesn't do a good job with and the fix isn't immediately clear.

See Eli's comment in D36250 for more context.

I'm reverting the clang change so the coverage bot can revert back to
producing sensible output, and to give myself some time to investigate
what went wrong in llvm.

Removed:
cfe/trunk/test/CoverageMapping/deferred-region.cpp
Modified:
cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp
cfe/trunk/test/CoverageMapping/label.cpp
cfe/trunk/test/CoverageMapping/moremacros.c
cfe/trunk/test/CoverageMapping/return.c
cfe/trunk/test/CoverageMapping/switch.cpp
cfe/trunk/test/CoverageMapping/switchmacro.c
cfe/trunk/test/CoverageMapping/trycatch.cpp

Modified: cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp?rev=310154=310153=310154=diff
==
--- cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp (original)
+++ cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp Fri Aug  4 17:34:10 2017
@@ -45,14 +45,10 @@ class SourceMappingRegion {
   /// \brief The region's ending location.
   Optional LocEnd;
 
-  /// Whether this region should be emitted after its parent is emitted.
-  bool DeferRegion;
-
 public:
   SourceMappingRegion(Counter Count, Optional LocStart,
-  Optional LocEnd, bool DeferRegion = 
false)
-  : Count(Count), LocStart(LocStart), LocEnd(LocEnd),
-DeferRegion(DeferRegion) {}
+  Optional LocEnd)
+  : Count(Count), LocStart(LocStart), LocEnd(LocEnd) {}
 
   const Counter () const { return Count; }
 
@@ -75,10 +71,6 @@ public:
 assert(LocEnd && "Region has no end location");
 return *LocEnd;
   }
-
-  bool isDeferred() const { return DeferRegion; }
-
-  void setDeferred(bool Deferred) { DeferRegion = Deferred; }
 };
 
 /// Spelling locations for the start and end of a source region.
@@ -417,10 +409,6 @@ struct CounterCoverageMappingBuilder
   /// \brief A stack of currently live regions.
   std::vector RegionStack;
 
-  /// The currently deferred region: its end location and count can be set once
-  /// its parent has been popped from the region stack.
-  Optional DeferredRegion;
-
   CounterExpressionBuilder Builder;
 
   /// \brief A location in the most recently visited file or macro.
@@ -456,60 +444,19 @@ struct CounterCoverageMappingBuilder
   /// used with popRegions to exit a "scope", ending the region that was 
pushed.
   size_t pushRegion(Counter Count, Optional StartLoc = None,
 Optional EndLoc = None) {
-if (StartLoc) {
+if (StartLoc)
   MostRecentLocation = *StartLoc;
-  completeDeferred(Count, MostRecentLocation);
-}
 RegionStack.emplace_back(Count, StartLoc, EndLoc);
 
 return RegionStack.size() - 1;
   }
 
-  /// Complete any pending deferred region by setting its end location and
-  /// count, and then pushing it onto the region stack.
-  size_t completeDeferred(Counter Count, SourceLocation DeferredEndLoc) {
-size_t Index = RegionStack.size();
-if (!DeferredRegion)
-  return Index;
-
-// Consume the pending region.
-SourceMappingRegion DR = DeferredRegion.getValue();
-DeferredRegion = None;
-
-// If the region ends in an expansion, find the expansion site.
-if (SM.getFileID(DeferredEndLoc) != SM.getMainFileID()) {
-  FileID StartFile = SM.getFileID(DR.getStartLoc());
-  if (isNestedIn(DeferredEndLoc, StartFile)) {
-do {
-  DeferredEndLoc = getIncludeOrExpansionLoc(DeferredEndLoc);
-} while (StartFile != SM.getFileID(DeferredEndLoc));
-  }
-}
-
-// The parent of this deferred region ends where the containing decl ends,
-// so the region isn't useful.
-if (DR.getStartLoc() == DeferredEndLoc)
-  return Index;
-
-// If we're visiting statements in non-source order (e.g switch cases or
-// a loop condition) we can't construct a sensible deferred region.
-if (!SpellingRegion(SM, DR.getStartLoc(), 
DeferredEndLoc).isInSourceOrder())
-  return Index;
-
-DR.setCounter(Count);
-DR.setEndLoc(DeferredEndLoc);
-handleFileExit(DeferredEndLoc);
-RegionStack.push_back(DR);
-return Index;
-  }
-
   /// \brief Pop regions from the stack into the function's list of regions.
   ///
   /// Adds all regions from \c ParentIndex to the top of the stack to the
   /// function's \c SourceRegions.
   void popRegions(size_t ParentIndex) {
 assert(RegionStack.size() >= ParentIndex && "parent not in stack");
-bool ParentOfDeferredRegion = false;
 while 

[PATCH] D36324: Integrate Kostya's clang-proto-fuzzer with LLVM.

2017-08-04 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added inline comments.



Comment at: clang/tools/clang-fuzzer/ClangFuzzer.cpp:20
 
 extern "C" int LLVMFuzzerTestOneInput(uint8_t *data, size_t size) {
   std::string s((const char *)data, size);

morehouse wrote:
> morehouse wrote:
> > vitalybuka wrote:
> > > Do we want replace this fuzzer? Why not just add another one?
> > The idea was to keep ClangFuzzer and add ClangProtoFuzzer alongside it.  
> > However, the two share a fair amount of code, which was factored out into 
> > HandleCXX.
> > It's ok to share code, but I don't see fuzzer with accept string as is.
> 
> That's exactly what this fuzzer is doing.
my mistake, I see now.



Comment at: clang/tools/clang-fuzzer/cxx_proto.proto:16
+
+syntax = "proto2";
+//option cc_api_version = 2;

vitalybuka wrote:
> I'd suggest proto3
proto3 has no required, to avoid backward compatibility issues.
Same is useful for us, we don't wont to discard corpus if we drop some field in 
the future.


https://reviews.llvm.org/D36324



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


[PATCH] D36250: [coverage] Special-case calls to noreturn functions.

2017-08-04 Thread Eli Friedman via Phabricator via cfe-commits
efriedma updated this revision to Diff 109838.
efriedma added a comment.

Add missing call to handleFileExit().

Not sure I'm really calling it in the right place, but this seems to work.


Repository:
  rL LLVM

https://reviews.llvm.org/D36250

Files:
  lib/CodeGen/CoverageMappingGen.cpp
  test/CoverageMapping/md.cpp
  test/CoverageMapping/switch.cpp


Index: test/CoverageMapping/switch.cpp
===
--- test/CoverageMapping/switch.cpp
+++ test/CoverageMapping/switch.cpp
@@ -97,3 +97,16 @@
 break;
   }
 }
+
+void abort(void) __attribute((noreturn));
+   // CHECK: noret
+int noret(int x) { // CHECK-NEXT: File 0, [[@LINE]]:18 -> [[@LINE+9]]:2
+  switch (x) {
+  default: // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:12
+abort();
+  case 1: // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:13
+return 5;
+  case 2: // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:14
+return 10;
+  }
+}
Index: test/CoverageMapping/md.cpp
===
--- test/CoverageMapping/md.cpp
+++ test/CoverageMapping/md.cpp
@@ -27,6 +27,17 @@
   #include "Inputs/md.def"
 }
 
+// CHECK: bar
+// CHECK-NEXT: File 0, [[@LINE+3]]:12 -> [[@LINE+8]]:2 = #0
+bool isVal1();
+bool isVal2();
+bool bar() {
+ #define HANDLE_MD(X) is##X() ||
+  return
+#include "Inputs/md.def"
+  0;
+}
+
 int main(int argc, const char *argv[]) {
   foo(MD::Val1);
   return 0;
Index: lib/CodeGen/CoverageMappingGen.cpp
===
--- lib/CodeGen/CoverageMappingGen.cpp
+++ lib/CodeGen/CoverageMappingGen.cpp
@@ -716,6 +716,19 @@
 terminateRegion(S);
   }
 
+  void VisitCallExpr(const CallExpr *E) {
+extendRegion(E);
+for (const Stmt *Child : E->children())
+  this->Visit(Child);
+handleFileExit(getEnd(E));
+
+// Terminate the region when we hit a noreturn function.
+// (This is helpful dealing with switch statements.)
+QualType CalleeType = E->getCallee()->getType();
+if (getFunctionExtInfo(*CalleeType).getNoReturn())
+  terminateRegion(E);
+  }
+
   void VisitWhileStmt(const WhileStmt *S) {
 extendRegion(S);
 


Index: test/CoverageMapping/switch.cpp
===
--- test/CoverageMapping/switch.cpp
+++ test/CoverageMapping/switch.cpp
@@ -97,3 +97,16 @@
 break;
   }
 }
+
+void abort(void) __attribute((noreturn));
+   // CHECK: noret
+int noret(int x) { // CHECK-NEXT: File 0, [[@LINE]]:18 -> [[@LINE+9]]:2
+  switch (x) {
+  default: // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:12
+abort();
+  case 1: // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:13
+return 5;
+  case 2: // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:14
+return 10;
+  }
+}
Index: test/CoverageMapping/md.cpp
===
--- test/CoverageMapping/md.cpp
+++ test/CoverageMapping/md.cpp
@@ -27,6 +27,17 @@
   #include "Inputs/md.def"
 }
 
+// CHECK: bar
+// CHECK-NEXT: File 0, [[@LINE+3]]:12 -> [[@LINE+8]]:2 = #0
+bool isVal1();
+bool isVal2();
+bool bar() {
+ #define HANDLE_MD(X) is##X() ||
+  return
+#include "Inputs/md.def"
+  0;
+}
+
 int main(int argc, const char *argv[]) {
   foo(MD::Val1);
   return 0;
Index: lib/CodeGen/CoverageMappingGen.cpp
===
--- lib/CodeGen/CoverageMappingGen.cpp
+++ lib/CodeGen/CoverageMappingGen.cpp
@@ -716,6 +716,19 @@
 terminateRegion(S);
   }
 
+  void VisitCallExpr(const CallExpr *E) {
+extendRegion(E);
+for (const Stmt *Child : E->children())
+  this->Visit(Child);
+handleFileExit(getEnd(E));
+
+// Terminate the region when we hit a noreturn function.
+// (This is helpful dealing with switch statements.)
+QualType CalleeType = E->getCallee()->getType();
+if (getFunctionExtInfo(*CalleeType).getNoReturn())
+  terminateRegion(E);
+  }
+
   void VisitWhileStmt(const WhileStmt *S) {
 extendRegion(S);
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D36250: [coverage] Special-case calls to noreturn functions.

2017-08-04 Thread Eli Friedman via Phabricator via cfe-commits
efriedma reopened this revision.
efriedma added a comment.
This revision is now accepted and ready to land.

This was reverted.

Failing function, from include/clang/AST/Type.h:

  inline bool Type::isImageType() const {
  #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) is##Id##Type() ||
return
  #include "clang/Basic/OpenCLImageTypes.def"
0; // end boolean or operation
  }

There are no noreturn calls here.  I think the problem is that we're missing a 
call to handleFileExit() somewhere.  I'll post an updated patch soon.


Repository:
  rL LLVM

https://reviews.llvm.org/D36250



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


r310147 - Debug Info: Set the DICompileUnit's isOptimized flag when compiling with LTO.

2017-08-04 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Fri Aug  4 16:08:57 2017
New Revision: 310147

URL: http://llvm.org/viewvc/llvm-project?rev=310147=rev
Log:
Debug Info: Set the DICompileUnit's isOptimized flag when compiling with LTO.

rdar://problem/27640939

Added:
cfe/trunk/test/CodeGen/debug-info-lto.c
Modified:
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=310147=310146=310147=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Fri Aug  4 16:08:57 2017
@@ -527,16 +527,15 @@ void CGDebugInfo::CreateCompileUnit() {
 
   // Create new compile unit.
   // FIXME - Eliminate TheCU.
+  auto  = CGM.getCodeGenOpts();
   TheCU = DBuilder.createCompileUnit(
   LangTag,
   DBuilder.createFile(remapDIPath(MainFileName),
   remapDIPath(getCurrentDirname()), CSKind, Checksum),
-  Producer, LO.Optimize, CGM.getCodeGenOpts().DwarfDebugFlags, RuntimeVers,
-  CGM.getCodeGenOpts().EnableSplitDwarf
-  ? ""
-  : CGM.getCodeGenOpts().SplitDwarfFile,
-  EmissionKind, 0 /* DWOid */, CGM.getCodeGenOpts().SplitDwarfInlining,
-  CGM.getCodeGenOpts().DebugInfoForProfiling);
+  Producer, LO.Optimize || CGOpts.PrepareForLTO || CGOpts.EmitSummaryIndex,
+  CGOpts.DwarfDebugFlags, RuntimeVers,
+  CGOpts.EnableSplitDwarf ? "" : CGOpts.SplitDwarfFile, EmissionKind,
+  0 /* DWOid */, CGOpts.SplitDwarfInlining, CGOpts.DebugInfoForProfiling);
 }
 
 llvm::DIType *CGDebugInfo::CreateType(const BuiltinType *BT) {

Added: cfe/trunk/test/CodeGen/debug-info-lto.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/debug-info-lto.c?rev=310147=auto
==
--- cfe/trunk/test/CodeGen/debug-info-lto.c (added)
+++ cfe/trunk/test/CodeGen/debug-info-lto.c Fri Aug  4 16:08:57 2017
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -flto -emit-llvm -debug-info-kind=standalone %s -o - | 
FileCheck %s
+// RUN: %clang_cc1 -flto=thin -emit-llvm -debug-info-kind=standalone %s -o - | 
FileCheck %s
+// The "o" in LTO stands for optimization!
+// CHECK: !DICompileUnit({{.*}} isOptimized: true


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


r310145 - Clean up some lambda conversion operator code, NFC

2017-08-04 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Fri Aug  4 15:38:06 2017
New Revision: 310145

URL: http://llvm.org/viewvc/llvm-project?rev=310145=rev
Log:
Clean up some lambda conversion operator code, NFC

We don't need special handling in CodeGenFunction::GenerateCode for
lambda block pointer conversion operators anymore. The conversion
operator emission code immediately calls back to the generic
EmitFunctionBody.

Rename EmitLambdaStaticInvokeFunction to EmitLambdaStaticInvokeBody for
better consistency with the other Emit*Body methods.

I'm preparing to do something about PR28299, which touches this code.

Modified:
cfe/trunk/lib/CodeGen/CGClass.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h

Modified: cfe/trunk/lib/CodeGen/CGClass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGClass.cpp?rev=310145=310144=310145=diff
==
--- cfe/trunk/lib/CodeGen/CGClass.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGClass.cpp Fri Aug  4 15:38:06 2017
@@ -2754,6 +2754,15 @@ void CodeGenFunction::EmitLambdaBlockInv
   const BlockDecl *BD = BlockInfo->getBlockDecl();
   const VarDecl *variable = BD->capture_begin()->getVariable();
   const CXXRecordDecl *Lambda = variable->getType()->getAsCXXRecordDecl();
+  const CXXMethodDecl *CallOp = Lambda->getLambdaCallOperator();
+
+  if (CallOp->isVariadic()) {
+// FIXME: Making this work correctly is nasty because it requires either
+// cloning the body of the call operator or making the call operator
+// forward.
+CGM.ErrorUnsupported(CurCodeDecl, "lambda conversion to variadic 
function");
+return;
+  }
 
   // Start building arguments for forwarding call
   CallArgList CallArgs;
@@ -2768,18 +2777,7 @@ void CodeGenFunction::EmitLambdaBlockInv
 
   assert(!Lambda->isGenericLambda() &&
 "generic lambda interconversion to block not implemented");
-  EmitForwardingCallToLambda(Lambda->getLambdaCallOperator(), CallArgs);
-}
-
-void CodeGenFunction::EmitLambdaToBlockPointerBody(FunctionArgList ) {
-  if (cast(CurCodeDecl)->isVariadic()) {
-// FIXME: Making this work correctly is nasty because it requires either
-// cloning the body of the call operator or making the call operator 
forward.
-CGM.ErrorUnsupported(CurCodeDecl, "lambda conversion to variadic 
function");
-return;
-  }
-
-  EmitFunctionBody(Args, cast(CurGD.getDecl())->getBody());
+  EmitForwardingCallToLambda(CallOp, CallArgs);
 }
 
 void CodeGenFunction::EmitLambdaDelegatingInvokeBody(const CXXMethodDecl *MD) {
@@ -2812,7 +2810,7 @@ void CodeGenFunction::EmitLambdaDelegati
   EmitForwardingCallToLambda(CallOp, CallArgs);
 }
 
-void CodeGenFunction::EmitLambdaStaticInvokeFunction(const CXXMethodDecl *MD) {
+void CodeGenFunction::EmitLambdaStaticInvokeBody(const CXXMethodDecl *MD) {
   if (MD->isVariadic()) {
 // FIXME: Making this work correctly is nasty because it requires either
 // cloning the body of the call operator or making the call operator 
forward.

Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?rev=310145=310144=310145=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp Fri Aug  4 15:38:06 2017
@@ -1204,16 +1204,11 @@ void CodeGenFunction::GenerateCode(Globa
!getLangOpts().CUDAIsDevice &&
FD->hasAttr())
 CGM.getCUDARuntime().emitDeviceStub(*this, Args);
-  else if (isa(FD) &&
-   cast(FD)->isLambdaToBlockPointerConversion()) {
-// The lambda conversion to block pointer is special; the semantics can't 
be
-// expressed in the AST, so IRGen needs to special-case it.
-EmitLambdaToBlockPointerBody(Args);
-  } else if (isa(FD) &&
- cast(FD)->isLambdaStaticInvoker()) {
+  else if (isa(FD) &&
+   cast(FD)->isLambdaStaticInvoker()) {
 // The lambda static invoker function is special, because it forwards or
 // clones the body of the function call operator (but is actually static).
-EmitLambdaStaticInvokeFunction(cast(FD));
+EmitLambdaStaticInvokeBody(cast(FD));
   } else if (FD->isDefaulted() && isa(FD) &&
  (cast(FD)->isCopyAssignmentOperator() ||
   cast(FD)->isMoveAssignmentOperator())) {

Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.h?rev=310145=310144=310145=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenFunction.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.h Fri Aug  4 15:38:06 2017
@@ -1643,10 +1643,9 @@ public:
 
   void EmitForwardingCallToLambda(const CXXMethodDecl *LambdaCallOperator,
   CallArgList );
-  void 

[PATCH] D36324: Integrate Kostya's clang-proto-fuzzer with LLVM.

2017-08-04 Thread Matt Morehouse via Phabricator via cfe-commits
morehouse added inline comments.



Comment at: clang/tools/clang-fuzzer/ClangFuzzer.cpp:20
 
 extern "C" int LLVMFuzzerTestOneInput(uint8_t *data, size_t size) {
   std::string s((const char *)data, size);

morehouse wrote:
> vitalybuka wrote:
> > Do we want replace this fuzzer? Why not just add another one?
> The idea was to keep ClangFuzzer and add ClangProtoFuzzer alongside it.  
> However, the two share a fair amount of code, which was factored out into 
> HandleCXX.
> It's ok to share code, but I don't see fuzzer with accept string as is.

That's exactly what this fuzzer is doing.


https://reviews.llvm.org/D36324



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


Re: r310057 - Revert r304953 for release 5.0.0

2017-08-04 Thread Vitaly Buka via cfe-commits
Probably not, r310056 fails as well

On Fri, Aug 4, 2017 at 3:19 PM, Vitaly Buka  wrote:

> Looks like it's causing
> http://lab.llvm.org:8011/builders/sanitizer-x86_64-
> linux-bootstrap/builds/1969/steps/build%20clang%2Fmsan/logs/stdio
>
> FAILED: lib/CodeGen/CMakeFiles/LLVMCodeGen.dir/MIRPrinter.cpp.o
> /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-bootstrap/build/llvm_build0/bin/clang++
>-DGTEST_HAS_RTTI=0 -D_DEBUG -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS 
> -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Ilib/CodeGen 
> -I/mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-bootstrap/build/llvm/lib/CodeGen
>  -Iinclude 
> -I/mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-bootstrap/build/llvm/include
>  -nostdinc++ -isystem 
> /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-bootstrap/build/libcxx_build_msan/include
>  -isystem 
> /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-bootstrap/build/libcxx_build_msan/include/c++/v1
>   -lc++abi 
> -Wl,--rpath=/mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-bootstrap/build/libcxx_build_msan/lib
>  
> -L/mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-bootstrap/build/libcxx_build_msan/lib
>  -fsanitize=memory -w -stdlib=libc++ -fPIC -fvisibility-inlines-hidden 
> -Werror=date-time -std=c++11 -Wall -W -Wno-unused-parameter -Wwrite-strings 
> -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long 
> -Wcovered-switch-default -Wnon-virtual-dtor -Wdelete-non-virtual-dtor 
> -Wstring-conversion -fno-omit-frame-pointer -gline-tables-only 
> -fsanitize=memory -fcolor-diagnostics -ffunction-sections -fdata-sections -O3 
>-UNDEBUG  -fno-exceptions -fno-rtti -MD -MT 
> lib/CodeGen/CMakeFiles/LLVMCodeGen.dir/MIRPrinter.cpp.o -MF 
> lib/CodeGen/CMakeFiles/LLVMCodeGen.dir/MIRPrinter.cpp.o.d -o 
> lib/CodeGen/CMakeFiles/LLVMCodeGen.dir/MIRPrinter.cpp.o -c 
> /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-bootstrap/build/llvm/lib/CodeGen/MIRPrinter.cpp
> clang-5.0: 
> /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-bootstrap/build/llvm/include/llvm/Support/Casting.h:106:
>  static bool llvm::isa_impl_cl::doit(const From*) [with To = 
> llvm::ConstantInt; From = llvm::Value]: Assertion `Val && "isa<> used on a 
> null pointer"' failed.
> #0 0x020b5d4a llvm::sys::PrintStackTrace(llvm::raw_ostream&) 
> (/mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-bootstrap/build/llvm_build0/bin/clang-5.0+0x20b5d4a)
> #1 0x020b3abe llvm::sys::RunSignalHandlers() 
> (/mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-bootstrap/build/llvm_build0/bin/clang-5.0+0x20b3abe)
> #2 0x020b3c32 SignalHandler(int) 
> (/mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-bootstrap/build/llvm_build0/bin/clang-5.0+0x20b3c32)
> #3 0x7f319d790390 __restore_rt 
> (/lib/x86_64-linux-gnu/libpthread.so.0+0x11390)
> #4 0x7f319c71c428 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x35428)
> #5 0x7f319c71e02a abort (/lib/x86_64-linux-gnu/libc.so.6+0x3702a)
> #6 0x7f319c714bd7 (/lib/x86_64-linux-gnu/libc.so.6+0x2dbd7)
> #7 0x7f319c714c82 (/lib/x86_64-linux-gnu/libc.so.6+0x2dc82)
> #8 0x0084f464 llvm::isa_impl_wrap const*, llvm::Value const*>::doit(llvm::Value const* const&) [clone 
> .isra.166] [clone .part.167] 
> (/mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-bootstrap/build/llvm_build0/bin/clang-5.0+0x84f464)
> #9 0x01c35d4c llvm::Value::stripPointerCasts() const 
> (/mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-bootstrap/build/llvm_build0/bin/clang-5.0+0x1c35d4c)
> #10 0x01e996e1 eliminateDeadStores(llvm::BasicBlock&, 
> llvm::AAResults*, llvm::MemoryDependenceResults*, llvm::DominatorTree*, 
> llvm::TargetLibraryInfo const*) 
> (/mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-bootstrap/build/llvm_build0/bin/clang-5.0+0x1e996e1)
> #11 0x01e9ad2a eliminateDeadStores(llvm::Function&, llvm::AAResults*, 
> llvm::MemoryDependenceResults*, llvm::DominatorTree*, llvm::TargetLibraryInfo 
> const*) 
> (/mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-bootstrap/build/llvm_build0/bin/clang-5.0+0x1e9ad2a)
> #12 0x01bff3a3 llvm::FPPassManager::runOnFunction(llvm::Function&) 
> (/mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-bootstrap/build/llvm_build0/bin/clang-5.0+0x1bff3a3)
> #13 0x01bff46c llvm::FPPassManager::runOnModule(llvm::Module&) 
> (/mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-bootstrap/build/llvm_build0/bin/clang-5.0+0x1bff46c)#14
>  0x01bfef0d llvm::legacy::PassManagerImpl::run(llvm::Module&) 
> (/mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-bootstrap/build/llvm_build0/bin/clang-5.0+0x1bfef0d)
> #15 0x0225c6d1 clang::EmitBackendOutput(clang::DiagnosticsEngine&, 
> clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, 
> clang::TargetOptions const&, clang::LangOptions const&, llvm::DataLayout 
> const&, llvm::Module*, clang::BackendAction, 
> 

Re: r310057 - Revert r304953 for release 5.0.0

2017-08-04 Thread Vitaly Buka via cfe-commits
Looks like it's causing
http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-bootstrap/builds/1969/steps/build%20clang%2Fmsan/logs/stdio

FAILED: lib/CodeGen/CMakeFiles/LLVMCodeGen.dir/MIRPrinter.cpp.o
/mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-bootstrap/build/llvm_build0/bin/clang++
  -DGTEST_HAS_RTTI=0 -D_DEBUG -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS
-D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Ilib/CodeGen
-I/mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-bootstrap/build/llvm/lib/CodeGen
-Iinclude 
-I/mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-bootstrap/build/llvm/include
-nostdinc++ -isystem
/mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-bootstrap/build/libcxx_build_msan/include
-isystem 
/mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-bootstrap/build/libcxx_build_msan/include/c++/v1
 -lc++abi 
-Wl,--rpath=/mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-bootstrap/build/libcxx_build_msan/lib
-L/mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-bootstrap/build/libcxx_build_msan/lib
-fsanitize=memory -w -stdlib=libc++ -fPIC -fvisibility-inlines-hidden
-Werror=date-time -std=c++11 -Wall -W -Wno-unused-parameter
-Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic
-Wno-long-long -Wcovered-switch-default -Wnon-virtual-dtor
-Wdelete-non-virtual-dtor -Wstring-conversion -fno-omit-frame-pointer
-gline-tables-only -fsanitize=memory -fcolor-diagnostics
-ffunction-sections -fdata-sections -O3-UNDEBUG  -fno-exceptions
-fno-rtti -MD -MT
lib/CodeGen/CMakeFiles/LLVMCodeGen.dir/MIRPrinter.cpp.o -MF
lib/CodeGen/CMakeFiles/LLVMCodeGen.dir/MIRPrinter.cpp.o.d -o
lib/CodeGen/CMakeFiles/LLVMCodeGen.dir/MIRPrinter.cpp.o -c
/mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-bootstrap/build/llvm/lib/CodeGen/MIRPrinter.cpp
clang-5.0: 
/mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-bootstrap/build/llvm/include/llvm/Support/Casting.h:106:
static bool llvm::isa_impl_cl::doit(const From*)
[with To = llvm::ConstantInt; From = llvm::Value]: Assertion `Val &&
"isa<> used on a null pointer"' failed.
#0 0x020b5d4a llvm::sys::PrintStackTrace(llvm::raw_ostream&)
(/mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-bootstrap/build/llvm_build0/bin/clang-5.0+0x20b5d4a)
#1 0x020b3abe llvm::sys::RunSignalHandlers()
(/mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-bootstrap/build/llvm_build0/bin/clang-5.0+0x20b3abe)
#2 0x020b3c32 SignalHandler(int)
(/mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-bootstrap/build/llvm_build0/bin/clang-5.0+0x20b3c32)
#3 0x7f319d790390 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x11390)
#4 0x7f319c71c428 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x35428)
#5 0x7f319c71e02a abort (/lib/x86_64-linux-gnu/libc.so.6+0x3702a)
#6 0x7f319c714bd7 (/lib/x86_64-linux-gnu/libc.so.6+0x2dbd7)
#7 0x7f319c714c82 (/lib/x86_64-linux-gnu/libc.so.6+0x2dc82)
#8 0x0084f464 llvm::isa_impl_wrap::doit(llvm::Value const*
const&) [clone .isra.166] [clone .part.167]
(/mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-bootstrap/build/llvm_build0/bin/clang-5.0+0x84f464)
#9 0x01c35d4c llvm::Value::stripPointerCasts() const
(/mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-bootstrap/build/llvm_build0/bin/clang-5.0+0x1c35d4c)
#10 0x01e996e1 eliminateDeadStores(llvm::BasicBlock&,
llvm::AAResults*, llvm::MemoryDependenceResults*,
llvm::DominatorTree*, llvm::TargetLibraryInfo const*)
(/mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-bootstrap/build/llvm_build0/bin/clang-5.0+0x1e996e1)
#11 0x01e9ad2a eliminateDeadStores(llvm::Function&,
llvm::AAResults*, llvm::MemoryDependenceResults*,
llvm::DominatorTree*, llvm::TargetLibraryInfo const*)
(/mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-bootstrap/build/llvm_build0/bin/clang-5.0+0x1e9ad2a)
#12 0x01bff3a3
llvm::FPPassManager::runOnFunction(llvm::Function&)
(/mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-bootstrap/build/llvm_build0/bin/clang-5.0+0x1bff3a3)
#13 0x01bff46c llvm::FPPassManager::runOnModule(llvm::Module&)
(/mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-bootstrap/build/llvm_build0/bin/clang-5.0+0x1bff46c)#14
0x01bfef0d llvm::legacy::PassManagerImpl::run(llvm::Module&)
(/mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-bootstrap/build/llvm_build0/bin/clang-5.0+0x1bfef0d)
#15 0x0225c6d1
clang::EmitBackendOutput(clang::DiagnosticsEngine&,
clang::HeaderSearchOptions const&, clang::CodeGenOptions const&,
clang::TargetOptions const&, clang::LangOptions const&,
llvm::DataLayout const&, llvm::Module*, clang::BackendAction,
std::unique_ptr)
(/mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-bootstrap/build/llvm_build0/bin/clang-5.0+0x225c6d1)
#16 0x029691a9
clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&)

[PATCH] D36324: Integrate Kostya's clang-proto-fuzzer with LLVM.

2017-08-04 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added inline comments.



Comment at: clang/tools/clang-fuzzer/CMakeLists.txt:12
+# Hack to bypass LLVM's cmake sources check and allow multiple libraries 
and
+# executables from this directory.
+set(LLVM_OPTIONAL_SOURCES

morehouse wrote:
> vitalybuka wrote:
> > You already download mutator, so maybe just DOWNLOAD_PROTOBUF and simplify 
> > this piece?
> That would be simpler if only protobuf-mutator needed protobuf.  But since we 
> need protobuf for some of the source files here, it would actually make this 
> CMakeLists.txt more complicated since it would have to fish for the paths 
> where protobuf mutator builds protobuf and then redefine variables.
It's ok to share code, but I don't see fuzzer with accept string as is.



Comment at: clang/tools/clang-fuzzer/cxx_proto.proto:16
+
+syntax = "proto2";
+//option cc_api_version = 2;

I'd suggest proto3



Comment at: clang/tools/clang-fuzzer/cxx_proto.proto:93
+}
+
+package clang_fuzzer;

morehouse wrote:
> vitalybuka wrote:
> > message CxxInput {
> >   required Function f = 1;
> >   required int/enum opt_level = 2;
> >   required enum tripple = 3;
> >   required scalar-evolution-max-arith-depth ...
> > }
> Interesting idea.  This would allow for protobuf-mutator to choose different 
> option combinations, if I understand correctly.
> 
> Is that worth adding to this initial patch, though?
yes, instead of CXX_FUZZ_MORE


https://reviews.llvm.org/D36324



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


r310138 - [libclang] Determinize order of platform availability attrs

2017-08-04 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Fri Aug  4 14:52:25 2017
New Revision: 310138

URL: http://llvm.org/viewvc/llvm-project?rev=310138=rev
Log:
[libclang] Determinize order of platform availability attrs

Previously this code was doing std::sort on IdentifierInfo pointers. Now
it sorts alphabetically by platform name.

This should de-flake clang/test/Index/availability.c, which was failing
non-deterministically for me.

Modified:
cfe/trunk/tools/libclang/CIndex.cpp

Modified: cfe/trunk/tools/libclang/CIndex.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=310138=310137=310138=diff
==
--- cfe/trunk/tools/libclang/CIndex.cpp (original)
+++ cfe/trunk/tools/libclang/CIndex.cpp Fri Aug  4 14:52:25 2017
@@ -7303,7 +7303,8 @@ static void getCursorPlatformAvailabilit
 
   std::sort(AvailabilityAttrs.begin(), AvailabilityAttrs.end(),
 [](AvailabilityAttr *LHS, AvailabilityAttr *RHS) {
-  return LHS->getPlatform() > RHS->getPlatform();
+  return LHS->getPlatform()->getName() <
+ RHS->getPlatform()->getName();
 });
   ASTContext  = D->getASTContext();
   auto It = std::unique(


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


r310137 - [Support] Use FILE_SHARE_DELETE to fix RemoveFileOnSignal on Windows

2017-08-04 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Fri Aug  4 14:52:00 2017
New Revision: 310137

URL: http://llvm.org/viewvc/llvm-project?rev=310137=rev
Log:
[Support] Use FILE_SHARE_DELETE to fix RemoveFileOnSignal on Windows

Summary:
Tools like clang that use RemoveFileOnSignal on their output files
weren't actually able to clean up their outputs before this change.  Now
the call to llvm::sys::fs::remove succeeds and the temporary file is
deleted. This is a stop-gap to fix clang before implementing the
solution outlined in PR34070.

Reviewers: davide

Subscribers: llvm-commits, hiraditya

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

Added:
cfe/trunk/test/Frontend/remove-file-on-signal.c

Added: cfe/trunk/test/Frontend/remove-file-on-signal.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/remove-file-on-signal.c?rev=310137=auto
==
--- cfe/trunk/test/Frontend/remove-file-on-signal.c (added)
+++ cfe/trunk/test/Frontend/remove-file-on-signal.c Fri Aug  4 14:52:00 2017
@@ -0,0 +1,7 @@
+// RUN: rm -rf %t && mkdir -p %t && cd %t
+// RUN: not --crash %clang_cc1 %s -emit-llvm -o foo.ll
+// RUN: ls . | FileCheck %s --allow-empty
+// CHECK-NOT: foo.ll
+
+#pragma clang __debug crash
+FOO


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


[PATCH] D36324: Integrate Kostya's clang-proto-fuzzer with LLVM.

2017-08-04 Thread Matt Morehouse via Phabricator via cfe-commits
morehouse added inline comments.



Comment at: clang/cmake/modules/ProtobufMutator.cmake:13
+-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
+-DCMAKE_BUILD_TYPE=Debug
+  BUILD_COMMAND ${CMAKE_MAKE_PROGRAM}

vitalybuka wrote:
> Why this is debug?
> 
I was just using what the libprotobuf-mutator readme suggested.  But I can 
change it to use CMAKE_BUILD_TYPE instead.



Comment at: clang/tools/clang-fuzzer/CMakeLists.txt:12
+# Hack to bypass LLVM's cmake sources check and allow multiple libraries 
and
+# executables from this directory.
+set(LLVM_OPTIONAL_SOURCES

vitalybuka wrote:
> You already download mutator, so maybe just DOWNLOAD_PROTOBUF and simplify 
> this piece?
That would be simpler if only protobuf-mutator needed protobuf.  But since we 
need protobuf for some of the source files here, it would actually make this 
CMakeLists.txt more complicated since it would have to fish for the paths where 
protobuf mutator builds protobuf and then redefine variables.



Comment at: clang/tools/clang-fuzzer/ClangFuzzer.cpp:20
 
 extern "C" int LLVMFuzzerTestOneInput(uint8_t *data, size_t size) {
   std::string s((const char *)data, size);

vitalybuka wrote:
> Do we want replace this fuzzer? Why not just add another one?
The idea was to keep ClangFuzzer and add ClangProtoFuzzer alongside it.  
However, the two share a fair amount of code, which was factored out into 
HandleCXX.



Comment at: clang/tools/clang-fuzzer/cxx_proto.proto:93
+}
+
+package clang_fuzzer;

vitalybuka wrote:
> message CxxInput {
>   required Function f = 1;
>   required int/enum opt_level = 2;
>   required enum tripple = 3;
>   required scalar-evolution-max-arith-depth ...
> }
Interesting idea.  This would allow for protobuf-mutator to choose different 
option combinations, if I understand correctly.

Is that worth adding to this initial patch, though?


https://reviews.llvm.org/D36324



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


r310136 - [libFuzzer] add -fsanitize-coverage-pc-table to -fsanitize=fuzzer

2017-08-04 Thread Kostya Serebryany via cfe-commits
Author: kcc
Date: Fri Aug  4 14:35:11 2017
New Revision: 310136

URL: http://llvm.org/viewvc/llvm-project?rev=310136=rev
Log:
[libFuzzer] add -fsanitize-coverage-pc-table to -fsanitize=fuzzer

Modified:
cfe/trunk/lib/Driver/SanitizerArgs.cpp
cfe/trunk/test/Driver/fuzzer.c

Modified: cfe/trunk/lib/Driver/SanitizerArgs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/SanitizerArgs.cpp?rev=310136=310135=310136=diff
==
--- cfe/trunk/lib/Driver/SanitizerArgs.cpp (original)
+++ cfe/trunk/lib/Driver/SanitizerArgs.cpp Fri Aug  4 14:35:11 2017
@@ -288,7 +288,8 @@ SanitizerArgs::SanitizerArgs(const ToolC
 
   // Enable coverage if the fuzzing flag is set.
   if (Add & Fuzzer)
-CoverageFeatures |= CoverageTracePCGuard | CoverageIndirCall | 
CoverageTraceCmp;
+CoverageFeatures |= CoverageTracePCGuard | CoverageIndirCall |
+CoverageTraceCmp | CoveragePCTable;
 
   Kinds |= Add;
 } else if (Arg->getOption().matches(options::OPT_fno_sanitize_EQ)) {

Modified: cfe/trunk/test/Driver/fuzzer.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/fuzzer.c?rev=310136=310135=310136=diff
==
--- cfe/trunk/test/Driver/fuzzer.c (original)
+++ cfe/trunk/test/Driver/fuzzer.c Fri Aug  4 14:35:11 2017
@@ -6,6 +6,7 @@
 // CHECK-COVERAGE: -fsanitize-coverage-trace-pc-guard
 // CHECK-COVERAGE-SAME: -fsanitize-coverage-indirect-calls
 // CHECK-COVERAGE-SAME: -fsanitize-coverage-trace-cmp
+// CHECK-COVERAGE-SAME: -fsanitize-coverage-pc-table
 
 // RUN: %clang -fsanitize=fuzzer -target i386-unknown-linux -stdlib=platform 
%s -### 2>&1 | FileCheck --check-prefixes=CHECK-LIBCXX-LINUX %s
 //


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


r310135 - Revert "[OPENMP][DEBUG] Set proper address space info if required by target."

2017-08-04 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Fri Aug  4 14:27:11 2017
New Revision: 310135

URL: http://llvm.org/viewvc/llvm-project?rev=310135=rev
Log:
Revert "[OPENMP][DEBUG] Set proper address space info if required by target."

This reverts commit r310104.

Removed:
cfe/trunk/test/OpenMP/target_parallel_debug_codegen.cpp
Modified:
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h
cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.h
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/test/OpenMP/nvptx_target_firstprivate_codegen.cpp

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=310135=310134=310135=diff
==
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Fri Aug  4 14:27:11 2017
@@ -2685,14 +2685,6 @@ def OMPCaptureNoInit : InheritableAttr {
   let Documentation = [Undocumented];
 }
 
-def OMPCaptureKind : Attr {
-  // This attribute has no spellings as it is only ever created implicitly.
-  let Spellings = [];
-  let SemaHandler = 0;
-  let Args = [UnsignedArgument<"CaptureKind">];
-  let Documentation = [Undocumented];
-}
-
 def OMPDeclareSimdDecl : Attr {
   let Spellings = [Pragma<"omp", "declare simd">];
   let Subjects = SubjectList<[Function]>;

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=310135=310134=310135=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Fri Aug  4 14:27:11 2017
@@ -8527,11 +8527,6 @@ public:
   /// is performed.
   bool isOpenMPPrivateDecl(ValueDecl *D, unsigned Level);
 
-  /// Sets OpenMP capture kind (OMPC_private, OMPC_firstprivate, OMPC_map etc.)
-  /// for \p FD based on DSA for the provided corresponding captured 
declaration
-  /// \p D.
-  void setOpenMPCaptureKind(FieldDecl *FD, ValueDecl *D, unsigned Level);
-
   /// \brief Check if the specified variable is captured  by 'target' 
directive.
   /// \param Level Relative level of nested OpenMP construct for that the check
   /// is performed.

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h?rev=310135=310134=310135=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h Fri Aug  4 14:27:11 2017
@@ -1325,33 +1325,6 @@ public:
   virtual void emitDoacrossOrdered(CodeGenFunction ,
const OMPDependClause *C);
 
-  /// Translates argument of outlined function if this is required for target.
-  /// \param FD A field for the corresponding captured variable in the captured
-  /// record.
-  /// \param NativeParam Native parameter of the outlined function.
-  virtual const VarDecl *translateParameter(const FieldDecl *FD,
-const VarDecl *NativeParam) const {
-return NativeParam;
-  }
-
-  typedef llvm::function_ref
-  MappingFnType;
-  /// Maps the native argument to the address of the target-specific argument.
-  /// \param FD A field for the corresponding captured variable in the captured
-  /// record.
-  /// \param NativeParam Native parameter of the outlined function.
-  /// \param TargetParam Target-specific parameter of the outlined function
-  /// (provided by the \a CGOpenMPRuntime::translateParameter).
-  /// \param MapFn Mapping function that maps the address of the \p NativeParam
-  /// to the address of the \p TargetParam.
-  virtual void mapParameterAddress(CodeGenFunction , const FieldDecl *FD,
-   const VarDecl *NativeParam,
-   const VarDecl *TargetParam,
-   const MappingFnType MapFn) const {
-assert(NativeParam == TargetParam &&
-   "native and target args must be the same");
-  }
-
   /// Emits call of the outlined function with the provided arguments,
   /// translating these arguments to correct target-specific arguments.
   virtual void

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp?rev=310135=310134=310135=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp Fri Aug  4 14:27:11 2017
@@ -2238,82 +2238,3 @@ void 

r310134 - Revert "[OPENMP] Fix for pacify buildbots, NFC."

2017-08-04 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Fri Aug  4 14:26:25 2017
New Revision: 310134

URL: http://llvm.org/viewvc/llvm-project?rev=310134=rev
Log:
Revert "[OPENMP] Fix for pacify buildbots, NFC."

This reverts commit r310120.

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

Modified: cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp?rev=310134=310133=310134=diff
==
--- cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp Fri Aug  4 14:26:25 2017
@@ -320,7 +320,10 @@ static std::pair
   ArgType, ImplicitParamDecl::Other);
 Args.emplace_back(Arg);
 // Do not cast arguments if we emit function with non-original types.
-TargetArgs.emplace_back(CGM.getOpenMPRuntime().translateParameter(FD, 
Arg));
+TargetArgs.emplace_back(
+FO.UIntPtrCastRequired
+? Arg
+: CGM.getOpenMPRuntime().translateParameter(FD, Arg));
 ++I;
   }
   Args.append(
@@ -444,11 +447,15 @@ CodeGenFunction::GenerateOpenMPCapturedS
   FunctionArgList Args;
   llvm::DenseMap> LocalAddrs;
   llvm::DenseMap> 
VLASizes;
-  FunctionOptions FO(, !NeedWrapperFunction, 
/*RegisterCastedArgsOnly=*/false,
- CapturedStmtInfo->getHelperName(),
- [](CodeGenFunction , const VarDecl *VD, Address Addr) 
{
-   CGF.setAddrOfLocalVar(VD, Addr);
- });
+  FunctionOptions FO(
+  , !NeedWrapperFunction, /*RegisterCastedArgsOnly=*/false,
+  CapturedStmtInfo->getHelperName(),
+  [NeedWrapperFunction](CodeGenFunction , const VarDecl *VD,
+Address Addr) {
+assert(NeedWrapperFunction && "Function should not be called if "
+  "wrapper function is not required.");
+CGF.setAddrOfLocalVar(VD, Addr);
+  });
   llvm::Function *F;
   bool HasUIntPtrArgs;
   std::tie(F, HasUIntPtrArgs) = emitOutlinedFunctionPrologue(
@@ -470,12 +477,11 @@ CodeGenFunction::GenerateOpenMPCapturedS
   SmallString<256> Buffer;
   llvm::raw_svector_ostream Out(Buffer);
   Out << "__nondebug_wrapper_" << CapturedStmtInfo->getHelperName();
-  FunctionOptions WrapperFO(
-  , /*UIntPtrCastRequired=*/true,
-  /*RegisterCastedArgsOnly=*/true, Out.str(),
-  [](CodeGenFunction , const VarDecl *VD, Address Addr) {
-CGF.setAddrOfLocalVar(VD, Addr);
-  });
+  FunctionOptions WrapperFO(, /*UIntPtrCastRequired=*/true,
+/*RegisterCastedArgsOnly=*/true, Out.str(),
+[](CodeGenFunction &, const VarDecl *, Address) {
+  llvm_unreachable("Function should not be 
called");
+});
   CodeGenFunction WrapperCGF(CGM, /*suppressNewContext=*/true);
   WrapperCGF.disableDebugInfo();
   Args.clear();


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


r310132 - Reland "CFI: blacklist STL allocate() from unrelated-casts"

2017-08-04 Thread Vlad Tsyrklevich via cfe-commits
Author: vlad.tsyrklevich
Date: Fri Aug  4 14:21:00 2017
New Revision: 310132

URL: http://llvm.org/viewvc/llvm-project?rev=310132=rev
Log:
Reland "CFI: blacklist STL allocate() from unrelated-casts"

Reland r310097 with a fix for a debug assertion in NamedDecl.getName()

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

Added:
cfe/trunk/test/CodeGen/cfi-unrelated-cast.cpp
Modified:
cfe/trunk/lib/CodeGen/CodeGenFunction.cpp

Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?rev=310132=310131=310132=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp Fri Aug  4 14:21:00 2017
@@ -723,6 +723,26 @@ static void markAsIgnoreThreadCheckingAt
   Fn->removeFnAttr(llvm::Attribute::SanitizeThread);
 }
 
+static bool matchesStlAllocatorFn(const Decl *D, const ASTContext ) {
+  auto *MD = dyn_cast_or_null(D);
+  if (!MD || !MD->getDeclName().getAsIdentifierInfo() ||
+  !MD->getDeclName().getAsIdentifierInfo()->isStr("allocate") ||
+  (MD->getNumParams() != 1 && MD->getNumParams() != 2))
+return false;
+
+  if (MD->parameters()[0]->getType().getCanonicalType() != Ctx.getSizeType())
+return false;
+
+  if (MD->getNumParams() == 2) {
+auto *PT = MD->parameters()[1]->getType()->getAs();
+if (!PT || !PT->isVoidPointerType() ||
+!PT->getPointeeType().isConstQualified())
+  return false;
+  }
+
+  return true;
+}
+
 void CodeGenFunction::StartFunction(GlobalDecl GD,
 QualType RetTy,
 llvm::Function *Fn,
@@ -782,6 +802,14 @@ void CodeGenFunction::StartFunction(Glob
 }
   }
 
+  // Ignore unrelated casts in STL allocate() since the allocator must cast
+  // from void* to T* before object initialization completes. Don't match on 
the
+  // namespace because not all allocators are in std::
+  if (D && SanOpts.has(SanitizerKind::CFIUnrelatedCast)) {
+if (matchesStlAllocatorFn(D, getContext()))
+  SanOpts.Mask &= ~SanitizerKind::CFIUnrelatedCast;
+  }
+
   // Apply xray attributes to the function (as a string, for now)
   if (D && ShouldXRayInstrumentFunction()) {
 if (const auto *XRayAttr = D->getAttr()) {

Added: cfe/trunk/test/CodeGen/cfi-unrelated-cast.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/cfi-unrelated-cast.cpp?rev=310132=auto
==
--- cfe/trunk/test/CodeGen/cfi-unrelated-cast.cpp (added)
+++ cfe/trunk/test/CodeGen/cfi-unrelated-cast.cpp Fri Aug  4 14:21:00 2017
@@ -0,0 +1,37 @@
+// STL allocators should not have unrelated-cast tests applied
+// RUN: %clang_cc1 -flto -triple x86_64-unknown-linux -fvisibility hidden 
-fsanitize=cfi-unrelated-cast -emit-llvm -o - %s | FileCheck %s
+
+#include 
+
+template
+class myalloc {
+ public:
+  // CHECK: define{{.*}}allocateE{{.}}
+  // CHECK-NOT: llvm.type.test
+  T *allocate(size_t sz) {
+return (T*)::operator new(sz);
+  }
+
+  // CHECK: define{{.*}}allocateE{{.}}PKv
+  // CHECK-NOT: llvm.type.test
+  T *allocate(size_t sz, const void *ptr) {
+return (T*)::operator new(sz);
+  }
+
+  // CHECK: define{{.*}}differentName
+  // CHECK: llvm.type.test
+  T *differentName(size_t sz, const void *ptr) {
+return (T*)::operator new(sz);
+  }
+};
+
+class C1 {
+  virtual void f() {}
+};
+
+C1 *f1() {
+  myalloc allocator;
+  (void)allocator.allocate(16);
+  (void)allocator.allocate(16, 0);
+  (void)allocator.differentName(16, 0);
+}


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


[PATCH] D36324: Integrate Kostya's clang-proto-fuzzer with LLVM.

2017-08-04 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added inline comments.



Comment at: clang/cmake/modules/ProtobufMutator.cmake:13
+-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
+-DCMAKE_BUILD_TYPE=Debug
+  BUILD_COMMAND ${CMAKE_MAKE_PROGRAM}

Why this is debug?




Comment at: clang/tools/clang-fuzzer/CMakeLists.txt:12
+# Hack to bypass LLVM's cmake sources check and allow multiple libraries 
and
+# executables from this directory.
+set(LLVM_OPTIONAL_SOURCES

You already download mutator, so maybe just DOWNLOAD_PROTOBUF and simplify this 
piece?



Comment at: clang/tools/clang-fuzzer/ClangFuzzer.cpp:20
 
 extern "C" int LLVMFuzzerTestOneInput(uint8_t *data, size_t size) {
   std::string s((const char *)data, size);

Do we want replace this fuzzer? Why not just add another one?



Comment at: clang/tools/clang-fuzzer/cxx_proto.proto:93
+}
+
+package clang_fuzzer;

message CxxInput {
  required Function f = 1;
  required int/enum opt_level = 2;
  required enum tripple = 3;
  required scalar-evolution-max-arith-depth ...
}



Comment at: clang/tools/clang-fuzzer/proto-to-cxx/proto_to_cxx.cpp:22
+
+#define P(Type) std::ostream <<(std::ostream , const Type )
+// Forward decls.

Not sure that macro here is justified
could you please replace with 
std::ostream <<(std::ostream , const BinaryOp& x) {

...


https://reviews.llvm.org/D36324



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


[PATCH] D32210: [Sema][ObjC] Add support for attribute "noescape"

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



Comment at: lib/CodeGen/CGCall.cpp:2096
+if (FI.getExtParameterInfo(ArgNo).isNoEscape())
+  Attrs.addAttribute(llvm::Attribute::NoCapture);
+

rjmccall wrote:
> ahatanak wrote:
> > rjmccall wrote:
> > > You should make sure that building a CGFunctionInfo with an 
> > > ObjCMethodDecl* collects this from the parameters.  (And add tests!)
> > > 
> > > For blocks, at least, the ObjC method case is arguably more important 
> > > than the C function case.
> > Should we issue a warning when a parameter of an ObjC method is annotated 
> > with noescape and the corresponding parameter of the overriding method in a 
> > derived class isn't? Also, should we warn about inconsistent C++ virtual 
> > functions too?
> Mmm.  Probably yes in both cases, although we could alternatively just 
> silently propagate the attribute InheritableParamAttr-style.
In the new patch, I chose to print diagnostics when the overriding method is 
missing noescape on its parameters lest users unintentionally let pointers 
escape.  


https://reviews.llvm.org/D32210



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


[PATCH] D32210: [Sema][ObjC] Add support for attribute "noescape"

2017-08-04 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak updated this revision to Diff 109814.
ahatanak added a comment.

Include noescape attribute information in the function prototype and modify the 
AST printer and name mangling accordingly.

Also, make changes to allow implicit conversion from a function that takes 
noescape parameters to a function that doesn't. For example:

void (*fnptr0)(int *) =  // valid conversion.
void (*fnptr1)(__attribute__((noescape)) int *) =  // invalid 
conversion.


https://reviews.llvm.org/D32210

Files:
  include/clang/AST/Type.h
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/Sema.h
  lib/AST/ItaniumMangle.cpp
  lib/AST/TypePrinter.cpp
  lib/CodeGen/CGCall.cpp
  lib/Sema/SemaDeclAttr.cpp
  lib/Sema/SemaDeclCXX.cpp
  lib/Sema/SemaDeclObjC.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaOverload.cpp
  lib/Sema/SemaTemplate.cpp
  lib/Sema/SemaType.cpp
  test/CodeGenCXX/noescape.cpp
  test/CodeGenObjC/noescape.m
  test/Misc/ast-dump-attr.cpp
  test/Misc/pragma-attribute-supported-attributes-list.test
  test/Misc/warning-flags.c
  test/Sema/noescape.c
  test/SemaObjCXX/noescape.mm

Index: test/SemaObjCXX/noescape.mm
===
--- /dev/null
+++ test/SemaObjCXX/noescape.mm
@@ -0,0 +1,76 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -fblocks -std=c++11 %s
+
+typedef void (^BlockTy)();
+
+struct S {
+  int i;
+  void m();
+};
+
+void noescapeFunc0(id, __attribute__((noescape)) BlockTy);
+void noescapeFunc1(id, [[clang::noescape]] BlockTy);
+void noescapeFunc2(__attribute__((noescape)) int *); // expected-note {{previous declaration is here}}
+void noescapeFunc3(__attribute__((noescape)) id);
+void noescapeFunc4(__attribute__((noescape)) int &);
+void noescapeFunc2(int *); // expected-error {{conflicting types for 'noescapeFunc2'}}
+
+void invalidFunc0(int __attribute__((noescape))); // expected-warning {{'noescape' attribute only applies to pointer arguments}}
+void invalidFunc1(int __attribute__((noescape(0; // expected-error {{'noescape' attribute takes no arguments}}
+void invalidFunc2(int0 *__attribute__((noescape))); // expected-error {{use of undeclared identifier 'int0'; did you mean 'int'?}}
+void invalidFunc3(__attribute__((noescape)) int (S::*Ty)); // expected-warning {{'noescape' attribute only applies to pointer arguments}}
+void invalidFunc4(__attribute__((noescape)) void (S::*Ty)()); // expected-warning {{'noescape' attribute only applies to pointer arguments}}
+int __attribute__((noescape)) g; // expected-warning {{'noescape' attribute only applies to parameters}}
+
+struct S1 {
+  virtual void m0(int *__attribute__((noescape))); // expected-note {{parameter of overridden method is annotated with __attribute__((noescape))}}
+};
+
+struct S2 : S1 {
+  void m0(int *__attribute__((noescape))) override;
+};
+
+struct S3 : S1 {
+  void m0(int *) override; // expected-warning {{parameter of overriding method should be annotated with __attribute__((noescape))}}
+};
+
+__attribute__((objc_root_class))
+@interface C0
+-(void) m0:(int*)__attribute__((noescape)) p; // expected-note {{parameter of overridden method is annotated with __attribute__((noescape))}}
+@end
+
+@implementation C0
+-(void) m0:(int*)__attribute__((noescape)) p {}
+@end
+
+@interface C1 : C0
+-(void) m0:(int*)__attribute__((noescape)) p;
+@end
+
+@implementation C1 : C0
+-(void) m0:(int*)__attribute__((noescape)) p {}
+@end
+
+@interface C2 : C0
+-(void) m0:(int*) p; // expected-warning {{parameter of overriding method should be annotated with __attribute__((noescape))}}
+@end
+
+@implementation C2 : C0
+-(void) m0:(int*) p {}
+@end
+
+void func0(int *);
+void (*fnptr0)(int *);
+void (*fnptr1)(__attribute__((noescape)) int *);
+template struct S4 {};
+template struct S5 {}; // expected-note {{template parameter is declared here}}
+
+void test0() {
+  fnptr0 = 
+  fnptr0 = 
+  fnptr1 =  // expected-error {{assigning to 'void (*)(__attribute__((noescape)) int *)' from incompatible type 'void (*)(int *)'}}
+  fnptr1 = 
+  S4<> e0;
+  S4<> e1;
+  S5<> ne0; // expected-error {{non-type template argument of type 'void (*)(int *)' cannot be converted to a value of type 'void (*)(__attribute__((noescape)) int *)'}}
+  S5<> ne1;
+}
Index: test/Sema/noescape.c
===
--- /dev/null
+++ test/Sema/noescape.c
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+void escapefunc(int *);
+void noescapefunc(__attribute__((noescape)) int *); // expected-note {{previous declaration is here}}
+void (*fnptr0)(int *);
+void (*fnptr1)(__attribute__((noescape)) int *);
+void noescapefunc(int *); // expected-error {{conflicting types for 'noescapefunc'}}
+
+void test0() {
+  fnptr0 = 
+  fnptr0 = 
+  fnptr1 =  // expected-warning {{incompatible function pointer types assigning to 'void (*)(__attribute__((noescape)) int *)' from 'void (*)(int *)'}}
+  fnptr1 = 
+}

r310121 - Revert "Reland "CFI: blacklist STL allocate() from unrelated-casts""

2017-08-04 Thread Vlad Tsyrklevich via cfe-commits
Author: vlad.tsyrklevich
Date: Fri Aug  4 13:37:49 2017
New Revision: 310121

URL: http://llvm.org/viewvc/llvm-project?rev=310121=rev
Log:
Revert "Reland "CFI: blacklist STL allocate() from unrelated-casts""

This reverts commit r310105.

Removed:
cfe/trunk/test/CodeGen/cfi-unrelated-cast.cpp
Modified:
cfe/trunk/lib/CodeGen/CodeGenFunction.cpp

Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?rev=310121=310120=310121=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp Fri Aug  4 13:37:49 2017
@@ -723,25 +723,6 @@ static void markAsIgnoreThreadCheckingAt
   Fn->removeFnAttr(llvm::Attribute::SanitizeThread);
 }
 
-static bool matchesStlAllocatorFn(const Decl *D, const ASTContext ) {
-  auto *MD = dyn_cast_or_null(D);
-  if (!MD || !MD->getName().equals("allocate") ||
-  (MD->getNumParams() != 1 && MD->getNumParams() != 2))
-return false;
-
-  if (MD->parameters()[0]->getType().getCanonicalType() != Ctx.getSizeType())
-return false;
-
-  if (MD->getNumParams() == 2) {
-auto *PT = MD->parameters()[1]->getType()->getAs();
-if (!PT || !PT->isVoidPointerType() ||
-!PT->getPointeeType().isConstQualified())
-  return false;
-  }
-
-  return true;
-}
-
 void CodeGenFunction::StartFunction(GlobalDecl GD,
 QualType RetTy,
 llvm::Function *Fn,
@@ -801,14 +782,6 @@ void CodeGenFunction::StartFunction(Glob
 }
   }
 
-  // Ignore unrelated casts in STL allocate() since the allocator must cast
-  // from void* to T* before object initialization completes. Don't match on 
the
-  // namespace because not all allocators are in std::
-  if (D && SanOpts.has(SanitizerKind::CFIUnrelatedCast)) {
-if (matchesStlAllocatorFn(D, getContext()))
-  SanOpts.Mask &= ~SanitizerKind::CFIUnrelatedCast;
-  }
-
   // Apply xray attributes to the function (as a string, for now)
   if (D && ShouldXRayInstrumentFunction()) {
 if (const auto *XRayAttr = D->getAttr()) {

Removed: cfe/trunk/test/CodeGen/cfi-unrelated-cast.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/cfi-unrelated-cast.cpp?rev=310120=auto
==
--- cfe/trunk/test/CodeGen/cfi-unrelated-cast.cpp (original)
+++ cfe/trunk/test/CodeGen/cfi-unrelated-cast.cpp (removed)
@@ -1,37 +0,0 @@
-// STL allocators should not have unrelated-cast tests applied
-// RUN: %clang_cc1 -flto -triple x86_64-unknown-linux -fvisibility hidden 
-fsanitize=cfi-unrelated-cast -emit-llvm -o - %s | FileCheck %s
-
-#include 
-
-template
-class myalloc {
- public:
-  // CHECK: define{{.*}}allocateE{{.}}
-  // CHECK-NOT: llvm.type.test
-  T *allocate(size_t sz) {
-return (T*)::operator new(sz);
-  }
-
-  // CHECK: define{{.*}}allocateE{{.}}PKv
-  // CHECK-NOT: llvm.type.test
-  T *allocate(size_t sz, const void *ptr) {
-return (T*)::operator new(sz);
-  }
-
-  // CHECK: define{{.*}}differentName
-  // CHECK: llvm.type.test
-  T *differentName(size_t sz, const void *ptr) {
-return (T*)::operator new(sz);
-  }
-};
-
-class C1 {
-  virtual void f() {}
-};
-
-C1 *f1() {
-  myalloc allocator;
-  (void)allocator.allocate(16);
-  (void)allocator.allocate(16, 0);
-  (void)allocator.differentName(16, 0);
-}


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


r310120 - [OPENMP] Fix for pacify buildbots, NFC.

2017-08-04 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Fri Aug  4 13:29:52 2017
New Revision: 310120

URL: http://llvm.org/viewvc/llvm-project?rev=310120=rev
Log:
[OPENMP] Fix for pacify buildbots, NFC.

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

Modified: cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp?rev=310120=310119=310120=diff
==
--- cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp Fri Aug  4 13:29:52 2017
@@ -320,10 +320,7 @@ static std::pair
   ArgType, ImplicitParamDecl::Other);
 Args.emplace_back(Arg);
 // Do not cast arguments if we emit function with non-original types.
-TargetArgs.emplace_back(
-FO.UIntPtrCastRequired
-? Arg
-: CGM.getOpenMPRuntime().translateParameter(FD, Arg));
+TargetArgs.emplace_back(CGM.getOpenMPRuntime().translateParameter(FD, 
Arg));
 ++I;
   }
   Args.append(
@@ -447,15 +444,11 @@ CodeGenFunction::GenerateOpenMPCapturedS
   FunctionArgList Args;
   llvm::DenseMap> LocalAddrs;
   llvm::DenseMap> 
VLASizes;
-  FunctionOptions FO(
-  , !NeedWrapperFunction, /*RegisterCastedArgsOnly=*/false,
-  CapturedStmtInfo->getHelperName(),
-  [NeedWrapperFunction](CodeGenFunction , const VarDecl *VD,
-Address Addr) {
-assert(NeedWrapperFunction && "Function should not be called if "
-  "wrapper function is not required.");
-CGF.setAddrOfLocalVar(VD, Addr);
-  });
+  FunctionOptions FO(, !NeedWrapperFunction, 
/*RegisterCastedArgsOnly=*/false,
+ CapturedStmtInfo->getHelperName(),
+ [](CodeGenFunction , const VarDecl *VD, Address Addr) 
{
+   CGF.setAddrOfLocalVar(VD, Addr);
+ });
   llvm::Function *F;
   bool HasUIntPtrArgs;
   std::tie(F, HasUIntPtrArgs) = emitOutlinedFunctionPrologue(
@@ -477,11 +470,12 @@ CodeGenFunction::GenerateOpenMPCapturedS
   SmallString<256> Buffer;
   llvm::raw_svector_ostream Out(Buffer);
   Out << "__nondebug_wrapper_" << CapturedStmtInfo->getHelperName();
-  FunctionOptions WrapperFO(, /*UIntPtrCastRequired=*/true,
-/*RegisterCastedArgsOnly=*/true, Out.str(),
-[](CodeGenFunction &, const VarDecl *, Address) {
-  llvm_unreachable("Function should not be 
called");
-});
+  FunctionOptions WrapperFO(
+  , /*UIntPtrCastRequired=*/true,
+  /*RegisterCastedArgsOnly=*/true, Out.str(),
+  [](CodeGenFunction , const VarDecl *VD, Address Addr) {
+CGF.setAddrOfLocalVar(VD, Addr);
+  });
   CodeGenFunction WrapperCGF(CGM, /*suppressNewContext=*/true);
   WrapperCGF.disableDebugInfo();
   Args.clear();


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


[PATCH] D36272: [CodeGen][x86_64] Enable 'force_align_arg_pointer' attribute at x86_64

2017-08-04 Thread Tim Northover via Phabricator via cfe-commits
t.p.northover added a comment.

I've added "cfe-commits" as a subscriber since that's how we make sure the 
review request gets to the mailing list (which is still where review 
canonically takes place).


Repository:
  rL LLVM

https://reviews.llvm.org/D36272



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


[PATCH] D35847: clang-format: Fix left pointer alignment after delctype/typeof

2017-08-04 Thread Erik Uhlmann via Phabricator via cfe-commits
euhlmann updated this revision to Diff 109805.
euhlmann added a comment.

Fix bad formatting


https://reviews.llvm.org/D35847

Files:
  lib/Format/TokenAnnotator.cpp
  unittests/Format/FormatTest.cpp


Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -5422,6 +5422,10 @@
   verifyFormat("for (;; *a = b) {\n}", Left);
   verifyFormat("return *this += 1;", Left);
   verifyFormat("throw *x;", Left);
+  verifyFormat("delete *x;", Left);
+  verifyFormat("typedef typeof(int(int, int))* MyFuncPtr;", Left);
+  verifyFormat("[](const decltype(*a)* ptr) {}", Left);
+  verifyFormat("typedef typeof /*comment*/ (int(int, int))* MyFuncPtr;", Left);
 
   verifyIndependentOfContext("a = *(x + y);");
   verifyIndependentOfContext("a = &(x + y);");
@@ -5468,9 +5472,6 @@
   verifyGoogleFormat("T** t = new T*;");
   verifyGoogleFormat("T** t = new T*();");
 
-  FormatStyle PointerLeft = getLLVMStyle();
-  PointerLeft.PointerAlignment = FormatStyle::PAS_Left;
-  verifyFormat("delete *x;", PointerLeft);
   verifyFormat("STATIC_ASSERT((a & b) == 0);");
   verifyFormat("STATIC_ASSERT(0 == (a & b));");
   verifyFormat("template  "
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -1397,11 +1397,13 @@
 if (NextToken->isOneOf(tok::comma, tok::semi))
   return TT_PointerOrReference;
 
-if (PrevToken->is(tok::r_paren) && PrevToken->MatchingParen &&
-PrevToken->MatchingParen->Previous &&
-PrevToken->MatchingParen->Previous->isOneOf(tok::kw_typeof,
-tok::kw_decltype))
-  return TT_PointerOrReference;
+if (PrevToken->is(tok::r_paren) && PrevToken->MatchingParen) {
+  FormatToken *TokenBeforeMatchingParen =
+PrevToken->MatchingParen->getPreviousNonComment();
+  if (TokenBeforeMatchingParen &&
+  TokenBeforeMatchingParen->isOneOf(tok::kw_typeof, tok::kw_decltype))
+return TT_PointerOrReference;
+}
 
 if (PrevToken->Tok.isLiteral() ||
 PrevToken->isOneOf(tok::r_paren, tok::r_square, tok::kw_true,
@@ -2205,15 +2207,24 @@
 Left.Previous->is(tok::kw_case));
   if (Left.is(tok::l_square) && Right.is(tok::amp))
 return false;
-  if (Right.is(TT_PointerOrReference))
-return (Left.is(tok::r_paren) && Line.MightBeFunctionDecl) ||
-   (Left.Tok.isLiteral() || (Left.is(tok::kw_const) && Left.Previous &&
+  if (Right.is(TT_PointerOrReference)) {
+if (Left.is(tok::r_paren) && Line.MightBeFunctionDecl) {
+  if (!Left.MatchingParen)
+return true;
+  FormatToken *TokenBeforeMatchingParen =
+Left.MatchingParen->getPreviousNonComment();
+  if (!TokenBeforeMatchingParen ||
+  !TokenBeforeMatchingParen->isOneOf(tok::kw_typeof, tok::kw_decltype))
+return true;
+}
+return (Left.Tok.isLiteral() || (Left.is(tok::kw_const) && Left.Previous &&
  Left.Previous->is(tok::r_paren)) ||
 (!Left.isOneOf(TT_PointerOrReference, tok::l_paren) &&
  (Style.PointerAlignment != FormatStyle::PAS_Left ||
   (Line.IsMultiVariableDeclStmt &&
(Left.NestingLevel == 0 ||
 (Left.NestingLevel == 1 && Line.First->is(tok::kw_for)));
+  }
   if (Right.is(TT_FunctionTypeLParen) && Left.isNot(tok::l_paren) &&
   (!Left.is(TT_PointerOrReference) ||
(Style.PointerAlignment != FormatStyle::PAS_Right &&


Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -5422,6 +5422,10 @@
   verifyFormat("for (;; *a = b) {\n}", Left);
   verifyFormat("return *this += 1;", Left);
   verifyFormat("throw *x;", Left);
+  verifyFormat("delete *x;", Left);
+  verifyFormat("typedef typeof(int(int, int))* MyFuncPtr;", Left);
+  verifyFormat("[](const decltype(*a)* ptr) {}", Left);
+  verifyFormat("typedef typeof /*comment*/ (int(int, int))* MyFuncPtr;", Left);
 
   verifyIndependentOfContext("a = *(x + y);");
   verifyIndependentOfContext("a = &(x + y);");
@@ -5468,9 +5472,6 @@
   verifyGoogleFormat("T** t = new T*;");
   verifyGoogleFormat("T** t = new T*();");
 
-  FormatStyle PointerLeft = getLLVMStyle();
-  PointerLeft.PointerAlignment = FormatStyle::PAS_Left;
-  verifyFormat("delete *x;", PointerLeft);
   verifyFormat("STATIC_ASSERT((a & b) == 0);");
   verifyFormat("STATIC_ASSERT(0 == (a & b));");
   verifyFormat("template  "
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -1397,11 +1397,13 @@
 if (NextToken->isOneOf(tok::comma, tok::semi))
  

r310105 - Reland "CFI: blacklist STL allocate() from unrelated-casts"

2017-08-04 Thread Vlad Tsyrklevich via cfe-commits
Author: vlad.tsyrklevich
Date: Fri Aug  4 12:50:39 2017
New Revision: 310105

URL: http://llvm.org/viewvc/llvm-project?rev=310105=rev
Log:
Reland "CFI: blacklist STL allocate() from unrelated-casts"

Reland r310097 with a unit test fix for MS ABI build bots.

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

Added:
cfe/trunk/test/CodeGen/cfi-unrelated-cast.cpp
Modified:
cfe/trunk/lib/CodeGen/CodeGenFunction.cpp

Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?rev=310105=310104=310105=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp Fri Aug  4 12:50:39 2017
@@ -723,6 +723,25 @@ static void markAsIgnoreThreadCheckingAt
   Fn->removeFnAttr(llvm::Attribute::SanitizeThread);
 }
 
+static bool matchesStlAllocatorFn(const Decl *D, const ASTContext ) {
+  auto *MD = dyn_cast_or_null(D);
+  if (!MD || !MD->getName().equals("allocate") ||
+  (MD->getNumParams() != 1 && MD->getNumParams() != 2))
+return false;
+
+  if (MD->parameters()[0]->getType().getCanonicalType() != Ctx.getSizeType())
+return false;
+
+  if (MD->getNumParams() == 2) {
+auto *PT = MD->parameters()[1]->getType()->getAs();
+if (!PT || !PT->isVoidPointerType() ||
+!PT->getPointeeType().isConstQualified())
+  return false;
+  }
+
+  return true;
+}
+
 void CodeGenFunction::StartFunction(GlobalDecl GD,
 QualType RetTy,
 llvm::Function *Fn,
@@ -782,6 +801,14 @@ void CodeGenFunction::StartFunction(Glob
 }
   }
 
+  // Ignore unrelated casts in STL allocate() since the allocator must cast
+  // from void* to T* before object initialization completes. Don't match on 
the
+  // namespace because not all allocators are in std::
+  if (D && SanOpts.has(SanitizerKind::CFIUnrelatedCast)) {
+if (matchesStlAllocatorFn(D, getContext()))
+  SanOpts.Mask &= ~SanitizerKind::CFIUnrelatedCast;
+  }
+
   // Apply xray attributes to the function (as a string, for now)
   if (D && ShouldXRayInstrumentFunction()) {
 if (const auto *XRayAttr = D->getAttr()) {

Added: cfe/trunk/test/CodeGen/cfi-unrelated-cast.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/cfi-unrelated-cast.cpp?rev=310105=auto
==
--- cfe/trunk/test/CodeGen/cfi-unrelated-cast.cpp (added)
+++ cfe/trunk/test/CodeGen/cfi-unrelated-cast.cpp Fri Aug  4 12:50:39 2017
@@ -0,0 +1,37 @@
+// STL allocators should not have unrelated-cast tests applied
+// RUN: %clang_cc1 -flto -triple x86_64-unknown-linux -fvisibility hidden 
-fsanitize=cfi-unrelated-cast -emit-llvm -o - %s | FileCheck %s
+
+#include 
+
+template
+class myalloc {
+ public:
+  // CHECK: define{{.*}}allocateE{{.}}
+  // CHECK-NOT: llvm.type.test
+  T *allocate(size_t sz) {
+return (T*)::operator new(sz);
+  }
+
+  // CHECK: define{{.*}}allocateE{{.}}PKv
+  // CHECK-NOT: llvm.type.test
+  T *allocate(size_t sz, const void *ptr) {
+return (T*)::operator new(sz);
+  }
+
+  // CHECK: define{{.*}}differentName
+  // CHECK: llvm.type.test
+  T *differentName(size_t sz, const void *ptr) {
+return (T*)::operator new(sz);
+  }
+};
+
+class C1 {
+  virtual void f() {}
+};
+
+C1 *f1() {
+  myalloc allocator;
+  (void)allocator.allocate(16);
+  (void)allocator.allocate(16, 0);
+  (void)allocator.differentName(16, 0);
+}


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


r310104 - [OPENMP][DEBUG] Set proper address space info if required by target.

2017-08-04 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Fri Aug  4 12:46:10 2017
New Revision: 310104

URL: http://llvm.org/viewvc/llvm-project?rev=310104=rev
Log:
[OPENMP][DEBUG] Set proper address space info if required by target.

Arguments, passed to the outlined function, must have correct address
space info for proper Debug info support. Patch sets global address
space for arguments that are mapped and passed by reference.

Also, cuda-gdb does not handle reference types correctly, so reference
arguments are represented as pointers.

Added:
cfe/trunk/test/OpenMP/target_parallel_debug_codegen.cpp
Modified:
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h
cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.h
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/test/OpenMP/nvptx_target_firstprivate_codegen.cpp

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=310104=310103=310104=diff
==
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Fri Aug  4 12:46:10 2017
@@ -2685,6 +2685,14 @@ def OMPCaptureNoInit : InheritableAttr {
   let Documentation = [Undocumented];
 }
 
+def OMPCaptureKind : Attr {
+  // This attribute has no spellings as it is only ever created implicitly.
+  let Spellings = [];
+  let SemaHandler = 0;
+  let Args = [UnsignedArgument<"CaptureKind">];
+  let Documentation = [Undocumented];
+}
+
 def OMPDeclareSimdDecl : Attr {
   let Spellings = [Pragma<"omp", "declare simd">];
   let Subjects = SubjectList<[Function]>;

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=310104=310103=310104=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Fri Aug  4 12:46:10 2017
@@ -8527,6 +8527,11 @@ public:
   /// is performed.
   bool isOpenMPPrivateDecl(ValueDecl *D, unsigned Level);
 
+  /// Sets OpenMP capture kind (OMPC_private, OMPC_firstprivate, OMPC_map etc.)
+  /// for \p FD based on DSA for the provided corresponding captured 
declaration
+  /// \p D.
+  void setOpenMPCaptureKind(FieldDecl *FD, ValueDecl *D, unsigned Level);
+
   /// \brief Check if the specified variable is captured  by 'target' 
directive.
   /// \param Level Relative level of nested OpenMP construct for that the check
   /// is performed.

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h?rev=310104=310103=310104=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h Fri Aug  4 12:46:10 2017
@@ -1325,6 +1325,33 @@ public:
   virtual void emitDoacrossOrdered(CodeGenFunction ,
const OMPDependClause *C);
 
+  /// Translates argument of outlined function if this is required for target.
+  /// \param FD A field for the corresponding captured variable in the captured
+  /// record.
+  /// \param NativeParam Native parameter of the outlined function.
+  virtual const VarDecl *translateParameter(const FieldDecl *FD,
+const VarDecl *NativeParam) const {
+return NativeParam;
+  }
+
+  typedef llvm::function_ref
+  MappingFnType;
+  /// Maps the native argument to the address of the target-specific argument.
+  /// \param FD A field for the corresponding captured variable in the captured
+  /// record.
+  /// \param NativeParam Native parameter of the outlined function.
+  /// \param TargetParam Target-specific parameter of the outlined function
+  /// (provided by the \a CGOpenMPRuntime::translateParameter).
+  /// \param MapFn Mapping function that maps the address of the \p NativeParam
+  /// to the address of the \p TargetParam.
+  virtual void mapParameterAddress(CodeGenFunction , const FieldDecl *FD,
+   const VarDecl *NativeParam,
+   const VarDecl *TargetParam,
+   const MappingFnType MapFn) const {
+assert(NativeParam == TargetParam &&
+   "native and target args must be the same");
+  }
+
   /// Emits call of the outlined function with the provided arguments,
   /// translating these arguments to correct target-specific arguments.
   virtual void

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
URL: 

[PATCH] D36336: [X86] Add support for __builtin_cpu_init

2017-08-04 Thread Craig Topper via Phabricator via cfe-commits
craig.topper created this revision.

This adds __builtin_cpu_init which will emit a call to __cpu_indicator_init in 
libgcc or compiler-rt.

This is needed to support __builtin_cpu_supports/__builtin_cpu_is in an ifunc 
resolver.


https://reviews.llvm.org/D36336

Files:
  include/clang/Basic/BuiltinsX86.def
  lib/CodeGen/CGBuiltin.cpp
  test/CodeGen/builtin-cpu-supports.c


Index: test/CodeGen/builtin-cpu-supports.c
===
--- test/CodeGen/builtin-cpu-supports.c
+++ test/CodeGen/builtin-cpu-supports.c
@@ -5,6 +5,10 @@
 extern void a(const char *);
 
 int main() {
+  __builtin_cpu_init();
+
+  // CHECK: call void @__cpu_indicator_init
+
   if (__builtin_cpu_supports("sse4.2"))
 a("sse4.2");
 
Index: lib/CodeGen/CGBuiltin.cpp
===
--- lib/CodeGen/CGBuiltin.cpp
+++ lib/CodeGen/CGBuiltin.cpp
@@ -7289,6 +7289,13 @@
 
 Value *CodeGenFunction::EmitX86BuiltinExpr(unsigned BuiltinID,
const CallExpr *E) {
+  if (BuiltinID == X86::BI__builtin_cpu_init) {
+llvm::FunctionType *FTy = llvm::FunctionType::get(VoidTy,
+  /*Variadic*/false);
+llvm::Constant *Func = CGM.CreateRuntimeFunction(FTy, 
"__cpu_indicator_init");
+return Builder.CreateCall(Func);
+  }
+
   SmallVector Ops;
 
   // Find out if any arguments are required to be integer constant expressions.
Index: include/clang/Basic/BuiltinsX86.def
===
--- include/clang/Basic/BuiltinsX86.def
+++ include/clang/Basic/BuiltinsX86.def
@@ -32,6 +32,7 @@
 // Miscellaneous builtin for checking x86 cpu features.
 // TODO: Make this somewhat generic so that other backends
 // can use it?
+BUILTIN(__builtin_cpu_init, "v", "n")
 BUILTIN(__builtin_cpu_supports, "bcC*", "nc")
 
 // Undefined Values


Index: test/CodeGen/builtin-cpu-supports.c
===
--- test/CodeGen/builtin-cpu-supports.c
+++ test/CodeGen/builtin-cpu-supports.c
@@ -5,6 +5,10 @@
 extern void a(const char *);
 
 int main() {
+  __builtin_cpu_init();
+
+  // CHECK: call void @__cpu_indicator_init
+
   if (__builtin_cpu_supports("sse4.2"))
 a("sse4.2");
 
Index: lib/CodeGen/CGBuiltin.cpp
===
--- lib/CodeGen/CGBuiltin.cpp
+++ lib/CodeGen/CGBuiltin.cpp
@@ -7289,6 +7289,13 @@
 
 Value *CodeGenFunction::EmitX86BuiltinExpr(unsigned BuiltinID,
const CallExpr *E) {
+  if (BuiltinID == X86::BI__builtin_cpu_init) {
+llvm::FunctionType *FTy = llvm::FunctionType::get(VoidTy,
+  /*Variadic*/false);
+llvm::Constant *Func = CGM.CreateRuntimeFunction(FTy, "__cpu_indicator_init");
+return Builder.CreateCall(Func);
+  }
+
   SmallVector Ops;
 
   // Find out if any arguments are required to be integer constant expressions.
Index: include/clang/Basic/BuiltinsX86.def
===
--- include/clang/Basic/BuiltinsX86.def
+++ include/clang/Basic/BuiltinsX86.def
@@ -32,6 +32,7 @@
 // Miscellaneous builtin for checking x86 cpu features.
 // TODO: Make this somewhat generic so that other backends
 // can use it?
+BUILTIN(__builtin_cpu_init, "v", "n")
 BUILTIN(__builtin_cpu_supports, "bcC*", "nc")
 
 // Undefined Values
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r310099 - Revert "CFI: blacklist STL allocate() from unrelated-casts"

2017-08-04 Thread Vlad Tsyrklevich via cfe-commits
Author: vlad.tsyrklevich
Date: Fri Aug  4 12:17:16 2017
New Revision: 310099

URL: http://llvm.org/viewvc/llvm-project?rev=310099=rev
Log:
Revert "CFI: blacklist STL allocate() from unrelated-casts"

This reverts commit r310097.

Removed:
cfe/trunk/test/CodeGen/cfi-unrelated-cast.cpp
Modified:
cfe/trunk/lib/CodeGen/CodeGenFunction.cpp

Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?rev=310099=310098=310099=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp Fri Aug  4 12:17:16 2017
@@ -723,25 +723,6 @@ static void markAsIgnoreThreadCheckingAt
   Fn->removeFnAttr(llvm::Attribute::SanitizeThread);
 }
 
-static bool matchesStlAllocatorFn(const Decl *D, const ASTContext ) {
-  auto *MD = dyn_cast_or_null(D);
-  if (!MD || !MD->getName().equals("allocate") ||
-  (MD->getNumParams() != 1 && MD->getNumParams() != 2))
-return false;
-
-  if (MD->parameters()[0]->getType().getCanonicalType() != Ctx.getSizeType())
-return false;
-
-  if (MD->getNumParams() == 2) {
-auto *PT = MD->parameters()[1]->getType()->getAs();
-if (!PT || !PT->isVoidPointerType() ||
-!PT->getPointeeType().isConstQualified())
-  return false;
-  }
-
-  return true;
-}
-
 void CodeGenFunction::StartFunction(GlobalDecl GD,
 QualType RetTy,
 llvm::Function *Fn,
@@ -801,14 +782,6 @@ void CodeGenFunction::StartFunction(Glob
 }
   }
 
-  // Ignore unrelated casts in STL allocate() since the allocator must cast
-  // from void* to T* before object initialization completes. Don't match on 
the
-  // namespace because not all allocators are in std::
-  if (D && SanOpts.has(SanitizerKind::CFIUnrelatedCast)) {
-if (matchesStlAllocatorFn(D, getContext()))
-  SanOpts.Mask &= ~SanitizerKind::CFIUnrelatedCast;
-  }
-
   // Apply xray attributes to the function (as a string, for now)
   if (D && ShouldXRayInstrumentFunction()) {
 if (const auto *XRayAttr = D->getAttr()) {

Removed: cfe/trunk/test/CodeGen/cfi-unrelated-cast.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/cfi-unrelated-cast.cpp?rev=310098=auto
==
--- cfe/trunk/test/CodeGen/cfi-unrelated-cast.cpp (original)
+++ cfe/trunk/test/CodeGen/cfi-unrelated-cast.cpp (removed)
@@ -1,37 +0,0 @@
-// STL allocators should not have unrelated-cast tests applied
-// RUN: %clang_cc1 -flto -fvisibility hidden -fsanitize=cfi-unrelated-cast 
-emit-llvm -o - %s | FileCheck %s
-
-#include 
-
-template
-class myalloc {
- public:
-  // CHECK: define{{.*}}allocateE{{.}}
-  // CHECK-NOT: llvm.type.test
-  T *allocate(size_t sz) {
-return (T*)::operator new(sz);
-  }
-
-  // CHECK: define{{.*}}allocateE{{.}}PKv
-  // CHECK-NOT: llvm.type.test
-  T *allocate(size_t sz, const void *ptr) {
-return (T*)::operator new(sz);
-  }
-
-  // CHECK: define{{.*}}differentName
-  // CHECK: llvm.type.test
-  T *differentName(size_t sz, const void *ptr) {
-return (T*)::operator new(sz);
-  }
-};
-
-class C1 {
-  virtual void f() {}
-};
-
-C1 *f1() {
-  myalloc allocator;
-  (void)allocator.allocate(16);
-  (void)allocator.allocate(16, 0);
-  (void)allocator.differentName(16, 0);
-}


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


r310097 - CFI: blacklist STL allocate() from unrelated-casts

2017-08-04 Thread Vlad Tsyrklevich via cfe-commits
Author: vlad.tsyrklevich
Date: Fri Aug  4 12:10:11 2017
New Revision: 310097

URL: http://llvm.org/viewvc/llvm-project?rev=310097=rev
Log:
CFI: blacklist STL allocate() from unrelated-casts

Summary:
Previously, STL allocators were blacklisted in compiler_rt's
cfi_blacklist.txt because they mandated a cast from void* to T* before
object initialization completed. This change moves that logic into the
front end because C++ name mangling supports a substitution compression
mechanism for symbols that makes it difficult to blacklist the mangled
symbol for allocate() using a regular expression.

Motivated by crbug.com/751385.

Reviewers: pcc, kcc

Reviewed By: pcc

Subscribers: cfe-commits

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

Added:
cfe/trunk/test/CodeGen/cfi-unrelated-cast.cpp
Modified:
cfe/trunk/lib/CodeGen/CodeGenFunction.cpp

Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?rev=310097=310096=310097=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp Fri Aug  4 12:10:11 2017
@@ -723,6 +723,25 @@ static void markAsIgnoreThreadCheckingAt
   Fn->removeFnAttr(llvm::Attribute::SanitizeThread);
 }
 
+static bool matchesStlAllocatorFn(const Decl *D, const ASTContext ) {
+  auto *MD = dyn_cast_or_null(D);
+  if (!MD || !MD->getName().equals("allocate") ||
+  (MD->getNumParams() != 1 && MD->getNumParams() != 2))
+return false;
+
+  if (MD->parameters()[0]->getType().getCanonicalType() != Ctx.getSizeType())
+return false;
+
+  if (MD->getNumParams() == 2) {
+auto *PT = MD->parameters()[1]->getType()->getAs();
+if (!PT || !PT->isVoidPointerType() ||
+!PT->getPointeeType().isConstQualified())
+  return false;
+  }
+
+  return true;
+}
+
 void CodeGenFunction::StartFunction(GlobalDecl GD,
 QualType RetTy,
 llvm::Function *Fn,
@@ -782,6 +801,14 @@ void CodeGenFunction::StartFunction(Glob
 }
   }
 
+  // Ignore unrelated casts in STL allocate() since the allocator must cast
+  // from void* to T* before object initialization completes. Don't match on 
the
+  // namespace because not all allocators are in std::
+  if (D && SanOpts.has(SanitizerKind::CFIUnrelatedCast)) {
+if (matchesStlAllocatorFn(D, getContext()))
+  SanOpts.Mask &= ~SanitizerKind::CFIUnrelatedCast;
+  }
+
   // Apply xray attributes to the function (as a string, for now)
   if (D && ShouldXRayInstrumentFunction()) {
 if (const auto *XRayAttr = D->getAttr()) {

Added: cfe/trunk/test/CodeGen/cfi-unrelated-cast.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/cfi-unrelated-cast.cpp?rev=310097=auto
==
--- cfe/trunk/test/CodeGen/cfi-unrelated-cast.cpp (added)
+++ cfe/trunk/test/CodeGen/cfi-unrelated-cast.cpp Fri Aug  4 12:10:11 2017
@@ -0,0 +1,37 @@
+// STL allocators should not have unrelated-cast tests applied
+// RUN: %clang_cc1 -flto -fvisibility hidden -fsanitize=cfi-unrelated-cast 
-emit-llvm -o - %s | FileCheck %s
+
+#include 
+
+template
+class myalloc {
+ public:
+  // CHECK: define{{.*}}allocateE{{.}}
+  // CHECK-NOT: llvm.type.test
+  T *allocate(size_t sz) {
+return (T*)::operator new(sz);
+  }
+
+  // CHECK: define{{.*}}allocateE{{.}}PKv
+  // CHECK-NOT: llvm.type.test
+  T *allocate(size_t sz, const void *ptr) {
+return (T*)::operator new(sz);
+  }
+
+  // CHECK: define{{.*}}differentName
+  // CHECK: llvm.type.test
+  T *differentName(size_t sz, const void *ptr) {
+return (T*)::operator new(sz);
+  }
+};
+
+class C1 {
+  virtual void f() {}
+};
+
+C1 *f1() {
+  myalloc allocator;
+  (void)allocator.allocate(16);
+  (void)allocator.allocate(16, 0);
+  (void)allocator.differentName(16, 0);
+}


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


r310098 - [OPENMP] Unify generation of outlined function calls.

2017-08-04 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Fri Aug  4 12:10:54 2017
New Revision: 310098

URL: http://llvm.org/viewvc/llvm-project?rev=310098=rev
Log:
[OPENMP] Unify generation of outlined function calls.

Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h
cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
cfe/trunk/test/OpenMP/ordered_codegen.cpp

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=310098=310097=310098=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Fri Aug  4 12:10:54 2017
@@ -2447,7 +2447,7 @@ void CGOpenMPRuntime::emitParallelCall(C
 OutlinedFnArgs.push_back(ThreadIDAddr.getPointer());
 OutlinedFnArgs.push_back(ZeroAddr.getPointer());
 OutlinedFnArgs.append(CapturedVars.begin(), CapturedVars.end());
-CGF.EmitCallOrInvoke(OutlinedFn, OutlinedFnArgs);
+RT.emitOutlinedFunctionCall(CGF, OutlinedFn, OutlinedFnArgs);
 
 // __kmpc_end_serialized_parallel(, GTid);
 llvm::Value *EndArgs[] = {RT.emitUpdateLocation(CGF, Loc), ThreadID};
@@ -3859,7 +3859,7 @@ emitProxyTaskFunction(CodeGenModule 
   }
   CallArgs.push_back(SharedsParam);
 
-  CGF.EmitCallOrInvoke(TaskFunction, CallArgs);
+  CGM.getOpenMPRuntime().emitOutlinedFunctionCall(CGF, TaskFunction, CallArgs);
   CGF.EmitStoreThroughLValue(
   RValue::get(CGF.Builder.getInt32(/*C=*/0)),
   CGF.MakeAddrLValue(CGF.ReturnValue, KmpInt32Ty));
@@ -4550,7 +4550,8 @@ void CGOpenMPRuntime::emitTaskCall(CodeG
 CodeGenFunction , PrePostActionTy ) {
   Action.Enter(CGF);
   llvm::Value *OutlinedFnArgs[] = {ThreadID, NewTaskNewTaskTTy};
-  CGF.EmitCallOrInvoke(TaskEntry, OutlinedFnArgs);
+  CGF.CGM.getOpenMPRuntime().emitOutlinedFunctionCall(CGF, TaskEntry,
+  OutlinedFnArgs);
 };
 
 // Build void __kmpc_omp_task_begin_if0(ident_t *, kmp_int32 gtid,
@@ -7034,7 +7035,7 @@ void CGOpenMPRuntime::emitTargetCall(Cod
   CGF.Builder.CreateCondBr(Failed, OffloadFailedBlock, OffloadContBlock);
 
   CGF.EmitBlock(OffloadFailedBlock);
-  CGF.Builder.CreateCall(OutlinedFn, KernelArgs);
+  emitOutlinedFunctionCall(CGF, OutlinedFn, KernelArgs);
   CGF.EmitBranch(OffloadContBlock);
 
   CGF.EmitBlock(OffloadContBlock, /*IsFinished=*/true);
@@ -7754,3 +7755,14 @@ void CGOpenMPRuntime::emitDoacrossOrdere
   CGF.EmitRuntimeCall(RTLFn, Args);
 }
 
+void CGOpenMPRuntime::emitOutlinedFunctionCall(
+CodeGenFunction , llvm::Value *OutlinedFn,
+ArrayRef Args) const {
+  if (auto *Fn = dyn_cast(OutlinedFn)) {
+if (Fn->doesNotThrow()) {
+  CGF.EmitNounwindRuntimeCall(OutlinedFn, Args);
+  return;
+}
+  }
+  CGF.EmitRuntimeCall(OutlinedFn, Args);
+}

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h?rev=310098=310097=310098=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h Fri Aug  4 12:10:54 2017
@@ -1324,6 +1324,12 @@ public:
   /// \param C 'depend' clause with 'sink|source' dependency kind.
   virtual void emitDoacrossOrdered(CodeGenFunction ,
const OMPDependClause *C);
+
+  /// Emits call of the outlined function with the provided arguments,
+  /// translating these arguments to correct target-specific arguments.
+  virtual void
+  emitOutlinedFunctionCall(CodeGenFunction , llvm::Value *OutlinedFn,
+   ArrayRef Args = llvm::None) const;
 };
 
 } // namespace CodeGen

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp?rev=310098=310097=310098=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp Fri Aug  4 12:10:54 2017
@@ -345,7 +345,7 @@ void CGOpenMPRuntimeNVPTX::emitGenericEn
   Bld.CreateCondBr(IsWorker, WorkerBB, MasterCheckBB);
 
   CGF.EmitBlock(WorkerBB);
-  CGF.EmitCallOrInvoke(WST.WorkerFn, llvm::None);
+  emitOutlinedFunctionCall(CGF, WST.WorkerFn);
   CGF.EmitBranch(EST.ExitBB);
 
   CGF.EmitBlock(MasterCheckBB);
@@ -555,7 +555,7 @@ void CGOpenMPRuntimeNVPTX::emitWorkerLoo
 CGF.CreateDefaultAlignTempAlloca(CGF.Int32Ty, /*Name=*/".zero.addr");
 CGF.InitTempAlloca(ZeroAddr, CGF.Builder.getInt32(/*C=*/0));
 llvm::Value *FnArgs[] = {ZeroAddr.getPointer(), ZeroAddr.getPointer()};
-CGF.EmitCallOrInvoke(Fn, FnArgs);
+emitOutlinedFunctionCall(CGF, Fn, FnArgs);
 
 // Go to end of parallel region.
   

[PATCH] D36294: CFI: blacklist STL allocate() from unrelated-casts

2017-08-04 Thread Vlad Tsyrklevich via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL310097: CFI: blacklist STL allocate() from unrelated-casts 
(authored by vlad.tsyrklevich).

Repository:
  rL LLVM

https://reviews.llvm.org/D36294

Files:
  cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
  cfe/trunk/test/CodeGen/cfi-unrelated-cast.cpp


Index: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
===
--- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
@@ -723,6 +723,25 @@
   Fn->removeFnAttr(llvm::Attribute::SanitizeThread);
 }
 
+static bool matchesStlAllocatorFn(const Decl *D, const ASTContext ) {
+  auto *MD = dyn_cast_or_null(D);
+  if (!MD || !MD->getName().equals("allocate") ||
+  (MD->getNumParams() != 1 && MD->getNumParams() != 2))
+return false;
+
+  if (MD->parameters()[0]->getType().getCanonicalType() != Ctx.getSizeType())
+return false;
+
+  if (MD->getNumParams() == 2) {
+auto *PT = MD->parameters()[1]->getType()->getAs();
+if (!PT || !PT->isVoidPointerType() ||
+!PT->getPointeeType().isConstQualified())
+  return false;
+  }
+
+  return true;
+}
+
 void CodeGenFunction::StartFunction(GlobalDecl GD,
 QualType RetTy,
 llvm::Function *Fn,
@@ -782,6 +801,14 @@
 }
   }
 
+  // Ignore unrelated casts in STL allocate() since the allocator must cast
+  // from void* to T* before object initialization completes. Don't match on 
the
+  // namespace because not all allocators are in std::
+  if (D && SanOpts.has(SanitizerKind::CFIUnrelatedCast)) {
+if (matchesStlAllocatorFn(D, getContext()))
+  SanOpts.Mask &= ~SanitizerKind::CFIUnrelatedCast;
+  }
+
   // Apply xray attributes to the function (as a string, for now)
   if (D && ShouldXRayInstrumentFunction()) {
 if (const auto *XRayAttr = D->getAttr()) {
Index: cfe/trunk/test/CodeGen/cfi-unrelated-cast.cpp
===
--- cfe/trunk/test/CodeGen/cfi-unrelated-cast.cpp
+++ cfe/trunk/test/CodeGen/cfi-unrelated-cast.cpp
@@ -0,0 +1,37 @@
+// STL allocators should not have unrelated-cast tests applied
+// RUN: %clang_cc1 -flto -fvisibility hidden -fsanitize=cfi-unrelated-cast 
-emit-llvm -o - %s | FileCheck %s
+
+#include 
+
+template
+class myalloc {
+ public:
+  // CHECK: define{{.*}}allocateE{{.}}
+  // CHECK-NOT: llvm.type.test
+  T *allocate(size_t sz) {
+return (T*)::operator new(sz);
+  }
+
+  // CHECK: define{{.*}}allocateE{{.}}PKv
+  // CHECK-NOT: llvm.type.test
+  T *allocate(size_t sz, const void *ptr) {
+return (T*)::operator new(sz);
+  }
+
+  // CHECK: define{{.*}}differentName
+  // CHECK: llvm.type.test
+  T *differentName(size_t sz, const void *ptr) {
+return (T*)::operator new(sz);
+  }
+};
+
+class C1 {
+  virtual void f() {}
+};
+
+C1 *f1() {
+  myalloc allocator;
+  (void)allocator.allocate(16);
+  (void)allocator.allocate(16, 0);
+  (void)allocator.differentName(16, 0);
+}


Index: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
===
--- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
@@ -723,6 +723,25 @@
   Fn->removeFnAttr(llvm::Attribute::SanitizeThread);
 }
 
+static bool matchesStlAllocatorFn(const Decl *D, const ASTContext ) {
+  auto *MD = dyn_cast_or_null(D);
+  if (!MD || !MD->getName().equals("allocate") ||
+  (MD->getNumParams() != 1 && MD->getNumParams() != 2))
+return false;
+
+  if (MD->parameters()[0]->getType().getCanonicalType() != Ctx.getSizeType())
+return false;
+
+  if (MD->getNumParams() == 2) {
+auto *PT = MD->parameters()[1]->getType()->getAs();
+if (!PT || !PT->isVoidPointerType() ||
+!PT->getPointeeType().isConstQualified())
+  return false;
+  }
+
+  return true;
+}
+
 void CodeGenFunction::StartFunction(GlobalDecl GD,
 QualType RetTy,
 llvm::Function *Fn,
@@ -782,6 +801,14 @@
 }
   }
 
+  // Ignore unrelated casts in STL allocate() since the allocator must cast
+  // from void* to T* before object initialization completes. Don't match on the
+  // namespace because not all allocators are in std::
+  if (D && SanOpts.has(SanitizerKind::CFIUnrelatedCast)) {
+if (matchesStlAllocatorFn(D, getContext()))
+  SanOpts.Mask &= ~SanitizerKind::CFIUnrelatedCast;
+  }
+
   // Apply xray attributes to the function (as a string, for now)
   if (D && ShouldXRayInstrumentFunction()) {
 if (const auto *XRayAttr = D->getAttr()) {
Index: cfe/trunk/test/CodeGen/cfi-unrelated-cast.cpp
===
--- cfe/trunk/test/CodeGen/cfi-unrelated-cast.cpp
+++ cfe/trunk/test/CodeGen/cfi-unrelated-cast.cpp
@@ -0,0 +1,37 @@
+// STL allocators should not have unrelated-cast tests applied
+// RUN: 

[clang-tools-extra] r310096 - [clang-tidy] Added clang-tidy test cases related to rL310095

2017-08-04 Thread Florian Gross via cfe-commits
Author: fgross
Date: Fri Aug  4 12:01:56 2017
New Revision: 310096

URL: http://llvm.org/viewvc/llvm-project?rev=310096=rev
Log:
[clang-tidy] Added clang-tidy test cases related to rL310095

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

Modified:
clang-tools-extra/trunk/test/clang-tidy/misc-use-after-move.cpp

clang-tools-extra/trunk/test/clang-tidy/performance-inefficient-string-concatenation.cpp

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

clang-tools-extra/trunk/test/clang-tidy/readability-uniqueptr-delete-release.cpp

Modified: clang-tools-extra/trunk/test/clang-tidy/misc-use-after-move.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/misc-use-after-move.cpp?rev=310096=310095=310096=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/misc-use-after-move.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/misc-use-after-move.cpp Fri Aug  4 
12:01:56 2017
@@ -723,6 +723,11 @@ void standardContainerClearIsReinit() {
 std::move(container);
 container.clear();
 container.empty();
+
+auto container2 = container;
+std::move(container2);
+container2.clear();
+container2.empty();
   }
   {
 std::deque container;

Modified: 
clang-tools-extra/trunk/test/clang-tidy/performance-inefficient-string-concatenation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/performance-inefficient-string-concatenation.cpp?rev=310096=310095=310096=diff
==
--- 
clang-tools-extra/trunk/test/clang-tidy/performance-inefficient-string-concatenation.cpp
 (original)
+++ 
clang-tools-extra/trunk/test/clang-tidy/performance-inefficient-string-concatenation.cpp
 Fri Aug  4 12:01:56 2017
@@ -19,6 +19,8 @@ std::string g(std::string) {}
 int main() {
   std::string mystr1, mystr2;
   std::wstring mywstr1, mywstr2;
+  auto myautostr1 = mystr1;
+  auto myautostr2 = mystr2;
 
   for (int i = 0; i < 10; ++i) {
 f(mystr1 + mystr2 + mystr1);
@@ -33,6 +35,8 @@ int main() {
 // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: string concatenation
 mywstr1 = mywstr2 + mywstr2 + mywstr2;
 // CHECK-MESSAGES: :[[@LINE-1]]:33: warning: string concatenation
+myautostr1 = myautostr1 + myautostr2;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: string concatenation
 
 mywstr1 = mywstr2 + mywstr2;
 mystr1 = mystr2 + mystr2;

Modified: 
clang-tools-extra/trunk/test/clang-tidy/readability-redundant-smartptr-get.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/readability-redundant-smartptr-get.cpp?rev=310096=310095=310096=diff
==
--- 
clang-tools-extra/trunk/test/clang-tidy/readability-redundant-smartptr-get.cpp 
(original)
+++ 
clang-tools-extra/trunk/test/clang-tidy/readability-redundant-smartptr-get.cpp 
Fri Aug  4 12:01:56 2017
@@ -97,6 +97,12 @@ void Positive() {
   // CHECK-MESSAGES: int i = *ip.get();
   // CHECK-FIXES: int i = *ip;
 
+  auto ip2 = ip;
+  i = *ip2.get();
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: redundant get() call
+  // CHECK-MESSAGES: i = *ip2.get();
+  // CHECK-FIXES: i = *ip2;
+
   std::unique_ptr uu;
   std::shared_ptr *ss;
   bool bb = uu.get() == nullptr;

Modified: 
clang-tools-extra/trunk/test/clang-tidy/readability-uniqueptr-delete-release.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/readability-uniqueptr-delete-release.cpp?rev=310096=310095=310096=diff
==
--- 
clang-tools-extra/trunk/test/clang-tidy/readability-uniqueptr-delete-release.cpp
 (original)
+++ 
clang-tools-extra/trunk/test/clang-tidy/readability-uniqueptr-delete-release.cpp
 Fri Aug  4 12:01:56 2017
@@ -24,6 +24,11 @@ void Positives() {
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: prefer '= nullptr' to 'delete 
x.release()' to reset unique_ptr<> objects 
[readability-uniqueptr-delete-release]
   // CHECK-FIXES: {{^}}  P = nullptr;
 
+  auto P2 = P;
+  delete P2.release();
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: prefer '= nullptr' to 'delete 
x.release()' to reset unique_ptr<> objects 
[readability-uniqueptr-delete-release]
+  // CHECK-FIXES: {{^}}  P2 = nullptr;
+
   std::unique_ptr Array[20];
   delete Array[4].release();
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: prefer '= nullptr' to 'delete


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


[PATCH] D36308: Add handling for DeducedType to HasDeclarationMatcher

2017-08-04 Thread Florian Gross via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL310095: [ASTMatcher] Add handling for DeducedType to 
HasDeclarationMatcher (authored by fgross).

Changed prior to commit:
  https://reviews.llvm.org/D36308?vs=109795=109796#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D36308

Files:
  cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h
  cfe/trunk/unittests/ASTMatchers/ASTMatchersNodeTest.cpp


Index: cfe/trunk/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
===
--- cfe/trunk/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
+++ cfe/trunk/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
@@ -1184,6 +1184,10 @@
   EXPECT_TRUE(matches("int v[] = { 2, 3 }; void f() { for (int i : v) {} }",
   autoType()));
 
+  EXPECT_TRUE(matches("auto i = 2;", varDecl(hasType(isInteger();
+  EXPECT_TRUE(matches("struct X{}; auto x = X{};",
+  varDecl(hasType(recordDecl(hasName("X"));
+
   // FIXME: Matching against the type-as-written can't work here, because the
   //type as written was not deduced.
   //EXPECT_TRUE(matches("auto a = 1;",
Index: cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h
===
--- cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h
+++ cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h
@@ -741,24 +741,34 @@
   /// matcher matches on it.
   bool matchesSpecialized(const Type , ASTMatchFinder *Finder,
   BoundNodesTreeBuilder *Builder) const {
+
+// DeducedType does not have declarations of its own, so
+// match the deduced type instead.
+const Type *EffectiveType = 
+if (const auto *S = dyn_cast()) {
+  EffectiveType = S->getDeducedType().getTypePtrOrNull();
+  if (!EffectiveType)
+return false;
+}
+
 // First, for any types that have a declaration, extract the declaration 
and
 // match on it.
-if (const auto *S = dyn_cast()) {
+if (const auto *S = dyn_cast(EffectiveType)) {
   return matchesDecl(S->getDecl(), Finder, Builder);
 }
-if (const auto *S = dyn_cast()) {
+if (const auto *S = dyn_cast(EffectiveType)) {
   return matchesDecl(S->getDecl(), Finder, Builder);
 }
-if (const auto *S = dyn_cast()) {
+if (const auto *S = dyn_cast(EffectiveType)) {
   return matchesDecl(S->getDecl(), Finder, Builder);
 }
-if (const auto *S = dyn_cast()) {
+if (const auto *S = dyn_cast(EffectiveType)) {
   return matchesDecl(S->getDecl(), Finder, Builder);
 }
-if (const auto *S = dyn_cast()) {
+if (const auto *S = dyn_cast(EffectiveType)) {
   return matchesDecl(S->getDecl(), Finder, Builder);
 }
-if (const auto *S = dyn_cast()) {
+if (const auto *S = dyn_cast(EffectiveType)) {
   return matchesDecl(S->getInterface(), Finder, Builder);
 }
 
@@ -770,14 +780,14 @@
 //   template struct X { T t; } class A {}; X a;
 // The following matcher will match, which otherwise would not:
 //   fieldDecl(hasType(pointerType())).
-if (const auto *S = dyn_cast()) {
+if (const auto *S = dyn_cast(EffectiveType)) {
   return matchesSpecialized(S->getReplacementType(), Finder, Builder);
 }
 
 // For template specialization types, we want to match the template
 // declaration, as long as the type is still dependent, and otherwise the
 // declaration of the instantiated tag type.
-if (const auto *S = dyn_cast()) {
+if (const auto *S = dyn_cast(EffectiveType)) {
   if (!S->isTypeAlias() && S->isSugared()) {
 // If the template is non-dependent, we want to match the instantiated
 // tag type.
@@ -796,7 +806,7 @@
 // FIXME: We desugar elaborated types. This makes the assumption that users
 // do never want to match on whether a type is elaborated - there are
 // arguments for both sides; for now, continue desugaring.
-if (const auto *S = dyn_cast()) {
+if (const auto *S = dyn_cast(EffectiveType)) {
   return matchesSpecialized(S->desugar(), Finder, Builder);
 }
 return false;


Index: cfe/trunk/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
===
--- cfe/trunk/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
+++ cfe/trunk/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
@@ -1184,6 +1184,10 @@
   EXPECT_TRUE(matches("int v[] = { 2, 3 }; void f() { for (int i : v) {} }",
   autoType()));
 
+  EXPECT_TRUE(matches("auto i = 2;", varDecl(hasType(isInteger();
+  EXPECT_TRUE(matches("struct X{}; auto x = X{};",
+  varDecl(hasType(recordDecl(hasName("X"));
+
   // FIXME: Matching against the type-as-written can't work here, because the
   //type as written was not deduced.
   //EXPECT_TRUE(matches("auto a = 1;",
Index: 

r310095 - [ASTMatcher] Add handling for DeducedType to HasDeclarationMatcher

2017-08-04 Thread Florian Gross via cfe-commits
Author: fgross
Date: Fri Aug  4 11:59:19 2017
New Revision: 310095

URL: http://llvm.org/viewvc/llvm-project?rev=310095=rev
Log:
[ASTMatcher] Add handling for DeducedType to HasDeclarationMatcher

HasDeclarationMatcher did not handle DeducedType, it always returned false for 
deduced types.

So with code like this:
struct X{};
auto x = X{};

This did no longer match:
varDecl(hasType(recordDecl(hasName("X"

Because HasDeclarationMatcher didn't resolve the DeducedType of x.

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

Modified:
cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h
cfe/trunk/unittests/ASTMatchers/ASTMatchersNodeTest.cpp

Modified: cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h?rev=310095=310094=310095=diff
==
--- cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h (original)
+++ cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h Fri Aug  4 
11:59:19 2017
@@ -741,24 +741,34 @@ private:
   /// matcher matches on it.
   bool matchesSpecialized(const Type , ASTMatchFinder *Finder,
   BoundNodesTreeBuilder *Builder) const {
+
+// DeducedType does not have declarations of its own, so
+// match the deduced type instead.
+const Type *EffectiveType = 
+if (const auto *S = dyn_cast()) {
+  EffectiveType = S->getDeducedType().getTypePtrOrNull();
+  if (!EffectiveType)
+return false;
+}
+
 // First, for any types that have a declaration, extract the declaration 
and
 // match on it.
-if (const auto *S = dyn_cast()) {
+if (const auto *S = dyn_cast(EffectiveType)) {
   return matchesDecl(S->getDecl(), Finder, Builder);
 }
-if (const auto *S = dyn_cast()) {
+if (const auto *S = dyn_cast(EffectiveType)) {
   return matchesDecl(S->getDecl(), Finder, Builder);
 }
-if (const auto *S = dyn_cast()) {
+if (const auto *S = dyn_cast(EffectiveType)) {
   return matchesDecl(S->getDecl(), Finder, Builder);
 }
-if (const auto *S = dyn_cast()) {
+if (const auto *S = dyn_cast(EffectiveType)) {
   return matchesDecl(S->getDecl(), Finder, Builder);
 }
-if (const auto *S = dyn_cast()) {
+if (const auto *S = dyn_cast(EffectiveType)) {
   return matchesDecl(S->getDecl(), Finder, Builder);
 }
-if (const auto *S = dyn_cast()) {
+if (const auto *S = dyn_cast(EffectiveType)) {
   return matchesDecl(S->getInterface(), Finder, Builder);
 }
 
@@ -770,14 +780,14 @@ private:
 //   template struct X { T t; } class A {}; X a;
 // The following matcher will match, which otherwise would not:
 //   fieldDecl(hasType(pointerType())).
-if (const auto *S = dyn_cast()) {
+if (const auto *S = dyn_cast(EffectiveType)) {
   return matchesSpecialized(S->getReplacementType(), Finder, Builder);
 }
 
 // For template specialization types, we want to match the template
 // declaration, as long as the type is still dependent, and otherwise the
 // declaration of the instantiated tag type.
-if (const auto *S = dyn_cast()) {
+if (const auto *S = dyn_cast(EffectiveType)) {
   if (!S->isTypeAlias() && S->isSugared()) {
 // If the template is non-dependent, we want to match the instantiated
 // tag type.
@@ -796,7 +806,7 @@ private:
 // FIXME: We desugar elaborated types. This makes the assumption that users
 // do never want to match on whether a type is elaborated - there are
 // arguments for both sides; for now, continue desugaring.
-if (const auto *S = dyn_cast()) {
+if (const auto *S = dyn_cast(EffectiveType)) {
   return matchesSpecialized(S->desugar(), Finder, Builder);
 }
 return false;

Modified: cfe/trunk/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/ASTMatchers/ASTMatchersNodeTest.cpp?rev=310095=310094=310095=diff
==
--- cfe/trunk/unittests/ASTMatchers/ASTMatchersNodeTest.cpp (original)
+++ cfe/trunk/unittests/ASTMatchers/ASTMatchersNodeTest.cpp Fri Aug  4 11:59:19 
2017
@@ -1184,6 +1184,10 @@ TEST(TypeMatching, MatchesAutoTypes) {
   EXPECT_TRUE(matches("int v[] = { 2, 3 }; void f() { for (int i : v) {} }",
   autoType()));
 
+  EXPECT_TRUE(matches("auto i = 2;", varDecl(hasType(isInteger();
+  EXPECT_TRUE(matches("struct X{}; auto x = X{};",
+  varDecl(hasType(recordDecl(hasName("X"));
+
   // FIXME: Matching against the type-as-written can't work here, because the
   //type as written was not deduced.
   //EXPECT_TRUE(matches("auto a = 1;",


___
cfe-commits mailing list
cfe-commits@lists.llvm.org

[PATCH] D36308: Add handling for DeducedType to HasDeclarationMatcher

2017-08-04 Thread Florian Gross via Phabricator via cfe-commits
fgross updated this revision to Diff 109795.
fgross added a comment.

Changed comment, added some clang-tidy test cases.


https://reviews.llvm.org/D36308

Files:
  include/clang/ASTMatchers/ASTMatchersInternal.h
  test/clang-tidy/misc-use-after-move.cpp
  test/clang-tidy/performance-inefficient-string-concatenation.cpp
  test/clang-tidy/readability-redundant-smartptr-get.cpp
  test/clang-tidy/readability-uniqueptr-delete-release.cpp
  unittests/ASTMatchers/ASTMatchersNodeTest.cpp

Index: test/clang-tidy/readability-uniqueptr-delete-release.cpp
===
--- test/clang-tidy/readability-uniqueptr-delete-release.cpp
+++ test/clang-tidy/readability-uniqueptr-delete-release.cpp
@@ -24,6 +24,11 @@
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: prefer '= nullptr' to 'delete x.release()' to reset unique_ptr<> objects [readability-uniqueptr-delete-release]
   // CHECK-FIXES: {{^}}  P = nullptr;
 
+  auto P2 = P;
+  delete P2.release();
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: prefer '= nullptr' to 'delete x.release()' to reset unique_ptr<> objects [readability-uniqueptr-delete-release]
+  // CHECK-FIXES: {{^}}  P2 = nullptr;
+
   std::unique_ptr Array[20];
   delete Array[4].release();
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: prefer '= nullptr' to 'delete
Index: test/clang-tidy/readability-redundant-smartptr-get.cpp
===
--- test/clang-tidy/readability-redundant-smartptr-get.cpp
+++ test/clang-tidy/readability-redundant-smartptr-get.cpp
@@ -97,6 +97,12 @@
   // CHECK-MESSAGES: int i = *ip.get();
   // CHECK-FIXES: int i = *ip;
 
+  auto ip2 = ip;
+  i = *ip2.get();
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: redundant get() call
+  // CHECK-MESSAGES: i = *ip2.get();
+  // CHECK-FIXES: i = *ip2;
+
   std::unique_ptr uu;
   std::shared_ptr *ss;
   bool bb = uu.get() == nullptr;
Index: test/clang-tidy/performance-inefficient-string-concatenation.cpp
===
--- test/clang-tidy/performance-inefficient-string-concatenation.cpp
+++ test/clang-tidy/performance-inefficient-string-concatenation.cpp
@@ -19,6 +19,8 @@
 int main() {
   std::string mystr1, mystr2;
   std::wstring mywstr1, mywstr2;
+  auto myautostr1 = mystr1;
+  auto myautostr2 = mystr2;
 
   for (int i = 0; i < 10; ++i) {
 f(mystr1 + mystr2 + mystr1);
@@ -33,6 +35,8 @@
 // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: string concatenation
 mywstr1 = mywstr2 + mywstr2 + mywstr2;
 // CHECK-MESSAGES: :[[@LINE-1]]:33: warning: string concatenation
+myautostr1 = myautostr1 + myautostr2;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: string concatenation
 
 mywstr1 = mywstr2 + mywstr2;
 mystr1 = mystr2 + mystr2;
Index: test/clang-tidy/misc-use-after-move.cpp
===
--- test/clang-tidy/misc-use-after-move.cpp
+++ test/clang-tidy/misc-use-after-move.cpp
@@ -723,6 +723,11 @@
 std::move(container);
 container.clear();
 container.empty();
+
+auto container2 = container;
+std::move(container2);
+container2.clear();
+container2.empty();
   }
   {
 std::deque container;
Index: unittests/ASTMatchers/ASTMatchersNodeTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersNodeTest.cpp
+++ unittests/ASTMatchers/ASTMatchersNodeTest.cpp
@@ -1184,6 +1184,10 @@
   EXPECT_TRUE(matches("int v[] = { 2, 3 }; void f() { for (int i : v) {} }",
   autoType()));
 
+  EXPECT_TRUE(matches("auto i = 2;", varDecl(hasType(isInteger();
+  EXPECT_TRUE(matches("struct X{}; auto x = X{};",
+  varDecl(hasType(recordDecl(hasName("X"));
+
   // FIXME: Matching against the type-as-written can't work here, because the
   //type as written was not deduced.
   //EXPECT_TRUE(matches("auto a = 1;",
Index: include/clang/ASTMatchers/ASTMatchersInternal.h
===
--- include/clang/ASTMatchers/ASTMatchersInternal.h
+++ include/clang/ASTMatchers/ASTMatchersInternal.h
@@ -741,24 +741,34 @@
   /// matcher matches on it.
   bool matchesSpecialized(const Type , ASTMatchFinder *Finder,
   BoundNodesTreeBuilder *Builder) const {
+
+// DeducedType does not have declarations of its own, so
+// match the deduced type instead.
+const Type *EffectiveType = 
+if (const auto *S = dyn_cast()) {
+  EffectiveType = S->getDeducedType().getTypePtrOrNull();
+  if (!EffectiveType)
+return false;
+}
+
 // First, for any types that have a declaration, extract the declaration and
 // match on it.
-if (const auto *S = dyn_cast()) {
+if (const auto *S = dyn_cast(EffectiveType)) {
   return matchesDecl(S->getDecl(), Finder, Builder);
 }
-if (const auto *S = dyn_cast()) {

[PATCH] D35847: clang-format: Fix left pointer alignment after delctype/typeof

2017-08-04 Thread Erik Uhlmann via Phabricator via cfe-commits
euhlmann updated this revision to Diff 109785.
euhlmann added a comment.

Pulled out `getPreviousNonComment()` into local variable to avoid calling twice.


https://reviews.llvm.org/D35847

Files:
  lib/Format/TokenAnnotator.cpp
  unittests/Format/FormatTest.cpp


Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -5422,6 +5422,10 @@
   verifyFormat("for (;; *a = b) {\n}", Left);
   verifyFormat("return *this += 1;", Left);
   verifyFormat("throw *x;", Left);
+  verifyFormat("delete *x;", Left);
+  verifyFormat("typedef typeof(int(int, int))* MyFuncPtr;", Left);
+  verifyFormat("[](const decltype(*a)* ptr) {}", Left);
+  verifyFormat("typedef typeof /*comment*/ (int(int, int))* MyFuncPtr;", Left);
 
   verifyIndependentOfContext("a = *(x + y);");
   verifyIndependentOfContext("a = &(x + y);");
@@ -5468,9 +5472,6 @@
   verifyGoogleFormat("T** t = new T*;");
   verifyGoogleFormat("T** t = new T*();");
 
-  FormatStyle PointerLeft = getLLVMStyle();
-  PointerLeft.PointerAlignment = FormatStyle::PAS_Left;
-  verifyFormat("delete *x;", PointerLeft);
   verifyFormat("STATIC_ASSERT((a & b) == 0);");
   verifyFormat("STATIC_ASSERT(0 == (a & b));");
   verifyFormat("template  "
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -1397,11 +1397,15 @@
 if (NextToken->isOneOf(tok::comma, tok::semi))
   return TT_PointerOrReference;
 
-if (PrevToken->is(tok::r_paren) && PrevToken->MatchingParen &&
-PrevToken->MatchingParen->Previous &&
-PrevToken->MatchingParen->Previous->isOneOf(tok::kw_typeof,
-tok::kw_decltype))
-  return TT_PointerOrReference;
+if (PrevToken->is(tok::r_paren) && PrevToken->MatchingParen) {
+  FormatToken *TokenBeforeMatchingParen =
+PrevToken->MatchingParen->getPreviousNonComment();
+  if (TokenBeforeMatchingParen &&
+  TokenBeforeMatchingParen->isOneOf(
+tok::kw_typeof,
+tok::kw_decltype))
+return TT_PointerOrReference;
+}
 
 if (PrevToken->Tok.isLiteral() ||
 PrevToken->isOneOf(tok::r_paren, tok::r_square, tok::kw_true,
@@ -2205,15 +2209,24 @@
 Left.Previous->is(tok::kw_case));
   if (Left.is(tok::l_square) && Right.is(tok::amp))
 return false;
-  if (Right.is(TT_PointerOrReference))
-return (Left.is(tok::r_paren) && Line.MightBeFunctionDecl) ||
-   (Left.Tok.isLiteral() || (Left.is(tok::kw_const) && Left.Previous &&
+  if (Right.is(TT_PointerOrReference)) {
+if (Left.is(tok::r_paren) && Line.MightBeFunctionDecl) {
+  if (!Left.MatchingParen)
+return true;
+  FormatToken *TokenBeforeMatchingParen =
+Left.MatchingParen->getPreviousNonComment();
+  if (!TokenBeforeMatchingParen ||
+  !TokenBeforeMatchingParen->isOneOf(tok::kw_typeof, tok::kw_decltype))
+return true;
+}
+return (Left.Tok.isLiteral() || (Left.is(tok::kw_const) && Left.Previous &&
  Left.Previous->is(tok::r_paren)) ||
 (!Left.isOneOf(TT_PointerOrReference, tok::l_paren) &&
  (Style.PointerAlignment != FormatStyle::PAS_Left ||
   (Line.IsMultiVariableDeclStmt &&
(Left.NestingLevel == 0 ||
 (Left.NestingLevel == 1 && Line.First->is(tok::kw_for)));
+  }
   if (Right.is(TT_FunctionTypeLParen) && Left.isNot(tok::l_paren) &&
   (!Left.is(TT_PointerOrReference) ||
(Style.PointerAlignment != FormatStyle::PAS_Right &&


Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -5422,6 +5422,10 @@
   verifyFormat("for (;; *a = b) {\n}", Left);
   verifyFormat("return *this += 1;", Left);
   verifyFormat("throw *x;", Left);
+  verifyFormat("delete *x;", Left);
+  verifyFormat("typedef typeof(int(int, int))* MyFuncPtr;", Left);
+  verifyFormat("[](const decltype(*a)* ptr) {}", Left);
+  verifyFormat("typedef typeof /*comment*/ (int(int, int))* MyFuncPtr;", Left);
 
   verifyIndependentOfContext("a = *(x + y);");
   verifyIndependentOfContext("a = &(x + y);");
@@ -5468,9 +5472,6 @@
   verifyGoogleFormat("T** t = new T*;");
   verifyGoogleFormat("T** t = new T*();");
 
-  FormatStyle PointerLeft = getLLVMStyle();
-  PointerLeft.PointerAlignment = FormatStyle::PAS_Left;
-  verifyFormat("delete *x;", PointerLeft);
   verifyFormat("STATIC_ASSERT((a & b) == 0);");
   verifyFormat("STATIC_ASSERT(0 == (a & b));");
   verifyFormat("template  "
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ 

[PATCH] D36324: Integrate Kostya's clang-proto-fuzzer with LLVM.

2017-08-04 Thread Kostya Serebryany via Phabricator via cfe-commits
kcc added a comment.

In https://reviews.llvm.org/D36324#832271, @thakis wrote:

> Why should this be part of llvm? This seems to come with very heavy 
> dependencies (protobuf), and LLVM has historically tried to minimize the 
> number of things it depends on.


This fuzzer has already uncovered a few llvm bugs, so I hope it can be useful 
directly. 
But more than that, I hope that a ready-to-use integration with structure-aware 
fuzzing will allow other researchers to experiment. 
Having it as a side patch (bit-rotten in a few weeks after creation) will 
discourage most of the potential researchers from experiments.

I agree we don't want to bring heavy deps to LLVM, but this patch (AFAICT) 
doesn't bring any new deps to the default build. (at least this is the intent)


https://reviews.llvm.org/D36324



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


[PATCH] D36324: Integrate Kostya's clang-proto-fuzzer with LLVM.

2017-08-04 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

Why should this be part of llvm? This seems to come with very heavy 
dependencies (protobuf), and LLVM has historically tried to minimize the number 
of things it depends on.


https://reviews.llvm.org/D36324



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


[PATCH] D28691: Add OpenCL 2.0 atomic builtin functions as Clang builtin

2017-08-04 Thread Yaxun Liu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
yaxunl marked 2 inline comments as done.
Closed by commit rL310082: Add OpenCL 2.0 atomic builtin functions as Clang 
builtin (authored by yaxunl).

Changed prior to commit:
  https://reviews.llvm.org/D28691?vs=109612=109782#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D28691

Files:
  cfe/trunk/docs/LanguageExtensions.rst
  cfe/trunk/include/clang/AST/Expr.h
  cfe/trunk/include/clang/Basic/Builtins.def
  cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
  cfe/trunk/include/clang/Basic/SyncScope.h
  cfe/trunk/lib/AST/ASTContext.cpp
  cfe/trunk/lib/AST/Expr.cpp
  cfe/trunk/lib/AST/StmtPrinter.cpp
  cfe/trunk/lib/Basic/Targets/AMDGPU.cpp
  cfe/trunk/lib/CodeGen/CGAtomic.cpp
  cfe/trunk/lib/CodeGen/CGExpr.cpp
  cfe/trunk/lib/CodeGen/TargetInfo.cpp
  cfe/trunk/lib/CodeGen/TargetInfo.h
  cfe/trunk/lib/Frontend/InitPreprocessor.cpp
  cfe/trunk/lib/Headers/opencl-c.h
  cfe/trunk/lib/Sema/SemaChecking.cpp
  cfe/trunk/test/CodeGenOpenCL/atomic-ops-libcall.cl
  cfe/trunk/test/CodeGenOpenCL/atomic-ops.cl
  cfe/trunk/test/Preprocessor/init.c
  cfe/trunk/test/Preprocessor/predefined-macros.c
  cfe/trunk/test/SemaOpenCL/atomic-ops.cl

Index: cfe/trunk/lib/CodeGen/TargetInfo.h
===
--- cfe/trunk/lib/CodeGen/TargetInfo.h
+++ cfe/trunk/lib/CodeGen/TargetInfo.h
@@ -19,6 +19,7 @@
 #include "CGValue.h"
 #include "clang/AST/Type.h"
 #include "clang/Basic/LLVM.h"
+#include "clang/Basic/SyncScope.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/StringRef.h"
 
@@ -260,6 +261,10 @@
   virtual llvm::Constant *
   performAddrSpaceCast(CodeGenModule , llvm::Constant *V, unsigned SrcAddr,
unsigned DestAddr, llvm::Type *DestTy) const;
+
+  /// Get the syncscope used in LLVM IR.
+  virtual llvm::SyncScope::ID getLLVMSyncScopeID(SyncScope S,
+ llvm::LLVMContext ) const;
 };
 
 } // namespace CodeGen
Index: cfe/trunk/lib/CodeGen/TargetInfo.cpp
===
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp
@@ -444,6 +444,11 @@
   return llvm::ConstantExpr::getPointerCast(Src, DestTy);
 }
 
+llvm::SyncScope::ID
+TargetCodeGenInfo::getLLVMSyncScopeID(SyncScope S, llvm::LLVMContext ) const {
+  return C.getOrInsertSyncScopeID(""); /* default sync scope */
+}
+
 static bool isEmptyRecord(ASTContext , QualType T, bool AllowArrays);
 
 /// isEmptyField - Return true iff a the field is "empty", that is it
@@ -7430,6 +7435,8 @@
   }
   unsigned getGlobalVarAddressSpace(CodeGenModule ,
 const VarDecl *D) const override;
+  llvm::SyncScope::ID getLLVMSyncScopeID(SyncScope S,
+ llvm::LLVMContext ) const override;
 };
 }
 
@@ -7539,6 +7546,26 @@
   return DefaultGlobalAS;
 }
 
+llvm::SyncScope::ID
+AMDGPUTargetCodeGenInfo::getLLVMSyncScopeID(SyncScope S,
+llvm::LLVMContext ) const {
+  StringRef Name;
+  switch (S) {
+  case SyncScope::OpenCLWorkGroup:
+Name = "workgroup";
+break;
+  case SyncScope::OpenCLDevice:
+Name = "agent";
+break;
+  case SyncScope::OpenCLAllSVMDevices:
+Name = "";
+break;
+  case SyncScope::OpenCLSubGroup:
+Name = "subgroup";
+  }
+  return C.getOrInsertSyncScopeID(Name);
+}
+
 //===--===//
 // SPARC v8 ABI Implementation.
 // Based on the SPARC Compliance Definition version 2.4.1.
Index: cfe/trunk/lib/CodeGen/CGExpr.cpp
===
--- cfe/trunk/lib/CodeGen/CGExpr.cpp
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp
@@ -48,7 +48,7 @@
 
 llvm::Value *CodeGenFunction::EmitCastToVoidPtr(llvm::Value *value) {
   unsigned addressSpace =
-cast(value->getType())->getAddressSpace();
+  cast(value->getType())->getAddressSpace();
 
   llvm::PointerType *destType = Int8PtrTy;
   if (addressSpace)
Index: cfe/trunk/lib/CodeGen/CGAtomic.cpp
===
--- cfe/trunk/lib/CodeGen/CGAtomic.cpp
+++ cfe/trunk/lib/CodeGen/CGAtomic.cpp
@@ -15,6 +15,7 @@
 #include "CGRecordLayout.h"
 #include "CodeGenFunction.h"
 #include "CodeGenModule.h"
+#include "TargetInfo.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/CodeGen/CGFunctionInfo.h"
 #include "llvm/IR/DataLayout.h"
@@ -359,13 +360,15 @@
   Address Val1, Address Val2,
   uint64_t Size,
   llvm::AtomicOrdering SuccessOrder,
-  llvm::AtomicOrdering FailureOrder) {
+  llvm::AtomicOrdering FailureOrder,
+  llvm::SyncScope::ID Scope) {
   // Note that cmpxchg doesn't support weak cmpxchg, at least at 

r310082 - Add OpenCL 2.0 atomic builtin functions as Clang builtin

2017-08-04 Thread Yaxun Liu via cfe-commits
Author: yaxunl
Date: Fri Aug  4 11:16:31 2017
New Revision: 310082

URL: http://llvm.org/viewvc/llvm-project?rev=310082=rev
Log:
Add OpenCL 2.0 atomic builtin functions as Clang builtin

OpenCL 2.0 atomic builtin functions have a scope argument which is ideally
represented as synchronization scope argument in LLVM atomic instructions.

Clang supports translating Clang atomic builtin functions to LLVM atomic
instructions. However it currently does not support synchronization scope
of LLVM atomic instructions. Without this, users have to use LLVM assembly
code to implement OpenCL atomic builtin functions.

This patch adds OpenCL 2.0 atomic builtin functions as Clang builtin
functions, which supports generating LLVM atomic instructions with
synchronization scope operand.

Currently only constant memory scope argument is supported. Support of
non-constant memory scope argument will be added later.

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

Added:
cfe/trunk/include/clang/Basic/SyncScope.h
cfe/trunk/test/CodeGenOpenCL/atomic-ops-libcall.cl
cfe/trunk/test/CodeGenOpenCL/atomic-ops.cl
cfe/trunk/test/SemaOpenCL/atomic-ops.cl
Modified:
cfe/trunk/docs/LanguageExtensions.rst
cfe/trunk/include/clang/AST/Expr.h
cfe/trunk/include/clang/Basic/Builtins.def
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/AST/Expr.cpp
cfe/trunk/lib/AST/StmtPrinter.cpp
cfe/trunk/lib/Basic/Targets/AMDGPU.cpp
cfe/trunk/lib/CodeGen/CGAtomic.cpp
cfe/trunk/lib/CodeGen/CGExpr.cpp
cfe/trunk/lib/CodeGen/TargetInfo.cpp
cfe/trunk/lib/CodeGen/TargetInfo.h
cfe/trunk/lib/Frontend/InitPreprocessor.cpp
cfe/trunk/lib/Headers/opencl-c.h
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/test/Preprocessor/init.c
cfe/trunk/test/Preprocessor/predefined-macros.c

Modified: cfe/trunk/docs/LanguageExtensions.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/LanguageExtensions.rst?rev=310082=310081=310082=diff
==
--- cfe/trunk/docs/LanguageExtensions.rst (original)
+++ cfe/trunk/docs/LanguageExtensions.rst Fri Aug  4 11:16:31 2017
@@ -1929,7 +1929,13 @@ provided, with values corresponding to t
 ``memory_order`` enumeration.
 
 (Note that Clang additionally provides GCC-compatible ``__atomic_*``
-builtins)
+builtins and OpenCL 2.0 ``__opencl_atomic_*`` builtins. The OpenCL 2.0
+atomic builtins are an explicit form of the corresponding OpenCL 2.0
+builtin function, and are named with a ``__opencl_`` prefix. The macros
+``__OPENCL_MEMORY_SCOPE_WORK_ITEM``, ``__OPENCL_MEMORY_SCOPE_WORK_GROUP``,
+``__OPENCL_MEMORY_SCOPE_DEVICE``, ``__OPENCL_MEMORY_SCOPE_ALL_SVM_DEVICES``,
+and ``__OPENCL_MEMORY_SCOPE_SUB_GROUP`` are provided, with values
+corresponding to the enumerators of OpenCL's ``memory_scope`` enumeration.)
 
 Low-level ARM exclusive memory builtins
 ---

Modified: cfe/trunk/include/clang/AST/Expr.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=310082=310081=310082=diff
==
--- cfe/trunk/include/clang/AST/Expr.h (original)
+++ cfe/trunk/include/clang/AST/Expr.h Fri Aug  4 11:16:31 2017
@@ -5064,9 +5064,11 @@ public:
 
 /// AtomicExpr - Variadic atomic builtins: __atomic_exchange, __atomic_fetch_*,
 /// __atomic_load, __atomic_store, and __atomic_compare_exchange_*, for the
-/// similarly-named C++11 instructions, and __c11 variants for .
-/// All of these instructions take one primary pointer and at least one memory
-/// order.
+/// similarly-named C++11 instructions, and __c11 variants for ,
+/// and corresponding __opencl_atomic_* for OpenCL 2.0.
+/// All of these instructions take one primary pointer, at least one memory
+/// order, and one synchronization scope. The C++11 and __c11 atomic AtomicExpr
+/// always take the default synchronization scope.
 class AtomicExpr : public Expr {
 public:
   enum AtomicOp {
@@ -5078,7 +5080,7 @@ public:
   };
 
 private:
-  enum { PTR, ORDER, VAL1, ORDER_FAIL, VAL2, WEAK, END_EXPR };
+  enum { PTR, ORDER, SCOPE, VAL1, ORDER_FAIL, VAL2, WEAK, END_EXPR };
   Stmt* SubExprs[END_EXPR];
   unsigned NumSubExprs;
   SourceLocation BuiltinLoc, RParenLoc;
@@ -5103,8 +5105,11 @@ public:
   Expr *getOrder() const {
 return cast(SubExprs[ORDER]);
   }
+  Expr *getScope() const {
+return cast(SubExprs[SCOPE]);
+  }
   Expr *getVal1() const {
-if (Op == AO__c11_atomic_init)
+if (Op == AO__c11_atomic_init || Op == AO__opencl_atomic_init)
   return cast(SubExprs[ORDER]);
 assert(NumSubExprs > VAL1);
 return cast(SubExprs[VAL1]);
@@ -5123,6 +5128,7 @@ public:
 assert(NumSubExprs > WEAK);
 return cast(SubExprs[WEAK]);
   }
+  QualType getValueType() const;
 
   AtomicOp getOp() const { return Op; }
   unsigned getNumSubExprs() const { 

[PATCH] D35372: [clang-tidy] Refactor the code and add a close-on-exec check on memfd_create() in Android module.

2017-08-04 Thread Yan Wang via Phabricator via cfe-commits
yawanng added inline comments.



Comment at: clang-tidy/android/CloexecCheck.h:72
+  StringRef getSpellingArg(const ast_matchers::MatchFinder::MatchResult 
,
+   int n);
+

hokein wrote:
> `n` should be capital `N`. I think we can make it a const member method. And 
> I can't see any usage of this method in this patch.
It's not used in this one, but in others.


https://reviews.llvm.org/D35372



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


[PATCH] D35372: [clang-tidy] Refactor the code and add a close-on-exec check on memfd_create() in Android module.

2017-08-04 Thread Yan Wang via Phabricator via cfe-commits
yawanng updated this revision to Diff 109778.
yawanng marked 13 inline comments as done.

https://reviews.llvm.org/D35372

Files:
  clang-tidy/android/AndroidTidyModule.cpp
  clang-tidy/android/CMakeLists.txt
  clang-tidy/android/CloexecCheck.cpp
  clang-tidy/android/CloexecCheck.h
  clang-tidy/android/CloexecMemfdCreateCheck.cpp
  clang-tidy/android/CloexecMemfdCreateCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/android-cloexec-memfd-create.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/android-cloexec-memfd-create.cpp

Index: test/clang-tidy/android-cloexec-memfd-create.cpp
===
--- /dev/null
+++ test/clang-tidy/android-cloexec-memfd-create.cpp
@@ -0,0 +1,63 @@
+// RUN: %check_clang_tidy %s android-cloexec-memfd-create %t
+
+#define MFD_ALLOW_SEALING 1
+#define __O_CLOEXEC 3
+#define MFD_CLOEXEC __O_CLOEXEC
+#define TEMP_FAILURE_RETRY(exp) \
+  ({\
+int _rc;\
+do {\
+  _rc = (exp);  \
+} while (_rc == -1);\
+  })
+#define NULL 0
+
+extern "C" int memfd_create(const char *name, unsigned int flags);
+
+void a() {
+  memfd_create(NULL, MFD_ALLOW_SEALING);
+  // CHECK-MESSAGES: :[[@LINE-1]]:39: warning: 'memfd_create' should use MFD_CLOEXEC where possible [android-cloexec-memfd-create]
+  // CHECK-FIXES: memfd_create(NULL, MFD_ALLOW_SEALING | MFD_CLOEXEC)
+  TEMP_FAILURE_RETRY(memfd_create(NULL, MFD_ALLOW_SEALING));
+  // CHECK-MESSAGES: :[[@LINE-1]]:58: warning: 'memfd_create'
+  // CHECK-FIXES: TEMP_FAILURE_RETRY(memfd_create(NULL, MFD_ALLOW_SEALING | MFD_CLOEXEC))
+}
+
+void f() {
+  memfd_create(NULL, 3);
+  // CHECK-MESSAGES: :[[@LINE-1]]:23: warning: 'memfd_create'
+  // CHECK-FIXES: memfd_create(NULL, 3 | MFD_CLOEXEC)
+  TEMP_FAILURE_RETRY(memfd_create(NULL, 3));
+  // CHECK-MESSAGES: :[[@LINE-1]]:42: warning: 'memfd_create'
+  // CHECK-FIXES: TEMP_FAILURE_RETRY(memfd_create(NULL, 3 | MFD_CLOEXEC))
+
+  int flag = 3;
+  memfd_create(NULL, flag);
+  TEMP_FAILURE_RETRY(memfd_create(NULL, flag));
+}
+
+namespace i {
+int memfd_create(const char *name, unsigned int flags);
+
+void d() {
+  memfd_create(NULL, MFD_ALLOW_SEALING);
+  TEMP_FAILURE_RETRY(memfd_create(NULL, MFD_ALLOW_SEALING));
+}
+
+} // namespace i
+
+void e() {
+  memfd_create(NULL, MFD_CLOEXEC);
+  TEMP_FAILURE_RETRY(memfd_create(NULL, MFD_CLOEXEC));
+  memfd_create(NULL, MFD_ALLOW_SEALING | MFD_CLOEXEC);
+  TEMP_FAILURE_RETRY(memfd_create(NULL, MFD_ALLOW_SEALING | MFD_CLOEXEC));
+}
+
+class G {
+public:
+  int memfd_create(const char *name, unsigned int flags);
+  void d() {
+memfd_create(NULL, MFD_ALLOW_SEALING);
+TEMP_FAILURE_RETRY(memfd_create(NULL, MFD_ALLOW_SEALING));
+  }
+};
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -6,6 +6,7 @@
 .. toctree::
android-cloexec-creat
android-cloexec-fopen
+   android-cloexec-memfd-create
android-cloexec-open
android-cloexec-socket
boost-use-to-string
Index: docs/clang-tidy/checks/android-cloexec-memfd-create.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/android-cloexec-memfd-create.rst
@@ -0,0 +1,18 @@
+.. title:: clang-tidy - android-cloexec-memfd-create
+
+android-cloexec-memfd-create
+
+
+``memfd_create()`` should include ``MFD_CLOEXEC`` in its type argument to avoid
+the file descriptor leakage. Without this flag, an opened sensitive file would
+remain open across a fork+exec to a lower-privileged SELinux domain.
+
+Examples:
+
+.. code-block:: c++
+
+  memfd_create(name, MFD_ALLOW_SEALING);
+
+  // becomes
+
+  memfd_create(name, MFD_ALLOW_SEALING | MFD_CLOEXEC);
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -73,6 +73,12 @@
 
   Checks if the required mode ``e`` exists in the mode argument of ``fopen()``.
 
+- New `android-cloexec-memfd_create
+  `_ check
+
+  Checks if the required file flag ``MFD_CLOEXEC`` is present in the argument of
+  ``memfd_create()``.
+
 - New `android-cloexec-socket
   `_ check
 
Index: clang-tidy/android/CloexecMemfdCreateCheck.h
===
--- /dev/null
+++ clang-tidy/android/CloexecMemfdCreateCheck.h
@@ -0,0 +1,35 @@
+//===--- CloexecMemfdCreateCheck.h - clang-tidy-*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//

[PATCH] D36148: clang-format: [JS] support fields with case/switch/default labels.

2017-08-04 Thread Martin Probst via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL310070: clang-format: [JS] support fields with 
case/switch/default labels. (authored by mprobst).

Repository:
  rL LLVM

https://reviews.llvm.org/D36148

Files:
  cfe/trunk/lib/Format/UnwrappedLineParser.cpp
  cfe/trunk/unittests/Format/FormatTestJS.cpp


Index: cfe/trunk/lib/Format/UnwrappedLineParser.cpp
===
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp
@@ -326,6 +326,11 @@
   break;
 case tok::kw_default:
 case tok::kw_case:
+  if (Style.Language == FormatStyle::LK_JavaScript && 
Line->MustBeDeclaration) {
+// A 'case: string' style field declaration.
+parseStructuralElement();
+break;
+  }
   if (!SwitchLabelEncountered &&
   (Style.IndentCaseLabels || (Line->InPPDirective && Line->Level == 
1)))
 ++Line->Level;
@@ -953,13 +958,22 @@
 parseDoWhile();
 return;
   case tok::kw_switch:
+if (Style.Language == FormatStyle::LK_JavaScript && 
Line->MustBeDeclaration)
+  // 'switch: string' field declaration.
+  break;
 parseSwitch();
 return;
   case tok::kw_default:
+if (Style.Language == FormatStyle::LK_JavaScript && 
Line->MustBeDeclaration)
+  // 'default: string' field declaration.
+  break;
 nextToken();
 parseLabel();
 return;
   case tok::kw_case:
+if (Style.Language == FormatStyle::LK_JavaScript && 
Line->MustBeDeclaration)
+  // 'case: string' field declaration.
+  break;
 parseCaseLabel();
 return;
   case tok::kw_try:
Index: cfe/trunk/unittests/Format/FormatTestJS.cpp
===
--- cfe/trunk/unittests/Format/FormatTestJS.cpp
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp
@@ -242,6 +242,12 @@
   verifyFormat("var interface = 2;");
   verifyFormat("interface = 2;");
   verifyFormat("x = interface instanceof y;");
+  verifyFormat("interface Test {\n"
+   "  x: string;\n"
+   "  switch: string;\n"
+   "  case: string;\n"
+   "  default: string;\n"
+   "}\n");
 }
 
 TEST_F(FormatTestJS, ReservedWordsMethods) {


Index: cfe/trunk/lib/Format/UnwrappedLineParser.cpp
===
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp
@@ -326,6 +326,11 @@
   break;
 case tok::kw_default:
 case tok::kw_case:
+  if (Style.Language == FormatStyle::LK_JavaScript && Line->MustBeDeclaration) {
+// A 'case: string' style field declaration.
+parseStructuralElement();
+break;
+  }
   if (!SwitchLabelEncountered &&
   (Style.IndentCaseLabels || (Line->InPPDirective && Line->Level == 1)))
 ++Line->Level;
@@ -953,13 +958,22 @@
 parseDoWhile();
 return;
   case tok::kw_switch:
+if (Style.Language == FormatStyle::LK_JavaScript && Line->MustBeDeclaration)
+  // 'switch: string' field declaration.
+  break;
 parseSwitch();
 return;
   case tok::kw_default:
+if (Style.Language == FormatStyle::LK_JavaScript && Line->MustBeDeclaration)
+  // 'default: string' field declaration.
+  break;
 nextToken();
 parseLabel();
 return;
   case tok::kw_case:
+if (Style.Language == FormatStyle::LK_JavaScript && Line->MustBeDeclaration)
+  // 'case: string' field declaration.
+  break;
 parseCaseLabel();
 return;
   case tok::kw_try:
Index: cfe/trunk/unittests/Format/FormatTestJS.cpp
===
--- cfe/trunk/unittests/Format/FormatTestJS.cpp
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp
@@ -242,6 +242,12 @@
   verifyFormat("var interface = 2;");
   verifyFormat("interface = 2;");
   verifyFormat("x = interface instanceof y;");
+  verifyFormat("interface Test {\n"
+   "  x: string;\n"
+   "  switch: string;\n"
+   "  case: string;\n"
+   "  default: string;\n"
+   "}\n");
 }
 
 TEST_F(FormatTestJS, ReservedWordsMethods) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r310070 - clang-format: [JS] support fields with case/switch/default labels.

2017-08-04 Thread Martin Probst via cfe-commits
Author: mprobst
Date: Fri Aug  4 10:07:15 2017
New Revision: 310070

URL: http://llvm.org/viewvc/llvm-project?rev=310070=rev
Log:
clang-format: [JS] support fields with case/switch/default labels.

Summary:
`case:` and `default:` would normally parse as labels for a `switch` block.
However in TypeScript, they can be used in field declarations, e.g.:

interface I {
  case: string;
}

This change special cases parsing them in declaration lines to avoid wrapping
them.

Reviewers: djasper

Subscribers: klimek, cfe-commits

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

Modified:
cfe/trunk/lib/Format/UnwrappedLineParser.cpp
cfe/trunk/unittests/Format/FormatTestJS.cpp

Modified: cfe/trunk/lib/Format/UnwrappedLineParser.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/UnwrappedLineParser.cpp?rev=310070=310069=310070=diff
==
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp (original)
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp Fri Aug  4 10:07:15 2017
@@ -326,6 +326,11 @@ void UnwrappedLineParser::parseLevel(boo
   break;
 case tok::kw_default:
 case tok::kw_case:
+  if (Style.Language == FormatStyle::LK_JavaScript && 
Line->MustBeDeclaration) {
+// A 'case: string' style field declaration.
+parseStructuralElement();
+break;
+  }
   if (!SwitchLabelEncountered &&
   (Style.IndentCaseLabels || (Line->InPPDirective && Line->Level == 
1)))
 ++Line->Level;
@@ -953,13 +958,22 @@ void UnwrappedLineParser::parseStructura
 parseDoWhile();
 return;
   case tok::kw_switch:
+if (Style.Language == FormatStyle::LK_JavaScript && 
Line->MustBeDeclaration)
+  // 'switch: string' field declaration.
+  break;
 parseSwitch();
 return;
   case tok::kw_default:
+if (Style.Language == FormatStyle::LK_JavaScript && 
Line->MustBeDeclaration)
+  // 'default: string' field declaration.
+  break;
 nextToken();
 parseLabel();
 return;
   case tok::kw_case:
+if (Style.Language == FormatStyle::LK_JavaScript && 
Line->MustBeDeclaration)
+  // 'case: string' field declaration.
+  break;
 parseCaseLabel();
 return;
   case tok::kw_try:

Modified: cfe/trunk/unittests/Format/FormatTestJS.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJS.cpp?rev=310070=310069=310070=diff
==
--- cfe/trunk/unittests/Format/FormatTestJS.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp Fri Aug  4 10:07:15 2017
@@ -242,6 +242,12 @@ TEST_F(FormatTestJS, ReservedWords) {
   verifyFormat("var interface = 2;");
   verifyFormat("interface = 2;");
   verifyFormat("x = interface instanceof y;");
+  verifyFormat("interface Test {\n"
+   "  x: string;\n"
+   "  switch: string;\n"
+   "  case: string;\n"
+   "  default: string;\n"
+   "}\n");
 }
 
 TEST_F(FormatTestJS, ReservedWordsMethods) {


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


[PATCH] D28691: Add OpenCL 2.0 atomic builtin functions as Clang builtin

2017-08-04 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.

Still LGTM.


https://reviews.llvm.org/D28691



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


[libcxx] r310068 - Merging r309920:

2017-08-04 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Fri Aug  4 09:52:25 2017
New Revision: 310068

URL: http://llvm.org/viewvc/llvm-project?rev=310068=rev
Log:
Merging r309920:

r309920 | ericwf | 2017-08-02 21:28:10 -0700 (Wed, 02 Aug 2017) | 5 lines

Fix libcxx build with glibc 2.26+ by removing xlocale.h include.

Patch by Khem Raj. Reviewed as D35697. Also see PR33729.




Modified:
libcxx/branches/release_50/   (props changed)
libcxx/branches/release_50/include/__locale

Propchange: libcxx/branches/release_50/
--
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Aug  4 09:52:25 2017
@@ -1,2 +1,2 @@
 /libcxx/branches/apple:136569-137939
-/libcxx/trunk:309917
+/libcxx/trunk:309917,309920

Modified: libcxx/branches/release_50/include/__locale
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/branches/release_50/include/__locale?rev=310068=310067=310068=diff
==
--- libcxx/branches/release_50/include/__locale (original)
+++ libcxx/branches/release_50/include/__locale Fri Aug  4 09:52:25 2017
@@ -34,7 +34,7 @@
 # include 
 #elif defined(_NEWLIB_VERSION)
 # include 
-#elif (defined(__GLIBC__) || defined(__APPLE__)  || defined(__FreeBSD__) \
+#elif (defined(__APPLE__)  || defined(__FreeBSD__) \
 || defined(__EMSCRIPTEN__) || defined(__IBMCPP__))
 # include 
 #elif defined(__Fuchsia__)


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


[PATCH] D36327: [OpenCL] Allow targets emit optimized pipe functions for power of 2 type sizes

2017-08-04 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl created this revision.
Herald added a subscriber: tpr.

Currently Clang emits call of __read_pipe_2 or __read_pipe_4 for OpenCL 
read_pipe builtin,
with appended type size and alignment arguments, where 2 or 4 indicates the 
original
number of arguments.

For certain targets (e.g. amdgpu), there are optimized version of 
__read_pipe_2/__read_pipe_4
when the type size and alignment has the same power of 2 value. It is desired 
that Clang
emits a different function for these cases.

This patch let Clang emits __read_pipe_2_N for such cases where N is the size 
in bytes of
the type. (N = 1,2,4,8,...,128), so that the target runtime can use an 
optimized version of
read_pipe.

The same with __read_pipe_4, __write_pipe_2 and __wirte_pipe_4.

This optimization is controlled by TargetCodeGenInfo::hasOptimizedPipeBuiltin, 
which returns
false by default. Each target can override this function to turn on this 
optimization.


https://reviews.llvm.org/D36327

Files:
  lib/CodeGen/CGBuiltin.cpp
  lib/CodeGen/TargetInfo.cpp
  lib/CodeGen/TargetInfo.h
  test/CodeGenOpenCL/pipe_builtin.cl

Index: test/CodeGenOpenCL/pipe_builtin.cl
===
--- test/CodeGenOpenCL/pipe_builtin.cl
+++ test/CodeGenOpenCL/pipe_builtin.cl
@@ -1,73 +1,90 @@
-// RUN: %clang_cc1 -emit-llvm -cl-ext=+cl_khr_subgroups -O0 -cl-std=CL2.0 -o - %s | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm -cl-ext=+cl_khr_subgroups -O0 -cl-std=CL2.0 -o - %s | FileCheck -check-prefixes=CHECK,NAMD %s
+// RUN: %clang_cc1 -triple amdgcn---amdgizcl -emit-llvm -cl-ext=+cl_khr_subgroups -O0 -cl-std=CL2.0 -o - %s | FileCheck -check-prefixes=CHECK,AMD %s
 
 // CHECK: %opencl.pipe_t = type opaque
 // CHECK: %opencl.reserve_id_t = type opaque
 
 #pragma OPENCL EXTENSION cl_khr_subgroups : enable
 
+typedef struct {
+  int x[100];
+} S;
+
+typedef long long2 __attribute__((ext_vector_type(2)));
+typedef long long3 __attribute__((ext_vector_type(3)));
+typedef long long4 __attribute__((ext_vector_type(4)));
+typedef long long8 __attribute__((ext_vector_type(8)));
+typedef long long16 __attribute__((ext_vector_type(16)));
+
 void test1(read_only pipe int p, global int *ptr) {
-  // CHECK: call i32 @__read_pipe_2(%opencl.pipe_t* %{{.*}}, i8* %{{.*}}, i32 4, i32 4)
+  // NAMD: call i32 @__read_pipe_2(%opencl.pipe_t* %{{.*}}, i8* %{{.*}}, i32 4, i32 4)
+  // AMD: call i32 @__read_pipe_2_4(%opencl.pipe_t addrspace(1)* %{{.*}}, i32* %{{.*}})
   read_pipe(p, ptr);
-  // CHECK: call %opencl.reserve_id_t* @__reserve_read_pipe(%opencl.pipe_t* %{{.*}}, i32 {{.*}}, i32 4, i32 4)
+  // CHECK: call %opencl.reserve_id_t* @__reserve_read_pipe(%opencl.pipe_t{{.*}}* %{{.*}}, i32 {{.*}}, i32 4, i32 4)
   reserve_id_t rid = reserve_read_pipe(p, 2);
-  // CHECK: call i32 @__read_pipe_4(%opencl.pipe_t* %{{.*}}, %opencl.reserve_id_t* %{{.*}}, i32 {{.*}}, i8* %{{.*}}, i32 4, i32 4)
+  // NAMD: call i32 @__read_pipe_4(%opencl.pipe_t* %{{.*}}, %opencl.reserve_id_t* %{{.*}}, i32 {{.*}}, i8* %{{.*}}, i32 4, i32 4)
+  // AMD: call i32 @__read_pipe_4_4(%opencl.pipe_t addrspace(1)* %{{.*}}, %opencl.reserve_id_t* %{{.*}}, i32 {{.*}}, i32* %{{.*}})
   read_pipe(p, rid, 2, ptr);
-  // CHECK: call void @__commit_read_pipe(%opencl.pipe_t* %{{.*}}, %opencl.reserve_id_t* %{{.*}}, i32 4, i32 4)
+  // CHECK: call void @__commit_read_pipe(%opencl.pipe_t{{.*}}* %{{.*}}, %opencl.reserve_id_t{{.*}}* %{{.*}}, i32 4, i32 4)
   commit_read_pipe(p, rid);
 }
 
 void test2(write_only pipe int p, global int *ptr) {
-  // CHECK: call i32 @__write_pipe_2(%opencl.pipe_t* %{{.*}}, i8* %{{.*}}, i32 4, i32 4)
+  // NAMD: call i32 @__write_pipe_2(%opencl.pipe_t* %{{.*}}, i8* %{{.*}}, i32 4, i32 4)
+  // AMD: call i32 @__write_pipe_2_4(%opencl.pipe_t addrspace(1)* %{{.*}}, i32* %{{.*}})
   write_pipe(p, ptr);
-  // CHECK: call %opencl.reserve_id_t* @__reserve_write_pipe(%opencl.pipe_t* %{{.*}}, i32 {{.*}}, i32 4, i32 4)
+  // CHECK: call %opencl.reserve_id_t* @__reserve_write_pipe(%opencl.pipe_t{{.*}}* %{{.*}}, i32 {{.*}}, i32 4, i32 4)
   reserve_id_t rid = reserve_write_pipe(p, 2);
-  // CHECK: call i32 @__write_pipe_4(%opencl.pipe_t* %{{.*}}, %opencl.reserve_id_t* %{{.*}}, i32 {{.*}}, i8* %{{.*}}, i32 4, i32 4)
+  // NAMD: call i32 @__write_pipe_4(%opencl.pipe_t* %{{.*}}, %opencl.reserve_id_t* %{{.*}}, i32 {{.*}}, i8* %{{.*}}, i32 4, i32 4)
+  // AMD: call i32 @__write_pipe_4_4(%opencl.pipe_t addrspace(1)* %{{.*}}, %opencl.reserve_id_t* %{{.*}}, i32 {{.*}}, i32* %{{.*}})
   write_pipe(p, rid, 2, ptr);
-  // CHECK: call void @__commit_write_pipe(%opencl.pipe_t* %{{.*}}, %opencl.reserve_id_t* %{{.*}}, i32 4, i32 4)
+  // CHECK: call void @__commit_write_pipe(%opencl.pipe_t{{.*}}* %{{.*}}, %opencl.reserve_id_t* %{{.*}}, i32 4, i32 4)
   commit_write_pipe(p, rid);
 }
 
 void test3(read_only pipe int p, global int *ptr) {
-  // CHECK: call %opencl.reserve_id_t* @__work_group_reserve_read_pipe(%opencl.pipe_t* %{{.*}}, i32 {{.*}}, i32 4, i32 4)
+  // CHECK: call 

Re: r309975 - Don't emit undefined-internal warnings for CXXDeductionGuideDecls.

2017-08-04 Thread Hans Wennborg via cfe-commits
r310067. Thanks!

On Thu, Aug 3, 2017 at 12:27 PM, Richard Smith  wrote:
> Can we get this fix onto the 5.0 branch? (Just the changes to lib/ and
> test/, the changes to doc/ were accidentally committed and have been
> reverted already.)
>
> On 3 August 2017 at 12:24, Richard Smith via cfe-commits
>  wrote:
>>
>> Author: rsmith
>> Date: Thu Aug  3 12:24:27 2017
>> New Revision: 309975
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=309975=rev
>> Log:
>> Don't emit undefined-internal warnings for CXXDeductionGuideDecls.
>>
>> Patch by ~paul (cynecx on phabricator)! Some test massaging by me.
>>
>> Added:
>> cfe/trunk/docs/ModuleMaps.rst
>>   - copied, changed from r307115, cfe/trunk/docs/Modules.rst
>> cfe/trunk/docs/ModulesTS.rst
>> Modified:
>> cfe/trunk/docs/Modules.rst
>> cfe/trunk/lib/Sema/Sema.cpp
>> cfe/trunk/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D35372: [clang-tidy] Refactor the code and add a close-on-exec check on memfd_create() in Android module.

2017-08-04 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments.



Comment at: clang-tidy/android/CloexecCheck.cpp:66
+  // Check if the  may be in the mode string.
+  const auto ModeStr = dyn_cast(ModeArg->IgnoreParenCasts());
+  if (!ModeStr || (ModeStr->getString().find(Mode) != StringRef::npos))

`const auto*`



Comment at: clang-tidy/android/CloexecCheck.h:11
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ANDROID_CLOEXEC_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ANDROID_CLOEXEC_H
+#include "../ClangTidy.h"

A blank line here.



Comment at: clang-tidy/android/CloexecCheck.h:23
+class CloexecCheck : public ClangTidyCheck {
+  const static constexpr char *FuncDeclBindingStr = "funcDecl";
+  const static constexpr char *FuncBindingStr = "func";

Normally, the style should like:
```
class Foo {
public:
  ...
protected:
  ...
privated:
  ...
};
```

BTW, in C++11 these are declarations, you still need to define them in the .cc 
file like 

```
const static constexpr char* CloexecCheck::FuncDeclBindingStr;
``` 



Comment at: clang-tidy/android/CloexecCheck.h:32
+  template 
+  void registerMatchersImpl(ast_matchers::MatchFinder *Finder,
+Types... Params) {

I think this method (and below) can be `protected` member.



Comment at: clang-tidy/android/CloexecCheck.h:51
+  void insertMacroFlag(const ast_matchers::MatchFinder::MatchResult ,
+   const StringRef Flag, const int ArgPos);
+

I'd name it `MacroFlag`.



Comment at: clang-tidy/android/CloexecCheck.h:59
+  void replaceFunc(const ast_matchers::MatchFinder::MatchResult ,
+   StringRef Msg, StringRef FixMsg);
+

It is not obvious to see what these parameter mean. `Msg` is a message for 
warning, maybe `WarningMsg`? 

I'd suggest using the formal documentation for this class 
(https://llvm.org/docs/CodingStandards.html#doxygen-use-in-documentation-comments).
 



Comment at: clang-tidy/android/CloexecCheck.h:63
+  // the flag is some string rather than a macro. For example, 'fopen' needs
+  // string 'e' in its mode argument, so the fix should be:
+  //   fpen(in_file, "r");

`e` is not a string, is a char.



Comment at: clang-tidy/android/CloexecCheck.h:64
+  // string 'e' in its mode argument, so the fix should be:
+  //   fpen(in_file, "r");
+  //^~~

s/fpen/fopen.



Comment at: clang-tidy/android/CloexecCheck.h:68
+  void insertStringFlag(const ast_matchers::MatchFinder::MatchResult ,
+const StringRef Mode, const int ArgPos);
+

Is `char` for `Mode` sufficient? Seems to me that only `fopen` check is using 
it, or there will be more checks using this in the future?



Comment at: clang-tidy/android/CloexecCheck.h:72
+  StringRef getSpellingArg(const ast_matchers::MatchFinder::MatchResult 
,
+   int n);
+

`n` should be capital `N`. I think we can make it a const member method. And I 
can't see any usage of this method in this patch.



Comment at: clang-tidy/android/CloexecCheck.h:75
+  // Helper function to form the correct string mode for Type3.
+  std::string buildFixMsgForStringFlag(const Expr *Arg, const SourceManager 
,
+ const LangOptions ,

Looks like this method is used internally, do we need to expose it? or just 
define it as an anonymous function in the cc file?



Comment at: clang-tidy/android/CloexecCheck.h:79
+
+  inline ast_matchers::internal::Matcher
+  hasIntegerParameter(int N) {

The `inline` is redundant. 



Comment at: clang-tidy/android/CloexecMemfdCreateCheck.cpp:24
+void CloexecMemfdCreateCheck::check(const MatchFinder::MatchResult ) {
+  insertMacroFlag(Result, "MFD_CLOEXEC", 1);
+}

nit: add `/*ArgPos=*/` before parameter 1 to make it more readable.


https://reviews.llvm.org/D35372



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


[PATCH] D36324: Integrate Kostya's clang-proto-fuzzer with LLVM.

2017-08-04 Thread Matt Morehouse via Phabricator via cfe-commits
morehouse created this revision.
Herald added a subscriber: mgorny.

The clang-proto-fuzzer models a subset of C++ as a protobuf and
uses libprotobuf-mutator to generate interesting mutations of C++
programs.  Clang-proto-fuzzer has already found several bugs in
Clang (e.g., https://bugs.llvm.org/show_bug.cgi?id=33747,
https://bugs.llvm.org/show_bug.cgi?id=33749).

As with clang-fuzzer, clang-proto-fuzzer requires the following
cmake flags:

- CMAKE_C_COMPILER=clang
- CMAKE_CXX_COMPILER=clang++
- LLVM_USE_SANITIZE_COVERAGE=YES  // needed for libFuzzer
- LLVM_USE_SANITIZER=Address  // needed for libFuzzer

In addition, clang-proto-fuzzer requires:

- LLVM_ENABLE_RTTI=ON   // needed for protobuf
- CLANG_ENABLE_PROTO_FUZZER=ON

clang-proto-fuzzer also requires the following dependencies:

- binutils  // needed for libprotobuf-mutator
- liblzma-dev  // needed for libprotobuf-mutator
- libz-dev  // needed for libprotobuf-mutator
- docbook2x  // needed for libprotobuf-mutator
- Recent version of protobuf [3.3.0 is known to work]

A working version of libprotobuf-mutator will automatically be
downloaded and built as an external project.

Implementation of clang-proto-fuzzer provided by Kostya
Serebryany.


https://reviews.llvm.org/D36324

Files:
  clang/CMakeLists.txt
  clang/cmake/modules/ProtobufMutator.cmake
  clang/tools/clang-fuzzer/CMakeLists.txt
  clang/tools/clang-fuzzer/ClangFuzzer.cpp
  clang/tools/clang-fuzzer/ExampleClangProtoFuzzer.cpp
  clang/tools/clang-fuzzer/cxx_proto.proto
  clang/tools/clang-fuzzer/handle-cxx/CMakeLists.txt
  clang/tools/clang-fuzzer/handle-cxx/handle_cxx.cpp
  clang/tools/clang-fuzzer/handle-cxx/handle_cxx.h
  clang/tools/clang-fuzzer/proto-to-cxx/CMakeLists.txt
  clang/tools/clang-fuzzer/proto-to-cxx/proto_to_cxx.cpp
  clang/tools/clang-fuzzer/proto-to-cxx/proto_to_cxx.h
  clang/tools/clang-fuzzer/proto-to-cxx/proto_to_cxx_main.cpp

Index: clang/tools/clang-fuzzer/proto-to-cxx/proto_to_cxx_main.cpp
===
--- /dev/null
+++ clang/tools/clang-fuzzer/proto-to-cxx/proto_to_cxx_main.cpp
@@ -0,0 +1,30 @@
+//==-- proto_to_cxx_main.cpp - Driver for protobuf-C++ conversion --==//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// Implements a simple driver to print a C++ program from a protobuf.
+//
+//===--===//
+#include 
+#include 
+#include 
+#include 
+
+#include "proto_to_cxx.h"
+
+int main(int argc, char **argv) {
+  for (int i = 1; i < argc; i++) {
+std::fstream in(argv[i]);
+std::string str((std::istreambuf_iterator(in)),
+std::istreambuf_iterator());
+std::cout << "// " << argv[i] << std::endl;
+std::cout << clang_fuzzer::ProtoToCxx(
+reinterpret_cast(str.data()), str.size());
+  }
+}
+
Index: clang/tools/clang-fuzzer/proto-to-cxx/proto_to_cxx.h
===
--- /dev/null
+++ clang/tools/clang-fuzzer/proto-to-cxx/proto_to_cxx.h
@@ -0,0 +1,22 @@
+//==-- proto_to_cxx.h - Protobuf-C++ conversion ==//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// Defines functions for converting between protobufs and C++.
+//
+//===--===//
+
+#include 
+#include 
+#include 
+
+namespace clang_fuzzer {
+class Function;
+std::string FunctionToString(const Function );
+std::string ProtoToCxx(const uint8_t *data, size_t size);
+}
Index: clang/tools/clang-fuzzer/proto-to-cxx/proto_to_cxx.cpp
===
--- /dev/null
+++ clang/tools/clang-fuzzer/proto-to-cxx/proto_to_cxx.cpp
@@ -0,0 +1,97 @@
+//==-- proto_to_cxx.cpp - Protobuf-C++ conversion --==//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// Implements functions for converting between protobufs and C++.
+//
+//===--===//
+
+#include "proto_to_cxx.h"
+#include "cxx_proto.pb.h"
+
+#include 
+#include 
+
+namespace clang_fuzzer {
+
+#define P(Type) std::ostream <<(std::ostream , const Type )
+// Forward decls.
+P(BinaryOp);
+P(StatementSeq);
+
+// Proto to C++.
+P(Const) { return os << "(" << x.val() << ")"; }

[PATCH] D30748: [Lexer] Finding beginning of token with escaped new line

2017-08-04 Thread Paweł Żukowski via Phabricator via cfe-commits
idlecode updated this revision to Diff 109748.
idlecode added a comment.

Applied clang-format


https://reviews.llvm.org/D30748

Files:
  include/clang/Lex/Lexer.h
  lib/Lex/Lexer.cpp
  unittests/Lex/LexerTest.cpp

Index: unittests/Lex/LexerTest.cpp
===
--- unittests/Lex/LexerTest.cpp
+++ unittests/Lex/LexerTest.cpp
@@ -420,4 +420,57 @@
 #endif
 }
 
+TEST_F(LexerTest, IsNewLineEscapedValid) {
+  auto hasNewLineEscaped = [](const char *S) {
+return Lexer::isNewLineEscaped(S, S + strlen(S) - 1);
+  };
+
+  EXPECT_TRUE(hasNewLineEscaped("\\\r"));
+  EXPECT_TRUE(hasNewLineEscaped("\\\n"));
+  EXPECT_TRUE(hasNewLineEscaped("\\\r\n"));
+  EXPECT_TRUE(hasNewLineEscaped("\\\n\r"));
+  EXPECT_TRUE(hasNewLineEscaped("\\ \t\v\f\r"));
+  EXPECT_TRUE(hasNewLineEscaped("\\ \t\v\f\r\n"));
+
+  EXPECT_FALSE(hasNewLineEscaped("\\\r\r"));
+  EXPECT_FALSE(hasNewLineEscaped("\\\r\r\n"));
+  EXPECT_FALSE(hasNewLineEscaped("\\\n\n"));
+  EXPECT_FALSE(hasNewLineEscaped("\r"));
+  EXPECT_FALSE(hasNewLineEscaped("\n"));
+  EXPECT_FALSE(hasNewLineEscaped("\r\n"));
+  EXPECT_FALSE(hasNewLineEscaped("\n\r"));
+  EXPECT_FALSE(hasNewLineEscaped("\r\r"));
+  EXPECT_FALSE(hasNewLineEscaped("\n\n"));
+}
+
+TEST_F(LexerTest, GetBeginningOfTokenWithEscapedNewLine) {
+  // Each line should have the same length for
+  // further offset calculation to be more straightforward.
+  const unsigned IdentifierLength = 8;
+  std::string TextToLex = "rabarbar\n"
+  "foo\\\nbar\n"
+  "foo\\\rbar\n"
+  "fo\\\r\nbar\n"
+  "foo\\\n\rba\n";
+  std::vector ExpectedTokens{5, tok::identifier};
+  std::vector LexedTokens = CheckLex(TextToLex, ExpectedTokens);
+
+  for (const Token  : LexedTokens) {
+std::pair OriginalLocation =
+SourceMgr.getDecomposedLoc(Tok.getLocation());
+for (unsigned Offset = 0; Offset < IdentifierLength; ++Offset) {
+  SourceLocation LookupLocation =
+  Tok.getLocation().getLocWithOffset(Offset);
+
+  std::pair FoundLocation =
+  SourceMgr.getDecomposedExpansionLoc(
+  Lexer::GetBeginningOfToken(LookupLocation, SourceMgr, LangOpts));
+
+  // Check that location returned by the GetBeginningOfToken
+  // is the same as original token location reported by Lexer.
+  EXPECT_EQ(FoundLocation.second, OriginalLocation.second);
+}
+  }
+}
+
 } // anonymous namespace
Index: lib/Lex/Lexer.cpp
===
--- lib/Lex/Lexer.cpp
+++ lib/Lex/Lexer.cpp
@@ -463,19 +463,18 @@
   const char *BufStart = Buffer.data();
   if (Offset >= Buffer.size())
 return nullptr;
-  const char *StrData = BufStart + Offset;
 
-  if (StrData[0] == '\n' || StrData[0] == '\r')
-return StrData;
+  const char *LexStart = BufStart + Offset;
+  for (; LexStart != BufStart; --LexStart) {
+if (!isVerticalWhitespace(LexStart[0]))
+  continue;
 
-  const char *LexStart = StrData;
-  while (LexStart != BufStart) {
-if (LexStart[0] == '\n' || LexStart[0] == '\r') {
-  ++LexStart;
-  break;
-}
+if (Lexer::isNewLineEscaped(BufStart, LexStart))
+  continue;
 
---LexStart;
+// LexStart should point at first character of logical line.
+++LexStart;
+break;
   }
   return LexStart;
 }
@@ -487,7 +486,7 @@
   std::pair LocInfo = SM.getDecomposedLoc(Loc);
   if (LocInfo.first.isInvalid())
 return Loc;
-  
+
   bool Invalid = false;
   StringRef Buffer = SM.getBufferData(LocInfo.first, );
   if (Invalid)
@@ -499,52 +498,52 @@
   const char *LexStart = findBeginningOfLine(Buffer, LocInfo.second);
   if (!LexStart || LexStart == StrData)
 return Loc;
-  
+
   // Create a lexer starting at the beginning of this token.
   SourceLocation LexerStartLoc = Loc.getLocWithOffset(-LocInfo.second);
   Lexer TheLexer(LexerStartLoc, LangOpts, Buffer.data(), LexStart,
  Buffer.end());
   TheLexer.SetCommentRetentionState(true);
-  
+
   // Lex tokens until we find the token that contains the source location.
   Token TheTok;
   do {
 TheLexer.LexFromRawLexer(TheTok);
-
+
 if (TheLexer.getBufferLocation() > StrData) {
   // Lexing this token has taken the lexer past the source location we're
   // looking for. If the current token encompasses our source location,
   // return the beginning of that token.
   if (TheLexer.getBufferLocation() - TheTok.getLength() <= StrData)
 return TheTok.getLocation();
-  
+
   // We ended up skipping over the source location entirely, which means
   // that it points into whitespace. We're done here.
   break;
 }
   } while (TheTok.getKind() != tok::eof);
-  
+
   // We've passed our source location; just return the original source location.
   return Loc;
 }
 
 SourceLocation 

[PATCH] D28691: Add OpenCL 2.0 atomic builtin functions as Clang builtin

2017-08-04 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl marked 3 inline comments as done.
yaxunl added a comment.

Ping. Any other comments? Thanks.




Comment at: lib/AST/Expr.cpp:4000-4004
+  if (auto AT = T->getAs()) {
+return AT->getValueType();
+  } else {
+return T;
+  }

bader wrote:
> No need in else branch after return:
> ```
> if (...) {
>   return AT->getValueType();
> }
> 
> return T;
> ```
> 
> http://llvm.org/docs/CodingStandards.html#don-t-use-else-after-a-return
will fix when committing.



Comment at: test/SemaOpenCL/atomic-ops.cl:1
+// RUN: %clang_cc1 %s -cl-std=CL2.0 -finclude-default-header -verify 
-fsyntax-only -triple=spir64
+// RUN: %clang_cc1 %s -cl-std=CL2.0 -finclude-default-header -verify 
-fsyntax-only -triple=amdgcn-amdhsa-amd-opencl

bader wrote:
> It's a pity, we have to parse the whole opencl-c.h file to get two enums and 
> one typedef...
Since there is change in opencl-c.h, using the header can test that.


https://reviews.llvm.org/D28691



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


[PATCH] D36315: [mips] Support implicit gpopt with N64 when using -fno-pic

2017-08-04 Thread Simon Dardis via Phabricator via cfe-commits
sdardis created this revision.
Herald added a subscriber: arichardson.

As clang defaults to -mno-abicalls when using -fno-pic for N64, implicitly use 
-mgpopt in that case.


https://reviews.llvm.org/D36315

Files:
  lib/Driver/ToolChains/Clang.cpp
  test/Driver/mips-features.c


Index: test/Driver/mips-features.c
===
--- test/Driver/mips-features.c
+++ test/Driver/mips-features.c
@@ -80,6 +80,24 @@
 // RUN:   | FileCheck --check-prefix=CHECK-MEMBEDDEDDATADEF %s
 // CHECK-MEMBEDDEDDATADEF-NOT: "-mllvm" "-membedded-data"
 //
+// MIPS64 + N64: -fno-pic -> -mno-abicalls -mgpopt
+// RUN: %clang -target mips64-mti-elf -mabi=64 -### -c %s -fno-pic 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-N64-GPOPT %s
+// CHECK-N64-GPOPT: "-target-feature" "+noabicalls"
+// CHECK-N64-GPOPT: "-mllvm" "-mgpopt"
+//
+// MIPS64 + N64: -fno-pic -mno-gpopt
+// RUN: %clang -target mips64-mti-elf -mabi=64 -### -c %s -fno-pic -mno-gpopt 
2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-N64-MNO-GPOPT %s
+// CHECK-N64-MNO-GPOPT: "-target-feature" "+noabicalls"
+// CHECK-N64-MNO-GPOPT-NOT: "-mllvm" "-mgpopt"
+//
+// MIPS64 + N64: -mgpopt (-fpic is implicit)
+// RUN: %clang -target mips64-mti-linux-gnu -mabi=64 -### -c %s -mgpopt 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-N64-PIC-GPOPT %s
+// CHECK-N64-PIC-GPOPT-NOT: "-mllvm" "-mgpopt"
+// CHECK-N64-PIC-GPOPT: ignoring '-mgpopt' option as it cannot be used with 
the implicit usage of -mabicalls
+//
 // -mips16
 // RUN: %clang -target mips-linux-gnu -### -c %s \
 // RUN: -mno-mips16 -mips16 2>&1 \
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -1473,8 +1473,21 @@
   // NOTE: We need a warning here or in the backend to warn when -mgpopt is
   //   passed explicitly when compiling something with -mabicalls
   //   (implictly) in affect. Currently the warning is in the backend.
+  //
+  // When the ABI in use is  N64, we also need to determine the PIC mode that
+  // is in use, as -fno-pic for N64 implies -mno-abicalls.
   bool NoABICalls =
   ABICalls && ABICalls->getOption().matches(options::OPT_mno_abicalls);
+
+  llvm::Reloc::Model RelocationModel;
+  unsigned PICLevel;
+  bool IsPIE;
+  std::tie(RelocationModel, PICLevel, IsPIE) =
+  ParsePICArgs(getToolChain(), Args);
+
+  NoABICalls = NoABICalls ||
+   (RelocationModel == llvm::Reloc::Static && ABIName == "n64");
+
   bool WantGPOpt = GPOpt && GPOpt->getOption().matches(options::OPT_mgpopt);
   // We quietly ignore -mno-gpopt as the backend defaults to -mno-gpopt.
   if (NoABICalls && (!GPOpt || WantGPOpt)) {


Index: test/Driver/mips-features.c
===
--- test/Driver/mips-features.c
+++ test/Driver/mips-features.c
@@ -80,6 +80,24 @@
 // RUN:   | FileCheck --check-prefix=CHECK-MEMBEDDEDDATADEF %s
 // CHECK-MEMBEDDEDDATADEF-NOT: "-mllvm" "-membedded-data"
 //
+// MIPS64 + N64: -fno-pic -> -mno-abicalls -mgpopt
+// RUN: %clang -target mips64-mti-elf -mabi=64 -### -c %s -fno-pic 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-N64-GPOPT %s
+// CHECK-N64-GPOPT: "-target-feature" "+noabicalls"
+// CHECK-N64-GPOPT: "-mllvm" "-mgpopt"
+//
+// MIPS64 + N64: -fno-pic -mno-gpopt
+// RUN: %clang -target mips64-mti-elf -mabi=64 -### -c %s -fno-pic -mno-gpopt 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-N64-MNO-GPOPT %s
+// CHECK-N64-MNO-GPOPT: "-target-feature" "+noabicalls"
+// CHECK-N64-MNO-GPOPT-NOT: "-mllvm" "-mgpopt"
+//
+// MIPS64 + N64: -mgpopt (-fpic is implicit)
+// RUN: %clang -target mips64-mti-linux-gnu -mabi=64 -### -c %s -mgpopt 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-N64-PIC-GPOPT %s
+// CHECK-N64-PIC-GPOPT-NOT: "-mllvm" "-mgpopt"
+// CHECK-N64-PIC-GPOPT: ignoring '-mgpopt' option as it cannot be used with the implicit usage of -mabicalls
+//
 // -mips16
 // RUN: %clang -target mips-linux-gnu -### -c %s \
 // RUN: -mno-mips16 -mips16 2>&1 \
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -1473,8 +1473,21 @@
   // NOTE: We need a warning here or in the backend to warn when -mgpopt is
   //   passed explicitly when compiling something with -mabicalls
   //   (implictly) in affect. Currently the warning is in the backend.
+  //
+  // When the ABI in use is  N64, we also need to determine the PIC mode that
+  // is in use, as -fno-pic for N64 implies -mno-abicalls.
   bool NoABICalls =
   ABICalls && ABICalls->getOption().matches(options::OPT_mno_abicalls);
+
+  llvm::Reloc::Model RelocationModel;
+  unsigned PICLevel;
+  bool IsPIE;
+  std::tie(RelocationModel, PICLevel, IsPIE) =
+  ParsePICArgs(getToolChain(), Args);
+
+  NoABICalls = NoABICalls ||
+

[PATCH] D28691: Add OpenCL 2.0 atomic builtin functions as Clang builtin

2017-08-04 Thread Alexey Bader via Phabricator via cfe-commits
bader accepted this revision.
bader added inline comments.



Comment at: lib/AST/Expr.cpp:4000-4004
+  if (auto AT = T->getAs()) {
+return AT->getValueType();
+  } else {
+return T;
+  }

No need in else branch after return:
```
if (...) {
  return AT->getValueType();
}

return T;
```

http://llvm.org/docs/CodingStandards.html#don-t-use-else-after-a-return



Comment at: test/SemaOpenCL/atomic-ops.cl:1
+// RUN: %clang_cc1 %s -cl-std=CL2.0 -finclude-default-header -verify 
-fsyntax-only -triple=spir64
+// RUN: %clang_cc1 %s -cl-std=CL2.0 -finclude-default-header -verify 
-fsyntax-only -triple=amdgcn-amdhsa-amd-opencl

It's a pity, we have to parse the whole opencl-c.h file to get two enums and 
one typedef...


https://reviews.llvm.org/D28691



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


[PATCH] D30748: [Lexer] Finding beginning of token with escaped new line

2017-08-04 Thread Paweł Żukowski via Phabricator via cfe-commits
idlecode updated this revision to Diff 109740.
idlecode marked an inline comment as done.

https://reviews.llvm.org/D30748

Files:
  include/clang/Lex/Lexer.h
  lib/Lex/Lexer.cpp
  unittests/Lex/LexerTest.cpp

Index: unittests/Lex/LexerTest.cpp
===
--- unittests/Lex/LexerTest.cpp
+++ unittests/Lex/LexerTest.cpp
@@ -420,4 +420,57 @@
 #endif
 }
 
+TEST_F(LexerTest, IsNewLineEscapedValid) {
+  auto hasNewLineEscaped = [] (const char *S) {
+return Lexer::isNewLineEscaped(S, S + strlen(S) - 1);
+  };
+
+  EXPECT_TRUE(hasNewLineEscaped("\\\r"));
+  EXPECT_TRUE(hasNewLineEscaped("\\\n"));
+  EXPECT_TRUE(hasNewLineEscaped("\\\r\n"));
+  EXPECT_TRUE(hasNewLineEscaped("\\\n\r"));
+  EXPECT_TRUE(hasNewLineEscaped("\\ \t\v\f\r"));
+  EXPECT_TRUE(hasNewLineEscaped("\\ \t\v\f\r\n"));
+
+  EXPECT_FALSE(hasNewLineEscaped("\\\r\r"));
+  EXPECT_FALSE(hasNewLineEscaped("\\\r\r\n"));
+  EXPECT_FALSE(hasNewLineEscaped("\\\n\n"));
+  EXPECT_FALSE(hasNewLineEscaped("\r"));
+  EXPECT_FALSE(hasNewLineEscaped("\n"));
+  EXPECT_FALSE(hasNewLineEscaped("\r\n"));
+  EXPECT_FALSE(hasNewLineEscaped("\n\r"));
+  EXPECT_FALSE(hasNewLineEscaped("\r\r"));
+  EXPECT_FALSE(hasNewLineEscaped("\n\n"));
+}
+
+TEST_F(LexerTest, GetBeginningOfTokenWithEscapedNewLine) {
+  // Each line should have the same length for
+  // further offset calculation to be more straightforward.
+  const unsigned IdentifierLength = 8;
+  std::string TextToLex = "rabarbar\n"
+  "foo\\\nbar\n"
+  "foo\\\rbar\n"
+  "fo\\\r\nbar\n"
+  "foo\\\n\rba\n";
+  std::vector ExpectedTokens{5, tok::identifier};
+  std::vector LexedTokens = CheckLex(TextToLex, ExpectedTokens);
+
+  for (const Token  : LexedTokens) {
+std::pair OriginalLocation =
+SourceMgr.getDecomposedLoc(Tok.getLocation());
+for (unsigned Offset = 0; Offset < IdentifierLength; ++Offset) {
+  SourceLocation LookupLocation =
+  Tok.getLocation().getLocWithOffset(Offset);
+
+  std::pair FoundLocation =
+  SourceMgr.getDecomposedExpansionLoc(
+  Lexer::GetBeginningOfToken(LookupLocation, SourceMgr, LangOpts));
+
+  // Check that location returned by the GetBeginningOfToken
+  // is the same as original token location reported by Lexer.
+  EXPECT_EQ(FoundLocation.second, OriginalLocation.second);
+}
+  }
+}
+
 } // anonymous namespace
Index: lib/Lex/Lexer.cpp
===
--- lib/Lex/Lexer.cpp
+++ lib/Lex/Lexer.cpp
@@ -463,19 +463,18 @@
   const char *BufStart = Buffer.data();
   if (Offset >= Buffer.size())
 return nullptr;
-  const char *StrData = BufStart + Offset;
 
-  if (StrData[0] == '\n' || StrData[0] == '\r')
-return StrData;
+  const char *LexStart = BufStart + Offset;
+  for (; LexStart != BufStart; --LexStart) {
+if (!isVerticalWhitespace(LexStart[0]))
+  continue;
 
-  const char *LexStart = StrData;
-  while (LexStart != BufStart) {
-if (LexStart[0] == '\n' || LexStart[0] == '\r') {
-  ++LexStart;
-  break;
-}
+if (Lexer::isNewLineEscaped(BufStart, LexStart))
+  continue;
 
---LexStart;
+// LexStart should point at first character of logical line.
+++LexStart;
+break;
   }
   return LexStart;
 }
@@ -487,7 +486,7 @@
   std::pair LocInfo = SM.getDecomposedLoc(Loc);
   if (LocInfo.first.isInvalid())
 return Loc;
-  
+
   bool Invalid = false;
   StringRef Buffer = SM.getBufferData(LocInfo.first, );
   if (Invalid)
@@ -499,52 +498,52 @@
   const char *LexStart = findBeginningOfLine(Buffer, LocInfo.second);
   if (!LexStart || LexStart == StrData)
 return Loc;
-  
+
   // Create a lexer starting at the beginning of this token.
   SourceLocation LexerStartLoc = Loc.getLocWithOffset(-LocInfo.second);
   Lexer TheLexer(LexerStartLoc, LangOpts, Buffer.data(), LexStart,
  Buffer.end());
   TheLexer.SetCommentRetentionState(true);
-  
+
   // Lex tokens until we find the token that contains the source location.
   Token TheTok;
   do {
 TheLexer.LexFromRawLexer(TheTok);
-
+
 if (TheLexer.getBufferLocation() > StrData) {
   // Lexing this token has taken the lexer past the source location we're
   // looking for. If the current token encompasses our source location,
   // return the beginning of that token.
   if (TheLexer.getBufferLocation() - TheTok.getLength() <= StrData)
 return TheTok.getLocation();
-  
+
   // We ended up skipping over the source location entirely, which means
   // that it points into whitespace. We're done here.
   break;
 }
   } while (TheTok.getKind() != tok::eof);
-  
+
   // We've passed our source location; just return the original source location.
   return Loc;
 }
 
 SourceLocation 

[PATCH] D30748: [Lexer] Finding beginning of token with escaped new line

2017-08-04 Thread Paweł Żukowski via Phabricator via cfe-commits
idlecode marked 3 inline comments as done.
idlecode added inline comments.



Comment at: lib/Lex/Lexer.cpp:460
+/// \brief Check if new line pointed by Str is escaped.
+bool isNewLineEscaped(const char *BufferStart, const char *Str) {
+  assert(isVerticalWhitespace(Str[0]));

alexfh wrote:
> The way the function is exposed to the test may lead to confusion. I'd either 
> properly declare it in the header (and place it in a namespace, if it is not 
> yet) or at least leave a comment here that the function is not static, since 
> it needs to be exposed to the test.
Ok, I have made `isNewLineEscaped` a static method of `Lexer` - in Lexer.h 
there were no global function declaration and I didn't like the idea of 
introducing one.
I would make it protected/private member but it have to be visible to unit 
tests (and introducing friend classes just for this method doesn't seem worth 
it).


https://reviews.llvm.org/D30748



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


RE: r308619 - Reland "[mips] Teach the driver to accept -m(no-)gpopt."

2017-08-04 Thread Simon Dardis via cfe-commits


> -Original Message-
> From: Simon Atanasyan [mailto:si...@atanasyan.com]
> Sent: 04 August 2017 11:29
> To: Simon Dardis
> Cc: Clang Commits
> Subject: Re: r308619 - Reland "[mips] Teach the driver to accept -m(no-
> )gpopt."
> 
> On Thu, Jul 20, 2017 at 5:04 PM, Simon Dardis via cfe-commits  comm...@lists.llvm.org> wrote:
> > Reland "[mips] Teach the driver to accept -m(no-)gpopt."
> >
> > This patch teaches the driver to pass -mgpopt by default to the
> > backend when it is supported, i.e. we are using -mno-abicalls.
> 
> [...]
> 
> > Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
> > URL:
> > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Cl
> > ang.cpp?rev=308619=308618=308619=diff
> >
> ==
> 
> > 
> > --- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
> > +++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Thu Jul 20 07:04:12 2017
> > @@ -1462,6 +1462,30 @@ void Clang::AddMIPSTargetArgs(const ArgL
> >  A->claim();
> >}
> >
> > +  Arg *GPOpt = Args.getLastArg(options::OPT_mgpopt,
> > + options::OPT_mno_gpopt);  Arg *ABICalls =
> > +  Args.getLastArg(options::OPT_mabicalls,
> > + options::OPT_mno_abicalls);
> > +
> > +  // -mabicalls is the default for many MIPS environments, even with -fno-
> pic.
> > +  // -mgpopt is the default for static, -fno-pic environments but
> > + these two  // options conflict. We want to be certain that
> > + -mno-abicalls -mgpopt is  // the only case where -mllvm -mgpopt is
> passed.
> > +  // NOTE: We need a warning here or in the backend to warn when -
> mgpopt is
> > +  //   passed explicitly when compiling something with -mabicalls
> > +  //   (implictly) in affect. Currently the warning is in the backend.
> > +  bool NoABICalls =
> > +  ABICalls &&
> > + ABICalls->getOption().matches(options::OPT_mno_abicalls);
> 
> What about N64 ABI + non-PIC code? In that case we pass the `+noabicalls`
> feature flag to the backend by default regardless of -mabicalls / -mnoabicalls
> options. Should we assign `true` to the NoABICalls in that case too to be
> consistent?

Yes, I think we should. I'll write a patch for this.

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


[PATCH] D36191: [CodeGen] Don't make availability attributes imply default visibility on macos

2017-08-04 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

Is landing this blocked on internal testing?


https://reviews.llvm.org/D36191



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


[PATCH] D36238: Use "foo-12345.o" instead of "foo.o-12345" as temporary file name.

2017-08-04 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

Hm, that's unfortunate. I don't see a good way to rescue this patch.

We could keep the lhs of this and always append ".tmp", then tools at least had 
a way of filtering out the temp files. Hm.


https://reviews.llvm.org/D36238



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


[PATCH] D35355: Fix templated type alias completion when using global completion cache

2017-08-04 Thread Ivan Donchevskii via Phabricator via cfe-commits
yvvan added a comment.

In https://reviews.llvm.org/D35355#831845, @klimek wrote:

> Sorry for missing this - can you add a test?


I think I can :)
Will add it next week.


https://reviews.llvm.org/D35355



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


Re: r310030 - Revert r309984, "Use "foo-12345.o" instead of "foo.o-12345" as temporary file name."

2017-08-04 Thread Nico Weber via cfe-commits
Takumi provides some more details on IRC: The change broke
http://bb.pgr.jp/builders/bootstrap-clang-libcxx-lld-i686-linux/builds/655/steps/build_stage2/logs/stdio
, which uses modules.  He says there's a race-condition: while clang emits
***-{tmp}.pcm, another clang collects *.pcm for the module index.
GlobalModuleIndex.cpp walks over a directory here and ignores everything
not ending in '.pcm' here:
http://llvm-cs.pcc.me.uk/tools/clang/lib/Serialization/GlobalModuleIndex.cpp#850

That seems pretty gross, but I can't think of a non-gross way to make this
patch work with that pcm walking.

We could always append ".tmp" to the temp file names, but then the original
benefit is gone too.

We could do this patch only for .obj files, or always except for .pcm
files, but that seems both kind of gross as well.

On Fri, Aug 4, 2017 at 2:35 AM, NAKAMURA Takumi via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: chapuni
> Date: Thu Aug  3 23:35:32 2017
> New Revision: 310030
>
> URL: http://llvm.org/viewvc/llvm-project?rev=310030=rev
> Log:
> Revert r309984, "Use "foo-12345.o" instead of "foo.o-12345" as temporary
> file name."
>
> It generates MODULE--.pcm, then GlobalModuleIndex.cpp
> is confused with the suffix ".pcm"
>
> Modified:
> cfe/trunk/lib/Frontend/CompilerInstance.cpp
>
> Modified: cfe/trunk/lib/Frontend/CompilerInstance.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/
> Frontend/CompilerInstance.cpp?rev=310030=310029=310030=diff
> 
> ==
> --- cfe/trunk/lib/Frontend/CompilerInstance.cpp (original)
> +++ cfe/trunk/lib/Frontend/CompilerInstance.cpp Thu Aug  3 23:35:32 2017
> @@ -759,13 +759,9 @@ std::unique_ptr
>
>if (UseTemporary) {
>  // Create a temporary file.
> -// Insert - before the extension (if any), so that tools doing
> -// things based on the file extension do the right thing.
> -StringRef OutputExtension = llvm::sys::path::extension(OutFile);
> -SmallString<128> TempPath =
> -StringRef(OutFile).drop_back(OutputExtension.size());
> +SmallString<128> TempPath;
> +TempPath = OutFile;
>  TempPath += "-";
> -TempPath += OutputExtension;
>  int fd;
>  std::error_code EC =
>  llvm::sys::fs::createUniqueFile(TempPath, fd, TempPath);
>
>
> ___
> 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] D35355: Fix templated type alias completion when using global completion cache

2017-08-04 Thread Manuel Klimek via Phabricator via cfe-commits
klimek added a comment.

Sorry for missing this - can you add a test?


https://reviews.llvm.org/D35355



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


[PATCH] D36308: Add handling for DeducedType to HasDeclarationMatcher

2017-08-04 Thread Manuel Klimek via Phabricator via cfe-commits
klimek accepted this revision.
klimek added a comment.
This revision is now accepted and ready to land.

Thanks! LG after comment change.

Also, should we add some tests to clang-tidy? :)




Comment at: include/clang/ASTMatchers/ASTMatchersInternal.h:745
+
+// For deduced types, use the deduced type
+const Type *EffectiveType = 

I think the behavior doesn't need a comment, but the reason :)

  // DeducedType dos not have declarations of its own, so
  // match the deduced type instead.


https://reviews.llvm.org/D36308



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


[PATCH] D28691: Add OpenCL 2.0 atomic builtin functions as Clang builtin

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



Comment at: include/clang/Basic/SyncScope.h:21
+/// \brief Defines the synch scope values used by the atomic builtins and
+/// expressions
+enum class SyncScope {

rjmccall wrote:
> If the numeric values here were chosen to align with the arguments to some 
> runtime function, that's important to leave as a comment.
I have added the comments and updated the review.. On the Phabricator web page, 
it may take a bit effort to find it since it is interleaved with reviewers' 
comments.


https://reviews.llvm.org/D28691



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


[PATCH] D36150: [clangd] LSP extension to switch between source/header file

2017-08-04 Thread Marc-Andre Laperle via Phabricator via cfe-commits
malaperle added inline comments.



Comment at: clangd/ProtocolHandlers.cpp:260
+  Dispatcher.registerHandler(
+  "textDocument/switchSourceHeader",
+  llvm::make_unique(Out, Callbacks));

ilya-biryukov wrote:
> ilya-biryukov wrote:
> > I don't see this method in the [[ 
> > https://github.com/Microsoft/language-server-protocol/blob/master/protocol.md
> >  | LSP spec ]].
> > Is this some kind of extension?
> > 
> > Could you add some comments on that with pointers to proposal/explanation 
> > of where this extension is used?
> This comment was not addressed, probably marked as 'Done' by accident.
> Is this some kind of extension?

It's briefly mentioned in the summary but could use some more detail.
The first client to use it is Theia but I wonder if it would be easy to add it 
to the VS Code extension, as an example.


https://reviews.llvm.org/D36150



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


r310057 - Revert r304953 for release 5.0.0

2017-08-04 Thread Stefan Maksimovic via cfe-commits
Author: smaksimovic
Date: Fri Aug  4 05:37:34 2017
New Revision: 310057

URL: http://llvm.org/viewvc/llvm-project?rev=310057=rev
Log:
Revert r304953 for release 5.0.0

This is causing failures when compiling clang with -O3
as one of the structures used by clang is passed by
value and uses the fastcc calling convention.

Faliures manifest for stage2 mips build.

Removed:
cfe/trunk/test/CodeGen/mips-madd4.c
Modified:
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/lib/Basic/Targets/Mips.cpp
cfe/trunk/lib/Basic/Targets/Mips.h
cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp
cfe/trunk/test/Preprocessor/init.c

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=310057=310056=310057=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Fri Aug  4 05:37:34 2017
@@ -2019,10 +2019,6 @@ def mdspr2 : Flag<["-"], "mdspr2">, Grou
 def mno_dspr2 : Flag<["-"], "mno-dspr2">, Group;
 def msingle_float : Flag<["-"], "msingle-float">, Group;
 def mdouble_float : Flag<["-"], "mdouble-float">, Group;
-def mmadd4 : Flag<["-"], "mmadd4">, Group,
-  HelpText<"Enable the generation of 4-operand madd.s, madd.d and related 
instructions.">;
-def mno_madd4 : Flag<["-"], "mno-madd4">, Group,
-  HelpText<"Disable the generation of 4-operand madd.s, madd.d and related 
instructions.">;
 def mmsa : Flag<["-"], "mmsa">, Group,
   HelpText<"Enable MSA ASE (MIPS only)">;
 def mno_msa : Flag<["-"], "mno-msa">, Group,

Modified: cfe/trunk/lib/Basic/Targets/Mips.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/Mips.cpp?rev=310057=310056=310057=diff
==
--- cfe/trunk/lib/Basic/Targets/Mips.cpp (original)
+++ cfe/trunk/lib/Basic/Targets/Mips.cpp Fri Aug  4 05:37:34 2017
@@ -166,9 +166,6 @@ void MipsTargetInfo::getTargetDefines(co
   if (HasMSA)
 Builder.defineMacro("__mips_msa", Twine(1));
 
-  if (DisableMadd4)
-Builder.defineMacro("__mips_no_madd4", Twine(1));
-
   Builder.defineMacro("_MIPS_SZPTR", Twine(getPointerWidth(0)));
   Builder.defineMacro("_MIPS_SZINT", Twine(getIntWidth()));
   Builder.defineMacro("_MIPS_SZLONG", Twine(getLongWidth()));

Modified: cfe/trunk/lib/Basic/Targets/Mips.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/Mips.h?rev=310057=310056=310057=diff
==
--- cfe/trunk/lib/Basic/Targets/Mips.h (original)
+++ cfe/trunk/lib/Basic/Targets/Mips.h Fri Aug  4 05:37:34 2017
@@ -52,7 +52,6 @@ class LLVM_LIBRARY_VISIBILITY MipsTarget
   enum MipsFloatABI { HardFloat, SoftFloat } FloatABI;
   enum DspRevEnum { NoDSP, DSP1, DSP2 } DspRev;
   bool HasMSA;
-  bool DisableMadd4;
 
 protected:
   bool HasFP64;
@@ -63,7 +62,7 @@ public:
   : TargetInfo(Triple), IsMips16(false), IsMicromips(false),
 IsNan2008(false), IsSingleFloat(false), IsNoABICalls(false),
 CanUseBSDABICalls(false), FloatABI(HardFloat), DspRev(NoDSP),
-HasMSA(false), DisableMadd4(false), HasFP64(false) {
+HasMSA(false), HasFP64(false) {
 TheCXXABI.set(TargetCXXABI::GenericMIPS);
 
 setABI((getTriple().getArch() == llvm::Triple::mips ||
@@ -320,8 +319,6 @@ public:
 DspRev = std::max(DspRev, DSP2);
   else if (Feature == "+msa")
 HasMSA = true;
-  else if (Feature == "+nomadd4")
-DisableMadd4 = true;
   else if (Feature == "+fp64")
 HasFP64 = true;
   else if (Feature == "-fp64")

Modified: cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp?rev=310057=310056=310057=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp Fri Aug  4 05:37:34 2017
@@ -297,8 +297,6 @@ void mips::getMIPSTargetFeatures(const D
 
   AddTargetFeature(Args, Features, options::OPT_mno_odd_spreg,
options::OPT_modd_spreg, "nooddspreg");
-  AddTargetFeature(Args, Features, options::OPT_mno_madd4, options::OPT_mmadd4,
-   "nomadd4");
   AddTargetFeature(Args, Features, options::OPT_mlong_calls,
options::OPT_mno_long_calls, "long-calls");
   AddTargetFeature(Args, Features, options::OPT_mmt, options::OPT_mno_mt, 
"mt");

Removed: cfe/trunk/test/CodeGen/mips-madd4.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/mips-madd4.c?rev=310056=auto
==
--- cfe/trunk/test/CodeGen/mips-madd4.c (original)
+++ cfe/trunk/test/CodeGen/mips-madd4.c (removed)
@@ -1,87 +0,0 @@
-// REQUIRES: mips-registered-target
-// 

[PATCH] D36308: Add handling for DeducedType to HasDeclarationMatcher

2017-08-04 Thread Florian Gross via Phabricator via cfe-commits
fgross created this revision.

HasDeclarationMatcher did not handle DeducedType, it always returned false for 
deduced types.

So with code like this:

  struct X{};
  auto x = X{};

This did no longer match:

  varDecl(hasType(recordDecl(hasName("X" 

Because HasDeclarationMatcher didn't resolve the DeducedType of `x`.

This came up because some checks in clang-tidy didn't match as expected anymore.


https://reviews.llvm.org/D36308

Files:
  include/clang/ASTMatchers/ASTMatchersInternal.h
  unittests/ASTMatchers/ASTMatchersNodeTest.cpp


Index: unittests/ASTMatchers/ASTMatchersNodeTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersNodeTest.cpp
+++ unittests/ASTMatchers/ASTMatchersNodeTest.cpp
@@ -1184,6 +1184,10 @@
   EXPECT_TRUE(matches("int v[] = { 2, 3 }; void f() { for (int i : v) {} }",
   autoType()));
 
+  EXPECT_TRUE(matches("auto i = 2;", varDecl(hasType(isInteger();
+  EXPECT_TRUE(matches("struct X{}; auto x = X{};",
+  varDecl(hasType(recordDecl(hasName("X"));
+
   // FIXME: Matching against the type-as-written can't work here, because the
   //type as written was not deduced.
   //EXPECT_TRUE(matches("auto a = 1;",
Index: include/clang/ASTMatchers/ASTMatchersInternal.h
===
--- include/clang/ASTMatchers/ASTMatchersInternal.h
+++ include/clang/ASTMatchers/ASTMatchersInternal.h
@@ -741,24 +741,33 @@
   /// matcher matches on it.
   bool matchesSpecialized(const Type , ASTMatchFinder *Finder,
   BoundNodesTreeBuilder *Builder) const {
+
+// For deduced types, use the deduced type
+const Type *EffectiveType = 
+if (const auto *S = dyn_cast()) {
+  EffectiveType = S->getDeducedType().getTypePtrOrNull();
+  if (!EffectiveType)
+return false;
+}
+
 // First, for any types that have a declaration, extract the declaration 
and
 // match on it.
-if (const auto *S = dyn_cast()) {
+if (const auto *S = dyn_cast(EffectiveType)) {
   return matchesDecl(S->getDecl(), Finder, Builder);
 }
-if (const auto *S = dyn_cast()) {
+if (const auto *S = dyn_cast(EffectiveType)) {
   return matchesDecl(S->getDecl(), Finder, Builder);
 }
-if (const auto *S = dyn_cast()) {
+if (const auto *S = dyn_cast(EffectiveType)) {
   return matchesDecl(S->getDecl(), Finder, Builder);
 }
-if (const auto *S = dyn_cast()) {
+if (const auto *S = dyn_cast(EffectiveType)) {
   return matchesDecl(S->getDecl(), Finder, Builder);
 }
-if (const auto *S = dyn_cast()) {
+if (const auto *S = dyn_cast(EffectiveType)) {
   return matchesDecl(S->getDecl(), Finder, Builder);
 }
-if (const auto *S = dyn_cast()) {
+if (const auto *S = dyn_cast(EffectiveType)) {
   return matchesDecl(S->getInterface(), Finder, Builder);
 }
 
@@ -770,14 +779,14 @@
 //   template struct X { T t; } class A {}; X a;
 // The following matcher will match, which otherwise would not:
 //   fieldDecl(hasType(pointerType())).
-if (const auto *S = dyn_cast()) {
+if (const auto *S = dyn_cast(EffectiveType)) {
   return matchesSpecialized(S->getReplacementType(), Finder, Builder);
 }
 
 // For template specialization types, we want to match the template
 // declaration, as long as the type is still dependent, and otherwise the
 // declaration of the instantiated tag type.
-if (const auto *S = dyn_cast()) {
+if (const auto *S = dyn_cast(EffectiveType)) {
   if (!S->isTypeAlias() && S->isSugared()) {
 // If the template is non-dependent, we want to match the instantiated
 // tag type.
@@ -796,7 +805,7 @@
 // FIXME: We desugar elaborated types. This makes the assumption that users
 // do never want to match on whether a type is elaborated - there are
 // arguments for both sides; for now, continue desugaring.
-if (const auto *S = dyn_cast()) {
+if (const auto *S = dyn_cast(EffectiveType)) {
   return matchesSpecialized(S->desugar(), Finder, Builder);
 }
 return false;


Index: unittests/ASTMatchers/ASTMatchersNodeTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersNodeTest.cpp
+++ unittests/ASTMatchers/ASTMatchersNodeTest.cpp
@@ -1184,6 +1184,10 @@
   EXPECT_TRUE(matches("int v[] = { 2, 3 }; void f() { for (int i : v) {} }",
   autoType()));
 
+  EXPECT_TRUE(matches("auto i = 2;", varDecl(hasType(isInteger();
+  EXPECT_TRUE(matches("struct X{}; auto x = X{};",
+  varDecl(hasType(recordDecl(hasName("X"));
+
   // FIXME: Matching against the type-as-written can't work here, because the
   //type as written was not deduced.
   //EXPECT_TRUE(matches("auto a = 1;",
Index: include/clang/ASTMatchers/ASTMatchersInternal.h

[PATCH] D36051: [clang-tidy] List the checkers with autofix

2017-08-04 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added a comment.

In my opinion, this list should be available to the executable for two reasons.

1. External tools, that want to integrate clang-tidy in their workflow should 
be able to get the information about fixits, since they could collidie with 
their own textual replacements
2. One might enable/disable only fixing checks. This one is less important, 
since the -fix flag is available.

Having it written in code, like maybe a flag you set when subclassing the 
check, makes it ez to automatically determine if the check is modifying for 
documentation as well.


https://reviews.llvm.org/D36051



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


[clang-tools-extra] r310051 - [clang-tidy] Add missing documents for "IgnoreMacros" option.

2017-08-04 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Fri Aug  4 04:25:05 2017
New Revision: 310051

URL: http://llvm.org/viewvc/llvm-project?rev=310051=rev
Log:
[clang-tidy] Add missing documents for "IgnoreMacros" option.

Modified:
clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-make-shared.rst

clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-bool-literals.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-using.rst

clang-tools-extra/trunk/docs/clang-tidy/checks/readability-redundant-declaration.rst

Modified: 
clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-make-shared.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-make-shared.rst?rev=310051=310050=310051=diff
==
--- clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-make-shared.rst 
(original)
+++ clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-make-shared.rst 
Fri Aug  4 04:25:05 2017
@@ -43,3 +43,8 @@ Options
 
A string specifying which include-style is used, `llvm` or `google`. Default
is `llvm`.
+
+.. option:: IgnoreMacros
+
+   If set to non-zero, the check will not give warnings inside macros. Default
+   is `1`.

Modified: 
clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-bool-literals.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-bool-literals.rst?rev=310051=310050=310051=diff
==
--- 
clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-bool-literals.rst 
(original)
+++ 
clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-bool-literals.rst 
Fri Aug  4 04:25:05 2017
@@ -18,3 +18,11 @@ Finds integer literals which are cast to
   bool f = true;
   std::ios_base::sync_with_stdio(false);
   bool x = p ? true : false;
+
+Options
+---
+
+.. option:: IgnoreMacros
+
+   If set to non-zero, the check will not give warnings inside macros. Default
+   is `1`.

Modified: clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-using.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-using.rst?rev=310051=310050=310051=diff
==
--- clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-using.rst 
(original)
+++ clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-using.rst Fri 
Aug  4 04:25:05 2017
@@ -24,3 +24,11 @@ After:
   using MyPtrType = void (Class::*)() const;
 
 This check requires using C++11 or higher to run.
+
+Options
+---
+
+.. option:: IgnoreMacros
+
+   If set to non-zero, the check will not give warnings inside macros. Default
+   is `1`.

Modified: 
clang-tools-extra/trunk/docs/clang-tidy/checks/readability-redundant-declaration.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/readability-redundant-declaration.rst?rev=310051=310050=310051=diff
==
--- 
clang-tools-extra/trunk/docs/clang-tidy/checks/readability-redundant-declaration.rst
 (original)
+++ 
clang-tools-extra/trunk/docs/clang-tidy/checks/readability-redundant-declaration.rst
 Fri Aug  4 04:25:05 2017
@@ -27,3 +27,11 @@ manually:
 
 * When the declarations are in different header files;
 * When multiple variables are declared together.
+
+Options
+---
+
+.. option:: IgnoreMacros
+
+   If set to non-zero, the check will not give warnings inside macros. Default
+   is `1`.


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


[PATCH] D35355: Fix templated type alias completion when using global completion cache

2017-08-04 Thread Ivan Donchevskii via Phabricator via cfe-commits
yvvan added a comment.

one more Ping. this is quite a useful fix that does not cost much


https://reviews.llvm.org/D35355



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


[clang-tools-extra] r310050 - [clang-tidy] Ignore macros in make-unique check.

2017-08-04 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Fri Aug  4 04:18:00 2017
New Revision: 310050

URL: http://llvm.org/viewvc/llvm-project?rev=310050=rev
Log:
[clang-tidy] Ignore macros in make-unique check.

Summary:
The check doesn't fully support smart-ptr usages inside macros, which
may cause incorrect fixes, or even crashes, ignore them for now.

Reviewers: alexfh

Reviewed By: alexfh

Subscribers: JDevlieghere, xazax.hun, cfe-commits

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

Added:
clang-tools-extra/trunk/test/clang-tidy/modernize-make-unique-macros.cpp
Modified:
clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.cpp
clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.h
clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-make-unique.rst
clang-tools-extra/trunk/test/clang-tidy/modernize-make-unique.cpp

Modified: clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.cpp?rev=310050=310049=310050=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.cpp Fri Aug  
4 04:18:00 2017
@@ -42,7 +42,8 @@ const char MakeSmartPtrCheck::Constructo
 const char MakeSmartPtrCheck::ResetCall[] = "resetCall";
 const char MakeSmartPtrCheck::NewExpression[] = "newExpression";
 
-MakeSmartPtrCheck::MakeSmartPtrCheck(StringRef Name, ClangTidyContext *Context,
+MakeSmartPtrCheck::MakeSmartPtrCheck(StringRef Name,
+ ClangTidyContext* Context,
  StringRef MakeSmartPtrFunctionName)
 : ClangTidyCheck(Name, Context),
   IncludeStyle(utils::IncludeSorter::parseIncludeStyle(
@@ -50,12 +51,14 @@ MakeSmartPtrCheck::MakeSmartPtrCheck(Str
   MakeSmartPtrFunctionHeader(
   Options.get("MakeSmartPtrFunctionHeader", StdMemoryHeader)),
   MakeSmartPtrFunctionName(
-  Options.get("MakeSmartPtrFunction", MakeSmartPtrFunctionName)) {}
+  Options.get("MakeSmartPtrFunction", MakeSmartPtrFunctionName)),
+  IgnoreMacros(Options.getLocalOrGlobal("IgnoreMacros", true)) {}
 
 void MakeSmartPtrCheck::storeOptions(ClangTidyOptions::OptionMap ) {
   Options.store(Opts, "IncludeStyle", IncludeStyle);
   Options.store(Opts, "MakeSmartPtrFunctionHeader", 
MakeSmartPtrFunctionHeader);
   Options.store(Opts, "MakeSmartPtrFunction", MakeSmartPtrFunctionName);
+  Options.store(Opts, "IgnoreMacros", IgnoreMacros);
 }
 
 void MakeSmartPtrCheck::registerPPCallbacks(CompilerInstance ) {
@@ -122,6 +125,11 @@ void MakeSmartPtrCheck::checkConstruct(S
const QualType *Type,
const CXXNewExpr *New) {
   SourceLocation ConstructCallStart = Construct->getExprLoc();
+  bool InMacro = ConstructCallStart.isMacroID();
+
+  if (InMacro && IgnoreMacros) {
+return;
+  }
 
   bool Invalid = false;
   StringRef ExprStr = Lexer::getSourceText(
@@ -134,6 +142,11 @@ void MakeSmartPtrCheck::checkConstruct(S
   auto Diag = diag(ConstructCallStart, "use %0 instead")
   << MakeSmartPtrFunctionName;
 
+  // Disable the fix in macros.
+  if (InMacro) {
+return;
+  }
+
   // Find the location of the template's left angle.
   size_t LAngle = ExprStr.find("<");
   SourceLocation ConstructCallEnd;
@@ -180,9 +193,20 @@ void MakeSmartPtrCheck::checkReset(Sourc
   SourceLocation ExprEnd =
   Lexer::getLocForEndOfToken(Expr->getLocEnd(), 0, SM, getLangOpts());
 
+  bool InMacro = ExprStart.isMacroID();
+
+  if (InMacro && IgnoreMacros) {
+return;
+  }
+
   auto Diag = diag(ResetCallStart, "use %0 instead")
   << MakeSmartPtrFunctionName;
 
+  // Disable the fix in macros.
+  if (InMacro) {
+return;
+  }
+
   Diag << FixItHint::CreateReplacement(
   CharSourceRange::getCharRange(OperatorLoc, ExprEnd),
   (llvm::Twine(" = ") + MakeSmartPtrFunctionName + "<" +

Modified: clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.h?rev=310050=310049=310050=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.h (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.h Fri Aug  4 
04:18:00 2017
@@ -50,6 +50,7 @@ private:
   const utils::IncludeSorter::IncludeStyle IncludeStyle;
   const std::string MakeSmartPtrFunctionHeader;
   const std::string MakeSmartPtrFunctionName;
+  const bool IgnoreMacros;
 
   void checkConstruct(SourceManager , const CXXConstructExpr *Construct,
   const QualType *Type, const CXXNewExpr *New);

Modified: 

[PATCH] D36264: [clang-tidy] Ignore macros in make-unique check.

2017-08-04 Thread Haojian Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL310050: [clang-tidy] Ignore macros in make-unique check. 
(authored by hokein).

Repository:
  rL LLVM

https://reviews.llvm.org/D36264

Files:
  clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.cpp
  clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.h
  clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-make-unique.rst
  clang-tools-extra/trunk/test/clang-tidy/modernize-make-unique-macros.cpp
  clang-tools-extra/trunk/test/clang-tidy/modernize-make-unique.cpp

Index: clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.h
===
--- clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.h
+++ clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.h
@@ -50,6 +50,7 @@
   const utils::IncludeSorter::IncludeStyle IncludeStyle;
   const std::string MakeSmartPtrFunctionHeader;
   const std::string MakeSmartPtrFunctionName;
+  const bool IgnoreMacros;
 
   void checkConstruct(SourceManager , const CXXConstructExpr *Construct,
   const QualType *Type, const CXXNewExpr *New);
Index: clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.cpp
@@ -42,20 +42,23 @@
 const char MakeSmartPtrCheck::ResetCall[] = "resetCall";
 const char MakeSmartPtrCheck::NewExpression[] = "newExpression";
 
-MakeSmartPtrCheck::MakeSmartPtrCheck(StringRef Name, ClangTidyContext *Context,
+MakeSmartPtrCheck::MakeSmartPtrCheck(StringRef Name,
+ ClangTidyContext* Context,
  StringRef MakeSmartPtrFunctionName)
 : ClangTidyCheck(Name, Context),
   IncludeStyle(utils::IncludeSorter::parseIncludeStyle(
   Options.getLocalOrGlobal("IncludeStyle", "llvm"))),
   MakeSmartPtrFunctionHeader(
   Options.get("MakeSmartPtrFunctionHeader", StdMemoryHeader)),
   MakeSmartPtrFunctionName(
-  Options.get("MakeSmartPtrFunction", MakeSmartPtrFunctionName)) {}
+  Options.get("MakeSmartPtrFunction", MakeSmartPtrFunctionName)),
+  IgnoreMacros(Options.getLocalOrGlobal("IgnoreMacros", true)) {}
 
 void MakeSmartPtrCheck::storeOptions(ClangTidyOptions::OptionMap ) {
   Options.store(Opts, "IncludeStyle", IncludeStyle);
   Options.store(Opts, "MakeSmartPtrFunctionHeader", MakeSmartPtrFunctionHeader);
   Options.store(Opts, "MakeSmartPtrFunction", MakeSmartPtrFunctionName);
+  Options.store(Opts, "IgnoreMacros", IgnoreMacros);
 }
 
 void MakeSmartPtrCheck::registerPPCallbacks(CompilerInstance ) {
@@ -122,6 +125,11 @@
const QualType *Type,
const CXXNewExpr *New) {
   SourceLocation ConstructCallStart = Construct->getExprLoc();
+  bool InMacro = ConstructCallStart.isMacroID();
+
+  if (InMacro && IgnoreMacros) {
+return;
+  }
 
   bool Invalid = false;
   StringRef ExprStr = Lexer::getSourceText(
@@ -134,6 +142,11 @@
   auto Diag = diag(ConstructCallStart, "use %0 instead")
   << MakeSmartPtrFunctionName;
 
+  // Disable the fix in macros.
+  if (InMacro) {
+return;
+  }
+
   // Find the location of the template's left angle.
   size_t LAngle = ExprStr.find("<");
   SourceLocation ConstructCallEnd;
@@ -180,9 +193,20 @@
   SourceLocation ExprEnd =
   Lexer::getLocForEndOfToken(Expr->getLocEnd(), 0, SM, getLangOpts());
 
+  bool InMacro = ExprStart.isMacroID();
+
+  if (InMacro && IgnoreMacros) {
+return;
+  }
+
   auto Diag = diag(ResetCallStart, "use %0 instead")
   << MakeSmartPtrFunctionName;
 
+  // Disable the fix in macros.
+  if (InMacro) {
+return;
+  }
+
   Diag << FixItHint::CreateReplacement(
   CharSourceRange::getCharRange(OperatorLoc, ExprEnd),
   (llvm::Twine(" = ") + MakeSmartPtrFunctionName + "<" +
Index: clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-make-unique.rst
===
--- clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-make-unique.rst
+++ clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-make-unique.rst
@@ -43,3 +43,8 @@
 
A string specifying which include-style is used, `llvm` or `google`. Default
is `llvm`.
+
+.. option:: IgnoreMacros
+
+   If set to non-zero, the check will not give warnings inside macros. Default
+   is `1`.
Index: clang-tools-extra/trunk/test/clang-tidy/modernize-make-unique-macros.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/modernize-make-unique-macros.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-make-unique-macros.cpp
@@ -0,0 +1,28 @@
+// RUN: 

[PATCH] D36264: [clang-tidy] Ignore macros in make-unique check.

2017-08-04 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 109701.
hokein marked 2 inline comments as done.
hokein added a comment.

Address review comments.


https://reviews.llvm.org/D36264

Files:
  clang-tidy/modernize/MakeSmartPtrCheck.cpp
  clang-tidy/modernize/MakeSmartPtrCheck.h
  docs/clang-tidy/checks/modernize-make-unique.rst
  test/clang-tidy/modernize-make-unique-macros.cpp
  test/clang-tidy/modernize-make-unique.cpp

Index: test/clang-tidy/modernize-make-unique.cpp
===
--- test/clang-tidy/modernize-make-unique.cpp
+++ test/clang-tidy/modernize-make-unique.cpp
@@ -404,3 +404,14 @@
   // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: use std::make_unique instead
   // CHECK-FIXES: *Q = std::make_unique();
 }
+
+#define DEFINE(...) __VA_ARGS__
+template
+void g2(std::unique_ptr *t) {
+  DEFINE(auto p = std::unique_ptr(new Foo); t->reset(new Foo););
+}
+void macro() {
+  std::unique_ptr *t;
+  g2(t);
+}
+#undef DEFINE
Index: test/clang-tidy/modernize-make-unique-macros.cpp
===
--- /dev/null
+++ test/clang-tidy/modernize-make-unique-macros.cpp
@@ -0,0 +1,28 @@
+// RUN: %check_clang_tidy %s modernize-make-unique %t -- \
+// RUN:   -config="{CheckOptions: [{key: modernize-make-unique.IgnoreMacros, value: 0}]}" \
+// RUN:   -- -std=c++11  -I%S/Inputs/modernize-smart-ptr
+
+#include "unique_ptr.h"
+
+class Foo {};
+class Bar {};
+#define DEFINE(...) __VA_ARGS__
+// CHECK-FIXES: {{^}}#define DEFINE(...) __VA_ARGS__{{$}}
+template
+void g2(std::unique_ptr *t) {
+  DEFINE(
+  // CHECK-FIXES: {{^ *}}DEFINE({{$}}
+  auto p = std::unique_ptr(new Foo);
+  // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: use std::make_unique instead
+  // CHECK-FIXES: {{^ *}}auto p = std::unique_ptr(new Foo);{{$}}
+  t->reset(new Foo);
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: use std::make_unique instead
+  // CHECK-FIXES: {{^ *}}t->reset(new Foo);{{$}}
+  );
+  // CHECK-FIXES: {{^ *}});{{$}}
+}
+void macro() {
+  std::unique_ptr *t;
+  g2(t);
+}
+#undef DEFINE
Index: docs/clang-tidy/checks/modernize-make-unique.rst
===
--- docs/clang-tidy/checks/modernize-make-unique.rst
+++ docs/clang-tidy/checks/modernize-make-unique.rst
@@ -43,3 +43,8 @@
 
A string specifying which include-style is used, `llvm` or `google`. Default
is `llvm`.
+
+.. option:: IgnoreMacros
+
+   If set to non-zero, the check will not give warnings inside macros. Default
+   is `1`.
Index: clang-tidy/modernize/MakeSmartPtrCheck.h
===
--- clang-tidy/modernize/MakeSmartPtrCheck.h
+++ clang-tidy/modernize/MakeSmartPtrCheck.h
@@ -50,6 +50,7 @@
   const utils::IncludeSorter::IncludeStyle IncludeStyle;
   const std::string MakeSmartPtrFunctionHeader;
   const std::string MakeSmartPtrFunctionName;
+  const bool IgnoreMacros;
 
   void checkConstruct(SourceManager , const CXXConstructExpr *Construct,
   const QualType *Type, const CXXNewExpr *New);
Index: clang-tidy/modernize/MakeSmartPtrCheck.cpp
===
--- clang-tidy/modernize/MakeSmartPtrCheck.cpp
+++ clang-tidy/modernize/MakeSmartPtrCheck.cpp
@@ -42,20 +42,23 @@
 const char MakeSmartPtrCheck::ResetCall[] = "resetCall";
 const char MakeSmartPtrCheck::NewExpression[] = "newExpression";
 
-MakeSmartPtrCheck::MakeSmartPtrCheck(StringRef Name, ClangTidyContext *Context,
+MakeSmartPtrCheck::MakeSmartPtrCheck(StringRef Name,
+ ClangTidyContext* Context,
  StringRef MakeSmartPtrFunctionName)
 : ClangTidyCheck(Name, Context),
   IncludeStyle(utils::IncludeSorter::parseIncludeStyle(
   Options.getLocalOrGlobal("IncludeStyle", "llvm"))),
   MakeSmartPtrFunctionHeader(
   Options.get("MakeSmartPtrFunctionHeader", StdMemoryHeader)),
   MakeSmartPtrFunctionName(
-  Options.get("MakeSmartPtrFunction", MakeSmartPtrFunctionName)) {}
+  Options.get("MakeSmartPtrFunction", MakeSmartPtrFunctionName)),
+  IgnoreMacros(Options.getLocalOrGlobal("IgnoreMacros", true)) {}
 
 void MakeSmartPtrCheck::storeOptions(ClangTidyOptions::OptionMap ) {
   Options.store(Opts, "IncludeStyle", IncludeStyle);
   Options.store(Opts, "MakeSmartPtrFunctionHeader", MakeSmartPtrFunctionHeader);
   Options.store(Opts, "MakeSmartPtrFunction", MakeSmartPtrFunctionName);
+  Options.store(Opts, "IgnoreMacros", IgnoreMacros);
 }
 
 void MakeSmartPtrCheck::registerPPCallbacks(CompilerInstance ) {
@@ -122,6 +125,11 @@
const QualType *Type,
const CXXNewExpr *New) {
   SourceLocation ConstructCallStart = Construct->getExprLoc();
+  bool InMacro = ConstructCallStart.isMacroID();
+
+  if (InMacro && IgnoreMacros) {
+

[PATCH] D34873: Fix miscompiled 32bit binaries by mingw

2017-08-04 Thread Martell Malone via Phabricator via cfe-commits
martell added a comment.

@rnk isn't this related to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78936
Assuming this is in fact a gcc bug this will most likely cause a regression 
with the standalone clang mingw toolchains we are on the verge of having.
This is of course assuming clang does not have the same regression gcc does.


https://reviews.llvm.org/D34873



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


[PATCH] D34331: func.wrap.func.con: Unset function before destroying anything

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

Don't you need `// UNSUPPORTED: c++98, c++03` since `std::function` is 
supported in C++11 only?


https://reviews.llvm.org/D34331



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


[PATCH] D36264: [clang-tidy] Ignore macros in make-unique check.

2017-08-04 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh accepted this revision.
alexfh added a comment.

LG with a couple of nits.




Comment at: clang-tidy/modernize/MakeSmartPtrCheck.cpp:54
+  Options.get("MakeSmartPtrFunction", MakeSmartPtrFunctionName)),
+  IgnoreMacros(Options.get("IgnoreMacros", true)) {}
 

Let's go with `getLocalOrGlobal` to be able to set the option for all checks at 
once. Other checks having this option do this already.



Comment at: test/clang-tidy/modernize-make-unique-macros.cpp:14
+  auto p = std::unique_ptr(new Foo);
+  // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: use std::make_unique instead
+  t->reset(new Foo);

Please add CHECK-FIXES to verify that the code remains intact (both macro 
definition and expansion).


https://reviews.llvm.org/D36264



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


r310047 - [Driver] Error if ARM mode was selected explicitly for M-profile CPUs.

2017-08-04 Thread Florian Hahn via cfe-commits
Author: fhahn
Date: Fri Aug  4 03:40:18 2017
New Revision: 310047

URL: http://llvm.org/viewvc/llvm-project?rev=310047=rev
Log:
[Driver] Error if ARM mode was selected explicitly for M-profile CPUs.

Summary:
M-class profiles do not support ARM execution mode, so providing
-marm/-mno-thumb does not make sense in combination with -mcpu/-march
options that support the M-profile.

This is a follow-up patch to D35569 and it seemed pretty clear that we
should emit an error in the driver in this case.

We probably also should warn/error if the provided -mcpu/-march options
do not match, e.g. -mcpu=cortex-m0 -march=armv8-a is invalid, as
cortex-m0 does not support armv8-a. But that should be a separate patch
I think.


Reviewers: echristo, richard.barton.arm, rengolin, labrinea, charles.baylis

Reviewed By: rengolin

Subscribers: aemerson, javed.absar, kristof.beyls, cfe-commits

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

Added:
cfe/trunk/test/Driver/arm-thumb-only-cores.c
Modified:
cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
cfe/trunk/lib/Driver/ToolChain.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=310047=310046=310047=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td Fri Aug  4 03:40:18 
2017
@@ -106,6 +106,10 @@ def err_drv_malformed_sanitizer_blacklis
 
 def err_target_unsupported_arch
   : Error<"the target architecture '%0' is not supported by the target '%1'">;
+def err_cpu_unsupported_isa
+  : Error<"CPU '%0' does not support '%1' execution mode">;
+def err_arch_unsupported_isa
+  : Error<"Architecture '%0' does not support '%1' execution mode">;
 
 def err_drv_I_dash_not_supported : Error<
   "'%0' not supported, please use -iquote instead">;

Modified: cfe/trunk/lib/Driver/ToolChain.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChain.cpp?rev=310047=310046=310047=diff
==
--- cfe/trunk/lib/Driver/ToolChain.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChain.cpp Fri Aug  4 03:40:18 2017
@@ -517,6 +517,18 @@ std::string ToolChain::ComputeLLVMTriple
 else
   ArchName = "arm";
 
+// Check if ARM ISA was explicitly selected (using -mno-thumb or -marm) for
+// M-Class CPUs/architecture variants, which is not supported.
+bool ARMModeRequested = !Args.hasFlag(options::OPT_mthumb,
+  options::OPT_mno_thumb, 
ThumbDefault);
+if (IsMProfile && ARMModeRequested) {
+  if (!MCPU.empty())
+getDriver().Diag(diag::err_cpu_unsupported_isa) << CPU << "ARM";
+   else
+getDriver().Diag(diag::err_arch_unsupported_isa)
+  << tools::arm::getARMArch(MArch, getTriple()) << "ARM";
+}
+
 // Assembly files should start in ARM mode, unless arch is M-profile.
 // Windows is always thumb.
 if ((InputType != types::TY_PP_Asm && Args.hasFlag(options::OPT_mthumb,

Added: cfe/trunk/test/Driver/arm-thumb-only-cores.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/arm-thumb-only-cores.c?rev=310047=auto
==
--- cfe/trunk/test/Driver/arm-thumb-only-cores.c (added)
+++ cfe/trunk/test/Driver/arm-thumb-only-cores.c Fri Aug  4 03:40:18 2017
@@ -0,0 +1,12 @@
+// RUN: not %clang -target arm-unknown-linux -marm -mcpu=cortex-m0 %s -o 
/dev/null 2>&1 \
+// RUN:   | FileCheck --check-prefix M0 %s
+// M0: error: CPU 'cortex-m0' does not support 'ARM' execution mode
+
+// RUN: not %clang -target arm-unknown-linux -marm -march=armv7m %s -o 
/dev/null 2>&1 \
+// RUN:   | FileCheck --check-prefix ARMV7M %s
+// RUN: not %clang -target armv7m-unknown-linux -mno-thumb %s -o /dev/null 
2>&1 \
+// RUN:   | FileCheck --check-prefix ARMV7M %s
+// ARMV7M: error: Architecture 'armv7m' does not support 'ARM' execution mode
+//
+// RUN: %clang -S -emit-llvm -target arm-unknown-linux -mcpu=cortex-m0 %s -o 
/dev/null 2>&1
+// M-Profile CPUs default to Thumb mode even if arm triples are provided.


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


Re: r308619 - Reland "[mips] Teach the driver to accept -m(no-)gpopt."

2017-08-04 Thread Simon Atanasyan via cfe-commits
On Thu, Jul 20, 2017 at 5:04 PM, Simon Dardis via cfe-commits
 wrote:
> Reland "[mips] Teach the driver to accept -m(no-)gpopt."
>
> This patch teaches the driver to pass -mgpopt by default to the backend when 
> it
> is supported, i.e. we are using -mno-abicalls.

[...]

> Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=308619=308618=308619=diff
> ==
> --- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
> +++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Thu Jul 20 07:04:12 2017
> @@ -1462,6 +1462,30 @@ void Clang::AddMIPSTargetArgs(const ArgL
>  A->claim();
>}
>
> +  Arg *GPOpt = Args.getLastArg(options::OPT_mgpopt, options::OPT_mno_gpopt);
> +  Arg *ABICalls =
> +  Args.getLastArg(options::OPT_mabicalls, options::OPT_mno_abicalls);
> +
> +  // -mabicalls is the default for many MIPS environments, even with 
> -fno-pic.
> +  // -mgpopt is the default for static, -fno-pic environments but these two
> +  // options conflict. We want to be certain that -mno-abicalls -mgpopt is
> +  // the only case where -mllvm -mgpopt is passed.
> +  // NOTE: We need a warning here or in the backend to warn when -mgpopt is
> +  //   passed explicitly when compiling something with -mabicalls
> +  //   (implictly) in affect. Currently the warning is in the backend.
> +  bool NoABICalls =
> +  ABICalls && ABICalls->getOption().matches(options::OPT_mno_abicalls);

What about N64 ABI + non-PIC code? In that case we pass the
`+noabicalls` feature flag to the backend by default regardless of
-mabicalls / -mnoabicalls options. Should we assign `true` to the
NoABICalls in that case too to be consistent?

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


[PATCH] D34992: Emit static constexpr member as available_externally definition

2017-08-04 Thread Mehdi AMINI via Phabricator via cfe-commits
mehdi_amini marked 6 inline comments as done.
mehdi_amini added inline comments.



Comment at: clang/lib/CodeGen/CodeGenModule.cpp:2293
 /// If ExcludeCtor is true, the duration when the object's constructor runs
-/// will not be considered. The caller will need to verify that the object is
-/// not written to during its construction.
+/// will not be considered (unless trivial). The caller will need to verify 
that
+/// the object is not written to during its construction.

rsmith wrote:
> This comment change suggests that when `ExcludeCtor` is true, a trivial 
> constructor is considered. That's the opposite of what this change does -- 
> namely, a trivial constructor is not considered regardless of the value of 
> `ExcludeCtor`.
Yep your right. I removed all the changes here.




Comment at: clang/lib/CodeGen/CodeGenModule.cpp:2437-2445
+  bool HasMutableField = false;
+  if (Context.getLangOpts().CPlusPlus) {
+if (const CXXRecordDecl *Record =
+Context.getBaseElementType(D->getType())->getAsCXXRecordDecl())
+  HasMutableField = Record->hasMutableFields();
+  }
+

rsmith wrote:
> This duplicates much of the work done by `isTypeConstant`.
Indeed, thanks for pointing this, this simplifies a lot!



Comment at: clang/lib/CodeGen/CodeGenModule.cpp:2448-2451
+if (InitExpr) {
+  GV->setLinkage(llvm::GlobalValue::AvailableExternallyLinkage);
+  GV->setInitializer(EmitConstantInit(*InitDecl));
+}

rsmith wrote:
> In order for this transformation to be correct, you need to know that the 
> variable has static initialization, which means that it needs to formally 
> have a constant initializer. You can use `D->isInitKnownICE()` to check this.
Done! But couldn't find how to express it as a test-case though.


https://reviews.llvm.org/D34992



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


[PATCH] D34992: Emit static constexpr member as available_externally definition

2017-08-04 Thread Mehdi AMINI via Phabricator via cfe-commits
mehdi_amini updated this revision to Diff 109694.
mehdi_amini marked 12 inline comments as done.
mehdi_amini added a comment.

Address Richard's comment


https://reviews.llvm.org/D34992

Files:
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/CodeGenCXX/cxx11-extern-constexpr.cpp


Index: clang/test/CodeGenCXX/cxx11-extern-constexpr.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/cxx11-extern-constexpr.cpp
@@ -0,0 +1,48 @@
+// RUN: %clang_cc1 -std=c++11 %s -emit-llvm -o - -triple x86_64-linux-gnu | 
FileCheck %s --check-prefix=CHECK --check-prefix=CXX11
+// RUN: %clang_cc1 -std=c++1z %s -emit-llvm -o - -triple x86_64-linux-gnu | 
FileCheck %s --check-prefix=CHECK --check-prefix=CXX17
+
+struct Bar {
+  int b;
+};
+
+struct MutableBar {
+  mutable int b;
+};
+
+struct Foo {
+  // CXX11: @_ZN3Foo21ConstexprStaticMemberE = available_externally constant 
i32 42,
+  // CXX17: @_ZN3Foo21ConstexprStaticMemberE = linkonce_odr constant i32 42,
+  static constexpr int ConstexprStaticMember = 42;
+  // CHECK: @_ZN3Foo17ConstStaticMemberE = available_externally constant i32 
43,
+  static const int ConstStaticMember = 43;
+
+  // CXX11: @_ZN3Foo23ConstStaticStructMemberE = available_externally constant 
%struct.Bar { i32 44 },
+  // CXX17: @_ZN3Foo23ConstStaticStructMemberE = linkonce_odr constant 
%struct.Bar { i32 44 },
+  static constexpr Bar ConstStaticStructMember = {44};
+
+  // CXX11: @_ZN3Foo34ConstexprStaticMutableStructMemberE = external global 
%struct.MutableBar,
+  // CXX17: @_ZN3Foo34ConstexprStaticMutableStructMemberE = linkonce_odr 
global %struct.MutableBar { i32 45 },
+  static constexpr MutableBar ConstexprStaticMutableStructMember = {45};
+};
+// CHECK: @_ZL15ConstStaticexpr = internal constant i32 46,
+static constexpr int ConstStaticexpr = 46;
+// CHECK: @_ZL9ConstExpr = internal constant i32 46, align 4
+static const int ConstExpr = 46;
+
+// CHECK: @_ZL21ConstexprStaticStruct = internal constant %struct.Bar { i32 47 
},
+static constexpr Bar ConstexprStaticStruct = {47};
+
+// CHECK: @_ZL28ConstexprStaticMutableStruct = internal global 
%struct.MutableBar { i32 48 },
+static constexpr MutableBar ConstexprStaticMutableStruct = {48};
+
+void use(const int &);
+void foo() {
+  use(Foo::ConstexprStaticMember);
+  use(Foo::ConstStaticMember);
+  use(Foo::ConstStaticStructMember.b);
+  use(Foo::ConstexprStaticMutableStructMember.b);
+  use(ConstStaticexpr);
+  use(ConstExpr);
+  use(ConstexprStaticStruct.b);
+  use(ConstexprStaticMutableStruct.b);
+}
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -2436,6 +2436,22 @@
 D->getType().isConstant(Context) &&
 isExternallyVisible(D->getLinkageAndVisibility().getLinkage()))
   GV->setSection(".cp.rodata");
+
+// Check if we a have a const declaration with an initializer, we may be
+// able to emit it as available_externally to expose its value to the
+// optimizer.
+if (GV->hasExternalLinkage() && isTypeConstant(D->getType(), true) &&
+!D->hasDefinition() && D->hasInit() &&
+/* C++17 static constexpr are inlined */ !D->isInline() &&
+!D->hasAttr() && D->isInitKnownICE()) {
+  const VarDecl *InitDecl;
+  const Expr *InitExpr = D->getAnyInitializer(InitDecl);
+  if (InitExpr) {
+GV->setConstant(true);
+GV->setLinkage(llvm::GlobalValue::AvailableExternallyLinkage);
+GV->setInitializer(EmitConstantInit(*InitDecl));
+  }
+}
   }
 
   auto ExpectedAS =


Index: clang/test/CodeGenCXX/cxx11-extern-constexpr.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/cxx11-extern-constexpr.cpp
@@ -0,0 +1,48 @@
+// RUN: %clang_cc1 -std=c++11 %s -emit-llvm -o - -triple x86_64-linux-gnu | FileCheck %s --check-prefix=CHECK --check-prefix=CXX11
+// RUN: %clang_cc1 -std=c++1z %s -emit-llvm -o - -triple x86_64-linux-gnu | FileCheck %s --check-prefix=CHECK --check-prefix=CXX17
+
+struct Bar {
+  int b;
+};
+
+struct MutableBar {
+  mutable int b;
+};
+
+struct Foo {
+  // CXX11: @_ZN3Foo21ConstexprStaticMemberE = available_externally constant i32 42,
+  // CXX17: @_ZN3Foo21ConstexprStaticMemberE = linkonce_odr constant i32 42,
+  static constexpr int ConstexprStaticMember = 42;
+  // CHECK: @_ZN3Foo17ConstStaticMemberE = available_externally constant i32 43,
+  static const int ConstStaticMember = 43;
+
+  // CXX11: @_ZN3Foo23ConstStaticStructMemberE = available_externally constant %struct.Bar { i32 44 },
+  // CXX17: @_ZN3Foo23ConstStaticStructMemberE = linkonce_odr constant %struct.Bar { i32 44 },
+  static constexpr Bar ConstStaticStructMember = {44};
+
+  // CXX11: @_ZN3Foo34ConstexprStaticMutableStructMemberE = external global %struct.MutableBar,
+  // CXX17: @_ZN3Foo34ConstexprStaticMutableStructMemberE = 

[PATCH] D36150: [clangd] LSP extension to switch between source/header file

2017-08-04 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov requested changes to this revision.
ilya-biryukov added a comment.
This revision now requires changes to proceed.

This is probably not a final version, but I feel my comments should be helpful 
anyway.
Also, we're missing testcases now.




Comment at: clangd/ClangdLSPServer.cpp:225
+  PathRef ref = PathRef((Params.uri.uri).c_str());
+  Path result = LangServer.Server.switchSourceHeader(ref);
+

We use `Params.uri.file`, not `Params.uri.uri` when passing paths to clangd.
Also no need for extra local var: 
`LangServer.Server.switchSourceHeader(Params.uri.file);` should work.



Comment at: clangd/ClangdLSPServer.cpp:225
+  PathRef ref = PathRef((Params.uri.uri).c_str());
+  Path result = LangServer.Server.switchSourceHeader(ref);
+

ilya-biryukov wrote:
> We use `Params.uri.file`, not `Params.uri.uri` when passing paths to clangd.
> Also no need for extra local var: 
> `LangServer.Server.switchSourceHeader(Params.uri.file);` should work.
Naming: local vars should start with capital letter.



Comment at: clangd/ClangdServer.cpp:295
+  std::string DEFAULT_SOURCE_EXTENSIONS[] = { ".cpp", ".c", ".cc", ".cxx",
+".c++", ".C", ".m", ".mm" };  
+  std::string DEFAULT_HEADER_EXTENSIONS[] = { ".h", ".hh", ".hpp", ".hxx",

We should check all extensions in both upper-case and lower-case, not just `.c` 
and `.C`
(ideally, we could use case-insensitive comparisons).



Comment at: clangd/ClangdServer.cpp:302
+
+  std::string pathDataRef = std::string(path.data());
+  bool isSourceFile = false, foundExtension = false;

`path` is already a `StringRef`, no need to convert it. 
`std::string` is also implicitly convertible to `StringRef`, you could pass 
`std::string` to every function that accepts a `StringRef`



Comment at: clangd/ClangdServer.cpp:307
+
+  while (!foundExtension && i < sourceSize)
+  {

Maybe replace with:
```
if (std::find(DEFAULT_SOURCE_EXTESIONS, /*end iterator*/, 
llvm::sys::path::extensions(path)) {
  isSourceFile = true;
  foundExtension = true;
}
```



Comment at: clangd/ClangdServer.cpp:323
+  {
+while (!foundExtension && i < headerSize)
+{

Maybe use `std::find` here too?



Comment at: clangd/ClangdServer.cpp:339
+  SmallString<128> CurrentPath;
+  CurrentPath = temp;
+  bool done = false;

Don't need `temp` var here, there's `StringRef::toVector` method to convert 
`StringRef` to `SmallString`.



Comment at: clangd/ClangdServer.cpp:341
+  bool done = false;
+  std::vector EXTENSIONS_ARRAY;
+  

Naming: EXTENSIONS_ARRAY is a local var, use `UpperCamelCase`.

Maybe use `ArrayRef` for `ExtensionsArray` instead?



Comment at: clangd/ClangdServer.cpp:360
+FILE * file;
+file = fopen(temp.c_str(), "r");
+if (file)

Please use `vfs::FileSystem` instance, provided by 
`FSProvider.getTaggedFileSystem()` here for file accesses.



Comment at: clangd/ClangdServer.cpp:367
+  std::string returnValue = std::string(NewPath.str());
+  return Path("\"" + returnValue + "\"");
+}

Don't add quotes here, `Uri` constructor and `Uri::unparse` is responsible for 
doing that.



Comment at: clangd/ClangdServer.h:185
 
+  std::string switchSourceHeader(std::string path);
+

ilya-biryukov wrote:
> ilya-biryukov wrote:
> > Please use descriptive typedefs for paths: `Path` (equivalent to 
> > `std::string`) for return type and `PathRef` (equivalent to `StringRef`) 
> > for parameter type.
> Maybe add a small comment for this function to indicate it's a fairly trivial 
> helper?
Maybe also change wording to indicate that this function does not mutate any 
state and is indeed trivial, i.e.:
`Helper function that returns a path to the corresponding source file when 
given a header file and vice versa.`

Code style: please end all comments with full stops.



Comment at: clangd/ClangdServer.h:186
+  // Helper function to change from one header file to it's corresponding 
source file and vice versa
+  Path switchSourceHeader(PathRef path);
+

Naming: parameter names must be capitalized



Comment at: clangd/ProtocolHandlers.cpp:260
+  Dispatcher.registerHandler(
+  "textDocument/switchSourceHeader",
+  llvm::make_unique(Out, Callbacks));

ilya-biryukov wrote:
> I don't see this method in the [[ 
> https://github.com/Microsoft/language-server-protocol/blob/master/protocol.md 
> | LSP spec ]].
> Is this some kind of extension?
> 
> Could you add some comments on that with pointers to proposal/explanation of 
> where this extension is used?
This comment was not addressed, probably marked as 'Done' by accident.


https://reviews.llvm.org/D36150




r310041 - Fix typo and update documentation.

2017-08-04 Thread Manuel Klimek via cfe-commits
Author: klimek
Date: Fri Aug  4 01:41:42 2017
New Revision: 310041

URL: http://llvm.org/viewvc/llvm-project?rev=310041=rev
Log:
Fix typo and update documentation.

The hasDeclaration documentation was outdated after r288366.

Modified:
cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h

Modified: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h?rev=310041=310040=310041=diff
==
--- cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h (original)
+++ cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h Fri Aug  4 01:41:42 2017
@@ -2566,8 +2566,21 @@ const internal::VariadicOperatorMatcherF
 /// - for CXXConstructExpr, the declaration of the constructor
 /// - for CXXNewExpr, the declaration of the operator new
 ///
-/// Also usable as Matcher for any T supporting the getDecl() member
-/// function. e.g. various subtypes of clang::Type and various expressions.
+/// For type nodes, hasDeclaration will generally match the declaration of the
+/// sugared type. Given
+/// \code
+///   class X {};
+///   typedef X Y;
+///   Y y;
+/// \endcode
+/// in varDecl(hasType(hasDeclaration(decl( the decl will match the
+/// typedefDecl. A common use case is to match the underlying, desugared type.
+/// This can be achieved by using the hasUnqualifiedDesugaredType matcher:
+/// \code
+///   varDecl(hasType(hasUnqualifiedDesugaredType(
+///   recordType(hasDeclaration(decl())
+/// \endcode
+/// In this matcher, the decl will match the CXXRecordDecl of class X.
 ///
 /// Usable as: Matcher, Matcher,
 ///   Matcher, Matcher, Matcher,
@@ -2860,7 +2873,7 @@ AST_MATCHER_P_OVERLOAD(QualType, pointsT
 ///   class A {};
 ///   using B = A;
 /// \endcode
-/// The matcher type(hasUniqualifeidDesugaredType(recordType())) matches
+/// The matcher type(hasUnqualifeidDesugaredType(recordType())) matches
 /// both B and A.
 AST_MATCHER_P(Type, hasUnqualifiedDesugaredType, internal::Matcher,
   InnerMatcher) {


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


[PATCH] D35847: clang-format: Fix left pointer alignment after delctype/typeof

2017-08-04 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir added inline comments.



Comment at: lib/Format/TokenAnnotator.cpp:1402
+PrevToken->MatchingParen->getPreviousNonComment() &&
+PrevToken->MatchingParen->getPreviousNonComment()->isOneOf(
+  tok::kw_typeof,

It would be cool if you extract the calls to getPreviousNonComment to a 
variable, saving the double iteration.


https://reviews.llvm.org/D35847



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


[PATCH] D36264: [clang-tidy] Ignore macros in make-unique check.

2017-08-04 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

Please take another look.




Comment at: clang-tidy/modernize/MakeSmartPtrCheck.cpp:114
 
-  if (Construct)
+  if (Construct && !Construct->getLocation().isMacroID())
 checkConstruct(SM, Construct, Type, New);

alexfh wrote:
> Seems to be a bit too broad. Maybe just disable the fix in macros? If 
> warnings without fixes will be a problem in some codebases, we could then 
> introduce the `IgnoreMacros` option as in readability-redundant-declaration, 
> modernize-use-using, modernize-use-bool-literals, and 
> modernize-use-default-member-init.
The idea sounds good to me. Done.

> If warnings without fixes will be a problem in some codebases, we could then 
> introduce the IgnoreMacros option 

Didn't know there is `IgnoreMacros` option, but we are missing the option 
document for these checks. Will add them afterwards.


https://reviews.llvm.org/D36264



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


[PATCH] D36264: [clang-tidy] Ignore macros in make-unique check.

2017-08-04 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 109691.
hokein marked an inline comment as done.
hokein added a comment.

Add a missing test file.


https://reviews.llvm.org/D36264

Files:
  clang-tidy/modernize/MakeSmartPtrCheck.cpp
  clang-tidy/modernize/MakeSmartPtrCheck.h
  docs/clang-tidy/checks/modernize-make-unique.rst
  test/clang-tidy/modernize-make-unique-macros.cpp
  test/clang-tidy/modernize-make-unique.cpp

Index: test/clang-tidy/modernize-make-unique.cpp
===
--- test/clang-tidy/modernize-make-unique.cpp
+++ test/clang-tidy/modernize-make-unique.cpp
@@ -404,3 +404,14 @@
   // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: use std::make_unique instead
   // CHECK-FIXES: *Q = std::make_unique();
 }
+
+#define DEFINE(...) __VA_ARGS__
+template
+void g2(std::unique_ptr *t) {
+  DEFINE(auto p = std::unique_ptr(new Foo); t->reset(new Foo););
+}
+void macro() {
+  std::unique_ptr *t;
+  g2(t);
+}
+#undef DEFINE
Index: test/clang-tidy/modernize-make-unique-macros.cpp
===
--- /dev/null
+++ test/clang-tidy/modernize-make-unique-macros.cpp
@@ -0,0 +1,23 @@
+// RUN: %check_clang_tidy %s modernize-make-unique %t -- \
+// RUN:   -config="{CheckOptions: [{key: modernize-make-unique.IgnoreMacros, value: 0}]}" \
+// RUN:   -- -std=c++11  -I%S/Inputs/modernize-smart-ptr
+
+#include "unique_ptr.h"
+
+class Foo {};
+class Bar {};
+#define DEFINE(...) __VA_ARGS__
+template
+void g2(std::unique_ptr *t) {
+  DEFINE(
+  auto p = std::unique_ptr(new Foo);
+  // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: use std::make_unique instead
+  t->reset(new Foo);
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: use std::make_unique instead
+  );
+}
+void macro() {
+  std::unique_ptr *t;
+  g2(t);
+}
+#undef DEFINE
Index: docs/clang-tidy/checks/modernize-make-unique.rst
===
--- docs/clang-tidy/checks/modernize-make-unique.rst
+++ docs/clang-tidy/checks/modernize-make-unique.rst
@@ -43,3 +43,8 @@
 
A string specifying which include-style is used, `llvm` or `google`. Default
is `llvm`.
+
+.. option:: IgnoreMacros
+
+   If set to non-zero, the check will not give warnings inside macros. Default
+   is `1`.
Index: clang-tidy/modernize/MakeSmartPtrCheck.h
===
--- clang-tidy/modernize/MakeSmartPtrCheck.h
+++ clang-tidy/modernize/MakeSmartPtrCheck.h
@@ -50,6 +50,7 @@
   const utils::IncludeSorter::IncludeStyle IncludeStyle;
   const std::string MakeSmartPtrFunctionHeader;
   const std::string MakeSmartPtrFunctionName;
+  const bool IgnoreMacros;
 
   void checkConstruct(SourceManager , const CXXConstructExpr *Construct,
   const QualType *Type, const CXXNewExpr *New);
Index: clang-tidy/modernize/MakeSmartPtrCheck.cpp
===
--- clang-tidy/modernize/MakeSmartPtrCheck.cpp
+++ clang-tidy/modernize/MakeSmartPtrCheck.cpp
@@ -50,12 +50,14 @@
   MakeSmartPtrFunctionHeader(
   Options.get("MakeSmartPtrFunctionHeader", StdMemoryHeader)),
   MakeSmartPtrFunctionName(
-  Options.get("MakeSmartPtrFunction", MakeSmartPtrFunctionName)) {}
+  Options.get("MakeSmartPtrFunction", MakeSmartPtrFunctionName)),
+  IgnoreMacros(Options.get("IgnoreMacros", true)) {}
 
 void MakeSmartPtrCheck::storeOptions(ClangTidyOptions::OptionMap ) {
   Options.store(Opts, "IncludeStyle", IncludeStyle);
   Options.store(Opts, "MakeSmartPtrFunctionHeader", MakeSmartPtrFunctionHeader);
   Options.store(Opts, "MakeSmartPtrFunction", MakeSmartPtrFunctionName);
+  Options.store(Opts, "IgnoreMacros", IgnoreMacros);
 }
 
 void MakeSmartPtrCheck::registerPPCallbacks(CompilerInstance ) {
@@ -122,6 +124,11 @@
const QualType *Type,
const CXXNewExpr *New) {
   SourceLocation ConstructCallStart = Construct->getExprLoc();
+  bool InMacro = ConstructCallStart.isMacroID();
+
+  if (InMacro && IgnoreMacros) {
+return;
+  }
 
   bool Invalid = false;
   StringRef ExprStr = Lexer::getSourceText(
@@ -134,6 +141,11 @@
   auto Diag = diag(ConstructCallStart, "use %0 instead")
   << MakeSmartPtrFunctionName;
 
+  // Disable the fix in macros.
+  if (InMacro) {
+return;
+  }
+
   // Find the location of the template's left angle.
   size_t LAngle = ExprStr.find("<");
   SourceLocation ConstructCallEnd;
@@ -180,9 +192,20 @@
   SourceLocation ExprEnd =
   Lexer::getLocForEndOfToken(Expr->getLocEnd(), 0, SM, getLangOpts());
 
+  bool InMacro = ExprStart.isMacroID();
+
+  if (InMacro && IgnoreMacros) {
+return;
+  }
+
   auto Diag = diag(ResetCallStart, "use %0 instead")
   << MakeSmartPtrFunctionName;
 
+  // Disable the fix in macros.
+  if (InMacro) {
+return;
+  }
+
   Diag << 

[PATCH] D34873: Fix miscompiled 32bit binaries by mingw

2017-08-04 Thread Ivan Donchevskii via Phabricator via cfe-commits
yvvan added a comment.

ping. Do you think this is ok now?


https://reviews.llvm.org/D34873



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


  1   2   >