[libclc] r356011 - mad: Convert to standard ternary header

2019-03-13 Thread Jan Vesely via cfe-commits
Author: jvesely
Date: Wed Mar 13 00:05:53 2019
New Revision: 356011

URL: http://llvm.org/viewvc/llvm-project?rev=356011&view=rev
Log:
mad: Convert to standard ternary header

Reviewer: Aaron Watry
Signed-off-by: Jan Vesely 

Removed:
libclc/trunk/generic/include/clc/math/mad.inc
Modified:
libclc/trunk/generic/include/clc/math/mad.h

Modified: libclc/trunk/generic/include/clc/math/mad.h
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/math/mad.h?rev=356011&r1=356010&r2=356011&view=diff
==
--- libclc/trunk/generic/include/clc/math/mad.h (original)
+++ libclc/trunk/generic/include/clc/math/mad.h Wed Mar 13 00:05:53 2019
@@ -1,2 +1,7 @@
-#define __CLC_BODY 
+#define __CLC_BODY 
+#define __CLC_FUNCTION mad
+
 #include 
+
+#undef __CLC_BODY
+#undef __CLC_FUNCTION

Removed: libclc/trunk/generic/include/clc/math/mad.inc
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/math/mad.inc?rev=356010&view=auto
==
--- libclc/trunk/generic/include/clc/math/mad.inc (original)
+++ libclc/trunk/generic/include/clc/math/mad.inc (removed)
@@ -1 +0,0 @@
-_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE mad(__CLC_GENTYPE a, __CLC_GENTYPE b, 
__CLC_GENTYPE c);


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


[libclc] r356013 - ceil: Remove llvm intrinsic from the header.

2019-03-13 Thread Jan Vesely via cfe-commits
Author: jvesely
Date: Wed Mar 13 00:05:58 2019
New Revision: 356013

URL: http://llvm.org/viewvc/llvm-project?rev=356013&view=rev
Log:
ceil: Remove llvm intrinsic from the header.

Reviewer: Aaron Watry
Signed-off-by: Jan Vesely 

Added:
libclc/trunk/generic/lib/math/ceil.cl
Modified:
libclc/trunk/generic/include/clc/math/ceil.h
libclc/trunk/generic/lib/SOURCES

Modified: libclc/trunk/generic/include/clc/math/ceil.h
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/math/ceil.h?rev=356013&r1=356012&r2=356013&view=diff
==
--- libclc/trunk/generic/include/clc/math/ceil.h (original)
+++ libclc/trunk/generic/include/clc/math/ceil.h Wed Mar 13 00:05:58 2019
@@ -1,6 +1,7 @@
-#undef ceil
-#define ceil __clc_ceil
+#define __CLC_BODY 
+#define __CLC_FUNCTION ceil
 
-#define __CLC_FUNCTION __clc_ceil
-#define __CLC_INTRINSIC "llvm.ceil"
-#include 
+#include 
+
+#undef __CLC_BODY
+#undef __CLC_FUNCTION

Modified: libclc/trunk/generic/lib/SOURCES
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/SOURCES?rev=356013&r1=356012&r2=356013&view=diff
==
--- libclc/trunk/generic/lib/SOURCES (original)
+++ libclc/trunk/generic/lib/SOURCES Wed Mar 13 00:05:58 2019
@@ -89,6 +89,7 @@ math/atan2pi.cl
 math/atanh.cl
 math/atanpi.cl
 math/cbrt.cl
+math/ceil.cl
 math/copysign.cl
 math/cos.cl
 math/cosh.cl

Added: libclc/trunk/generic/lib/math/ceil.cl
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/math/ceil.cl?rev=356013&view=auto
==
--- libclc/trunk/generic/lib/math/ceil.cl (added)
+++ libclc/trunk/generic/lib/math/ceil.cl Wed Mar 13 00:05:58 2019
@@ -0,0 +1,11 @@
+#include 
+#include "../clcmacro.h"
+
+// Map the llvm intrinsic to an OpenCL function.
+#define __CLC_FUNCTION __clc_ceil
+#define __CLC_INTRINSIC "llvm.ceil"
+#include 
+
+#undef __CLC_FUNCTION
+#define __CLC_FUNCTION ceil
+#include "unary_builtin.inc"


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


[libclc] r356012 - sqrt: Split function generation to a shared inc file.

2019-03-13 Thread Jan Vesely via cfe-commits
Author: jvesely
Date: Wed Mar 13 00:05:56 2019
New Revision: 356012

URL: http://llvm.org/viewvc/llvm-project?rev=356012&view=rev
Log:
sqrt: Split function generation to a shared inc file.

This will be reused by other unary functions.
Reviewer: Aaron Watry
Signed-off-by: Jan Vesely 

Added:
libclc/trunk/generic/lib/math/unary_builtin.inc
Modified:
libclc/trunk/generic/lib/math/sqrt.cl

Modified: libclc/trunk/generic/lib/math/sqrt.cl
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/math/sqrt.cl?rev=356012&r1=356011&r2=356012&view=diff
==
--- libclc/trunk/generic/lib/math/sqrt.cl (original)
+++ libclc/trunk/generic/lib/math/sqrt.cl Wed Mar 13 00:05:56 2019
@@ -21,23 +21,7 @@
  */
 
 #include 
-#include "../clcmacro.h"
 #include "math/clc_sqrt.h"
 
-_CLC_DEFINE_UNARY_BUILTIN(float, sqrt, __clc_sqrt, float)
-
-#ifdef cl_khr_fp64
-
-#pragma OPENCL EXTENSION cl_khr_fp64 : enable
-
-_CLC_DEFINE_UNARY_BUILTIN(double, sqrt, __clc_sqrt, double)
-
-#endif
-
-#ifdef cl_khr_fp16
-
-#pragma OPENCL EXTENSION cl_khr_fp16 : enable
-
-_CLC_DEFINE_UNARY_BUILTIN(half, sqrt, __clc_sqrt, half)
-
-#endif
+#define __CLC_FUNCTION sqrt
+#include "unary_builtin.inc"

Added: libclc/trunk/generic/lib/math/unary_builtin.inc
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/math/unary_builtin.inc?rev=356012&view=auto
==
--- libclc/trunk/generic/lib/math/unary_builtin.inc (added)
+++ libclc/trunk/generic/lib/math/unary_builtin.inc Wed Mar 13 00:05:56 2019
@@ -0,0 +1,24 @@
+#include "../clcmacro.h"
+#include "utils.h"
+
+#ifndef __CLC_BUILTIN
+#define __CLC_BUILTIN __CLC_XCONCAT(__clc_, __CLC_FUNCTION)
+#endif
+
+_CLC_DEFINE_UNARY_BUILTIN(float, __CLC_FUNCTION, __CLC_BUILTIN, float)
+
+#ifdef cl_khr_fp64
+
+#pragma OPENCL EXTENSION cl_khr_fp64 : enable
+
+_CLC_DEFINE_UNARY_BUILTIN(double, __CLC_FUNCTION, __CLC_BUILTIN, double)
+
+#endif
+
+#ifdef cl_khr_fp16
+
+#pragma OPENCL EXTENSION cl_khr_fp16 : enable
+
+_CLC_DEFINE_UNARY_BUILTIN(half, __CLC_FUNCTION, __CLC_BUILTIN, half)
+
+#endif


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


[libclc] r356017 - round: Remove llvm intrinsic from the header

2019-03-13 Thread Jan Vesely via cfe-commits
Author: jvesely
Date: Wed Mar 13 00:06:08 2019
New Revision: 356017

URL: http://llvm.org/viewvc/llvm-project?rev=356017&view=rev
Log:
round: Remove llvm intrinsic from the header

Reviewer: Aaron Watry
Signed-off-by: Jan Vesely 

Added:
libclc/trunk/generic/lib/math/round.cl
  - copied, changed from r356016, 
libclc/trunk/generic/include/clc/math/round.h
Modified:
libclc/trunk/generic/include/clc/math/round.h
libclc/trunk/generic/lib/SOURCES

Modified: libclc/trunk/generic/include/clc/math/round.h
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/math/round.h?rev=356017&r1=356016&r2=356017&view=diff
==
--- libclc/trunk/generic/include/clc/math/round.h (original)
+++ libclc/trunk/generic/include/clc/math/round.h Wed Mar 13 00:06:08 2019
@@ -1,9 +1,7 @@
-#undef round
-#define round __clc_round
+#define __CLC_BODY 
+#define __CLC_FUNCTION round
 
-#define __CLC_FUNCTION __clc_round
-#define __CLC_INTRINSIC "llvm.round"
-#include 
+#include 
 
+#undef __CLC_BODY
 #undef __CLC_FUNCTION
-#undef __CLC_INTRINSIC

Modified: libclc/trunk/generic/lib/SOURCES
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/SOURCES?rev=356017&r1=356016&r2=356017&view=diff
==
--- libclc/trunk/generic/lib/SOURCES (original)
+++ libclc/trunk/generic/lib/SOURCES Wed Mar 13 00:06:08 2019
@@ -175,6 +175,7 @@ math/remquo.cl
 math/rint.cl
 math/clc_rootn.cl
 math/rootn.cl
+math/round.cl
 math/sin.cl
 math/sincos.cl
 math/sincos_helpers.cl

Copied: libclc/trunk/generic/lib/math/round.cl (from r356016, 
libclc/trunk/generic/include/clc/math/round.h)
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/math/round.cl?p2=libclc/trunk/generic/lib/math/round.cl&p1=libclc/trunk/generic/include/clc/math/round.h&r1=356016&r2=356017&rev=356017&view=diff
==
--- libclc/trunk/generic/include/clc/math/round.h (original)
+++ libclc/trunk/generic/lib/math/round.cl Wed Mar 13 00:06:08 2019
@@ -1,9 +1,10 @@
-#undef round
-#define round __clc_round
+#include 
 
+// Map the llvm intrinsic to an OpenCL function.
 #define __CLC_FUNCTION __clc_round
 #define __CLC_INTRINSIC "llvm.round"
 #include 
 
 #undef __CLC_FUNCTION
-#undef __CLC_INTRINSIC
+#define __CLC_FUNCTION round
+#include "unary_builtin.inc"


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


[libclc] r356014 - fabs: Remove llvm intrinsic from the header.

2019-03-13 Thread Jan Vesely via cfe-commits
Author: jvesely
Date: Wed Mar 13 00:06:00 2019
New Revision: 356014

URL: http://llvm.org/viewvc/llvm-project?rev=356014&view=rev
Log:
fabs: Remove llvm intrinsic from the header.

Reviewer: Aaron Watry
Signed-off-by: Jan Vesely 

Added:
libclc/trunk/generic/lib/math/fabs.cl
Modified:
libclc/trunk/generic/include/clc/math/fabs.h
libclc/trunk/generic/lib/SOURCES

Modified: libclc/trunk/generic/include/clc/math/fabs.h
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/math/fabs.h?rev=356014&r1=356013&r2=356014&view=diff
==
--- libclc/trunk/generic/include/clc/math/fabs.h (original)
+++ libclc/trunk/generic/include/clc/math/fabs.h Wed Mar 13 00:06:00 2019
@@ -1,6 +1,7 @@
-#undef fabs
-#define fabs __clc_fabs
+#define __CLC_BODY 
+#define __CLC_FUNCTION fabs
 
-#define __CLC_FUNCTION __clc_fabs
-#define __CLC_INTRINSIC "llvm.fabs"
-#include 
+#include 
+
+#undef __CLC_BODY
+#undef __CLC_FUNCTION

Modified: libclc/trunk/generic/lib/SOURCES
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/SOURCES?rev=356014&r1=356013&r2=356014&view=diff
==
--- libclc/trunk/generic/lib/SOURCES (original)
+++ libclc/trunk/generic/lib/SOURCES Wed Mar 13 00:06:00 2019
@@ -103,6 +103,7 @@ math/expm1.cl
 math/exp2.cl
 math/clc_exp10.cl
 math/exp10.cl
+math/fabs.cl
 math/fdim.cl
 math/clc_fma.cl
 math/fma.cl

Added: libclc/trunk/generic/lib/math/fabs.cl
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/math/fabs.cl?rev=356014&view=auto
==
--- libclc/trunk/generic/lib/math/fabs.cl (added)
+++ libclc/trunk/generic/lib/math/fabs.cl Wed Mar 13 00:06:00 2019
@@ -0,0 +1,11 @@
+#include 
+#include "../clcmacro.h"
+
+// Map the llvm intrinsic to an OpenCL function.
+#define __CLC_FUNCTION __clc_fabs
+#define __CLC_INTRINSIC "llvm.fabs"
+#include 
+
+#undef __CLC_FUNCTION
+#define __CLC_FUNCTION fabs
+#include "unary_builtin.inc"


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


[libclc] r356019 - Move ternary_intrinsic.h to private headers.

2019-03-13 Thread Jan Vesely via cfe-commits
Author: jvesely
Date: Wed Mar 13 00:06:13 2019
New Revision: 356019

URL: http://llvm.org/viewvc/llvm-project?rev=356019&view=rev
Log:
Move ternary_intrinsic.h to private headers.

Reviewer: Aaron Watry
Signed-off-by: Jan Vesely 

Added:
libclc/trunk/generic/include/math/ternary_intrin.inc
  - copied, changed from r356018, 
libclc/trunk/generic/include/clc/math/ternary_intrin.inc
Removed:
libclc/trunk/generic/include/clc/math/ternary_intrin.inc
Modified:
libclc/trunk/generic/include/math/clc_fma.h

Removed: libclc/trunk/generic/include/clc/math/ternary_intrin.inc
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/math/ternary_intrin.inc?rev=356018&view=auto
==
--- libclc/trunk/generic/include/clc/math/ternary_intrin.inc (original)
+++ libclc/trunk/generic/include/clc/math/ternary_intrin.inc (removed)
@@ -1,30 +0,0 @@
-_CLC_OVERLOAD float __CLC_FUNCTION(float, float, float) __asm(__CLC_INTRINSIC 
".f32");
-_CLC_OVERLOAD float2 __CLC_FUNCTION(float2, float2, float2) 
__asm(__CLC_INTRINSIC ".v2f32");
-_CLC_OVERLOAD float3 __CLC_FUNCTION(float3, float3, float3) 
__asm(__CLC_INTRINSIC ".v3f32");
-_CLC_OVERLOAD float4 __CLC_FUNCTION(float4, float4, float4) 
__asm(__CLC_INTRINSIC ".v4f32");
-_CLC_OVERLOAD float8 __CLC_FUNCTION(float8, float8, float8) 
__asm(__CLC_INTRINSIC ".v8f32");
-_CLC_OVERLOAD float16 __CLC_FUNCTION(float16, float16, float16) 
__asm(__CLC_INTRINSIC ".v16f32");
-
-#ifdef cl_khr_fp64
-#pragma OPENCL EXTENSION cl_khr_fp64 : enable
-_CLC_OVERLOAD double __CLC_FUNCTION(double, double, double) 
__asm(__CLC_INTRINSIC ".f64");
-_CLC_OVERLOAD double2 __CLC_FUNCTION(double2, double2, double2) 
__asm(__CLC_INTRINSIC ".v2f64");
-_CLC_OVERLOAD double3 __CLC_FUNCTION(double3, double3, double3) 
__asm(__CLC_INTRINSIC ".v3f64");
-_CLC_OVERLOAD double4 __CLC_FUNCTION(double4, double4, double4) 
__asm(__CLC_INTRINSIC ".v4f64");
-_CLC_OVERLOAD double8 __CLC_FUNCTION(double8, double8, double8) 
__asm(__CLC_INTRINSIC ".v8f64");
-_CLC_OVERLOAD double16 __CLC_FUNCTION(double16, double16, double16) 
__asm(__CLC_INTRINSIC ".v16f64");
-#endif
-
-#ifdef cl_khr_fp16
-#pragma OPENCL EXTENSION cl_khr_fp16: enable
-_CLC_OVERLOAD half __CLC_FUNCTION(half, half, half) __asm(__CLC_INTRINSIC 
".f16");
-_CLC_OVERLOAD half2 __CLC_FUNCTION(half2, half2, half2) __asm(__CLC_INTRINSIC 
".v2f16");
-_CLC_OVERLOAD half3 __CLC_FUNCTION(half3, half3, half3) __asm(__CLC_INTRINSIC 
".v3f16");
-_CLC_OVERLOAD half4 __CLC_FUNCTION(half4, half4, half4) __asm(__CLC_INTRINSIC 
".v4f16");
-_CLC_OVERLOAD half8 __CLC_FUNCTION(half8, half8, half8) __asm(__CLC_INTRINSIC 
".v8f16");
-_CLC_OVERLOAD half16 __CLC_FUNCTION(half16, half16, half16) 
__asm(__CLC_INTRINSIC ".v16f16");
-#endif
-
-
-#undef __CLC_FUNCTION
-#undef __CLC_INTRINSIC

Modified: libclc/trunk/generic/include/math/clc_fma.h
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/math/clc_fma.h?rev=356019&r1=356018&r2=356019&view=diff
==
--- libclc/trunk/generic/include/math/clc_fma.h (original)
+++ libclc/trunk/generic/include/math/clc_fma.h Wed Mar 13 00:06:13 2019
@@ -1,6 +1,6 @@
 #define __CLC_FUNCTION __clc_fma
 #define __CLC_INTRINSIC "llvm.fma"
-#include 
+#include "math/ternary_intrin.inc"
 
 #define __FLOAT_ONLY
 #define __CLC_FUNCTION __clc_sw_fma

Copied: libclc/trunk/generic/include/math/ternary_intrin.inc (from r356018, 
libclc/trunk/generic/include/clc/math/ternary_intrin.inc)
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/math/ternary_intrin.inc?p2=libclc/trunk/generic/include/math/ternary_intrin.inc&p1=libclc/trunk/generic/include/clc/math/ternary_intrin.inc&r1=356018&r2=356019&rev=356019&view=diff
==
(empty)


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


[libclc] r356015 - floor: Remove llvm isntrinsic from the header.

2019-03-13 Thread Jan Vesely via cfe-commits
Author: jvesely
Date: Wed Mar 13 00:06:03 2019
New Revision: 356015

URL: http://llvm.org/viewvc/llvm-project?rev=356015&view=rev
Log:
floor: Remove llvm isntrinsic from the header.

Reviewer: Aaron Watry
Signed-off-by: Jan Vesely 

Added:
libclc/trunk/generic/lib/math/floor.cl
Modified:
libclc/trunk/generic/include/clc/math/floor.h
libclc/trunk/generic/lib/SOURCES

Modified: libclc/trunk/generic/include/clc/math/floor.h
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/math/floor.h?rev=356015&r1=356014&r2=356015&view=diff
==
--- libclc/trunk/generic/include/clc/math/floor.h (original)
+++ libclc/trunk/generic/include/clc/math/floor.h Wed Mar 13 00:06:03 2019
@@ -1,6 +1,7 @@
-#undef floor
-#define floor __clc_floor
+#define __CLC_BODY 
+#define __CLC_FUNCTION floor
 
-#define __CLC_FUNCTION __clc_floor
-#define __CLC_INTRINSIC "llvm.floor"
-#include 
+#include 
+
+#undef __CLC_BODY
+#undef __CLC_FUNCTION

Modified: libclc/trunk/generic/lib/SOURCES
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/SOURCES?rev=356015&r1=356014&r2=356015&view=diff
==
--- libclc/trunk/generic/lib/SOURCES (original)
+++ libclc/trunk/generic/lib/SOURCES Wed Mar 13 00:06:03 2019
@@ -105,6 +105,7 @@ math/clc_exp10.cl
 math/exp10.cl
 math/fabs.cl
 math/fdim.cl
+math/floor.cl
 math/clc_fma.cl
 math/fma.cl
 math/fmax.cl

Added: libclc/trunk/generic/lib/math/floor.cl
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/math/floor.cl?rev=356015&view=auto
==
--- libclc/trunk/generic/lib/math/floor.cl (added)
+++ libclc/trunk/generic/lib/math/floor.cl Wed Mar 13 00:06:03 2019
@@ -0,0 +1,11 @@
+#include 
+#include "../clcmacro.h"
+
+// Map the llvm intrinsic to an OpenCL function.
+#define __CLC_FUNCTION __clc_floor
+#define __CLC_INTRINSIC "llvm.floor"
+#include 
+
+#undef __CLC_FUNCTION
+#define __CLC_FUNCTION floor
+#include "unary_builtin.inc"


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


[libclc] r356016 - rint: Remove llvm intrinsic from the header.

2019-03-13 Thread Jan Vesely via cfe-commits
Author: jvesely
Date: Wed Mar 13 00:06:06 2019
New Revision: 356016

URL: http://llvm.org/viewvc/llvm-project?rev=356016&view=rev
Log:
rint: Remove llvm intrinsic from the header.

Reviewer: Aaron Watry
Signed-off-by: Jan Vesely 

Added:
libclc/trunk/generic/lib/math/rint.cl
Modified:
libclc/trunk/generic/include/clc/math/rint.h
libclc/trunk/generic/lib/SOURCES

Modified: libclc/trunk/generic/include/clc/math/rint.h
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/math/rint.h?rev=356016&r1=356015&r2=356016&view=diff
==
--- libclc/trunk/generic/include/clc/math/rint.h (original)
+++ libclc/trunk/generic/include/clc/math/rint.h Wed Mar 13 00:06:06 2019
@@ -1,6 +1,7 @@
-#undef rint
-#define rint __clc_rint
+#define __CLC_BODY 
+#define __CLC_FUNCTION rint
 
-#define __CLC_FUNCTION __clc_rint
-#define __CLC_INTRINSIC "llvm.rint"
-#include 
+#include 
+
+#undef __CLC_BODY
+#undef __CLC_FUNCTION

Modified: libclc/trunk/generic/lib/SOURCES
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/SOURCES?rev=356016&r1=356015&r2=356016&view=diff
==
--- libclc/trunk/generic/lib/SOURCES (original)
+++ libclc/trunk/generic/lib/SOURCES Wed Mar 13 00:06:06 2019
@@ -172,6 +172,7 @@ math/clc_remainder.cl
 math/remainder.cl
 math/clc_remquo.cl
 math/remquo.cl
+math/rint.cl
 math/clc_rootn.cl
 math/rootn.cl
 math/sin.cl

Added: libclc/trunk/generic/lib/math/rint.cl
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/math/rint.cl?rev=356016&view=auto
==
--- libclc/trunk/generic/lib/math/rint.cl (added)
+++ libclc/trunk/generic/lib/math/rint.cl Wed Mar 13 00:06:06 2019
@@ -0,0 +1,10 @@
+#include 
+
+// Map the llvm intrinsic to an OpenCL function.
+#define __CLC_FUNCTION __clc_rint
+#define __CLC_INTRINSIC "llvm.rint"
+#include 
+
+#undef __CLC_FUNCTION
+#define __CLC_FUNCTION rint
+#include "unary_builtin.inc"


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


[libclc] r356018 - trunc: Remove llvm intrinsic from the header.

2019-03-13 Thread Jan Vesely via cfe-commits
Author: jvesely
Date: Wed Mar 13 00:06:10 2019
New Revision: 356018

URL: http://llvm.org/viewvc/llvm-project?rev=356018&view=rev
Log:
trunc: Remove llvm intrinsic from the header.

Reviewer: Aaron Watry
Signed-off-by: Jan Vesely 

Added:
libclc/trunk/generic/lib/math/trunc.cl
  - copied, changed from r356017, 
libclc/trunk/generic/include/clc/math/trunc.h
Modified:
libclc/trunk/generic/include/clc/math/trunc.h
libclc/trunk/generic/lib/SOURCES

Modified: libclc/trunk/generic/include/clc/math/trunc.h
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/math/trunc.h?rev=356018&r1=356017&r2=356018&view=diff
==
--- libclc/trunk/generic/include/clc/math/trunc.h (original)
+++ libclc/trunk/generic/include/clc/math/trunc.h Wed Mar 13 00:06:10 2019
@@ -1,9 +1,7 @@
-#undef trunc
-#define trunc __clc_trunc
+#define __CLC_BODY 
+#define __CLC_FUNCTION trunc
 
-#define __CLC_FUNCTION __clc_trunc
-#define __CLC_INTRINSIC "llvm.trunc"
-#include 
+#include 
 
+#undef __CLC_BODY
 #undef __CLC_FUNCTION
-#undef __CLC_INTRINSIC

Modified: libclc/trunk/generic/lib/SOURCES
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/SOURCES?rev=356018&r1=356017&r2=356018&view=diff
==
--- libclc/trunk/generic/lib/SOURCES (original)
+++ libclc/trunk/generic/lib/SOURCES Wed Mar 13 00:06:10 2019
@@ -189,6 +189,7 @@ math/tanh.cl
 math/clc_tanpi.cl
 math/tanpi.cl
 math/tgamma.cl
+math/trunc.cl
 misc/shuffle.cl
 misc/shuffle2.cl
 relational/all.cl

Copied: libclc/trunk/generic/lib/math/trunc.cl (from r356017, 
libclc/trunk/generic/include/clc/math/trunc.h)
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/math/trunc.cl?p2=libclc/trunk/generic/lib/math/trunc.cl&p1=libclc/trunk/generic/include/clc/math/trunc.h&r1=356017&r2=356018&rev=356018&view=diff
==
--- libclc/trunk/generic/include/clc/math/trunc.h (original)
+++ libclc/trunk/generic/lib/math/trunc.cl Wed Mar 13 00:06:10 2019
@@ -1,9 +1,10 @@
-#undef trunc
-#define trunc __clc_trunc
+#include 
 
+// Map the llvm intrinsic to an OpenCL function.
 #define __CLC_FUNCTION __clc_trunc
 #define __CLC_INTRINSIC "llvm.trunc"
 #include 
 
 #undef __CLC_FUNCTION
-#undef __CLC_INTRINSIC
+#define __CLC_FUNCTION trunc
+#include "unary_builtin.inc"


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


[libclc] r356021 - Move unary_instrinsic.inc to private headers.

2019-03-13 Thread Jan Vesely via cfe-commits
Author: jvesely
Date: Wed Mar 13 00:06:19 2019
New Revision: 356021

URL: http://llvm.org/viewvc/llvm-project?rev=356021&view=rev
Log:
Move unary_instrinsic.inc to private headers.

Reviewer: Aaron Watry
Signed-off-by: Jan Vesely 

Added:
libclc/trunk/generic/include/math/unary_intrin.inc
  - copied, changed from r356020, 
libclc/trunk/generic/include/clc/math/unary_intrin.inc
Removed:
libclc/trunk/generic/include/clc/math/unary_intrin.inc
Modified:
libclc/trunk/generic/lib/math/ceil.cl
libclc/trunk/generic/lib/math/clc_sqrt.cl
libclc/trunk/generic/lib/math/fabs.cl
libclc/trunk/generic/lib/math/floor.cl
libclc/trunk/generic/lib/math/native_unary_intrinsic.inc
libclc/trunk/generic/lib/math/rint.cl
libclc/trunk/generic/lib/math/round.cl
libclc/trunk/generic/lib/math/trunc.cl

Removed: libclc/trunk/generic/include/clc/math/unary_intrin.inc
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/math/unary_intrin.inc?rev=356020&view=auto
==
--- libclc/trunk/generic/include/clc/math/unary_intrin.inc (original)
+++ libclc/trunk/generic/include/clc/math/unary_intrin.inc (removed)
@@ -1,29 +0,0 @@
-_CLC_OVERLOAD float __CLC_FUNCTION(float f) __asm(__CLC_INTRINSIC ".f32");
-_CLC_OVERLOAD float2 __CLC_FUNCTION(float2 f) __asm(__CLC_INTRINSIC ".v2f32");
-_CLC_OVERLOAD float3 __CLC_FUNCTION(float3 f) __asm(__CLC_INTRINSIC ".v3f32");
-_CLC_OVERLOAD float4 __CLC_FUNCTION(float4 f) __asm(__CLC_INTRINSIC ".v4f32");
-_CLC_OVERLOAD float8 __CLC_FUNCTION(float8 f) __asm(__CLC_INTRINSIC ".v8f32");
-_CLC_OVERLOAD float16 __CLC_FUNCTION(float16 f) __asm(__CLC_INTRINSIC 
".v16f32");
-
-#ifdef cl_khr_fp64
-#pragma OPENCL EXTENSION cl_khr_fp64 : enable
-_CLC_OVERLOAD double __CLC_FUNCTION(double d) __asm(__CLC_INTRINSIC ".f64");
-_CLC_OVERLOAD double2 __CLC_FUNCTION(double2 d) __asm(__CLC_INTRINSIC 
".v2f64");
-_CLC_OVERLOAD double3 __CLC_FUNCTION(double3 d) __asm(__CLC_INTRINSIC 
".v3f64");
-_CLC_OVERLOAD double4 __CLC_FUNCTION(double4 d) __asm(__CLC_INTRINSIC 
".v4f64");
-_CLC_OVERLOAD double8 __CLC_FUNCTION(double8 d) __asm(__CLC_INTRINSIC 
".v8f64");
-_CLC_OVERLOAD double16 __CLC_FUNCTION(double16 d) __asm(__CLC_INTRINSIC 
".v16f64");
-#endif
-
-#ifdef cl_khr_fp16
-#pragma OPENCL EXTENSION cl_khr_fp16: enable
-_CLC_OVERLOAD half __CLC_FUNCTION(half d) __asm(__CLC_INTRINSIC ".f16");
-_CLC_OVERLOAD half2 __CLC_FUNCTION(half2 d) __asm(__CLC_INTRINSIC ".v2f16");
-_CLC_OVERLOAD half3 __CLC_FUNCTION(half3 d) __asm(__CLC_INTRINSIC ".v3f16");
-_CLC_OVERLOAD half4 __CLC_FUNCTION(half4 d) __asm(__CLC_INTRINSIC ".v4f16");
-_CLC_OVERLOAD half8 __CLC_FUNCTION(half8 d) __asm(__CLC_INTRINSIC ".v8f16");
-_CLC_OVERLOAD half16 __CLC_FUNCTION(half16 d) __asm(__CLC_INTRINSIC ".v16f16");
-#endif
-
-#undef __CLC_FUNCTION
-#undef __CLC_INTRINSIC

Copied: libclc/trunk/generic/include/math/unary_intrin.inc (from r356020, 
libclc/trunk/generic/include/clc/math/unary_intrin.inc)
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/math/unary_intrin.inc?p2=libclc/trunk/generic/include/math/unary_intrin.inc&p1=libclc/trunk/generic/include/clc/math/unary_intrin.inc&r1=356020&r2=356021&rev=356021&view=diff
==
(empty)

Modified: libclc/trunk/generic/lib/math/ceil.cl
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/math/ceil.cl?rev=356021&r1=356020&r2=356021&view=diff
==
--- libclc/trunk/generic/lib/math/ceil.cl (original)
+++ libclc/trunk/generic/lib/math/ceil.cl Wed Mar 13 00:06:19 2019
@@ -4,7 +4,7 @@
 // Map the llvm intrinsic to an OpenCL function.
 #define __CLC_FUNCTION __clc_ceil
 #define __CLC_INTRINSIC "llvm.ceil"
-#include 
+#include "math/unary_intrin.inc"
 
 #undef __CLC_FUNCTION
 #define __CLC_FUNCTION ceil

Modified: libclc/trunk/generic/lib/math/clc_sqrt.cl
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/math/clc_sqrt.cl?rev=356021&r1=356020&r2=356021&view=diff
==
--- libclc/trunk/generic/lib/math/clc_sqrt.cl (original)
+++ libclc/trunk/generic/lib/math/clc_sqrt.cl Wed Mar 13 00:06:19 2019
@@ -25,7 +25,7 @@
 // Map the llvm sqrt intrinsic to an OpenCL function.
 #define __CLC_FUNCTION __clc_llvm_intr_sqrt
 #define __CLC_INTRINSIC "llvm.sqrt"
-#include 
+#include 
 #undef __CLC_FUNCTION
 #undef __CLC_INTRINSIC
 

Modified: libclc/trunk/generic/lib/math/fabs.cl
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/math/fabs.cl?rev=356021&r1=356020&r2=356021&view=diff
==
--- libclc/trunk/generic/lib/math/fabs.cl (original)
+++ libclc/trunk/generic/lib/math/fabs.cl Wed Mar 13 00:06:19 2019
@@ -4,7 +4,7 @@
 // Map the llvm intrinsic to an Open

[libclc] r356020 - Move binary_intrinsic.h to private headers.

2019-03-13 Thread Jan Vesely via cfe-commits
Author: jvesely
Date: Wed Mar 13 00:06:15 2019
New Revision: 356020

URL: http://llvm.org/viewvc/llvm-project?rev=356020&view=rev
Log:
Move binary_intrinsic.h to private headers.

Reviewer: Aaron Watry
Signed-off-by: Jan Vesely 

Added:
libclc/trunk/generic/include/math/binary_intrin.inc
  - copied, changed from r356019, 
libclc/trunk/generic/include/clc/math/binary_intrin.inc
Removed:
libclc/trunk/generic/include/clc/math/binary_intrin.inc

Removed: libclc/trunk/generic/include/clc/math/binary_intrin.inc
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/math/binary_intrin.inc?rev=356019&view=auto
==
--- libclc/trunk/generic/include/clc/math/binary_intrin.inc (original)
+++ libclc/trunk/generic/include/clc/math/binary_intrin.inc (removed)
@@ -1,29 +0,0 @@
-_CLC_OVERLOAD float __CLC_FUNCTION(float, float) __asm(__CLC_INTRINSIC ".f32");
-_CLC_OVERLOAD float2 __CLC_FUNCTION(float2, float2) __asm(__CLC_INTRINSIC 
".v2f32");
-_CLC_OVERLOAD float3 __CLC_FUNCTION(float3, float3) __asm(__CLC_INTRINSIC 
".v3f32");
-_CLC_OVERLOAD float4 __CLC_FUNCTION(float4, float4) __asm(__CLC_INTRINSIC 
".v4f32");
-_CLC_OVERLOAD float8 __CLC_FUNCTION(float8, float8) __asm(__CLC_INTRINSIC 
".v8f32");
-_CLC_OVERLOAD float16 __CLC_FUNCTION(float16, float16) __asm(__CLC_INTRINSIC 
".v16f32");
-
-#ifdef cl_khr_fp64
-#pragma OPENCL EXTENSION cl_khr_fp64 : enable
-_CLC_OVERLOAD double __CLC_FUNCTION(double, double) __asm(__CLC_INTRINSIC 
".f64");
-_CLC_OVERLOAD double2 __CLC_FUNCTION(double2, double2) __asm(__CLC_INTRINSIC 
".v2f64");
-_CLC_OVERLOAD double3 __CLC_FUNCTION(double3, double3) __asm(__CLC_INTRINSIC 
".v3f64");
-_CLC_OVERLOAD double4 __CLC_FUNCTION(double4, double4) __asm(__CLC_INTRINSIC 
".v4f64");
-_CLC_OVERLOAD double8 __CLC_FUNCTION(double8, double8) __asm(__CLC_INTRINSIC 
".v8f64");
-_CLC_OVERLOAD double16 __CLC_FUNCTION(double16, double16) 
__asm(__CLC_INTRINSIC ".v16f64");
-#endif
-
-#ifdef cl_khr_fp16
-#pragma OPENCL EXTENSION cl_khr_fp16 : enable
-_CLC_OVERLOAD half __CLC_FUNCTION(half, half) __asm(__CLC_INTRINSIC ".f16");
-_CLC_OVERLOAD half2 __CLC_FUNCTION(half2, half2) __asm(__CLC_INTRINSIC 
".v2f16");
-_CLC_OVERLOAD half3 __CLC_FUNCTION(half3, half3) __asm(__CLC_INTRINSIC 
".v3f16");
-_CLC_OVERLOAD half4 __CLC_FUNCTION(half4, half4) __asm(__CLC_INTRINSIC 
".v4f16");
-_CLC_OVERLOAD half8 __CLC_FUNCTION(half8, half8) __asm(__CLC_INTRINSIC 
".v8f16");
-_CLC_OVERLOAD half16 __CLC_FUNCTION(half16, half16) __asm(__CLC_INTRINSIC 
".v16f16");
-#endif
-
-#undef __CLC_FUNCTION
-#undef __CLC_INTRINSIC

Copied: libclc/trunk/generic/include/math/binary_intrin.inc (from r356019, 
libclc/trunk/generic/include/clc/math/binary_intrin.inc)
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/math/binary_intrin.inc?p2=libclc/trunk/generic/include/math/binary_intrin.inc&p1=libclc/trunk/generic/include/clc/math/binary_intrin.inc&r1=356019&r2=356020&rev=356020&view=diff
==
(empty)


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


[libclc] r356022 - hypot: Use binary_decl_tt.inc instead of custom inc file

2019-03-13 Thread Jan Vesely via cfe-commits
Author: jvesely
Date: Wed Mar 13 00:13:22 2019
New Revision: 356022

URL: http://llvm.org/viewvc/llvm-project?rev=356022&view=rev
Log:
hypot: Use binary_decl_tt.inc instead of custom inc file

Reviewer: Aaron Watry
Signed-off-by: Jan Vesely 

Removed:
libclc/trunk/generic/include/clc/math/hypot.inc
Modified:
libclc/trunk/generic/include/clc/math/hypot.h

Modified: libclc/trunk/generic/include/clc/math/hypot.h
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/math/hypot.h?rev=356022&r1=356021&r2=356022&view=diff
==
--- libclc/trunk/generic/include/clc/math/hypot.h (original)
+++ libclc/trunk/generic/include/clc/math/hypot.h Wed Mar 13 00:13:22 2019
@@ -1,2 +1,7 @@
-#define __CLC_BODY 
+#define __CLC_FUNCTION hypot
+#define __CLC_BODY 
+
 #include 
+
+#undef __CLC_BODY
+#undef __CLC_FUNCTION

Removed: libclc/trunk/generic/include/clc/math/hypot.inc
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/math/hypot.inc?rev=356021&view=auto
==
--- libclc/trunk/generic/include/clc/math/hypot.inc (original)
+++ libclc/trunk/generic/include/clc/math/hypot.inc (removed)
@@ -1 +0,0 @@
-_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE hypot(__CLC_GENTYPE x, __CLC_GENTYPE y);


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


[libclc] r356026 - nextafter: Use binary_decl_tt.inc instead of custom inc file.

2019-03-13 Thread Jan Vesely via cfe-commits
Author: jvesely
Date: Wed Mar 13 00:13:30 2019
New Revision: 356026

URL: http://llvm.org/viewvc/llvm-project?rev=356026&view=rev
Log:
nextafter: Use binary_decl_tt.inc instead of custom inc file.

Reviewer: Aaron Watry
Signed-off-by: Jan Vesely 

Removed:
libclc/trunk/generic/include/clc/math/nextafter.inc
Modified:
libclc/trunk/generic/include/clc/math/nextafter.h

Modified: libclc/trunk/generic/include/clc/math/nextafter.h
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/math/nextafter.h?rev=356026&r1=356025&r2=356026&view=diff
==
--- libclc/trunk/generic/include/clc/math/nextafter.h (original)
+++ libclc/trunk/generic/include/clc/math/nextafter.h Wed Mar 13 00:13:30 2019
@@ -1,2 +1,7 @@
-#define __CLC_BODY 
+#define __CLC_FUNCTION nextafter
+#define __CLC_BODY 
+
 #include 
+
+#undef __CLC_BODY
+#undef __CLC_FUNCTION

Removed: libclc/trunk/generic/include/clc/math/nextafter.inc
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/math/nextafter.inc?rev=356025&view=auto
==
--- libclc/trunk/generic/include/clc/math/nextafter.inc (original)
+++ libclc/trunk/generic/include/clc/math/nextafter.inc (removed)
@@ -1 +0,0 @@
-_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE nextafter(__CLC_GENTYPE a, __CLC_GENTYPE 
b);


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


[libclc] r356025 - copysign: Use binary_decl_tt.inc instead of custom inc file.

2019-03-13 Thread Jan Vesely via cfe-commits
Author: jvesely
Date: Wed Mar 13 00:13:28 2019
New Revision: 356025

URL: http://llvm.org/viewvc/llvm-project?rev=356025&view=rev
Log:
copysign: Use binary_decl_tt.inc instead of custom inc file.

Reviewer: Aaron Watry
Signed-off-by: Jan Vesely 

Removed:
libclc/trunk/generic/include/clc/math/copysign.inc
Modified:
libclc/trunk/generic/include/clc/math/copysign.h

Modified: libclc/trunk/generic/include/clc/math/copysign.h
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/math/copysign.h?rev=356025&r1=356024&r2=356025&view=diff
==
--- libclc/trunk/generic/include/clc/math/copysign.h (original)
+++ libclc/trunk/generic/include/clc/math/copysign.h Wed Mar 13 00:13:28 2019
@@ -1,2 +1,7 @@
-#define __CLC_BODY 
+#define __CLC_FUNCTION copysign
+#define __CLC_BODY 
+
 #include 
+
+#undef __CLC_BODY
+#undef __CLC_FUNCTION

Removed: libclc/trunk/generic/include/clc/math/copysign.inc
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/math/copysign.inc?rev=356024&view=auto
==
--- libclc/trunk/generic/include/clc/math/copysign.inc (original)
+++ libclc/trunk/generic/include/clc/math/copysign.inc (removed)
@@ -1 +0,0 @@
-_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE copysign(__CLC_GENTYPE a, __CLC_GENTYPE 
b);


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


[libclc] r356027 - fdim: Use binary_decl_tt.inc instead of custom inc file.

2019-03-13 Thread Jan Vesely via cfe-commits
Author: jvesely
Date: Wed Mar 13 00:13:32 2019
New Revision: 356027

URL: http://llvm.org/viewvc/llvm-project?rev=356027&view=rev
Log:
fdim: Use binary_decl_tt.inc instead of custom inc file.

Reviewer: Aaron Watry
Signed-off-by: Jan Vesely 

Removed:
libclc/trunk/generic/include/clc/math/fdim.inc
Modified:
libclc/trunk/generic/include/clc/math/fdim.h

Modified: libclc/trunk/generic/include/clc/math/fdim.h
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/math/fdim.h?rev=356027&r1=356026&r2=356027&view=diff
==
--- libclc/trunk/generic/include/clc/math/fdim.h (original)
+++ libclc/trunk/generic/include/clc/math/fdim.h Wed Mar 13 00:13:32 2019
@@ -1,2 +1,7 @@
-#define __CLC_BODY 
+#define __CLC_FUNCTION fdim
+#define __CLC_BODY 
+
 #include 
+
+#undef __CLC_BODY
+#undef __CLC_FUNCTION

Removed: libclc/trunk/generic/include/clc/math/fdim.inc
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/math/fdim.inc?rev=356026&view=auto
==
--- libclc/trunk/generic/include/clc/math/fdim.inc (original)
+++ libclc/trunk/generic/include/clc/math/fdim.inc (removed)
@@ -1 +0,0 @@
-_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE fdim(__CLC_GENTYPE a, __CLC_GENTYPE b);


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


[libclc] r356023 - atan2: Use binary_decl_tt.inc instead of custom inc file.

2019-03-13 Thread Jan Vesely via cfe-commits
Author: jvesely
Date: Wed Mar 13 00:13:24 2019
New Revision: 356023

URL: http://llvm.org/viewvc/llvm-project?rev=356023&view=rev
Log:
atan2: Use binary_decl_tt.inc instead of custom inc file.

Reviewer: Aaron Watry
Signed-off-by: Jan Vesely 

Removed:
libclc/trunk/generic/include/clc/math/atan2.inc
Modified:
libclc/trunk/generic/include/clc/math/atan2.h

Modified: libclc/trunk/generic/include/clc/math/atan2.h
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/math/atan2.h?rev=356023&r1=356022&r2=356023&view=diff
==
--- libclc/trunk/generic/include/clc/math/atan2.h (original)
+++ libclc/trunk/generic/include/clc/math/atan2.h Wed Mar 13 00:13:24 2019
@@ -20,5 +20,10 @@
  * THE SOFTWARE.
  */
 
-#define __CLC_BODY 
+#define __CLC_FUNCTION atan2
+#define __CLC_BODY 
+
 #include 
+
+#undef __CLC_BODY
+#undef __CLC_FUNCTION

Removed: libclc/trunk/generic/include/clc/math/atan2.inc
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/math/atan2.inc?rev=356022&view=auto
==
--- libclc/trunk/generic/include/clc/math/atan2.inc (original)
+++ libclc/trunk/generic/include/clc/math/atan2.inc (removed)
@@ -1,23 +0,0 @@
-/*
- * Copyright (c) 2014 Advanced Micro Devices, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to 
deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE atan2(__CLC_GENTYPE a, __CLC_GENTYPE b);


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


[libclc] r356024 - atan2pi: Use binary_decl_tt.inc instead of custom inc file.

2019-03-13 Thread Jan Vesely via cfe-commits
Author: jvesely
Date: Wed Mar 13 00:13:26 2019
New Revision: 356024

URL: http://llvm.org/viewvc/llvm-project?rev=356024&view=rev
Log:
atan2pi: Use binary_decl_tt.inc instead of custom inc file.

Reviewer: Aaron Watry
Signed-off-by: Jan Vesely 

Removed:
libclc/trunk/generic/include/clc/math/atan2pi.inc
Modified:
libclc/trunk/generic/include/clc/math/atan2pi.h

Modified: libclc/trunk/generic/include/clc/math/atan2pi.h
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/math/atan2pi.h?rev=356024&r1=356023&r2=356024&view=diff
==
--- libclc/trunk/generic/include/clc/math/atan2pi.h (original)
+++ libclc/trunk/generic/include/clc/math/atan2pi.h Wed Mar 13 00:13:26 2019
@@ -20,5 +20,10 @@
  * THE SOFTWARE.
  */
 
-#define __CLC_BODY 
+#define __CLC_FUNCTION atan2pi
+#define __CLC_BODY 
+
 #include 
+
+#undef __CLC_BODY
+#undef __CLC_FUNCTION

Removed: libclc/trunk/generic/include/clc/math/atan2pi.inc
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/math/atan2pi.inc?rev=356023&view=auto
==
--- libclc/trunk/generic/include/clc/math/atan2pi.inc (original)
+++ libclc/trunk/generic/include/clc/math/atan2pi.inc (removed)
@@ -1,23 +0,0 @@
-/*
- * Copyright (c) 2014, 2015 Advanced Micro Devices, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to 
deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE atan2pi(__CLC_GENTYPE x, __CLC_GENTYPE 
y);


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


[libclc] r356028 - sincos: Simplify declaration headers.

2019-03-13 Thread Jan Vesely via cfe-commits
Author: jvesely
Date: Wed Mar 13 00:13:34 2019
New Revision: 356028

URL: http://llvm.org/viewvc/llvm-project?rev=356028&view=rev
Log:
sincos: Simplify declaration headers.

This follows the same pattern as modf and fract.
Reviewer: Aaron Watry
Signed-off-by: Jan Vesely 

Modified:
libclc/trunk/generic/include/clc/math/sincos.inc

Modified: libclc/trunk/generic/include/clc/math/sincos.inc
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/math/sincos.inc?rev=356028&r1=356027&r2=356028&view=diff
==
--- libclc/trunk/generic/include/clc/math/sincos.inc (original)
+++ libclc/trunk/generic/include/clc/math/sincos.inc Wed Mar 13 00:13:34 2019
@@ -1,8 +1,3 @@
-#define __CLC_DECLARE_SINCOS(ADDRSPACE, TYPE) \
-  _CLC_OVERLOAD _CLC_DECL TYPE sincos (TYPE x, ADDRSPACE TYPE * cosval);
-
-__CLC_DECLARE_SINCOS(global, __CLC_GENTYPE)
-__CLC_DECLARE_SINCOS(local, __CLC_GENTYPE)
-__CLC_DECLARE_SINCOS(private, __CLC_GENTYPE)
-
-#undef __CLC_DECLARE_SINCOS
+ _CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE sincos (__CLC_GENTYPE x, global 
__CLC_GENTYPE * cosval);
+ _CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE sincos (__CLC_GENTYPE x, local 
__CLC_GENTYPE * cosval);
+ _CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE sincos (__CLC_GENTYPE x, private 
__CLC_GENTYPE * cosval);


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


[PATCH] D59264: [Driver] Support compiler-rt crtbegin.o/crtend.o for Linux

2019-03-13 Thread Petr Hosek via Phabricator via cfe-commits
phosek marked an inline comment as done.
phosek added inline comments.



Comment at: clang/lib/Driver/ToolChains/Gnu.cpp:563
+  crtend = Args.hasArg(options::OPT_shared) || IsPIE || IsStaticPIE ?
+  "crtend_shared" : "crtend";
+  CmdArgs.push_back(ToolChain.getCompilerRTArgString(

MaskRay wrote:
> phosek wrote:
> > MaskRay wrote:
> > > I believe `crtbegin.o` `crtend.o` should just work. It is not necessary 
> > > to use `crtbegin_shared.o` `crtend_shared.o`.
> > This is related to your comments on D28791, specifically that we should be 
> > using `crtbegin_shared.o` for `-shared` or `-pie` and `crtbegin.o` 
> > otherwise, is that not the case?
> Yes. I think we can rename `crtbegin_shared.o` to `crtbegin.o` and use it for 
> every configuration: `-no-pie` `-pie` `-shared` `-static` `-static -pie`.
We've checked the glibc implementation of `__cxa_finalize`. A nonzero 
`__dso_handle` has to match the value passed to `__cxa_atexit` but a zero 
`__dso_handle` matches every function registered. So it matters that DSO fini 
calls use `&__dso_handle` to match their registrations for the `dlclose` case, 
but it also matters that the main executable fini call use zero to run all the 
dtors at exit time. It's not clear it really needs to be that way, but it would 
affect how the dtors get run which might affect some use cases. Hence, I don't 
think we can combine `crtbegin.o` and `crtbegin_shared.o`.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59264/new/

https://reviews.llvm.org/D59264



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


[PATCH] D33841: [clang-tidy] redundant keyword check

2019-03-13 Thread Daniel Kolozsvari via Phabricator via cfe-commits
koldaniel updated this revision to Diff 190377.

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D33841/new/

https://reviews.llvm.org/D33841

Files:
  clang-tidy/readability/CMakeLists.txt
  clang-tidy/readability/ReadabilityTidyModule.cpp
  clang-tidy/readability/RedundantExternCheck.cpp
  clang-tidy/readability/RedundantExternCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/readability-redundant-extern.rst
  test/clang-tidy/readability-redundant-extern.cpp

Index: test/clang-tidy/readability-redundant-extern.cpp
===
--- /dev/null
+++ test/clang-tidy/readability-redundant-extern.cpp
@@ -0,0 +1,37 @@
+// RUN: %check_clang_tidy %s readability-redundant-extern %t
+
+extern int f();
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: redundant 'extern' keyword [readability-redundant-extern]
+// CHECK-FIXES: int f();
+
+extern int f() { return 0; }
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: redundant 'extern' keyword [readability-redundant-extern]
+// CHECK-FIXES: int f() { return 0; }
+
+extern "C" int g();
+
+extern "C" int g() { return 0; }
+
+extern "C++" int h();
+
+extern "C++" int h() { return 0; }
+
+inline extern void foo_inline();
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: redundant 'extern' keyword [readability-redundant-extern]
+// CHECK-FIXES: inline void foo_inline();
+
+#define FOO_EXTERN extern
+FOO_EXTERN void foo_macro_1();
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: redundant 'extern' keyword [readability-redundant-extern]
+
+#define FOO_INLINE inline
+FOO_INLINE extern void foo_macro_3();
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: redundant 'extern' keyword [readability-redundant-extern]
+
+#define FOO_EXTERN_INLINE inline extern
+FOO_EXTERN_INLINE void foo_macro_2();
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: redundant 'extern' keyword [readability-redundant-extern]
+
+void file_scope();
+
+void another_file_scope(int _extern);
Index: docs/clang-tidy/checks/readability-redundant-extern.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/readability-redundant-extern.rst
@@ -0,0 +1,13 @@
+.. title:: clang-tidy - readability-redundant-extern
+
+readability-redundant-extern
+
+
+Removes the redundant ``extern`` keywords from code.
+
+``extern`` is redundant in function declarations
+
+.. code-block:: c++
+
+  extern void h();
+
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -258,6 +258,7 @@
readability-non-const-parameter
readability-redundant-control-flow
readability-redundant-declaration
+   readability-redundant-extern
readability-redundant-function-ptr-dereference
readability-redundant-member-init
readability-redundant-preprocessor
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -117,6 +117,11 @@
   ` now supports `OverrideSpelling`
   and `FinalSpelling` options.
 
+- New :doc:`readability-redundant-extern
+  ` check.
+
+  Removes the redundant ``extern`` keywords.
+
 Improvements to include-fixer
 -
 
Index: clang-tidy/readability/RedundantExternCheck.h
===
--- /dev/null
+++ clang-tidy/readability/RedundantExternCheck.h
@@ -0,0 +1,34 @@
+//===--- RedundantExternCheck.h - clang-tidy *- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_REDUNDANT_EXTERN_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_REDUNDANT_EXTERN_H
+
+#include "../ClangTidy.h"
+
+namespace clang {
+namespace tidy {
+namespace readability {
+
+/// Finds redundant 'extern' keywords
+///
+/// For the user-facing documentation see:
+/// http://clang.llvm.org/extra/clang-tidy/checks/readability-redundant-extern.html
+class RedundantExternCheck : public ClangTidyCheck {
+public:
+  RedundantExternCheck(StringRef Name, ClangTidyContext *Context)
+  : ClangTidyCheck(Name, Context) {}
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+};
+
+} // namespace readability
+} // namespace tidy
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_REDUNDANT_EXTERN_H
Index: clang-tidy/readability/RedundantExternCheck.cpp
===
--- /dev/null
+++ clang-tidy/readabilit

[clang-tools-extra] r356029 - [clang-format] [PR25010] AllowShortIfStatementsOnASingleLine not working if an "else" statement is present

2019-03-13 Thread Paul Hoad via cfe-commits
Author: paulhoad
Date: Wed Mar 13 01:07:46 2019
New Revision: 356029

URL: http://llvm.org/viewvc/llvm-project?rev=356029&view=rev
Log:
[clang-format] [PR25010] AllowShortIfStatementsOnASingleLine not working if an 
"else" statement is present

Summary:
Addressing: PR25010 - https://bugs.llvm.org/show_bug.cgi?id=25010

Code like:

```
if(true) var++;
else  {
var--;
}
```

is reformatted to be

```
  if (true)
var++;
  else {
var--;
  }
```

Even when `AllowShortIfStatementsOnASingleLine` is true

The following revision comes from a +1'd suggestion in the PR to support 
AllowShortIfElseStatementsOnASingleLine

This suppresses the clause prevents the merging of the if when there is a 
compound else

Reviewers: klimek, djasper, JonasToth, alexfh, krasimir, reuk
Reviewed By: reuk
Subscribers: reuk, Higuoxing, jdoerfert, cfe-commits
Tags: #clang-tools-extra
Differential Revision: https://reviews.llvm.org/D59087

Modified:

clang-tools-extra/trunk/docs/clang-tidy/checks/readability-identifier-naming.rst
clang-tools-extra/trunk/docs/conf.py

Modified: 
clang-tools-extra/trunk/docs/clang-tidy/checks/readability-identifier-naming.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/readability-identifier-naming.rst?rev=356029&r1=356028&r2=356029&view=diff
==
--- 
clang-tools-extra/trunk/docs/clang-tidy/checks/readability-identifier-naming.rst
 (original)
+++ 
clang-tools-extra/trunk/docs/clang-tidy/checks/readability-identifier-naming.rst
 Wed Mar 13 01:07:46 2019
@@ -9,7 +9,7 @@ This check will try to enforce coding gu
 supports one of the following casing types and tries to convert from one to
 another if a mismatch is detected
 
-Casing types inclde:
+Casing types include:
 
  - ``lower_case``,
  - ``UPPER_CASE``,

Modified: clang-tools-extra/trunk/docs/conf.py
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/conf.py?rev=356029&r1=356028&r2=356029&view=diff
==
--- clang-tools-extra/trunk/docs/conf.py (original)
+++ clang-tools-extra/trunk/docs/conf.py Wed Mar 13 01:07:46 2019
@@ -26,7 +26,7 @@ from datetime import date
 
 # Add any Sphinx extension module names here, as strings. They can be 
extensions
 # coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
-extensions = ['sphinx.ext.todo', 'sphinx.ext.mathjax']
+extensions = ['sphinx.ext.todo', 'sphinx.ext.mathjax', 
'sphinxcontrib.spelling' ]
 
 # Add any paths that contain templates here, relative to this directory.
 templates_path = ['_templates']


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


r356029 - [clang-format] [PR25010] AllowShortIfStatementsOnASingleLine not working if an "else" statement is present

2019-03-13 Thread Paul Hoad via cfe-commits
Author: paulhoad
Date: Wed Mar 13 01:07:46 2019
New Revision: 356029

URL: http://llvm.org/viewvc/llvm-project?rev=356029&view=rev
Log:
[clang-format] [PR25010] AllowShortIfStatementsOnASingleLine not working if an 
"else" statement is present

Summary:
Addressing: PR25010 - https://bugs.llvm.org/show_bug.cgi?id=25010

Code like:

```
if(true) var++;
else  {
var--;
}
```

is reformatted to be

```
  if (true)
var++;
  else {
var--;
  }
```

Even when `AllowShortIfStatementsOnASingleLine` is true

The following revision comes from a +1'd suggestion in the PR to support 
AllowShortIfElseStatementsOnASingleLine

This suppresses the clause prevents the merging of the if when there is a 
compound else

Reviewers: klimek, djasper, JonasToth, alexfh, krasimir, reuk
Reviewed By: reuk
Subscribers: reuk, Higuoxing, jdoerfert, cfe-commits
Tags: #clang-tools-extra
Differential Revision: https://reviews.llvm.org/D59087

Modified:
cfe/trunk/docs/ClangFormatStyleOptions.rst
cfe/trunk/include/clang/Format/Format.h
cfe/trunk/lib/Format/Format.cpp
cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp
cfe/trunk/unittests/Format/FormatTest.cpp
cfe/trunk/unittests/Format/FormatTestSelective.cpp

Modified: cfe/trunk/docs/ClangFormatStyleOptions.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ClangFormatStyleOptions.rst?rev=356029&r1=356028&r2=356029&view=diff
==
--- cfe/trunk/docs/ClangFormatStyleOptions.rst (original)
+++ cfe/trunk/docs/ClangFormatStyleOptions.rst Wed Mar 13 01:07:46 2019
@@ -365,10 +365,47 @@ the configuration (without a prefix: ``A
   };
   void f() { bar(); }
 
+**AllowShortIfStatementsOnASingleLine** (``ShortIfStyle``)
+  Dependent on the value, ``if (a) return 0;`` can be put on a
+  single line.
 
+  Possible values:
 
-**AllowShortIfStatementsOnASingleLine** (``bool``)
-  If ``true``, ``if (a) return;`` can be put on a single line.
+  * ``SIS_Never`` (in configuration: ``Never``)
+Do not allow short if functions.
+
+.. code-block:: c++
+
+   if (a)
+ return;
+   else
+ return;
+
+  * ``SIS_WithoutElse`` (in configuration: ``WithoutElse``)
+Allow short if functions on the same line, as long as else
+is not a compound statement.
+
+.. code-block:: c++
+
+   if (a) return;
+   else
+ return;
+
+   if (a)
+ return;
+   else {
+ return;
+   }
+
+  * ``SIS_Always`` (in configuration: ``Always``)
+Allow short if statements even if the else is a compound statement.
+
+.. code-block:: c++
+
+   if (a) return;
+   else {
+  return;
+   }
 
 **AllowShortLoopsOnASingleLine** (``bool``)
   If ``true``, ``while (true) continue;`` can be put on a single

Modified: cfe/trunk/include/clang/Format/Format.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Format/Format.h?rev=356029&r1=356028&r2=356029&view=diff
==
--- cfe/trunk/include/clang/Format/Format.h (original)
+++ cfe/trunk/include/clang/Format/Format.h Wed Mar 13 01:07:46 2019
@@ -241,8 +241,38 @@ struct FormatStyle {
   /// single line.
   ShortFunctionStyle AllowShortFunctionsOnASingleLine;
 
+  /// Different styles for handling short if lines
+  enum ShortIfStyle {
+/// Never put short ifs on the same line.
+/// \code
+///   if (a)
+/// return ;
+///   else {
+/// return;
+///   }
+/// \endcode
+SIS_Never,
+/// Without else put short ifs on the same line only if
+/// the else is not a compound statement.
+/// \code
+///   if (a) return;
+///   else
+/// return;
+/// \endcode
+SIS_WithoutElse,
+/// Always put short ifs on the same line if
+/// the else is not a compound statement or not.
+/// \code
+///   if (a) return;
+///   else {
+/// return;
+///   }
+/// \endcode
+SIS_Always,
+  };
+
   /// If ``true``, ``if (a) return;`` can be put on a single line.
-  bool AllowShortIfStatementsOnASingleLine;
+  ShortIfStyle AllowShortIfStatementsOnASingleLine;
 
   /// If ``true``, ``while (true) continue;`` can be put on a single
   /// line.

Modified: cfe/trunk/lib/Format/Format.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=356029&r1=356028&r2=356029&view=diff
==
--- cfe/trunk/lib/Format/Format.cpp (original)
+++ cfe/trunk/lib/Format/Format.cpp Wed Mar 13 01:07:46 2019
@@ -106,6 +106,18 @@ template <> struct ScalarEnumerationTrai
   }
 };
 
+template <> struct ScalarEnumerationTraits {
+  static void enumeration(IO &IO, FormatStyle::ShortIfStyle &Value) {
+IO.enumCase(Value, "Never", FormatStyle::SIS_Never);
+IO.enumCase(Value, "Always", FormatStyle::SIS_Always);
+IO.enumCase(Value

[PATCH] D59087: [clang-format] [PR25010] AllowShortIfStatementsOnASingleLine not working if an "else" statement is present

2019-03-13 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL356029: [clang-format] [PR25010] 
AllowShortIfStatementsOnASingleLine not working if an… (authored by paulhoad, 
committed by ).
Herald added a reviewer: serge-sans-paille.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D59087?vs=190351&id=190378#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59087/new/

https://reviews.llvm.org/D59087

Files:
  cfe/trunk/docs/ClangFormatStyleOptions.rst
  cfe/trunk/include/clang/Format/Format.h
  cfe/trunk/lib/Format/Format.cpp
  cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp
  cfe/trunk/unittests/Format/FormatTest.cpp
  cfe/trunk/unittests/Format/FormatTestSelective.cpp
  
clang-tools-extra/trunk/docs/clang-tidy/checks/readability-identifier-naming.rst
  clang-tools-extra/trunk/docs/conf.py
  llvm/trunk/utils/release/build_llvm_package.bat

Index: llvm/trunk/utils/release/build_llvm_package.bat
===
--- llvm/trunk/utils/release/build_llvm_package.bat
+++ llvm/trunk/utils/release/build_llvm_package.bat
@@ -42,13 +42,13 @@
 cd %build_dir%
 
 echo Checking out %branch% at r%revision%...
-svn.exe export -r %revision% http://llvm.org/svn/llvm-project/llvm/%branch% llvm || exit /b
-svn.exe export -r %revision% http://llvm.org/svn/llvm-project/cfe/%branch% llvm/tools/clang || exit /b
-svn.exe export -r %revision% http://llvm.org/svn/llvm-project/clang-tools-extra/%branch% llvm/tools/clang/tools/extra || exit /b
-svn.exe export -r %revision% http://llvm.org/svn/llvm-project/lld/%branch% llvm/tools/lld || exit /b
-svn.exe export -r %revision% http://llvm.org/svn/llvm-project/compiler-rt/%branch% llvm/projects/compiler-rt || exit /b
-svn.exe export -r %revision% http://llvm.org/svn/llvm-project/openmp/%branch% llvm/projects/openmp || exit /b
-svn.exe export -r %revision% http://llvm.org/svn/llvm-project/lldb/%branch% llvm/tools/lldb || exit /b
+REM svn.exe export -r %revision% http://llvm.org/svn/llvm-project/llvm/%branch% llvm || exit /b
+REM svn.exe export -r %revision% http://llvm.org/svn/llvm-project/cfe/%branch% llvm/tools/clang || exit /b
+REM svn.exe export -r %revision% http://llvm.org/svn/llvm-project/clang-tools-extra/%branch% llvm/tools/clang/tools/extra || exit /b
+REM svn.exe export -r %revision% http://llvm.org/svn/llvm-project/lld/%branch% llvm/tools/lld || exit /b
+REM svn.exe export -r %revision% http://llvm.org/svn/llvm-project/compiler-rt/%branch% llvm/projects/compiler-rt || exit /b
+REM svn.exe export -r %revision% http://llvm.org/svn/llvm-project/openmp/%branch% llvm/projects/openmp || exit /b
+REM svn.exe export -r %revision% http://llvm.org/svn/llvm-project/lldb/%branch% llvm/tools/lldb || exit /b
 
 
 REM Setting CMAKE_CL_SHOWINCLUDES_PREFIX to work around PR27226.
Index: cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp
===
--- cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp
+++ cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp
@@ -413,10 +413,12 @@
 if (I[1]->First->isOneOf(tok::semi, tok::kw_if, tok::kw_for, tok::kw_while,
  TT_LineComment))
   return 0;
-// Only inline simple if's (no nested if or else).
-if (I + 2 != E && Line.startsWith(tok::kw_if) &&
-I[2]->First->is(tok::kw_else))
-  return 0;
+// Only inline simple if's (no nested if or else), unless specified
+if (Style.AllowShortIfStatementsOnASingleLine != FormatStyle::SIS_Always) {
+  if (I + 2 != E && Line.startsWith(tok::kw_if) &&
+  I[2]->First->is(tok::kw_else))
+return 0;
+}
 return 1;
   }
 
Index: cfe/trunk/lib/Format/Format.cpp
===
--- cfe/trunk/lib/Format/Format.cpp
+++ cfe/trunk/lib/Format/Format.cpp
@@ -106,6 +106,18 @@
   }
 };
 
+template <> struct ScalarEnumerationTraits {
+  static void enumeration(IO &IO, FormatStyle::ShortIfStyle &Value) {
+IO.enumCase(Value, "Never", FormatStyle::SIS_Never);
+IO.enumCase(Value, "Always", FormatStyle::SIS_Always);
+IO.enumCase(Value, "WithoutElse", FormatStyle::SIS_WithoutElse);
+
+// For backward compatibility.
+IO.enumCase(Value, "false", FormatStyle::SIS_Never);
+IO.enumCase(Value, "true", FormatStyle::SIS_WithoutElse);
+  }
+};
+
 template <> struct ScalarEnumerationTraits {
   static void enumeration(IO &IO, FormatStyle::BinPackStyle &Value) {
 IO.enumCase(Value, "Auto", FormatStyle::BPS_Auto);
@@ -631,7 +643,7 @@
   LLVMStyle.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_All;
   LLVMStyle.AllowShortBlocksOnASingleLine = false;
   LLVMStyle.AllowShortCaseLabelsOnASingleLine = false;
-  LLVMStyle.AllowShortIfStatementsOnASingleLine = false;
+  LLVMStyle.AllowShortIfStatementsOnASingleLine = FormatStyle::SIS_Never;
   LLVMStyle.All

r356030 - Revert "[clang-format] [PR25010] AllowShortIfStatementsOnASingleLine not working if an "else" statement is present"

2019-03-13 Thread Paul Hoad via cfe-commits
Author: paulhoad
Date: Wed Mar 13 01:15:03 2019
New Revision: 356030

URL: http://llvm.org/viewvc/llvm-project?rev=356030&view=rev
Log:
Revert "[clang-format] [PR25010] AllowShortIfStatementsOnASingleLine not 
working if an "else" statement is present"

This reverts commit b358cbb9b78389e20f7be36e1a98e26515c3ecce.

Modified:
cfe/trunk/docs/ClangFormatStyleOptions.rst
cfe/trunk/include/clang/Format/Format.h
cfe/trunk/lib/Format/Format.cpp
cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp
cfe/trunk/unittests/Format/FormatTest.cpp
cfe/trunk/unittests/Format/FormatTestSelective.cpp

Modified: cfe/trunk/docs/ClangFormatStyleOptions.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ClangFormatStyleOptions.rst?rev=356030&r1=356029&r2=356030&view=diff
==
--- cfe/trunk/docs/ClangFormatStyleOptions.rst (original)
+++ cfe/trunk/docs/ClangFormatStyleOptions.rst Wed Mar 13 01:15:03 2019
@@ -365,47 +365,10 @@ the configuration (without a prefix: ``A
   };
   void f() { bar(); }
 
-**AllowShortIfStatementsOnASingleLine** (``ShortIfStyle``)
-  Dependent on the value, ``if (a) return 0;`` can be put on a
-  single line.
 
-  Possible values:
 
-  * ``SIS_Never`` (in configuration: ``Never``)
-Do not allow short if functions.
-
-.. code-block:: c++
-
-   if (a)
- return;
-   else
- return;
-
-  * ``SIS_WithoutElse`` (in configuration: ``WithoutElse``)
-Allow short if functions on the same line, as long as else
-is not a compound statement.
-
-.. code-block:: c++
-
-   if (a) return;
-   else
- return;
-
-   if (a)
- return;
-   else {
- return;
-   }
-
-  * ``SIS_Always`` (in configuration: ``Always``)
-Allow short if statements even if the else is a compound statement.
-
-.. code-block:: c++
-
-   if (a) return;
-   else {
-  return;
-   }
+**AllowShortIfStatementsOnASingleLine** (``bool``)
+  If ``true``, ``if (a) return;`` can be put on a single line.
 
 **AllowShortLoopsOnASingleLine** (``bool``)
   If ``true``, ``while (true) continue;`` can be put on a single

Modified: cfe/trunk/include/clang/Format/Format.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Format/Format.h?rev=356030&r1=356029&r2=356030&view=diff
==
--- cfe/trunk/include/clang/Format/Format.h (original)
+++ cfe/trunk/include/clang/Format/Format.h Wed Mar 13 01:15:03 2019
@@ -241,38 +241,8 @@ struct FormatStyle {
   /// single line.
   ShortFunctionStyle AllowShortFunctionsOnASingleLine;
 
-  /// Different styles for handling short if lines
-  enum ShortIfStyle {
-/// Never put short ifs on the same line.
-/// \code
-///   if (a)
-/// return ;
-///   else {
-/// return;
-///   }
-/// \endcode
-SIS_Never,
-/// Without else put short ifs on the same line only if
-/// the else is not a compound statement.
-/// \code
-///   if (a) return;
-///   else
-/// return;
-/// \endcode
-SIS_WithoutElse,
-/// Always put short ifs on the same line if
-/// the else is not a compound statement or not.
-/// \code
-///   if (a) return;
-///   else {
-/// return;
-///   }
-/// \endcode
-SIS_Always,
-  };
-
   /// If ``true``, ``if (a) return;`` can be put on a single line.
-  ShortIfStyle AllowShortIfStatementsOnASingleLine;
+  bool AllowShortIfStatementsOnASingleLine;
 
   /// If ``true``, ``while (true) continue;`` can be put on a single
   /// line.

Modified: cfe/trunk/lib/Format/Format.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=356030&r1=356029&r2=356030&view=diff
==
--- cfe/trunk/lib/Format/Format.cpp (original)
+++ cfe/trunk/lib/Format/Format.cpp Wed Mar 13 01:15:03 2019
@@ -106,18 +106,6 @@ template <> struct ScalarEnumerationTrai
   }
 };
 
-template <> struct ScalarEnumerationTraits {
-  static void enumeration(IO &IO, FormatStyle::ShortIfStyle &Value) {
-IO.enumCase(Value, "Never", FormatStyle::SIS_Never);
-IO.enumCase(Value, "Always", FormatStyle::SIS_Always);
-IO.enumCase(Value, "WithoutElse", FormatStyle::SIS_WithoutElse);
-
-// For backward compatibility.
-IO.enumCase(Value, "false", FormatStyle::SIS_Never);
-IO.enumCase(Value, "true", FormatStyle::SIS_WithoutElse);
-  }
-};
-
 template <> struct ScalarEnumerationTraits {
   static void enumeration(IO &IO, FormatStyle::BinPackStyle &Value) {
 IO.enumCase(Value, "Auto", FormatStyle::BPS_Auto);
@@ -643,7 +631,7 @@ FormatStyle getLLVMStyle(FormatStyle::La
   LLVMStyle.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_All;
   LLVMStyle.AllowShortBlocksOnASingleLine = false;
   LLVMStyle.AllowShortCaseLabelsOnASingleLine = false;
- 

[clang-tools-extra] r356030 - Revert "[clang-format] [PR25010] AllowShortIfStatementsOnASingleLine not working if an "else" statement is present"

2019-03-13 Thread Paul Hoad via cfe-commits
Author: paulhoad
Date: Wed Mar 13 01:15:03 2019
New Revision: 356030

URL: http://llvm.org/viewvc/llvm-project?rev=356030&view=rev
Log:
Revert "[clang-format] [PR25010] AllowShortIfStatementsOnASingleLine not 
working if an "else" statement is present"

This reverts commit b358cbb9b78389e20f7be36e1a98e26515c3ecce.

Modified:

clang-tools-extra/trunk/docs/clang-tidy/checks/readability-identifier-naming.rst
clang-tools-extra/trunk/docs/conf.py

Modified: 
clang-tools-extra/trunk/docs/clang-tidy/checks/readability-identifier-naming.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/readability-identifier-naming.rst?rev=356030&r1=356029&r2=356030&view=diff
==
--- 
clang-tools-extra/trunk/docs/clang-tidy/checks/readability-identifier-naming.rst
 (original)
+++ 
clang-tools-extra/trunk/docs/clang-tidy/checks/readability-identifier-naming.rst
 Wed Mar 13 01:15:03 2019
@@ -9,7 +9,7 @@ This check will try to enforce coding gu
 supports one of the following casing types and tries to convert from one to
 another if a mismatch is detected
 
-Casing types include:
+Casing types inclde:
 
  - ``lower_case``,
  - ``UPPER_CASE``,

Modified: clang-tools-extra/trunk/docs/conf.py
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/conf.py?rev=356030&r1=356029&r2=356030&view=diff
==
--- clang-tools-extra/trunk/docs/conf.py (original)
+++ clang-tools-extra/trunk/docs/conf.py Wed Mar 13 01:15:03 2019
@@ -26,7 +26,7 @@ from datetime import date
 
 # Add any Sphinx extension module names here, as strings. They can be 
extensions
 # coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
-extensions = ['sphinx.ext.todo', 'sphinx.ext.mathjax', 
'sphinxcontrib.spelling' ]
+extensions = ['sphinx.ext.todo', 'sphinx.ext.mathjax']
 
 # Add any paths that contain templates here, relative to this directory.
 templates_path = ['_templates']


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


[PATCH] D56370: [clangd] Add support for type hierarchy (super types only for now)

2019-03-13 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

In D56370#1427075 , @nridge wrote:

> Ok, I filed a Theia issue  
> about it for now.


Thanks!

In D56370#1427076 , @nridge wrote:

> Are these tests written manually, or with the help or some kind of tool?


Yes unfortunately :(

Thanks for moving the tests!




Comment at: clang-tools-extra/test/clangd/type-hierarchy.test:1
+# RUN: clangd -lit-test < %s | FileCheck -strict-whitespace %s
+{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}

why strict-whitespace?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56370/new/

https://reviews.llvm.org/D56370



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


r356031 - [clang-format] [PR25010] AllowShortIfStatementsOnASingleLine not working if an "else" statement is present

2019-03-13 Thread Paul Hoad via cfe-commits
Author: paulhoad
Date: Wed Mar 13 01:26:39 2019
New Revision: 356031

URL: http://llvm.org/viewvc/llvm-project?rev=356031&view=rev
Log:
[clang-format] [PR25010] AllowShortIfStatementsOnASingleLine not working if an 
"else" statement is present

Summary:
Addressing: PR25010 - https://bugs.llvm.org/show_bug.cgi?id=25010

Code like:

```
if(true) var++;
else  {
var--;
}
```

is reformatted to be

```
  if (true)
var++;
  else {
var--;
  }
```

Even when `AllowShortIfStatementsOnASingleLine` is true

The following revision comes from a +1'd suggestion in the PR to support 
AllowShortIfElseStatementsOnASingleLine

This suppresses the clause prevents the merging of the if when there is a 
compound else

Reviewers: klimek, djasper, JonasToth, alexfh, krasimir, reuk
Reviewed By: reuk
Subscribers: reuk, Higuoxing, jdoerfert, cfe-commits
Tags: #clang-tools-extra
Differential Revision: https://reviews.llvm.org/D59087

Modified:
cfe/trunk/docs/ClangFormatStyleOptions.rst
cfe/trunk/include/clang/Format/Format.h
cfe/trunk/lib/Format/Format.cpp
cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp
cfe/trunk/unittests/Format/FormatTest.cpp
cfe/trunk/unittests/Format/FormatTestSelective.cpp

Modified: cfe/trunk/docs/ClangFormatStyleOptions.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ClangFormatStyleOptions.rst?rev=356031&r1=356030&r2=356031&view=diff
==
--- cfe/trunk/docs/ClangFormatStyleOptions.rst (original)
+++ cfe/trunk/docs/ClangFormatStyleOptions.rst Wed Mar 13 01:26:39 2019
@@ -365,10 +365,47 @@ the configuration (without a prefix: ``A
   };
   void f() { bar(); }
 
+**AllowShortIfStatementsOnASingleLine** (``ShortIfStyle``)
+  Dependent on the value, ``if (a) return 0;`` can be put on a
+  single line.
 
+  Possible values:
 
-**AllowShortIfStatementsOnASingleLine** (``bool``)
-  If ``true``, ``if (a) return;`` can be put on a single line.
+  * ``SIS_Never`` (in configuration: ``Never``)
+Do not allow short if functions.
+
+.. code-block:: c++
+
+   if (a)
+ return;
+   else
+ return;
+
+  * ``SIS_WithoutElse`` (in configuration: ``WithoutElse``)
+Allow short if functions on the same line, as long as else
+is not a compound statement.
+
+.. code-block:: c++
+
+   if (a) return;
+   else
+ return;
+
+   if (a)
+ return;
+   else {
+ return;
+   }
+
+  * ``SIS_Always`` (in configuration: ``Always``)
+Allow short if statements even if the else is a compound statement.
+
+.. code-block:: c++
+
+   if (a) return;
+   else {
+  return;
+   }
 
 **AllowShortLoopsOnASingleLine** (``bool``)
   If ``true``, ``while (true) continue;`` can be put on a single

Modified: cfe/trunk/include/clang/Format/Format.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Format/Format.h?rev=356031&r1=356030&r2=356031&view=diff
==
--- cfe/trunk/include/clang/Format/Format.h (original)
+++ cfe/trunk/include/clang/Format/Format.h Wed Mar 13 01:26:39 2019
@@ -241,8 +241,38 @@ struct FormatStyle {
   /// single line.
   ShortFunctionStyle AllowShortFunctionsOnASingleLine;
 
+  /// Different styles for handling short if lines
+  enum ShortIfStyle {
+/// Never put short ifs on the same line.
+/// \code
+///   if (a)
+/// return ;
+///   else {
+/// return;
+///   }
+/// \endcode
+SIS_Never,
+/// Without else put short ifs on the same line only if
+/// the else is not a compound statement.
+/// \code
+///   if (a) return;
+///   else
+/// return;
+/// \endcode
+SIS_WithoutElse,
+/// Always put short ifs on the same line if
+/// the else is not a compound statement or not.
+/// \code
+///   if (a) return;
+///   else {
+/// return;
+///   }
+/// \endcode
+SIS_Always,
+  };
+
   /// If ``true``, ``if (a) return;`` can be put on a single line.
-  bool AllowShortIfStatementsOnASingleLine;
+  ShortIfStyle AllowShortIfStatementsOnASingleLine;
 
   /// If ``true``, ``while (true) continue;`` can be put on a single
   /// line.

Modified: cfe/trunk/lib/Format/Format.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=356031&r1=356030&r2=356031&view=diff
==
--- cfe/trunk/lib/Format/Format.cpp (original)
+++ cfe/trunk/lib/Format/Format.cpp Wed Mar 13 01:26:39 2019
@@ -106,6 +106,18 @@ template <> struct ScalarEnumerationTrai
   }
 };
 
+template <> struct ScalarEnumerationTraits {
+  static void enumeration(IO &IO, FormatStyle::ShortIfStyle &Value) {
+IO.enumCase(Value, "Never", FormatStyle::SIS_Never);
+IO.enumCase(Value, "Always", FormatStyle::SIS_Always);
+IO.enumCase(Value

[PATCH] D59087: [clang-format] [PR25010] AllowShortIfStatementsOnASingleLine not working if an "else" statement is present

2019-03-13 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL356031: [clang-format] [PR25010] 
AllowShortIfStatementsOnASingleLine not working if an… (authored by paulhoad, 
committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D59087?vs=190378&id=190379#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59087/new/

https://reviews.llvm.org/D59087

Files:
  cfe/trunk/docs/ClangFormatStyleOptions.rst
  cfe/trunk/include/clang/Format/Format.h
  cfe/trunk/lib/Format/Format.cpp
  cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp
  cfe/trunk/unittests/Format/FormatTest.cpp
  cfe/trunk/unittests/Format/FormatTestSelective.cpp

Index: cfe/trunk/unittests/Format/FormatTestSelective.cpp
===
--- cfe/trunk/unittests/Format/FormatTestSelective.cpp
+++ cfe/trunk/unittests/Format/FormatTestSelective.cpp
@@ -98,7 +98,7 @@
 }
 
 TEST_F(FormatTestSelective, FormatsIfWithoutCompoundStatement) {
-  Style.AllowShortIfStatementsOnASingleLine = true;
+  Style.AllowShortIfStatementsOnASingleLine = FormatStyle::SIS_WithoutElse;
   EXPECT_EQ("if (a) return;", format("if(a)\nreturn;", 7, 1));
   EXPECT_EQ("if (a) return; // comment",
 format("if(a)\nreturn; // comment", 20, 1));
Index: cfe/trunk/unittests/Format/FormatTest.cpp
===
--- cfe/trunk/unittests/Format/FormatTest.cpp
+++ cfe/trunk/unittests/Format/FormatTest.cpp
@@ -439,7 +439,8 @@
 
   FormatStyle AllowsMergedIf = getLLVMStyle();
   AllowsMergedIf.AlignEscapedNewlines = FormatStyle::ENAS_Left;
-  AllowsMergedIf.AllowShortIfStatementsOnASingleLine = true;
+  AllowsMergedIf.AllowShortIfStatementsOnASingleLine =
+  FormatStyle::SIS_WithoutElse;
   verifyFormat("if (a)\n"
"  // comment\n"
"  f();",
@@ -487,6 +488,41 @@
   verifyFormat("if (a)\n  return;", AllowsMergedIf);
 }
 
+TEST_F(FormatTest, FormatIfWithoutCompoundStatementButElseWith) {
+  FormatStyle AllowsMergedIf = getLLVMStyle();
+  AllowsMergedIf.AlignEscapedNewlines = FormatStyle::ENAS_Left;
+  AllowsMergedIf.AllowShortIfStatementsOnASingleLine =
+  FormatStyle::SIS_WithoutElse;
+  verifyFormat("if (a)\n"
+   "  f();\n"
+   "else {\n"
+   "  g();\n"
+   "}",
+   AllowsMergedIf);
+  verifyFormat("if (a)\n"
+   "  f();\n"
+   "else\n"
+   "  g();\n",
+   AllowsMergedIf);
+
+  AllowsMergedIf.AllowShortIfStatementsOnASingleLine = FormatStyle::SIS_Always;
+
+  verifyFormat("if (a) f();\n"
+   "else {\n"
+   "  g();\n"
+   "}",
+   AllowsMergedIf);
+  verifyFormat("if (a) f();\n"
+   "else {\n"
+   "  if (a) f();\n"
+   "  else {\n"
+   "g();\n"
+   "  }\n"
+   "  g();\n"
+   "}",
+   AllowsMergedIf);
+}
+
 TEST_F(FormatTest, FormatLoopsWithoutCompoundStatement) {
   FormatStyle AllowsMergedLoops = getLLVMStyle();
   AllowsMergedLoops.AllowShortLoopsOnASingleLine = true;
@@ -515,7 +551,8 @@
   AllowSimpleBracedStatements.ColumnLimit = 40;
   AllowSimpleBracedStatements.AllowShortBlocksOnASingleLine = true;
 
-  AllowSimpleBracedStatements.AllowShortIfStatementsOnASingleLine = true;
+  AllowSimpleBracedStatements.AllowShortIfStatementsOnASingleLine =
+  FormatStyle::SIS_WithoutElse;
   AllowSimpleBracedStatements.AllowShortLoopsOnASingleLine = true;
 
   AllowSimpleBracedStatements.BreakBeforeBraces = FormatStyle::BS_Custom;
@@ -563,7 +600,8 @@
"};",
AllowSimpleBracedStatements);
 
-  AllowSimpleBracedStatements.AllowShortIfStatementsOnASingleLine = false;
+  AllowSimpleBracedStatements.AllowShortIfStatementsOnASingleLine =
+  FormatStyle::SIS_Never;
   verifyFormat("if (true) {}", AllowSimpleBracedStatements);
   verifyFormat("if (true) {\n"
"  f();\n"
@@ -588,7 +626,8 @@
"}",
AllowSimpleBracedStatements);
 
-  AllowSimpleBracedStatements.AllowShortIfStatementsOnASingleLine = true;
+  AllowSimpleBracedStatements.AllowShortIfStatementsOnASingleLine =
+  FormatStyle::SIS_WithoutElse;
   AllowSimpleBracedStatements.AllowShortLoopsOnASingleLine = true;
   AllowSimpleBracedStatements.BraceWrapping.AfterControlStatement = true;
 
@@ -625,7 +664,8 @@
"}",
AllowSimpleBracedStatements);
 
-  AllowSimpleBracedStatements.AllowShortIfStatementsOnASingleLine = false;
+  AllowSimpleBracedStatements.AllowShortIfStatementsOnASingleLine =
+  FormatStyle::SIS_Never;
   verifyFormat("if (true) {}", AllowSimpleBracedStatements);
   verifyFormat("if (true)\n"
"{\n"
@@ -659,7 +699,7 @@
 TEST_F(FormatTest, ShortBlocksInMacrosDontMergeWithCodeAfterMacro) {
   FormatStyle Style = getLLVMStyleWithColum

[clang-tools-extra] r356032 - [clangd] Default initialize SymInfo

2019-03-13 Thread Kadir Cetinkaya via cfe-commits
Author: kadircet
Date: Wed Mar 13 01:42:15 2019
New Revision: 356032

URL: http://llvm.org/viewvc/llvm-project?rev=356032&view=rev
Log:
[clangd] Default initialize SymInfo

Modified:
clang-tools-extra/trunk/clangd/index/Symbol.h

Modified: clang-tools-extra/trunk/clangd/index/Symbol.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/Symbol.h?rev=356032&r1=356031&r2=356032&view=diff
==
--- clang-tools-extra/trunk/clangd/index/Symbol.h (original)
+++ clang-tools-extra/trunk/clangd/index/Symbol.h Wed Mar 13 01:42:15 2019
@@ -37,7 +37,7 @@ struct Symbol {
   /// The ID of the symbol.
   SymbolID ID;
   /// The symbol information, like symbol kind.
-  index::SymbolInfo SymInfo;
+  index::SymbolInfo SymInfo = index::SymbolInfo();
   /// The unqualified name of the symbol, e.g. "bar" (for ns::bar).
   llvm::StringRef Name;
   /// The containing namespace. e.g. "" (global), "ns::" (top-level namespace).


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


Re: r356031 - [clang-format] [PR25010] AllowShortIfStatementsOnASingleLine not working if an "else" statement is present

2019-03-13 Thread Roman Lebedev via cfe-commits
This was reviewed by someone already familiar with, and active with
the code in question?

On Wed, Mar 13, 2019 at 11:25 AM Paul Hoad via cfe-commits
 wrote:
>
> Author: paulhoad
> Date: Wed Mar 13 01:26:39 2019
> New Revision: 356031
>
> URL: http://llvm.org/viewvc/llvm-project?rev=356031&view=rev
> Log:
> [clang-format] [PR25010] AllowShortIfStatementsOnASingleLine not working if 
> an "else" statement is present
>
> Summary:
> Addressing: PR25010 - https://bugs.llvm.org/show_bug.cgi?id=25010
>
> Code like:
>
> ```
> if(true) var++;
> else  {
> var--;
> }
> ```
>
> is reformatted to be
>
> ```
>   if (true)
> var++;
>   else {
> var--;
>   }
> ```
>
> Even when `AllowShortIfStatementsOnASingleLine` is true
>
> The following revision comes from a +1'd suggestion in the PR to support 
> AllowShortIfElseStatementsOnASingleLine
>
> This suppresses the clause prevents the merging of the if when there is a 
> compound else
>
> Reviewers: klimek, djasper, JonasToth, alexfh, krasimir, reuk
> Reviewed By: reuk
> Subscribers: reuk, Higuoxing, jdoerfert, cfe-commits
> Tags: #clang-tools-extra
> Differential Revision: https://reviews.llvm.org/D59087
>
> Modified:
> cfe/trunk/docs/ClangFormatStyleOptions.rst
> cfe/trunk/include/clang/Format/Format.h
> cfe/trunk/lib/Format/Format.cpp
> cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp
> cfe/trunk/unittests/Format/FormatTest.cpp
> cfe/trunk/unittests/Format/FormatTestSelective.cpp
>
> Modified: cfe/trunk/docs/ClangFormatStyleOptions.rst
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ClangFormatStyleOptions.rst?rev=356031&r1=356030&r2=356031&view=diff
> ==
> --- cfe/trunk/docs/ClangFormatStyleOptions.rst (original)
> +++ cfe/trunk/docs/ClangFormatStyleOptions.rst Wed Mar 13 01:26:39 2019
> @@ -365,10 +365,47 @@ the configuration (without a prefix: ``A
>};
>void f() { bar(); }
>
> +**AllowShortIfStatementsOnASingleLine** (``ShortIfStyle``)
> +  Dependent on the value, ``if (a) return 0;`` can be put on a
> +  single line.
>
> +  Possible values:
>
> -**AllowShortIfStatementsOnASingleLine** (``bool``)
> -  If ``true``, ``if (a) return;`` can be put on a single line.
> +  * ``SIS_Never`` (in configuration: ``Never``)
> +Do not allow short if functions.
> +
> +.. code-block:: c++
> +
> +   if (a)
> + return;
> +   else
> + return;
> +
> +  * ``SIS_WithoutElse`` (in configuration: ``WithoutElse``)
> +Allow short if functions on the same line, as long as else
> +is not a compound statement.
> +
> +.. code-block:: c++
> +
> +   if (a) return;
> +   else
> + return;
> +
> +   if (a)
> + return;
> +   else {
> + return;
> +   }
> +
> +  * ``SIS_Always`` (in configuration: ``Always``)
> +Allow short if statements even if the else is a compound statement.
> +
> +.. code-block:: c++
> +
> +   if (a) return;
> +   else {
> +  return;
> +   }
>
>  **AllowShortLoopsOnASingleLine** (``bool``)
>If ``true``, ``while (true) continue;`` can be put on a single
>
> Modified: cfe/trunk/include/clang/Format/Format.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Format/Format.h?rev=356031&r1=356030&r2=356031&view=diff
> ==
> --- cfe/trunk/include/clang/Format/Format.h (original)
> +++ cfe/trunk/include/clang/Format/Format.h Wed Mar 13 01:26:39 2019
> @@ -241,8 +241,38 @@ struct FormatStyle {
>/// single line.
>ShortFunctionStyle AllowShortFunctionsOnASingleLine;
>
> +  /// Different styles for handling short if lines
> +  enum ShortIfStyle {
> +/// Never put short ifs on the same line.
> +/// \code
> +///   if (a)
> +/// return ;
> +///   else {
> +/// return;
> +///   }
> +/// \endcode
> +SIS_Never,
> +/// Without else put short ifs on the same line only if
> +/// the else is not a compound statement.
> +/// \code
> +///   if (a) return;
> +///   else
> +/// return;
> +/// \endcode
> +SIS_WithoutElse,
> +/// Always put short ifs on the same line if
> +/// the else is not a compound statement or not.
> +/// \code
> +///   if (a) return;
> +///   else {
> +/// return;
> +///   }
> +/// \endcode
> +SIS_Always,
> +  };
> +
>/// If ``true``, ``if (a) return;`` can be put on a single line.
> -  bool AllowShortIfStatementsOnASingleLine;
> +  ShortIfStyle AllowShortIfStatementsOnASingleLine;
>
>/// If ``true``, ``while (true) continue;`` can be put on a single
>/// line.
>
> Modified: cfe/trunk/lib/Format/Format.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=356031&r1=356030&r2=356031&view=diff
> =

[PATCH] D59083: [clangd] Store explicit template specializations in index for code navigation purposes

2019-03-13 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 190382.
kadircet marked an inline comment as done.
kadircet added a comment.

- Agree on ilya-biryukov@'s suggestion, changing fuzzyfind to skip template 
(partial) specializations for now.


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59083/new/

https://reviews.llvm.org/D59083

Files:
  clangd/CodeComplete.cpp
  clangd/index/MemIndex.cpp
  clangd/index/SymbolCollector.cpp
  clangd/index/dex/Dex.cpp
  unittests/clangd/DexTests.cpp
  unittests/clangd/IndexTests.cpp
  unittests/clangd/SymbolCollectorTests.cpp

Index: unittests/clangd/SymbolCollectorTests.cpp
===
--- unittests/clangd/SymbolCollectorTests.cpp
+++ unittests/clangd/SymbolCollectorTests.cpp
@@ -392,17 +392,25 @@
 
 TEST_F(SymbolCollectorTest, Template) {
   Annotations Header(R"(
-// Template is indexed, specialization and instantiation is not.
-template  struct [[Tmpl]] {T $xdecl[[x]] = 0;};
-template <> struct Tmpl {};
-extern template struct Tmpl;
-template struct Tmpl;
+// Primary template and explicit specialization are indexed, instantiation
+// is not.
+template  struct [[Tmpl]] {T $xdecl[[x]] = 0;};
+template <> struct $specdecl[[Tmpl]] {};
+template  struct $partspecdecl[[Tmpl]] {};
+extern template struct Tmpl;
+template struct Tmpl;
   )");
   runSymbolCollector(Header.code(), /*Main=*/"");
   EXPECT_THAT(Symbols,
-  UnorderedElementsAreArray(
-  {AllOf(QName("Tmpl"), DeclRange(Header.range())),
-   AllOf(QName("Tmpl::x"), DeclRange(Header.range("xdecl")))}));
+  UnorderedElementsAre(
+  AllOf(QName("Tmpl"), DeclRange(Header.range()),
+ForCodeCompletion(true)),
+  AllOf(QName("Tmpl"), DeclRange(Header.range("specdecl")),
+ForCodeCompletion(false)),
+  AllOf(QName("Tmpl"), DeclRange(Header.range("partspecdecl")),
+ForCodeCompletion(false)),
+  AllOf(QName("Tmpl::x"), DeclRange(Header.range("xdecl")),
+ForCodeCompletion(false;
 }
 
 TEST_F(SymbolCollectorTest, ObjCSymbols) {
Index: unittests/clangd/IndexTests.cpp
===
--- unittests/clangd/IndexTests.cpp
+++ unittests/clangd/IndexTests.cpp
@@ -13,6 +13,8 @@
 #include "index/Index.h"
 #include "index/MemIndex.h"
 #include "index/Merge.h"
+#include "index/Symbol.h"
+#include "clang/Index/IndexSymbol.h"
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
 
@@ -181,6 +183,41 @@
   EXPECT_THAT(lookup(*I, SymbolID("ns::nonono")), UnorderedElementsAre());
 }
 
+TEST(MemIndexTest, TemplateSpecialization) {
+  SymbolSlab::Builder B;
+
+  Symbol S = symbol("TempSpec");
+  S.ID = SymbolID("0");
+  B.insert(S);
+
+  S = symbol("TempSpec");
+  S.ID = SymbolID("1");
+  S.SymInfo.Properties = static_cast(
+  index::SymbolProperty::TemplateSpecialization);
+  B.insert(S);
+
+  S = symbol("TempSpec");
+  S.ID = SymbolID("2");
+  S.SymInfo.Properties = static_cast(
+  index::SymbolProperty::TemplatePartialSpecialization);
+  B.insert(S);
+
+  auto I = MemIndex::build(std::move(B).build(), RefSlab());
+  FuzzyFindRequest Req;
+  Req.Query = "TempSpec";
+  Req.AnyScope = true;
+
+  std::vector Symbols;
+  I->fuzzyFind(Req, [&Symbols](const Symbol &Sym) { Symbols.push_back(Sym); });
+  EXPECT_EQ(Symbols.size(), 1U);
+  EXPECT_FALSE(Symbols.front().SymInfo.Properties &
+   static_cast(
+   index::SymbolProperty::TemplateSpecialization));
+  EXPECT_FALSE(Symbols.front().SymInfo.Properties &
+   static_cast(
+   index::SymbolProperty::TemplatePartialSpecialization));
+}
+
 TEST(MergeIndexTest, Lookup) {
   auto I = MemIndex::build(generateSymbols({"ns::A", "ns::B"}), RefSlab()),
J = MemIndex::build(generateSymbols({"ns::B", "ns::C"}), RefSlab());
Index: unittests/clangd/DexTests.cpp
===
--- unittests/clangd/DexTests.cpp
+++ unittests/clangd/DexTests.cpp
@@ -710,6 +710,41 @@
   EXPECT_THAT(match(I, Req), ElementsAre("t2"));
 }
 
+TEST(DexTest, TemplateSpecialization) {
+  SymbolSlab::Builder B;
+
+  Symbol S = symbol("TempSpec");
+  S.ID = SymbolID("0");
+  B.insert(S);
+
+  S = symbol("TempSpec");
+  S.ID = SymbolID("1");
+  S.SymInfo.Properties = static_cast(
+  index::SymbolProperty::TemplateSpecialization);
+  B.insert(S);
+
+  S = symbol("TempSpec");
+  S.ID = SymbolID("2");
+  S.SymInfo.Properties = static_cast(
+  index::SymbolProperty::TemplatePartialSpecialization);
+  B.insert(S);
+
+  auto I = dex::Dex::build(std::move(B).build(), RefSlab());
+  FuzzyFindRequest Req;
+  Req.Query = "TempSpec";
+  Req.AnyScope = true;
+
+  std::vector Symbols;
+  I->fuzzyFind(Req, [&Symbols](const Symbol 

[PATCH] D59083: [clangd] Store explicit template specializations in index for code navigation purposes

2019-03-13 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

In D59083#1426105 , @ilya-biryukov 
wrote:

> To split this into multiple independent changes, we could start with storing 
> the symbols for template specializations, but only showing the primary 
> template in the results of workspaceSymbols.
>  This would enable other features (xrefs, etc), and we could re-add 
> specializations to workspaceSymbols after we improve the presentation.


SGTM, moving forward with that approach.


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59083/new/

https://reviews.llvm.org/D59083



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


[PATCH] D56370: [clangd] Add support for type hierarchy (super types only for now)

2019-03-13 Thread Eric Liu via Phabricator via cfe-commits
ioeric added a comment.

just a few drive-by comments ;)




Comment at: clang-tools-extra/clangd/FindSymbols.h:28
+// https://github.com/Microsoft/language-server-protocol/issues/344
+SymbolKind indexSymbolKindToSymbolKind(index::SymbolKind Kind);
+

This could probably live in `Protocol.h`.



Comment at: clang-tools-extra/clangd/XRefs.cpp:957
+  getTypeAncestors(*CXXRD, AST.getASTContext());
+  // TODO: Resolve type descendants if direction is Children or Both,
+  //   and ResolveLevels > 0.

nit: s/TODO/FIXME(owner)/

same elsewhere.



Comment at: clang-tools-extra/clangd/index/SymbolCollector.h:154
+// the SourceManager.
+std::string toURI(const SourceManager &SM, llvm::StringRef Path,
+  llvm::StringRef FallbackDir);

why are we pulling this into the header? This still seems to be only used in 
SymbolCollector.cpp.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56370/new/

https://reviews.llvm.org/D56370



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


[PATCH] D56370: [clangd] Add support for type hierarchy (super types only for now)

2019-03-13 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

A few small NITs




Comment at: clang-tools-extra/clangd/ClangdServer.h:188
+  /// Get information about type hierarchy for a given position.
+  void findTypeHierarchy(PathRef File, Position Pos, int Resolve,
+ TypeHierarchyDirection Direction,

Could you rename it to `typeHierarchy`?
We try to keep these method names aligned with the LSP methods.



Comment at: clang-tools-extra/clangd/XRefs.h:62
+/// Find the record type references at \p Pos.
+const CXXRecordDecl *findRecordTypeAt(ParsedAST &AST, Position Pos);
+

This method looks like an implementation detail and does not align with other 
methods in `XRefs.h` which are high-level methods that implement LSP 
functionality.

It would be more appropriate to move it to `AST.h` or directly into the 
`XRefs.cpp`. WDYT?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56370/new/

https://reviews.llvm.org/D56370



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


[PATCH] D59292: [clang-format] messes up indentation when using JavaScript private fields and methods

2019-03-13 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay created this revision.
MyDeveloperDay added reviewers: djasper, klimek, JonasToth, reuk, krasimir.
MyDeveloperDay added a project: clang-tools-extra.

Addresses PR40999 https://bugs.llvm.org/show_bug.cgi?id=40999

Private fields and methods  in javasceipt would get incorrectly indented (it 
sees them as preprocessor directives and hence left aligns them)

In this revision  "#identifier" tokens  tok::hash->tok::identifier are merged 
into a single new token
tok::identifier with the '#' contained inside the TokenText

  class Example {
pub = 1;
  #priv = 2;
  
static pub2 = "foo";
static #priv2 = "bar";
  
method() { this.#priv = 5; }
  
static staticMethod() {
  switch (this.#priv) {
  case '1':
  #priv = 3;
break;
  }
}
  
  #privateMethod() {
this.#privateMethod(); // infinite loop
  }
  
  static #staticPrivateMethod() {}
  }

After this fix the code will be correctly indented

  class Example {
pub = 1;
#priv = 2;
  
static pub2 = "foo";
static #priv2 = "bar";
  
method() { this.#priv = 5; }
  
static staticMethod() {
  switch (this.#priv) {
  case '1':
#priv = 3;
break;
  }
}
  
#privateMethod() {
  this.#privateMethod(); // infinite loop
}
  
static #staticPrivateMethod() {}
  }



NOTE: There might be some Javascript code out there which uses the C processor 
to preprocess .js files http://www.nongnu.org/espresso/js-cpp.html,  Its not 
clear how this revision or even private fields and methods would interact.


https://reviews.llvm.org/D59292

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Format/FormatToken.h
  clang/lib/Format/FormatTokenLexer.cpp
  clang/lib/Format/FormatTokenLexer.h
  clang/unittests/Format/FormatTestJS.cpp

Index: clang/unittests/Format/FormatTestJS.cpp
===
--- clang/unittests/Format/FormatTestJS.cpp
+++ clang/unittests/Format/FormatTestJS.cpp
@@ -2328,5 +2328,27 @@
   " never) extends((k: infer I) => void) ? I : never;");
 }
 
-} // end namespace tooling
+TEST_F(FormatTestJS, SupportPrivateFieldsAndMethods) {
+  verifyFormat("class Example {\n"
+   "  pub = 1;\n"
+   "  #priv = 2;\n"
+   "  static pub2 = 'foo';\n"
+   "  static #priv2 = 'bar';\n"
+   "  method() {\n"
+   "this.#priv = 5;\n"
+   "  }\n"
+   "  static staticMethod() {\n"
+   "switch (this.#priv) {\n"
+   "  case '1':\n"
+   "#priv = 3;\n"
+   "break;\n"
+   "}\n"
+   "  }\n"
+   "  #privateMethod() {\n"
+   "this.#privateMethod();  // infinite loop\n"
+   "  }\n"
+   "  static #staticPrivateMethod() {}\n");
+}
+
+} // namespace format
 } // end namespace clang
Index: clang/lib/Format/FormatTokenLexer.h
===
--- clang/lib/Format/FormatTokenLexer.h
+++ clang/lib/Format/FormatTokenLexer.h
@@ -48,6 +48,7 @@
 
   bool tryMergeLessLess();
   bool tryMergeNSStringLiteral();
+  bool tryMergeJSPrivateIdentifier();
 
   bool tryMergeTokens(ArrayRef Kinds, TokenType NewType);
 
Index: clang/lib/Format/FormatTokenLexer.cpp
===
--- clang/lib/Format/FormatTokenLexer.cpp
+++ clang/lib/Format/FormatTokenLexer.cpp
@@ -95,6 +95,8 @@
   Tokens.back()->Tok.setKind(tok::starequal);
   return;
 }
+if (tryMergeJSPrivateIdentifier())
+  return;
   }
 
   if (Style.Language == FormatStyle::LK_Java) {
@@ -121,6 +123,25 @@
   return true;
 }
 
+bool FormatTokenLexer::tryMergeJSPrivateIdentifier() {
+  // Merges #idenfier into a single identifier with the text #identifier
+  // but the token tok::identifier.
+  if (Tokens.size() < 2)
+return false;
+  auto &Hash = *(Tokens.end() - 2);
+  auto &Identifier = *(Tokens.end() - 1);
+  if (!Hash->is(tok::hash) || !Identifier->is(tok::identifier))
+return false;
+  Hash->Tok.setKind(tok::identifier);
+  Hash->TokenText =
+  StringRef(Hash->TokenText.begin(),
+Identifier->TokenText.end() - Hash->TokenText.begin());
+  Hash->ColumnWidth += Identifier->ColumnWidth;
+  Hash->Type = TT_JsPrivateIdentifier;
+  Tokens.erase(Tokens.end() - 1);
+  return true;
+}
+
 bool FormatTokenLexer::tryMergeLessLess() {
   // Merge X,less,less,Y into X,lessless,Y unless X or Y is less.
   if (Tokens.size() < 3)
Index: clang/lib/Format/FormatToken.h
===
--- clang/lib/Format/FormatToken.h
+++ clang/lib/Format/FormatToken.h
@@ -63,6 +63,7 @@
   TYPE(JsTypeColon)\
   TYPE(JsTypeOperator) \
   TYPE(JsTypeO

[PATCH] D59283: Fixed global constant/variable naming check on C++ class for ObjC++ files.

2019-03-13 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments.



Comment at: clang-tidy/google/GlobalVariableDeclarationCheck.cpp:82
   if (const auto *Decl = Result.Nodes.getNodeAs("global_var")) {
+if (Decl->isStaticDataMember()) {
+  return;

nit: removing the `{}`, the same below.



Comment at: test/clang-tidy/google-objc-global-variable-declaration.mm:38
 
+class MyTest {
+static int not_objc_style;

instead of moving `.m` to `.mm`, I think we can create a new ".mm" file for 
testing this case.


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59283/new/

https://reviews.llvm.org/D59283



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


[PATCH] D59279: [Analyzer] Checker for non-determinism caused by iteration of unordered container of pointers

2019-03-13 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus requested changes to this revision.
Szelethus added a reviewer: baloghadamsoftware.
Szelethus added a comment.
This revision now requires changes to proceed.

Code is great, idea's great, so green light on my part, but maybe we should 
allow some folks who are more knowledgeable on AST matching to have a say in 
this.

The obvious question, why not implement this in clang-tidy? I have nothing 
against landing this in the static analyzer, just curious.

Please also add some doc to `docs/analyzer/checkers.rst`.




Comment at: lib/StaticAnalyzer/Checkers/PointerIterationChecker.cpp:5-6
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//

Uh-oh, we changed licence not long ago, and your last patch also landed with 
the incorrect header -- could you please fix them?



Comment at: test/Analysis/ptr-iter.cpp:1
+// RUN: %clang_analyze_cc1 
-analyzer-checker=core,alpha.nondeterminism.PointerIteration %s 
-analyzer-output=text -verify
+

```

// RUN: %clang_analyze_cc1 %s -analyzer-output=text -verify \
// RUN:   -analyzer-checker=core,alpha.nondeterminism.PointerIteration
```


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59279/new/

https://reviews.llvm.org/D59279



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


[PATCH] D59279: [Analyzer] Checker for non-determinism caused by iteration of unordered container of pointers

2019-03-13 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added a comment.

In D59279#1427017 , @mgrang wrote:

>   3. Currently, we also do not check for what happens inside the for loop. 
> Not all iterations may causes non-determinism. For example, counting or 
> summing up the elements should not be non-deterministic.
>


Could you please add a TODO then to the code? We definitely wouldn't want to 
forget this before moving out of alpha.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59279/new/

https://reviews.llvm.org/D59279



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


[PATCH] D59264: [Driver] Support compiler-rt crtbegin.o/crtend.o for Linux

2019-03-13 Thread Ethan Sommer via Phabricator via cfe-commits
E5ten added inline comments.



Comment at: clang/lib/Driver/ToolChains/Gnu.cpp:563
+  crtend = Args.hasArg(options::OPT_shared) || IsPIE || IsStaticPIE ?
+  "crtend_shared" : "crtend";
+  CmdArgs.push_back(ToolChain.getCompilerRTArgString(

phosek wrote:
> MaskRay wrote:
> > phosek wrote:
> > > MaskRay wrote:
> > > > I believe `crtbegin.o` `crtend.o` should just work. It is not necessary 
> > > > to use `crtbegin_shared.o` `crtend_shared.o`.
> > > This is related to your comments on D28791, specifically that we should 
> > > be using `crtbegin_shared.o` for `-shared` or `-pie` and `crtbegin.o` 
> > > otherwise, is that not the case?
> > Yes. I think we can rename `crtbegin_shared.o` to `crtbegin.o` and use it 
> > for every configuration: `-no-pie` `-pie` `-shared` `-static` `-static 
> > -pie`.
> We've checked the glibc implementation of `__cxa_finalize`. A nonzero 
> `__dso_handle` has to match the value passed to `__cxa_atexit` but a zero 
> `__dso_handle` matches every function registered. So it matters that DSO fini 
> calls use `&__dso_handle` to match their registrations for the `dlclose` 
> case, but it also matters that the main executable fini call use zero to run 
> all the dtors at exit time. It's not clear it really needs to be that way, 
> but it would affect how the dtors get run which might affect some use cases. 
> Hence, I don't think we can combine `crtbegin.o` and `crtbegin_shared.o`.
I may be wrong but from what I can see crtend and crtend_shared are identical, 
so while the crtbegins must stay separate can't the 2 crtends be merged into 
one that gets used in all cases instead of having a duplicate object under a 
different name?


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59264/new/

https://reviews.llvm.org/D59264



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


r356047 - [AST] Improve support of external layouts in `MicrosoftRecordLayoutBuilder`

2019-03-13 Thread Aleksandr Urakov via cfe-commits
Author: aleksandr.urakov
Date: Wed Mar 13 06:38:12 2019
New Revision: 356047

URL: http://llvm.org/viewvc/llvm-project?rev=356047&view=rev
Log:
[AST] Improve support of external layouts in `MicrosoftRecordLayoutBuilder`

Summary:
This patch fixes several small problems with external layouts support in
`MicrosoftRecordLayoutBuilder`:
- aligns properly the size of a struct that ends with a bit field. It was
  aligned on byte before, not on the size of the field, so the struct size was
  smaller than it should be;
- adjusts the struct size when injecting a vbptr in the case when there were no
  bases or fields allocated after the vbptr. Similarly, without the adjustment
  the struct was smaller than it should be;
- the same fix as above for the vfptr.
All these fixes affect the non-virtual size of a struct, so they are tested
through non-virtual inheritance.

Reviewers: rnk, zturner, rsmith

Reviewed By: rnk

Subscribers: jdoerfert, cfe-commits

Tags: #clang

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

Added:
cfe/trunk/test/CodeGenCXX/Inputs/override-layout-virtual-base.layout
cfe/trunk/test/CodeGenCXX/override-layout-virtual-base.cpp
Modified:
cfe/trunk/lib/AST/RecordLayoutBuilder.cpp
cfe/trunk/test/CodeGenCXX/Inputs/override-bit-field-layout.layout
cfe/trunk/test/CodeGenCXX/override-bit-field-layout.cpp
cfe/trunk/test/CodeGenCXX/override-layout.cpp

Modified: cfe/trunk/lib/AST/RecordLayoutBuilder.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/RecordLayoutBuilder.cpp?rev=356047&r1=356046&r2=356047&view=diff
==
--- cfe/trunk/lib/AST/RecordLayoutBuilder.cpp (original)
+++ cfe/trunk/lib/AST/RecordLayoutBuilder.cpp Wed Mar 13 06:38:12 2019
@@ -2692,7 +2692,8 @@ void MicrosoftRecordLayoutBuilder::layou
 auto FieldBitOffset = External.getExternalFieldOffset(FD);
 placeFieldAtBitOffset(FieldBitOffset);
 auto NewSize = Context.toCharUnitsFromBits(
-llvm::alignTo(FieldBitOffset + Width, Context.getCharWidth()));
+llvm::alignDown(FieldBitOffset, Context.toBits(Info.Alignment)) +
+Context.toBits(Info.Size));
 Size = std::max(Size, NewSize);
 Alignment = std::max(Alignment, Info.Alignment);
   } else if (IsUnion) {
@@ -2741,12 +2742,17 @@ void MicrosoftRecordLayoutBuilder::injec
   CharUnits InjectionSite = VBPtrOffset;
   // But before we do, make sure it's properly aligned.
   VBPtrOffset = VBPtrOffset.alignTo(PointerInfo.Alignment);
+  // Determine where the first field should be laid out after the vbptr.
+  CharUnits FieldStart = VBPtrOffset + PointerInfo.Size;
   // Shift everything after the vbptr down, unless we're using an external
   // layout.
-  if (UseExternalLayout)
+  if (UseExternalLayout) {
+// It is possible that there were no fields or bases located after vbptr,
+// so the size was not adjusted before.
+if (Size < FieldStart)
+  Size = FieldStart;
 return;
-  // Determine where the first field should be laid out after the vbptr.
-  CharUnits FieldStart = VBPtrOffset + PointerInfo.Size;
+  }
   // Make sure that the amount we push the fields back by is a multiple of the
   // alignment.
   CharUnits Offset = (FieldStart - InjectionSite)
@@ -2771,8 +2777,14 @@ void MicrosoftRecordLayoutBuilder::injec
   if (HasVBPtr)
 VBPtrOffset += Offset;
 
-  if (UseExternalLayout)
+  if (UseExternalLayout) {
+// The class may have no bases or fields, but still have a vfptr
+// (e.g. it's an interface class). The size was not correctly set before
+// in this case.
+if (FieldOffsets.empty() && Bases.empty())
+  Size += Offset;
 return;
+  }
 
   Size += Offset;
 

Modified: cfe/trunk/test/CodeGenCXX/Inputs/override-bit-field-layout.layout
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/Inputs/override-bit-field-layout.layout?rev=356047&r1=356046&r2=356047&view=diff
==
--- cfe/trunk/test/CodeGenCXX/Inputs/override-bit-field-layout.layout (original)
+++ cfe/trunk/test/CodeGenCXX/Inputs/override-bit-field-layout.layout Wed Mar 
13 06:38:12 2019
@@ -14,3 +14,11 @@ Layout: 
+
+*** Dumping AST Record Layout
+Type: struct S3
+
+Layout: 

Added: cfe/trunk/test/CodeGenCXX/Inputs/override-layout-virtual-base.layout
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/Inputs/override-layout-virtual-base.layout?rev=356047&view=auto
==
--- cfe/trunk/test/CodeGenCXX/Inputs/override-layout-virtual-base.layout (added)
+++ cfe/trunk/test/CodeGenCXX/Inputs/override-layout-virtual-base.layout Wed 
Mar 13 06:38:12 2019
@@ -0,0 +1,8 @@
+
+*** Dumping AST Record Layout
+Type: struct S2
+
+Layout: 

Modified: cfe/trunk/test/CodeGenCXX/override-bit-field-layout.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/override-b

[PATCH] D58544: [AST] Improve support of external layouts in `MicrosoftRecordLayoutBuilder`

2019-03-13 Thread Aleksandr Urakov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL356047: [AST] Improve support of external layouts in 
`MicrosoftRecordLayoutBuilder` (authored by aleksandr.urakov, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D58544?vs=187922&id=190403#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58544/new/

https://reviews.llvm.org/D58544

Files:
  cfe/trunk/lib/AST/RecordLayoutBuilder.cpp
  cfe/trunk/test/CodeGenCXX/Inputs/override-bit-field-layout.layout
  cfe/trunk/test/CodeGenCXX/Inputs/override-layout-virtual-base.layout
  cfe/trunk/test/CodeGenCXX/override-bit-field-layout.cpp
  cfe/trunk/test/CodeGenCXX/override-layout-virtual-base.cpp
  cfe/trunk/test/CodeGenCXX/override-layout.cpp

Index: cfe/trunk/lib/AST/RecordLayoutBuilder.cpp
===
--- cfe/trunk/lib/AST/RecordLayoutBuilder.cpp
+++ cfe/trunk/lib/AST/RecordLayoutBuilder.cpp
@@ -2692,7 +2692,8 @@
 auto FieldBitOffset = External.getExternalFieldOffset(FD);
 placeFieldAtBitOffset(FieldBitOffset);
 auto NewSize = Context.toCharUnitsFromBits(
-llvm::alignTo(FieldBitOffset + Width, Context.getCharWidth()));
+llvm::alignDown(FieldBitOffset, Context.toBits(Info.Alignment)) +
+Context.toBits(Info.Size));
 Size = std::max(Size, NewSize);
 Alignment = std::max(Alignment, Info.Alignment);
   } else if (IsUnion) {
@@ -2741,12 +2742,17 @@
   CharUnits InjectionSite = VBPtrOffset;
   // But before we do, make sure it's properly aligned.
   VBPtrOffset = VBPtrOffset.alignTo(PointerInfo.Alignment);
+  // Determine where the first field should be laid out after the vbptr.
+  CharUnits FieldStart = VBPtrOffset + PointerInfo.Size;
   // Shift everything after the vbptr down, unless we're using an external
   // layout.
-  if (UseExternalLayout)
+  if (UseExternalLayout) {
+// It is possible that there were no fields or bases located after vbptr,
+// so the size was not adjusted before.
+if (Size < FieldStart)
+  Size = FieldStart;
 return;
-  // Determine where the first field should be laid out after the vbptr.
-  CharUnits FieldStart = VBPtrOffset + PointerInfo.Size;
+  }
   // Make sure that the amount we push the fields back by is a multiple of the
   // alignment.
   CharUnits Offset = (FieldStart - InjectionSite)
@@ -2771,8 +2777,14 @@
   if (HasVBPtr)
 VBPtrOffset += Offset;
 
-  if (UseExternalLayout)
+  if (UseExternalLayout) {
+// The class may have no bases or fields, but still have a vfptr
+// (e.g. it's an interface class). The size was not correctly set before
+// in this case.
+if (FieldOffsets.empty() && Bases.empty())
+  Size += Offset;
 return;
+  }
 
   Size += Offset;
 
Index: cfe/trunk/test/CodeGenCXX/override-layout-virtual-base.cpp
===
--- cfe/trunk/test/CodeGenCXX/override-layout-virtual-base.cpp
+++ cfe/trunk/test/CodeGenCXX/override-layout-virtual-base.cpp
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -w -triple=x86_64-pc-win32 -fms-compatibility -fdump-record-layouts-simple -foverride-record-layout=%S/Inputs/override-layout-virtual-base.layout %s | FileCheck %s
+
+struct S1 {
+  int a;
+};
+
+struct S2 : virtual S1 {
+  virtual void foo() {}
+};
+
+// CHECK: Type: struct S3
+// CHECK:   FieldOffsets: [128]
+struct S3 : S2 {
+  char b;
+};
+
+void use_structs() {
+  S1 s1s[sizeof(S1)];
+  S2 s2s[sizeof(S2)];
+  S3 s3s[sizeof(S3)];
+}
Index: cfe/trunk/test/CodeGenCXX/Inputs/override-bit-field-layout.layout
===
--- cfe/trunk/test/CodeGenCXX/Inputs/override-bit-field-layout.layout
+++ cfe/trunk/test/CodeGenCXX/Inputs/override-bit-field-layout.layout
@@ -14,3 +14,11 @@
   Size:128
   Alignment:64
   FieldOffsets: [64]>
+
+*** Dumping AST Record Layout
+Type: struct S3
+
+Layout: 
Index: cfe/trunk/test/CodeGenCXX/Inputs/override-layout-virtual-base.layout
===
--- cfe/trunk/test/CodeGenCXX/Inputs/override-layout-virtual-base.layout
+++ cfe/trunk/test/CodeGenCXX/Inputs/override-layout-virtual-base.layout
@@ -0,0 +1,8 @@
+
+*** Dumping AST Record Layout
+Type: struct S2
+
+Layout: 
Index: cfe/trunk/test/CodeGenCXX/override-bit-field-layout.cpp
===
--- cfe/trunk/test/CodeGenCXX/override-bit-field-layout.cpp
+++ cfe/trunk/test/CodeGenCXX/override-bit-field-layout.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -w -fdump-record-layouts-simple -foverride-record-layout=%S/Inputs/override-bit-field-layout.layout %s | FileCheck %s
+// RUN: %clang_cc1 -w -triple=x86_64-pc-win32 -fms-compatibility -fdump-record-layouts-simple -foverride-record-layout=%S/Inputs/override-bit-field-layout.layout %s | FileCheck %s
 

[PATCH] D58544: [AST] Improve support of external layouts in `MicrosoftRecordLayoutBuilder`

2019-03-13 Thread Aleksandr Urakov via Phabricator via cfe-commits
aleksandr.urakov added a comment.

Thank you! I've added a slightly reworked test too.


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58544/new/

https://reviews.llvm.org/D58544



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


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

2019-03-13 Thread Nico Weber via Phabricator via cfe-commits
thakis abandoned this revision.
thakis added a comment.

We went with https://reviews.llvm.org/D36413 instead. (Upstream issue was 
https://crbug.com/751225)


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D36238/new/

https://reviews.llvm.org/D36238



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


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

2019-03-13 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

Note to self, this was for https://crbug.com/751225


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D36413/new/

https://reviews.llvm.org/D36413



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


[PATCH] D59135: Add check for matching HeaderFilter before emitting Diagnostic

2019-03-13 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh requested changes to this revision.
alexfh added inline comments.
This revision now requires changes to proceed.



Comment at: clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp:453
+
+  StringRef FileName(Loc.printToString(Loc.getManager()));
+  if(getHeaderFilter()->match(FileName))

That'll result in a dangling pointer. `SourceLocation::printToString` returns a 
temporary std::string that will be destroyed at the end of expression, but 
`FileName` will point to its data.

Also, the `printToString` method will contain much more than just the filename. 
`SourceManager::getPresumedLoc` should do a better job here.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59135/new/

https://reviews.llvm.org/D59135



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


[PATCH] D59296: [pp-trace] Delete -ignore and add generalized -callbacks

2019-03-13 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay created this revision.
MaskRay added reviewers: juliehockett, aaron.ballman, alexfh.
Herald added subscribers: cfe-commits, jsji, kbarton, nemanjai.
Herald added a project: clang.

-ignore specifies a list of PP callbacks to ignore. It cannot express a
whitelist, which may be more useful than a blacklist.
Delete it and add a generalized -callbacks instead.

-ignore= (default) => -callbacks='*' (default)
-ignore=FileChanged,FileSkipped => -callbacks='*,-FileChanged,-FileSkipped'

-callbacks='Macro*' : only print MacroDefined,MacroExpands,MacroUndefined,... 
callbacks


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D59296

Files:
  docs/pp-trace.rst
  pp-trace/PPCallbacksTracker.cpp
  pp-trace/PPCallbacksTracker.h
  pp-trace/PPTrace.cpp
  test/pp-trace/pp-trace-conditional.cpp
  test/pp-trace/pp-trace-filter.cpp
  test/pp-trace/pp-trace-ident.cpp
  test/pp-trace/pp-trace-macro.cpp
  test/pp-trace/pp-trace-modules.cpp
  test/pp-trace/pp-trace-pragma-general.cpp
  test/pp-trace/pp-trace-pragma-ms.cpp
  test/pp-trace/pp-trace-pragma-opencl.cpp

Index: test/pp-trace/pp-trace-pragma-opencl.cpp
===
--- test/pp-trace/pp-trace-pragma-opencl.cpp
+++ test/pp-trace/pp-trace-pragma-opencl.cpp
@@ -1,4 +1,4 @@
-// RUN: pp-trace -ignore FileChanged,MacroDefined %s -x cl | FileCheck --strict-whitespace %s
+// RUN: pp-trace -callbacks '*,-FileChanged,-MacroDefined' %s -x cl | FileCheck --strict-whitespace %s
 
 #pragma OPENCL EXTENSION all : disable
 #pragma OPENCL EXTENSION cl_khr_int64_base_atomics : disable
Index: test/pp-trace/pp-trace-pragma-ms.cpp
===
--- test/pp-trace/pp-trace-pragma-ms.cpp
+++ test/pp-trace/pp-trace-pragma-ms.cpp
@@ -1,4 +1,4 @@
-// RUN: pp-trace -ignore FileChanged,MacroDefined %s -target x86_64-unknown-windows-msvc -fms-extensions -w | FileCheck --strict-whitespace %s
+// RUN: pp-trace -callbacks '*,-FileChanged,-MacroDefined' %s -target x86_64-unknown-windows-msvc -fms-extensions -w | FileCheck --strict-whitespace %s
 
 #pragma comment(compiler, "compiler comment")
 #pragma comment(exestr, "exestr comment")
Index: test/pp-trace/pp-trace-pragma-general.cpp
===
--- test/pp-trace/pp-trace-pragma-general.cpp
+++ test/pp-trace/pp-trace-pragma-general.cpp
@@ -1,4 +1,4 @@
-// RUN: pp-trace -ignore FileChanged,MacroDefined %s | FileCheck --strict-whitespace %s
+// RUN: pp-trace -callbacks '*,-FileChanged,-MacroDefined' %s | FileCheck --strict-whitespace %s
 
 #pragma clang diagnostic push
 #pragma clang diagnostic pop
Index: test/pp-trace/pp-trace-modules.cpp
===
--- test/pp-trace/pp-trace-modules.cpp
+++ test/pp-trace/pp-trace-modules.cpp
@@ -1,5 +1,5 @@
 // RUN: rm -rf %t
-// RUN: pp-trace -ignore FileChanged,MacroDefined %s -x objective-c++ -undef -target x86_64 -std=c++11 -fmodules -fcxx-modules -fmodules-cache-path=%t -I%S -I%S/Input | FileCheck --strict-whitespace %s
+// RUN: pp-trace -callbacks '*,-FileChanged,-MacroDefined' %s -x objective-c++ -undef -target x86_64 -std=c++11 -fmodules -fcxx-modules -fmodules-cache-path=%t -I%S -I%S/Input | FileCheck --strict-whitespace %s
 
 // CHECK: ---
 
Index: test/pp-trace/pp-trace-macro.cpp
===
--- test/pp-trace/pp-trace-macro.cpp
+++ test/pp-trace/pp-trace-macro.cpp
@@ -1,4 +1,4 @@
-// RUN: pp-trace -ignore FileChanged %s -undef -target x86_64 -std=c++11 | FileCheck --strict-whitespace %s
+// RUN: pp-trace -callbacks '*,-FileChanged' %s -undef -target x86_64 -std=c++11 | FileCheck --strict-whitespace %s
 
 #define MACRO 1
 int i = MACRO;
Index: test/pp-trace/pp-trace-ident.cpp
===
--- test/pp-trace/pp-trace-ident.cpp
+++ test/pp-trace/pp-trace-ident.cpp
@@ -1,4 +1,4 @@
-// RUN: pp-trace -ignore FileChanged,MacroDefined %s -undef -target x86_64 -std=c++11 | FileCheck --strict-whitespace %s
+// RUN: pp-trace -callbacks '*,-FileChanged,-MacroDefined' %s -undef -target x86_64 -std=c++11 | FileCheck --strict-whitespace %s
 
 #ident "$Id$"
 
Index: test/pp-trace/pp-trace-filter.cpp
===
--- /dev/null
+++ test/pp-trace/pp-trace-filter.cpp
@@ -0,0 +1,16 @@
+// RUN: pp-trace -callbacks 'File*,Macro*,-MacroUndefined' %s | FileCheck %s
+// RUN: not pp-trace -callbacks '[' %s 2>&1 | FileCheck --check-prefix=INVALID %s
+
+#define M 1
+int i = M;
+#undef M
+
+// CHECK:  ---
+// CHECK:  - Callback: FileChanged
+// CHECK:  - Callback: MacroDefined
+// CHECK:  - Callback: MacroExpands
+// CHECK-NOT:  - Callback: MacroUndefined
+// CHECK-NOT:  - Callback: EndOfMainFile
+// CHECK:  ...
+
+// INVALID: error: invalid glob pattern: [
Index: test/pp-trace/pp-trace-conditional.cpp

r356049 - [Analyzer] Skip symbolic regions based on conjured symbols in comparison of the containers of iterators

2019-03-13 Thread Adam Balogh via cfe-commits
Author: baloghadamsoftware
Date: Wed Mar 13 06:55:11 2019
New Revision: 356049

URL: http://llvm.org/viewvc/llvm-project?rev=356049&view=rev
Log:
[Analyzer] Skip symbolic regions based on conjured symbols in comparison of the 
containers of iterators

Checking whether two regions are the same is a partially decidable problem:
either we know for sure that they are the same or we cannot decide. A typical
case for this are the symbolic regions based on conjured symbols. Two
different conjured symbols are either the same or they are different. Since
we cannot decide this and want to reduce false positives as much as possible
we exclude these regions whenever checking whether two containers are the
same at iterator mismatch check.

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


Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
cfe/trunk/test/Analysis/mismatched-iterator.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/IteratorChecker.cpp?rev=356049&r1=356048&r2=356049&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/IteratorChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/IteratorChecker.cpp Wed Mar 13 
06:55:11 2019
@@ -1098,14 +1098,34 @@ void IteratorChecker::verifyMatch(Checke
   // Verify match between a container and the container of an iterator
   Cont = Cont->getMostDerivedObjectRegion();
 
+  if (const auto *ContSym = Cont->getSymbolicBase()) {
+if (isa(ContSym->getSymbol()))
+  return;
+  }
+
   auto State = C.getState();
   const auto *Pos = getIteratorPosition(State, Iter);
-  if (Pos && Pos->getContainer() != Cont) {
+  if (!Pos)
+return;
+
+  const auto *IterCont = Pos->getContainer();
+
+  // Skip symbolic regions based on conjured symbols. Two conjured symbols
+  // may or may not be the same. For example, the same function can return
+  // the same or a different container but we get different conjured symbols
+  // for each call. This may cause false positives so omit them from the check.
+  if (const auto *ContSym = IterCont->getSymbolicBase()) {
+if (isa(ContSym->getSymbol()))
+  return;
+  }
+
+  if (IterCont != Cont) {
 auto *N = C.generateNonFatalErrorNode(State);
 if (!N) {
   return;
 }
-reportMismatchedBug("Container accessed using foreign iterator argument.", 
Iter, Cont, C, N);
+reportMismatchedBug("Container accessed using foreign iterator argument.",
+Iter, Cont, C, N);
   }
 }
 
@@ -1114,8 +1134,31 @@ void IteratorChecker::verifyMatch(Checke
   // Verify match between the containers of two iterators
   auto State = C.getState();
   const auto *Pos1 = getIteratorPosition(State, Iter1);
+  if (!Pos1)
+return;
+
+  const auto *IterCont1 = Pos1->getContainer();
+
+  // Skip symbolic regions based on conjured symbols. Two conjured symbols
+  // may or may not be the same. For example, the same function can return
+  // the same or a different container but we get different conjured symbols
+  // for each call. This may cause false positives so omit them from the check.
+  if (const auto *ContSym = IterCont1->getSymbolicBase()) {
+if (isa(ContSym->getSymbol()))
+  return;
+  }
+
   const auto *Pos2 = getIteratorPosition(State, Iter2);
-  if (Pos1 && Pos2 && Pos1->getContainer() != Pos2->getContainer()) {
+  if (!Pos2)
+return;
+
+  const auto *IterCont2 = Pos2->getContainer();
+  if (const auto *ContSym = IterCont2->getSymbolicBase()) {
+if (isa(ContSym->getSymbol()))
+  return;
+  }
+
+  if (IterCont1 != IterCont2) {
 auto *N = C.generateNonFatalErrorNode(State);
 if (!N)
   return;

Modified: cfe/trunk/test/Analysis/mismatched-iterator.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/mismatched-iterator.cpp?rev=356049&r1=356048&r2=356049&view=diff
==
--- cfe/trunk/test/Analysis/mismatched-iterator.cpp (original)
+++ cfe/trunk/test/Analysis/mismatched-iterator.cpp Wed Mar 13 06:55:11 2019
@@ -189,3 +189,17 @@ void bad_comparison(std::vector &v1
 *v1.cbegin();
   }
 }
+
+std::vector &return_vector_ref();
+
+void ignore_conjured1() {
+  std::vector &v1 = return_vector_ref(), &v2 = return_vector_ref();
+
+  v2.erase(v1.cbegin()); // no-warning
+}
+
+void ignore_conjured2() {
+  std::vector &v1 = return_vector_ref(), &v2 = return_vector_ref();
+
+  if (v1.cbegin() == v2.cbegin()) {} //no-warning
+}


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


[PATCH] D58345: [clangd] Using symbol name to map includes for STL symbols.

2019-03-13 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 190406.
hokein marked 3 inline comments as done.
hokein added a comment.

Rename the tool.


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58345/new/

https://reviews.llvm.org/D58345

Files:
  clangd/StdSymbolMap.inc
  clangd/include-mapping/gen_std.py
  clangd/include-mapping/test.py
  clangd/index/CanonicalIncludes.cpp

Index: clangd/index/CanonicalIncludes.cpp
===
--- clangd/index/CanonicalIncludes.cpp
+++ clangd/index/CanonicalIncludes.cpp
@@ -107,53 +107,20 @@
 
 void addSystemHeadersMapping(CanonicalIncludes *Includes) {
   static const std::vector> SymbolMap = {
-  {"std::addressof", ""},
-  // Map symbols in  to their preferred includes.
   {"std::basic_filebuf", ""},
-  {"std::basic_fstream", ""},
-  {"std::basic_ifstream", ""},
-  {"std::basic_ofstream", ""},
   {"std::filebuf", ""},
-  {"std::fstream", ""},
-  {"std::ifstream", ""},
-  {"std::ofstream", ""},
   {"std::wfilebuf", ""},
-  {"std::wfstream", ""},
-  {"std::wifstream", ""},
-  {"std::wofstream", ""},
-  {"std::basic_ios", ""},
-  {"std::ios", ""},
-  {"std::wios", ""},
-  {"std::basic_iostream", ""},
-  {"std::iostream", ""},
-  {"std::wiostream", ""},
   {"std::basic_istream", ""},
   {"std::istream", ""},
   {"std::wistream", ""},
-  {"std::istreambuf_iterator", ""},
-  {"std::ostreambuf_iterator", ""},
   {"std::basic_ostream", ""},
   {"std::ostream", ""},
   {"std::wostream", ""},
-  {"std::basic_istringstream", ""},
-  {"std::basic_ostringstream", ""},
-  {"std::basic_stringbuf", ""},
-  {"std::basic_stringstream", ""},
-  {"std::istringstream", ""},
-  {"std::ostringstream", ""},
-  {"std::string", ""},
-  {"std::stringbuf", ""},
-  {"std::stringstream", ""},
-  {"std::wistringstream", ""},
-  {"std::wostringstream", ""},
-  {"std::wstringbuf", ""},
-  {"std::wstringstream", ""},
-  {"std::basic_streambuf", ""},
-  {"std::streambuf", ""},
-  {"std::wstreambuf", ""},
   {"std::uint_least16_t", ""}, //  redeclares these
   {"std::uint_least32_t", ""},
-  {"std::declval", ""},
+#define SYMBOL(Name, NameSpace, Header) { #NameSpace#Name, #Header },
+  #include "StdSymbolMap.inc"
+#undef SYMBOL
   };
   for (const auto &Pair : SymbolMap)
 Includes->addSymbolMapping(Pair.first, Pair.second);
Index: clangd/include-mapping/test.py
===
--- /dev/null
+++ clangd/include-mapping/test.py
@@ -0,0 +1,101 @@
+#!/usr/bin/env python
+#===- test.py -  -*- python -*--===#
+#
+# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+# See https://llvm.org/LICENSE.txt for license information.
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+#
+#======#
+
+from gen_std import ParseSymbolPage, ParseIndexPage
+
+import unittest
+
+class TestStdGen(unittest.TestCase):
+
+  def testParseIndexPage(self):
+html = """
+ abs() (int) 
+ abs<>() (std::complex) 
+ acos() 
+ acosh() (since C++11) 
+ as_bytes<>() (since C++20) 
+ """
+
+actual = ParseIndexPage(html)
+expected = [
+  ("abs", "abs.html"),
+  ("abs", "complex/abs.html"),
+  ("acos", "acos.html"),
+  ("acosh", "acosh.html"),
+  ("as_bytes", "as_bytes.html"),
+]
+self.assertEqual(len(actual), len(expected))
+for i in range(0, len(actual)):
+  self.assertEqual(expected[i][0], actual[i][0])
+  self.assertTrue(actual[i][1].endswith(expected[i][1]))
+
+
+  def testParseSymbolPage_SingleHeader(self):
+# Defined in header 
+html = """
+ 
+  
+   Defined in header 
+   
+  
+  
+  
+
+"""
+self.assertEqual(ParseSymbolPage(html), [''])
+
+
+  def testParseSymbolPage_MulHeaders(self):
+#  Defined in header 
+#  Defined in header 
+#  Defined in header 
+html = """
+
+  
+ Defined in header 
+ 
+ 
+
+  
+  
+ Defined in header 
+ 
+
+
+  
+  
+ Defined in header 
+ 
+
+
+  
+
+"""
+self.assertEqual(ParseSymbolPage(html),
+['', '', ''])
+
+
+  def testParseSymbolPage_MulHeadersInSameDiv(self):
+# Multile  blocks in a Div.
+# Defined in header 
+# Defined in header 
+html = """
+
+
+ Defined in header 
+ Defined in header 
+
+
+
+"""
+self.assertEqual(ParseSymbolPage(html), ['', ''])
+
+
+if __name__ == '__main__':
+  unittest.main()
Index: clangd/include-mapping/gen_std.py
===
--- /dev/null
+++ clangd/include-mapping/gen_std.py
@@ -0,0 +1,149 @@
+#!/usr/bin/env python
+#===

[PATCH] D53754: [Analyzer] Skip symbolic regions based on conjured symbols in comparison of the containers of iterators

2019-03-13 Thread Balogh, Ádám via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC356049: [Analyzer] Skip symbolic regions based on conjured 
symbols in comparison of the… (authored by baloghadamsoftware, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D53754?vs=171282&id=190407#toc

Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D53754/new/

https://reviews.llvm.org/D53754

Files:
  lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
  test/Analysis/mismatched-iterator.cpp


Index: lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
+++ lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
@@ -1098,14 +1098,34 @@
   // Verify match between a container and the container of an iterator
   Cont = Cont->getMostDerivedObjectRegion();
 
+  if (const auto *ContSym = Cont->getSymbolicBase()) {
+if (isa(ContSym->getSymbol()))
+  return;
+  }
+
   auto State = C.getState();
   const auto *Pos = getIteratorPosition(State, Iter);
-  if (Pos && Pos->getContainer() != Cont) {
+  if (!Pos)
+return;
+
+  const auto *IterCont = Pos->getContainer();
+
+  // Skip symbolic regions based on conjured symbols. Two conjured symbols
+  // may or may not be the same. For example, the same function can return
+  // the same or a different container but we get different conjured symbols
+  // for each call. This may cause false positives so omit them from the check.
+  if (const auto *ContSym = IterCont->getSymbolicBase()) {
+if (isa(ContSym->getSymbol()))
+  return;
+  }
+
+  if (IterCont != Cont) {
 auto *N = C.generateNonFatalErrorNode(State);
 if (!N) {
   return;
 }
-reportMismatchedBug("Container accessed using foreign iterator argument.", 
Iter, Cont, C, N);
+reportMismatchedBug("Container accessed using foreign iterator argument.",
+Iter, Cont, C, N);
   }
 }
 
@@ -1114,8 +1134,31 @@
   // Verify match between the containers of two iterators
   auto State = C.getState();
   const auto *Pos1 = getIteratorPosition(State, Iter1);
+  if (!Pos1)
+return;
+
+  const auto *IterCont1 = Pos1->getContainer();
+
+  // Skip symbolic regions based on conjured symbols. Two conjured symbols
+  // may or may not be the same. For example, the same function can return
+  // the same or a different container but we get different conjured symbols
+  // for each call. This may cause false positives so omit them from the check.
+  if (const auto *ContSym = IterCont1->getSymbolicBase()) {
+if (isa(ContSym->getSymbol()))
+  return;
+  }
+
   const auto *Pos2 = getIteratorPosition(State, Iter2);
-  if (Pos1 && Pos2 && Pos1->getContainer() != Pos2->getContainer()) {
+  if (!Pos2)
+return;
+
+  const auto *IterCont2 = Pos2->getContainer();
+  if (const auto *ContSym = IterCont2->getSymbolicBase()) {
+if (isa(ContSym->getSymbol()))
+  return;
+  }
+
+  if (IterCont1 != IterCont2) {
 auto *N = C.generateNonFatalErrorNode(State);
 if (!N)
   return;
Index: test/Analysis/mismatched-iterator.cpp
===
--- test/Analysis/mismatched-iterator.cpp
+++ test/Analysis/mismatched-iterator.cpp
@@ -189,3 +189,17 @@
 *v1.cbegin();
   }
 }
+
+std::vector &return_vector_ref();
+
+void ignore_conjured1() {
+  std::vector &v1 = return_vector_ref(), &v2 = return_vector_ref();
+
+  v2.erase(v1.cbegin()); // no-warning
+}
+
+void ignore_conjured2() {
+  std::vector &v1 = return_vector_ref(), &v2 = return_vector_ref();
+
+  if (v1.cbegin() == v2.cbegin()) {} //no-warning
+}


Index: lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
+++ lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
@@ -1098,14 +1098,34 @@
   // Verify match between a container and the container of an iterator
   Cont = Cont->getMostDerivedObjectRegion();
 
+  if (const auto *ContSym = Cont->getSymbolicBase()) {
+if (isa(ContSym->getSymbol()))
+  return;
+  }
+
   auto State = C.getState();
   const auto *Pos = getIteratorPosition(State, Iter);
-  if (Pos && Pos->getContainer() != Cont) {
+  if (!Pos)
+return;
+
+  const auto *IterCont = Pos->getContainer();
+
+  // Skip symbolic regions based on conjured symbols. Two conjured symbols
+  // may or may not be the same. For example, the same function can return
+  // the same or a different container but we get different conjured symbols
+  // for each call. This may cause false positives so omit them from the check.
+  if (const auto *ContSym = IterCont->getSymbolicBase()) {
+if (isa(ContSym->getSymbol()))
+  return;
+  }
+
+  if (IterCont != Cont) {
 auto *N = C.generateNonFatalErrorNode(State);
 if (!N) {
   return;
 }
-reportMismatchedBug("Container accessed using foreig

[PATCH] D58345: [clangd] Using symbol name to map includes for STL symbols.

2019-03-13 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments.



Comment at: clangd/StdGen/StdGen.py:2
+#!/usr/bin/env python
+#===- StdGen.py -  ---*- python 
-*--===#
+#

ioeric wrote:
> hokein wrote:
> > ioeric wrote:
> > > I'd avoid abbreviation in the file name and the new directory name. 
> > > `StdGen` sounds a lot like a library ;)
> > > 
> > > I'd suggest something like `std-include-mapping/generate.py`
> > Personally I'd vote `StdGen`, and it follows llvm's `TableGen`.  The name 
> > `std-include-mapping/generate.py` seems too verbose...
> Why do we want to follow `TableGen`?
> 
> Two reasons why I think a more informative name should be used. 1) `StdGen` 
> sounds like a name for library and doesn't follow the naming convention for 
> tool directory (e.g. `global-symbol-builder`) and 2) it's hard for readers 
> without much context to understand what `StdGen` actually means.
Changed to include-mapping/gen_std.py, according to offline discussion.



Comment at: clangd/StdGen/StdGen.py:94
+  cpp_symbol_root = os.path.join(cpp_reference_root, "en", "cpp")
+  if not os.path.exists(cpp_reference_root):
+exit("Path %s doesn't exist!" % cpp_reference_root)

ioeric wrote:
> hokein wrote:
> > ioeric wrote:
> > > why not check `exists(index_page_path)` instead?
> > I think either way works.
> It seems to me that using `exists(index_page_path)` would be less likely to 
> trigger an exception (better use experience). I don't see a good reason to 
> check the root.
> It seems to me that using exists(index_page_path) would be less likely to 
> trigger an exception (better use experience). 

I don't see any big difference between checking `exists(index_page_path)` and 
`exists(cpp_symbol_root)` here. Checking `cpp_symbol_root` is more natural as 
we also construct the path of symbol page from it.

Anyway, changed to check index_page_path.



Comment at: clangd/StdSymbolMap.inc:8
+//===--===//
+// Used to build a lookup table (qualified names => include headers) for C++
+// Standard Library symbols.

ioeric wrote:
> hokein wrote:
> > ioeric wrote:
> > > can we include the information about the HTML archive (e.g. STL version) 
> > > from which this table is generated? This would be useful for future 
> > > maintenance.
> > The version of HTML archive is the date information, but this information 
> > is only present in the `.zip` name, we lose it after we unzip the `zip` 
> > file
> If we can't get this from the doc, we should ask users to explicitly provide 
> this information. I think we would want some version info to relate the 
> output to the source.
> If we can't get this from the doc, we should ask users to explicitly provide 
> this information. 

I'm not sure this is a good idea. Asking users provide the information seems 
error-prone.

I think we may use the file stat information (modified date) of the 
`symbol_index.html` page. 


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58345/new/

https://reviews.llvm.org/D58345



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


[PATCH] D59135: Add check for matching HeaderFilter before emitting Diagnostic

2019-03-13 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added inline comments.



Comment at: clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp:454
+  StringRef FileName(Loc.printToString(Loc.getManager()));
+  if(getHeaderFilter()->match(FileName))
+  {

aaron.ballman wrote:
> Formatting is incorrect here -- you should run the patch through clang-format 
> (https://clang.llvm.org/docs/ClangFormat.html#script-for-patch-reformatting), 
> and elide the braces.
I believe, this will break the handling of notes. If the notes attached to the 
diagnostic are in the "interesting" part of the code (see the checkFilters 
method below), the whole diagnostic should be treated as such.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59135/new/

https://reviews.llvm.org/D59135



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


[PATCH] D59298: [RISCV] Pass -target-abi to -cc1as

2019-03-13 Thread Roger Ferrer Ibanez via Phabricator via cfe-commits
rogfer01 created this revision.
rogfer01 added a reviewer: asb.
Herald added subscribers: cfe-commits, jocewei, PkmX, rkruppe, the_o, 
brucehoult, MartinMosbeck, edward-jones, zzheng, jrtc27, shiva0217, kito-cheng, 
niosHD, sabuasal, apazos, simoncook, johnrusso, rbar.
Herald added a project: clang.

The RISC-V assembler needs the target ABI because it defines a flag of the the 
ELF file, as described in [1].

Make `clang` (the driver) to pass the target ABI to `-cc1as` in exactly the 
same way it does for `-cc1`.

Currently `-cc1as` knows about `-target-abi` but is not handling it. Handle it 
and pass it to the MC layer via MCTargetOptions.

[1] 
https://github.com/riscv/riscv-elf-psabi-doc/blob/master/riscv-elf.md#file-header


Repository:
  rC Clang

https://reviews.llvm.org/D59298

Files:
  lib/Driver/ToolChains/Clang.cpp
  lib/Driver/ToolChains/Clang.h
  test/Driver/riscv-abi.c
  tools/driver/cc1as_main.cpp

Index: tools/driver/cc1as_main.cpp
===
--- tools/driver/cc1as_main.cpp
+++ tools/driver/cc1as_main.cpp
@@ -137,6 +137,10 @@
   /// The name of the relocation model to use.
   std::string RelocationModel;
 
+  /// The ABI targeted by the backend. Specified using -target-abi. Empty
+  /// otherwise.
+  std::string TargetABI;
+
   /// @}
 
 public:
@@ -282,6 +286,7 @@
   Opts.NoExecStack = Args.hasArg(OPT_mno_exec_stack);
   Opts.FatalWarnings = Args.hasArg(OPT_massembler_fatal_warnings);
   Opts.RelocationModel = Args.getLastArgValue(OPT_mrelocation_model, "pic");
+  Opts.TargetABI = Args.getLastArgValue(OPT_target_abi);
   Opts.IncrementalLinkerCompatible =
   Args.hasArg(OPT_mincremental_linker_compatible);
   Opts.SymbolDefs = Args.getAllArgValues(OPT_defsym);
@@ -426,6 +431,9 @@
   raw_pwrite_stream *Out = FDOS.get();
   std::unique_ptr BOS;
 
+  MCTargetOptions MCOptions;
+  MCOptions.ABIName = Opts.TargetABI;
+
   // FIXME: There is a bit of code duplication with addPassesToEmitFile.
   if (Opts.OutputType == AssemblerInvocation::FT_Asm) {
 MCInstPrinter *IP = TheTarget->createMCInstPrinter(
@@ -434,7 +442,6 @@
 std::unique_ptr CE;
 if (Opts.ShowEncoding)
   CE.reset(TheTarget->createMCCodeEmitter(*MCII, *MRI, Ctx));
-MCTargetOptions MCOptions;
 std::unique_ptr MAB(
 TheTarget->createMCAsmBackend(*STI, *MRI, MCOptions));
 
@@ -455,7 +462,6 @@
 
 std::unique_ptr CE(
 TheTarget->createMCCodeEmitter(*MCII, *MRI, Ctx));
-MCTargetOptions MCOptions;
 std::unique_ptr MAB(
 TheTarget->createMCAsmBackend(*STI, *MRI, MCOptions));
 std::unique_ptr OW =
@@ -489,9 +495,8 @@
   createMCAsmParser(SrcMgr, Ctx, *Str.get(), *MAI));
 
   // FIXME: init MCTargetOptions from sanitizer flags here.
-  MCTargetOptions Options;
   std::unique_ptr TAP(
-  TheTarget->createMCAsmParser(*STI, *Parser, *MCII, Options));
+  TheTarget->createMCAsmParser(*STI, *Parser, *MCII, MCOptions));
   if (!TAP)
 Failed = Diags.Report(diag::err_target_unknown_triple) << Opts.Triple;
 
Index: test/Driver/riscv-abi.c
===
--- test/Driver/riscv-abi.c
+++ test/Driver/riscv-abi.c
@@ -2,6 +2,10 @@
 // RUN:   | FileCheck -check-prefix=CHECK-ILP32 %s
 // RUN: %clang -target riscv32-unknown-elf %s -### -o %t.o -mabi=ilp32 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-ILP32 %s
+// RUN: %clang -target riscv32-unknown-elf -x assembler %s -### -o %t.o 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-ILP32 %s
+// RUN: %clang -target riscv32-unknown-elf -x assembler %s -### -o %t.o \
+// RUN:   -mabi=ilp32 2>&1 | FileCheck -check-prefix=CHECK-ILP32 %s
 
 // CHECK-ILP32: "-target-abi" "ilp32"
 
@@ -26,6 +30,10 @@
 // RUN:   | FileCheck -check-prefix=CHECK-LP64 %s
 // RUN: %clang -target riscv64-unknown-elf %s -### -o %t.o -mabi=lp64 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-LP64 %s
+// RUN: %clang -target riscv64-unknown-elf -x assembler %s -### -o %t.o 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-LP64  %s
+// RUN: %clang -target riscv64-unknown-elf -x assembler %s -### -o %t.o \
+// RUN:   -mabi=lp64 2>&1 | FileCheck -check-prefix=CHECK-LP64 %s
 
 // CHECK-LP64: "-target-abi" "lp64"
 
Index: lib/Driver/ToolChains/Clang.h
===
--- lib/Driver/ToolChains/Clang.h
+++ lib/Driver/ToolChains/Clang.h
@@ -119,6 +119,8 @@
  llvm::opt::ArgStringList &CmdArgs) const;
   void AddX86TargetArgs(const llvm::opt::ArgList &Args,
 llvm::opt::ArgStringList &CmdArgs) const;
+  void AddRISCVTargetArgs(const llvm::opt::ArgList &Args,
+  llvm::opt::ArgStringList &CmdArgs) const;
   bool hasGoodDiagnostics() const override { return true; }
   bool hasIntegratedAssembler() const override { return false; }
   bool hasIntegratedCPP() const override { return false; }
Index: lib/Driver/ToolChains/Clang.cpp
=

[PATCH] D48357: [RISCV] Remove duplicated logic when determining the target ABI

2019-03-13 Thread Roger Ferrer Ibanez via Phabricator via cfe-commits
rogfer01 added a comment.
Herald added subscribers: jocewei, PkmX, rkruppe.

@asb in D59298  I call `riscv::getRISCVABI` 
for `ClangAs`, does it make sense to make the same change for `Clang` here?

Thank you.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D48357/new/

https://reviews.llvm.org/D48357



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


[PATCH] D59254: [RFC] Implementation of Clang randstruct

2019-03-13 Thread Connor Kuehl via Phabricator via cfe-commits
connorkuehl added a comment.

In D59254#1426809 , @pcc wrote:

> This needs a test under `test/CodeGen` at least.


Will do, thank you!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59254/new/

https://reviews.llvm.org/D59254



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


[PATCH] D59254: [RFC] Implementation of Clang randstruct

2019-03-13 Thread Connor Kuehl via Phabricator via cfe-commits
connorkuehl added inline comments.



Comment at: clang/include/clang/AST/RecordFieldReorganizer.h:54
+  std::seed_seq Seq;
+  std::default_random_engine rng;
+};

pcc wrote:
> I don't think we can use `default_random_engine` for this because the 
> behaviour would need to be consistent between C++ standard library 
> implementations, and the behaviour of `default_random_engine` is 
> implementation defined. Similarly, I don't think that we can use 
> `std::shuffle` (see note in 
> https://en.cppreference.com/w/cpp/algorithm/random_shuffle ).
Sure thing, we'll begin investigating alternatives.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59254/new/

https://reviews.llvm.org/D59254



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


[PATCH] D59214: [clang][OpeMP] Model OpenMP structured-block in AST (PR40563)

2019-03-13 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added inline comments.



Comment at: include/clang/AST/StmtOpenMP.h:335
 
+  llvm::Optional getStructuredBlockImpl() const {
+return const_cast(getInnermostCapturedStmt()->getCapturedStmt());

lebedev.ri wrote:
> ABataev wrote:
> > lebedev.ri wrote:
> > > lebedev.ri wrote:
> > > > ABataev wrote:
> > > > > lebedev.ri wrote:
> > > > > > ABataev wrote:
> > > > > > > No need to insert it into each class, just add:
> > > > > > > ```
> > > > > > > Stmt * OMPExecutableDirective::getStructuredBlock() const {
> > > > > > >   if (!hasAssociatedStmt() || !getAssociatedStmt())
> > > > > > > return nullptr;
> > > > > > >   if (auto *LD = dyn_cast(this))
> > > > > > > return LD->getBody();
> > > > > > >   return getInnermostCapturedStmt()->getCapturedStmt();
> > > > > > > }
> > > > > > > ```
> > > > > > I absolutely can do that, you are sure that is the most 
> > > > > > future-proof state?
> > > > > > In particular, i want to re-point-out that if it's implemented like 
> > > > > > this,
> > > > > > in the base class, then the sub-class may(will) not even know about 
> > > > > > this function,
> > > > > > and thus 'forget' to update it, should it not be giving the correct 
> > > > > > answer for
> > > > > > that new specific OpenMP executable directive.
> > > > > > 
> > > > > > You are sure it's better to implement it in the 
> > > > > > `OMPExecutableDirective` itself?
> > > > > Yes, I'm sure. It is the universal solution and all future classes 
> > > > > must be compatible with it. If they are not, then they are incorrect.
> > > > Aha! Well, ok then.
> > > > 
> > > > Do you also suggest that `Optional<>` is too fancy?
> > > > Would it be better to do this instead?
> > > > ```
> > > > bool isStandaloneDirective() const {
> > > >   return !hasAssociatedStmt() || !getAssociatedStmt();
> > > > }
> > > > 
> > > > // Requires: !isStandaloneDirective()
> > > > Stmt *OMPExecutableDirective::getStructuredBlock() const {
> > > >   assert(!isStandaloneDirective() && "Standalone Executable OpenMP 
> > > > directives don't have structured blocks.")
> > > >   if (auto *LD = dyn_cast(this))
> > > > return LD->getBody();
> > > >   return getInnermostCapturedStmt()->getCapturedStmt();
> > > > }
> > > > ```
> > > > Hm, maybe that actually conveys more meaning..
> > > Great, that doesn't work, and highlights my concerns.
> > > `target enter data` / `target exit data` / `target update` are 
> > > stand-alone directives as per the spec,
> > > but not as per that `isStandaloneDirective()` check ^.
> > > https://godbolt.org/z/0tE93s
> > > 
> > > Is this a bug, or intentional?
> > Well, this is an incompatibility caused by previous not-quite correct 
> > implementation. It was reworked already, but these incorrect children still 
> > remain, I just had no time to clean them out. You can fix this.
> Okay, that is reassuring, thanks.
> this is an incompatibility caused by previous not-quite correct 
> implementation. It was reworked already,
> but these incorrect children still remain, I just had no time to clean them 
> out. You can fix this.

I have looked into this, and while parsing/sema changes are trivial, it has 
consequences for CodeGen.
In particular `CodeGenFunction::EmitOMPTargetEnterDataDirective()` & friends 
can no longer
create `OMPLexicalScope` with `OMPD_task`, or else it will assert that there 
are no associated stmts.

And more importantly, in the end 
`CodeGenFunction::EmitOMPTargetTaskBasedDirective()` tries to, again, 
get these assoc stmts, and fails. I'm guessing it shouldn't just bailout, then 
it would not emit anything?

Any hints would be appreciated.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59214/new/

https://reviews.llvm.org/D59214



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


[PATCH] D59299: [libclang] Expose aligned() attribute.

2019-03-13 Thread Emilio Cobos Álvarez via Phabricator via cfe-commits
emilio created this revision.
emilio added reviewers: Anastasia, arphaman.
Herald added a reviewer: serge-sans-paille.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This is useful because otherwise there's no easy way to distinguish #pragma
packed(N) from attribute(packed, aligned(N)) that isn't looking at field
offsets (since pragma packed() also creates a packed attribute).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D59299

Files:
  clang/bindings/python/clang/cindex.py
  clang/include/clang-c/Index.h
  clang/test/Index/attributes.c
  clang/tools/libclang/CIndex.cpp
  clang/tools/libclang/CXCursor.cpp


Index: clang/tools/libclang/CXCursor.cpp
===
--- clang/tools/libclang/CXCursor.cpp
+++ clang/tools/libclang/CXCursor.cpp
@@ -81,6 +81,7 @@
 case attr::Convergent: return CXCursor_ConvergentAttr;
 case attr::WarnUnused: return CXCursor_WarnUnusedAttr;
 case attr::WarnUnusedResult: return CXCursor_WarnUnusedResultAttr;
+case attr::Aligned: return CXCursor_AlignedAttr;
   }
 
   return CXCursor_UnexposedAttr;
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -5484,6 +5484,8 @@
   return cxstring::createRef("attribute(warn_unused)");
   case CXCursor_WarnUnusedResultAttr:
   return cxstring::createRef("attribute(warn_unused_result)");
+  case CXCursor_AlignedAttr:
+  return cxstring::createRef("attribute(aligned)");
   }
 
   llvm_unreachable("Unhandled CXCursorKind");
Index: clang/test/Index/attributes.c
===
--- clang/test/Index/attributes.c
+++ clang/test/Index/attributes.c
@@ -20,6 +20,14 @@
   int b;
 };
 
+struct __attribute__((aligned(64))) Aligned1 {
+  int c;
+};
+
+struct Aligned2 {
+  int c;
+} __attribute__((aligned(64)));
+
 // CHECK: attributes.c:3:32: StructDecl=Test2:3:32 (Definition) Extent=[3:1 - 
5:2]
 // CHECK: attributes.c:3:23: attribute(packed)=packed Extent=[3:23 - 3:29]
 // CHECK: attributes.c:4:8: FieldDecl=a:4:8 (Definition) Extent=[4:3 - 4:9] 
[access=public]
@@ -39,3 +47,7 @@
 // CHECK: attributes.c:17:44: attribute(warn_unused_result)= Extent=[17:44 - 
17:62]
 // CHECK: attributes.c:19:37: StructDecl=WarnUnused:19:37 (Definition) 
Extent=[19:1 - 21:2]
 // CHECK: attributes.c:19:23: attribute(warn_unused)= Extent=[19:23 - 19:34]
+// CHECK: attributes.c:23:37: StructDecl=Aligned1:23:37 (Definition) 
Extent=[23:1 - 25:2]
+// CHECK: attributes.c:23:23: attribute(aligned)= Extent=[23:23 - 23:34]
+// CHECK: attributes.c:27:8: StructDecl=Aligned2:27:8 (Definition) 
Extent=[27:1 - 29:2]
+// CHECK: attributes.c:29:18: attribute(aligned)= Extent=[29:18 - 29:29]
Index: clang/include/clang-c/Index.h
===
--- clang/include/clang-c/Index.h
+++ clang/include/clang-c/Index.h
@@ -32,7 +32,7 @@
  * compatible, thus CINDEX_VERSION_MAJOR is expected to remain stable.
  */
 #define CINDEX_VERSION_MAJOR 0
-#define CINDEX_VERSION_MINOR 53
+#define CINDEX_VERSION_MINOR 54
 
 #define CINDEX_VERSION_ENCODE(major, minor) ( \
   ((major) * 1)   \
@@ -2589,7 +2589,8 @@
   CXCursor_ConvergentAttr= 438,
   CXCursor_WarnUnusedAttr= 439,
   CXCursor_WarnUnusedResultAttr  = 440,
-  CXCursor_LastAttr  = CXCursor_WarnUnusedResultAttr,
+  CXCursor_AlignedAttr   = 441,
+  CXCursor_LastAttr  = CXCursor_AlignedAttr,
 
   /* Preprocessing */
   CXCursor_PreprocessingDirective= 500,
Index: clang/bindings/python/clang/cindex.py
===
--- clang/bindings/python/clang/cindex.py
+++ clang/bindings/python/clang/cindex.py
@@ -1345,6 +1345,7 @@
 CursorKind.CONVERGENT_ATTR = CursorKind(438)
 CursorKind.WARN_UNUSED_ATTR = CursorKind(439)
 CursorKind.WARN_UNUSED_RESULT_ATTR = CursorKind(440)
+CursorKind.ALIGNED_ATTR = CursorKind(441)
 
 ###
 # Preprocessing


Index: clang/tools/libclang/CXCursor.cpp
===
--- clang/tools/libclang/CXCursor.cpp
+++ clang/tools/libclang/CXCursor.cpp
@@ -81,6 +81,7 @@
 case attr::Convergent: return CXCursor_ConvergentAttr;
 case attr::WarnUnused: return CXCursor_WarnUnusedAttr;
 case attr::WarnUnusedResult: return CXCursor_WarnUnusedResultAttr;
+case attr::Aligned: return CXCursor_AlignedAttr;
   }
 
   return CXCursor_UnexposedAttr;
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -5484,6 +5484,8 @@
   return cxstring::createRef("attribute(warn_unused)");
   case CXCursor_WarnUnusedResultAttr:
   return c

[PATCH] D59300: [clangd] Tune the fuzzy-matching algorithm

2019-03-13 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov created this revision.
ilya-biryukov added a reviewer: ioeric.
Herald added subscribers: kadircet, arphaman, jkorous, MaskRay.
Herald added a project: clang.

It now gives less preference to prefix matches and does not penalize
skipping segments.

The motivation is producing better scoring in one particular example,
but the change does not seem to cause large regressions in other cases.

The examples is matching 'up' against 'unique_ptr' and 'upper_bound'.
Before the change, we had:

- "[u]nique_[p]tr" with a score of 0.3.
- "[up]per_bound" with a score of 1.0.

A 3x difference meant that symbol quality signals were almost always ignored
and 'upper_bound' was always ranked higher.

However, intuitively, the match scores should be very close for the two.
After the change both items match with a score of 1.0.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D59300

Files:
  clang-tools-extra/clangd/FuzzyMatch.cpp
  clang-tools-extra/unittests/clangd/FuzzyMatchTests.cpp

Index: clang-tools-extra/unittests/clangd/FuzzyMatchTests.cpp
===
--- clang-tools-extra/unittests/clangd/FuzzyMatchTests.cpp
+++ clang-tools-extra/unittests/clangd/FuzzyMatchTests.cpp
@@ -9,6 +9,7 @@
 #include "FuzzyMatch.h"
 
 #include "llvm/ADT/StringExtras.h"
+#include "gmock/gmock-matchers.h"
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
 
@@ -16,6 +17,7 @@
 namespace clangd {
 namespace {
 using testing::Not;
+using testing::AllOf;
 
 struct ExpectedMatch {
   // Annotations are optional, and will not be asserted if absent.
@@ -170,7 +172,10 @@
   EXPECT_THAT("zzg", matches("[zzG]roup"));
   EXPECT_THAT("g", matches("zz[G]roup"));
 
-  EXPECT_THAT("", matches("_a_[]")); // Prefer consecutive.
+  EXPECT_THAT("", matches("_a_[]")); // Prefer consecutive.
+  // All-lowercase patterns are special, they treat consecutive matches and
+  // head character matches the same, as the pattern lacks segmentation signals.
+  EXPECT_THAT("", matches("_[a]_[aaa]a"));
   // These would ideally match, but would need special segmentation rules.
   EXPECT_THAT("printf", Not(matches("s[printf]")));
   EXPECT_THAT("str", Not(matches("o[str]eam")));
@@ -246,7 +251,7 @@
   ranks("[cons]ole", "[Cons]ole", "ArrayBuffer[Cons]tructor"));
   EXPECT_THAT("foo", ranks("[foo]", "[Foo]"));
   EXPECT_THAT("onMes",
-  ranks("[onMes]sage", "[onmes]sage", "[on]This[M]ega[Es]capes"));
+  ranks("[onMes]sage", "[on]This[M]ega[Es]capes", "[onmes]sage"));
   EXPECT_THAT("CC", ranks("[C]amel[C]ase", "[c]amel[C]ase"));
   EXPECT_THAT("cC", ranks("[c]amel[C]ase", "[C]amel[C]ase"));
   EXPECT_THAT("p", ranks("[p]", "[p]arse", "[p]osix", "[p]afdsa", "[p]ath"));
@@ -270,12 +275,18 @@
 // Verify some bounds so we know scores fall in the right range.
 // Testing exact scores is fragile, so we prefer Ranking tests.
 TEST(FuzzyMatch, Scoring) {
-  EXPECT_THAT("abs", matches("[a]w[B]xYz[S]", 0.f));
+  EXPECT_THAT("abs", matches("[a]w[B]xYz[S]", 1.f));
   EXPECT_THAT("abs", matches("[abs]l", 1.f));
   EXPECT_THAT("abs", matches("[abs]", 2.f));
   EXPECT_THAT("Abs", matches("[abs]", 2.f));
 }
 
+TEST(FuzzyMatch, PrefixAndHead) {
+  // We want these scores to be roughly the same.
+  EXPECT_THAT("up", matches("[u]nique_[p]tr", 1.f));
+  EXPECT_THAT("up", matches("[up]per_bound", 1.f));
+}
+
 // Returns pretty-printed segmentation of Text.
 // e.g. std::basic_string --> +--  + +-
 std::string segment(llvm::StringRef Text) {
Index: clang-tools-extra/clangd/FuzzyMatch.cpp
===
--- clang-tools-extra/clangd/FuzzyMatch.cpp
+++ clang-tools-extra/clangd/FuzzyMatch.cpp
@@ -71,7 +71,7 @@
 // Score field is 15 bits wide, min value is -2^14, we use half of that.
 static constexpr int AwfulScore = -(1 << 13);
 static bool isAwful(int S) { return S < AwfulScore / 2; }
-static constexpr int PerfectBonus = 3; // Perfect per-pattern-char score.
+static constexpr int PerfectBonus = 2; // Perfect per-pattern-char score.
 
 FuzzyMatcher::FuzzyMatcher(llvm::StringRef Pattern)
 : PatN(std::min(MaxPat, Pattern.size())),
@@ -268,32 +268,25 @@
 
 int FuzzyMatcher::skipPenalty(int W, Action Last) const {
   int S = 0;
-  if (WordRole[W] == Head) // Skipping a segment.
-S += 1;
-  if (Last == Match) // Non-consecutive match.
-S += 2;  // We'd rather skip a segment than split our match.
+  if (W == 0) // Skipping the first character.
+S += 2;
   return S;
 }
 
 int FuzzyMatcher::matchBonus(int P, int W, Action Last) const {
   assert(LowPat[P] == LowWord[W]);
   int S = 1;
-  // Bonus: pattern so far is a (case-insensitive) prefix of the word.
-  if (P == W) // We can't skip pattern characters, so we must have matched all.
-++S;
-  // Bonus: case matches, or a Head in the pattern aligns with one in the word.
-  if ((Pat[P] == Word[W] && ((PatTypeSet & 1 << Upper) || P =

[PATCH] D59300: [clangd] Tune the fuzzy-matching algorithm

2019-03-13 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

I'll collect the metrics and post them here too


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59300/new/

https://reviews.llvm.org/D59300



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


[PATCH] D59214: [clang][OpeMP] Model OpenMP structured-block in AST (PR40563)

2019-03-13 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: include/clang/AST/StmtOpenMP.h:335
 
+  llvm::Optional getStructuredBlockImpl() const {
+return const_cast(getInnermostCapturedStmt()->getCapturedStmt());

lebedev.ri wrote:
> lebedev.ri wrote:
> > ABataev wrote:
> > > lebedev.ri wrote:
> > > > lebedev.ri wrote:
> > > > > ABataev wrote:
> > > > > > lebedev.ri wrote:
> > > > > > > ABataev wrote:
> > > > > > > > No need to insert it into each class, just add:
> > > > > > > > ```
> > > > > > > > Stmt * OMPExecutableDirective::getStructuredBlock() const {
> > > > > > > >   if (!hasAssociatedStmt() || !getAssociatedStmt())
> > > > > > > > return nullptr;
> > > > > > > >   if (auto *LD = dyn_cast(this))
> > > > > > > > return LD->getBody();
> > > > > > > >   return getInnermostCapturedStmt()->getCapturedStmt();
> > > > > > > > }
> > > > > > > > ```
> > > > > > > I absolutely can do that, you are sure that is the most 
> > > > > > > future-proof state?
> > > > > > > In particular, i want to re-point-out that if it's implemented 
> > > > > > > like this,
> > > > > > > in the base class, then the sub-class may(will) not even know 
> > > > > > > about this function,
> > > > > > > and thus 'forget' to update it, should it not be giving the 
> > > > > > > correct answer for
> > > > > > > that new specific OpenMP executable directive.
> > > > > > > 
> > > > > > > You are sure it's better to implement it in the 
> > > > > > > `OMPExecutableDirective` itself?
> > > > > > Yes, I'm sure. It is the universal solution and all future classes 
> > > > > > must be compatible with it. If they are not, then they are 
> > > > > > incorrect.
> > > > > Aha! Well, ok then.
> > > > > 
> > > > > Do you also suggest that `Optional<>` is too fancy?
> > > > > Would it be better to do this instead?
> > > > > ```
> > > > > bool isStandaloneDirective() const {
> > > > >   return !hasAssociatedStmt() || !getAssociatedStmt();
> > > > > }
> > > > > 
> > > > > // Requires: !isStandaloneDirective()
> > > > > Stmt *OMPExecutableDirective::getStructuredBlock() const {
> > > > >   assert(!isStandaloneDirective() && "Standalone Executable OpenMP 
> > > > > directives don't have structured blocks.")
> > > > >   if (auto *LD = dyn_cast(this))
> > > > > return LD->getBody();
> > > > >   return getInnermostCapturedStmt()->getCapturedStmt();
> > > > > }
> > > > > ```
> > > > > Hm, maybe that actually conveys more meaning..
> > > > Great, that doesn't work, and highlights my concerns.
> > > > `target enter data` / `target exit data` / `target update` are 
> > > > stand-alone directives as per the spec,
> > > > but not as per that `isStandaloneDirective()` check ^.
> > > > https://godbolt.org/z/0tE93s
> > > > 
> > > > Is this a bug, or intentional?
> > > Well, this is an incompatibility caused by previous not-quite correct 
> > > implementation. It was reworked already, but these incorrect children 
> > > still remain, I just had no time to clean them out. You can fix this.
> > Okay, that is reassuring, thanks.
> > this is an incompatibility caused by previous not-quite correct 
> > implementation. It was reworked already,
> > but these incorrect children still remain, I just had no time to clean them 
> > out. You can fix this.
> 
> I have looked into this, and while parsing/sema changes are trivial, it has 
> consequences for CodeGen.
> In particular `CodeGenFunction::EmitOMPTargetEnterDataDirective()` & friends 
> can no longer
> create `OMPLexicalScope` with `OMPD_task`, or else it will assert that there 
> are no associated stmts.
> 
> And more importantly, in the end 
> `CodeGenFunction::EmitOMPTargetTaskBasedDirective()` tries to, again, 
> get these assoc stmts, and fails. I'm guessing it shouldn't just bailout, 
> then it would not emit anything?
> 
> Any hints would be appreciated.
Ahh, now I recall why it was required. It is needed to support the asynchronous 
data transfers. It can be reworked to avoid adding those special associated 
statements but it requires significant amount of time.
You can just add a check for those 3 directives in this `Stmt 
*OMPExecutableDirective::getStructuredBlock()` and return `nullptr` for them 
explicitly. I think it is still better than adding a whole bunch of those 
`getStructuredStmt` functions for each class. Plus, using this single function, 
you can apply it to the base `OMPExecutableDirective` class rather than to the 
derived classes. Some matchers could prefer to do this.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59214/new/

https://reviews.llvm.org/D59214



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


[PATCH] D59223: Objective-C++11: Support static_assert() in @interface/@implementation ivar lists and method declarations

2019-03-13 Thread Nico Weber via Phabricator via cfe-commits
thakis updated this revision to Diff 190418.
thakis edited the summary of this revision.
thakis added a comment.

two features


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59223/new/

https://reviews.llvm.org/D59223

Files:
  clang/include/clang/Basic/Features.def
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/ParseObjc.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/Parser/objc-static-assert.m
  clang/test/Parser/objc-static-assert.mm

Index: clang/test/Parser/objc-static-assert.mm
===
--- /dev/null
+++ clang/test/Parser/objc-static-assert.mm
@@ -0,0 +1,74 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
+// RUN: %clang_cc1 -std=c++98 -fsyntax-only -verify -Wno-objc-root-class %s
+
+#if !__has_feature(objc_c_static_assert)
+#error failed
+#endif
+
+#if __cplusplus >= 201103L
+
+#if !__has_feature(objc_cxx_static_assert)
+#error failed
+#endif
+
+// C++11
+
+@interface A {
+  int a;
+  static_assert(1, "");
+  _Static_assert(1, "");
+
+  static_assert(0, ""); // expected-error {{static_assert failed}}
+  _Static_assert(0, ""); // expected-error {{static_assert failed}}
+
+  static_assert(a, ""); // expected-error {{static_assert expression is not an integral constant expression}}
+  static_assert(sizeof(a) == 4, "");
+  static_assert(sizeof(a) == 3, ""); // expected-error {{static_assert failed}}
+}
+
+static_assert(1, "");
+_Static_assert(1, "");
+
+- (void)f;
+@end
+
+@implementation A {
+  int b;
+  static_assert(1, "");
+  _Static_assert(1, "");
+  static_assert(sizeof(b) == 4, "");
+  static_assert(sizeof(b) == 3, ""); // expected-error {{static_assert failed}}
+}
+
+static_assert(1, "");
+
+- (void)f {
+  static_assert(1, "");
+}
+@end
+
+@interface B
+@end
+
+@interface B () {
+  int b;
+  static_assert(sizeof(b) == 4, "");
+  static_assert(sizeof(b) == 3, ""); // expected-error {{static_assert failed}}
+}
+@end
+
+#else
+
+#if __has_feature(objc_cxx_static_assert)
+#error failed
+#endif
+
+// C++98
+@interface A {
+  int a;
+  static_assert(1, ""); // expected-error {{type name requires a specifier or qualifier}} expected-error{{expected parameter declarator}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  _Static_assert(1, "");
+  _Static_assert(0, ""); // expected-error {{static_assert failed}}
+}
+@end
+#endif
Index: clang/test/Parser/objc-static-assert.m
===
--- /dev/null
+++ clang/test/Parser/objc-static-assert.m
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -fobjc-runtime=macosx-fragile -fsyntax-only -verify -Wno-objc-root-class %s
+
+#if !__has_feature(objc_c_static_assert)
+#error failed
+#endif
+
+@interface A {
+  int a;
+  _Static_assert(1, "");
+  _Static_assert(0, ""); // expected-error {{static_assert failed}}
+
+  _Static_assert(a, ""); // expected-error {{use of undeclared identifier 'a'}}
+  _Static_assert(sizeof(a), ""); // expected-error {{use of undeclared identifier 'a'}}
+}
+
+_Static_assert(1, "");
+
+@end
+
+struct S {
+  @defs(A);
+};
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -2998,7 +2998,6 @@
 
 // These shouldn't make it here.
 case Decl::ObjCAtDefsField:
-case Decl::ObjCIvar:
   llvm_unreachable("forming non-member reference to ivar?");
 
 // Enum constants are always r-values and never references.
@@ -3016,6 +3015,7 @@
 // exist in the high-level semantics.
 case Decl::Field:
 case Decl::IndirectField:
+case Decl::ObjCIvar:
   assert(getLangOpts().CPlusPlus &&
  "building reference to field in C?");
 
Index: clang/lib/Parse/ParseObjc.cpp
===
--- clang/lib/Parse/ParseObjc.cpp
+++ clang/lib/Parse/ParseObjc.cpp
@@ -623,6 +623,8 @@
 }
 // Ignore excess semicolons.
 if (Tok.is(tok::semi)) {
+  // FIXME: This should use ConsumeExtraSemi() for extraneous semicolons,
+  // to make -Wextra-semi diagnose them.
   ConsumeToken();
   continue;
 }
@@ -646,7 +648,19 @@
   // erroneous r_brace would cause an infinite loop if not handled here.
   if (Tok.is(tok::r_brace))
 break;
+
   ParsedAttributesWithRange attrs(AttrFactory);
+
+  // Since we call ParseDeclarationOrFunctionDefinition() instead of
+  // ParseExternalDeclaration() below (so that this doesn't parse nested
+  // @interfaces), this needs to duplicate some code from the latter.
+  if (Tok.isOneOf(tok::kw_static_assert, tok::kw__Static_assert)) {
+SourceLocation DeclEnd;
+allTUVariables.push_back(
+ParseDeclaration(DeclaratorContext::FileContext, DeclEnd, attrs));
+continue;
+  }
+
   allTUVariables.push_back(ParseDeclarationOrFunctionDefinition(attrs));
   continue;
 }
@@ -1875,6 +1889,7 @@

[PATCH] D59223: Objective-C++11: Support static_assert() in @interface/@implementation ivar lists and method declarations

2019-03-13 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

Seems like this wasn't convincing, so now with two separate feature flags. I 
went with the shorter name, since adding "interface_" isn't just longer but 
also misleading, since this also works in @implementation ivar blocks now.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59223/new/

https://reviews.llvm.org/D59223



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


[PATCH] D59287: [X86] Only define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_16 in 64-bit mode.

2019-03-13 Thread JF Bastien via Phabricator via cfe-commits
jfb added a comment.

I don't think this is quite right: CX16 is literally "I have cmpxchg16b".

In clang/lib/Basic/Targets/X86.h we do:

  void setMaxAtomicWidth() override {
if (hasFeature("cx16"))
  MaxAtomicInlineWidth = 128;
  }

Your change makes it inconsistent.

We also have `HasCX16` which should be kept consistent.

The problem seems to be that cx16 can be set for 32-bit targets.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59287/new/

https://reviews.llvm.org/D59287



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


[clang-tools-extra] r356055 - [clangd] Fix a typo in doc.

2019-03-13 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Wed Mar 13 08:22:31 2019
New Revision: 356055

URL: http://llvm.org/viewvc/llvm-project?rev=356055&view=rev
Log:
[clangd] Fix a typo in doc.

Modified:
clang-tools-extra/trunk/docs/clangd/Installation.rst

Modified: clang-tools-extra/trunk/docs/clangd/Installation.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clangd/Installation.rst?rev=356055&r1=356054&r2=356055&view=diff
==
--- clang-tools-extra/trunk/docs/clangd/Installation.rst (original)
+++ clang-tools-extra/trunk/docs/clangd/Installation.rst Wed Mar 13 08:22:31 
2019
@@ -368,4 +368,4 @@ project-wide index to clangd.  There are
   Then you can pass generated index file to clangd using
   `-index-file=/path/to/index_file`.  *Note that clangd-indexer isn't
   included alongside clangd in the Debian clang-tools package. You will
-  likely have to build clangd from source to use this option.*
+  likely have to build it from source to use this option.*


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


[PATCH] D59299: [libclang] Expose aligned() attribute.

2019-03-13 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia accepted this revision.
Anastasia added a comment.
This revision is now accepted and ready to land.

LGTM! Thanks!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59299/new/

https://reviews.llvm.org/D59299



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


[PATCH] D59287: [X86] Only define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_16 in 64-bit mode.

2019-03-13 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

Isn’t that setMaxAtomicWidth in the x86-64 derived class?

As far as preventing “cx16” from being set in 32-bit mode, we’ll need to check 
the behavior of CPUID in 32-bit mode or -march=native might still end up 
setting it.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59287/new/

https://reviews.llvm.org/D59287



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


[PATCH] D58556: [LibTooling] Add "smart" retrieval of AST-node source to FixIt library

2019-03-13 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

Ah, had some comments and forgot to send them out before I went on vacation :-(




Comment at: clang/include/clang/Tooling/FixIt.h:60
+// future to include more associated text (like comments).
+CharSourceRange getSourceRangeAuto(const Stmt &S, ASTContext &Context);
+

ymandel wrote:
> ilya-biryukov wrote:
> > Do you have alternative names in mind? It would be nice to (1) not mention 
> > the SourceRange now that we return CharSourceRange, (2) change "auto" to 
> > something more descriptive.
> > 
> > Was thinking about `getNodeRange()` or `getSpannedRange()`, but that 
> > completely misses the "auto" part (maybe it's fine, though).
> > WDYT? Maybe other ideas?
> I completely agree. I went through quite a few iterations on this name and 
> disliked this one the least.  ;)  I think you're right, though, that once 
> we're choosing a different name, the "auto" part doesn't really need to be in 
> it.  I like `getSpannedRange` better than this. Other thoughts:
> 
> getLogicalRange
> getExtendedRange
> getAssociatedRange
> 
> any preference?
`getSpannedRange` and `getAssociatedRange` would be my favorites.
Both seem to leave no room for interpretation.



Comment at: clang/include/clang/Tooling/FixIt.h:73
+// context. In contrast with \p getText(), this function selects a source range
+// "automatically", extracting text that a reader might intuitively associate
+// with a node.  Currently, only specialized for \p clang::Stmt, where it will

ymandel wrote:
> ilya-biryukov wrote:
> > What are other tricky cases you have in mind for the future?
> I just assumed that we'd hit more as we dig into them, but, I'm not so sure 
> now.  The two others I can think of offhand are 1) extending to include 
> associated comments, 2) semicolons after declarations.  Commas present a 
> similar challenge (if a bit simpler) when used in a list (vs. the comma 
> operator).  Are there any other separators in C++? 
> 
> At a higher level, it would be nice to align this with your work on tree 
> transformations. That is, think of these functions as short-term shims to 
> simulate the behavior we'll ultimately get from that new library. However, it 
> might be premature to consider those details here.
Would it be fair to characterize those as "the text range that you needs to be 
removed when removing a node"?
Trying to come up with a comment that does not rely on the intuition, since 
that might differ from one reader to the other.

Maybe move this comment to `getSourceRangeAuto` and in this function's comment 
simply mention that we return the text for the node covered with 
`getSourceRangeAuto`?

> At a higher level, it would be nice to align this with your work on tree 
> transformations. That is, think of these functions as short-term shims to 
> simulate the behavior we'll ultimately get from that new library. However, it 
> might be premature to consider those details here.
Agree, we can figure it out as soon as the syntax trees are in a good enough 
shape.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58556/new/

https://reviews.llvm.org/D58556



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


[PATCH] D58556: [LibTooling] Add "smart" retrieval of AST-node source to FixIt library

2019-03-13 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

Ignore my previous comment, I'll take another look


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58556/new/

https://reviews.llvm.org/D58556



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


[PATCH] D59287: [X86] Only define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_16 in 64-bit mode.

2019-03-13 Thread JF Bastien via Phabricator via cfe-commits
jfb added a comment.

In D59287#1427485 , @craig.topper 
wrote:

> Isn’t that setMaxAtomicWidth in the x86-64 derived class?


Right you are!

> As far as preventing “cx16” from being set in 32-bit mode, we’ll need to 
> check the behavior of CPUID in 32-bit mode or -march=native might still end 
> up setting it.

What I want to make sure is that your fix to the macro (which seems correct!) 
doesn't diverge from what the rest LLVM ends up doing with atomics. i.e. the 
macro says "no cmpxchg16b" but somehow codegen does generate it.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59287/new/

https://reviews.llvm.org/D59287



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


[PATCH] D58556: [LibTooling] Add "smart" retrieval of AST-node source to FixIt library

2019-03-13 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov accepted this revision.
ilya-biryukov added a comment.
This revision is now accepted and ready to land.

LGTM.
`getExtendedRange` is a really good choice!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58556/new/

https://reviews.llvm.org/D58556



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


r356060 - Add AIX Target Info

2019-03-13 Thread Jason Liu via cfe-commits
Author: jasonliu
Date: Wed Mar 13 09:02:26 2019
New Revision: 356060

URL: http://llvm.org/viewvc/llvm-project?rev=356060&view=rev
Log:
Add AIX Target Info

Summary:
A first pass over platform-specific properties of the C API/ABI
on AIX for both 32-bit and 64-bit modes.
This is a continuation of D18360 by Andrew Paprocki and further work by Wu Zhao.

Patch by Andus Yu

Reviewers: apaprocki, chandlerc, hubert.reinterpretcast, jasonliu,
xingxue, sfertile

Reviewed by: hubert.reinterpretcast, apaprocki, sfertile

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

Added:
cfe/trunk/test/Headers/max_align.c
cfe/trunk/test/Sema/varargs-aix.c
Modified:
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/lib/Basic/Targets/OSTargets.h
cfe/trunk/lib/Basic/Targets/PPC.cpp
cfe/trunk/lib/Basic/Targets/PPC.h
cfe/trunk/test/Driver/types.c
cfe/trunk/test/Preprocessor/init.c

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=356060&r1=356059&r2=356060&view=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Wed Mar 13 09:02:26 2019
@@ -332,6 +332,8 @@ TargetInfo *AllocateTarget(const llvm::T
   return new OpenBSDTargetInfo(Triple, Opts);
 case llvm::Triple::RTEMS:
   return new RTEMSTargetInfo(Triple, Opts);
+case llvm::Triple::AIX:
+  return new AIXPPC32TargetInfo(Triple, Opts);
 default:
   return new PPC32TargetInfo(Triple, Opts);
 }
@@ -348,6 +350,8 @@ TargetInfo *AllocateTarget(const llvm::T
   return new FreeBSDTargetInfo(Triple, Opts);
 case llvm::Triple::NetBSD:
   return new NetBSDTargetInfo(Triple, Opts);
+case llvm::Triple::AIX:
+  return new AIXPPC64TargetInfo(Triple, Opts);
 default:
   return new PPC64TargetInfo(Triple, Opts);
 }

Modified: cfe/trunk/lib/Basic/Targets/OSTargets.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/OSTargets.h?rev=356060&r1=356059&r2=356060&view=diff
==
--- cfe/trunk/lib/Basic/Targets/OSTargets.h (original)
+++ cfe/trunk/lib/Basic/Targets/OSTargets.h Wed Mar 13 09:02:26 2019
@@ -613,6 +613,53 @@ public:
   }
 };
 
+// AIX Target
+template 
+class AIXTargetInfo : public OSTargetInfo {
+protected:
+  void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple,
+MacroBuilder &Builder) const override {
+DefineStd(Builder, "unix", Opts);
+Builder.defineMacro("_IBMR2");
+Builder.defineMacro("_POWER");
+
+// FIXME: Define AIX OS-Version Macros.
+Builder.defineMacro("_AIX");
+
+// FIXME: Do not define _LONG_LONG when -fno-long-long is specified.
+Builder.defineMacro("_LONG_LONG");
+
+if (Opts.POSIXThreads) {
+  Builder.defineMacro("_THREAD_SAFE");
+}
+
+if (this->PointerWidth == 64) {
+  Builder.defineMacro("__64BIT__");
+}
+
+// Define _WCHAR_T when it is a fundamental type
+// (i.e., for C++ without -fno-wchar).
+if (Opts.CPlusPlus && Opts.WChar) {
+  Builder.defineMacro("_WCHAR_T");
+}
+  }
+
+public:
+  AIXTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
+  : OSTargetInfo(Triple, Opts) {
+if (this->PointerWidth == 64) {
+  this->WCharType = this->UnsignedInt;
+} else {
+  this->WCharType = this->UnsignedShort;
+}
+this->UseZeroLengthBitfieldAlignment = true;
+  }
+
+  // AIX sets FLT_EVAL_METHOD to be 1.
+  unsigned getFloatEvalMethod() const override { return 1; }
+  bool hasInt128Type() const override { return false; }
+};
+
 // Windows target
 template 
 class LLVM_LIBRARY_VISIBILITY WindowsTargetInfo : public OSTargetInfo {

Modified: cfe/trunk/lib/Basic/Targets/PPC.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/PPC.cpp?rev=356060&r1=356059&r2=356060&view=diff
==
--- cfe/trunk/lib/Basic/Targets/PPC.cpp (original)
+++ cfe/trunk/lib/Basic/Targets/PPC.cpp Wed Mar 13 09:02:26 2019
@@ -100,7 +100,9 @@ void PPCTargetInfo::getTargetDefines(con
 Builder.defineMacro("_CALL_LINUX", "1");
 
   // Subtarget options.
-  Builder.defineMacro("__NATURAL_ALIGNMENT__");
+  if (!getTriple().isOSAIX()){
+Builder.defineMacro("__NATURAL_ALIGNMENT__");
+  }
   Builder.defineMacro("__REGISTER_PREFIX__", "");
 
   // FIXME: Should be controlled by command line option.

Modified: cfe/trunk/lib/Basic/Targets/PPC.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/PPC.h?rev=356060&r1=356059&r2=356060&view=diff
==
--- cfe/trunk/lib/Basic/Targets/PPC.h (original)
+++ cfe/trunk/lib/Basic/Targets/PPC.h Wed Mar 13 09:02:26 2019
@@ -325,6 +325,12 @@ public:
   PtrDiffType = SignedInt;
   IntPt

[PATCH] D59300: [clangd] Tune the fuzzy-matching algorithm

2019-03-13 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

Here are some initial measurements with the current metrics that we have. We 
seem to regress significantly in some cases. This is expected, since we only 
check the prefix matches there.
@ioeric is working on including the non-prefix (more concretely, initialism 
matches) into the metrics, we'll update when we get those metrics too.

  
==
  OVERALL (excl. CROSS_NAMESPACE)
  
==
Total measurements: 109166 (+0)
Average latency (ms): 219.219589233 (-7)
All measurements:
MRR: 69.12 (-0.93)  Top-1: 59.54% (-1.20%)  Top-5: 81.21% (-0.48%)  
Top-100: 96.06% (-0.10%)
Full identifiers:
MRR: 97.68 (-0.54)  Top-1: 96.62% (-0.96%)  Top-5: 98.96% (-0.07%)  
Top-100: 99.15% (-0.01%)
Filter length 0-5:
MRR:  29.11 (+0.00) 62.02 (+0.41)   70.71 (-1.45)   
73.41 (-1.18)   75.44 (-1.71)   78.78 (-2.50)
Top-1:17.49% (+0.00%)   49.19% (+0.50%) 59.52% 
(-1.51%) 62.47% (-1.41%) 65.27% (-2.11%) 69.25% (-3.53%)
Top-5:42.45% (+0.00%)   78.99% (+0.39%) 85.48% 
(-1.01%) 87.21% (-0.87%) 88.26% (-1.05%) 90.83% (-0.94%)
Top-100:  84.62% (+0.00%)   96.75% (+0.15%) 98.03% 
(-0.16%) 98.22% (-0.23%) 98.29% (-0.31%) 98.47% (-0.23%)
  
==
  DEFAULT
  
==
Total measurements: 52054 (+0)
Average latency (ms): 251.10333252 (-8)
All measurements:
MRR: 61.26 (-1.13)  Top-1: 51.13% (-1.31%)  Top-5: 74.10% (-0.68%)  
Top-100: 92.60% (-0.21%)
Full identifiers:
MRR: 96.31 (-0.24)  Top-1: 95.08% (-0.33%)  Top-5: 97.93% (-0.09%)  
Top-100: 98.30% (-0.01%)
Filter length 0-5:
MRR:  16.78 (+0.00) 48.89 (+0.32)   62.07 (-2.05)   
66.09 (-1.67)   69.65 (-2.45)   72.49 (-2.23)
Top-1:9.06% (+0.00%)34.63% (+0.25%) 49.11% 
(-2.03%) 53.07% (-1.99%) 58.01% (-2.83%) 61.95% (-2.74%)
Top-5:23.57% (+0.00%)   68.10% (+0.52%) 79.78% 
(-1.35%) 82.73% (-1.26%) 84.63% (-1.66%) 86.08% (-1.19%)
Top-100:  70.73% (+0.00%)   93.67% (+0.29%) 96.41% 
(-0.31%) 96.77% (-0.47%) 96.92% (-0.63%) 97.07% (-0.47%)
  
==
  EXPLICIT_MEMBER_ACCESS
  
==
Total measurements: 30470 (+0)
Average latency (ms): 114.196846008 (-5)
All measurements:
MRR: 67.95 (-1.05)  Top-1: 58.04% (-1.53%)  Top-5: 80.28% (-0.43%)  
Top-100: 98.64% (-0.01%)
Full identifiers:
MRR: 98.19 (-1.45)  Top-1: 96.69% (-2.75%)  Top-5: 99.83% (-0.07%)  
Top-100: 99.89% (+0.00%)
Filter length 0-5:
MRR:  27.70 (+0.00) 62.41 (+0.78)   68.45 (-1.11)   
70.82 (-0.71)   72.00 (-1.10)   78.54 (-4.29)
Top-1:16.41% (+0.00%)   49.21% (+1.05%) 57.13% 
(-1.02%) 60.02% (-0.71%) 61.31% (-1.43%) 67.65% (-6.68%)
Top-5:39.39% (+0.00%)   80.05% (+0.52%) 83.26% 
(-1.18%) 84.73% (-0.69%) 85.38% (-0.69%) 92.24% (-1.05%)
Top-100:  94.25% (+0.00%)   99.21% (+0.02%) 99.20% 
(-0.04%) 99.24% (-0.02%) 99.26% (-0.02%) 99.71% (+0.00%)
  
==
  WANT_LOCAL
  
==
Total measurements: 26642 (+0)
Average latency (ms): 277.036773682 (-7)
All measurements:
MRR: 85.82 (-0.40)  Top-1: 77.69% (-0.60%)  Top-5: 96.18% (-0.13%)  
Top-100: 99.88% (+0.00%)
Full identifiers:
MRR: 99.63 (-0.11)  Top-1: 99.37% (-0.21%)  Top-5: 99.91% (-0.02%)  
Top-100: 99.93% (+0.00%)
Filter length 0-5:
MRR:  53.07 (+0.00) 86.94 (+0.19)   90.42 (-0.64)   
91.19 (-0.74)   91.51 (-0.94)   92.59 (-0.81)
Top-1:34.01% (+0.00%)   77.25% (+0.34%) 82.89% 
(-1

[PATCH] D59048: Add AIX Target Info

2019-03-13 Thread Jason Liu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC356060: Add AIX Target Info (authored by jasonliu, committed 
by ).

Changed prior to commit:
  https://reviews.llvm.org/D59048?vs=190133&id=190425#toc

Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59048/new/

https://reviews.llvm.org/D59048

Files:
  lib/Basic/Targets.cpp
  lib/Basic/Targets/OSTargets.h
  lib/Basic/Targets/PPC.cpp
  lib/Basic/Targets/PPC.h
  test/Driver/types.c
  test/Headers/max_align.c
  test/Preprocessor/init.c
  test/Sema/varargs-aix.c

Index: test/Preprocessor/init.c
===
--- test/Preprocessor/init.c
+++ test/Preprocessor/init.c
@@ -6409,6 +6409,209 @@
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc64-none-none -target-feature +float128 -target-cpu power9 -fno-signed-char < /dev/null | FileCheck -check-prefix PPC-FLOAT128 %s
 // PPC-FLOAT128:#define __FLOAT128__ 1
 //
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc64-ibm-aix7.1.0.0 -fno-signed-char < /dev/null | FileCheck -match-full-lines -check-prefix PPC64-AIX %s
+//
+// PPC64-AIX:#define _AIX 1
+// PPC64-AIX:#define _ARCH_PPC 1
+// PPC64-AIX:#define _ARCH_PPC64 1
+// PPC64-AIX:#define _BIG_ENDIAN 1
+// PPC64-AIX:#define _IBMR2 1
+// PPC64-AIX-NOT:#define _ILP32 1
+// PPC64-AIX:#define _LONG_LONG 1
+// PPC64-AIX:#define _LP64 1
+// PPC64-AIX:#define _POWER 1
+// PPC64-AIX:#define __64BIT__ 1
+// PPC64-AIX:#define __BIGGEST_ALIGNMENT__ 8
+// PPC64-AIX:#define __BIG_ENDIAN__ 1
+// PPC64-AIX:#define __BYTE_ORDER__ __ORDER_BIG_ENDIAN__
+// PPC64-AIX:#define __CHAR16_TYPE__ unsigned short
+// PPC64-AIX:#define __CHAR32_TYPE__ unsigned int
+// PPC64-AIX:#define __CHAR_BIT__ 8
+// PPC64-AIX:#define __CHAR_UNSIGNED__ 1
+// PPC64-AIX:#define __DBL_DENORM_MIN__ 4.9406564584124654e-324
+// PPC64-AIX:#define __DBL_DIG__ 15
+// PPC64-AIX:#define __DBL_EPSILON__ 2.2204460492503131e-16
+// PPC64-AIX:#define __DBL_HAS_DENORM__ 1
+// PPC64-AIX:#define __DBL_HAS_INFINITY__ 1
+// PPC64-AIX:#define __DBL_HAS_QUIET_NAN__ 1
+// PPC64-AIX:#define __DBL_MANT_DIG__ 53
+// PPC64-AIX:#define __DBL_MAX_10_EXP__ 308
+// PPC64-AIX:#define __DBL_MAX_EXP__ 1024
+// PPC64-AIX:#define __DBL_MAX__ 1.7976931348623157e+308
+// PPC64-AIX:#define __DBL_MIN_10_EXP__ (-307)
+// PPC64-AIX:#define __DBL_MIN_EXP__ (-1021)
+// PPC64-AIX:#define __DBL_MIN__ 2.2250738585072014e-308
+// PPC64-AIX:#define __DECIMAL_DIG__ __LDBL_DECIMAL_DIG__
+// PPC64-AIX:#define __FLT_DENORM_MIN__ 1.40129846e-45F
+// PPC64-AIX:#define __FLT_DIG__ 6
+// PPC64-AIX:#define __FLT_EPSILON__ 1.19209290e-7F
+// PPC64-AIX:#define __FLT_EVAL_METHOD__ 1
+// PPC64-AIX:#define __FLT_HAS_DENORM__ 1
+// PPC64-AIX:#define __FLT_HAS_INFINITY__ 1
+// PPC64-AIX:#define __FLT_HAS_QUIET_NAN__ 1
+// PPC64-AIX:#define __FLT_MANT_DIG__ 24
+// PPC64-AIX:#define __FLT_MAX_10_EXP__ 38
+// PPC64-AIX:#define __FLT_MAX_EXP__ 128
+// PPC64-AIX:#define __FLT_MAX__ 3.40282347e+38F
+// PPC64-AIX:#define __FLT_MIN_10_EXP__ (-37)
+// PPC64-AIX:#define __FLT_MIN_EXP__ (-125)
+// PPC64-AIX:#define __FLT_MIN__ 1.17549435e-38F
+// PPC64-AIX:#define __FLT_RADIX__ 2
+// PPC64-AIX-NOT:#define __ILP32__ 1
+// PPC64-AIX:#define __INT16_C_SUFFIX__
+// PPC64-AIX:#define __INT16_FMTd__ "hd"
+// PPC64-AIX:#define __INT16_FMTi__ "hi"
+// PPC64-AIX:#define __INT16_MAX__ 32767
+// PPC64-AIX:#define __INT16_TYPE__ short
+// PPC64-AIX:#define __INT32_C_SUFFIX__
+// PPC64-AIX:#define __INT32_FMTd__ "d"
+// PPC64-AIX:#define __INT32_FMTi__ "i"
+// PPC64-AIX:#define __INT32_MAX__ 2147483647
+// PPC64-AIX:#define __INT32_TYPE__ int
+// PPC64-AIX:#define __INT64_C_SUFFIX__ L
+// PPC64-AIX:#define __INT64_FMTd__ "ld"
+// PPC64-AIX:#define __INT64_FMTi__ "li"
+// PPC64-AIX:#define __INT64_MAX__ 9223372036854775807L
+// PPC64-AIX:#define __INT64_TYPE__ long int
+// PPC64-AIX:#define __INT8_C_SUFFIX__
+// PPC64-AIX:#define __INT8_FMTd__ "hhd"
+// PPC64-AIX:#define __INT8_FMTi__ "hhi"
+// PPC64-AIX:#define __INT8_MAX__ 127
+// PPC64-AIX:#define __INT8_TYPE__ signed char
+// PPC64-AIX:#define __INTMAX_C_SUFFIX__ L
+// PPC64-AIX:#define __INTMAX_FMTd__ "ld"
+// PPC64-AIX:#define __INTMAX_FMTi__ "li"
+// PPC64-AIX:#define __INTMAX_MAX__ 9223372036854775807L
+// PPC64-AIX:#define __INTMAX_TYPE__ long int
+// PPC64-AIX:#define __INTMAX_WIDTH__ 64
+// PPC64-AIX:#define __INTPTR_FMTd__ "ld"
+// PPC64-AIX:#define __INTPTR_FMTi__ "li"
+// PPC64-AIX:#define __INTPTR_MAX__ 9223372036854775807L
+// PPC64-AIX:#define __INTPTR_TYPE__ long int
+// PPC64-AIX:#define __INTPTR_WIDTH__ 64
+// PPC64-AIX:#define __INT_FAST16_FMTd__ "hd"
+// PPC64-AIX:#define __INT_FAST16_FMTi__ "hi"
+// PPC64-AIX:#define __INT_FAST16_MAX__ 32767
+// PPC64-AIX:#define __INT_FAST16_TYPE__ short
+// PPC64-AIX:#define __INT_FAST32_FMTd__ "d"
+// PPC64-AIX:#define __INT_FAST32_FMTi__ "i"
+// PPC64-AIX:#define __INT_FAST32_MAX__ 2147483647
+// PPC64-AIX:#define __INT_FAST32_TYPE__ int
+// PPC64

[PATCH] D59302: [clangd] Surface diagnostics from headers inside main file

2019-03-13 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet added reviewers: ioeric, ilya-biryukov.
Herald added subscribers: cfe-commits, jdoerfert, arphaman, jkorous, MaskRay.
Herald added a project: clang.

Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D59302

Files:
  clangd/ClangdServer.cpp
  clangd/ClangdServer.h
  clangd/ClangdUnit.cpp
  clangd/Compiler.h
  clangd/Diagnostics.cpp
  clangd/tool/ClangdMain.cpp
  unittests/clangd/DiagnosticsTests.cpp

Index: unittests/clangd/DiagnosticsTests.cpp
===
--- unittests/clangd/DiagnosticsTests.cpp
+++ unittests/clangd/DiagnosticsTests.cpp
@@ -9,6 +9,7 @@
 #include "Annotations.h"
 #include "ClangdUnit.h"
 #include "SourceCode.h"
+#include "TestFS.h"
 #include "TestIndex.h"
 #include "TestTU.h"
 #include "index/MemIndex.h"
@@ -73,7 +74,6 @@
   return true;
 }
 
-
 // Helper function to make tests shorter.
 Position pos(int line, int character) {
   Position Res;
@@ -603,7 +603,144 @@
   "Add include \"x.h\" for symbol a::X");
 }
 
+ParsedAST
+build(const std::string &MainFile, const llvm::StringMap &Files,
+  llvm::Optional LimitDiagsOutsideMainFile = llvm::None) {
+  std::vector Cmd = {"clang", MainFile.c_str()};
+  ParseInputs Inputs;
+  Inputs.CompileCommand.Filename = MainFile;
+  Inputs.CompileCommand.CommandLine = {Cmd.begin(), Cmd.end()};
+  Inputs.CompileCommand.Directory = testRoot();
+  Inputs.Contents = Files.lookup(MainFile);
+  Inputs.FS = buildTestFS(Files);
+  Inputs.Opts = ParseOptions();
+  Inputs.Opts.LimitDiagsOutsideMainFile = LimitDiagsOutsideMainFile;
+  auto PCHs = std::make_shared();
+  auto CI = buildCompilerInvocation(Inputs);
+  assert(CI && "Failed to build compilation invocation.");
+  auto Preamble =
+  buildPreamble(MainFile, *CI,
+/*OldPreamble=*/nullptr,
+/*OldCompileCommand=*/Inputs.CompileCommand, Inputs, PCHs,
+/*StoreInMemory=*/true, /*PreambleCallback=*/nullptr);
+  auto AST = buildAST(MainFile, createInvocationFromCommandLine(Cmd), Inputs,
+  Preamble, PCHs);
+  if (!AST.hasValue()) {
+ADD_FAILURE() << "Failed to build code:\n" << Files.lookup(MainFile);
+llvm_unreachable("Failed to build TestTU!");
+  }
+  return std::move(*AST);
+}
+
+TEST(DiagsInHeaders, DiagInsideHeader) {
+  Annotations Main(R"cpp(
+#include [["a.h"]]
+void foo() {})cpp");
+  std::string MainFile = testPath("main.cc");
+  llvm::StringMap Files = {{MainFile, Main.code()},
+{testPath("a.h"), "no_type_spec;"}};
+  auto FS = buildTestFS(Files);
+
+  EXPECT_THAT(build(MainFile, Files).getDiagnostics(),
+  UnorderedElementsAre(Diag(Main.range(),
+"Error in header: C++ requires a type "
+"specifier for all declarations")));
+}
+
+TEST(DiagsInHeaders, DiagInTransitiveInclude) {
+  Annotations Main(R"cpp(
+#include [["a.h"]]
+void foo() {})cpp");
+  std::string MainFile = testPath("main.cc");
+  llvm::StringMap Files = {{MainFile, Main.code()},
+{testPath("a.h"), "#include \"b.h\""},
+{testPath("b.h"), "no_type_spec;"}};
+  auto FS = buildTestFS(Files);
+
+  EXPECT_THAT(build(MainFile, Files).getDiagnostics(),
+  UnorderedElementsAre(Diag(Main.range(),
+"Error in header: C++ requires a type "
+"specifier for all declarations")));
+}
+
+TEST(DiagsInHeaders, DiagInMultipleHeaders) {
+  Annotations Main(R"cpp(
+#include $a[["a.h"]]
+#include $b[["b.h"]]
+void foo() {})cpp");
+  std::string MainFile = testPath("main.cc");
+  llvm::StringMap Files = {{MainFile, Main.code()},
+{testPath("a.h"), "no_type_spec;"},
+{testPath("b.h"), "no_type_spec;"}};
+  auto FS = buildTestFS(Files);
+
+  EXPECT_THAT(build(MainFile, Files).getDiagnostics(),
+  UnorderedElementsAre(
+  Diag(Main.range("a"), "Error in header: C++ requires a type "
+"specifier for all declarations"),
+  Diag(Main.range("b"), "Error in header: C++ requires a type "
+"specifier for all declarations")));
+}
+
+TEST(DiagsInHeaders, PreferDirectIncludeLocation) {
+  Annotations Main(R"cpp(
+#include "a.h"
+#include [["b.h"]]
+void foo() {})cpp");
+  std::string MainFile = testPath("main.cc");
+  llvm::StringMap Files = {
+  {MainFile, Main.code()},
+  {testPath("a.h"), "#include \"b.h\"\n"},
+  {testPath("b.h"), "#ifndef X\n#define X\nno_type_spec;\n#endif"}};
+  auto FS = buildTestFS(Files);
+
+  EXPECT_THAT(build(MainFile, Files).getDiagnostics(),
+  Unordere

[PATCH] D59299: [libclang] Expose aligned() attribute.

2019-03-13 Thread Emilio Cobos Álvarez via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL356062: [libclang] Expose aligned() attribute. (authored by 
emilio, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D59299?vs=190414&id=190430#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59299/new/

https://reviews.llvm.org/D59299

Files:
  cfe/trunk/bindings/python/clang/cindex.py
  cfe/trunk/include/clang-c/Index.h
  cfe/trunk/test/Index/attributes.c
  cfe/trunk/tools/libclang/CIndex.cpp
  cfe/trunk/tools/libclang/CXCursor.cpp


Index: cfe/trunk/tools/libclang/CIndex.cpp
===
--- cfe/trunk/tools/libclang/CIndex.cpp
+++ cfe/trunk/tools/libclang/CIndex.cpp
@@ -5484,6 +5484,8 @@
   return cxstring::createRef("attribute(warn_unused)");
   case CXCursor_WarnUnusedResultAttr:
   return cxstring::createRef("attribute(warn_unused_result)");
+  case CXCursor_AlignedAttr:
+  return cxstring::createRef("attribute(aligned)");
   }
 
   llvm_unreachable("Unhandled CXCursorKind");
Index: cfe/trunk/tools/libclang/CXCursor.cpp
===
--- cfe/trunk/tools/libclang/CXCursor.cpp
+++ cfe/trunk/tools/libclang/CXCursor.cpp
@@ -81,6 +81,7 @@
 case attr::Convergent: return CXCursor_ConvergentAttr;
 case attr::WarnUnused: return CXCursor_WarnUnusedAttr;
 case attr::WarnUnusedResult: return CXCursor_WarnUnusedResultAttr;
+case attr::Aligned: return CXCursor_AlignedAttr;
   }
 
   return CXCursor_UnexposedAttr;
Index: cfe/trunk/bindings/python/clang/cindex.py
===
--- cfe/trunk/bindings/python/clang/cindex.py
+++ cfe/trunk/bindings/python/clang/cindex.py
@@ -1345,6 +1345,7 @@
 CursorKind.CONVERGENT_ATTR = CursorKind(438)
 CursorKind.WARN_UNUSED_ATTR = CursorKind(439)
 CursorKind.WARN_UNUSED_RESULT_ATTR = CursorKind(440)
+CursorKind.ALIGNED_ATTR = CursorKind(441)
 
 ###
 # Preprocessing
Index: cfe/trunk/include/clang-c/Index.h
===
--- cfe/trunk/include/clang-c/Index.h
+++ cfe/trunk/include/clang-c/Index.h
@@ -32,7 +32,7 @@
  * compatible, thus CINDEX_VERSION_MAJOR is expected to remain stable.
  */
 #define CINDEX_VERSION_MAJOR 0
-#define CINDEX_VERSION_MINOR 53
+#define CINDEX_VERSION_MINOR 54
 
 #define CINDEX_VERSION_ENCODE(major, minor) ( \
   ((major) * 1)   \
@@ -2589,7 +2589,8 @@
   CXCursor_ConvergentAttr= 438,
   CXCursor_WarnUnusedAttr= 439,
   CXCursor_WarnUnusedResultAttr  = 440,
-  CXCursor_LastAttr  = CXCursor_WarnUnusedResultAttr,
+  CXCursor_AlignedAttr   = 441,
+  CXCursor_LastAttr  = CXCursor_AlignedAttr,
 
   /* Preprocessing */
   CXCursor_PreprocessingDirective= 500,
Index: cfe/trunk/test/Index/attributes.c
===
--- cfe/trunk/test/Index/attributes.c
+++ cfe/trunk/test/Index/attributes.c
@@ -20,6 +20,14 @@
   int b;
 };
 
+struct __attribute__((aligned(64))) Aligned1 {
+  int c;
+};
+
+struct Aligned2 {
+  int c;
+} __attribute__((aligned(64)));
+
 // CHECK: attributes.c:3:32: StructDecl=Test2:3:32 (Definition) Extent=[3:1 - 
5:2]
 // CHECK: attributes.c:3:23: attribute(packed)=packed Extent=[3:23 - 3:29]
 // CHECK: attributes.c:4:8: FieldDecl=a:4:8 (Definition) Extent=[4:3 - 4:9] 
[access=public]
@@ -39,3 +47,7 @@
 // CHECK: attributes.c:17:44: attribute(warn_unused_result)= Extent=[17:44 - 
17:62]
 // CHECK: attributes.c:19:37: StructDecl=WarnUnused:19:37 (Definition) 
Extent=[19:1 - 21:2]
 // CHECK: attributes.c:19:23: attribute(warn_unused)= Extent=[19:23 - 19:34]
+// CHECK: attributes.c:23:37: StructDecl=Aligned1:23:37 (Definition) 
Extent=[23:1 - 25:2]
+// CHECK: attributes.c:23:23: attribute(aligned)= Extent=[23:23 - 23:34]
+// CHECK: attributes.c:27:8: StructDecl=Aligned2:27:8 (Definition) 
Extent=[27:1 - 29:2]
+// CHECK: attributes.c:29:18: attribute(aligned)= Extent=[29:18 - 29:29]


Index: cfe/trunk/tools/libclang/CIndex.cpp
===
--- cfe/trunk/tools/libclang/CIndex.cpp
+++ cfe/trunk/tools/libclang/CIndex.cpp
@@ -5484,6 +5484,8 @@
   return cxstring::createRef("attribute(warn_unused)");
   case CXCursor_WarnUnusedResultAttr:
   return cxstring::createRef("attribute(warn_unused_result)");
+  case CXCursor_AlignedAttr:
+  return cxstring::createRef("attribute(aligned)");
   }
 
   llvm_unreachable("Unhandled CXCursorKind");
Index: cfe/trunk/tools/libclang/CXCursor.cpp
===
--- cfe/trunk/tools/libclang/CXCursor.cpp
+++ cfe/trunk/tools/libclang/CXCursor.cpp
@@ -81,6 +81,7 @@
 case at

r356062 - [libclang] Expose aligned() attribute.

2019-03-13 Thread Emilio Cobos Alvarez via cfe-commits
Author: emilio
Date: Wed Mar 13 09:16:54 2019
New Revision: 356062

URL: http://llvm.org/viewvc/llvm-project?rev=356062&view=rev
Log:
[libclang] Expose aligned() attribute.

Summary:
This is useful because otherwise there's no easy way to distinguish #pragma
packed(N) from attribute(packed, aligned(N)) that isn't looking at field
offsets (since pragma packed() also creates a packed attribute).

Reviewers: Anastasia, arphaman, serge-sans-paille

Subscribers: cfe-commits

Tags: #clang

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

Modified:
cfe/trunk/bindings/python/clang/cindex.py
cfe/trunk/include/clang-c/Index.h
cfe/trunk/test/Index/attributes.c
cfe/trunk/tools/libclang/CIndex.cpp
cfe/trunk/tools/libclang/CXCursor.cpp

Modified: cfe/trunk/bindings/python/clang/cindex.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/bindings/python/clang/cindex.py?rev=356062&r1=356061&r2=356062&view=diff
==
--- cfe/trunk/bindings/python/clang/cindex.py (original)
+++ cfe/trunk/bindings/python/clang/cindex.py Wed Mar 13 09:16:54 2019
@@ -1345,6 +1345,7 @@ CursorKind.DLLIMPORT_ATTR = CursorKind(4
 CursorKind.CONVERGENT_ATTR = CursorKind(438)
 CursorKind.WARN_UNUSED_ATTR = CursorKind(439)
 CursorKind.WARN_UNUSED_RESULT_ATTR = CursorKind(440)
+CursorKind.ALIGNED_ATTR = CursorKind(441)
 
 ###
 # Preprocessing

Modified: cfe/trunk/include/clang-c/Index.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/Index.h?rev=356062&r1=356061&r2=356062&view=diff
==
--- cfe/trunk/include/clang-c/Index.h (original)
+++ cfe/trunk/include/clang-c/Index.h Wed Mar 13 09:16:54 2019
@@ -32,7 +32,7 @@
  * compatible, thus CINDEX_VERSION_MAJOR is expected to remain stable.
  */
 #define CINDEX_VERSION_MAJOR 0
-#define CINDEX_VERSION_MINOR 53
+#define CINDEX_VERSION_MINOR 54
 
 #define CINDEX_VERSION_ENCODE(major, minor) ( \
   ((major) * 1)   \
@@ -2589,7 +2589,8 @@ enum CXCursorKind {
   CXCursor_ConvergentAttr= 438,
   CXCursor_WarnUnusedAttr= 439,
   CXCursor_WarnUnusedResultAttr  = 440,
-  CXCursor_LastAttr  = CXCursor_WarnUnusedResultAttr,
+  CXCursor_AlignedAttr   = 441,
+  CXCursor_LastAttr  = CXCursor_AlignedAttr,
 
   /* Preprocessing */
   CXCursor_PreprocessingDirective= 500,

Modified: cfe/trunk/test/Index/attributes.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/attributes.c?rev=356062&r1=356061&r2=356062&view=diff
==
--- cfe/trunk/test/Index/attributes.c (original)
+++ cfe/trunk/test/Index/attributes.c Wed Mar 13 09:16:54 2019
@@ -20,6 +20,14 @@ struct __attribute__((warn_unused)) Warn
   int b;
 };
 
+struct __attribute__((aligned(64))) Aligned1 {
+  int c;
+};
+
+struct Aligned2 {
+  int c;
+} __attribute__((aligned(64)));
+
 // CHECK: attributes.c:3:32: StructDecl=Test2:3:32 (Definition) Extent=[3:1 - 
5:2]
 // CHECK: attributes.c:3:23: attribute(packed)=packed Extent=[3:23 - 3:29]
 // CHECK: attributes.c:4:8: FieldDecl=a:4:8 (Definition) Extent=[4:3 - 4:9] 
[access=public]
@@ -39,3 +47,7 @@ struct __attribute__((warn_unused)) Warn
 // CHECK: attributes.c:17:44: attribute(warn_unused_result)= Extent=[17:44 - 
17:62]
 // CHECK: attributes.c:19:37: StructDecl=WarnUnused:19:37 (Definition) 
Extent=[19:1 - 21:2]
 // CHECK: attributes.c:19:23: attribute(warn_unused)= Extent=[19:23 - 19:34]
+// CHECK: attributes.c:23:37: StructDecl=Aligned1:23:37 (Definition) 
Extent=[23:1 - 25:2]
+// CHECK: attributes.c:23:23: attribute(aligned)= Extent=[23:23 - 23:34]
+// CHECK: attributes.c:27:8: StructDecl=Aligned2:27:8 (Definition) 
Extent=[27:1 - 29:2]
+// CHECK: attributes.c:29:18: attribute(aligned)= Extent=[29:18 - 29:29]

Modified: cfe/trunk/tools/libclang/CIndex.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=356062&r1=356061&r2=356062&view=diff
==
--- cfe/trunk/tools/libclang/CIndex.cpp (original)
+++ cfe/trunk/tools/libclang/CIndex.cpp Wed Mar 13 09:16:54 2019
@@ -5484,6 +5484,8 @@ CXString clang_getCursorKindSpelling(enu
   return cxstring::createRef("attribute(warn_unused)");
   case CXCursor_WarnUnusedResultAttr:
   return cxstring::createRef("attribute(warn_unused_result)");
+  case CXCursor_AlignedAttr:
+  return cxstring::createRef("attribute(aligned)");
   }
 
   llvm_unreachable("Unhandled CXCursorKind");

Modified: cfe/trunk/tools/libclang/CXCursor.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CXCursor.cpp?rev=356062&r1=356061&r2=356062&view=diff
==
--- cfe/trunk/tools/libclang/CXCursor.

[PATCH] D59299: [libclang] Expose aligned() attribute.

2019-03-13 Thread Emilio Cobos Álvarez via Phabricator via cfe-commits
emilio added a comment.

Thank you for the review! :)


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59299/new/

https://reviews.llvm.org/D59299



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


[PATCH] D59304: Fix invocation of Gold plugin with LTO after r355331

2019-03-13 Thread Nemanja Ivanovic via Phabricator via cfe-commits
nemanjai created this revision.
nemanjai added reviewers: xur, tejohnson, davidxl.
Herald added subscribers: dexonsmith, steven_wu, inglorion, mehdi_amini.
Herald added a project: clang.

The above commit tries to access the parameter to the `-fprofile-use` option 
without checking whether the option has actually been specified with a 
parameter. When the option was not specified with a parameter, this trips an 
assertion.
All of our builds with PGO/LTO use `-fprofile-use` without a parameter so this 
broke all such internal builds.

To reproduce (the contents of the C++ file don't actually matter as long as it 
can be linked/run):

  $ clang++ -O3 -fprofile-generate pgo-lto.cpp
  $ ./a.out
  $ clang++ -O3 -fprofile-use -flto=thin pgo-lto.cpp
  clang++: /home/nemanjai/llvm/llvm-clean/include/llvm/ADT/SmallVector.h:153: 
const T& llvm::SmallVectorTemplateCommon 
>::operator[](llvm::SmallVectorTemplateCommon 
>::size_type) const [with T = const char*;  = void; 
llvm::SmallVectorTemplateCommon >::const_reference 
= const char* const&; llvm::SmallVectorTemplateCommon >::size_type = long unsigned int]: Assertion `idx < 
size()' failed.

This patch fixes it by handling the option the same way it is handled elsewhere.

The original patch did not include any test cases, so I've added one for the 
problem case. Had the patch been committed with tests, this issue would 
probably not have happened.

I am hoping for a quick review of this so we can commit this and not have to 
change our build tools to specify the `default.profdata` default.


Repository:
  rC Clang

https://reviews.llvm.org/D59304

Files:
  lib/Driver/ToolChains/CommonArgs.cpp
  test/Driver/cspgo-lto.c


Index: test/Driver/cspgo-lto.c
===
--- test/Driver/cspgo-lto.c
+++ test/Driver/cspgo-lto.c
@@ -0,0 +1,6 @@
+// RUN: touch %t.o
+//
+// RUN: %clang -target x86_64-unknown-linux -### %t.o -flto=thin \
+// RUN:   -fprofile-use 2>&1 | FileCheck %s
+
+// CHECK: -plugin-opt=cs-profile-path=default.profdata
Index: lib/Driver/ToolChains/CommonArgs.cpp
===
--- lib/Driver/ToolChains/CommonArgs.cpp
+++ lib/Driver/ToolChains/CommonArgs.cpp
@@ -464,8 +464,12 @@
   CmdArgs.push_back(
   
Args.MakeArgString("-plugin-opt=cs-profile-path=default_%m.profraw"));
   } else if (ProfileUseArg) {
+SmallString<128> Path(
+ProfileUseArg->getNumValues() == 0 ? "" : ProfileUseArg->getValue());
+if (Path.empty() || llvm::sys::fs::is_directory(Path))
+  llvm::sys::path::append(Path, "default.profdata");
 CmdArgs.push_back(Args.MakeArgString(Twine("-plugin-opt=cs-profile-path=") 
+
- ProfileUseArg->getValue()));
+ Path));
   }
 
   // Need this flag to turn on new pass manager via Gold plugin.


Index: test/Driver/cspgo-lto.c
===
--- test/Driver/cspgo-lto.c
+++ test/Driver/cspgo-lto.c
@@ -0,0 +1,6 @@
+// RUN: touch %t.o
+//
+// RUN: %clang -target x86_64-unknown-linux -### %t.o -flto=thin \
+// RUN:   -fprofile-use 2>&1 | FileCheck %s
+
+// CHECK: -plugin-opt=cs-profile-path=default.profdata
Index: lib/Driver/ToolChains/CommonArgs.cpp
===
--- lib/Driver/ToolChains/CommonArgs.cpp
+++ lib/Driver/ToolChains/CommonArgs.cpp
@@ -464,8 +464,12 @@
   CmdArgs.push_back(
   Args.MakeArgString("-plugin-opt=cs-profile-path=default_%m.profraw"));
   } else if (ProfileUseArg) {
+SmallString<128> Path(
+ProfileUseArg->getNumValues() == 0 ? "" : ProfileUseArg->getValue());
+if (Path.empty() || llvm::sys::fs::is_directory(Path))
+  llvm::sys::path::append(Path, "default.profdata");
 CmdArgs.push_back(Args.MakeArgString(Twine("-plugin-opt=cs-profile-path=") +
- ProfileUseArg->getValue()));
+ Path));
   }
 
   // Need this flag to turn on new pass manager via Gold plugin.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D59304: Fix invocation of Gold plugin with LTO after r355331

2019-03-13 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson accepted this revision.
tejohnson added a comment.
This revision is now accepted and ready to land.

lgtm


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59304/new/

https://reviews.llvm.org/D59304



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


[PATCH] D36357: Added a better diagnostic when using the delete operator with lambdas

2019-03-13 Thread Nicolas Lesser via Phabricator via cfe-commits
Rakete updated this revision to Diff 190435.
Rakete added a comment.

Rebase + friendly ping :).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D36357/new/

https://reviews.llvm.org/D36357

Files:
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/lib/Parse/ParseExprCXX.cpp
  clang/test/FixIt/fixit-cxx0x.cpp
  clang/test/Parser/cxx0x-lambda-expressions.cpp
  clang/test/SemaCXX/new-delete-0x.cpp

Index: clang/test/SemaCXX/new-delete-0x.cpp
===
--- clang/test/SemaCXX/new-delete-0x.cpp
+++ clang/test/SemaCXX/new-delete-0x.cpp
@@ -34,6 +34,6 @@
 void bad_deletes()
 {
   // 'delete []' is always array delete, per [expr.delete]p1.
-  // FIXME: Give a better diagnostic.
-  delete []{ return (int*)0; }(); // expected-error {{expected expression}}
+  delete []{ return (int*)0; }(); // expected-error {{'[]' after delete interpreted as 'delete[]'}}
 }
+
Index: clang/test/Parser/cxx0x-lambda-expressions.cpp
===
--- clang/test/Parser/cxx0x-lambda-expressions.cpp
+++ clang/test/Parser/cxx0x-lambda-expressions.cpp
@@ -53,8 +53,11 @@
   void delete_lambda(int *p) {
 delete [] p;
 delete [] (int*) { new int }; // ok, compound-literal, not lambda
-delete [] { return new int; } (); // expected-error{{expected expression}}
+delete [] { return new int; } (); // expected-error {{'[]' after delete interpreted as 'delete[]'}}
 delete [&] { return new int; } (); // ok, lambda
+
+delete []() { return new int; }(); // expected-error{{'[]' after delete interpreted as 'delete[]'}}
+delete [](E Enum) { return new int((int)Enum); }(e); // expected-error{{'[]' after delete interpreted as 'delete[]'}}
   }
 
   // We support init-captures in C++11 as an extension.
Index: clang/test/FixIt/fixit-cxx0x.cpp
===
--- clang/test/FixIt/fixit-cxx0x.cpp
+++ clang/test/FixIt/fixit-cxx0x.cpp
@@ -58,6 +58,9 @@
   (void)[&, i, i]{ }; // expected-error{{'i' can appear only once in a capture list}}
   (void)[] mutable { }; // expected-error{{lambda requires '()' before 'mutable'}}
   (void)[] -> int { }; // expected-error{{lambda requires '()' before return type}}
+
+  delete []() { return new int; }(); // expected-error{{'[]' after delete interpreted as 'delete[]'}}
+  delete [] { return new int; }(); // expected-error{{'[]' after delete interpreted as 'delete[]'}}
 }
 
 #define bar "bar"
Index: clang/lib/Parse/ParseExprCXX.cpp
===
--- clang/lib/Parse/ParseExprCXX.cpp
+++ clang/lib/Parse/ParseExprCXX.cpp
@@ -2984,8 +2984,38 @@
 //   [Footnote: A lambda expression with a lambda-introducer that consists
 //  of empty square brackets can follow the delete keyword if
 //  the lambda expression is enclosed in parentheses.]
-// FIXME: Produce a better diagnostic if the '[]' is unambiguously a
-//lambda-introducer.
+
+const Token Next = GetLookAheadToken(2);
+
+// Basic lookahead to check if we have a lambda expression.
+if (Next.isOneOf(tok::l_brace, tok::less) ||
+(Next.is(tok::l_paren) &&
+ (GetLookAheadToken(3).is(tok::r_paren) ||
+  (GetLookAheadToken(3).is(tok::identifier) &&
+   GetLookAheadToken(4).is(tok::identifier) {
+  SourceLocation RightBracketLock = NextToken().getLocation();
+  // Warn if the non-capturing lambda isn't surrounded by parenthesis
+  // to disambiguate it from 'delete[]'.
+  ExprResult Lambda = ParseLambdaExpression();
+  if (Lambda.isInvalid())
+return ExprError();
+
+  SourceLocation StartLoc = Lambda.get()->getBeginLoc();
+  Diag(Start, diag::err_lambda_after_delete)
+  << SourceRange(Start, RightBracketLock)
+  << FixItHint::CreateInsertion(StartLoc, "(")
+  << FixItHint::CreateInsertion(
+ Lexer::getLocForEndOfToken(Lambda.get()->getEndLoc(), 0,
+Actions.getSourceManager(),
+getLangOpts()),
+ ")");
+
+  // Evaluate any postfix expressions used on the lambda.
+  Lambda = ParsePostfixExpressionSuffix(Lambda);
+  return Actions.ActOnCXXDelete(Start, UseGlobal, /*ArrayForm=*/false,
+Lambda.get());
+}
+
 ArrayDelete = true;
 BalancedDelimiterTracker T(*this, tok::l_square);
 
Index: clang/include/clang/Basic/DiagnosticParseKinds.td
===
--- clang/include/clang/Basic/DiagnosticParseKinds.td
+++ clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -105,6 +105,8 @@
   InGroup, DefaultIgnore;
 def ext_alignof_expr : ExtWarn<
   "%0 applied to an expression is a GNU extension">, InGroup;
+def err_la

[PATCH] D59304: Fix invocation of Gold plugin with LTO after r355331

2019-03-13 Thread Nemanja Ivanovic via Phabricator via cfe-commits
nemanjai added a comment.

Thanks Teresa, I'll commit this soon.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59304/new/

https://reviews.llvm.org/D59304



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


[PATCH] D59306: [NFC][clang][astdump] Some baseline tests for OpenMP

2019-03-13 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri created this revision.
lebedev.ri added reviewers: ABataev, aaron.ballman, stephenkelly.
lebedev.ri added projects: clang, OpenMP.
Herald added subscribers: jdoerfert, jfb, guansong.
lebedev.ri added a child revision: D59214: [clang][OpeMP] Model OpenMP 
structured-block in AST (PR40563).

Split off from D59214 .
Not a fully exaustive test coverage, but better than what there currently is.


Repository:
  rC Clang

https://reviews.llvm.org/D59306

Files:
  test/AST/ast-dump-openmp-atomic.c
  test/AST/ast-dump-openmp-barrier.c
  test/AST/ast-dump-openmp-cancel.c
  test/AST/ast-dump-openmp-cancellation-point.c
  test/AST/ast-dump-openmp-critical.c
  test/AST/ast-dump-openmp-distribute-parallel-for-simd.c
  test/AST/ast-dump-openmp-distribute-parallel-for.c
  test/AST/ast-dump-openmp-distribute-simd.c
  test/AST/ast-dump-openmp-distribute.c
  test/AST/ast-dump-openmp-flush.c
  test/AST/ast-dump-openmp-for-simd.c
  test/AST/ast-dump-openmp-for.c
  test/AST/ast-dump-openmp-master.c
  test/AST/ast-dump-openmp-ordered.c
  test/AST/ast-dump-openmp-parallel-for-simd.c
  test/AST/ast-dump-openmp-parallel-for.c
  test/AST/ast-dump-openmp-parallel-master-XFAIL.c
  test/AST/ast-dump-openmp-parallel-sections.c
  test/AST/ast-dump-openmp-parallel.c
  test/AST/ast-dump-openmp-section.c
  test/AST/ast-dump-openmp-sections.c
  test/AST/ast-dump-openmp-simd.c
  test/AST/ast-dump-openmp-single.c
  test/AST/ast-dump-openmp-target-data.c
  test/AST/ast-dump-openmp-target-enter-data.c
  test/AST/ast-dump-openmp-target-exit-data.c
  test/AST/ast-dump-openmp-target-parallel-for-simd.c
  test/AST/ast-dump-openmp-target-parallel-for.c
  test/AST/ast-dump-openmp-target-parallel.c
  test/AST/ast-dump-openmp-target-simd.c
  test/AST/ast-dump-openmp-target-teams-distribute-parallel-for-simd.c
  test/AST/ast-dump-openmp-target-teams-distribute-parallel-for.c
  test/AST/ast-dump-openmp-target-teams-distribute-simd.c
  test/AST/ast-dump-openmp-target-teams-distribute.c
  test/AST/ast-dump-openmp-target-teams.c
  test/AST/ast-dump-openmp-target-update.c
  test/AST/ast-dump-openmp-target.c
  test/AST/ast-dump-openmp-task.c
  test/AST/ast-dump-openmp-taskgroup.c
  test/AST/ast-dump-openmp-taskloop-simd.c
  test/AST/ast-dump-openmp-taskloop.c
  test/AST/ast-dump-openmp-taskwait.c
  test/AST/ast-dump-openmp-taskyield.c
  test/AST/ast-dump-openmp-teams-distribute-parallel-for-simd.c
  test/AST/ast-dump-openmp-teams-distribute-parallel-for.c
  test/AST/ast-dump-openmp-teams-distribute-simd.c
  test/AST/ast-dump-openmp-teams-distribute.c
  test/AST/ast-dump-openmp-teams.c



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


[PATCH] D59307: Patch llvm bug 41033 concerning atomicity of statement expressions

2019-03-13 Thread Melanie Blower via Phabricator via cfe-commits
mibintc created this revision.
mibintc added reviewers: cfe-commits, erichkeane, rsmith.
Herald added subscribers: jdoerfert, jfb.
Herald added a project: clang.

Clang considers the type of a statement expression that returns the value of an 
_Atomic(ty) to be atomic, and this makes the statement expression incompatible 
with other expressions of type ty, for example in assignment or comparison.  
This patch drops the atomic attribute before creating the StmtExpr.

I noticed that unlike gcc, clang doesn't allow StmtExpr on the left hand side 
of an assignment, I agree with clang.

I checked with Clark Nelson about the legitimacy of dropping the atomicity, he 
said "Atomicity has to do with the way data is transferred between a processor 
and its memory. Once it has been loaded, it's just data."


Repository:
  rC Clang

https://reviews.llvm.org/D59307

Files:
  lib/Sema/SemaExpr.cpp
  test/Sema/atomic-expr-stmt.c


Index: test/Sema/atomic-expr-stmt.c
===
--- /dev/null
+++ test/Sema/atomic-expr-stmt.c
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm < %s | 
FileCheck %s
+void test_assign(_Atomic int a, int b) {
+  //CHECK: define void @test_assign(i32 %a, i32 %b)
+  // assignment is OK
+  b = ({a;});
+  //CHECK: %atomic-load = load atomic i32, i32* %a.addr seq_cst, align 4
+  //CHECK: store atomic i32 %atomic-load, i32* %tmp seq_cst, align 4
+  //CHECK: %0 = load i32, i32* %tmp, align 4
+  //CHECK: store i32 %0, i32* %b.addr, align 4
+}
+
+int test_compare(_Atomic int x, int y) {
+  //CHECK: define i32 @test_compare(i32 %x, i32 %y)
+  // comparison is OK
+  //CHECK: %0 = load i32, i32* %y.addr, align 4
+  //CHECK: %atomic-load = load atomic i32, i32* %x.addr seq_cst, align 4
+  //CHECK: store atomic i32 %atomic-load, i32* %tmp seq_cst, align 4
+  //CHECK: %1 = load i32, i32* %tmp, align 4
+  //CHECK: %cmp = icmp slt i32 %0, %1
+  if (y <({x;}))
+return 0;
+  else return 1;
+}
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -13375,6 +13375,8 @@
   if (const Expr *Value = LastStmt->getExprStmt()) {
 StmtExprMayBindToTemp = true;
 Ty = Value->getType();
+if (const AtomicType *AtomicRHS = Ty->getAs())
+  Ty = AtomicRHS->getValueType();
   }
 }
   }


Index: test/Sema/atomic-expr-stmt.c
===
--- /dev/null
+++ test/Sema/atomic-expr-stmt.c
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm < %s | FileCheck %s
+void test_assign(_Atomic int a, int b) {
+  //CHECK: define void @test_assign(i32 %a, i32 %b)
+  // assignment is OK
+  b = ({a;});
+  //CHECK: %atomic-load = load atomic i32, i32* %a.addr seq_cst, align 4
+  //CHECK: store atomic i32 %atomic-load, i32* %tmp seq_cst, align 4
+  //CHECK: %0 = load i32, i32* %tmp, align 4
+  //CHECK: store i32 %0, i32* %b.addr, align 4
+}
+
+int test_compare(_Atomic int x, int y) {
+  //CHECK: define i32 @test_compare(i32 %x, i32 %y)
+  // comparison is OK
+  //CHECK: %0 = load i32, i32* %y.addr, align 4
+  //CHECK: %atomic-load = load atomic i32, i32* %x.addr seq_cst, align 4
+  //CHECK: store atomic i32 %atomic-load, i32* %tmp seq_cst, align 4
+  //CHECK: %1 = load i32, i32* %tmp, align 4
+  //CHECK: %cmp = icmp slt i32 %0, %1
+  if (y <({x;}))
+return 0;
+  else return 1;
+}
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -13375,6 +13375,8 @@
   if (const Expr *Value = LastStmt->getExprStmt()) {
 StmtExprMayBindToTemp = true;
 Ty = Value->getType();
+if (const AtomicType *AtomicRHS = Ty->getAs())
+  Ty = AtomicRHS->getValueType();
   }
 }
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D59307: Patch llvm bug 41033 concerning atomicity of statement expressions

2019-03-13 Thread JF Bastien via Phabricator via cfe-commits
jfb requested changes to this revision.
jfb added a comment.
This revision now requires changes to proceed.

I think you also want to test C++ `std::atomic` as well as regular `volatile`.




Comment at: test/Sema/atomic-expr-stmt.c:7
+  //CHECK: %atomic-load = load atomic i32, i32* %a.addr seq_cst, align 4
+  //CHECK: store atomic i32 %atomic-load, i32* %tmp seq_cst, align 4
+  //CHECK: %0 = load i32, i32* %tmp, align 4

Why is there a store to `a` here?



Comment at: test/Sema/atomic-expr-stmt.c:9
+  //CHECK: %0 = load i32, i32* %tmp, align 4
+  //CHECK: store i32 %0, i32* %b.addr, align 4
+}

What's in `%tmp`? I'd expect the value loaded from `a` to be stored to `b`.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59307/new/

https://reviews.llvm.org/D59307



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


[PATCH] D59287: [X86] Only define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_16 in 64-bit mode.

2019-03-13 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

Most if not all of the test cases in test/CodeGen/X86/atomic128.ll fail with a 
fatal error if you run it in 32-bit mode with -mattr=+cx16  Looks like the 
backend is also bad at checking 64 bit mode.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59287/new/

https://reviews.llvm.org/D59287



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


[PATCH] D59287: [X86] Only define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_16 in 64-bit mode.

2019-03-13 Thread JF Bastien via Phabricator via cfe-commits
jfb added a comment.

In D59287#1427654 , @craig.topper 
wrote:

> Most if not all of the test cases in test/CodeGen/X86/atomic128.ll fail with 
> a fatal error if you run it in 32-bit mode with -mattr=+cx16  Looks like the 
> backend is also bad at checking 64 bit mode.


So you're saying we're consistent, but in a bad way? It seems like an i386 
target just shouldn't be allowed to set cx16, no?


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59287/new/

https://reviews.llvm.org/D59287



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


[PATCH] D59307: Patch llvm bug 41033 concerning atomicity of statement expressions

2019-03-13 Thread JF Bastien via Phabricator via cfe-commits
jfb added a comment.

Thinking some more, this is really a silly gotcha in code. We should probably 
follow what we're about to do with wg21.link/P1152 
 and ban chaining. Statement expressions should 
therefore not be allowed to return `_Atomic`, `std::atomic`, nor `volatile`.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59307/new/

https://reviews.llvm.org/D59307



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


[PATCH] D59307: Patch llvm bug 41033 concerning atomicity of statement expressions

2019-03-13 Thread JF Bastien via Phabricator via cfe-commits
jfb added a subscriber: jwakely.
jfb added a comment.

From an offline discussion, I'm told that @jwakely uses this in GCC headers and 
expects some semantics from it? Jonathan, why?!?!


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59307/new/

https://reviews.llvm.org/D59307



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


[PATCH] D59309: [clang-format] BreakAfterReturnType ignored on functions with numeric template parameters

2019-03-13 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay created this revision.
MyDeveloperDay added reviewers: djasper, klimek, JonasToth, krasimir, reuk.
MyDeveloperDay added a project: clang-tools-extra.

Addresses PR40696 - https://bugs.llvm.org/show_bug.cgi?id=40696

The BreakAfterReturnType didn't work if it had a single arguments which was a 
template with an integer template parameter

  int  foo(A<8> a) { return a; }

When run with the Mozilla style. would not break after the `int`

  int TestFn(A<8> a)
  {
return a;
  }

This revision resolves this issue by allowing numeric constants to be 
considered function parameters if if seen inside `<>`


https://reviews.llvm.org/D59309

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


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -5419,6 +5419,42 @@
"}\n"
"template  T *f(T &c);\n", // No break here.
Style);
+  verifyFormat("int\n"
+   "foo(A a)\n"
+   "{\n"
+   "  return a;\n"
+   "}\n",
+   Style);
+  verifyFormat("int\n"
+   "foo(A<8> a)\n"
+   "{\n"
+   "  return a;\n"
+   "}\n",
+   Style);
+  verifyFormat("int\n"
+   "foo(A, 8> a)\n"
+   "{\n"
+   "  return a;\n"
+   "}\n",
+   Style);
+  verifyFormat("int\n"
+   "foo(A, bool> a)\n"
+   "{\n"
+   "  return a;\n"
+   "}\n",
+   Style);
+  verifyFormat("int\n"
+   "foo(A, bool> a)\n"
+   "{\n"
+   "  return a;\n"
+   "}\n",
+   Style);
+  verifyFormat("int\n"
+   "foo(A, 8> a)\n"
+   "{\n"
+   "  return a;\n"
+   "}\n",
+   Style);
 }
 
 TEST_F(FormatTest, AlwaysBreakBeforeMultilineStrings) {
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -2040,6 +2040,7 @@
   if (Next->MatchingParen->Next &&
   Next->MatchingParen->Next->is(TT_PointerOrReference))
 return true;
+  int TemplateOpenerLevel = 0;
   for (const FormatToken *Tok = Next->Next; Tok && Tok != Next->MatchingParen;
Tok = Tok->Next) {
 if (Tok->is(tok::l_paren) && Tok->MatchingParen) {
@@ -2049,6 +2050,15 @@
 if (Tok->is(tok::kw_const) || Tok->isSimpleTypeSpecifier() ||
 Tok->isOneOf(TT_PointerOrReference, TT_StartOfName, tok::ellipsis))
   return true;
+// Keep a track of how deep inside nested templates chevrons we are.
+if (Tok->is(TT_TemplateOpener))
+  TemplateOpenerLevel++;
+if (Tok->is(TT_TemplateCloser))
+  TemplateOpenerLevel--;
+// We need to see a numeric_constant in a template argument e.g. <8>
+// for it to be an argument that suggests a function decl.
+if (Tok->is(tok::numeric_constant) && TemplateOpenerLevel > 0)
+  return true;
 if (Tok->isOneOf(tok::l_brace, tok::string_literal, TT_ObjCMethodExpr) ||
 Tok->Tok.isLiteral())
   return false;


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -5419,6 +5419,42 @@
"}\n"
"template  T *f(T &c);\n", // No break here.
Style);
+  verifyFormat("int\n"
+   "foo(A a)\n"
+   "{\n"
+   "  return a;\n"
+   "}\n",
+   Style);
+  verifyFormat("int\n"
+   "foo(A<8> a)\n"
+   "{\n"
+   "  return a;\n"
+   "}\n",
+   Style);
+  verifyFormat("int\n"
+   "foo(A, 8> a)\n"
+   "{\n"
+   "  return a;\n"
+   "}\n",
+   Style);
+  verifyFormat("int\n"
+   "foo(A, bool> a)\n"
+   "{\n"
+   "  return a;\n"
+   "}\n",
+   Style);
+  verifyFormat("int\n"
+   "foo(A, bool> a)\n"
+   "{\n"
+   "  return a;\n"
+   "}\n",
+   Style);
+  verifyFormat("int\n"
+   "foo(A, 8> a)\n"
+   "{\n"
+   "  return a;\n"
+   "}\n",
+   Style);
 }
 
 TEST_F(FormatTest, AlwaysBreakBeforeMultilineStrings) {
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -2040,6 +2040,7 @@
   if (Next->MatchingParen->Next &&
   Next->MatchingParen->Next->is(TT_PointerOrRe

[PATCH] D56803: clang -dumpversion returns 4.2.1 for legacy reason, update it

2019-03-13 Thread Sylvestre Ledru via Phabricator via cfe-commits
sylvestre.ledru added a comment.
Herald added a subscriber: jdoerfert.
Herald added a project: clang.

@ddunbar ping?


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56803/new/

https://reviews.llvm.org/D56803



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


[PATCH] D59279: [Analyzer] Checker for non-determinism caused by iteration of unordered container of pointers

2019-03-13 Thread Mandeep Singh Grang via Phabricator via cfe-commits
mgrang updated this revision to Diff 190453.

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59279/new/

https://reviews.llvm.org/D59279

Files:
  docs/analyzer/checkers.rst
  include/clang/StaticAnalyzer/Checkers/Checkers.td
  lib/StaticAnalyzer/Checkers/CMakeLists.txt
  lib/StaticAnalyzer/Checkers/PointerIterationChecker.cpp
  test/Analysis/Inputs/system-header-simulator-cxx.h
  test/Analysis/ptr-iter.cpp
  www/analyzer/alpha_checks.html

Index: www/analyzer/alpha_checks.html
===
--- www/analyzer/alpha_checks.html
+++ www/analyzer/alpha_checks.html
@@ -1182,6 +1182,24 @@
 Name, DescriptionExample
 
 
+
+alpha.nondeterminism.PointerIteration
+(C++)
+Check for non-determinism caused by iterating unordered containers of pointers.
+
+
+// C++
+void test() {
+ int a = 1, b = 2;
+ std::unordered_set UnorderedPointerSet = {&a, &b};
+
+ for (auto i : UnorderedPointerSet) // warn
+   f(i);
+}
+
+
+
+
 
 alpha.nondeterminism.PointerSorting
 (C++)
Index: test/Analysis/ptr-iter.cpp
===
--- /dev/null
+++ test/Analysis/ptr-iter.cpp
@@ -0,0 +1,28 @@
+// RUN: %clang_analyze_cc1 %s -analyzer-output=text -verify \
+// RUN: -analyzer-checker=core,alpha.nondeterminism.PointerIteration
+
+#include "Inputs/system-header-simulator-cxx.h"
+
+template
+void f(T x);
+
+void PointerIteration() {
+  int a = 1, b = 2;
+  std::set OrderedIntSet = {a, b};
+  std::set OrderedPointerSet = {&a, &b};
+  std::unordered_set UnorderedIntSet = {a, b};
+  std::unordered_set UnorderedPointerSet = {&a, &b};
+
+  for (auto i : OrderedIntSet) // no-warning
+f(i);
+
+  for (auto i : OrderedPointerSet) // no-warning
+f(i);
+
+  for (auto i : UnorderedIntSet) // no-warning
+f(i);
+
+  for (auto i : UnorderedPointerSet) // expected-warning {{Iteration of pointer-like elements can result in non-deterministic ordering}} [alpha.nondeterminism.PointerIteration]
+// expected-note@-1 {{Iteration of pointer-like elements can result in non-deterministic ordering}} [alpha.nondeterminism.PointerIteration]
+f(i);
+}
Index: test/Analysis/Inputs/system-header-simulator-cxx.h
===
--- test/Analysis/Inputs/system-header-simulator-cxx.h
+++ test/Analysis/Inputs/system-header-simulator-cxx.h
@@ -845,3 +845,64 @@
   template
   BidirIt stable_partition(BidirIt first, BidirIt last, UnaryPredicate p);
 }
+
+namespace std {
+
+template< class T = void >
+struct less;
+
+template< class T >
+struct allocator;
+
+template< class Key >
+struct hash;
+
+template<
+  class Key,
+  class Compare = std::less,
+  class Alloc = std::allocator
+> class set {
+  public:
+set(initializer_list __list) {}
+
+class iterator {
+public:
+  iterator(Key *key): ptr(key) {}
+  iterator operator++() { ++ptr; return *this; }
+  bool operator!=(const iterator &other) const { return ptr != other.ptr; }
+  const Key &operator*() const { return *ptr; }
+private:
+  Key *ptr;
+};
+
+  public:
+Key *val;
+iterator begin() const { return iterator(val); }
+iterator end() const { return iterator(val + 1); }
+};
+
+template<
+  class Key,
+  class Hash = std::hash,
+  class Compare = std::less,
+  class Alloc = std::allocator
+> class unordered_set {
+  public:
+unordered_set(initializer_list __list) {}
+
+class iterator {
+public:
+  iterator(Key *key): ptr(key) {}
+  iterator operator++() { ++ptr; return *this; }
+  bool operator!=(const iterator &other) const { return ptr != other.ptr; }
+  const Key &operator*() const { return *ptr; }
+private:
+  Key *ptr;
+};
+
+  public:
+Key *val;
+iterator begin() const { return iterator(val); }
+iterator end() const { return iterator(val + 1); }
+};
+}
Index: lib/StaticAnalyzer/Checkers/PointerIterationChecker.cpp
===
--- /dev/null
+++ lib/StaticAnalyzer/Checkers/PointerIterationChecker.cpp
@@ -0,0 +1,100 @@
+//== PointerIterationChecker.cpp --- -*- C++ -*--=//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This file defines PointerIterationChecker which checks for non-determinism
+// caused due to iteration of unordered containers of pointer elements.
+//
+//===--===//
+
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/StaticAnalyzer/Checkers/BuiltinCheckerRegistration.h"
+#include "clang/StaticAnalyzer/Core/Checker.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
+
+using namespace clang;
+using namesp

r356070 - Revert "Add AIX Target Info"

2019-03-13 Thread Jason Liu via cfe-commits
Author: jasonliu
Date: Wed Mar 13 10:57:23 2019
New Revision: 356070

URL: http://llvm.org/viewvc/llvm-project?rev=356070&view=rev
Log:
Revert "Add AIX Target Info"

This reverts commit 4e192d0e1e72ce32fabf1bccc06ac31ab5385e78.
The newly added test case max_align.c do not work on all platforms.

original llvm-svn: 356060

Removed:
cfe/trunk/test/Headers/max_align.c
cfe/trunk/test/Sema/varargs-aix.c
Modified:
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/lib/Basic/Targets/OSTargets.h
cfe/trunk/lib/Basic/Targets/PPC.cpp
cfe/trunk/lib/Basic/Targets/PPC.h
cfe/trunk/test/Driver/types.c
cfe/trunk/test/Preprocessor/init.c

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=356070&r1=356069&r2=356070&view=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Wed Mar 13 10:57:23 2019
@@ -332,8 +332,6 @@ TargetInfo *AllocateTarget(const llvm::T
   return new OpenBSDTargetInfo(Triple, Opts);
 case llvm::Triple::RTEMS:
   return new RTEMSTargetInfo(Triple, Opts);
-case llvm::Triple::AIX:
-  return new AIXPPC32TargetInfo(Triple, Opts);
 default:
   return new PPC32TargetInfo(Triple, Opts);
 }
@@ -350,8 +348,6 @@ TargetInfo *AllocateTarget(const llvm::T
   return new FreeBSDTargetInfo(Triple, Opts);
 case llvm::Triple::NetBSD:
   return new NetBSDTargetInfo(Triple, Opts);
-case llvm::Triple::AIX:
-  return new AIXPPC64TargetInfo(Triple, Opts);
 default:
   return new PPC64TargetInfo(Triple, Opts);
 }

Modified: cfe/trunk/lib/Basic/Targets/OSTargets.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/OSTargets.h?rev=356070&r1=356069&r2=356070&view=diff
==
--- cfe/trunk/lib/Basic/Targets/OSTargets.h (original)
+++ cfe/trunk/lib/Basic/Targets/OSTargets.h Wed Mar 13 10:57:23 2019
@@ -613,53 +613,6 @@ public:
   }
 };
 
-// AIX Target
-template 
-class AIXTargetInfo : public OSTargetInfo {
-protected:
-  void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple,
-MacroBuilder &Builder) const override {
-DefineStd(Builder, "unix", Opts);
-Builder.defineMacro("_IBMR2");
-Builder.defineMacro("_POWER");
-
-// FIXME: Define AIX OS-Version Macros.
-Builder.defineMacro("_AIX");
-
-// FIXME: Do not define _LONG_LONG when -fno-long-long is specified.
-Builder.defineMacro("_LONG_LONG");
-
-if (Opts.POSIXThreads) {
-  Builder.defineMacro("_THREAD_SAFE");
-}
-
-if (this->PointerWidth == 64) {
-  Builder.defineMacro("__64BIT__");
-}
-
-// Define _WCHAR_T when it is a fundamental type
-// (i.e., for C++ without -fno-wchar).
-if (Opts.CPlusPlus && Opts.WChar) {
-  Builder.defineMacro("_WCHAR_T");
-}
-  }
-
-public:
-  AIXTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
-  : OSTargetInfo(Triple, Opts) {
-if (this->PointerWidth == 64) {
-  this->WCharType = this->UnsignedInt;
-} else {
-  this->WCharType = this->UnsignedShort;
-}
-this->UseZeroLengthBitfieldAlignment = true;
-  }
-
-  // AIX sets FLT_EVAL_METHOD to be 1.
-  unsigned getFloatEvalMethod() const override { return 1; }
-  bool hasInt128Type() const override { return false; }
-};
-
 // Windows target
 template 
 class LLVM_LIBRARY_VISIBILITY WindowsTargetInfo : public OSTargetInfo {

Modified: cfe/trunk/lib/Basic/Targets/PPC.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/PPC.cpp?rev=356070&r1=356069&r2=356070&view=diff
==
--- cfe/trunk/lib/Basic/Targets/PPC.cpp (original)
+++ cfe/trunk/lib/Basic/Targets/PPC.cpp Wed Mar 13 10:57:23 2019
@@ -100,9 +100,7 @@ void PPCTargetInfo::getTargetDefines(con
 Builder.defineMacro("_CALL_LINUX", "1");
 
   // Subtarget options.
-  if (!getTriple().isOSAIX()){
-Builder.defineMacro("__NATURAL_ALIGNMENT__");
-  }
+  Builder.defineMacro("__NATURAL_ALIGNMENT__");
   Builder.defineMacro("__REGISTER_PREFIX__", "");
 
   // FIXME: Should be controlled by command line option.

Modified: cfe/trunk/lib/Basic/Targets/PPC.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/PPC.h?rev=356070&r1=356069&r2=356070&view=diff
==
--- cfe/trunk/lib/Basic/Targets/PPC.h (original)
+++ cfe/trunk/lib/Basic/Targets/PPC.h Wed Mar 13 10:57:23 2019
@@ -325,12 +325,6 @@ public:
   PtrDiffType = SignedInt;
   IntPtrType = SignedInt;
   break;
-case llvm::Triple::AIX:
-  SizeType = UnsignedLong;
-  PtrDiffType = SignedLong;
-  IntPtrType = SignedLong;
-  SuitableAlign = 64;
-  break;
 default:
   break;
 }
@@ -339,8 +

[PATCH] D59168: [runtimes] Move libunwind, libc++abi and libc++ to lib/clang/ and include/

2019-03-13 Thread Joel E. Denny via Phabricator via cfe-commits
jdenny accepted this revision.
jdenny added a comment.

In D59168#1423587 , @phosek wrote:

> I'm not super enthusiastic about the duplicated triple, but the only way to 
> eliminate it would be to move the Clang resource directory inside of 
> `lib/clang/x86_64-linux-gnu`, i.e. we'd have 
> `lib/clang/x86_64-linux-gnu/9.0.0/{include,lib}`.


`lib/x86_64-linux-gnu/clang/9.0.0/{include,lib}` would mean less duplication of 
the triple within system directories.  Is there a reason not to do that?  I'm 
not necessarily advocating for this.  I'm just trying to understand what you've 
chosen.

In D59168#1425701 , @phosek wrote:

> In D59168#1424968 , @smeenai wrote:
>
> > I don't think the duplicated triple is too huge of a deal. I think the 
> > layout where the resource directory is moved inside the triple directory is 
> > a bit nicer, but I also don't know how much work that change would be and 
> > if it's worth it.
>
>
> One downside is that we would be duplicating Clang resource headers for each 
> target which may not be too big of a deal but something worth mentioning.


In that case, could we symlink the target-specific include directories to a 
common directory?

Regardless of these points, your patch appears to strictly improve the 
situation, so maybe we should see how things go with it and then make further 
changes later if desired.

So, LGTM modulo the question I added inline.  Thanks.




Comment at: libcxx/lib/CMakeLists.txt:407
   install(TARGETS ${LIBCXX_INSTALL_TARGETS} ${filesystem_lib} 
${experimental_lib}
-LIBRARY DESTINATION ${LIBCXX_INSTALL_PREFIX}lib${LIBCXX_LIBDIR_SUFFIX} 
COMPONENT cxx
-ARCHIVE DESTINATION ${LIBCXX_INSTALL_PREFIX}lib${LIBCXX_LIBDIR_SUFFIX} 
COMPONENT cxx
+LIBRARY DESTINATION ${LIBCXX_INSTALL_PREFIX}${LIBCXX_INSTALL_LIBRARY_DIR} 
COMPONENT cxx
+ARCHIVE DESTINATION ${LIBCXX_INSTALL_PREFIX}${LIBCXX_INSTALL_LIBRARY_DIR} 
COMPONENT cxx

Assume LLVM_ENABLE_PER_TARGET_RUNTIME_DIR=True.

Without your patch, it looks to me like specifying LIBCXX_INSTALL_PREFIX 
collapses the library destination from `$prefix/lib/clang/$version/$triple/lib` 
to `$prefix/lib`.

With your patch, it looks to me like the library destination is always 
`$prefix/lib/clang/$triple`, and specifying LIBCXX_INSTALL_PREFIX simply 
changes `$prefix`.

Is that correct?  If so, is that worthwhile to note in the summary?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59168/new/

https://reviews.llvm.org/D59168



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


[PATCH] D59048: Add AIX Target Info

2019-03-13 Thread Jason Liu via Phabricator via cfe-commits
jasonliu added a comment.

I'm seeing some build bot failures because of the newly added test case: 
max_align.c.
So I reverted the previous committed change. 
Please fix the test case and let me know so that I can help you commit again.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59048/new/

https://reviews.llvm.org/D59048



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


RE: [PATCH] D59307: Patch llvm bug 41033 concerning atomicity of statement expressions

2019-03-13 Thread Blower, Melanie via cfe-commits
Yes the IR looks a bit odd. I should use a simpler case with a global _Atomic 
int a instead of the parameter. The store is the parameter value a, if I move 
that to a global then it won't be as confusing. 

> -Original Message-
> From: JF Bastien via Phabricator [mailto:revi...@reviews.llvm.org]
> Sent: Wednesday, March 13, 2019 12:57 PM
> To: Blower, Melanie ; cfe-commits@lists.llvm.org;
> Keane, Erich ; rich...@metafoo.co.uk;
> r...@google.com; jfbast...@apple.com
> Cc: jdoerf...@anl.gov; mlek...@skidmore.edu; blitzrak...@gmail.com;
> shen...@google.com
> Subject: [PATCH] D59307: Patch llvm bug 41033 concerning atomicity of
> statement expressions
> 
> jfb requested changes to this revision.
> jfb added a comment.
> This revision now requires changes to proceed.
> 
> I think you also want to test C++ `std::atomic` as well as regular `volatile`.
> 
> 
> 
> 
> Comment at: test/Sema/atomic-expr-stmt.c:7
> +  //CHECK: %atomic-load = load atomic i32, i32* %a.addr seq_cst, align
> + 4
> +  //CHECK: store atomic i32 %atomic-load, i32* %tmp seq_cst, align 4
> +  //CHECK: %0 = load i32, i32* %tmp, align 4
> 
> Why is there a store to `a` here?
[Blower, Melanie] Yes the IR looks a bit odd. I can use a simpler case with a 
global _Atomic int a instead of the parameter. But it does seem like the "store 
atomic" to tmp shouldn't exist.  The %tmp is the value returned by the 
StmtExpr. Since the atomic load has already occurred, the value returned by 
StmtExpr could just be %atomic-load. Without the StmtExpr, there's just the 
atomic load, which is then stored into b.

I changed the test like this, and the IR follows
_Atomic int a;
void test_assign(int b) { 
  // assignment is OK
  b = ({a;}); 
}

; Function Attrs: noinline nounwind optnone
define void @test_assign(i32 %b) #0 {
entry:
  %b.addr = alloca i32, align 4
  %tmp = alloca i32, align 4
  store i32 %b, i32* %b.addr, align 4
  %atomic-load = load atomic i32, i32* @a seq_cst, align 4
  store atomic i32 %atomic-load, i32* %tmp seq_cst, align 4
  %0 = load i32, i32* %tmp, align 4
  store i32 %0, i32* %b.addr, align 4
  ret void
}
> 
> 
> 
> Comment at: test/Sema/atomic-expr-stmt.c:9
> +  //CHECK: %0 = load i32, i32* %tmp, align 4
> +  //CHECK: store i32 %0, i32* %b.addr, align 4 }
> 
> What's in `%tmp`? I'd expect the value loaded from `a` to be stored to `b`.
> 
> 
> Repository:
>   rC Clang
> 
> CHANGES SINCE LAST ACTION
>   https://reviews.llvm.org/D59307/new/
> 
> https://reviews.llvm.org/D59307
> 
> 

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


[PATCH] D59279: [Analyzer] Checker for non-determinism caused by iteration of unordered container of pointers

2019-03-13 Thread Mandeep Singh Grang via Phabricator via cfe-commits
mgrang added a comment.

Also, what is the difference between these two: 
https://clang.llvm.org/docs/analyzer/checkers.html, 
https://clang-analyzer.llvm.org/available_checks.html. It seems they document 
similar stuff. Should we add the doc for each new checker in both of these?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59279/new/

https://reviews.llvm.org/D59279



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


[PATCH] D59279: [Analyzer] Checker for non-determinism caused by iteration of unordered container of pointers

2019-03-13 Thread Mandeep Singh Grang via Phabricator via cfe-commits
mgrang added a comment.

> The obvious question, why not implement this in clang-tidy?

Going forward I would like to make these non-determinism checks more precise by 
reasoning about what happens inside the loop, for example. I am not sure if 
clang-tidy has support for such deeper reasoning. I thought clang-tidy is more 
of a pattern matcher?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59279/new/

https://reviews.llvm.org/D59279



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


RE: [PATCH] D59307: Patch llvm bug 41033 concerning atomicity of statement expressions

2019-03-13 Thread Blower, Melanie via cfe-commits
Sorry I formatted my reply badly, there are responses inline in the previous 
message

> -Original Message-
> From: Blower, Melanie
> Sent: Wednesday, March 13, 2019 2:06 PM
> To: 'reviews+d59307+public+153a08d52e63c...@reviews.llvm.org'
> ; cfe-
> comm...@lists.llvm.org; Keane, Erich ;
> rich...@metafoo.co.uk; r...@google.com; jfbast...@apple.com
> Cc: jdoerf...@anl.gov; mlek...@skidmore.edu; blitzrak...@gmail.com;
> shen...@google.com
> Subject: RE: [PATCH] D59307: Patch llvm bug 41033 concerning atomicity of
> statement expressions
> 
> Yes the IR looks a bit odd. I should use a simpler case with a global _Atomic 
> int a
> instead of the parameter. The store is the parameter value a, if I move that 
> to a
> global then it won't be as confusing.
> 
> > -Original Message-
> > From: JF Bastien via Phabricator [mailto:revi...@reviews.llvm.org]
> > Sent: Wednesday, March 13, 2019 12:57 PM
> > To: Blower, Melanie ;
> > cfe-commits@lists.llvm.org; Keane, Erich ;
> > rich...@metafoo.co.uk; r...@google.com; jfbast...@apple.com
> > Cc: jdoerf...@anl.gov; mlek...@skidmore.edu; blitzrak...@gmail.com;
> > shen...@google.com
> > Subject: [PATCH] D59307: Patch llvm bug 41033 concerning atomicity of
> > statement expressions
> >
> > jfb requested changes to this revision.
> > jfb added a comment.
> > This revision now requires changes to proceed.
> >
> > I think you also want to test C++ `std::atomic` as well as regular 
> > `volatile`.
> >
> >
> >
> > 
> > Comment at: test/Sema/atomic-expr-stmt.c:7
> > +  //CHECK: %atomic-load = load atomic i32, i32* %a.addr seq_cst,
> > + align
> > + 4
> > +  //CHECK: store atomic i32 %atomic-load, i32* %tmp seq_cst, align 4
> > +  //CHECK: %0 = load i32, i32* %tmp, align 4
> > 
> > Why is there a store to `a` here?
> [Blower, Melanie] Yes the IR looks a bit odd. I can use a simpler case with a
> global _Atomic int a instead of the parameter. But it does seem like the 
> "store
> atomic" to tmp shouldn't exist.  The %tmp is the value returned by the 
> StmtExpr.
> Since the atomic load has already occurred, the value returned by StmtExpr
> could just be %atomic-load. Without the StmtExpr, there's just the atomic 
> load,
> which is then stored into b.
> 
> I changed the test like this, and the IR follows _Atomic int a; void 
> test_assign(int
> b) {
>   // assignment is OK
>   b = ({a;});
> }
> 
> ; Function Attrs: noinline nounwind optnone define void @test_assign(i32 %b) 
> #0
> {
> entry:
>   %b.addr = alloca i32, align 4
>   %tmp = alloca i32, align 4
>   store i32 %b, i32* %b.addr, align 4
>   %atomic-load = load atomic i32, i32* @a seq_cst, align 4
>   store atomic i32 %atomic-load, i32* %tmp seq_cst, align 4
>   %0 = load i32, i32* %tmp, align 4
>   store i32 %0, i32* %b.addr, align 4
>   ret void
> }
> >
> >
> > 
> > Comment at: test/Sema/atomic-expr-stmt.c:9
> > +  //CHECK: %0 = load i32, i32* %tmp, align 4
> > +  //CHECK: store i32 %0, i32* %b.addr, align 4 }
> > 
> > What's in `%tmp`? I'd expect the value loaded from `a` to be stored to `b`.
> >
> >
> > Repository:
> >   rC Clang
> >
> > CHANGES SINCE LAST ACTION
> >   https://reviews.llvm.org/D59307/new/
> >
> > https://reviews.llvm.org/D59307
> >
> >

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


[PATCH] D59183: [clang-tidy] Expand cases covered by the abseil-duration-unnecessary-conversion check

2019-03-13 Thread Hyrum Wright via Phabricator via cfe-commits
hwright updated this revision to Diff 190456.
hwright marked 4 inline comments as done.
hwright added a comment.

Addressed reviewer comments


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59183/new/

https://reviews.llvm.org/D59183

Files:
  clang-tidy/abseil/DurationUnnecessaryConversionCheck.cpp
  docs/clang-tidy/checks/abseil-duration-unnecessary-conversion.rst
  test/clang-tidy/Inputs/absl/time/time.h
  test/clang-tidy/abseil-duration-unnecessary-conversion.cpp

Index: test/clang-tidy/abseil-duration-unnecessary-conversion.cpp
===
--- test/clang-tidy/abseil-duration-unnecessary-conversion.cpp
+++ test/clang-tidy/abseil-duration-unnecessary-conversion.cpp
@@ -8,42 +8,80 @@
   // Floating point
   d2 = absl::Hours(absl::ToDoubleHours(d1));
   // CHECK-MESSAGES: [[@LINE-1]]:8: warning: remove unnecessary absl::Duration conversions [abseil-duration-unnecessary-conversion]
-  // CHECK-FIXES: d1
+  // CHECK-FIXES: d2 = d1
   d2 = absl::Minutes(absl::ToDoubleMinutes(d1));
   // CHECK-MESSAGES: [[@LINE-1]]:8: warning: remove unnecessary absl::Duration conversions [abseil-duration-unnecessary-conversion]
-  // CHECK-FIXES: d1
+  // CHECK-FIXES: d2 = d1
   d2 = absl::Seconds(absl::ToDoubleSeconds(d1));
   // CHECK-MESSAGES: [[@LINE-1]]:8: warning: remove unnecessary absl::Duration conversions [abseil-duration-unnecessary-conversion]
-  // CHECK-FIXES: d1
+  // CHECK-FIXES: d2 = d1
   d2 = absl::Milliseconds(absl::ToDoubleMilliseconds(d1));
   // CHECK-MESSAGES: [[@LINE-1]]:8: warning: remove unnecessary absl::Duration conversions [abseil-duration-unnecessary-conversion]
-  // CHECK-FIXES: d1
+  // CHECK-FIXES: d2 = d1
   d2 = absl::Microseconds(absl::ToDoubleMicroseconds(d1));
   // CHECK-MESSAGES: [[@LINE-1]]:8: warning: remove unnecessary absl::Duration conversions [abseil-duration-unnecessary-conversion]
-  // CHECK-FIXES: d1
+  // CHECK-FIXES: d2 = d1
   d2 = absl::Nanoseconds(absl::ToDoubleNanoseconds(d1));
   // CHECK-MESSAGES: [[@LINE-1]]:8: warning: remove unnecessary absl::Duration conversions [abseil-duration-unnecessary-conversion]
-  // CHECK-FIXES: d1
+  // CHECK-FIXES: d2 = d1
 
   // Integer point
   d2 = absl::Hours(absl::ToInt64Hours(d1));
   // CHECK-MESSAGES: [[@LINE-1]]:8: warning: remove unnecessary absl::Duration conversions [abseil-duration-unnecessary-conversion]
-  // CHECK-FIXES: d1
+  // CHECK-FIXES: d2 = d1
   d2 = absl::Minutes(absl::ToInt64Minutes(d1));
   // CHECK-MESSAGES: [[@LINE-1]]:8: warning: remove unnecessary absl::Duration conversions [abseil-duration-unnecessary-conversion]
-  // CHECK-FIXES: d1
+  // CHECK-FIXES: d2 = d1
   d2 = absl::Seconds(absl::ToInt64Seconds(d1));
   // CHECK-MESSAGES: [[@LINE-1]]:8: warning: remove unnecessary absl::Duration conversions [abseil-duration-unnecessary-conversion]
-  // CHECK-FIXES: d1
+  // CHECK-FIXES: d2 = d1
   d2 = absl::Milliseconds(absl::ToInt64Milliseconds(d1));
   // CHECK-MESSAGES: [[@LINE-1]]:8: warning: remove unnecessary absl::Duration conversions [abseil-duration-unnecessary-conversion]
-  // CHECK-FIXES: d1
+  // CHECK-FIXES: d2 = d1
   d2 = absl::Microseconds(absl::ToInt64Microseconds(d1));
   // CHECK-MESSAGES: [[@LINE-1]]:8: warning: remove unnecessary absl::Duration conversions [abseil-duration-unnecessary-conversion]
-  // CHECK-FIXES: d1
+  // CHECK-FIXES: d2 = d1
   d2 = absl::Nanoseconds(absl::ToInt64Nanoseconds(d1));
   // CHECK-MESSAGES: [[@LINE-1]]:8: warning: remove unnecessary absl::Duration conversions [abseil-duration-unnecessary-conversion]
-  // CHECK-FIXES: d1
+  // CHECK-FIXES: d2 = d1
+
+  d2 = absl::Hours(d1 / absl::Hours(1));
+  // CHECK-MESSAGES: [[@LINE-1]]:8: warning: remove unnecessary absl::Duration conversions [abseil-duration-unnecessary-conversion]
+  // CHECK-FIXES: d2 = d1
+  d2 = absl::Minutes(d1 / absl::Minutes(1));
+  // CHECK-MESSAGES: [[@LINE-1]]:8: warning: remove unnecessary absl::Duration conversions [abseil-duration-unnecessary-conversion]
+  // CHECK-FIXES: d2 = d1
+  d2 = absl::Seconds(d1 / absl::Seconds(1));
+  // CHECK-MESSAGES: [[@LINE-1]]:8: warning: remove unnecessary absl::Duration conversions [abseil-duration-unnecessary-conversion]
+  // CHECK-FIXES: d2 = d1
+  d2 = absl::Milliseconds(d1 / absl::Milliseconds(1));
+  // CHECK-MESSAGES: [[@LINE-1]]:8: warning: remove unnecessary absl::Duration conversions [abseil-duration-unnecessary-conversion]
+  // CHECK-FIXES: d2 = d1
+  d2 = absl::Microseconds(d1 / absl::Microseconds(1));
+  // CHECK-MESSAGES: [[@LINE-1]]:8: warning: remove unnecessary absl::Duration conversions [abseil-duration-unnecessary-conversion]
+  // CHECK-FIXES: d2 = d1
+  d2 = absl::Nanoseconds(d1 / absl::Nanoseconds(1));
+  // CHECK-MESSAGES: [[@LINE-1]]:8: warning: remove unnecessary absl::Duration conversions [abseil-duration-unnecessary-conversion]
+  // CHECK-FIXES: d2 = d1
+
+  d2 = absl::Hours(absl::FDivDuration(d1, absl::Hours(1)));
+  // CHECK-MESSAGES: [[@LINE-1]]:8: warning: 

[PATCH] D59183: [clang-tidy] Expand cases covered by the abseil-duration-unnecessary-conversion check

2019-03-13 Thread Hyrum Wright via Phabricator via cfe-commits
hwright added inline comments.



Comment at: test/clang-tidy/abseil-duration-unnecessary-conversion.cpp:48
 
+  d2 = absl::Hours(d1 / absl::Hours(1));
+  // CHECK-MESSAGES: [[@LINE-1]]:8: warning: remove unnecessary absl::Duration 
conversions [abseil-duration-unnecessary-conversion]

hokein wrote:
> An off-topic comment: do we have this code pattern in the codebase? From my 
> understanding, the usage like this is really rare. 
This mostly shows up in migrations.  When an existing API takes an integer, and 
caller already has a `Duration`, they sometimes use `dur / absl::Seconds(1)` to 
get back in integer at the callsite.   After a migration, we end up with 
`absl::Seconds(dur /absl::Seconds(1))`, which should really just be `dur`.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59183/new/

https://reviews.llvm.org/D59183



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


  1   2   3   >