[libclc] r325867 - utils: Adapt to llvm r325155

2018-02-22 Thread Jan Vesely via cfe-commits
Author: jvesely
Date: Thu Feb 22 23:37:03 2018
New Revision: 325867

URL: http://llvm.org/viewvc/llvm-project?rev=325867=rev
Log:
utils: Adapt to llvm r325155

r325155 ("Pass a reference to a module to the bitcode writer.")
changed bit writer interface from pointer to reference

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

Modified:
libclc/trunk/utils/prepare-builtins.cpp

Modified: libclc/trunk/utils/prepare-builtins.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/utils/prepare-builtins.cpp?rev=325867=325866=325867=diff
==
--- libclc/trunk/utils/prepare-builtins.cpp (original)
+++ libclc/trunk/utils/prepare-builtins.cpp Thu Feb 22 23:37:03 2018
@@ -105,7 +105,11 @@ int main(int argc, char **argv) {
 exit(1);
   }
 
+#if HAVE_LLVM >= 0x0700
+  WriteBitcodeToFile(*M, Out->os());
+#else
   WriteBitcodeToFile(M, Out->os());
+#endif
 
   // Declare success.
   Out->keep();


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


[libclc] r325866 - amdgcn: Fix build after GDS/const AS swap in r325030

2018-02-22 Thread Jan Vesely via cfe-commits
Author: jvesely
Date: Thu Feb 22 23:37:01 2018
New Revision: 325866

URL: http://llvm.org/viewvc/llvm-project?rev=325866=rev
Log:
amdgcn: Fix build after GDS/const AS swap in r325030

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

Added:
libclc/trunk/amdgcn-amdhsa/lib/OVERRIDES_4.0
libclc/trunk/amdgcn-amdhsa/lib/OVERRIDES_5.0
libclc/trunk/amdgcn-amdhsa/lib/SOURCES_4.0
libclc/trunk/amdgcn-amdhsa/lib/SOURCES_5.0
libclc/trunk/amdgcn-amdhsa/lib/workitem/get_global_size.50.ll
  - copied, changed from r325865, 
libclc/trunk/amdgcn-amdhsa/lib/workitem/get_global_size.ll
libclc/trunk/amdgcn-amdhsa/lib/workitem/get_global_size.cl
libclc/trunk/amdgcn-amdhsa/lib/workitem/get_local_size.50.ll
  - copied, changed from r325865, 
libclc/trunk/amdgcn-amdhsa/lib/workitem/get_local_size.ll
libclc/trunk/amdgcn-amdhsa/lib/workitem/get_local_size.cl
Removed:
libclc/trunk/amdgcn-amdhsa/lib/workitem/get_global_size.ll
libclc/trunk/amdgcn-amdhsa/lib/workitem/get_local_size.ll
Modified:
libclc/trunk/amdgcn-amdhsa/lib/OVERRIDES
libclc/trunk/amdgcn-amdhsa/lib/OVERRIDES_3.9
libclc/trunk/amdgcn-amdhsa/lib/SOURCES
libclc/trunk/amdgcn/lib/cl_khr_int64_extended_atomics/minmax_helpers.ll
libclc/trunk/amdgcn/lib/workitem/get_global_offset.cl
libclc/trunk/amdgcn/lib/workitem/get_global_size.ll
libclc/trunk/amdgcn/lib/workitem/get_local_size.ll
libclc/trunk/amdgcn/lib/workitem/get_num_groups.ll
libclc/trunk/amdgcn/lib/workitem/get_work_dim.cl

Modified: libclc/trunk/amdgcn-amdhsa/lib/OVERRIDES
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/amdgcn-amdhsa/lib/OVERRIDES?rev=325866=325865=325866=diff
==
--- libclc/trunk/amdgcn-amdhsa/lib/OVERRIDES (original)
+++ libclc/trunk/amdgcn-amdhsa/lib/OVERRIDES Thu Feb 22 23:37:01 2018
@@ -1,4 +1,6 @@
 workitem/get_num_groups.ll
+workitem/get_global_size.ll
+workitem/get_local_size.ll
 workitem/get_num_groups.40.ll
 workitem/get_global_size.40.ll
 workitem/get_local_size.40.ll

Modified: libclc/trunk/amdgcn-amdhsa/lib/OVERRIDES_3.9
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/amdgcn-amdhsa/lib/OVERRIDES_3.9?rev=325866=325865=325866=diff
==
--- libclc/trunk/amdgcn-amdhsa/lib/OVERRIDES_3.9 (original)
+++ libclc/trunk/amdgcn-amdhsa/lib/OVERRIDES_3.9 Thu Feb 22 23:37:01 2018
@@ -1,3 +1,3 @@
-workitem/get_global_size.ll
-workitem/get_local_size.ll
+workitem/get_global_size.cl
+workitem/get_local_size.cl
 workitem/get_num_groups.39.ll

Added: libclc/trunk/amdgcn-amdhsa/lib/OVERRIDES_4.0
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/amdgcn-amdhsa/lib/OVERRIDES_4.0?rev=325866=auto
==
--- libclc/trunk/amdgcn-amdhsa/lib/OVERRIDES_4.0 (added)
+++ libclc/trunk/amdgcn-amdhsa/lib/OVERRIDES_4.0 Thu Feb 22 23:37:01 2018
@@ -0,0 +1,2 @@
+workitem/get_global_size.cl
+workitem/get_local_size.cl

Added: libclc/trunk/amdgcn-amdhsa/lib/OVERRIDES_5.0
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/amdgcn-amdhsa/lib/OVERRIDES_5.0?rev=325866=auto
==
--- libclc/trunk/amdgcn-amdhsa/lib/OVERRIDES_5.0 (added)
+++ libclc/trunk/amdgcn-amdhsa/lib/OVERRIDES_5.0 Thu Feb 22 23:37:01 2018
@@ -0,0 +1,2 @@
+workitem/get_global_size.cl
+workitem/get_local_size.cl

Modified: libclc/trunk/amdgcn-amdhsa/lib/SOURCES
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/amdgcn-amdhsa/lib/SOURCES?rev=325866=325865=325866=diff
==
--- libclc/trunk/amdgcn-amdhsa/lib/SOURCES (original)
+++ libclc/trunk/amdgcn-amdhsa/lib/SOURCES Thu Feb 22 23:37:01 2018
@@ -1,3 +1,3 @@
-workitem/get_global_size.ll
-workitem/get_local_size.ll
+workitem/get_global_size.cl
+workitem/get_local_size.cl
 workitem/get_num_groups.cl

Added: libclc/trunk/amdgcn-amdhsa/lib/SOURCES_4.0
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/amdgcn-amdhsa/lib/SOURCES_4.0?rev=325866=auto
==
--- libclc/trunk/amdgcn-amdhsa/lib/SOURCES_4.0 (added)
+++ libclc/trunk/amdgcn-amdhsa/lib/SOURCES_4.0 Thu Feb 22 23:37:01 2018
@@ -0,0 +1,2 @@
+workitem/get_global_size.50.ll
+workitem/get_local_size.50.ll

Added: libclc/trunk/amdgcn-amdhsa/lib/SOURCES_5.0
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/amdgcn-amdhsa/lib/SOURCES_5.0?rev=325866=auto
==
--- libclc/trunk/amdgcn-amdhsa/lib/SOURCES_5.0 (added)
+++ libclc/trunk/amdgcn-amdhsa/lib/SOURCES_5.0 Thu Feb 22 23:37:01 2018
@@ -0,0 +1,2 @@
+workitem/get_global_size.50.ll
+workitem/get_local_size.50.ll

Copied: 

[libclc] r325865 - amdgcn: Fix datalayout after addition of 32bit const AS in r324747

2018-02-22 Thread Jan Vesely via cfe-commits
Author: jvesely
Date: Thu Feb 22 23:36:54 2018
New Revision: 325865

URL: http://llvm.org/viewvc/llvm-project?rev=325865=rev
Log:
amdgcn: Fix datalayout after addition of 32bit const AS in r324747

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

Modified:
libclc/trunk/amdgcn/lib/cl_khr_int64_extended_atomics/minmax_helpers.ll
libclc/trunk/amdgcn/lib/workitem/get_global_size.ll
libclc/trunk/amdgcn/lib/workitem/get_local_size.ll
libclc/trunk/amdgcn/lib/workitem/get_num_groups.ll

Modified: 
libclc/trunk/amdgcn/lib/cl_khr_int64_extended_atomics/minmax_helpers.ll
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/amdgcn/lib/cl_khr_int64_extended_atomics/minmax_helpers.ll?rev=325865=325864=325865=diff
==
--- libclc/trunk/amdgcn/lib/cl_khr_int64_extended_atomics/minmax_helpers.ll 
(original)
+++ libclc/trunk/amdgcn/lib/cl_khr_int64_extended_atomics/minmax_helpers.ll Thu 
Feb 22 23:36:54 2018
@@ -1,4 +1,4 @@
-target datalayout = 
"e-p:64:64-p1:64:64-p2:64:64-p3:32:32-p4:32:32-p5:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-A5"
+target datalayout = 
"e-p:64:64-p1:64:64-p2:64:64-p3:32:32-p4:32:32-p5:32:32-p6:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-A5"
 
 define i64 @__clc__sync_fetch_and_min_global_8(i64 addrspace(1)* nocapture 
%ptr, i64 %value) nounwind alwaysinline {
 entry:

Modified: libclc/trunk/amdgcn/lib/workitem/get_global_size.ll
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/amdgcn/lib/workitem/get_global_size.ll?rev=325865=325864=325865=diff
==
--- libclc/trunk/amdgcn/lib/workitem/get_global_size.ll (original)
+++ libclc/trunk/amdgcn/lib/workitem/get_global_size.ll Thu Feb 22 23:36:54 2018
@@ -2,7 +2,7 @@ declare i32 @llvm.r600.read.global.size.
 declare i32 @llvm.r600.read.global.size.y() nounwind readnone
 declare i32 @llvm.r600.read.global.size.z() nounwind readnone
 
-target datalayout = 
"e-p:64:64-p1:64:64-p2:64:64-p3:32:32-p4:32:32-p5:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-A5"
+target datalayout = 
"e-p:64:64-p1:64:64-p2:64:64-p3:32:32-p4:32:32-p5:32:32-p6:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-A5"
 
 define i64 @get_global_size(i32 %dim) nounwind readnone alwaysinline {
   switch i32 %dim, label %default [i32 0, label %x_dim i32 1, label %y_dim i32 
2, label %z_dim]

Modified: libclc/trunk/amdgcn/lib/workitem/get_local_size.ll
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/amdgcn/lib/workitem/get_local_size.ll?rev=325865=325864=325865=diff
==
--- libclc/trunk/amdgcn/lib/workitem/get_local_size.ll (original)
+++ libclc/trunk/amdgcn/lib/workitem/get_local_size.ll Thu Feb 22 23:36:54 2018
@@ -2,7 +2,7 @@ declare i32 @llvm.r600.read.local.size.x
 declare i32 @llvm.r600.read.local.size.y() nounwind readnone
 declare i32 @llvm.r600.read.local.size.z() nounwind readnone
 
-target datalayout = 
"e-p:64:64-p1:64:64-p2:64:64-p3:32:32-p4:32:32-p5:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-A5"
+target datalayout = 
"e-p:64:64-p1:64:64-p2:64:64-p3:32:32-p4:32:32-p5:32:32-p6:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-A5"
 
 define i64 @get_local_size(i32 %dim) nounwind readnone alwaysinline {
   switch i32 %dim, label %default [i32 0, label %x_dim i32 1, label %y_dim i32 
2, label %z_dim]

Modified: libclc/trunk/amdgcn/lib/workitem/get_num_groups.ll
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/amdgcn/lib/workitem/get_num_groups.ll?rev=325865=325864=325865=diff
==
--- libclc/trunk/amdgcn/lib/workitem/get_num_groups.ll (original)
+++ libclc/trunk/amdgcn/lib/workitem/get_num_groups.ll Thu Feb 22 23:36:54 2018
@@ -2,7 +2,7 @@ declare i32 @llvm.r600.read.ngroups.x()
 declare i32 @llvm.r600.read.ngroups.y() nounwind readnone
 declare i32 @llvm.r600.read.ngroups.z() nounwind readnone
 
-target datalayout = 
"e-p:64:64-p1:64:64-p2:64:64-p3:32:32-p4:32:32-p5:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-A5"
+target datalayout = 
"e-p:64:64-p1:64:64-p2:64:64-p3:32:32-p4:32:32-p5:32:32-p6:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-A5"
 
 define i64 @get_num_groups(i32 %dim) nounwind readnone alwaysinline {
   switch i32 %dim, label %default [i32 0, label %x_dim i32 1, label %y_dim i32 
2, label %z_dim]



[libclc] r325864 - r600: Fix datalayout after clang r324101

2018-02-22 Thread Jan Vesely via cfe-commits
Author: jvesely
Date: Thu Feb 22 23:36:51 2018
New Revision: 325864

URL: http://llvm.org/viewvc/llvm-project?rev=325864=rev
Log:
r600: Fix datalayout after clang r324101

r324101 switched around AS numbering

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

Added:
libclc/trunk/r600/lib/OVERRIDES_3.9
libclc/trunk/r600/lib/OVERRIDES_4.0
libclc/trunk/r600/lib/OVERRIDES_5.0
libclc/trunk/r600/lib/OVERRIDES_6.0
libclc/trunk/r600/lib/SOURCES_4.0
libclc/trunk/r600/lib/SOURCES_5.0
libclc/trunk/r600/lib/SOURCES_6.0
libclc/trunk/r600/lib/synchronization/barrier_impl.39.ll
  - copied, changed from r325863, 
libclc/trunk/r600/lib/synchronization/barrier_impl.ll
libclc/trunk/r600/lib/workitem/get_global_size.39.ll
  - copied, changed from r325863, 
libclc/trunk/r600/lib/workitem/get_global_size.ll
libclc/trunk/r600/lib/workitem/get_local_size.39.ll
  - copied, changed from r325863, 
libclc/trunk/r600/lib/workitem/get_local_size.ll
libclc/trunk/r600/lib/workitem/get_num_groups.39.ll
  - copied, changed from r325863, 
libclc/trunk/r600/lib/workitem/get_num_groups.ll
Modified:
libclc/trunk/r600/lib/SOURCES_3.9
libclc/trunk/r600/lib/synchronization/barrier_impl.ll
libclc/trunk/r600/lib/workitem/get_global_size.ll
libclc/trunk/r600/lib/workitem/get_local_size.ll
libclc/trunk/r600/lib/workitem/get_num_groups.ll

Added: libclc/trunk/r600/lib/OVERRIDES_3.9
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/r600/lib/OVERRIDES_3.9?rev=325864=auto
==
--- libclc/trunk/r600/lib/OVERRIDES_3.9 (added)
+++ libclc/trunk/r600/lib/OVERRIDES_3.9 Thu Feb 22 23:36:51 2018
@@ -0,0 +1,4 @@
+synchronization/barrier_impl.ll
+workitem/get_global_size.ll
+workitem/get_local_size.ll
+workitem/get_num_groups.ll

Added: libclc/trunk/r600/lib/OVERRIDES_4.0
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/r600/lib/OVERRIDES_4.0?rev=325864=auto
==
--- libclc/trunk/r600/lib/OVERRIDES_4.0 (added)
+++ libclc/trunk/r600/lib/OVERRIDES_4.0 Thu Feb 22 23:36:51 2018
@@ -0,0 +1,4 @@
+synchronization/barrier_impl.ll
+workitem/get_global_size.ll
+workitem/get_local_size.ll
+workitem/get_num_groups.ll

Added: libclc/trunk/r600/lib/OVERRIDES_5.0
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/r600/lib/OVERRIDES_5.0?rev=325864=auto
==
--- libclc/trunk/r600/lib/OVERRIDES_5.0 (added)
+++ libclc/trunk/r600/lib/OVERRIDES_5.0 Thu Feb 22 23:36:51 2018
@@ -0,0 +1,4 @@
+synchronization/barrier_impl.ll
+workitem/get_global_size.ll
+workitem/get_local_size.ll
+workitem/get_num_groups.ll

Added: libclc/trunk/r600/lib/OVERRIDES_6.0
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/r600/lib/OVERRIDES_6.0?rev=325864=auto
==
--- libclc/trunk/r600/lib/OVERRIDES_6.0 (added)
+++ libclc/trunk/r600/lib/OVERRIDES_6.0 Thu Feb 22 23:36:51 2018
@@ -0,0 +1,4 @@
+synchronization/barrier_impl.ll
+workitem/get_global_size.ll
+workitem/get_local_size.ll
+workitem/get_num_groups.ll

Modified: libclc/trunk/r600/lib/SOURCES_3.9
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/r600/lib/SOURCES_3.9?rev=325864=325863=325864=diff
==
--- libclc/trunk/r600/lib/SOURCES_3.9 (original)
+++ libclc/trunk/r600/lib/SOURCES_3.9 Thu Feb 22 23:36:51 2018
@@ -13,3 +13,7 @@ image/write_imagef.cl
 image/write_imagei.cl
 image/write_imageui.cl
 image/write_image_impl.ll
+synchronization/barrier_impl.39.ll
+workitem/get_global_size.39.ll
+workitem/get_local_size.39.ll
+workitem/get_num_groups.39.ll

Added: libclc/trunk/r600/lib/SOURCES_4.0
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/r600/lib/SOURCES_4.0?rev=325864=auto
==
--- libclc/trunk/r600/lib/SOURCES_4.0 (added)
+++ libclc/trunk/r600/lib/SOURCES_4.0 Thu Feb 22 23:36:51 2018
@@ -0,0 +1,4 @@
+synchronization/barrier_impl.39.ll
+workitem/get_global_size.39.ll
+workitem/get_local_size.39.ll
+workitem/get_num_groups.39.ll

Added: libclc/trunk/r600/lib/SOURCES_5.0
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/r600/lib/SOURCES_5.0?rev=325864=auto
==
--- libclc/trunk/r600/lib/SOURCES_5.0 (added)
+++ libclc/trunk/r600/lib/SOURCES_5.0 Thu Feb 22 23:36:51 2018
@@ -0,0 +1,4 @@
+synchronization/barrier_impl.39.ll
+workitem/get_global_size.39.ll
+workitem/get_local_size.39.ll
+workitem/get_num_groups.39.ll

Added: libclc/trunk/r600/lib/SOURCES_6.0
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/r600/lib/SOURCES_6.0?rev=325864=auto

[libclc] r325863 - amdgcn: Fix datalayout after clang r324101

2018-02-22 Thread Jan Vesely via cfe-commits
Author: jvesely
Date: Thu Feb 22 23:36:39 2018
New Revision: 325863

URL: http://llvm.org/viewvc/llvm-project?rev=325863=rev
Log:
amdgcn: Fix datalayout after clang r324101

r324101 switched around AS numbering

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

Added:
libclc/trunk/amdgcn/lib/OVERRIDES_4.0
  - copied, changed from r325061, libclc/trunk/amdgcn/lib/OVERRIDES_3.9
libclc/trunk/amdgcn/lib/OVERRIDES_5.0
  - copied, changed from r325061, libclc/trunk/amdgcn/lib/OVERRIDES_3.9
libclc/trunk/amdgcn/lib/OVERRIDES_6.0
  - copied, changed from r325061, libclc/trunk/amdgcn/lib/OVERRIDES_3.9
libclc/trunk/amdgcn/lib/SOURCES_4.0
libclc/trunk/amdgcn/lib/SOURCES_5.0
libclc/trunk/amdgcn/lib/SOURCES_6.0
libclc/trunk/amdgcn/lib/cl_khr_int64_extended_atomics/minmax_helpers.39.ll
  - copied, changed from r325061, 
libclc/trunk/amdgcn/lib/cl_khr_int64_extended_atomics/minmax_helpers.ll
libclc/trunk/amdgcn/lib/workitem/get_global_size.40.ll
  - copied, changed from r325061, 
libclc/trunk/amdgcn/lib/workitem/get_global_size.ll
libclc/trunk/amdgcn/lib/workitem/get_local_size.40.ll
  - copied, changed from r325061, 
libclc/trunk/amdgcn/lib/workitem/get_local_size.ll
libclc/trunk/amdgcn/lib/workitem/get_num_groups.40.ll
  - copied, changed from r325061, 
libclc/trunk/amdgcn/lib/workitem/get_num_groups.ll
Modified:
libclc/trunk/amdgcn-amdhsa/lib/OVERRIDES
libclc/trunk/amdgcn/lib/OVERRIDES_3.9
libclc/trunk/amdgcn/lib/SOURCES
libclc/trunk/amdgcn/lib/SOURCES_3.9
libclc/trunk/amdgcn/lib/cl_khr_int64_extended_atomics/minmax_helpers.ll
libclc/trunk/amdgcn/lib/workitem/get_global_size.ll
libclc/trunk/amdgcn/lib/workitem/get_local_size.ll
libclc/trunk/amdgcn/lib/workitem/get_num_groups.ll

Modified: libclc/trunk/amdgcn-amdhsa/lib/OVERRIDES
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/amdgcn-amdhsa/lib/OVERRIDES?rev=325863=325862=325863=diff
==
--- libclc/trunk/amdgcn-amdhsa/lib/OVERRIDES (original)
+++ libclc/trunk/amdgcn-amdhsa/lib/OVERRIDES Thu Feb 22 23:36:39 2018
@@ -1 +1,4 @@
 workitem/get_num_groups.ll
+workitem/get_num_groups.40.ll
+workitem/get_global_size.40.ll
+workitem/get_local_size.40.ll

Modified: libclc/trunk/amdgcn/lib/OVERRIDES_3.9
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/amdgcn/lib/OVERRIDES_3.9?rev=325863=325862=325863=diff
==
--- libclc/trunk/amdgcn/lib/OVERRIDES_3.9 (original)
+++ libclc/trunk/amdgcn/lib/OVERRIDES_3.9 Thu Feb 22 23:36:39 2018
@@ -1,3 +1,4 @@
+cl_khr_int64_extended_atomics/minmax_helpers.ll
 workitem/get_global_size.ll
 workitem/get_local_size.ll
 workitem/get_num_groups.ll

Copied: libclc/trunk/amdgcn/lib/OVERRIDES_4.0 (from r325061, 
libclc/trunk/amdgcn/lib/OVERRIDES_3.9)
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/amdgcn/lib/OVERRIDES_4.0?p2=libclc/trunk/amdgcn/lib/OVERRIDES_4.0=libclc/trunk/amdgcn/lib/OVERRIDES_3.9=325061=325863=325863=diff
==
--- libclc/trunk/amdgcn/lib/OVERRIDES_3.9 (original)
+++ libclc/trunk/amdgcn/lib/OVERRIDES_4.0 Thu Feb 22 23:36:39 2018
@@ -1,3 +1,4 @@
+cl_khr_int64_extended_atomics/minmax_helpers.ll
 workitem/get_global_size.ll
 workitem/get_local_size.ll
 workitem/get_num_groups.ll

Copied: libclc/trunk/amdgcn/lib/OVERRIDES_5.0 (from r325061, 
libclc/trunk/amdgcn/lib/OVERRIDES_3.9)
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/amdgcn/lib/OVERRIDES_5.0?p2=libclc/trunk/amdgcn/lib/OVERRIDES_5.0=libclc/trunk/amdgcn/lib/OVERRIDES_3.9=325061=325863=325863=diff
==
--- libclc/trunk/amdgcn/lib/OVERRIDES_3.9 (original)
+++ libclc/trunk/amdgcn/lib/OVERRIDES_5.0 Thu Feb 22 23:36:39 2018
@@ -1,3 +1,4 @@
+cl_khr_int64_extended_atomics/minmax_helpers.ll
 workitem/get_global_size.ll
 workitem/get_local_size.ll
 workitem/get_num_groups.ll

Copied: libclc/trunk/amdgcn/lib/OVERRIDES_6.0 (from r325061, 
libclc/trunk/amdgcn/lib/OVERRIDES_3.9)
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/amdgcn/lib/OVERRIDES_6.0?p2=libclc/trunk/amdgcn/lib/OVERRIDES_6.0=libclc/trunk/amdgcn/lib/OVERRIDES_3.9=325061=325863=325863=diff
==
--- libclc/trunk/amdgcn/lib/OVERRIDES_3.9 (original)
+++ libclc/trunk/amdgcn/lib/OVERRIDES_6.0 Thu Feb 22 23:36:39 2018
@@ -1,3 +1,4 @@
+cl_khr_int64_extended_atomics/minmax_helpers.ll
 workitem/get_global_size.ll
 workitem/get_local_size.ll
 workitem/get_num_groups.ll

Modified: libclc/trunk/amdgcn/lib/SOURCES
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/amdgcn/lib/SOURCES?rev=325863=325862=325863=diff
==
--- 

[PATCH] D43581: [clang-tidy/google] Improve the Objective-C global variable declaration check 

2018-02-22 Thread Stephane Moore via Phabricator via cfe-commits
stephanemoore marked an inline comment as not done.
stephanemoore added inline comments.



Comment at: test/clang-tidy/google-objc-global-variable-declaration.m:33
 static NSString* const kGood = @"hello";
+static NSString* const XYGood = @"hello";
 static NSString* gMyIntGood = 0;

aaron.ballman wrote:
> Can you also add the code from the style guide as a test case?
> ```
> extern NSString *const GTLServiceErrorDomain;
> 
> typedef NS_ENUM(NSInteger, GTLServiceError) {
>   GTLServiceErrorQueryResultMissing = -3000,
>   GTLServiceErrorWaitTimedOut   = -3001,
> };
> ```
NS_ENUM and NSInteger are not defined in this implementation file.

I can either (1) Omit the macro and the type alias; or (2) reasonably replicate 
the macro and type alias in this source file.

Which option is preferred? For the time being, I have pursued option (1) on the 
assumption that NS_ENUM and NSInteger are not critical to this test case.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D43581



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


[PATCH] D43581: [clang-tidy/google] Improve the Objective-C global variable declaration check 

2018-02-22 Thread Stephane Moore via Phabricator via cfe-commits
stephanemoore added inline comments.



Comment at: clang-tidy/google/GlobalVariableDeclarationCheck.cpp:92
+ "an appropriate prefix (see "
+ "http://google.github.io/styleguide/objcguide#constants).")
 << Decl->getName() << generateFixItHint(Decl, true);

Wizard wrote:
> aaron.ballman wrote:
> > We don't usually put hyperlinks in the diagnostic messages, so please 
> > remove this.
> > 
> > My suggestion about describing what constitutes an appropriate prefix was 
> > with regards to the style guide wording itself. For instance, that document 
> > doesn't mention that two capital letters is good. That's not on you to fix 
> > before this patch goes in, of course.
> Btw it is actually "2 or more" characters for prefix. I think it makes sense 
> because we need at least 2 or more characters to call it a "prefix" :-)
Reverted the inclusion of the hyperlink in the message. I agree that embedding 
the hyperlink in the message is indirect and inconsistent with other diagnostic 
messages in LLVM projecta.



Comment at: clang-tidy/google/GlobalVariableDeclarationCheck.cpp:92
+ "an appropriate prefix (see "
+ "http://google.github.io/styleguide/objcguide#constants).")
 << Decl->getName() << generateFixItHint(Decl, true);

stephanemoore wrote:
> Wizard wrote:
> > aaron.ballman wrote:
> > > We don't usually put hyperlinks in the diagnostic messages, so please 
> > > remove this.
> > > 
> > > My suggestion about describing what constitutes an appropriate prefix was 
> > > with regards to the style guide wording itself. For instance, that 
> > > document doesn't mention that two capital letters is good. That's not on 
> > > you to fix before this patch goes in, of course.
> > Btw it is actually "2 or more" characters for prefix. I think it makes 
> > sense because we need at least 2 or more characters to call it a "prefix" 
> > :-)
> Reverted the inclusion of the hyperlink in the message. I agree that 
> embedding the hyperlink in the message is indirect and inconsistent with 
> other diagnostic messages in LLVM projecta.
§1 Regarding Prefixes And Character Count

Strictly speaking, a single character prefix (e.g., `extern const int ALimit;` 
❌) is possible but not allowed for constants in Google Objective-C style except 
for lowercase 'k' as a prefix for file scope constants (e.g., `static const int 
kLimit = 3;` ✔️). As hinted in the commit description, Google currently 
enforces a minimum two character prefix (e.g., `extern const int ABPrefix;` ✔️) 
or exceptionally 'k' where appropriate.

Technically this modified regex allows authored code to include inadvisable 
constant names with a single character prefix (e.g., `extern const int 
APrefix;` ❌). In this respect I would say that this change eliminates an 
important category of false positives (constants prefixed with '[A-Z]{2,}') 
while introducing a less important category of false negatives (constants 
prefixed with only '[A-Z]'). The false positives are observed in standard 
recommended code while the false negatives occur in non-standard unrecommended 
code. Without a reliable mechanism to separate the constant prefix from the 
constant name (e.g., splitting "FOOURL" into "FOO" and "URL" or "HTTP2Header" 
into "HTTP2" and "Header"), I cannot immediately think of a way to eliminate 
the introduced category of false negatives without introducing other false 
positives. I intend to continue thinking about alternative methods that might 
eliminate these false negatives without introducing other compromises. If it is 
acceptable to the reviewers I would propose to move forward with this proposed 
change to eliminate the observed false positives and then consider addressing 
the false negatives in a followup.

§2 Regarding the Google Objective-C Style Guide's Description of Appropriate 
Prefixes

I agree that the Google Objective-C style guide should be clearer on this topic 
and will pursue clarifying this promptly.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D43581



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


[PATCH] D43581: [clang-tidy/google] Improve the Objective-C global variable declaration check 

2018-02-22 Thread Stephane Moore via Phabricator via cfe-commits
stephanemoore updated this revision to Diff 135595.
stephanemoore marked 2 inline comments as done.
stephanemoore retitled this revision from "[clang-tidy/google] Fix the 
Objective-C global variable declaration check " to "[clang-tidy/google] 
Improve the Objective-C global variable declaration check ".
stephanemoore edited the summary of this revision.
stephanemoore added a comment.

I had to make two more fixes to get the tests working:
• Updated the CHECK-MESSAGES in 
`test/clang-tidy/google-objc-global-variable-declaration.m` to the revised 
diagnostic message.
• Removed NS_ENUM and NSInteger from the additions to 
`test/clang-tidy/google-objc-global-variable-declaration.m` because their 
declarations were missing and I assumed that replication of the Foundation 
macro and type alias was not meaningfully important to this test case.

I verified the changes with the following commands:

  $ ${LLVM_ROOT}/tools/clang/tools/extra/test/clang-tidy/check_clang_tidy.py 
${LLVM_ROOT}/tools/clang/tools/extra/test/clang-tidy/google-objc-global-variable-declaration.m
 google-objc-global-variable-declaration /tmp/test && make check-all

Is that satisfactory verification of these changes?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D43581

Files:
  clang-tidy/google/GlobalVariableDeclarationCheck.cpp
  test/clang-tidy/google-objc-global-variable-declaration.m


Index: test/clang-tidy/google-objc-global-variable-declaration.m
===
--- test/clang-tidy/google-objc-global-variable-declaration.m
+++ test/clang-tidy/google-objc-global-variable-declaration.m
@@ -2,7 +2,7 @@
 
 @class NSString;
 static NSString* const myConstString = @"hello";
-// CHECK-MESSAGES: :[[@LINE-1]]:24: warning: const global variable 
'myConstString' must have a name which starts with 'k[A-Z]' 
[google-objc-global-variable-declaration]
+// CHECK-MESSAGES: :[[@LINE-1]]:24: warning: const global variable 
'myConstString' must have a name which starts with an appropriate prefix 
matching '(k[A-Z]|[A-Z]{2,})' [google-objc-global-variable-declaration]
 // CHECK-FIXES: static NSString* const kMyConstString = @"hello";
 
 static NSString* MyString = @"hi";
@@ -22,16 +22,24 @@
 // CHECK-FIXES: static NSString* gNoDef;
 
 static NSString* const _notAlpha = @"NotBeginWithAlpha";
-// CHECK-MESSAGES: :[[@LINE-1]]:24: warning: const global variable '_notAlpha' 
must have a name which starts with 'k[A-Z]' 
[google-objc-global-variable-declaration]
+// CHECK-MESSAGES: :[[@LINE-1]]:24: warning: const global variable '_notAlpha' 
must have a name which starts with an appropriate prefix matching 
'(k[A-Z]|[A-Z]{2,})' [google-objc-global-variable-declaration]
 // CHECK-FIXES: static NSString* const _notAlpha = @"NotBeginWithAlpha";
 
 static NSString* const k_Alpha = @"SecondNotAlpha";
-// CHECK-MESSAGES: :[[@LINE-1]]:24: warning: const global variable 'k_Alpha' 
must have a name which starts with 'k[A-Z]' 
[google-objc-global-variable-declaration]
+// CHECK-MESSAGES: :[[@LINE-1]]:24: warning: const global variable 'k_Alpha' 
must have a name which starts with an appropriate prefix matching 
'(k[A-Z]|[A-Z]{2,})' [google-objc-global-variable-declaration]
 // CHECK-FIXES: static NSString* const k_Alpha = @"SecondNotAlpha";
 
 static NSString* const kGood = @"hello";
+static NSString* const XYGood = @"hello";
 static NSString* gMyIntGood = 0;
 
+extern NSString* const GTLServiceErrorDomain;
+
+enum GTLServiceError {
+  GTLServiceErrorQueryResultMissing = -3000,
+  GTLServiceErrorWaitTimedOut   = -3001,
+};
+
 @implementation Foo
 - (void)f {
 int x = 0;
Index: clang-tidy/google/GlobalVariableDeclarationCheck.cpp
===
--- clang-tidy/google/GlobalVariableDeclarationCheck.cpp
+++ clang-tidy/google/GlobalVariableDeclarationCheck.cpp
@@ -72,7 +72,7 @@
   this);
   Finder->addMatcher(varDecl(hasGlobalStorage(), hasType(isConstQualified()),
  unless(isLocalVariable()),
- unless(matchesName("::k[A-Z]")))
+ unless(matchesName("::(k[A-Z]|[A-Z]{2,})")))
  .bind("global_const"),
  this);
 }
@@ -88,7 +88,7 @@
   if (const auto *Decl = Result.Nodes.getNodeAs("global_const")) {
 diag(Decl->getLocation(),
  "const global variable '%0' must have a name which starts with "
- "'k[A-Z]'")
+ "an appropriate prefix matching '(k[A-Z]|[A-Z]{2,})'")
 << Decl->getName() << generateFixItHint(Decl, true);
   }
 }


Index: test/clang-tidy/google-objc-global-variable-declaration.m
===
--- test/clang-tidy/google-objc-global-variable-declaration.m
+++ test/clang-tidy/google-objc-global-variable-declaration.m
@@ -2,7 +2,7 @@
 
 @class NSString;
 static NSString* const myConstString = @"hello";
-// CHECK-MESSAGES: 

[PATCH] D43621: [Driver] Allow using a canonical form of '-fuse-ld=' when cross-compiling on Windows.

2018-02-22 Thread Rui Ueyama via Phabricator via cfe-commits
ruiu added a comment.

> That's weird, because lots of lldb tests compile and link test binaries on 
> Windows with `-fuse-ld=lld` (without the `.exe`).  What makes you say the 
> `.exe` is necessary?

Maybe he is using clang (not clang-cl) and want to use ld.lld.exe instead of 
lld-link?


Repository:
  rC Clang

https://reviews.llvm.org/D43621



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


[PATCH] D43497: [analyzer] Introduce correct lifetime extension behavior in simple cases.

2018-02-22 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

> Add a FIXME test case that demonstrates that automatic destructors don't fire 
> after lifetime extension through a POD field, even though lifetime extension 
> itself seems to work correctly.

This has always been broken - the CFG element for the automatic destructor is 
simply missing in this case. But previously we didn't inline the constructor, 
so the whole thing was invalidated anyway. I wonder how Sema lives without it.

Now the interesting part here is https://reviews.llvm.org/rC288563 which seems 
to have removed the need to `skipRValueSubobjectAdjustments()` //three days 
after// i added that code in https://reviews.llvm.org/rC288263 ¯\_(ツ)_/¯


https://reviews.llvm.org/D43497



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


[PATCH] D42645: New simple Checker for mmap calls

2018-02-22 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision.
NoQ added a comment.
This revision is now accepted and ready to land.

Thank you! I'll try to commit again.


https://reviews.llvm.org/D42645



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


[PATCH] D43424: [clang-doc] Implement a (simple) Markdown generator

2018-02-22 Thread Julie Hockett via Phabricator via cfe-commits
juliehockett updated this revision to Diff 135583.
juliehockett added a comment.

Updating based on parent revision changes -- still rough, will continue to 
improve.


https://reviews.llvm.org/D43424

Files:
  clang-doc/generators/CMakeLists.txt
  clang-doc/generators/Generators.h
  clang-doc/generators/MDGenerator.cpp
  clang-doc/tool/ClangDocMain.cpp

Index: clang-doc/tool/ClangDocMain.cpp
===
--- clang-doc/tool/ClangDocMain.cpp
+++ clang-doc/tool/ClangDocMain.cpp
@@ -49,7 +49,7 @@
 cl::init("docs"), cl::cat(ClangDocCategory));
 
 static cl::opt Format(
-"format", cl::desc("Format for outputted docs (Current options are yaml)."),
+"format", cl::desc("Format for outputted docs (Current options are yaml, md)."),
 cl::init("yaml"), cl::cat(ClangDocCategory));
 
 static cl::opt DumpResult(
Index: clang-doc/generators/MDGenerator.cpp
===
--- /dev/null
+++ clang-doc/generators/MDGenerator.cpp
@@ -0,0 +1,366 @@
+//===-- MDGenerator.cpp - Markdown Generator *- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "../Representation.h"
+#include "Generators.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Path.h"
+
+using namespace llvm;
+
+namespace clang {
+namespace doc {
+
+int MDGenerator::generate() {
+  if (buildDirTree() && writeNamespaces() && writeClasses()) return 0;
+  return 1;
+}
+
+// File creation and I/O
+
+int MDGenerator::buildDirTree() {
+  removeExistingDirectory(Root);
+  sys::path::native(Root, NamespacesPath);
+  sys::path::append(NamespacesPath, "namespaces");
+  sys::path::native(Root, ClassPath);
+  sys::path::append(ClassPath, "classes");
+  return buildDirectory(NamespacesPath) && buildDirectory(ClassPath);
+}
+
+// Documentation generation
+
+bool MDGenerator::writeNamespaces() {
+  // TODO: Generate summary page
+  bool Success = true;
+  for (const auto  : IS->getNamespaceInfos()) Success = writeNamespacePage(I);
+  return Success;
+}
+
+bool MDGenerator::writeClasses() {
+  bool Success = true;
+  for (const auto  : IS->getRecordInfos()) {
+if (I->TagType == TagTypeKind::TTK_Class) Success = writeClassPage(I);
+  }
+  return Success;
+}
+
+bool MDGenerator::writeNamespacePage(const std::unique_ptr ) {
+  SmallString<128> Path;
+  sys::path::native(NamespacesPath, Path);
+  // for (const auto  : I->Namespace)
+  //   sys::path::append(Path, IS->find(Namespace)->Name);
+  // std::error_code DirectoryStatus = sys::fs::create_directories(Path);
+  // if (DirectoryStatus != OK) {
+  //   errs() << "Unable to create class directories.\n";
+  //   return 1;
+  // }
+  sys::path::append(Path, I->Name + ".md");
+  std::error_code OutErrorInfo;
+  raw_fd_ostream OS(Path, OutErrorInfo, sys::fs::F_None);
+  if (OutErrorInfo != OK) {
+errs() << "Error opening class file.\n";
+return false;
+  }
+
+  writeLine(genH1("namespace " + I->Name), OS);
+  writeBlankLine(OS);
+
+  for (const auto  : I->Description) writeDescription(C, OS);
+
+  // TODO: Write subnamespaces
+
+  // Write functions.
+  bool wroteFunctionHeader = false;
+  for (const auto  : IS->getFunctionInfos()) {
+if (!F->Namespace.empty() && F->Namespace[0] == I->Name) {
+  if (!wroteFunctionHeader) {
+wroteFunctionHeader = true;
+writeLine(genH2("Functions"), OS);
+  }
+  writeFunction(F, OS);
+  writeBlankLine(OS);
+}
+  }
+
+  // Fetch and sort records.
+  llvm::SmallVector Structs;
+  llvm::SmallVector Classes;
+  llvm::SmallVector Unions;
+  for (const auto  : IS->getRecordInfos()) {
+if (!R->Namespace.empty() && R->Namespace[0] == I->Name) {
+  switch (R->TagType) {
+case TagTypeKind::TTK_Class:
+  Classes.push_back(R.get());
+  break;
+case TagTypeKind::TTK_Struct:
+  Structs.push_back(R.get());
+  break;
+case TagTypeKind::TTK_Union:
+  Unions.push_back(R.get());
+  break;
+default:
+  continue;
+  }
+}
+  }
+
+  // Write structs.
+  bool wroteHeader = false;
+  sortRecordInfos(Structs);
+  for (const auto  : Structs) {
+if (!wroteHeader) {
+  wroteHeader = true;
+  writeLine(genH2("Structs"), OS);
+}
+writeRecordSummary(*S, OS);
+writeBlankLine(OS);
+  }
+
+  // Write classes.
+  wroteHeader = false;
+  sortRecordInfos(Classes);
+  for (const auto  : Classes) {
+if (!wroteHeader) {
+  wroteHeader = true;
+  writeLine(genH2("Classes"), OS);
+}
+writeRecordSummary(*C, OS);
+writeBlankLine(OS);
+  }
+
+  // Write unions.
+  wroteHeader = false;
+  sortRecordInfos(Unions);
+  for 

[PATCH] D43667: [clang-doc] Implement a YAML generator

2018-02-22 Thread Julie Hockett via Phabricator via cfe-commits
juliehockett created this revision.
juliehockett added reviewers: klimek, jakehehrlich, sammccall, lebedev.ri.
juliehockett added a project: clang-tools-extra.
Herald added a subscriber: mgorny.
juliehockett added a dependency: D43341: [clang-doc] Implement reducer portion 
of the frontend framework.

Implmenting a YAML generator from the emitted bitcode summary of declarations. 
Emits one YAML file with all declaration information.

For a more detailed overview of the tool, see the design document on the 
mailing list: RFC: clang-doc proposal 



https://reviews.llvm.org/D43667

Files:
  clang-doc/CMakeLists.txt
  clang-doc/generators/CMakeLists.txt
  clang-doc/generators/GeneratorBase.cpp
  clang-doc/generators/Generators.h
  clang-doc/generators/YAMLGenerator.cpp
  clang-doc/tool/CMakeLists.txt
  clang-doc/tool/ClangDocMain.cpp
  test/clang-doc/namespace-yaml.cpp
  test/clang-doc/record-yaml.cpp

Index: test/clang-doc/record-yaml.cpp
===
--- /dev/null
+++ test/clang-doc/record-yaml.cpp
@@ -0,0 +1,119 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: echo "" > %t/compile_flags.txt
+// RUN: cp "%s" "%t/test.cpp"
+// RUN: clang-doc --dump --omit-filenames -doxygen -p %t %t/test.cpp -output=%t/docs
+// RUN: cat %t/docs/yaml/docs.yaml | FileCheck %s
+
+union A { int X; int Y; };
+
+enum B { X, Y };
+
+struct C { int i; };
+
+class D {};
+
+class E {
+public:
+  E() {}
+  ~E() {}
+
+protected:
+  void ProtectedMethod();
+};
+
+void E::ProtectedMethod() {}
+
+class F : virtual private D, public E {};
+
+// CHECK: ---
+// CHECK: Namespaces:  
+// CHECK: Records: 
+// CHECK:   - Name:A
+// CHECK: TagType: Union
+// CHECK: IsDefinition:true
+// CHECK: Location:
+// CHECK: Members: 
+// CHECK:   - Type:int
+// CHECK: Name:'A::X'
+// CHECK: Access:  None
+// CHECK: Description: 
+// CHECK:   - Type:int
+// CHECK: Name:'A::Y'
+// CHECK: Access:  None
+// CHECK: Description: 
+// CHECK: ParentUSRs:  
+// CHECK: VirtualParentUSRs: 
+// CHECK:   - Name:C
+// CHECK: TagType: Struct
+// CHECK: IsDefinition:true
+// CHECK: Location:
+// CHECK: Members: 
+// CHECK:   - Type:int
+// CHECK: Name:'C::i'
+// CHECK: Access:  None
+// CHECK: Description: 
+// CHECK: ParentUSRs:  
+// CHECK: VirtualParentUSRs: 
+// CHECK:   - Name:D
+// CHECK: TagType: Class
+// CHECK: IsDefinition:true
+// CHECK: Location:
+// CHECK: Members: 
+// CHECK: ParentUSRs:  
+// CHECK: VirtualParentUSRs: 
+// CHECK:   - Name:E
+// CHECK: TagType: Class
+// CHECK: IsDefinition:true
+// CHECK: Location:
+// CHECK: Members: 
+// CHECK: ParentUSRs:  
+// CHECK: VirtualParentUSRs: 
+// CHECK:   - Name:F
+// CHECK: TagType: Class
+// CHECK: IsDefinition:true
+// CHECK: Location:
+// CHECK: Members: 
+// CHECK: ParentUSRs:  
+// CHECK:   - 'c:@S@E'
+// CHECK: VirtualParentUSRs: 
+// CHECK:   - 'c:@S@D'
+// CHECK: Functions:   
+// CHECK:   - Name:E
+// CHECK: IsDefinition:true
+// CHECK: Location:
+// CHECK: ParentUSR:   E
+// CHECK: Params:  
+// CHECK: ReturnType:  
+// CHECK:   Type:void
+// CHECK:   Description: 
+// CHECK: Access:  Public
+// CHECK:   - Name:'~E'
+// CHECK: IsDefinition:true
+// CHECK: Location:
+// CHECK: ParentUSR:   '~E'
+// CHECK: Params:  
+// CHECK: ReturnType:  
+// CHECK:   Type:void
+// CHECK:   Description: 
+// CHECK: Access:  Public
+// CHECK:   - Name:ProtectedMethod
+// CHECK: IsDefinition:true
+// CHECK: Location:
+// CHECK: ParentUSR:   ProtectedMethod
+// CHECK: Params:  
+// CHECK: ReturnType:  
+// CHECK:   Type:void
+// CHECK:   Description: 
+// CHECK: Access:  Public
+// CHECK: Enums:   
+// CHECK:   - Name:B
+// CHECK: IsDefinition:true
+// CHECK: Location:
+// CHECK: Scoped:  false
+// CHECK: Members: 
+// CHECK:   - Type:X
+// CHECK: Description: 
+// CHECK:   - Type:Y
+// CHECK: Description: 
+// CHECK: ...
Index: test/clang-doc/namespace-yaml.cpp
===
--- /dev/null
+++ 

[PATCH] D43666: [analyzer] When constructing a temporary without construction context, track it for destruction anyway.

2018-02-22 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ created this revision.
NoQ added reviewers: dcoughlin, xazax.hun, a.sidorin, george.karpenkov, szepet.
Herald added subscribers: cfe-commits, rnkovacs.

This brings back code that was doing so earlier (when we had no constructed 
contexts at all) but was removed too early in https://reviews.llvm.org/D43104, 
as discussed in https://reviews.llvm.org/D43497. This allows us to call the 
correct destructor sequence in the end of the operator `&&` in the test, even 
if not all of them are inlined, because we keep track of all temporaries we've 
constructed in order to resolve situations when the number or nature of 
temporaries is not known in compile-time.

The test case provided in https://reviews.llvm.org/D43497 was not entirely 
correct: the global variable would anyway be invalidated by the other 
destructor that we don't inline yet. Though, yeah, it needs to be fixed as 
well, but it isn't addressed by the fix that i've been thinking of (this patch).

Cleanup process misbehaves when the node after the cleanup is caching out: in 
this case we take the node that wasn't cleaned up and hit the assertion. This 
was fixed as well. It's a bit disappointing that our process of constructing a 
single exploded node is so complicated and error-prone.


Repository:
  rC Clang

https://reviews.llvm.org/D43666

Files:
  include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
  lib/StaticAnalyzer/Core/ExprEngine.cpp
  test/Analysis/temporaries.cpp

Index: test/Analysis/temporaries.cpp
===
--- test/Analysis/temporaries.cpp
+++ test/Analysis/temporaries.cpp
@@ -900,7 +900,13 @@
 
 class C {
 public:
-  ~C() { glob = 1; }
+  ~C() {
+glob = 1;
+clang_analyzer_checkInlined(true);
+#ifdef TEMPORARY_DTORS
+// expected-warning@-2{{TRUE}}
+#endif
+  }
 };
 
 C get();
@@ -913,12 +919,11 @@
   // temporaries: the return value of get() and the elidable copy constructor
   // of that return value into is(). According to the CFG, we need to cleanup
   // both of them depending on whether the temporary corresponding to the
-  // return value of get() was initialized. However, for now we don't track
-  // temporaries returned from functions, so we take the wrong branch.
+  // return value of get() was initialized. However, we didn't track
+  // temporaries returned from functions, so we took the wrong branch.
   coin && is(get()); // no-crash
-  // FIXME: We should have called the destructor, i.e. should be TRUE,
-  // at least when we inline temporary destructors.
-  clang_analyzer_eval(glob == 1); // expected-warning{{UNKNOWN}}
+  // FIXME: Should be true once we inline all destructors.
+  clang_analyzer_eval(glob); // expected-warning{{UNKNOWN}}
 }
 } // namespace dont_forget_destructor_around_logical_op
 
Index: lib/StaticAnalyzer/Core/ExprEngine.cpp
===
--- lib/StaticAnalyzer/Core/ExprEngine.cpp
+++ lib/StaticAnalyzer/Core/ExprEngine.cpp
@@ -1089,6 +1089,34 @@
   }
 }
 
+void ExprEngine::VisitCXXBindTemporaryExpr(const CXXBindTemporaryExpr *BTE,
+   ExplodedNodeSet ,
+   ExplodedNodeSet ) {
+  // This is a fallback solution in case we didn't have a construction
+  // context when we were constructing the temporary. Otherwise the map should
+  // have been populated there.
+  if (!getAnalysisManager().options.includeTemporaryDtorsInCFG()) {
+// In case we don't have temporary destructors in the CFG, do not mark
+// the initialization - we would otherwise never clean it up.
+Dst = PreVisit;
+return;
+  }
+  StmtNodeBuilder StmtBldr(PreVisit, Dst, *currBldrCtx);
+  for (ExplodedNode *Node : PreVisit) {
+ProgramStateRef State = Node->getState();
+		const auto  = std::make_pair(BTE, Node->getStackFrame());
+
+if (!State->contains(Key)) {
+  // FIXME: Currently the state might also already contain the marker due to
+  // incorrect handling of temporaries bound to default parameters; for
+  // those, we currently skip the CXXBindTemporaryExpr but rely on adding
+  // temporary destructor nodes.
+  State = State->set(Key, nullptr);
+}
+StmtBldr.generateNode(BTE, Node, State);
+  }
+}
+
 namespace {
 class CollectReachableSymbolsCallback final : public SymbolVisitor {
   InvalidatedSymbols Symbols;
@@ -1251,7 +1279,9 @@
   Bldr.takeNodes(Pred);
   ExplodedNodeSet PreVisit;
   getCheckerManager().runCheckersForPreStmt(PreVisit, Pred, S, *this);
-  getCheckerManager().runCheckersForPostStmt(Dst, PreVisit, S, *this);
+  ExplodedNodeSet Next;
+  VisitCXXBindTemporaryExpr(cast(S), PreVisit, Next);
+  getCheckerManager().runCheckersForPostStmt(Dst, Next, S, *this);
   Bldr.addNodes(Dst);
   break;
 }
@@ -2194,13 +2224,15 @@
Pred->getLocationContext(),

r325854 - Add a test to ensure we don't permit mutable access on temporaries outside the evaluation in which they were created.

2018-02-22 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Feb 22 18:03:26 2018
New Revision: 325854

URL: http://llvm.org/viewvc/llvm-project?rev=325854=rev
Log:
Add a test to ensure we don't permit mutable access on temporaries outside the 
evaluation in which they were created.

Modified:
cfe/trunk/test/SemaCXX/constant-expression-cxx1y.cpp

Modified: cfe/trunk/test/SemaCXX/constant-expression-cxx1y.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/constant-expression-cxx1y.cpp?rev=325854=325853=325854=diff
==
--- cfe/trunk/test/SemaCXX/constant-expression-cxx1y.cpp (original)
+++ cfe/trunk/test/SemaCXX/constant-expression-cxx1y.cpp Thu Feb 22 18:03:26 
2018
@@ -1028,13 +1028,14 @@ namespace Mutable {
   static_assert(k == 123, "");
 
   struct Q { A & int b = a.n; };
-  constexpr Q q = { A{456} }; // ok
+  constexpr Q q = { A{456} }; // expected-note {{temporary}}
   static_assert(q.b == 456, "");
+  static_assert(q.a.n == 456, ""); // expected-error {{constant expression}} 
expected-note {{outside the expression that created the temporary}}
 
   constexpr A a = {123};
   constexpr int m = a.n; // expected-error {{constant expression}} 
expected-note {{mutable}}
 
-  constexpr Q r = { static_cast(const_cast(a)) }; // expected-error 
{{constant expression}} expected-note@-7 {{mutable}}
+  constexpr Q r = { static_cast(const_cast(a)) }; // expected-error 
{{constant expression}} expected-note@-8 {{mutable}}
 
   struct B {
 mutable int n; // expected-note {{here}}


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


[PATCH] D43663: [NFC] Move CommentOpts checks to the call sites that depend on it.

2018-02-22 Thread David L. Jones via Phabricator via cfe-commits
dlj created this revision.
dlj added a reviewer: rsmith.
Herald added a subscriber: sanjoy.

When parsing comments, for example, for -Wdocumentation, slightly different
behaviour occurs when -fparse-all-comments is specified. However, these
differences are subtle:

1. All comments are saved during parsing, regardless of whether they are doc 
comments or not.
2. "Maybe-doc" comments, like //<, //!, etc, are saved as such, instead of 
marking them as ordinary comments. The maybe-doc type of comment is never saved 
otherwise. (Warning on these is the impetus of -Wdocumentation.)
3. All comments are treated as doc comments in ASTContext, even if they are 
ordinary.

This change moves the logic for checking CommentOptions.ParseAllComments closer
to where it has an effect. The overall logic is unchanged, but checks of the
ParseAllComments flag are now done where the effect will be clearer.


Repository:
  rC Clang

https://reviews.llvm.org/D43663

Files:
  include/clang/AST/ASTContext.h
  include/clang/AST/RawCommentList.h
  lib/AST/ASTContext.cpp
  lib/AST/RawCommentList.cpp
  lib/Sema/Sema.cpp
  lib/Serialization/ASTReader.cpp

Index: lib/Serialization/ASTReader.cpp
===
--- lib/Serialization/ASTReader.cpp
+++ lib/Serialization/ASTReader.cpp
@@ -9067,8 +9067,7 @@
 bool IsTrailingComment = Record[Idx++];
 bool IsAlmostTrailingComment = Record[Idx++];
 Comments.push_back(new (Context) RawComment(
-SR, Kind, IsTrailingComment, IsAlmostTrailingComment,
-Context.getLangOpts().CommentOpts.ParseAllComments));
+SR, Kind, IsTrailingComment, IsAlmostTrailingComment));
 break;
   }
   }
Index: lib/Sema/Sema.cpp
===
--- lib/Sema/Sema.cpp
+++ lib/Sema/Sema.cpp
@@ -1463,8 +1463,7 @@
   if (!LangOpts.RetainCommentsFromSystemHeaders &&
   SourceMgr.isInSystemHeader(Comment.getBegin()))
 return;
-  RawComment RC(SourceMgr, Comment, false,
-LangOpts.CommentOpts.ParseAllComments);
+  RawComment RC(SourceMgr, Comment, LangOpts.CommentOpts, false);
   if (RC.isAlmostTrailingComment()) {
 SourceRange MagicMarkerRange(Comment.getBegin(),
  Comment.getBegin().getLocWithOffset(3));
Index: lib/AST/RawCommentList.cpp
===
--- lib/AST/RawCommentList.cpp
+++ lib/AST/RawCommentList.cpp
@@ -107,21 +107,22 @@
 }
 
 RawComment::RawComment(const SourceManager , SourceRange SR,
-   bool Merged, bool ParseAllComments) :
+   const CommentOptions , bool Merged) :
 Range(SR), RawTextValid(false), BriefTextValid(false),
-IsAttached(false), IsTrailingComment(false), IsAlmostTrailingComment(false),
-ParseAllComments(ParseAllComments) {
+IsAttached(false), IsTrailingComment(false),
+IsAlmostTrailingComment(false) {
   // Extract raw comment text, if possible.
   if (SR.getBegin() == SR.getEnd() || getRawText(SourceMgr).empty()) {
 Kind = RCK_Invalid;
 return;
   }
 
   // Guess comment kind.
-  std::pair K = getCommentKind(RawText, ParseAllComments);
+  std::pair K =
+  getCommentKind(RawText, CommentOpts.ParseAllComments);
 
   // Guess whether an ordinary comment is trailing.
-  if (ParseAllComments && isOrdinaryKind(K.first)) {
+  if (CommentOpts.ParseAllComments && isOrdinaryKind(K.first)) {
 FileID BeginFileID;
 unsigned BeginOffset;
 std::tie(BeginFileID, BeginOffset) =
@@ -270,6 +271,7 @@
 }
 
 void RawCommentList::addComment(const RawComment ,
+const CommentOptions ,
 llvm::BumpPtrAllocator ) {
   if (RC.isInvalid())
 return;
@@ -284,7 +286,7 @@
   }
 
   // Ordinary comments are not interesting for us.
-  if (RC.isOrdinary())
+  if (RC.isOrdinary() && !CommentOpts.ParseAllComments)
 return;
 
   // If this is the first Doxygen comment, save it (because there isn't
@@ -317,8 +319,7 @@
   onlyWhitespaceBetween(SourceMgr, C1.getLocEnd(), C2.getLocStart(),
 /*MaxNewlinesAllowed=*/1)) {
 SourceRange MergedRange(C1.getLocStart(), C2.getLocEnd());
-*Comments.back() = RawComment(SourceMgr, MergedRange, true,
-  RC.isParseAllComments());
+*Comments.back() = RawComment(SourceMgr, MergedRange, CommentOpts, true);
   } else {
 Comments.push_back(new (Allocator) RawComment(RC));
   }
Index: lib/AST/ASTContext.cpp
===
--- lib/AST/ASTContext.cpp
+++ lib/AST/ASTContext.cpp
@@ -226,8 +226,7 @@
 // for is usually among the last two comments we parsed -- check them
 // first.
 RawComment CommentAtDeclLoc(
-SourceMgr, SourceRange(DeclLoc), false,
-

[PATCH] D43659: [analyzer] Don't crash when dynamic type of a concrete region is hard-set with placement new.

2018-02-22 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

> In this case, could we emit a warning? If not from CallEvent, then from where?

(1) This might result in a buffer overflow, so i home that `alpha.ArrayBound` 
may eventually catch it.
(2) It might be a good idea to make a fairly generic checker for the strict 
aliasing rule.


https://reviews.llvm.org/D43659



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


r325850 - [Darwin] Add a test to check clang produces accelerator tables.

2018-02-22 Thread Davide Italiano via cfe-commits
Author: davide
Date: Thu Feb 22 17:25:03 2018
New Revision: 325850

URL: http://llvm.org/viewvc/llvm-project?rev=325850=rev
Log:
[Darwin] Add a test to check clang produces accelerator tables.

This test was previously in lldb, and was only checking that clang
was emitting the correct section. So, it belongs here and not
in the debugger.

Added:
cfe/trunk/test/CodeGen/debug-info-section-macho.c

Added: cfe/trunk/test/CodeGen/debug-info-section-macho.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/debug-info-section-macho.c?rev=325850=auto
==
--- cfe/trunk/test/CodeGen/debug-info-section-macho.c (added)
+++ cfe/trunk/test/CodeGen/debug-info-section-macho.c Thu Feb 22 17:25:03 2018
@@ -0,0 +1,16 @@
+// Test that clang produces the __apple accelerator tables,
+// e.g., __apple_types, correctly.
+// RUN: %clang %s -target x86_64-apple-macosx10.13.0 -c -g -o %t-ex
+// RUN: llvm-objdump -section-headers %t-ex | FileCheck %s
+
+int main (int argc, char const *argv[]) { return argc; }
+
+// CHECK: __debug_str
+// CHECK-NEXT: __debug_abbrev
+// CHECK-NEXT: __debug_info
+// CHECK-NEXT: __debug_ranges
+// CHECK-NEXT: __debug_macinfo
+// CHECK-NEXT: __apple_names
+// CHECK-NEXT: __apple_objc
+// CHECK-NEXT: __apple_namespac
+// CHECK-NEXT: __apple_types


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


[PATCH] D43659: [analyzer] Don't crash when dynamic type of a concrete region is hard-set with placement new.

2018-02-22 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments.



Comment at: lib/StaticAnalyzer/Core/CallEvent.cpp:593
+// Fall back to a generic pointer cast for this-value.
+const CXXMethodDecl *StaticMD = cast(getDecl());
+const CXXRecordDecl *StaticClass = StaticMD->getParent();

george.karpenkov wrote:
> nit: auto?
Dunno, i somehow like the symmetry with the next line. "Take method decl, take 
record decl". Maybe it's just me.


https://reviews.llvm.org/D43659



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


[PATCH] D43659: [analyzer] Don't crash when dynamic type of a concrete region is hard-set with placement new.

2018-02-22 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ updated this revision to Diff 135572.
NoQ added a comment.

- Add a definitely-not-UB example (`char` buffers are special).
- Bring back an accidentally deleted blank line.


https://reviews.llvm.org/D43659

Files:
  lib/StaticAnalyzer/Core/CallEvent.cpp
  test/Analysis/new-dynamic-types.cpp


Index: test/Analysis/new-dynamic-types.cpp
===
--- /dev/null
+++ test/Analysis/new-dynamic-types.cpp
@@ -0,0 +1,28 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core -std=c++11 -verify %s
+
+// expected-no-diagnostics
+
+typedef __typeof(sizeof(int)) size_t;
+
+void *operator new(size_t size, void *ptr);
+
+struct B {
+  virtual void foo();
+};
+
+struct D : public B {
+  virtual void foo() override {}
+};
+
+void test_ub() {
+  // FIXME: Potentially warn because this code is pretty weird.
+  B b;
+  new () D;
+  b.foo(); // no-crash
+}
+
+void test_non_ub() {
+  char c[sizeof(D)]; // Should be enough storage.
+  new (c) D;
+  ((B *)c)->foo(); // no-crash
+}
Index: lib/StaticAnalyzer/Core/CallEvent.cpp
===
--- lib/StaticAnalyzer/Core/CallEvent.cpp
+++ lib/StaticAnalyzer/Core/CallEvent.cpp
@@ -587,7 +587,15 @@
   // FIXME: CallEvent maybe shouldn't be directly accessing StoreManager.
   bool Failed;
   ThisVal = StateMgr.getStoreManager().attemptDownCast(ThisVal, Ty, 
Failed);
-  assert(!Failed && "Calling an incorrectly devirtualized method");
+  if (Failed) {
+// We might have suffered some sort of placement new earlier, so
+// we're constructing in a completely unexpected storage.
+// Fall back to a generic pointer cast for this-value.
+const CXXMethodDecl *StaticMD = cast(getDecl());
+const CXXRecordDecl *StaticClass = StaticMD->getParent();
+QualType StaticTy = Ctx.getPointerType(Ctx.getRecordType(StaticClass));
+ThisVal = SVB.evalCast(ThisVal, Ty, StaticTy);
+  }
 }
 
 if (!ThisVal.isUnknown())


Index: test/Analysis/new-dynamic-types.cpp
===
--- /dev/null
+++ test/Analysis/new-dynamic-types.cpp
@@ -0,0 +1,28 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core -std=c++11 -verify %s
+
+// expected-no-diagnostics
+
+typedef __typeof(sizeof(int)) size_t;
+
+void *operator new(size_t size, void *ptr);
+
+struct B {
+  virtual void foo();
+};
+
+struct D : public B {
+  virtual void foo() override {}
+};
+
+void test_ub() {
+  // FIXME: Potentially warn because this code is pretty weird.
+  B b;
+  new () D;
+  b.foo(); // no-crash
+}
+
+void test_non_ub() {
+  char c[sizeof(D)]; // Should be enough storage.
+  new (c) D;
+  ((B *)c)->foo(); // no-crash
+}
Index: lib/StaticAnalyzer/Core/CallEvent.cpp
===
--- lib/StaticAnalyzer/Core/CallEvent.cpp
+++ lib/StaticAnalyzer/Core/CallEvent.cpp
@@ -587,7 +587,15 @@
   // FIXME: CallEvent maybe shouldn't be directly accessing StoreManager.
   bool Failed;
   ThisVal = StateMgr.getStoreManager().attemptDownCast(ThisVal, Ty, Failed);
-  assert(!Failed && "Calling an incorrectly devirtualized method");
+  if (Failed) {
+// We might have suffered some sort of placement new earlier, so
+// we're constructing in a completely unexpected storage.
+// Fall back to a generic pointer cast for this-value.
+const CXXMethodDecl *StaticMD = cast(getDecl());
+const CXXRecordDecl *StaticClass = StaticMD->getParent();
+QualType StaticTy = Ctx.getPointerType(Ctx.getRecordType(StaticClass));
+ThisVal = SVB.evalCast(ThisVal, Ty, StaticTy);
+  }
 }
 
 if (!ThisVal.isUnknown())
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D43659: [analyzer] Don't crash when dynamic type of a concrete region is hard-set with placement new.

2018-02-22 Thread George Karpenkov via Phabricator via cfe-commits
george.karpenkov accepted this revision.
george.karpenkov added a comment.
This revision is now accepted and ready to land.

LGTM, though in general I still think we should do something on 
soft-failure-modes in order to aid future debugging...

Is the failure mode in this case always a UB? In this case, could we emit a 
warning? If not from CallEvent, then from where?




Comment at: lib/StaticAnalyzer/Core/CallEvent.cpp:593
+// Fall back to a generic pointer cast for this-value.
+const CXXMethodDecl *StaticMD = cast(getDecl());
+const CXXRecordDecl *StaticClass = StaticMD->getParent();

nit: auto?


Repository:
  rC Clang

https://reviews.llvm.org/D43659



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


[PATCH] D43660: [OpenMP] Add OpenMP data sharing infrastructure using global memory

2018-02-22 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea created this revision.
gtbercea added reviewers: ABataev, carlo.bertolli, caomhin, hfinkel, Hahnfeld.
Herald added subscribers: cfe-commits, guansong, jholewinski.

This patch handles the Clang code generation phase for the OpenMP data sharing 
infrastructure.

TODO: add a more detailed description.


Repository:
  rC Clang

https://reviews.llvm.org/D43660

Files:
  lib/CodeGen/CGDecl.cpp
  lib/CodeGen/CGOpenMPRuntime.cpp
  lib/CodeGen/CGOpenMPRuntime.h
  lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
  lib/CodeGen/CGOpenMPRuntimeNVPTX.h
  lib/CodeGen/CGStmtOpenMP.cpp
  lib/CodeGen/CodeGenFunction.cpp
  test/OpenMP/nvptx_parallel_codegen.cpp

Index: test/OpenMP/nvptx_parallel_codegen.cpp
===
--- test/OpenMP/nvptx_parallel_codegen.cpp
+++ test/OpenMP/nvptx_parallel_codegen.cpp
@@ -92,20 +92,20 @@
   //
   // CHECK: [[EXEC_PARALLEL]]
   // CHECK: [[WF1:%.+]] = load i8*, i8** [[OMP_WORK_FN]],
-  // CHECK: [[WM1:%.+]] = icmp eq i8* [[WF1]], bitcast (void (i32*, i32*)* [[PARALLEL_FN1:@.+]] to i8*)
+  // CHECK: [[WM1:%.+]] = icmp eq i8* [[WF1]], bitcast (void (i16, i32)* [[PARALLEL_FN1:@.+]]_wrapper to i8*)
   // CHECK: br i1 [[WM1]], label {{%?}}[[EXEC_PFN1:.+]], label {{%?}}[[CHECK_NEXT1:.+]]
   //
   // CHECK: [[EXEC_PFN1]]
-  // CHECK: call void [[PARALLEL_FN1]](
+  // CHECK: call void [[PARALLEL_FN1]]_wrapper(
   // CHECK: br label {{%?}}[[TERM_PARALLEL:.+]]
   //
   // CHECK: [[CHECK_NEXT1]]
   // CHECK: [[WF2:%.+]] = load i8*, i8** [[OMP_WORK_FN]],
-  // CHECK: [[WM2:%.+]] = icmp eq i8* [[WF2]], bitcast (void (i32*, i32*)* [[PARALLEL_FN2:@.+]] to i8*)
+  // CHECK: [[WM2:%.+]] = icmp eq i8* [[WF2]], bitcast (void (i16, i32)* [[PARALLEL_FN2:@.+]]_wrapper to i8*)
   // CHECK: br i1 [[WM2]], label {{%?}}[[EXEC_PFN2:.+]], label {{%?}}[[CHECK_NEXT2:.+]]
   //
   // CHECK: [[EXEC_PFN2]]
-  // CHECK: call void [[PARALLEL_FN2]](
+  // CHECK: call void [[PARALLEL_FN2]]_wrapper(
   // CHECK: br label {{%?}}[[TERM_PARALLEL:.+]]
   //
   // CHECK: [[CHECK_NEXT2]]
@@ -152,13 +152,13 @@
   // CHECK-DAG: [[MWS:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.warpsize()
   // CHECK: [[MTMP1:%.+]] = sub i32 [[MNTH]], [[MWS]]
   // CHECK: call void @__kmpc_kernel_init(i32 [[MTMP1]]
-  // CHECK: call void @__kmpc_kernel_prepare_parallel(i8* bitcast (void (i32*, i32*)* [[PARALLEL_FN1]] to i8*),
+  // CHECK: call void @__kmpc_kernel_prepare_parallel(i8* bitcast (void (i16, i32)* [[PARALLEL_FN1]]_wrapper to i8*),
   // CHECK: call void @llvm.nvvm.barrier0()
   // CHECK: call void @llvm.nvvm.barrier0()
   // CHECK: call void @__kmpc_serialized_parallel(
   // CHECK: {{call|invoke}} void [[PARALLEL_FN3:@.+]](
   // CHECK: call void @__kmpc_end_serialized_parallel(
-  // CHECK: call void @__kmpc_kernel_prepare_parallel(i8* bitcast (void (i32*, i32*)* [[PARALLEL_FN2]] to i8*),
+  // CHECK: call void @__kmpc_kernel_prepare_parallel(i8* bitcast (void (i16, i32)* [[PARALLEL_FN2]]_wrapper to i8*),
   // CHECK: call void @llvm.nvvm.barrier0()
   // CHECK: call void @llvm.nvvm.barrier0()
   // CHECK-64-DAG: load i32, i32* [[REF_A]]
@@ -203,7 +203,7 @@
   //
   // CHECK: [[AWAIT_WORK]]
   // CHECK: call void @llvm.nvvm.barrier0()
-  // CHECK: [[KPR:%.+]] = call i1 @__kmpc_kernel_parallel(i8** [[OMP_WORK_FN]]
+  // CHECK: [[KPR:%.+]] = call i1 @__kmpc_kernel_parallel(i8** [[OMP_WORK_FN]],
   // CHECK: [[KPRB:%.+]] = zext i1 [[KPR]] to i8
   // store i8 [[KPRB]], i8* [[OMP_EXEC_STATUS]], align 1
   // CHECK: [[WORK:%.+]] = load i8*, i8** [[OMP_WORK_FN]],
@@ -217,11 +217,11 @@
   //
   // CHECK: [[EXEC_PARALLEL]]
   // CHECK: [[WF:%.+]] = load i8*, i8** [[OMP_WORK_FN]],
-  // CHECK: [[WM:%.+]] = icmp eq i8* [[WF]], bitcast (void (i32*, i32*)* [[PARALLEL_FN4:@.+]] to i8*)
+  // CHECK: [[WM:%.+]] = icmp eq i8* [[WF]], bitcast (void (i16, i32)* [[PARALLEL_FN4:@.+]]_wrapper to i8*)
   // CHECK: br i1 [[WM]], label {{%?}}[[EXEC_PFN:.+]], label {{%?}}[[CHECK_NEXT:.+]]
   //
   // CHECK: [[EXEC_PFN]]
-  // CHECK: call void [[PARALLEL_FN4]](
+  // CHECK: call void [[PARALLEL_FN4]]_wrapper(
   // CHECK: br label {{%?}}[[TERM_PARALLEL:.+]]
   //
   // CHECK: [[CHECK_NEXT]]
@@ -283,7 +283,7 @@
   // CHECK: br i1 [[CMP]], label {{%?}}[[IF_THEN:.+]], label {{%?}}[[IF_ELSE:.+]]
   //
   // CHECK: [[IF_THEN]]
-  // CHECK: call void @__kmpc_kernel_prepare_parallel(i8* bitcast (void (i32*, i32*)* [[PARALLEL_FN4]] to i8*),
+  // CHECK: call void @__kmpc_kernel_prepare_parallel(i8* bitcast (void (i16, i32)* [[PARALLEL_FN4]]_wrapper to i8*),
   // CHECK: call void @llvm.nvvm.barrier0()
   // CHECK: call void @llvm.nvvm.barrier0()
   // CHECK: br label {{%?}}[[IF_END:.+]]
Index: lib/CodeGen/CodeGenFunction.cpp
===
--- lib/CodeGen/CodeGenFunction.cpp
+++ lib/CodeGen/CodeGenFunction.cpp
@@ -1058,6 +1058,11 @@
   EmitStartEHSpec(CurCodeDecl);
 
   PrologueCleanupDepth = EHStack.stable_begin();
+
+  // Emit OpenMP specific initialization of the 

[PATCH] D43659: [analyzer] Don't crash when dynamic type of a concrete region is hard-set with placement new.

2018-02-22 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ created this revision.
NoQ added reviewers: dcoughlin, xazax.hun, a.sidorin, george.karpenkov, szepet.
Herald added subscribers: cfe-commits, rnkovacs.

This is assertion removal that i find valid. With placement new (which isn't 
even need to be inlined, we used to model it conservatively well enough), 
anything of any type can have any dynamic type. Even if we have a concrete 
region of a variable, its dynamic type and its static type can be completely 
unrelated. This might be UB due to strict aliasing rules, but we shouldn't 
crash. This patch introduces a relatively sane behavior in this scenario that 
consists of `evalCast()`ing this-region to the assumed dynamic type during 
virtual calls.

In the common case when the dynamic type is a sub-class of the static type, 
this is worse than calling `attemptDownCast()` because it adds element region 
instead of removing base regions (which is not incorrect but produces a 
non-canonical representation of the SVal). But when the common-case approach is 
known to have failed, there doesn't seem to be a better option.

A lot of these crashes have suddenly shown up when i was testing temporaries. 
They have nothing to do with temporaries though, but with a weird 
implementation detail of `std::function` that suddenly got some if its methods 
inlined.


Repository:
  rC Clang

https://reviews.llvm.org/D43659

Files:
  lib/StaticAnalyzer/Core/CallEvent.cpp
  test/Analysis/new-dynamic-types.cpp


Index: test/Analysis/new-dynamic-types.cpp
===
--- /dev/null
+++ test/Analysis/new-dynamic-types.cpp
@@ -0,0 +1,22 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core -std=c++11 -verify %s
+
+// expected-no-diagnostics
+
+typedef __typeof(sizeof(int)) size_t;
+
+void *operator new(size_t size, void *ptr);
+
+struct B {
+  virtual void foo();
+};
+
+struct D : public B {
+  virtual void foo() override {}
+};
+
+void test() {
+  // FIXME: Potentially warn because this code is pretty weird.
+  B b;
+  new () D;
+  b.foo(); // no-crash
+}
Index: lib/StaticAnalyzer/Core/CallEvent.cpp
===
--- lib/StaticAnalyzer/Core/CallEvent.cpp
+++ lib/StaticAnalyzer/Core/CallEvent.cpp
@@ -583,11 +583,18 @@
   ASTContext  = SVB.getContext();
   const CXXRecordDecl *Class = MD->getParent();
   QualType Ty = Ctx.getPointerType(Ctx.getRecordType(Class));
-
   // FIXME: CallEvent maybe shouldn't be directly accessing StoreManager.
   bool Failed;
   ThisVal = StateMgr.getStoreManager().attemptDownCast(ThisVal, Ty, 
Failed);
-  assert(!Failed && "Calling an incorrectly devirtualized method");
+  if (Failed) {
+// We might have suffered some sort of placement new earlier, so
+// we're constructing in a completely unexpected storage.
+// Fall back to a generic pointer cast for this-value.
+const CXXMethodDecl *StaticMD = cast(getDecl());
+const CXXRecordDecl *StaticClass = StaticMD->getParent();
+QualType StaticTy = Ctx.getPointerType(Ctx.getRecordType(StaticClass));
+ThisVal = SVB.evalCast(ThisVal, Ty, StaticTy);
+  }
 }
 
 if (!ThisVal.isUnknown())


Index: test/Analysis/new-dynamic-types.cpp
===
--- /dev/null
+++ test/Analysis/new-dynamic-types.cpp
@@ -0,0 +1,22 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core -std=c++11 -verify %s
+
+// expected-no-diagnostics
+
+typedef __typeof(sizeof(int)) size_t;
+
+void *operator new(size_t size, void *ptr);
+
+struct B {
+  virtual void foo();
+};
+
+struct D : public B {
+  virtual void foo() override {}
+};
+
+void test() {
+  // FIXME: Potentially warn because this code is pretty weird.
+  B b;
+  new () D;
+  b.foo(); // no-crash
+}
Index: lib/StaticAnalyzer/Core/CallEvent.cpp
===
--- lib/StaticAnalyzer/Core/CallEvent.cpp
+++ lib/StaticAnalyzer/Core/CallEvent.cpp
@@ -583,11 +583,18 @@
   ASTContext  = SVB.getContext();
   const CXXRecordDecl *Class = MD->getParent();
   QualType Ty = Ctx.getPointerType(Ctx.getRecordType(Class));
-
   // FIXME: CallEvent maybe shouldn't be directly accessing StoreManager.
   bool Failed;
   ThisVal = StateMgr.getStoreManager().attemptDownCast(ThisVal, Ty, Failed);
-  assert(!Failed && "Calling an incorrectly devirtualized method");
+  if (Failed) {
+// We might have suffered some sort of placement new earlier, so
+// we're constructing in a completely unexpected storage.
+// Fall back to a generic pointer cast for this-value.
+const CXXMethodDecl *StaticMD = cast(getDecl());
+const CXXRecordDecl *StaticClass = StaticMD->getParent();
+QualType StaticTy = Ctx.getPointerType(Ctx.getRecordType(StaticClass));
+ThisVal = SVB.evalCast(ThisVal, Ty, StaticTy);
+  }
 }
 

Re: [PATCH] D43514: Start settinng dso_local for COFF

2018-02-22 Thread Eric Christopher via cfe-commits
On Thu, Feb 22, 2018 at 4:40 PM Rafael Avila de Espindola via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Eric Christopher via Phabricator  writes:
>
> > echristo added inline comments.
> >
> >
> > 
> > Comment at: lib/CodeGen/CodeGenModule.h:728
> > +  /// This must be called after dllimport/dllexport is set.
> > +  /// FIXME: should this set dllimport/dllexport instead?
> >void setGVProperties(llvm::GlobalValue *GV, const NamedDecl *D) const;
> > 
> > Agreed? Maybe? Should the rest of the properties from above each call be
> set in this function?
> >
> > Since you've got the decl it might be best to get as many of them in one
> place as possible?
>
> Very likely yes.
>
> One think I have locally is a very ugly patch that sets dso_local all
> over the place in clang until every GV in coff is dso_local or
> dllimport.
>
> My idea is to cleanup it bit by bit once the initial patch (this one) is
> in.
>
> I can try moving dllimport/dllexport setting to setGVProperties as the
> first followup patch if you agree.
>
>
SGTM. I'll ack the patch.

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


[PATCH] D43657: [analyzer] dump() dynamic type info and taint into state dumps.

2018-02-22 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ created this revision.
NoQ added reviewers: dcoughlin, xazax.hun, a.sidorin, george.karpenkov, szepet.
Herald added subscribers: cfe-commits, rnkovacs.

More dumps!

Eg.:

  Dynamic types of regions:
  x : class PR13569_virtual::Child

Taint dumps were already implemented, so i added them because they seemed to 
have been accidentally left out.


Repository:
  rC Clang

https://reviews.llvm.org/D43657

Files:
  include/clang/StaticAnalyzer/Core/PathSensitive/DynamicTypeMap.h
  lib/StaticAnalyzer/Core/DynamicTypeMap.cpp
  lib/StaticAnalyzer/Core/ProgramState.cpp


Index: lib/StaticAnalyzer/Core/ProgramState.cpp
===
--- lib/StaticAnalyzer/Core/ProgramState.cpp
+++ lib/StaticAnalyzer/Core/ProgramState.cpp
@@ -17,6 +17,7 @@
 #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/SubEngine.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/TaintManager.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/DynamicTypeMap.h"
 #include "llvm/Support/raw_ostream.h"
 
 using namespace clang;
@@ -449,6 +450,12 @@
   // Print out the constraints.
   Mgr.getConstraintManager().print(this, Out, NL, Sep);
 
+  // Print out the tracked dynamic types.
+  printDynamicTypeInfo(this, Out, NL, Sep);
+
+  // Print out tainted symbols.
+  printTaint(Out, NL, Sep);
+
   // Print checker-specific data.
   Mgr.getOwningEngine()->printState(Out, this, NL, Sep, LC);
 }
@@ -466,7 +473,7 @@
   TaintMapImpl TM = get();
 
   if (!TM.isEmpty())
-Out <<"Tainted Symbols:" << NL;
+Out <<"Tainted symbols:" << NL;
 
   for (TaintMapImpl::iterator I = TM.begin(), E = TM.end(); I != E; ++I) {
 Out << I->first << " : " << I->second << NL;
Index: lib/StaticAnalyzer/Core/DynamicTypeMap.cpp
===
--- lib/StaticAnalyzer/Core/DynamicTypeMap.cpp
+++ lib/StaticAnalyzer/Core/DynamicTypeMap.cpp
@@ -47,5 +47,28 @@
   return NewState;
 }
 
+void printDynamicTypeInfo(ProgramStateRef State, raw_ostream ,
+  const char *NL, const char *Sep) {
+  bool First = true;
+  for (const auto  : State->get()) {
+if (First) {
+  Out << NL << "Dynamic types of regions:" << NL;
+  First = false;
+}
+const MemRegion *MR = I.first;
+const DynamicTypeInfo  = I.second;
+Out << MR << " : ";
+if (DTI.isValid()) {
+  Out << DTI.getType()->getPointeeType().getAsString();
+  if (DTI.canBeASubClass()) {
+Out << " (or its subclass)";
+  }
+} else {
+  Out << "Invalid type info";
+}
+Out << NL;
+  }
+}
+
 } // namespace ento
 } // namespace clang
Index: include/clang/StaticAnalyzer/Core/PathSensitive/DynamicTypeMap.h
===
--- include/clang/StaticAnalyzer/Core/PathSensitive/DynamicTypeMap.h
+++ include/clang/StaticAnalyzer/Core/PathSensitive/DynamicTypeMap.h
@@ -51,6 +51,9 @@
 DynamicTypeInfo(NewTy, CanBeSubClassed));
 }
 
+void printDynamicTypeInfo(ProgramStateRef State, raw_ostream ,
+  const char *NL, const char *Sep);
+
 } // ento
 } // clang
 


Index: lib/StaticAnalyzer/Core/ProgramState.cpp
===
--- lib/StaticAnalyzer/Core/ProgramState.cpp
+++ lib/StaticAnalyzer/Core/ProgramState.cpp
@@ -17,6 +17,7 @@
 #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/SubEngine.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/TaintManager.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/DynamicTypeMap.h"
 #include "llvm/Support/raw_ostream.h"
 
 using namespace clang;
@@ -449,6 +450,12 @@
   // Print out the constraints.
   Mgr.getConstraintManager().print(this, Out, NL, Sep);
 
+  // Print out the tracked dynamic types.
+  printDynamicTypeInfo(this, Out, NL, Sep);
+
+  // Print out tainted symbols.
+  printTaint(Out, NL, Sep);
+
   // Print checker-specific data.
   Mgr.getOwningEngine()->printState(Out, this, NL, Sep, LC);
 }
@@ -466,7 +473,7 @@
   TaintMapImpl TM = get();
 
   if (!TM.isEmpty())
-Out <<"Tainted Symbols:" << NL;
+Out <<"Tainted symbols:" << NL;
 
   for (TaintMapImpl::iterator I = TM.begin(), E = TM.end(); I != E; ++I) {
 Out << I->first << " : " << I->second << NL;
Index: lib/StaticAnalyzer/Core/DynamicTypeMap.cpp
===
--- lib/StaticAnalyzer/Core/DynamicTypeMap.cpp
+++ lib/StaticAnalyzer/Core/DynamicTypeMap.cpp
@@ -47,5 +47,28 @@
   return NewState;
 }
 
+void printDynamicTypeInfo(ProgramStateRef State, raw_ostream ,
+  const char *NL, const char *Sep) {
+  bool First = true;
+  for (const auto  : State->get()) {
+if (First) {
+  Out << NL << "Dynamic types of regions:" << NL;
+  First = false;
+}
+const 

Re: [PATCH] D43514: Start settinng dso_local for COFF

2018-02-22 Thread Rafael Avila de Espindola via cfe-commits
Eric Christopher via Phabricator  writes:

> echristo added inline comments.
>
>
> 
> Comment at: lib/CodeGen/CodeGenModule.h:728
> +  /// This must be called after dllimport/dllexport is set.
> +  /// FIXME: should this set dllimport/dllexport instead?
>void setGVProperties(llvm::GlobalValue *GV, const NamedDecl *D) const;
> 
> Agreed? Maybe? Should the rest of the properties from above each call be set 
> in this function?
>
> Since you've got the decl it might be best to get as many of them in one 
> place as possible?

Very likely yes.

One think I have locally is a very ugly patch that sets dso_local all
over the place in clang until every GV in coff is dso_local or
dllimport.

My idea is to cleanup it bit by bit once the initial patch (this one) is
in.

I can try moving dllimport/dllexport setting to setGVProperties as the
first followup patch if you agree.

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


[PATCH] D41102: Setup clang-doc frontend framework

2018-02-22 Thread Julie Hockett via Phabricator via cfe-commits
juliehockett updated this revision to Diff 135559.
juliehockett marked 10 inline comments as done.
juliehockett added a comment.

Refactoring bitcode writer


https://reviews.llvm.org/D41102

Files:
  CMakeLists.txt
  clang-doc/BitcodeWriter.cpp
  clang-doc/BitcodeWriter.h
  clang-doc/CMakeLists.txt
  clang-doc/ClangDoc.h
  clang-doc/Mapper.cpp
  clang-doc/Mapper.h
  clang-doc/Representation.h
  clang-doc/tool/CMakeLists.txt
  clang-doc/tool/ClangDocMain.cpp
  docs/clang-doc.rst
  test/CMakeLists.txt
  test/clang-doc/mapper-class.cpp
  test/clang-doc/mapper-enum.cpp
  test/clang-doc/mapper-function.cpp
  test/clang-doc/mapper-method.cpp
  test/clang-doc/mapper-namespace.cpp
  test/clang-doc/mapper-struct.cpp
  test/clang-doc/mapper-union.cpp

Index: test/clang-doc/mapper-union.cpp
===
--- /dev/null
+++ test/clang-doc/mapper-union.cpp
@@ -0,0 +1,29 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: echo "" > %t/compile_flags.txt
+// RUN: cp "%s" "%t/test.cpp"
+// RUN: clang-doc --dump --omit-filenames -doxygen -p %t %t/test.cpp -output=%t/docs
+// RUN: llvm-bcanalyzer %t/docs/c:@u...@d.bc --dump | FileCheck %s
+
+union D { int X; int Y; };
+// CHECK: 
+  // CHECK: 
+// CHECK: 
+// CHECK: 
+  // CHECK:  blob data = 'D'
+  // CHECK: 
+  // CHECK: 
+  // CHECK: 
+// CHECK:  blob data = 'int'
+// CHECK:  blob data = 'D::X'
+// CHECK: 
+  // CHECK: 
+  // CHECK: 
+// CHECK:  blob data = 'int'
+// CHECK:  blob data = 'D::Y'
+// CHECK: 
+  // CHECK: 
+// CHECK: 
+
+
+
Index: test/clang-doc/mapper-struct.cpp
===
--- /dev/null
+++ test/clang-doc/mapper-struct.cpp
@@ -0,0 +1,24 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: echo "" > %t/compile_flags.txt
+// RUN: cp "%s" "%t/test.cpp"
+// RUN: clang-doc --dump --omit-filenames -doxygen -p %t %t/test.cpp -output=%t/docs
+// RUN: llvm-bcanalyzer %t/docs/c:@s...@c.bc --dump | FileCheck %s
+
+struct C { int i; };
+// CHECK: 
+// CHECK: 
+  // CHECK: 
+// CHECK: 
+// CHECK: 
+  // CHECK:  blob data = 'C'
+  // CHECK: 
+  // CHECK: 
+// CHECK:  blob data = 'int'
+// CHECK:  blob data = 'C::i'
+// CHECK: 
+  // CHECK: 
+// CHECK: 
+
+
+
Index: test/clang-doc/mapper-namespace.cpp
===
--- /dev/null
+++ test/clang-doc/mapper-namespace.cpp
@@ -0,0 +1,17 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: echo "" > %t/compile_flags.txt
+// RUN: cp "%s" "%t/test.cpp"
+// RUN: clang-doc --dump --omit-filenames -doxygen -p %t %t/test.cpp -output=%t/docs
+// RUN: llvm-bcanalyzer %t/docs/c:@n...@a.bc --dump | FileCheck %s
+
+namespace A {}
+// CHECK: 
+// CHECK: 
+  // CHECK: 
+// CHECK: 
+// CHECK: 
+  // CHECK:  blob data = 'A'
+// CHECK: 
+
+
Index: test/clang-doc/mapper-method.cpp
===
--- /dev/null
+++ test/clang-doc/mapper-method.cpp
@@ -0,0 +1,31 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: echo "" > %t/compile_flags.txt
+// RUN: cp "%s" "%t/test.cpp"
+// RUN: clang-doc --dump --omit-filenames -doxygen -p %t %t/test.cpp -output=%t/docs
+// RUN: llvm-bcanalyzer %t/docs/c:@S@G@F@Method#I#.bc --dump | FileCheck %s
+
+class G {
+public: 
+	int Method(int param) { return param; }
+};
+// CHECK: 
+// CHECK: 
+  // CHECK: 
+// CHECK: 
+// CHECK: 
+  // CHECK:  blob data = 'Method'
+  // CHECK: 
+  // CHECK:  blob data = 'c:@S@G'
+  // CHECK: 
+// CHECK:  blob data = 'int'
+  // CHECK: 
+  // CHECK: 
+// CHECK:  blob data = 'int'
+// CHECK:  blob data = 'param'
+  // CHECK: 
+// CHECK: 
+
+
+
+
Index: test/clang-doc/mapper-function.cpp
===
--- /dev/null
+++ test/clang-doc/mapper-function.cpp
@@ -0,0 +1,25 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: echo "" > %t/compile_flags.txt
+// RUN: cp "%s" "%t/test.cpp"
+// RUN: clang-doc --dump --omit-filenames -doxygen -p %t %t/test.cpp -output=%t/docs
+// RUN: llvm-bcanalyzer %t/docs/c:@F@F#I#.bc --dump | FileCheck %s
+
+int F(int param) { return param; }
+// CHECK: 
+// CHECK: 
+  // CHECK: 
+// CHECK: 
+// CHECK: 
+  // CHECK:  blob data = 'F'
+  // CHECK: 
+  // CHECK: 
+// CHECK:  blob data = 'int'
+  // CHECK: 
+  // CHECK: 
+// CHECK:  blob data = 'int'
+// CHECK:  blob data = 'param'
+  // CHECK: 
+// CHECK: 
+
+
Index: test/clang-doc/mapper-enum.cpp
===
--- /dev/null
+++ test/clang-doc/mapper-enum.cpp
@@ -0,0 +1,26 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: echo "" > %t/compile_flags.txt
+// RUN: cp "%s" "%t/test.cpp"
+// RUN: clang-doc --dump --omit-filenames -doxygen -p %t %t/test.cpp -output=%t/docs
+// RUN: llvm-bcanalyzer %t/docs/c:@e...@b.bc --dump | FileCheck %s
+
+enum B { X, Y };
+// CHECK: 
+// CHECK: 
+  // CHECK: 
+// CHECK: 
+// CHECK: 
+  // CHECK:  blob data = 'B'
+  // 

[PATCH] D43362: Simplify setting dso_local. NFC.

2018-02-22 Thread Rafael Avila de Espindola via Phabricator via cfe-commits
espindola closed this revision.
espindola added a comment.

r325846


https://reviews.llvm.org/D43362



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


[PATCH] D43514: Start settinng dso_local for COFF

2018-02-22 Thread Eric Christopher via Phabricator via cfe-commits
echristo added inline comments.



Comment at: lib/CodeGen/CodeGenModule.h:728
+  /// This must be called after dllimport/dllexport is set.
+  /// FIXME: should this set dllimport/dllexport instead?
   void setGVProperties(llvm::GlobalValue *GV, const NamedDecl *D) const;

Agreed? Maybe? Should the rest of the properties from above each call be set in 
this function?

Since you've got the decl it might be best to get as many of them in one place 
as possible?


https://reviews.llvm.org/D43514



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


r325846 - Simplify setting dso_local. NFC.

2018-02-22 Thread Rafael Espindola via cfe-commits
Author: rafael
Date: Thu Feb 22 16:22:15 2018
New Revision: 325846

URL: http://llvm.org/viewvc/llvm-project?rev=325846=rev
Log:
Simplify setting dso_local. NFC.

The value of dso_local can be computed from just IR properties and
global information (object file type, command line options, etc).

With this patch we no longer pass in the Decl. It was almost unused
and making it fully unused guarantees that dso_local is consistent
with the rest of the IR.

Modified:
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.h
cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=325846=325845=325846=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Thu Feb 22 16:22:15 2018
@@ -712,7 +712,7 @@ void CodeGenModule::setGlobalVisibility(
 }
 
 static bool shouldAssumeDSOLocal(const CodeGenModule ,
- llvm::GlobalValue *GV, const NamedDecl *D) {
+ llvm::GlobalValue *GV) {
   const llvm::Triple  = CGM.getTriple();
   // Only handle ELF for now.
   if (!TT.isOSBinFormatELF())
@@ -742,31 +742,30 @@ static bool shouldAssumeDSOLocal(const C
 return false;
 
   // If we can use copy relocations we can assume it is local.
-  if (auto *VD = dyn_cast(D))
-if (VD->getTLSKind() == VarDecl::TLS_None &&
+  if (auto *Var = dyn_cast(GV))
+if (!Var->isThreadLocal() &&
 (RM == llvm::Reloc::Static || CGOpts.PIECopyRelocations))
   return true;
 
   // If we can use a plt entry as the symbol address we can assume it
   // is local.
   // FIXME: This should work for PIE, but the gold linker doesn't support it.
-  if (isa(D) && !CGOpts.NoPLT && RM == llvm::Reloc::Static)
+  if (isa(GV) && !CGOpts.NoPLT && RM == llvm::Reloc::Static)
 return true;
 
   // Otherwise don't assue it is local.
   return false;
 }
 
-void CodeGenModule::setDSOLocal(llvm::GlobalValue *GV,
-const NamedDecl *D) const {
-  if (shouldAssumeDSOLocal(*this, GV, D))
+void CodeGenModule::setDSOLocal(llvm::GlobalValue *GV) const {
+  if (shouldAssumeDSOLocal(*this, GV))
 GV->setDSOLocal(true);
 }
 
 void CodeGenModule::setGVProperties(llvm::GlobalValue *GV,
 const NamedDecl *D) const {
   setGlobalVisibility(GV, D);
-  setDSOLocal(GV, D);
+  setDSOLocal(GV);
 }
 
 static llvm::GlobalVariable::ThreadLocalMode GetLLVMTLSModel(StringRef S) {
@@ -2749,7 +2748,6 @@ CodeGenModule::GetOrCreateLLVMGlobal(Str
 GV->setAlignment(getContext().getDeclAlign(D).getQuantity());
 
 setLinkageForGV(GV, D);
-setGVProperties(GV, D);
 
 if (D->getTLSKind()) {
   if (D->getTLSKind() == VarDecl::TLS_Dynamic)
@@ -2757,6 +2755,8 @@ CodeGenModule::GetOrCreateLLVMGlobal(Str
   setTLSMode(GV, *D);
 }
 
+setGVProperties(GV, D);
+
 // If required by the ABI, treat declarations of static data members with
 // inline initializers as definitions.
 if (getContext().isMSStaticDataMemberInlineDefinition(D)) {

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.h?rev=325846=325845=325846=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.h Thu Feb 22 16:22:15 2018
@@ -721,7 +721,7 @@ public:
   /// Set the visibility for the given LLVM GlobalValue.
   void setGlobalVisibility(llvm::GlobalValue *GV, const NamedDecl *D) const;
 
-  void setDSOLocal(llvm::GlobalValue *GV, const NamedDecl *D) const;
+  void setDSOLocal(llvm::GlobalValue *GV) const;
 
   void setGVProperties(llvm::GlobalValue *GV, const NamedDecl *D) const;
 

Modified: cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp?rev=325846=325845=325846=diff
==
--- cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp (original)
+++ cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp Thu Feb 22 16:22:15 2018
@@ -3214,10 +3214,10 @@ llvm::Constant *ItaniumRTTIBuilder::Buil
 llvmVisibility = CodeGenModule::GetLLVMVisibility(Ty->getVisibility());
 
   TypeName->setVisibility(llvmVisibility);
-  CGM.setDSOLocal(TypeName, Ty->getAsCXXRecordDecl());
+  CGM.setDSOLocal(TypeName);
 
   GV->setVisibility(llvmVisibility);
-  CGM.setDSOLocal(GV, Ty->getAsCXXRecordDecl());
+  CGM.setDSOLocal(GV);
 
   if (CGM.getTriple().isWindowsItaniumEnvironment()) {
 auto RD = Ty->getAsCXXRecordDecl();


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


[PATCH] D43105: [RISCV] Enable __int128_t and __uint128_t through clang flag

2018-02-22 Thread Mandeep Singh Grang via Phabricator via cfe-commits
mgrang updated this revision to Diff 135553.

Repository:
  rC Clang

https://reviews.llvm.org/D43105

Files:
  include/clang/Basic/TargetInfo.h
  include/clang/Basic/TargetOptions.h
  include/clang/Driver/Options.td
  lib/Basic/Targets/Mips.h
  lib/Driver/ToolChains/Clang.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGen/riscv32-abi.c
  test/Driver/types.c
  test/Preprocessor/init.c

Index: test/Preprocessor/init.c
===
--- test/Preprocessor/init.c
+++ test/Preprocessor/init.c
@@ -10007,6 +10007,9 @@
 // RUN:   | FileCheck -match-full-lines -check-prefix=RISCV32 %s
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=riscv32-unknown-linux < /dev/null \
 // RUN:   | FileCheck -match-full-lines -check-prefixes=RISCV32,RISCV32-LINUX %s
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=riscv32 \
+// RUN: -fforce-enable-int128 < /dev/null | FileCheck -match-full-lines \
+// RUN: -check-prefixes=RISCV32,RISCV32-INT128 %s
 // RISCV32: #define _ILP32 1
 // RISCV32: #define __ATOMIC_ACQUIRE 2
 // RISCV32: #define __ATOMIC_ACQ_REL 4
@@ -10136,6 +10139,7 @@
 // RISCV32: #define __SIG_ATOMIC_WIDTH__ 32
 // RISCV32: #define __SIZEOF_DOUBLE__ 8
 // RISCV32: #define __SIZEOF_FLOAT__ 4
+// RISCV32-INT128: #define __SIZEOF_INT128__ 16
 // RISCV32: #define __SIZEOF_INT__ 4
 // RISCV32: #define __SIZEOF_LONG_DOUBLE__ 16
 // RISCV32: #define __SIZEOF_LONG_LONG__ 8
Index: test/Driver/types.c
===
--- /dev/null
+++ test/Driver/types.c
@@ -0,0 +1,18 @@
+// Check whether __int128_t and __uint128_t are supported.
+
+// RUN: not %clang -c --target=riscv32-unknown-linux-gnu -fsyntax-only %s \
+// RUN: 2>&1 | FileCheck %s
+
+// RUN: %clang -c --target=riscv32-unknown-linux-gnu -fsyntax-only %s \
+// RUN: -fno-force-enable-int128 -fforce-enable-int128
+
+// RUN: not %clang -c --target=riscv32-unknown-linux-gnu -fsyntax-only %s \
+// RUN: -fforce-enable-int128 -fno-force-enable-int128
+
+void a() {
+  __int128_t s;
+  __uint128_t t;
+}
+
+// CHECK: error: use of undeclared identifier '__int128_t'
+// CHECK: error: use of undeclared identifier '__uint128_t'
Index: test/CodeGen/riscv32-abi.c
===
--- test/CodeGen/riscv32-abi.c
+++ test/CodeGen/riscv32-abi.c
@@ -1,4 +1,6 @@
 // RUN: %clang_cc1 -triple riscv32 -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -triple riscv32 -emit-llvm -fforce-enable-int128 %s -o - \
+// RUN: | FileCheck %s -check-prefixes=CHECK,CHECK-FORCEINT128
 
 #include 
 #include 
@@ -24,6 +26,11 @@
 // CHECK-LABEL: define i64 @f_scalar_4(i64 %x)
 int64_t f_scalar_4(int64_t x) { return x; }
 
+#ifdef __SIZEOF_INT128__
+// CHECK-FORCEINT128-LABEL: define i128 @f_scalar_5(i128 %x)
+__int128_t f_scalar_5(__int128_t x) { return x; }
+#endif
+
 // CHECK-LABEL: define float @f_fp_scalar_1(float %x)
 float f_fp_scalar_1(float x) { return x; }
 
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -2765,6 +2765,7 @@
   if (Opts.Triple.empty())
 Opts.Triple = llvm::sys::getDefaultTargetTriple();
   Opts.OpenCLExtensionsAsWritten = Args.getAllArgValues(OPT_cl_ext_EQ);
+  Opts.ForceEnableInt128 = Args.hasArg(OPT_fforce_enable_int128);
 }
 
 bool CompilerInvocation::CreateFromArgs(CompilerInvocation ,
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -4725,6 +4725,12 @@
 }
   }
 
+  if (Arg *A = Args.getLastArg(options::OPT_fforce_enable_int128,
+   options::OPT_fno_force_enable_int128)) {
+if (A->getOption().matches(options::OPT_fforce_enable_int128))
+  CmdArgs.push_back("-fforce-enable-int128");
+  }
+
   // Finally add the compile command to the compilation.
   if (Args.hasArg(options::OPT__SLASH_fallback) &&
   Output.getType() == types::TY_Object &&
Index: lib/Basic/Targets/Mips.h
===
--- lib/Basic/Targets/Mips.h
+++ lib/Basic/Targets/Mips.h
@@ -387,7 +387,9 @@
 return llvm::makeArrayRef(NewABIRegAliases);
   }
 
-  bool hasInt128Type() const override { return ABI == "n32" || ABI == "n64"; }
+  bool hasInt128Type() const override {
+return (ABI == "n32" || ABI == "n64") || getTargetOpts().ForceEnableInt128;
+  }
 
   bool validateTarget(DiagnosticsEngine ) const override;
 };
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -839,6 +839,12 @@
 def fjump_tables : Flag<["-"], "fjump-tables">, Group;
 def fno_jump_tables : Flag<["-"], "fno-jump-tables">, Group, Flags<[CC1Option]>,
   HelpText<"Do not use jump tables 

[PATCH] D43514: Start settinng dso_local for COFF

2018-02-22 Thread Rafael Avila de Espindola via Phabricator via cfe-commits
espindola updated this revision to Diff 135547.
espindola added a comment.

Address review comments.


https://reviews.llvm.org/D43514

Files:
  lib/CodeGen/CGDecl.cpp
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/CodeGenModule.h
  lib/CodeGen/ItaniumCXXABI.cpp
  test/CodeGen/aarch64-varargs-ms.c
  test/CodeGen/attr-x86-interrupt.c
  test/CodeGen/blocks-windows.c
  test/CodeGen/builtins-ms.c
  test/CodeGen/builtins-overflow.c
  test/CodeGen/c-strings.c
  test/CodeGen/cfi-icall-cross-dso.c
  test/CodeGen/cfi-icall.c
  test/CodeGen/cfstring-windows.c
  test/CodeGen/dllexport.c
  test/CodeGen/dllimport.c
  test/CodeGen/dso-local-executable.c
  test/CodeGen/exceptions-seh-finally.c
  test/CodeGen/exceptions-seh-leave.c
  test/CodeGen/exceptions-seh.c
  test/CodeGen/inline.c
  test/CodeGen/mangle-ms.c
  test/CodeGen/mangle-windows-rtd.c
  test/CodeGen/mangle-windows.c
  test/CodeGen/microsoft-call-conv-x64.c
  test/CodeGen/mingw-long-double.c
  test/CodeGen/ms-align-tentative.c
  test/CodeGen/ms-annotation.c
  test/CodeGen/ms-barriers-intrinsics.c
  test/CodeGen/ms-declspecs.c
  test/CodeGen/ms-declspecs.cpp
  test/CodeGen/ms-inline-asm-align.c
  test/CodeGen/ms-inline-asm-avx512.c
  test/CodeGen/ms-intrinsics.c
  test/CodeGen/ms-setjmp.c
  test/CodeGen/ms-x86-intrinsics.c
  test/CodeGen/ms_abi.c
  test/CodeGen/ms_abi_aarch64.c
  test/CodeGen/ms_this.cpp
  test/CodeGen/preserve-call-conv.c
  test/CodeGen/regcall.c
  test/CodeGen/variadic-null-win64.c
  test/CodeGen/vectorcall.c
  test/CodeGen/windows-itanium.c
  test/CodeGen/windows-on-arm-dllimport-dllexport.c
  test/CodeGen/windows-struct-abi.c
  test/CodeGen/windows-swiftcall.c
  test/CodeGen/x86_32-arguments-win32.c
  test/CodeGen/x86_32-fpcc-struct-return.c
  test/CodeGen/x86_64-arguments-win32.c
  test/CodeGenCXX/PR19955.cpp
  test/CodeGenCXX/atomic-dllexport.cpp
  test/CodeGenCXX/attr-x86-interrupt.cpp
  test/CodeGenCXX/constructor-destructor-return-this.cpp
  test/CodeGenCXX/dllexport-alias.cpp
  test/CodeGenCXX/dllexport-ctor-closure.cpp
  test/CodeGenCXX/dllexport-dtor-thunks.cpp
  test/CodeGenCXX/dllexport-members.cpp
  test/CodeGenCXX/dllexport-ms-friend.cpp
  test/CodeGenCXX/dllexport-pr26549.cpp
  test/CodeGenCXX/dllexport-vtable-thunks.cpp
  test/CodeGenCXX/dllexport.cpp
  test/CodeGenCXX/dllimport-dtor-thunks.cpp
  test/CodeGenCXX/dllimport-members.cpp
  test/CodeGenCXX/dllimport-memptr-global.cpp
  test/CodeGenCXX/dllimport-rtti.cpp
  test/CodeGenCXX/dllimport.cpp
  test/CodeGenCXX/exceptions-cxx-ehsc.cpp
  test/CodeGenCXX/exceptions-cxx-new.cpp
  test/CodeGenCXX/exceptions-seh-filter-captures.cpp
  test/CodeGenCXX/exceptions-seh.cpp
  test/CodeGenCXX/explicit-instantiation.cpp
  test/CodeGenCXX/homogeneous-aggregates.cpp
  test/CodeGenCXX/initializer-list-ctor-order.cpp
  test/CodeGenCXX/inline-dllexport-member.cpp
  test/CodeGenCXX/inline-functions.cpp
  test/CodeGenCXX/mangle-ms-cxx11.cpp
  test/CodeGenCXX/mangle-ms-md5.cpp
  test/CodeGenCXX/mangle-ms-templates-memptrs-2.cpp
  test/CodeGenCXX/mangle-ms-vector-types.cpp
  test/CodeGenCXX/mangle-ms.cpp
  test/CodeGenCXX/mangle-windows.cpp
  test/CodeGenCXX/member-function-pointer-calls.cpp
  test/CodeGenCXX/microsoft-abi-arg-order.cpp
  test/CodeGenCXX/microsoft-abi-array-cookies.cpp
  test/CodeGenCXX/microsoft-abi-byval-sret.cpp
  test/CodeGenCXX/microsoft-abi-byval-thunks.cpp
  test/CodeGenCXX/microsoft-abi-byval-vararg.cpp
  test/CodeGenCXX/microsoft-abi-cdecl-method-sret.cpp
  test/CodeGenCXX/microsoft-abi-constexpr-vs-inheritance.cpp
  test/CodeGenCXX/microsoft-abi-default-cc.cpp
  test/CodeGenCXX/microsoft-abi-dynamic-cast.cpp
  test/CodeGenCXX/microsoft-abi-eh-catch.cpp
  test/CodeGenCXX/microsoft-abi-eh-cleanups.cpp
  test/CodeGenCXX/microsoft-abi-eh-inlineasm.cpp
  test/CodeGenCXX/microsoft-abi-eh-terminate.cpp
  test/CodeGenCXX/microsoft-abi-extern-template.cpp
  test/CodeGenCXX/microsoft-abi-member-pointers.cpp
  test/CodeGenCXX/microsoft-abi-methods.cpp
  test/CodeGenCXX/microsoft-abi-multiple-nonvirtual-inheritance.cpp
  test/CodeGenCXX/microsoft-abi-sret-and-byval.cpp
  test/CodeGenCXX/microsoft-abi-static-initializers.cpp
  test/CodeGenCXX/microsoft-abi-structors-alias.cpp
  test/CodeGenCXX/microsoft-abi-structors.cpp
  test/CodeGenCXX/microsoft-abi-thread-safe-statics.cpp
  test/CodeGenCXX/microsoft-abi-thunks.cpp
  test/CodeGenCXX/microsoft-abi-try-throw.cpp
  test/CodeGenCXX/microsoft-abi-typeid.cpp
  test/CodeGenCXX/microsoft-abi-virtual-inheritance-vtordisps.cpp
  test/CodeGenCXX/microsoft-abi-virtual-inheritance.cpp
  test/CodeGenCXX/microsoft-abi-virtual-member-pointers.cpp
  test/CodeGenCXX/microsoft-abi-vmemptr-conflicts.cpp
  test/CodeGenCXX/microsoft-abi-vmemptr-vbase.cpp
  
test/CodeGenCXX/microsoft-abi-vtables-multiple-nonvirtual-inheritance-this-adjustment.cpp
  test/CodeGenCXX/microsoft-abi-vtables-virtual-inheritance.cpp
  test/CodeGenCXX/microsoft-compatibility.cpp
  test/CodeGenCXX/microsoft-inaccessible-base.cpp
  test/CodeGenCXX/microsoft-interface.cpp
  

[PATCH] D43105: [RISCV] Enable __int128_t and __uint128_t through clang flag

2018-02-22 Thread Alex Bradbury via Phabricator via cfe-commits
asb added inline comments.



Comment at: test/CodeGen/riscv32-abi.c:2-3
 // RUN: %clang_cc1 -triple riscv32 -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -triple riscv32 -emit-llvm -fforce-enable-int128 %s -o - \
+// RUN: | FileCheck %s -check-prefix=CHECK-FORCEINT128
 

Nit: this is slightly different to what I suggested. 
`-check-prefixes=CHECK,CHECK-FORCEINT128` would mean that all the other 
lowerings are rechecked with -fforce-eanble-int128 and are seen to remain 
unchanged.


Repository:
  rC Clang

https://reviews.llvm.org/D43105



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


[PATCH] D43650: [ARM] Add ARMv8.2-A FP16 vector intrinsics

2018-02-22 Thread Abderrazek Zaafrani via Phabricator via cfe-commits
az created this revision.
az added a reviewer: SjoerdMeijer.
Herald added subscribers: kristof.beyls, javed.absar.

This patch adds the fp16 neon vector intrinsic for ARM as described in the ARM 
ACLE document.

While this patch may seem large at first but it is essentially a 
modification/addition on top of  some old work by doing this:

- Port AArch64 patch https://reviews.llvm.org/D32511 to ARM.
- Enable the frontend fp16 data type for ARM (which is a revert of patch  
https://reviews.llvm.org/D41360).


https://reviews.llvm.org/D43650

Files:
  clang/include/clang/Basic/arm_neon.td
  clang/lib/Basic/Targets/ARM.cpp
  clang/lib/Basic/Targets/ARM.h
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/test/CodeGen/arm-v8.2a-neon-intrinsics.c
  clang/test/CodeGen/arm_neon_intrinsics.c

Index: clang/test/CodeGen/arm_neon_intrinsics.c
===
--- clang/test/CodeGen/arm_neon_intrinsics.c
+++ clang/test/CodeGen/arm_neon_intrinsics.c
@@ -3896,9 +3896,8 @@
 
 // CHECK-LABEL: @test_vld1q_f16(
 // CHECK:   [[TMP0:%.*]] = bitcast half* %a to i8*
-// CHECK:   [[VLD1:%.*]] = call <8 x i16> @llvm.arm.neon.vld1.v8i16.p0i8(i8* [[TMP0]], i32 2)
-// CHECK:   [[TMP1:%.*]] = bitcast <8 x i16> [[VLD1]] to <8 x half>
-// CHECK:   ret <8 x half> [[TMP1]]
+// CHECK:   [[VLD1:%.*]] = call <8 x half> @llvm.arm.neon.vld1.v8f16.p0i8(i8* [[TMP0]], i32 2)
+// CHECK:   ret <8 x half> [[VLD1]]
 float16x8_t test_vld1q_f16(float16_t const * a) {
   return vld1q_f16(a);
 }
@@ -3990,9 +3989,8 @@
 
 // CHECK-LABEL: @test_vld1_f16(
 // CHECK:   [[TMP0:%.*]] = bitcast half* %a to i8*
-// CHECK:   [[VLD1:%.*]] = call <4 x i16> @llvm.arm.neon.vld1.v4i16.p0i8(i8* [[TMP0]], i32 2)
-// CHECK:   [[TMP1:%.*]] = bitcast <4 x i16> [[VLD1]] to <4 x half>
-// CHECK:   ret <4 x half> [[TMP1]]
+// CHECK:   [[VLD1:%.*]] = call <4 x half> @llvm.arm.neon.vld1.v4f16.p0i8(i8* [[TMP0]], i32 2)
+// CHECK:   ret <4 x half> [[VLD1]]
 float16x4_t test_vld1_f16(float16_t const * a) {
   return vld1_f16(a);
 }
@@ -4106,12 +4104,11 @@
 
 // CHECK-LABEL: @test_vld1q_dup_f16(
 // CHECK:   [[TMP0:%.*]] = bitcast half* %a to i8*
-// CHECK:   [[TMP1:%.*]] = bitcast i8* [[TMP0]] to i16*
-// CHECK:   [[TMP2:%.*]] = load i16, i16* [[TMP1]], align 2
-// CHECK:   [[TMP3:%.*]] = insertelement <8 x i16> undef, i16 [[TMP2]], i32 0
-// CHECK:   [[LANE:%.*]] = shufflevector <8 x i16> [[TMP3]], <8 x i16> [[TMP3]], <8 x i32> zeroinitializer
-// CHECK:   [[TMP4:%.*]] = bitcast <8 x i16> [[LANE]] to <8 x half>
-// CHECK:   ret <8 x half> [[TMP4]]
+// CHECK:   [[TMP1:%.*]] = bitcast i8* [[TMP0]] to half*
+// CHECK:   [[TMP2:%.*]] = load half, half* [[TMP1]], align 2
+// CHECK:   [[TMP3:%.*]] = insertelement <8 x half> undef, half [[TMP2]], i32 0
+// CHECK:   [[LANE:%.*]] = shufflevector <8 x half> [[TMP3]], <8 x half> [[TMP3]], <8 x i32> zeroinitializer
+// CHECK:   ret <8 x half> [[LANE]]
 float16x8_t test_vld1q_dup_f16(float16_t const * a) {
   return vld1q_dup_f16(a);
 }
@@ -4233,12 +4230,11 @@
 
 // CHECK-LABEL: @test_vld1_dup_f16(
 // CHECK:   [[TMP0:%.*]] = bitcast half* %a to i8*
-// CHECK:   [[TMP1:%.*]] = bitcast i8* [[TMP0]] to i16*
-// CHECK:   [[TMP2:%.*]] = load i16, i16* [[TMP1]], align 2
-// CHECK:   [[TMP3:%.*]] = insertelement <4 x i16> undef, i16 [[TMP2]], i32 0
-// CHECK:   [[LANE:%.*]] = shufflevector <4 x i16> [[TMP3]], <4 x i16> [[TMP3]], <4 x i32> zeroinitializer
-// CHECK:   [[TMP4:%.*]] = bitcast <4 x i16> [[LANE]] to <4 x half>
-// CHECK:   ret <4 x half> [[TMP4]]
+// CHECK:   [[TMP1:%.*]] = bitcast i8* [[TMP0]] to half*
+// CHECK:   [[TMP2:%.*]] = load half, half* [[TMP1]], align 2
+// CHECK:   [[TMP3:%.*]] = insertelement <4 x half> undef, half [[TMP2]], i32 0
+// CHECK:   [[LANE:%.*]] = shufflevector <4 x half> [[TMP3]], <4 x half> [[TMP3]], <4 x i32> zeroinitializer
+// CHECK:   ret <4 x half> [[LANE]]
 float16x4_t test_vld1_dup_f16(float16_t const * a) {
   return vld1_dup_f16(a);
 }
@@ -4365,12 +4361,11 @@
 // CHECK-LABEL: @test_vld1q_lane_f16(
 // CHECK:   [[TMP0:%.*]] = bitcast half* %a to i8*
 // CHECK:   [[TMP1:%.*]] = bitcast <8 x half> %b to <16 x i8>
-// CHECK:   [[TMP2:%.*]] = bitcast <16 x i8> [[TMP1]] to <8 x i16>
-// CHECK:   [[TMP3:%.*]] = bitcast i8* [[TMP0]] to i16*
-// CHECK:   [[TMP4:%.*]] = load i16, i16* [[TMP3]], align 2
-// CHECK:   [[VLD1_LANE:%.*]] = insertelement <8 x i16> [[TMP2]], i16 [[TMP4]], i32 7
-// CHECK:   [[TMP5:%.*]] = bitcast <8 x i16> [[VLD1_LANE]] to <8 x half>
-// CHECK:   ret <8 x half> [[TMP5]]
+// CHECK:   [[TMP2:%.*]] = bitcast <16 x i8> [[TMP1]] to <8 x half>
+// CHECK:   [[TMP3:%.*]] = bitcast i8* [[TMP0]] to half*
+// CHECK:   [[TMP4:%.*]] = load half, half* [[TMP3]], align 2
+// CHECK:   [[VLD1_LANE:%.*]] = insertelement <8 x half> [[TMP2]], half [[TMP4]], i32 7
+// CHECK:   ret <8 x half> [[VLD1_LANE]]
 float16x8_t test_vld1q_lane_f16(float16_t const * a, float16x8_t b) {
   return vld1q_lane_f16(a, b, 7);
 }
@@ -4498,12 

[PATCH] D43105: [RISCV] Enable __int128_t and __uint128_t through clang flag

2018-02-22 Thread Mandeep Singh Grang via Phabricator via cfe-commits
mgrang updated this revision to Diff 135540.
mgrang added a comment.

Thanks @asb. I have addressed your comments.


Repository:
  rC Clang

https://reviews.llvm.org/D43105

Files:
  include/clang/Basic/TargetInfo.h
  include/clang/Basic/TargetOptions.h
  include/clang/Driver/Options.td
  lib/Basic/Targets/Mips.h
  lib/Driver/ToolChains/Clang.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGen/riscv32-abi.c
  test/Driver/types.c
  test/Preprocessor/init.c

Index: test/Preprocessor/init.c
===
--- test/Preprocessor/init.c
+++ test/Preprocessor/init.c
@@ -10007,6 +10007,9 @@
 // RUN:   | FileCheck -match-full-lines -check-prefix=RISCV32 %s
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=riscv32-unknown-linux < /dev/null \
 // RUN:   | FileCheck -match-full-lines -check-prefixes=RISCV32,RISCV32-LINUX %s
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=riscv32 \
+// RUN: -fforce-enable-int128 < /dev/null | FileCheck -match-full-lines \
+// RUN: -check-prefixes=RISCV32,RISCV32-INT128 %s
 // RISCV32: #define _ILP32 1
 // RISCV32: #define __ATOMIC_ACQUIRE 2
 // RISCV32: #define __ATOMIC_ACQ_REL 4
@@ -10136,6 +10139,7 @@
 // RISCV32: #define __SIG_ATOMIC_WIDTH__ 32
 // RISCV32: #define __SIZEOF_DOUBLE__ 8
 // RISCV32: #define __SIZEOF_FLOAT__ 4
+// RISCV32-INT128: #define __SIZEOF_INT128__ 16
 // RISCV32: #define __SIZEOF_INT__ 4
 // RISCV32: #define __SIZEOF_LONG_DOUBLE__ 16
 // RISCV32: #define __SIZEOF_LONG_LONG__ 8
Index: test/Driver/types.c
===
--- /dev/null
+++ test/Driver/types.c
@@ -0,0 +1,18 @@
+// Check whether __int128_t and __uint128_t are supported.
+
+// RUN: not %clang -c --target=riscv32-unknown-linux-gnu -fsyntax-only %s \
+// RUN: 2>&1 | FileCheck %s
+
+// RUN: %clang -c --target=riscv32-unknown-linux-gnu -fsyntax-only %s \
+// RUN: -fno-force-enable-int128 -fforce-enable-int128
+
+// RUN: not %clang -c --target=riscv32-unknown-linux-gnu -fsyntax-only %s \
+// RUN: -fforce-enable-int128 -fno-force-enable-int128
+
+void a() {
+  __int128_t s;
+  __uint128_t t;
+}
+
+// CHECK: error: use of undeclared identifier '__int128_t'
+// CHECK: error: use of undeclared identifier '__uint128_t'
Index: test/CodeGen/riscv32-abi.c
===
--- test/CodeGen/riscv32-abi.c
+++ test/CodeGen/riscv32-abi.c
@@ -1,4 +1,6 @@
 // RUN: %clang_cc1 -triple riscv32 -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -triple riscv32 -emit-llvm -fforce-enable-int128 %s -o - \
+// RUN: | FileCheck %s -check-prefix=CHECK-FORCEINT128
 
 #include 
 #include 
@@ -24,6 +26,11 @@
 // CHECK-LABEL: define i64 @f_scalar_4(i64 %x)
 int64_t f_scalar_4(int64_t x) { return x; }
 
+#ifdef __SIZEOF_INT128__
+// CHECK-FORCEINT128-LABEL: define i128 @f_scalar_5(i128 %x)
+__int128_t f_scalar_5(__int128_t x) { return x; }
+#endif
+
 // CHECK-LABEL: define float @f_fp_scalar_1(float %x)
 float f_fp_scalar_1(float x) { return x; }
 
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -2765,6 +2765,7 @@
   if (Opts.Triple.empty())
 Opts.Triple = llvm::sys::getDefaultTargetTriple();
   Opts.OpenCLExtensionsAsWritten = Args.getAllArgValues(OPT_cl_ext_EQ);
+  Opts.ForceEnableInt128 = Args.hasArg(OPT_fforce_enable_int128);
 }
 
 bool CompilerInvocation::CreateFromArgs(CompilerInvocation ,
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -4725,6 +4725,12 @@
 }
   }
 
+  if (Arg *A = Args.getLastArg(options::OPT_fforce_enable_int128,
+   options::OPT_fno_force_enable_int128)) {
+if (A->getOption().matches(options::OPT_fforce_enable_int128))
+  CmdArgs.push_back("-fforce-enable-int128");
+  }
+
   // Finally add the compile command to the compilation.
   if (Args.hasArg(options::OPT__SLASH_fallback) &&
   Output.getType() == types::TY_Object &&
Index: lib/Basic/Targets/Mips.h
===
--- lib/Basic/Targets/Mips.h
+++ lib/Basic/Targets/Mips.h
@@ -387,7 +387,9 @@
 return llvm::makeArrayRef(NewABIRegAliases);
   }
 
-  bool hasInt128Type() const override { return ABI == "n32" || ABI == "n64"; }
+  bool hasInt128Type() const override {
+return (ABI == "n32" || ABI == "n64") || getTargetOpts().ForceEnableInt128;
+  }
 
   bool validateTarget(DiagnosticsEngine ) const override;
 };
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -839,6 +839,12 @@
 def fjump_tables : Flag<["-"], "fjump-tables">, Group;
 def fno_jump_tables : Flag<["-"], "fno-jump-tables">, 

[PATCH] D43648: [clangd] Debounce streams of updates.

2018-02-22 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added reviewers: hokein, ilya-biryukov.
Herald added subscribers: cfe-commits, ioeric, jkorous-apple, klimek.

Don't actually start building ASTs for new revisions until either:

- 500ms have passed since the last revision, or
- we actually need the revision for something (or to unblock the queue)

In practice, this avoids the "first keystroke results in diagnostics" problem.
This is kind of awkward to test, and the test is pretty bad.
It can be observed nicely by capturing a trace, though.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D43648

Files:
  clangd/TUScheduler.cpp
  clangd/TUScheduler.h
  unittests/clangd/TUSchedulerTests.cpp

Index: unittests/clangd/TUSchedulerTests.cpp
===
--- unittests/clangd/TUSchedulerTests.cpp
+++ unittests/clangd/TUSchedulerTests.cpp
@@ -118,6 +118,28 @@
   EXPECT_EQ(2, CallbackCount);
 }
 
+TEST_F(TUSchedulerTests, Debounce) {
+  std::atomic CallbackCount(0);
+  {
+TUScheduler S(getDefaultAsyncThreadsCount(),
+  /*StorePreamblesInMemory=*/true,
+  /*ASTParsedCallback=*/nullptr,
+  /*UpdateDebounce=*/std::chrono::milliseconds(50));
+auto Path = testPath("foo.cpp");
+S.update(Path, getInputs(Path, "auto (debounced)"), WantDiagnostics::Auto,
+ [&](std::vector Diags) {
+   ADD_FAILURE() << "auto should have been debounced and canceled";
+ });
+std::this_thread::sleep_for(std::chrono::milliseconds(10));
+S.update(Path, getInputs(Path, "auto (timed out)"), WantDiagnostics::Auto,
+ [&](std::vector Diags) { ++CallbackCount; });
+std::this_thread::sleep_for(std::chrono::milliseconds(60));
+S.update(Path, getInputs(Path, "auto (shut down)"), WantDiagnostics::Auto,
+ [&](std::vector Diags) { ++CallbackCount; });
+  }
+  EXPECT_EQ(2, CallbackCount);
+}
+
 TEST_F(TUSchedulerTests, ManyUpdates) {
   const int FilesCount = 3;
   const int UpdatesPerFile = 10;
Index: clangd/TUScheduler.h
===
--- clangd/TUScheduler.h
+++ clangd/TUScheduler.h
@@ -17,6 +17,7 @@
 
 namespace clang {
 namespace clangd {
+
 /// Returns a number of a default async threads to use for TUScheduler.
 /// Returned value is always >= 1 (i.e. will not cause requests to be processed
 /// synchronously).
@@ -46,10 +47,13 @@
 /// and scheduling tasks.
 /// Callbacks are run on a threadpool and it's appropriate to do slow work in
 /// them. Each task has a name, used for tracing (should be UpperCamelCase).
+/// FIXME(sammccall): pull out a scheduler options struct.
 class TUScheduler {
 public:
   TUScheduler(unsigned AsyncThreadsCount, bool StorePreamblesInMemory,
-  ASTParsedCallback ASTCallback);
+  ASTParsedCallback ASTCallback,
+  std::chrono::steady_clock::duration UpdateDebounce =
+  std::chrono::milliseconds(500));
   ~TUScheduler();
 
   /// Returns estimated memory usage for each of the currently open files.
@@ -101,6 +105,7 @@
   // asynchronously.
   llvm::Optional PreambleTasks;
   llvm::Optional WorkerThreads;
+  std::chrono::steady_clock::duration UpdateDebounce;
 };
 } // namespace clangd
 } // namespace clang
Index: clangd/TUScheduler.cpp
===
--- clangd/TUScheduler.cpp
+++ clangd/TUScheduler.cpp
@@ -54,6 +54,7 @@
 
 namespace clang {
 namespace clangd {
+using std::chrono::steady_clock;
 namespace {
 class ASTWorkerHandle;
 
@@ -69,17 +70,18 @@
 /// worker.
 class ASTWorker {
   friend class ASTWorkerHandle;
-  ASTWorker(llvm::StringRef File, Semaphore , CppFile AST,
-bool RunSync);
+  ASTWorker(llvm::StringRef File, Semaphore , CppFile AST, bool RunSync,
+steady_clock::duration UpdateDebounce);
 
 public:
   /// Create a new ASTWorker and return a handle to it.
   /// The processing thread is spawned using \p Tasks. However, when \p Tasks
   /// is null, all requests will be processed on the calling thread
   /// synchronously instead. \p Barrier is acquired when processing each
   /// request, it is be used to limit the number of actively running threads.
   static ASTWorkerHandle Create(llvm::StringRef File, AsyncTaskRunner *Tasks,
-Semaphore , CppFile AST);
+Semaphore , CppFile AST,
+steady_clock::duration UpdateDebounce);
   ~ASTWorker();
 
   void update(ParseInputs Inputs, WantDiagnostics,
@@ -101,12 +103,19 @@
   /// Adds a new task to the end of the request queue.
   void startTask(llvm::StringRef Name, UniqueFunction Task,
  llvm::Optional UpdateType);
+  /// Determines the next action to perform.
+  /// All actions that should never run are disarded.
+  /// If the next action is ready, returns None to indicate this.
+ 

[PATCH] D43514: Start settinng dso_local for COFF

2018-02-22 Thread Eric Christopher via Phabricator via cfe-commits
echristo added a comment.

Some inline comments - I think this looks ok in general, but I'm curious about 
the answers to the questions/documentation bits inline.

Thanks!




Comment at: lib/CodeGen/CGDecl.cpp:257
 
+  setGVProperties(GV, );
+

If positioning is important here we should probably document it.



Comment at: lib/CodeGen/CodeGenModule.cpp:726
+  // Every other GV is local on COFF.
+  // Make an exception for windows OS in the triple: Some firmwares builds use
+  // *-win32-macho triples. This (accidentally?) produced windows relocations

"firmware"



Comment at: lib/CodeGen/CodeGenModule.cpp:733
+
   // Only handle ELF for now.
   if (!TT.isOSBinFormatELF())

This seems to need an update?



Comment at: lib/CodeGen/ItaniumCXXABI.cpp:1650
 
+  CGM.setGVProperties(VTable, RD);
+

Ditto with the moving comment from above.


https://reviews.llvm.org/D43514



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


[PATCH] D43576: Solution to fix PR27066 - Redefinition with same mangled name as another definition (dllexport and uuid)

2018-02-22 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

In https://reviews.llvm.org/D43576#1016561, @majnemer wrote:

> Here's my thinking: the `__uuidof` expression literally declares a variable 
> called `_GUID_ddb47a6a_0f23_11d5_9109_00e0296b75d3` of type `__s_GUID` which 
> is why it behaves the way it does: https://godbolt.org/g/74FY7U


This is an implementation detail leaking, though. no? Note that that is a 
reserved name.

> I don't think it is reasonable to invent new semantics which are different 
> from the MSVC ones because we find the MSVC ones inelegant.

I mostly agree, but my point is that this is *not* the MSVC semantics, it's 
merely an implementation detail that non-conforming code happens to be able to 
observe. Suppose that `type_info` objects were similarly accessible in MSVC by 
guessing their mangled names. Would you be arguing that we should inject 
variables for those too? (And note that it is *nearly* true that `type_info` 
objects work that way: https://godbolt.org/g/zByFFg -- but the parser gets 
confused somehow when you reference them.) The only difference I can see 
between these cases is that the reserved name used for the GUID case happens to 
not contain any ?s and @s, so happens to be utterable as an identifier.

We should not attempt to be compatible with the cases where MSVC's 
implementation details happen to leak into user-visible semantics.

> What is the relative upside to a new kind of Decl? Better AST fidelity?

Yes, exactly. The same reason we don't desguar other things any more than we 
have to.


https://reviews.llvm.org/D43576



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


[PATCH] D43362: Simplify setting dso_local. NFC.

2018-02-22 Thread Eric Christopher via Phabricator via cfe-commits
echristo accepted this revision.
echristo added a comment.
This revision is now accepted and ready to land.

LGTM. Thanks for the cleanup.


https://reviews.llvm.org/D43362



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


[PATCH] D43105: [RISCV] Enable __int128_t and __uint128_t through clang flag

2018-02-22 Thread Alex Bradbury via Phabricator via cfe-commits
asb accepted this revision.
asb added a comment.

I've added two suggestions on further tweaking the tests which I think it would 
be worth adopting. Looks good to me.




Comment at: test/CodeGen/riscv32-abi.c:424-430
+
+// RUN: %clang_cc1 -triple riscv32 -fforce-enable-int128 \
+// RUN: -emit-llvm %s -o - | FileCheck %s -check-prefix=CHECK-FORCEINT128-LABEL
+#ifdef __SIZEOF_INT128__
+// CHECK-FORCEINT128-LABEL: define i128 @f_scalar_5(i128 %x)
+__int128_t f_scalar_5(__int128_t x) { return x; }
+#endif

I'd probably insert this around line 26 (just after f_scalar_4) and put the RUN 
line at the very top of the file with -check-prefixes=CHECK,CHECK-FORCEINT128. 
This would demonstrate and verify that all other ABI lowering remains totally 
unaffected, which probably can't hurt. Note that `$CHECKPREFIX-LABEL` is a 
[FileCheck 
feature](https://llvm.org/docs/CommandGuide/FileCheck.html#the-check-label-directive),
 so the prefix should be defined without `-LABEL`.



Comment at: test/Preprocessor/init.c:10213-10216
+// RUN: %clang_cc1 -E -dM -ffreestanding \
+// RUN: -triple=riscv32 -fforce-enable-int128 < /dev/null \
+// RUN:   | FileCheck -match-full-lines -check-prefix=RISCV32-INT128 %s
+// RISCV32-INT128: #define __SIZEOF_INT128__ 16

It would be slightly better to define this in a similar way to the 
RISCV32-LINUX checks, so that the test also picks up the fact that other 
defines (such as _INTMAX_WIDTH__) remain unmodified.


Repository:
  rC Clang

https://reviews.llvm.org/D43105



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


[PATCH] D43576: Solution to fix PR27066 - Redefinition with same mangled name as another definition (dllexport and uuid)

2018-02-22 Thread David Majnemer via Phabricator via cfe-commits
majnemer added a comment.

In https://reviews.llvm.org/D43576#1016512, @rsmith wrote:

> Do we need to also track whether the argument is a pointer or reference to a 
> UUID (and also the cv-qualifiers)? For the `Declaration` case, we track this 
> by tracking the corresponding parameter type; the same thing would presumably 
> work here.
>
> In https://reviews.llvm.org/D43576#1016295, @majnemer wrote:
>
> > We should really, really avoid making this sort of change without first 
> > trying to desugar uuidof into a reference to a variable. That would solve a 
> > ton of problems, problems like this one.
>
>
> This desugaring approach is not how we generally do things in Clang. The fact 
> that MS exposes a variable that can be named from user code is, in my 
> opinion, simply a bug in their implementation -- their implementation details 
> are leaking -- and not part of the actual semantics here. I view this as 
> exactly analogous to `typeid` (which would have exactly the same problems if 
> its result could be used as a non-type template parameter); as with `typeid`, 
> `__uuidof` notionally produces a global object not corresponding to any 
> variable. If we want to model this as a declaration, we could add a new 
> `Decl` subclass for these uuid objects (and eventually also for objects 
> produced by `typeid`). But I don't think we should model them as variables 
> unless that's actually part of their intended semantics.


Here's my thinking: the `__uuidof` expression literally declares a variable 
called `_GUID_ddb47a6a_0f23_11d5_9109_00e0296b75d3` of type `__s_GUID` which is 
why it behaves the way it does: https://godbolt.org/g/74FY7U

I don't think it is reasonable to invent new semantics which are different from 
the MSVC ones because we find the MSVC ones inelegant. The huge upside I see 
from matching their behavior is that the implementation is dramatically 
simpler, we have a considerable amount of mumbo jumbo in the template 
instantiation code to handle `__uuidof` correctly and it looks like we will 
need some more.

What is the relative upside to a new kind of Decl? Better AST fidelity?


https://reviews.llvm.org/D43576



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


[PATCH] D43341: [clang-doc] Implement reducer portion of the frontend framework

2018-02-22 Thread Julie Hockett via Phabricator via cfe-commits
juliehockett updated this revision to Diff 135520.
juliehockett added a comment.

Updating for parent diff changes


https://reviews.llvm.org/D43341

Files:
  clang-doc/BitcodeReader.cpp
  clang-doc/BitcodeReader.h
  clang-doc/BitcodeWriter.cpp
  clang-doc/BitcodeWriter.h
  clang-doc/CMakeLists.txt
  clang-doc/Reducer.cpp
  clang-doc/Reducer.h
  clang-doc/Representation.cpp
  clang-doc/Representation.h
  clang-doc/tool/ClangDocMain.cpp
  test/clang-doc/mapper-class.cpp
  test/clang-doc/mapper-enum.cpp
  test/clang-doc/mapper-function.cpp
  test/clang-doc/mapper-method.cpp
  test/clang-doc/mapper-namespace.cpp
  test/clang-doc/mapper-struct.cpp
  test/clang-doc/mapper-union.cpp
  test/clang-doc/namespace.cpp
  test/clang-doc/record.cpp

Index: test/clang-doc/record.cpp
===
--- /dev/null
+++ test/clang-doc/record.cpp
@@ -0,0 +1,107 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: echo "" > %t/compile_flags.txt
+// RUN: cp "%s" "%t/test.cpp"
+// RUN: clang-doc --dump --omit-filenames -doxygen -p %t %t/test.cpp -output=%t/docs
+// RUN: llvm-bcanalyzer %t/docs/bc/docs.bc --dump | FileCheck %s
+
+union A { int X; int Y; };
+
+enum B { X, Y };
+
+struct C { int i; };
+
+class D {};
+
+class E {
+public:
+  E() {}
+  ~E() {}
+
+protected:
+  void ProtectedMethod();
+};
+
+void E::ProtectedMethod() {}
+
+class F : virtual private D, public E {};
+
+// CHECK: 
+// CHECK: 
+  // CHECK: 
+// CHECK: 
+// CHECK: 
+  // CHECK:  blob data = 'E'
+  // CHECK: 
+  // CHECK:  blob data = 'c:@S@E'
+  // CHECK: 
+// CHECK:  blob data = 'void'
+  // CHECK: 
+// CHECK: 
+// CHECK: 
+  // CHECK:  blob data = '~E'
+  // CHECK: 
+  // CHECK:  blob data = 'c:@S@E'
+  // CHECK: 
+// CHECK:  blob data = 'void'
+  // CHECK: 
+// CHECK: 
+// CHECK: 
+  // CHECK:  blob data = 'ProtectedMethod'
+  // CHECK: 
+  // CHECK:  blob data = 'c:@S@E'
+  // CHECK: 
+// CHECK:  blob data = 'void'
+  // CHECK: 
+// CHECK: 
+// CHECK: 
+  // CHECK:  blob data = 'A'
+  // CHECK: 
+  // CHECK: 
+  // CHECK: 
+// CHECK:  blob data = 'int'
+// CHECK:  blob data = 'A::X'
+// CHECK: 
+  // CHECK: 
+  // CHECK: 
+// CHECK:  blob data = 'int'
+// CHECK:  blob data = 'A::Y'
+// CHECK: 
+  // CHECK: 
+// CHECK: 
+// CHECK: 
+  // CHECK:  blob data = 'C'
+  // CHECK: 
+  // CHECK: 
+// CHECK:  blob data = 'int'
+// CHECK:  blob data = 'C::i'
+// CHECK: 
+  // CHECK: 
+// CHECK: 
+// CHECK: 
+  // CHECK:  blob data = 'D'
+  // CHECK: 
+  // CHECK: 
+// CHECK: 
+// CHECK: 
+  // CHECK:  blob data = 'E'
+  // CHECK: 
+  // CHECK: 
+// CHECK: 
+// CHECK: 
+  // CHECK:  blob data = 'F'
+  // CHECK: 
+  // CHECK: 
+  // CHECK:  blob data = 'c:@S@E'
+  // CHECK:  blob data = 'c:@S@D'
+// CHECK: 
+// CHECK: 
+  // CHECK:  blob data = 'B'
+  // CHECK: 
+  // CHECK: 
+// CHECK:  blob data = 'X'
+  // CHECK: 
+  // CHECK: 
+// CHECK:  blob data = 'Y'
+  // CHECK: 
+// CHECK: 
Index: test/clang-doc/namespace.cpp
===
--- /dev/null
+++ test/clang-doc/namespace.cpp
@@ -0,0 +1,67 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: echo "" > %t/compile_flags.txt
+// RUN: cp "%s" "%t/test.cpp"
+// RUN: clang-doc --dump --omit-filenames -doxygen -p %t %t/test.cpp -output=%t/docs
+// RUN: llvm-bcanalyzer %t/docs/bc/docs.bc --dump | FileCheck %s
+
+namespace A {
+
+void f();
+void f() {};
+
+} // A
+
+namespace A {
+namespace B {
+
+enum E { X };
+
+E func(int i) { 
+  return X;
+}
+
+}
+}
+
+// CHECK: 
+// CHECK: 
+  // CHECK: 
+// CHECK: 
+// CHECK: 
+  // CHECK:  blob data = 'A'
+// CHECK: 
+// CHECK: 
+  // CHECK:  blob data = 'B'
+  // CHECK:  blob data = 'c:@N@A'
+// CHECK: 
+// CHECK: 
+  // CHECK:  blob data = 'f'
+  // CHECK:  blob data = 'c:@N@A'
+  // CHECK: 
+  // CHECK: 
+// CHECK:  blob data = 'void'
+  // CHECK: 
+// CHECK: 
+// CHECK: 
+  // CHECK:  blob data = 'func'
+  // CHECK:  blob data = 'c:@N@A@N@B'
+  // CHECK:  blob data = 'c:@N@A'
+  // CHECK: 
+  // CHECK: 
+// CHECK:  blob data = 'enum A::B::E'
+  // CHECK: 
+  // CHECK: 
+// CHECK:  blob data = 'int'
+// CHECK:  blob data = 'i'
+  // CHECK: 
+// CHECK: 
+// CHECK: 
+  // CHECK:  blob data = 'E'
+  // CHECK:  blob data = 'c:@N@A@N@B'
+  // CHECK:  blob data = 'c:@N@A'
+  // CHECK: 
+  // CHECK: 
+// CHECK:  blob data = 'A::B::X'
+  // CHECK: 
+// CHECK: 
Index: test/clang-doc/mapper-union.cpp
===
--- test/clang-doc/mapper-union.cpp
+++ /dev/null
@@ -1,29 +0,0 @@
-// RUN: rm -rf %t
-// RUN: mkdir %t
-// RUN: echo "" > %t/compile_flags.txt
-// RUN: cp "%s" "%t/test.cpp"
-// RUN: clang-doc --dump --omit-filenames -doxygen -p %t %t/test.cpp -output=%t/docs
-// RUN: llvm-bcanalyzer %t/docs/c:@u...@d.bc --dump | FileCheck %s
-
-union D { int X; int Y; };
-// CHECK: 
-// CHECK: 
-  // CHECK: 
-// CHECK: 
-// CHECK: 
-  // CHECK:  blob data = 'D'
-  // 

[PATCH] D41102: Setup clang-doc frontend framework

2018-02-22 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

An idea on how to further generalize/cleanup `emitBlockInfoBlock()`.

While *i think* will help, i'm not sure how to further consolidate the 
`BlockIdNameMap`/`RecordIdNameMap` and the actual `emitBlock(*)`...




Comment at: clang-doc/BitcodeWriter.cpp:55
+}();
+
+static const IndexedMap RecordIdNameMap =

After thinking, i think the solution is to turn the lambdas in 
`emit{String,...}Abbrev()` into static functions, and store not a stringref in 
RecordIdNameMap, but a struct with stringref + pointer to one of the functions.
Since `RecordIdNameMap` is only used in `emitRecordID()`, which is only used in 
`emitBlockInfoBlock()`, i think it should not be too intrusive..

So
```
// Or, decltype(), or std::function?
using AbbrevDsc = void (*)(std::shared_ptr );

static void StringAbbrev(std::shared_ptr ) {
Abbrev->Add(
BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
BitCodeConstants::LineNumFixedSize));  // String size
Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));   // String
};
static void LocationAbbrev(std::shared_ptr ) {
Abbrev->Add(
BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
BitCodeConstants::LineNumFixedSize));  // Line number
Abbrev->Add(
BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
BitCodeConstants::LineNumFixedSize));  // Filename size
Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));   // Filename
}
static void IntAbbrev = [](std::shared_ptr ) {
Abbrev->Add(
BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
BitCodeConstants::LineNumFixedSize));  // Integer
};

struct RecordIdDsc {
  StringRef Name;
  AbbrevDsc Abbrev;

  RecordIdDsc() = default;

  RecordIdDsc(StringRef Name_, AbbrevDsc Abbrev_) : Name(Name_), 
Abbrev(Abbrev_) {}
}

static const IndexedMap RecordIdNameMap =
[]() {
  IndexedMap RecordIdNameMap;
  static constexpr unsigned ExpectedSize = RI_LAST - RI_FIRST + 1;
  RecordIdNameMap.resize(ExpectedSize);

  // There is no init-list constructor for the IndexedMap, so have to
  // improvise
  static constexpr std::initializer_list<
  std::pair>
  inits = {{VERSION, {"Version", }},

```



Comment at: clang-doc/BitcodeWriter.cpp:156
+  prepRecordData(ID);
+  for (const char C : RecordIdNameMap[ID]) Record.push_back(C);
+  Stream.EmitRecord(llvm::bitc::BLOCKINFO_CODE_SETRECORDNAME, Record);

```
for (const char C : RecordIdNameMap[ID].Name) Record.push_back(C);
```



Comment at: clang-doc/BitcodeWriter.cpp:162
+
+template 
+void ClangDocBitcodeWriter::emitAbbrev(RecordId ID, BlockId Block, Lambda &) 
{

```
void ClangDocBitcodeWriter::emitAbbrev(RecordId ID, BlockId Block) {
  auto Abbrev = std::make_shared();
  Abbrev->Add(BitCodeAbbrevOp(ID));
  RecordIdNameMap[ID].Abbrev(Abbrev);
  Abbrevs.add(ID, Stream.EmitBlockInfoAbbrev(Block, std::move(Abbrev)));
}
```



Comment at: clang-doc/BitcodeWriter.cpp:170
+
+void ClangDocBitcodeWriter::emitStringAbbrev(RecordId ID, BlockId Block) {
+  auto EmitString = [](std::shared_ptr ) {

Those three will be gone



Comment at: clang-doc/BitcodeWriter.cpp:253
+COMMENT_ARG, COMMENT_POSITION})
+emitStringAbbrev(RID, BI_COMMENT_BLOCK_ID);
+  emitIntAbbrev(COMMENT_SELFCLOSING, BI_COMMENT_BLOCK_ID);

So now this is
```
  for (RecordId RID :
   {COMMENT_KIND, COMMENT_TEXT, COMMENT_NAME, COMMENT_DIRECTION,
COMMENT_PARAMNAME, COMMENT_CLOSENAME, COMMENT_ATTRKEY, COMMENT_ATTRVAL,
COMMENT_ARG, COMMENT_POSITION, COMMENT_SELFCLOSING, COMMENT_EXPLICIT})
emitAbbrev(RID, BI_COMMENT_BLOCK_ID);
```



Comment at: clang-doc/BitcodeWriter.cpp:273
+emitRecordID(RID);
+  emitStringAbbrev(MEMBER_TYPE_TYPE, BI_MEMBER_TYPE_BLOCK_ID);
+  emitStringAbbrev(MEMBER_TYPE_NAME, BI_MEMBER_TYPE_BLOCK_ID);

```
  for (RecordId RID : {MEMBER_TYPE_TYPE, MEMBER_TYPE_NAME, MEMBER_TYPE_ACCESS})
emitAbbrev(RID, BI_MEMBER_TYPE_BLOCK_ID);
```
and so on



Comment at: clang-doc/BitcodeWriter.cpp:277
+
+  // Namespace Block
+  emitBlockID(BI_NAMESPACE_BLOCK_ID);

And The Next Pattern:
```
emitBlockID(BI_{STUFF}_BLOCK_ID); // <- same BI_{STUFF}_BLOCK_ID
for (RecordId RID : {STUFF_FOO, STUFF_BAR, STUFF_BAZ, ...}) // <- same init-list
  emitRecordID(RID);
for (RecordId RID : {STUFF_FOO, STUFF_BAR, STUFF_BAZ, ...}) // <- same init-list
  emitAbbrev(RID, BI_{STUFF}_BLOCK_ID); // <- same BI_{STUFF}_BLOCK_ID
```

I think it can be generalized as:
```
std::initializer_list> 
TheBlocks {
...
  // Namespace Block
  {BI_NAMESPACE_BLOCK_ID, 

r325834 - [Sema] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).

2018-02-22 Thread Eugene Zelenko via cfe-commits
Author: eugenezelenko
Date: Thu Feb 22 14:35:17 2018
New Revision: 325834

URL: http://llvm.org/viewvc/llvm-project?rev=325834=rev
Log:
[Sema] Fix some Clang-tidy modernize and Include What You Use warnings; other 
minor fixes (NFC).

Modified:
cfe/trunk/include/clang/Sema/Scope.h
cfe/trunk/include/clang/Sema/ScopeInfo.h
cfe/trunk/include/clang/Sema/Template.h
cfe/trunk/include/clang/Sema/TemplateDeduction.h
cfe/trunk/include/clang/Sema/TypoCorrection.h
cfe/trunk/include/clang/Serialization/ASTReader.h
cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp

Modified: cfe/trunk/include/clang/Sema/Scope.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Scope.h?rev=325834=325833=325834=diff
==
--- cfe/trunk/include/clang/Sema/Scope.h (original)
+++ cfe/trunk/include/clang/Sema/Scope.h Thu Feb 22 14:35:17 2018
@@ -1,4 +1,4 @@
-//===--- Scope.h - Scope interface --*- C++ 
-*-===//
+//===- Scope.h - Scope interface *- C++ 
-*-===//
 //
 // The LLVM Compiler Infrastructure
 //
@@ -14,28 +14,29 @@
 #ifndef LLVM_CLANG_SEMA_SCOPE_H
 #define LLVM_CLANG_SEMA_SCOPE_H
 
-#include "clang/AST/Decl.h"
 #include "clang/Basic/Diagnostic.h"
 #include "llvm/ADT/PointerIntPair.h"
 #include "llvm/ADT/SmallPtrSet.h"
 #include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/iterator_range.h"
+#include 
 
 namespace llvm {
 
 class raw_ostream;
 
-}
+} // namespace llvm
 
 namespace clang {
 
 class Decl;
+class DeclContext;
 class UsingDirectiveDecl;
 class VarDecl;
 
 /// Scope - A scope is a transient data structure that is used while parsing 
the
 /// program.  It assists with resolving identifiers to the appropriate
 /// declaration.
-///
 class Scope {
 public:
   /// ScopeFlags - These are bitfields that are or'd together when creating a
@@ -131,6 +132,7 @@ public:
 /// We are between inheritance colon and the real class/struct definition 
scope.
 ClassInheritanceScope = 0x80,
   };
+
 private:
   /// The parent scope for this scope.  This is null for the translation-unit
   /// scope.
@@ -185,7 +187,7 @@ private:
   /// popped, these declarations are removed from the IdentifierTable's notion
   /// of current declaration.  It is up to the current Action implementation to
   /// implement these semantics.
-  typedef llvm::SmallPtrSet DeclSetTy;
+  using DeclSetTy = llvm::SmallPtrSet;
   DeclSetTy DeclsInScope;
 
   /// The DeclContext with which this scope is associated. For
@@ -193,7 +195,7 @@ private:
   /// entity of a function scope is a function, etc.
   DeclContext *Entity;
 
-  typedef SmallVector UsingDirectivesTy;
+  using UsingDirectivesTy = SmallVector;
   UsingDirectivesTy UsingDirectives;
 
   /// \brief Used to determine if errors occurred in this scope.
@@ -207,25 +209,23 @@ private:
 
 public:
   Scope(Scope *Parent, unsigned ScopeFlags, DiagnosticsEngine )
-: ErrorTrap(Diag) {
+  : ErrorTrap(Diag) {
 Init(Parent, ScopeFlags);
   }
 
   /// getFlags - Return the flags for this scope.
-  ///
   unsigned getFlags() const { return Flags; }
+
   void setFlags(unsigned F) { setFlags(getParent(), F); }
 
   /// isBlockScope - Return true if this scope correspond to a closure.
   bool isBlockScope() const { return Flags & BlockScope; }
 
   /// getParent - Return the scope that this is nested in.
-  ///
   const Scope *getParent() const { return AnyParent; }
   Scope *getParent() { return AnyParent; }
 
   /// getFnParent - Return the closest scope that is a function body.
-  ///
   const Scope *getFnParent() const { return FnParent; }
   Scope *getFnParent() { return FnParent; }
 
@@ -275,10 +275,12 @@ public:
 return PrototypeIndex++;
   }
 
-  typedef llvm::iterator_range decl_range;
+  using decl_range = llvm::iterator_range;
+
   decl_range decls() const {
 return decl_range(DeclsInScope.begin(), DeclsInScope.end());
   }
+
   bool decl_empty() const { return DeclsInScope.empty(); }
 
   void AddDecl(Decl *D) {
@@ -368,7 +370,6 @@ public:
 return false;
   }
 
-  
   /// isTemplateParamScope - Return true if this scope is a C++
   /// template parameter scope.
   bool isTemplateParamScope() const {
@@ -457,8 +458,8 @@ public:
 UsingDirectives.push_back(UDir);
   }
 
-  typedef llvm::iterator_range
-using_directives_range;
+  using using_directives_range =
+  llvm::iterator_range;
 
   using_directives_range using_directives() {
 return using_directives_range(UsingDirectives.begin(),
@@ -477,25 +478,23 @@ public:
   }
 
   void setNoNRVO() {
-NRVO.setInt(1);
+NRVO.setInt(true);
 NRVO.setPointer(nullptr);
   }
 
   void mergeNRVOIntoParent();
 
   /// Init - This is used by the parser to implement scope caching.
-  ///
   void Init(Scope *parent, unsigned flags);
 
   /// \brief Sets up the specified scope flags and adjusts the scope state
   /// variables 

[PATCH] D43576: Solution to fix PR27066 - Redefinition with same mangled name as another definition (dllexport and uuid)

2018-02-22 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

Do we need to also track whether the argument is a pointer or reference to a 
UUID (and also the cv-qualifiers)? For the `Declaration` case, we track this by 
tracking the corresponding parameter type; the same thing would presumably work 
here.

In https://reviews.llvm.org/D43576#1016295, @majnemer wrote:

> We should really, really avoid making this sort of change without first 
> trying to desugar uuidof into a reference to a variable. That would solve a 
> ton of problems, problems like this one.


This desugaring approach is not how we generally do things in Clang. The fact 
that MS exposes a variable that can be named from user code is, in my opinion, 
simply a bug in their implementation -- their implementation details are 
leaking -- and not part of the actual semantics here. I view this as exactly 
analogous to `typeid` (which would have exactly the same problems if its result 
could be used as a non-type template parameter); as with `typeid`, `__uuidof` 
notionally produces a global object not corresponding to any variable. If we 
want to model this as a declaration, we could add a new `Decl` subclass for 
these uuid objects (and eventually also for objects produced by `typeid`). But 
I don't think we should model them as variables unless that's actually part of 
their intended semantics.


https://reviews.llvm.org/D43576



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


[PATCH] D43576: Solution to fix PR27066 - Redefinition with same mangled name as another definition (dllexport and uuid)

2018-02-22 Thread David Majnemer via Phabricator via cfe-commits
majnemer added a comment.

In https://reviews.llvm.org/D43576#1016418, @zahiraam wrote:

> In https://reviews.llvm.org/D43576#1016295, @majnemer wrote:
>
> > We should really, really avoid making this sort of change without first 
> > trying to desugar uuidof into a reference to a variable. That would solve a 
> > ton of problems, problems like this one.
>
>
> Not sure I fully understand what you are proposing?
>
> Are you proposing that generated symbols like this:
>  
> ??4?$A@$E?_GUID_ddb47a6a_0f23_11d5_9109_00e0296b75d3@@3U__s_GUID@@B@@QEAAAEAV0@AEBV0@@Z
>  
>  Be de-sugared? Wouldn't that be different that what MS is doing? 
>  Can you please give me more details about what you are thinking of?
>  Thanks.


We create an AST such that the following:

  struct _GUID;
  
  template 
  class A {};
  
  struct __declspec(uuid("{DDB47A6A-0F23-11D5-9109-00E0296B75D3}")) S {};
  
  struct __declspec(dllexport) C : public A<&__uuidof(S)> {};

is turned into something like:

  struct _GUID;
  
  __declspec(selectany) __s_GUID const 
_GUID_ddb47a6a_0f23_11d5_9109_00e0296b75d3 = {...};
  
  template 
  class A {};
  
  struct __declspec(uuid("{DDB47A6A-0F23-11D5-9109-00E0296B75D3}")) S {};
  
  struct __declspec(dllexport) C : public 
A<&_GUID_ddb47a6a_0f23_11d5_9109_00e0296b75d3> {};


https://reviews.llvm.org/D43576



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


[PATCH] D42776: [Sema] Fix an assertion failure in constant expression evaluation of calls to functions with default arguments

2018-02-22 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

Thank you, this looks like a great direction.

As noted, there are a bunch of other cases that we should cover with this 
approach. I'm really happy about the number of related bugs we get to fix with 
this change.




Comment at: lib/AST/ExprConstant.cpp:3186-3187
   // object under construction.
-  if (Info.isEvaluatingConstructor(LVal.getLValueBase(), LVal.CallIndex)) {
+  if (Info.isEvaluatingConstructor(LVal.getLValueBase(),
+   LVal.getLValueCallIndex())) {
 BaseType = Info.Ctx.getCanonicalType(BaseType);

This should take the version into account.



Comment at: lib/AST/ExprConstant.cpp:5236
 if (Frame) {
-  Result.set(VD, Frame->Index);
+  Result.set({VD, Frame->Index});
   return true;

Hmm. We should be versioning local variables as well. Currently we'll accept 
invalid code such as:

```
constexpr int f() {
  int *p = nullptr;
  for (int k = 0; k != 2; ++k) {
int local_var = 0;
if (k == 0)
  p = _var;
else
  return *p;
  }
}
static_assert(f() == 0);
```



Comment at: lib/AST/ExprConstant.cpp:5275-5278
+unsigned Version = Info.CurrentCall->getMTEVersion();
 Value = >
-createTemporary(E, E->getStorageDuration() == SD_Automatic);
-Result.set(E, Info.CurrentCall->Index);
+createTemporary(E, E->getStorageDuration() == SD_Automatic, Version);
+Result.set({E, Info.CurrentCall->Index, Version});

Can you combine these, so we have a single function to create a temporary and 
produce both an `LValue` denoting it and an `APValue*` to hold its evaluated 
value?



Comment at: lib/AST/ExprConstant.cpp:5772
 } else {
-  Result.set(SubExpr, Info.CurrentCall->Index);
+  Result.set({SubExpr, Info.CurrentCall->Index});
   if (!EvaluateInPlace(Info.CurrentCall->createTemporary(SubExpr, false),

This should create a versioned temporary object.



Comment at: lib/AST/ExprConstant.cpp:6540
   bool VisitConstructExpr(const Expr *E) {
-Result.set(E, Info.CurrentCall->Index);
+Result.set({E, Info.CurrentCall->Index});
 return EvaluateInPlace(Info.CurrentCall->createTemporary(E, false),

This should create a versioned temporary object.



Comment at: lib/AST/ExprConstant.cpp:8031
+ (A.getLValueCallIndex() == B.getLValueCallIndex() &&
+  A.getLValueVersion() == B.getLValueVersion());
 }

You already checked this above. It'd make sense to check the call index and 
version in the same place here, but we should only need one check for each :)



Comment at: lib/AST/ExprConstant.cpp:9974-9997
+LV.set({E, Info.CurrentCall->Index});
 APValue  = Info.CurrentCall->createTemporary(E, false);
 if (!EvaluateArray(E, LV, Value, Info))
   return false;
 Result = Value;
   } else if (T->isRecordType()) {
 LValue LV;

These temporaries should all be versioned.


https://reviews.llvm.org/D42776



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


[PATCH] D43581: [clang-tidy/google] Fix the Objective-C global variable declaration check 

2018-02-22 Thread Stephane Moore via Phabricator via cfe-commits
stephanemoore updated this revision to Diff 135510.
stephanemoore added a comment.

Revert the inclusion of the link to the Google Objective-C style guide in the 
diagnostic message.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D43581

Files:
  clang-tidy/google/GlobalVariableDeclarationCheck.cpp
  test/clang-tidy/google-objc-global-variable-declaration.m


Index: test/clang-tidy/google-objc-global-variable-declaration.m
===
--- test/clang-tidy/google-objc-global-variable-declaration.m
+++ test/clang-tidy/google-objc-global-variable-declaration.m
@@ -30,8 +30,16 @@
 // CHECK-FIXES: static NSString* const k_Alpha = @"SecondNotAlpha";
 
 static NSString* const kGood = @"hello";
+static NSString* const XYGood = @"hello";
 static NSString* gMyIntGood = 0;
 
+extern NSString* const GTLServiceErrorDomain;
+
+typedef NS_ENUM(NSInteger, GTLServiceError) {
+  GTLServiceErrorQueryResultMissing = -3000,
+  GTLServiceErrorWaitTimedOut   = -3001,
+};
+
 @implementation Foo
 - (void)f {
 int x = 0;
Index: clang-tidy/google/GlobalVariableDeclarationCheck.cpp
===
--- clang-tidy/google/GlobalVariableDeclarationCheck.cpp
+++ clang-tidy/google/GlobalVariableDeclarationCheck.cpp
@@ -72,7 +72,7 @@
   this);
   Finder->addMatcher(varDecl(hasGlobalStorage(), hasType(isConstQualified()),
  unless(isLocalVariable()),
- unless(matchesName("::k[A-Z]")))
+ unless(matchesName("::(k[A-Z]|[A-Z]{2,})")))
  .bind("global_const"),
  this);
 }
@@ -88,7 +88,7 @@
   if (const auto *Decl = Result.Nodes.getNodeAs("global_const")) {
 diag(Decl->getLocation(),
  "const global variable '%0' must have a name which starts with "
- "'k[A-Z]'")
+ "an appropriate prefix matching '(k[A-Z]|[A-Z]{2,})'.")
 << Decl->getName() << generateFixItHint(Decl, true);
   }
 }


Index: test/clang-tidy/google-objc-global-variable-declaration.m
===
--- test/clang-tidy/google-objc-global-variable-declaration.m
+++ test/clang-tidy/google-objc-global-variable-declaration.m
@@ -30,8 +30,16 @@
 // CHECK-FIXES: static NSString* const k_Alpha = @"SecondNotAlpha";
 
 static NSString* const kGood = @"hello";
+static NSString* const XYGood = @"hello";
 static NSString* gMyIntGood = 0;
 
+extern NSString* const GTLServiceErrorDomain;
+
+typedef NS_ENUM(NSInteger, GTLServiceError) {
+  GTLServiceErrorQueryResultMissing = -3000,
+  GTLServiceErrorWaitTimedOut   = -3001,
+};
+
 @implementation Foo
 - (void)f {
 int x = 0;
Index: clang-tidy/google/GlobalVariableDeclarationCheck.cpp
===
--- clang-tidy/google/GlobalVariableDeclarationCheck.cpp
+++ clang-tidy/google/GlobalVariableDeclarationCheck.cpp
@@ -72,7 +72,7 @@
   this);
   Finder->addMatcher(varDecl(hasGlobalStorage(), hasType(isConstQualified()),
  unless(isLocalVariable()),
- unless(matchesName("::k[A-Z]")))
+ unless(matchesName("::(k[A-Z]|[A-Z]{2,})")))
  .bind("global_const"),
  this);
 }
@@ -88,7 +88,7 @@
   if (const auto *Decl = Result.Nodes.getNodeAs("global_const")) {
 diag(Decl->getLocation(),
  "const global variable '%0' must have a name which starts with "
- "'k[A-Z]'")
+ "an appropriate prefix matching '(k[A-Z]|[A-Z]{2,})'.")
 << Decl->getName() << generateFixItHint(Decl, true);
   }
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r324308 - Fix crash on invalid.

2018-02-22 Thread Richard Trieu via cfe-commits
Thanks, Hans!

On Thu, Feb 22, 2018 at 3:27 AM, Hans Wennborg  wrote:

> Seems safe. Merged in r325766.
>
> On Thu, Feb 22, 2018 at 1:15 AM, Richard Trieu  wrote:
> > Hi Hans,
> >
> > If there's still time for rc3, I'd like to get this crash fix in.  This
> adds
> > a null check to prevent a crash on invalid.
> >
> > Richard
> >
> > On Mon, Feb 5, 2018 at 6:58 PM, Richard Trieu via cfe-commits
> >  wrote:
> >>
> >> Author: rtrieu
> >> Date: Mon Feb  5 18:58:21 2018
> >> New Revision: 324308
> >>
> >> URL: http://llvm.org/viewvc/llvm-project?rev=324308=rev
> >> Log:
> >> Fix crash on invalid.
> >>
> >> Don't call a method when the pointer is null.
> >>
> >> Modified:
> >> cfe/trunk/lib/Sema/SemaExpr.cpp
> >> cfe/trunk/test/SemaCXX/lambda-expressions.cpp
> >>
> >> Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
> >> URL:
> >> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/
> SemaExpr.cpp?rev=324308=324307=324308=diff
> >>
> >> 
> ==
> >> --- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
> >> +++ cfe/trunk/lib/Sema/SemaExpr.cpp Mon Feb  5 18:58:21 2018
> >> @@ -14958,7 +14958,8 @@ static void DoMarkVarDeclReferenced(Sema
> >>  if (RefersToEnclosingScope) {
> >>LambdaScopeInfo *const LSI =
> >>SemaRef.getCurLambda(/*IgnoreNonLambdaCapturingScope=
> */true);
> >> -  if (LSI && !LSI->CallOperator->Encloses(Var->getDeclContext()))
> {
> >> +  if (LSI && (!LSI->CallOperator ||
> >> +  !LSI->CallOperator->Encloses(Var->getDeclContext(
> {
> >>  // If a variable could potentially be odr-used, defer marking
> it
> >> so
> >>  // until we finish analyzing the full expression for any
> >>  // lvalue-to-rvalue
> >>
> >> Modified: cfe/trunk/test/SemaCXX/lambda-expressions.cpp
> >> URL:
> >> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/
> SemaCXX/lambda-expressions.cpp?rev=324308=324307=324308=diff
> >>
> >> 
> ==
> >> --- cfe/trunk/test/SemaCXX/lambda-expressions.cpp (original)
> >> +++ cfe/trunk/test/SemaCXX/lambda-expressions.cpp Mon Feb  5 18:58:21
> 2018
> >> @@ -608,3 +608,18 @@ namespace ConversionOperatorDoesNotHaveD
> >>// This used to crash in return type deduction for the conversion
> >> opreator.
> >>struct A { int n; void f() { +[](decltype(n)) {}; } };
> >>  }
> >> +
> >> +namespace TypoCorrection {
> >> +template  struct X {};
> >> +// expected-note@-1 {{template parameter is declared here}}
> >> +
> >> +template 
> >> +void Run(const int& points) {
> >> +// expected-note@-1 {{'points' declared here}}
> >> +  auto outer_lambda = []() {
> >> +auto inner_lambda = [](const X&) {};
> >> +// expected-error@-1 {{use of undeclared identifier 'Points'; did
> you
> >> mean 'points'?}}
> >> +// expected-error@-2 {{template argument for template type
> parameter
> >> must be a type}}
> >> +  };
> >> +}
> >> +}
> >>
> >>
> >> ___
> >> cfe-commits mailing list
> >> cfe-commits@lists.llvm.org
> >> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
> >
> >
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D43581: [clang-tidy/google] Fix the Objective-C global variable declaration check 

2018-02-22 Thread Yan Zhang via Phabricator via cfe-commits
Wizard added inline comments.



Comment at: clang-tidy/google/GlobalVariableDeclarationCheck.cpp:92
+ "an appropriate prefix (see "
+ "http://google.github.io/styleguide/objcguide#constants).")
 << Decl->getName() << generateFixItHint(Decl, true);

aaron.ballman wrote:
> We don't usually put hyperlinks in the diagnostic messages, so please remove 
> this.
> 
> My suggestion about describing what constitutes an appropriate prefix was 
> with regards to the style guide wording itself. For instance, that document 
> doesn't mention that two capital letters is good. That's not on you to fix 
> before this patch goes in, of course.
Btw it is actually "2 or more" characters for prefix. I think it makes sense 
because we need at least 2 or more characters to call it a "prefix" :-)


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D43581



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


[PATCH] D43576: Solution to fix PR27066 - Redefinition with same mangled name as another definition (dllexport and uuid)

2018-02-22 Thread Zahira Ammarguellat via Phabricator via cfe-commits
zahiraam added a comment.

In https://reviews.llvm.org/D43576#1016295, @majnemer wrote:

> We should really, really avoid making this sort of change without first 
> trying to desugar uuidof into a reference to a variable. That would solve a 
> ton of problems, problems like this one.


Not sure I fully understand what you are proposing?

Are you proposing that generated symbols like this:
??4?$A@$E?_GUID_ddb47a6a_0f23_11d5_9109_00e0296b75d3@@3U__s_GUID@@B@@QEAAAEAV0@AEBV0@@Z
 
Be de-sugared? Wouldn't that be different that what MS is doing? 
Can you please give me more details about what you are thinking of?
Thanks.


https://reviews.llvm.org/D43576



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


[PATCH] D42776: [Sema] Fix an assertion failure in constant expression evaluation of calls to functions with default arguments

2018-02-22 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added a comment.

ping


https://reviews.llvm.org/D42776



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


[PATCH] D43576: Solution to fix PR27066 - Redefinition with same mangled name as another definition (dllexport and uuid)

2018-02-22 Thread Zahira Ammarguellat via Phabricator via cfe-commits
zahiraam updated this revision to Diff 135502.

https://reviews.llvm.org/D43576

Files:
  test/CodeGenCXX/instantiate-uuid.cpp
  test/Sema/member-reference-dll.cpp


Index: test/Sema/member-reference-dll.cpp
===
--- test/Sema/member-reference-dll.cpp
+++ /dev/null
@@ -1,24 +0,0 @@
-// RUN: %clang_cc1 -triple x86_64-windows-msvc -fsyntax-only -verify 
-fms-extensions -fms-compatibility %s
-// expected-no-diagnostics
-
-namespace test1 {
-class __declspec(dllimport) Edge;
-
-template 
-class __declspec(dllimport) Range {
-  void insert(T *obj) { obj->loc(); }
-};
-
-template void Range::insert(Edge *);
-} // namespace test1
-
-namespace test2 {
-class __declspec(dllexport) Edge;
-
-template 
-class __declspec(dllimport) Range {
-  void insert(T *obj) { obj->loc(); }
-};
-
-template void Range::insert(Edge *);
-} // namespace test2
Index: test/CodeGenCXX/instantiate-uuid.cpp
===
--- /dev/null
+++ test/CodeGenCXX/instantiate-uuid.cpp
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -triple x86_64-pc-windows-msvc -std=c++14 -fms-extensions 
-fms-compatibility -emit-llvm -o - %s | Filecheck %s
+
+// expected-no-diagnostics
+
+// M32-DAG: 
$"\01??4?$A@$E?_GUID_ddb47a6a_0f23_11d5_9109_00e0296b75d3@@3U__s_GUID@@B@@QEAAAEAV0@AEBV0@@Z"
 = comdat any
+
+typedef struct _GUID {
+  int i;
+} IID;
+template 
+class A {};
+
+struct
+__declspec(uuid("{DDB47A6A-0F23-11D5-9109-00E0296B75D3}"))
+S1 {};
+
+struct
+__declspec(uuid("{DDB47A6A-0F23-11D5-9109-00E0296B75D3}"))
+S2 {};
+
+struct __declspec(dllexport)
+C1 : public A<&__uuidof(S1)> {};
+
+struct __declspec(dllexport)
+C2 : public A<&__uuidof(S2)> {};
+
+// CHECK-LABEL: define weak_odr dllexport dereferenceable(1) %class.A* 
@"\01??4?$A@$E?_GUID_ddb47a6a_0f23_11d5_9109_00e0296b75d3@@3U__s_GUID@@B@@QEAAAEAV0@AEBV0@@Z"
+
+


Index: test/Sema/member-reference-dll.cpp
===
--- test/Sema/member-reference-dll.cpp
+++ /dev/null
@@ -1,24 +0,0 @@
-// RUN: %clang_cc1 -triple x86_64-windows-msvc -fsyntax-only -verify -fms-extensions -fms-compatibility %s
-// expected-no-diagnostics
-
-namespace test1 {
-class __declspec(dllimport) Edge;
-
-template 
-class __declspec(dllimport) Range {
-  void insert(T *obj) { obj->loc(); }
-};
-
-template void Range::insert(Edge *);
-} // namespace test1
-
-namespace test2 {
-class __declspec(dllexport) Edge;
-
-template 
-class __declspec(dllimport) Range {
-  void insert(T *obj) { obj->loc(); }
-};
-
-template void Range::insert(Edge *);
-} // namespace test2
Index: test/CodeGenCXX/instantiate-uuid.cpp
===
--- /dev/null
+++ test/CodeGenCXX/instantiate-uuid.cpp
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -triple x86_64-pc-windows-msvc -std=c++14 -fms-extensions -fms-compatibility -emit-llvm -o - %s | Filecheck %s
+
+// expected-no-diagnostics
+
+// M32-DAG: $"\01??4?$A@$E?_GUID_ddb47a6a_0f23_11d5_9109_00e0296b75d3@@3U__s_GUID@@B@@QEAAAEAV0@AEBV0@@Z" = comdat any
+
+typedef struct _GUID {
+  int i;
+} IID;
+template 
+class A {};
+
+struct
+__declspec(uuid("{DDB47A6A-0F23-11D5-9109-00E0296B75D3}"))
+S1 {};
+
+struct
+__declspec(uuid("{DDB47A6A-0F23-11D5-9109-00E0296B75D3}"))
+S2 {};
+
+struct __declspec(dllexport)
+C1 : public A<&__uuidof(S1)> {};
+
+struct __declspec(dllexport)
+C2 : public A<&__uuidof(S2)> {};
+
+// CHECK-LABEL: define weak_odr dllexport dereferenceable(1) %class.A* @"\01??4?$A@$E?_GUID_ddb47a6a_0f23_11d5_9109_00e0296b75d3@@3U__s_GUID@@B@@QEAAAEAV0@AEBV0@@Z"
+
+
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D43576: Solution to fix PR27066 - Redefinition with same mangled name as another definition (dllexport and uuid)

2018-02-22 Thread Zahira Ammarguellat via Phabricator via cfe-commits
zahiraam added a comment.

Adding test case.


https://reviews.llvm.org/D43576



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


[PATCH] D43581: [clang-tidy/google] Fix the Objective-C global variable declaration check 

2018-02-22 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang-tidy/google/GlobalVariableDeclarationCheck.cpp:92
+ "an appropriate prefix (see "
+ "http://google.github.io/styleguide/objcguide#constants).")
 << Decl->getName() << generateFixItHint(Decl, true);

We don't usually put hyperlinks in the diagnostic messages, so please remove 
this.

My suggestion about describing what constitutes an appropriate prefix was with 
regards to the style guide wording itself. For instance, that document doesn't 
mention that two capital letters is good. That's not on you to fix before this 
patch goes in, of course.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D43581



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


[PATCH] D43581: [clang-tidy/google] Fix the Objective-C global variable declaration check 

2018-02-22 Thread Stephane Moore via Phabricator via cfe-commits
stephanemoore added a comment.

In https://reviews.llvm.org/D43581#1016327, @Wizard wrote:

> In https://reviews.llvm.org/D43581#1016318, @stephanemoore wrote:
>
> > In https://reviews.llvm.org/D43581#1016300, @Wizard wrote:
> >
> > > Please update the warning info to indicate that prefix 'k' is not the 
> > > only option for constants. Something like:
> > >  "const global variable '%0' must have an appropriate prefix or a name 
> > > which starts with 'k[A-Z]'"
> >
> >
> > Is the latest warning info satisfactory? I believe I updated it after 
> > adding you as a reviewer.
>
>
> Hmm I feel it is a bit unfriendly to show users a rather complicated regex in 
> the info, but I will leave it to you. Not a big problem.


At a glance this seems unconventional but could we have the warning link to the 
Google Objective-C style guide for guidance on an appropriate prefix? Is that 
allowed for diagnostic messages? I can revert if that is considered 
inappropriate.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D43581



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


[PATCH] D43581: [clang-tidy/google] Fix the Objective-C global variable declaration check 

2018-02-22 Thread Stephane Moore via Phabricator via cfe-commits
stephanemoore updated this revision to Diff 135497.
stephanemoore added a comment.

Update the diagnostic information to link to the Google Objective-C style guide 
for guidance on an appropriate prefix.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D43581

Files:
  clang-tidy/google/GlobalVariableDeclarationCheck.cpp
  test/clang-tidy/google-objc-global-variable-declaration.m


Index: test/clang-tidy/google-objc-global-variable-declaration.m
===
--- test/clang-tidy/google-objc-global-variable-declaration.m
+++ test/clang-tidy/google-objc-global-variable-declaration.m
@@ -30,8 +30,16 @@
 // CHECK-FIXES: static NSString* const k_Alpha = @"SecondNotAlpha";
 
 static NSString* const kGood = @"hello";
+static NSString* const XYGood = @"hello";
 static NSString* gMyIntGood = 0;
 
+extern NSString* const GTLServiceErrorDomain;
+
+typedef NS_ENUM(NSInteger, GTLServiceError) {
+  GTLServiceErrorQueryResultMissing = -3000,
+  GTLServiceErrorWaitTimedOut   = -3001,
+};
+
 @implementation Foo
 - (void)f {
 int x = 0;
Index: clang-tidy/google/GlobalVariableDeclarationCheck.cpp
===
--- clang-tidy/google/GlobalVariableDeclarationCheck.cpp
+++ clang-tidy/google/GlobalVariableDeclarationCheck.cpp
@@ -72,7 +72,7 @@
   this);
   Finder->addMatcher(varDecl(hasGlobalStorage(), hasType(isConstQualified()),
  unless(isLocalVariable()),
- unless(matchesName("::k[A-Z]")))
+ unless(matchesName("::(k[A-Z]|[A-Z]{2,})")))
  .bind("global_const"),
  this);
 }
@@ -88,7 +88,8 @@
   if (const auto *Decl = Result.Nodes.getNodeAs("global_const")) {
 diag(Decl->getLocation(),
  "const global variable '%0' must have a name which starts with "
- "'k[A-Z]'")
+ "an appropriate prefix (see "
+ "http://google.github.io/styleguide/objcguide#constants).")
 << Decl->getName() << generateFixItHint(Decl, true);
   }
 }


Index: test/clang-tidy/google-objc-global-variable-declaration.m
===
--- test/clang-tidy/google-objc-global-variable-declaration.m
+++ test/clang-tidy/google-objc-global-variable-declaration.m
@@ -30,8 +30,16 @@
 // CHECK-FIXES: static NSString* const k_Alpha = @"SecondNotAlpha";
 
 static NSString* const kGood = @"hello";
+static NSString* const XYGood = @"hello";
 static NSString* gMyIntGood = 0;
 
+extern NSString* const GTLServiceErrorDomain;
+
+typedef NS_ENUM(NSInteger, GTLServiceError) {
+  GTLServiceErrorQueryResultMissing = -3000,
+  GTLServiceErrorWaitTimedOut   = -3001,
+};
+
 @implementation Foo
 - (void)f {
 int x = 0;
Index: clang-tidy/google/GlobalVariableDeclarationCheck.cpp
===
--- clang-tidy/google/GlobalVariableDeclarationCheck.cpp
+++ clang-tidy/google/GlobalVariableDeclarationCheck.cpp
@@ -72,7 +72,7 @@
   this);
   Finder->addMatcher(varDecl(hasGlobalStorage(), hasType(isConstQualified()),
  unless(isLocalVariable()),
- unless(matchesName("::k[A-Z]")))
+ unless(matchesName("::(k[A-Z]|[A-Z]{2,})")))
  .bind("global_const"),
  this);
 }
@@ -88,7 +88,8 @@
   if (const auto *Decl = Result.Nodes.getNodeAs("global_const")) {
 diag(Decl->getLocation(),
  "const global variable '%0' must have a name which starts with "
- "'k[A-Z]'")
+ "an appropriate prefix (see "
+ "http://google.github.io/styleguide/objcguide#constants).")
 << Decl->getName() << generateFixItHint(Decl, true);
   }
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D34367: CodeGen: Fix address space of indirect function argument

2018-02-22 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 135499.
yaxunl added a comment.

sync to ToT.


https://reviews.llvm.org/D34367

Files:
  lib/CodeGen/CGAtomic.cpp
  lib/CodeGen/CGCall.cpp
  lib/CodeGen/CGCall.h
  lib/CodeGen/CGClass.cpp
  lib/CodeGen/CGDecl.cpp
  lib/CodeGen/CGExprCXX.cpp
  lib/CodeGen/CGGPUBuiltin.cpp
  lib/CodeGen/CGObjCGNU.cpp
  lib/CodeGen/CGObjCMac.cpp
  lib/CodeGen/ItaniumCXXABI.cpp
  lib/CodeGen/MicrosoftCXXABI.cpp
  test/CodeGenCXX/amdgcn-func-arg.cpp
  test/CodeGenOpenCL/addr-space-struct-arg.cl
  test/CodeGenOpenCL/byval.cl

Index: test/CodeGenOpenCL/byval.cl
===
--- test/CodeGenOpenCL/byval.cl
+++ test/CodeGenOpenCL/byval.cl
@@ -1,5 +1,4 @@
 // RUN: %clang_cc1 -emit-llvm -o - -triple amdgcn %s | FileCheck %s
-// RUN: %clang_cc1 -emit-llvm -o - -triple amdgcn---opencl %s | FileCheck %s
 
 struct A {
   int x[100];
Index: test/CodeGenOpenCL/addr-space-struct-arg.cl
===
--- test/CodeGenOpenCL/addr-space-struct-arg.cl
+++ test/CodeGenOpenCL/addr-space-struct-arg.cl
@@ -1,5 +1,6 @@
 // RUN: %clang_cc1 %s -emit-llvm -o - -O0 -finclude-default-header -ffake-address-space-map -triple i686-pc-darwin | FileCheck -enable-var-scope -check-prefixes=COM,X86 %s
 // RUN: %clang_cc1 %s -emit-llvm -o - -O0 -finclude-default-header -triple amdgcn-amdhsa-amd | FileCheck -enable-var-scope -check-prefixes=COM,AMDGCN %s
+// RUN: %clang_cc1 %s -emit-llvm -o - -cl-std=CL2.0 -O0 -finclude-default-header -triple amdgcn-amdhsa-amd | FileCheck -enable-var-scope -check-prefixes=COM,AMDGCN,AMDGCN20 %s
 
 typedef struct {
   int cells[9];
@@ -35,6 +36,9 @@
   int2 y[20];
 };
 
+#if __OPENCL_C_VERSION__ >= 200
+struct LargeStructOneMember g_s;
+#endif
 
 // X86-LABEL: define void @foo(%struct.Mat4X4* noalias sret %agg.result, %struct.Mat3X3* byval align 4 %in)
 // AMDGCN-LABEL: define %struct.Mat4X4 @foo([9 x i32] %in.coerce)
@@ -80,10 +84,42 @@
 }
 
 // AMDGCN-LABEL: define void @FuncOneLargeMember(%struct.LargeStructOneMember addrspace(5)* byval align 8 %u)
+// AMDGCN-NOT: addrspacecast
+// AMDGCN:   store <2 x i32> %{{.*}}, <2 x i32> addrspace(5)*
 void FuncOneLargeMember(struct LargeStructOneMember u) {
   u.x[0] = (int2)(0, 0);
 }
 
+// AMDGCN20-LABEL: define void @test_indirect_arg_globl()
+// AMDGCN20:  %[[byval_temp:.*]] = alloca %struct.LargeStructOneMember, align 8, addrspace(5)
+// AMDGCN20:  %[[r0:.*]] = bitcast %struct.LargeStructOneMember addrspace(5)* %[[byval_temp]] to i8 addrspace(5)*
+// AMDGCN20:  call void @llvm.memcpy.p5i8.p1i8.i64(i8 addrspace(5)* align 8 %[[r0]], i8 addrspace(1)* align 8 bitcast (%struct.LargeStructOneMember addrspace(1)* @g_s to i8 addrspace(1)*), i64 800, i1 false)
+// AMDGCN20:  call void @FuncOneLargeMember(%struct.LargeStructOneMember addrspace(5)* byval align 8 %[[byval_temp]])
+#if __OPENCL_C_VERSION__ >= 200
+void test_indirect_arg_globl(void) {
+  FuncOneLargeMember(g_s);
+}
+#endif
+
+// AMDGCN-LABEL: define amdgpu_kernel void @test_indirect_arg_local()
+// AMDGCN: %[[byval_temp:.*]] = alloca %struct.LargeStructOneMember, align 8, addrspace(5)
+// AMDGCN: %[[r0:.*]] = bitcast %struct.LargeStructOneMember addrspace(5)* %[[byval_temp]] to i8 addrspace(5)*
+// AMDGCN: call void @llvm.memcpy.p5i8.p3i8.i64(i8 addrspace(5)* align 8 %[[r0]], i8 addrspace(3)* align 8 bitcast (%struct.LargeStructOneMember addrspace(3)* @test_indirect_arg_local.l_s to i8 addrspace(3)*), i64 800, i1 false)
+// AMDGCN: call void @FuncOneLargeMember(%struct.LargeStructOneMember addrspace(5)* byval align 8 %[[byval_temp]])
+kernel void test_indirect_arg_local(void) {
+  local struct LargeStructOneMember l_s;
+  FuncOneLargeMember(l_s);
+}
+
+// AMDGCN-LABEL: define void @test_indirect_arg_private()
+// AMDGCN: %[[p_s:.*]] = alloca %struct.LargeStructOneMember, align 8, addrspace(5)
+// AMDGCN-NOT: @llvm.memcpy
+// AMDGCN-NEXT: call void @FuncOneLargeMember(%struct.LargeStructOneMember addrspace(5)* byval align 8 %[[p_s]])
+void test_indirect_arg_private(void) {
+  struct LargeStructOneMember p_s;
+  FuncOneLargeMember(p_s);
+}
+
 // AMDGCN-LABEL: define amdgpu_kernel void @KernelOneMember
 // AMDGCN-SAME:  (<2 x i32> %[[u_coerce:.*]])
 // AMDGCN:  %[[u:.*]] = alloca %struct.StructOneMember, align 8, addrspace(5)
@@ -112,7 +148,6 @@
   u.y[0] = (int2)(0, 0);
 }
 
-
 // AMDGCN-LABEL: define amdgpu_kernel void @KernelTwoMember
 // AMDGCN-SAME:  (%struct.StructTwoMember %[[u_coerce:.*]])
 // AMDGCN:  %[[u:.*]] = alloca %struct.StructTwoMember, align 8, addrspace(5)
Index: test/CodeGenCXX/amdgcn-func-arg.cpp
===
--- /dev/null
+++ test/CodeGenCXX/amdgcn-func-arg.cpp
@@ -0,0 +1,94 @@
+// RUN: %clang_cc1 -O0 -triple amdgcn---amdgiz -emit-llvm %s -o - | FileCheck %s
+
+class A {
+public:
+  int x;
+  A():x(0) {}
+  ~A() {}
+};
+
+class B {
+int x[100];
+};
+
+A g_a;
+B g_b;
+
+void func_with_ref_arg(A );
+void 

[PATCH] D34367: CodeGen: Fix address space of indirect function argument

2018-02-22 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: lib/CodeGen/CGCall.cpp:3446
+  return LV.asAggregateRValue();
+}
+

No, I don't think this is right.  This method should always return an 
independent RValue; if the CallArg is storing an LValue, it should copy from it 
into a temporary.  That means it needs to take a CGF, and it also means you 
can't call it eagerly.



Comment at: lib/CodeGen/CGCall.cpp:3779
+  RV = I->getRValue();
+}
 

For example, all of this is eagerly forcing an RValue, and it needs to be 
delayed so that you can take advantage of having an LValue in the right cases 
below.



Comment at: lib/CodeGen/CGCall.cpp:3814
 EmitInitStoreOfNonAggregate(*this, RV, argLV);
   }
   break;

I think most of this could be replaced with a copyInto(CGF&, Address) method on 
CallArg that just stores/copies the RValue into the destination.  But you might 
need to handle the aggregate-RValue case specially before calling the method, 
because I think what that's expressing is that we're trying to evaluate 
aggregate-RValue arguments directly into the right place in the inalloca 
allocation.


https://reviews.llvm.org/D34367



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


[PATCH] D41228: [ObjC] Enable __strong pointers in structs under ARC

2018-02-22 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: include/clang/AST/Type.h:1121
+  /// after it is moved, as opposed to a truely destructive move in which the
+  /// source object is placed in an uninitialized state.
+  PrimitiveCopyKind isNonTrivialToPrimitiveDestructiveMove() const;

ahatanak wrote:
> rjmccall wrote:
> > "truly"
> > 
> > Hmm.  Now that I'm thinking more about it, I'm not sure there's any point 
> > in tracking non-triviality of a C++-style destructive move separately from 
> > the non-triviality of a copy.  It's hard to imagine that there would ever 
> > be a non-C++ type that primitively has non-trivial copies but trivial 
> > C++-style moves or vice-versa.  Type-based destructors imply that the type 
> > represents some kind of resource, and a C++-style move will always be 
> > non-trivial for resource types because ownership of the resource needs to 
> > be given up by the old location.  Otherwise, a type might be non-trivial to 
> > copy but not destroy because there's something special about how it's 
> > stored (like volatility), but it's hard to imagine what could possibly 
> > cause it to be non-trivial to destroy but not copy.
> > 
> > If we were tracking non-triviality of an *unsafe* destructive move, one 
> > that leaves the source in an uninitialized state, that's quite different.
> > 
> > I think there are three reasonable options here:
> > 
> > - Ignore the argument I just made about the types that we're *likely* to 
> > care about modeling and generalize your tracking to also distinguish 
> > construction from assignment.  In such an environment, I think you can 
> > absolutely make an argument that it's still interesting to track C++-style 
> > moves separately from copies.
> > 
> > - Drop the tracking of destructive moves completely.  If you want to keep 
> > the method around, find, but it can just call 
> > `isNonTrivialToPrimitiveCopy()`.
> > 
> > - Change the tracking of *destructive* moves to instead track 
> > *deinitializing* moves.  The implementation would stop considering 
> > `__strong` types to be non-trivial to move.
> > 
> > But as things stand today, I do not see any point in separately tracking 
> > triviality of C++-style destructive moves.
> The second option seems most reasonable to me. We can always make changes if 
> someone comes up with a type that requires tracking destructive moves 
> separately.
Well, we already have a type that would have a trivial deinitializing move: ARC 
`__strong` pointers.  What we don't have is anything in IRGen that currently 
would take advantage of that fact.  Anyway, I agree that we can wait to start 
tracking this until we add such code to the compiler.



Comment at: lib/CodeGen/CGNonTrivialStruct.cpp:193
+
+TrivialFieldIsVolatile |= FT.isVolatileQualified();
+if (Start == End)

ahatanak wrote:
> rjmccall wrote:
> > ahatanak wrote:
> > > rjmccall wrote:
> > > > I feel like maybe volatile fields should be individually copied instead 
> > > > of being aggregated into a multi-field memcpy.  This is a more natural 
> > > > interpretation of the C volatile rules than we currently do.  In fact, 
> > > > arguably we should really add a PrimitiveCopyKind enumerator for 
> > > > volatile fields (that are otherwise trivially-copyable) and force all 
> > > > copies of structs with volatile fields into this path precisely so that 
> > > > we can make a point of copying the volatile fields this way.  
> > > > (Obviously that part is not something that's your responsibility to do.)
> > > > 
> > > > To get that right with bit-fields, you'll need to propagate the actual 
> > > > FieldDecl down.  On the plus side, that should let you use 
> > > > EmitLValueForField to do the field projection in the common case.
> > > I added method visitVolatileTrivial that copies volatile fields 
> > > individually. Please see test case test_copy_constructor_Bitfield1 in 
> > > test/CodeGenObjC/strong-in-c-struct.m.
> > Okay, great!  I like the name.
> > 
> > Does this mean we're now copying all structs that contain volatile fields 
> > with one of these helper functions?  If so, please add a C test case 
> > testing just that.  Also, you should retitle this review and stress that 
> > we're changing how *all* non-trivial types are copied, and that that 
> > includes both volatile and ARC-qualified fields.
> No, the current patch doesn't copy volatile fields of a struct individually 
> unless the struct is a non-trivial type (which means its primitive copy kind 
> is PCK_Struct). I'll look into today how I can force structs with volatile 
> fields that are not non-trivial to be copied using the helper functions.
> 
> It seems like we would need a boolean flag in RecordDecl that tracks the 
> presence of volatile fields in the struct or one of its subobjects. I assume 
> we want to copy volatile fields individually in C++ too, in which case the 
> flag needs to be set in both C 

[PATCH] D43105: [RISCV] Enable __int128_t and __uint128_t through clang flag

2018-02-22 Thread Mandeep Singh Grang via Phabricator via cfe-commits
mgrang added a comment.

Added tests for ABI lowering and preprocessor defines as per comments.


Repository:
  rC Clang

https://reviews.llvm.org/D43105



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


[PATCH] D43105: [RISCV] Enable __int128_t and __uint128_t through clang flag

2018-02-22 Thread Mandeep Singh Grang via Phabricator via cfe-commits
mgrang updated this revision to Diff 135493.
mgrang retitled this revision from "[RISCV] Enable __int128_t and uint128_t 
through clang flag" to "[RISCV] Enable __int128_t and __uint128_t through clang 
flag".
mgrang edited the summary of this revision.

Repository:
  rC Clang

https://reviews.llvm.org/D43105

Files:
  include/clang/Basic/TargetInfo.h
  include/clang/Basic/TargetOptions.h
  include/clang/Driver/Options.td
  lib/Basic/Targets/Mips.h
  lib/Driver/ToolChains/Clang.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGen/riscv32-abi.c
  test/Driver/types.c
  test/Preprocessor/init.c

Index: test/Preprocessor/init.c
===
--- test/Preprocessor/init.c
+++ test/Preprocessor/init.c
@@ -10210,6 +10210,11 @@
 // RISCV32-LINUX: #define linux 1
 // RISCV32-LINUX: #define unix 1
 
+// RUN: %clang_cc1 -E -dM -ffreestanding \
+// RUN: -triple=riscv32 -fforce-enable-int128 < /dev/null \
+// RUN:   | FileCheck -match-full-lines -check-prefix=RISCV32-INT128 %s
+// RISCV32-INT128: #define __SIZEOF_INT128__ 16
+
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=riscv64 < /dev/null \
 // RUN:   | FileCheck -match-full-lines -check-prefix=RISCV64 %s
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=riscv64-unknown-linux < /dev/null \
Index: test/Driver/types.c
===
--- /dev/null
+++ test/Driver/types.c
@@ -0,0 +1,18 @@
+// Check whether __int128_t and __uint128_t are supported.
+
+// RUN: not %clang -c --target=riscv32-unknown-linux-gnu -fsyntax-only %s \
+// RUN: 2>&1 | FileCheck %s
+
+// RUN: %clang -c --target=riscv32-unknown-linux-gnu -fsyntax-only %s \
+// RUN: -fno-force-enable-int128 -fforce-enable-int128
+
+// RUN: not %clang -c --target=riscv32-unknown-linux-gnu -fsyntax-only %s \
+// RUN: -fforce-enable-int128 -fno-force-enable-int128
+
+void a() {
+  __int128_t s;
+  __uint128_t t;
+}
+
+// CHECK: error: use of undeclared identifier '__int128_t'
+// CHECK: error: use of undeclared identifier '__uint128_t'
Index: test/CodeGen/riscv32-abi.c
===
--- test/CodeGen/riscv32-abi.c
+++ test/CodeGen/riscv32-abi.c
@@ -421,3 +421,10 @@
 
   return ret;
 }
+
+// RUN: %clang_cc1 -triple riscv32 -fforce-enable-int128 \
+// RUN: -emit-llvm %s -o - | FileCheck %s -check-prefix=CHECK-FORCEINT128-LABEL
+#ifdef __SIZEOF_INT128__
+// CHECK-FORCEINT128-LABEL: define i128 @f_scalar_5(i128 %x)
+__int128_t f_scalar_5(__int128_t x) { return x; }
+#endif
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -2765,6 +2765,7 @@
   if (Opts.Triple.empty())
 Opts.Triple = llvm::sys::getDefaultTargetTriple();
   Opts.OpenCLExtensionsAsWritten = Args.getAllArgValues(OPT_cl_ext_EQ);
+  Opts.ForceEnableInt128 = Args.hasArg(OPT_fforce_enable_int128);
 }
 
 bool CompilerInvocation::CreateFromArgs(CompilerInvocation ,
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -4725,6 +4725,12 @@
 }
   }
 
+  if (Arg *A = Args.getLastArg(options::OPT_fforce_enable_int128,
+   options::OPT_fno_force_enable_int128)) {
+if (A->getOption().matches(options::OPT_fforce_enable_int128))
+  CmdArgs.push_back("-fforce-enable-int128");
+  }
+
   // Finally add the compile command to the compilation.
   if (Args.hasArg(options::OPT__SLASH_fallback) &&
   Output.getType() == types::TY_Object &&
Index: lib/Basic/Targets/Mips.h
===
--- lib/Basic/Targets/Mips.h
+++ lib/Basic/Targets/Mips.h
@@ -387,7 +387,9 @@
 return llvm::makeArrayRef(NewABIRegAliases);
   }
 
-  bool hasInt128Type() const override { return ABI == "n32" || ABI == "n64"; }
+  bool hasInt128Type() const override {
+return (ABI == "n32" || ABI == "n64") || getTargetOpts().ForceEnableInt128;
+  }
 
   bool validateTarget(DiagnosticsEngine ) const override;
 };
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -839,6 +839,12 @@
 def fjump_tables : Flag<["-"], "fjump-tables">, Group;
 def fno_jump_tables : Flag<["-"], "fno-jump-tables">, Group, Flags<[CC1Option]>,
   HelpText<"Do not use jump tables for lowering switches">;
+def fforce_enable_int128 : Flag<["-"], "fforce-enable-int128">,
+  Group, Flags<[CC1Option]>,
+  HelpText<"Enable support for int128_t type">;
+def fno_force_enable_int128 : Flag<["-"], "fno-force-enable-int128">,
+  Group, Flags<[CC1Option]>,
+  HelpText<"Disable support for int128_t type">;
 
 // Begin sanitizer flags. These should all be core options exposed in all driver
 // 

[PATCH] D43581: [clang-tidy/google] Fix the Objective-C global variable declaration check 

2018-02-22 Thread Yan Zhang via Phabricator via cfe-commits
Wizard accepted this revision.
Wizard added a comment.
This revision is now accepted and ready to land.

In https://reviews.llvm.org/D43581#1016318, @stephanemoore wrote:

> In https://reviews.llvm.org/D43581#1016300, @Wizard wrote:
>
> > Please update the warning info to indicate that prefix 'k' is not the only 
> > option for constants. Something like:
> >  "const global variable '%0' must have an appropriate prefix or a name 
> > which starts with 'k[A-Z]'"
>
>
> Is the latest warning info satisfactory? I believe I updated it after adding 
> you as a reviewer.


Hmm I feel it is a bit unfriendly to show users a rather complicated regex in 
the info, but I will leave it to you. Not a big problem.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D43581



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


[PATCH] D43513: [OpenMP] Limit reduction support for pragma 'distribute' when combined with pragma 'simd'

2018-02-22 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL325822: [OpenMP] Limit reduction support for pragma 
distribute when combined with… (authored by cbertol, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D43513?vs=135429=135491#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D43513

Files:
  cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
  cfe/trunk/test/OpenMP/distribute_parallel_for_reduction_codegen.cpp

Index: cfe/trunk/test/OpenMP/distribute_parallel_for_reduction_codegen.cpp
===
--- cfe/trunk/test/OpenMP/distribute_parallel_for_reduction_codegen.cpp
+++ cfe/trunk/test/OpenMP/distribute_parallel_for_reduction_codegen.cpp
@@ -0,0 +1,84 @@
+// Test host code gen
+
+// RUN: %clang_cc1  -verify -fopenmp -fopenmp-version=45 -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-64
+// RUN: %clang_cc1  -fopenmp -fopenmp-version=45 -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-pch -o %t %s
+// RUN: %clang_cc1  -fopenmp -fopenmp-version=45 -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-64
+// RUN: %clang_cc1  -verify -fopenmp -fopenmp-version=45 -x c++ -std=c++11 -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-llvm %s -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-32
+// RUN: %clang_cc1  -fopenmp -fopenmp-version=45 -x c++ -std=c++11 -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-pch -o %t %s
+// RUN: %clang_cc1  -fopenmp -fopenmp-version=45 -x c++ -std=c++11 -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-32
+
+// RUN: %clang_cc1  -verify -fopenmp-simd -fopenmp-version=45 -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY1 %s
+// RUN: %clang_cc1  -fopenmp-simd -fopenmp-version=45 -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-pch -o %t %s
+// RUN: %clang_cc1  -fopenmp-simd -fopenmp-version=45 -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY1 %s
+// RUN: %clang_cc1  -verify -fopenmp-simd -fopenmp-version=45 -x c++ -std=c++11 -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY1 %s
+// RUN: %clang_cc1  -fopenmp-simd -fopenmp-version=45 -x c++ -std=c++11 -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-pch -o %t %s
+// RUN: %clang_cc1  -fopenmp-simd -fopenmp-version=45 -x c++ -std=c++11 -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY1 %s
+// SIMD-ONLY1-NOT: {{__kmpc|__tgt}}
+// expected-no-diagnostics
+#ifndef HEADER
+#define HEADER
+
+
+template 
+T tmain(T ) {
+  int n = 1000;  
+  // schedule: dynamic chunk
+  #pragma omp target map(tofrom:r)
+  #pragma omp teams
+  #pragma omp distribute parallel for reduction(+:r)
+  for (int i = 0; i < n; ++i)
+r += (T)i;  
+
+  return r;
+}
+
+int main() {
+  int n = 1000;
+  int r = 0;
+  #pragma omp target map(tofrom:r)
+  #pragma omp teams
+  #pragma omp distribute parallel for reduction(+:r)
+  for (int i = 0; i < n; ++i)
+r += i;
+
+  return tmain(r);
+}
+
+// CHECK-LABEL: main
+// CHECK: call{{.+}} @__tgt_target_teams(
+// CHECK: call void [[OFFL:@.+]](
+// CHECK: call{{.+}} [[TMAIN:@.+]](i{{32|64}}
+// CHECK: ret
+
+// CHECK: define{{.+}} [[OFFL]](
+// CHECK: call{{.+}} @__kmpc_fork_teams({{.+}}, {{.+}}, {{.+}} [[TEOUTL:@.+]] to{{.+}}
+// CHECK: ret void
+
+// CHECK: define{{.+}} [[TEOUTL]](
+// CHECK: call{{.+}} @__kmpc_fork_call({{.+}}, {{.+}}, {{.+}} [[PAROUTL:@.+]] to{{.+}}
+// CHECK: ret void
+
+// CHECK: define{{.+}} [[PAROUTL]](
+// CHECK: call{{.+}} @__kmpc_reduce_nowait(
+// CHECK: call{{.+}} @__kmpc_end_reduce_nowait(
+// CHECK: ret void
+
+// CHECK: define{{.+}} [[TMAIN]](i{{32|64}}
+// CHECK: call{{.+}} @__tgt_target_teams(
+// CHECK: call void [[TOFFL:@.+]](
+// CHECK: ret
+
+// CHECK: define{{.+}} [[TOFFL]](
+// CHECK: call{{.+}} @__kmpc_fork_teams({{.+}}, {{.+}}, {{.+}} [[TEMPLTEOUTL:@.+]] to{{.+}}
+// CHECK: ret void
+
+// CHECK: define{{.+}} [[TEMPLTEOUTL]](
+// CHECK: call{{.+}} @__kmpc_fork_call({{.+}}, {{.+}}, {{.+}} [[TPAROUTL:@.+]] to{{.+}}
+// CHECK: ret void
+
+// CHECK: define{{.+}} 

r325822 - [OpenMP] Limit reduction support for pragma 'distribute' when combined with pragma 'simd'

2018-02-22 Thread Carlo Bertolli via cfe-commits
Author: cbertol
Date: Thu Feb 22 11:38:14 2018
New Revision: 325822

URL: http://llvm.org/viewvc/llvm-project?rev=325822=rev
Log:
[OpenMP] Limit reduction support for pragma 'distribute' when combined with 
pragma 'simd'

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

This is a bug fix that removes the emission of reduction support for pragma 
'distribute' when found alone or in combinations without simd.
Pragma 'distribute' does not have a reduction clause, but when combined with 
pragma 'simd' we need to emit the support for simd's reduction clause as part 
of code generation for distribute. This guard is similar to the one used for 
reduction support earlier in the same code gen function.



Added:
cfe/trunk/test/OpenMP/distribute_parallel_for_reduction_codegen.cpp
Modified:
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp

Modified: cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp?rev=325822=325821=325822=diff
==
--- cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp Thu Feb 22 11:38:14 2018
@@ -3358,26 +3358,30 @@ void CodeGenFunction::EmitOMPDistributeL
   CGF.EmitLoadOfScalar(IL, S.getLocStart()));
 });
   }
-  OpenMPDirectiveKind ReductionKind = OMPD_unknown;
-  if (isOpenMPParallelDirective(S.getDirectiveKind()) &&
-  isOpenMPSimdDirective(S.getDirectiveKind())) {
-ReductionKind = OMPD_parallel_for_simd;
-  } else if (isOpenMPParallelDirective(S.getDirectiveKind())) {
-ReductionKind = OMPD_parallel_for;
-  } else if (isOpenMPSimdDirective(S.getDirectiveKind())) {
-ReductionKind = OMPD_simd;
-  } else if (!isOpenMPTeamsDirective(S.getDirectiveKind()) &&
- S.hasClausesOfKind()) {
-llvm_unreachable(
-"No reduction clauses is allowed in distribute directive.");
+  if (isOpenMPSimdDirective(S.getDirectiveKind()) &&
+  !isOpenMPParallelDirective(S.getDirectiveKind()) &&
+  !isOpenMPTeamsDirective(S.getDirectiveKind())) {
+OpenMPDirectiveKind ReductionKind = OMPD_unknown;
+if (isOpenMPParallelDirective(S.getDirectiveKind()) &&
+isOpenMPSimdDirective(S.getDirectiveKind())) {
+  ReductionKind = OMPD_parallel_for_simd;
+} else if (isOpenMPParallelDirective(S.getDirectiveKind())) {
+  ReductionKind = OMPD_parallel_for;
+} else if (isOpenMPSimdDirective(S.getDirectiveKind())) {
+  ReductionKind = OMPD_simd;
+} else if (!isOpenMPTeamsDirective(S.getDirectiveKind()) &&
+   S.hasClausesOfKind()) {
+  llvm_unreachable(
+  "No reduction clauses is allowed in distribute directive.");
+}
+EmitOMPReductionClauseFinal(S, ReductionKind);
+// Emit post-update of the reduction variables if IsLastIter != 0.
+emitPostUpdateForReductionClause(
+*this, S, [&](CodeGenFunction ) -> llvm::Value * {
+  return CGF.Builder.CreateIsNotNull(
+  CGF.EmitLoadOfScalar(IL, S.getLocStart()));
+});
   }
-  EmitOMPReductionClauseFinal(S, ReductionKind);
-  // Emit post-update of the reduction variables if IsLastIter != 0.
-  emitPostUpdateForReductionClause(
-  *this, S, [&](CodeGenFunction ) -> llvm::Value * {
-return CGF.Builder.CreateIsNotNull(
-CGF.EmitLoadOfScalar(IL, S.getLocStart()));
-  });
   // Emit final copy of the lastprivate variables if IsLastIter != 0.
   if (HasLastprivateClause) {
 EmitOMPLastprivateClauseFinal(

Added: cfe/trunk/test/OpenMP/distribute_parallel_for_reduction_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/distribute_parallel_for_reduction_codegen.cpp?rev=325822=auto
==
--- cfe/trunk/test/OpenMP/distribute_parallel_for_reduction_codegen.cpp (added)
+++ cfe/trunk/test/OpenMP/distribute_parallel_for_reduction_codegen.cpp Thu Feb 
22 11:38:14 2018
@@ -0,0 +1,84 @@
+// Test host code gen
+
+// RUN: %clang_cc1  -verify -fopenmp -fopenmp-version=45 -x c++ -std=c++11 
-triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-emit-llvm %s -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-64
+// RUN: %clang_cc1  -fopenmp -fopenmp-version=45 -x c++ -std=c++11 -triple 
powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-emit-pch -o %t %s
+// RUN: %clang_cc1  -fopenmp -fopenmp-version=45 -x c++ -triple 
powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s 
--check-prefix CHECK --check-prefix CHECK-64
+// RUN: %clang_cc1  -verify -fopenmp -fopenmp-version=45 -x c++ -std=c++11 
-triple 

[PATCH] D43640: add support for constants with appropriate prefix. Start with 'k' is not the only option. This is according to http://google.github.io/styleguide/objcguide.html#constants

2018-02-22 Thread Yan Zhang via Phabricator via cfe-commits
Wizard updated this revision to Diff 135485.
Wizard added a comment.

fix format


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D43640

Files:
  clang-tidy/google/GlobalVariableDeclarationCheck.cpp
  test/clang-tidy/google-objc-global-variable-declaration.m


Index: test/clang-tidy/google-objc-global-variable-declaration.m
===
--- test/clang-tidy/google-objc-global-variable-declaration.m
+++ test/clang-tidy/google-objc-global-variable-declaration.m
@@ -2,7 +2,7 @@
 
 @class NSString;
 static NSString* const myConstString = @"hello";
-// CHECK-MESSAGES: :[[@LINE-1]]:24: warning: const global variable 
'myConstString' must have a name which starts with 'k[A-Z]' 
[google-objc-global-variable-declaration]
+// CHECK-MESSAGES: :[[@LINE-1]]:24: warning: const global variable 
'myConstString' must have an appropriate prefix or a name which starts with 
'k[A-Z]' [google-objc-global-variable-declaration]
 // CHECK-FIXES: static NSString* const kMyConstString = @"hello";
 
 static NSString* MyString = @"hi";
@@ -22,14 +22,15 @@
 // CHECK-FIXES: static NSString* gNoDef;
 
 static NSString* const _notAlpha = @"NotBeginWithAlpha";
-// CHECK-MESSAGES: :[[@LINE-1]]:24: warning: const global variable '_notAlpha' 
must have a name which starts with 'k[A-Z]' 
[google-objc-global-variable-declaration]
+// CHECK-MESSAGES: :[[@LINE-1]]:24: warning: const global variable '_notAlpha' 
must have an appropriate prefix or a name which starts with 'k[A-Z]' 
[google-objc-global-variable-declaration]
 // CHECK-FIXES: static NSString* const _notAlpha = @"NotBeginWithAlpha";
 
 static NSString* const k_Alpha = @"SecondNotAlpha";
-// CHECK-MESSAGES: :[[@LINE-1]]:24: warning: const global variable 'k_Alpha' 
must have a name which starts with 'k[A-Z]' 
[google-objc-global-variable-declaration]
+// CHECK-MESSAGES: :[[@LINE-1]]:24: warning: const global variable 'k_Alpha' 
must have an appropriate prefix or a name which starts with 'k[A-Z]' 
[google-objc-global-variable-declaration]
 // CHECK-FIXES: static NSString* const k_Alpha = @"SecondNotAlpha";
 
 static NSString* const kGood = @"hello";
+static NSString* const ABCGood = @"I have a prefix";
 static NSString* gMyIntGood = 0;
 
 @implementation Foo
Index: clang-tidy/google/GlobalVariableDeclarationCheck.cpp
===
--- clang-tidy/google/GlobalVariableDeclarationCheck.cpp
+++ clang-tidy/google/GlobalVariableDeclarationCheck.cpp
@@ -24,15 +24,15 @@
 
 namespace {
 
-AST_MATCHER(VarDecl, isLocalVariable) {
-  return Node.isLocalVarDecl();
+AST_MATCHER(VarDecl, isLocalVariable) { 
+  return Node.isLocalVarDecl(); 
 }
 
 FixItHint generateFixItHint(const VarDecl *Decl, bool IsConst) {
   char FC = Decl->getName()[0];
   if (!llvm::isAlpha(FC) || Decl->getName().size() == 1) {
 // No fix available if first character is not alphabetical character, or it
-// is a single-character variable, since it is difficult to determine the 
+// is a single-character variable, since it is difficult to determine the
 // proper fix in this case. Users should create a proper variable name by
 // their own.
 return FixItHint();
@@ -72,7 +72,7 @@
   this);
   Finder->addMatcher(varDecl(hasGlobalStorage(), hasType(isConstQualified()),
  unless(isLocalVariable()),
- unless(matchesName("::k[A-Z]")))
+ unless(matchesName("::(k|[A-Z]{2,})[A-Z]")))
  .bind("global_const"),
  this);
 }
@@ -87,8 +87,8 @@
   }
   if (const auto *Decl = Result.Nodes.getNodeAs("global_const")) {
 diag(Decl->getLocation(),
- "const global variable '%0' must have a name which starts with "
- "'k[A-Z]'")
+ "const global variable '%0' must have an appropriate prefix or a name 
"
+ "which starts with 'k[A-Z]'")
 << Decl->getName() << generateFixItHint(Decl, true);
   }
 }


Index: test/clang-tidy/google-objc-global-variable-declaration.m
===
--- test/clang-tidy/google-objc-global-variable-declaration.m
+++ test/clang-tidy/google-objc-global-variable-declaration.m
@@ -2,7 +2,7 @@
 
 @class NSString;
 static NSString* const myConstString = @"hello";
-// CHECK-MESSAGES: :[[@LINE-1]]:24: warning: const global variable 'myConstString' must have a name which starts with 'k[A-Z]' [google-objc-global-variable-declaration]
+// CHECK-MESSAGES: :[[@LINE-1]]:24: warning: const global variable 'myConstString' must have an appropriate prefix or a name which starts with 'k[A-Z]' [google-objc-global-variable-declaration]
 // CHECK-FIXES: static NSString* const kMyConstString = @"hello";
 
 static NSString* MyString = @"hi";
@@ -22,14 +22,15 @@
 // CHECK-FIXES: static NSString* gNoDef;
 
 static NSString* const _notAlpha = @"NotBeginWithAlpha";
-// 

[PATCH] D43602: [CUDA] Added missing functions.

2018-02-22 Thread Artem Belevich via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC325814: [CUDA] Added missing functions. (authored by tra, 
committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D43602?vs=135348=135466#toc

Repository:
  rC Clang

https://reviews.llvm.org/D43602

Files:
  lib/Headers/__clang_cuda_device_functions.h


Index: lib/Headers/__clang_cuda_device_functions.h
===
--- lib/Headers/__clang_cuda_device_functions.h
+++ lib/Headers/__clang_cuda_device_functions.h
@@ -687,6 +687,10 @@
 __DEVICE__ float __ull2float_rz(unsigned long long __a) {
   return __nv_ull2float_rz(__a);
 }
+__DEVICE__ unsigned long long __ullAtomicAdd(unsigned long long *__p,
+ unsigned long long __v) {
+  return __nvvm_atom_add_gen_ll((long long *)__p, __v);
+}
 __DEVICE__ unsigned long long __ullAtomicAdd_block(unsigned long long *__p,
unsigned long long __v) {
   return __nvvm_atom_cta_add_gen_ll((long long *)__p, __v);
@@ -707,6 +711,11 @@
 unsigned long long __v) {
   return __nvvm_atom_sys_and_gen_ll((long long *)__p, __v);
 }
+__DEVICE__ unsigned long long __ullAtomicCAS(unsigned long long *__p,
+ unsigned long long __cmp,
+ unsigned long long __v) {
+  return __nvvm_atom_cas_gen_ll((long long *)__p, __cmp, __v);
+}
 __DEVICE__ unsigned long long __ullAtomicCAS_block(unsigned long long *__p,
unsigned long long __cmp,
unsigned long long __v) {
@@ -717,6 +726,10 @@
 unsigned long long __v) {
   return __nvvm_atom_sys_cas_gen_ll((long long *)__p, __cmp, __v);
 }
+__DEVICE__ unsigned long long __ullAtomicExch(unsigned long long *__p,
+  unsigned long long __v) {
+  return __nvvm_atom_xchg_gen_ll((long long *)__p, __v);
+}
 __DEVICE__ unsigned long long __ullAtomicExch_block(unsigned long long *__p,
 unsigned long long __v) {
   return __nvvm_atom_cta_xchg_gen_ll((long long *)__p, __v);
@@ -1123,10 +1136,16 @@
 __DEVICE__ float j1f(float __a) { return __nv_j1f(__a); }
 __DEVICE__ double jn(int __n, double __a) { return __nv_jn(__n, __a); }
 __DEVICE__ float jnf(int __n, float __a) { return __nv_jnf(__n, __a); }
+#if defined(__LP64__)
+__DEVICE__ long labs(long __a) { return llabs(__a); };
+#else
+__DEVICE__ long labs(long __a) { return __nv_abs(__a); };
+#endif
 __DEVICE__ double ldexp(double __a, int __b) { return __nv_ldexp(__a, __b); }
 __DEVICE__ float ldexpf(float __a, int __b) { return __nv_ldexpf(__a, __b); }
 __DEVICE__ double lgamma(double __a) { return __nv_lgamma(__a); }
 __DEVICE__ float lgammaf(float __a) { return __nv_lgammaf(__a); }
+__DEVICE__ long long llabs(long long __a) { return __nv_llabs(__a); }
 __DEVICE__ long long llmax(long long __a, long long __b) {
   return __nv_llmax(__a, __b);
 }
@@ -1267,6 +1286,9 @@
   return scalbnf(__a, (int)__b);
 }
 __DEVICE__ double sin(double __a) { return __nv_sin(__a); }
+__DEVICE__ void sincos(double __a, double *__sptr, double *__cptr) {
+  return __nv_sincos(__a, __sptr, __cptr);
+}
 __DEVICE__ void sincosf(float __a, float *__sptr, float *__cptr) {
   return __FAST_OR_SLOW(__nv_fast_sincosf, __nv_sincosf)(__a, __sptr, __cptr);
 }


Index: lib/Headers/__clang_cuda_device_functions.h
===
--- lib/Headers/__clang_cuda_device_functions.h
+++ lib/Headers/__clang_cuda_device_functions.h
@@ -687,6 +687,10 @@
 __DEVICE__ float __ull2float_rz(unsigned long long __a) {
   return __nv_ull2float_rz(__a);
 }
+__DEVICE__ unsigned long long __ullAtomicAdd(unsigned long long *__p,
+ unsigned long long __v) {
+  return __nvvm_atom_add_gen_ll((long long *)__p, __v);
+}
 __DEVICE__ unsigned long long __ullAtomicAdd_block(unsigned long long *__p,
unsigned long long __v) {
   return __nvvm_atom_cta_add_gen_ll((long long *)__p, __v);
@@ -707,6 +711,11 @@
 unsigned long long __v) {
   return __nvvm_atom_sys_and_gen_ll((long long *)__p, __v);
 }
+__DEVICE__ unsigned long long __ullAtomicCAS(unsigned long long *__p,
+ unsigned long long __cmp,
+ unsigned long long __v) {
+  return __nvvm_atom_cas_gen_ll((long long *)__p, __cmp, __v);
+}
 __DEVICE__ unsigned long long __ullAtomicCAS_block(unsigned long long *__p,
unsigned long long __cmp,
 

[PATCH] D43533: [CFG] [analyzer] NFC: Refactor ConstructionContext into a finite set of cases.

2018-02-22 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments.



Comment at: include/clang/Analysis/ConstructionContext.h:119
+  static const ConstructionContext *
+  finalize(BumpVectorContext , const ConstructionContextLayer *TopLayer);
+

a.sidorin wrote:
> Maybe just `build()`? For me, `finalize()` strongly associates with Java's 
> broken clean-up mechanism.
Renamed into `createFromLayers()`.



Comment at: lib/Analysis/CFG.cpp:4737
+}
+case ConstructionContext::SimpleVariableKind: {
+  const auto *DSCC = cast(CC);

dcoughlin wrote:
> Eventually (not now) I think it would be great to include the construction 
> context kind in the printed CFG. This would make it easier to understand at a 
> glance the context.
Yeah, the only reason i don't do verbose printing is because changes in tests 
are massive.



Comment at: lib/Analysis/ConstructionContext.cpp:49
+  // patterns.
+  if (const Stmt *S = TopLayer->getTriggerStmt()) {
+if (const auto *DS = dyn_cast(S)) {

dcoughlin wrote:
> I like how this puts all the messy pattern matching in one place. The follows 
> the general LLVM guidelines of "if it has to be messy, put it all in one 
> place and hide the messiness from everything else".
Actually two places, the other one being `findConstructionContext()`.


https://reviews.llvm.org/D43533



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


[PATCH] D43581: [clang-tidy/google] Fix the Objective-C global variable declaration check 

2018-02-22 Thread Stephane Moore via Phabricator via cfe-commits
stephanemoore added a comment.

In https://reviews.llvm.org/D43581#1016300, @Wizard wrote:

> Please update the warning info to indicate that prefix 'k' is not the only 
> option for constants. Something like:
>  "const global variable '%0' must have an appropriate prefix or a name which 
> starts with 'k[A-Z]'"


Is the latest warning info satisfactory? I believe I updated it after adding 
you as a reviewer.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D43581



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


[PATCH] D34367: CodeGen: Fix address space of indirect function argument

2018-02-22 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 135474.
yaxunl added a comment.

Revised by John's comments.


https://reviews.llvm.org/D34367

Files:
  lib/CodeGen/CGAtomic.cpp
  lib/CodeGen/CGCall.cpp
  lib/CodeGen/CGCall.h
  lib/CodeGen/CGClass.cpp
  lib/CodeGen/CGDecl.cpp
  lib/CodeGen/CGExprCXX.cpp
  lib/CodeGen/CGGPUBuiltin.cpp
  lib/CodeGen/CGObjCGNU.cpp
  lib/CodeGen/CGObjCMac.cpp
  lib/CodeGen/ItaniumCXXABI.cpp
  lib/CodeGen/MicrosoftCXXABI.cpp
  test/CodeGenCXX/amdgcn-func-arg.cpp
  test/CodeGenOpenCL/addr-space-struct-arg.cl
  test/CodeGenOpenCL/byval.cl

Index: test/CodeGenOpenCL/byval.cl
===
--- test/CodeGenOpenCL/byval.cl
+++ test/CodeGenOpenCL/byval.cl
@@ -1,5 +1,4 @@
 // RUN: %clang_cc1 -emit-llvm -o - -triple amdgcn %s | FileCheck %s
-// RUN: %clang_cc1 -emit-llvm -o - -triple amdgcn---opencl %s | FileCheck %s
 
 struct A {
   int x[100];
Index: test/CodeGenOpenCL/addr-space-struct-arg.cl
===
--- test/CodeGenOpenCL/addr-space-struct-arg.cl
+++ test/CodeGenOpenCL/addr-space-struct-arg.cl
@@ -1,5 +1,6 @@
 // RUN: %clang_cc1 %s -emit-llvm -o - -O0 -finclude-default-header -ffake-address-space-map -triple i686-pc-darwin | FileCheck -enable-var-scope -check-prefixes=COM,X86 %s
-// RUN: %clang_cc1 %s -emit-llvm -o - -O0 -finclude-default-header -triple amdgcn-amdhsa-amd-amdgizcl | FileCheck -enable-var-scope -check-prefixes=COM,AMD %s
+// RUN: %clang_cc1 %s -emit-llvm -o - -O0 -finclude-default-header -triple amdgcn-amdhsa-amd | FileCheck -enable-var-scope -check-prefixes=COM,AMDGCN %s
+// RUN: %clang_cc1 %s -emit-llvm -o - -cl-std=CL2.0 -O0 -finclude-default-header -triple amdgcn-amdhsa-amd | FileCheck -enable-var-scope -check-prefixes=COM,AMDGCN,AMDGCN20 %s
 
 typedef struct {
   int cells[9];
@@ -35,9 +36,12 @@
   int2 y[20];
 };
 
+#if __OPENCL_C_VERSION__ >= 200
+struct LargeStructOneMember g_s;
+#endif
 
 // X86-LABEL: define void @foo(%struct.Mat4X4* noalias sret %agg.result, %struct.Mat3X3* byval align 4 %in)
-// AMD-LABEL: define %struct.Mat4X4 @foo([9 x i32] %in.coerce)
+// AMDGCN-LABEL: define %struct.Mat4X4 @foo([9 x i32] %in.coerce)
 Mat4X4 __attribute__((noinline)) foo(Mat3X3 in) {
   Mat4X4 out;
   return out;
@@ -49,15 +53,15 @@
 // X86: call void @llvm.memcpy.p0i8.p1i8.i32(i8*
 // X86: call void @llvm.memcpy.p1i8.p0i8.i32(i8 addrspace(1)*
 
-// AMD: load [9 x i32], [9 x i32] addrspace(1)*
-// AMD: call %struct.Mat4X4 @foo([9 x i32]
-// AMD: call void @llvm.memcpy.p1i8.p5i8.i64(i8 addrspace(1)*
+// AMDGCN: load [9 x i32], [9 x i32] addrspace(1)*
+// AMDGCN: call %struct.Mat4X4 @foo([9 x i32]
+// AMDGCN: call void @llvm.memcpy.p1i8.p5i8.i64(i8 addrspace(1)*
 kernel void ker(global Mat3X3 *in, global Mat4X4 *out) {
   out[0] = foo(in[1]);
 }
 
 // X86-LABEL: define void @foo_large(%struct.Mat64X64* noalias sret %agg.result, %struct.Mat32X32* byval align 4 %in)
-// AMD-LABEL: define void @foo_large(%struct.Mat64X64 addrspace(5)* noalias sret %agg.result, %struct.Mat32X32 addrspace(5)* byval align 4 %in)
+// AMDGCN-LABEL: define void @foo_large(%struct.Mat64X64 addrspace(5)* noalias sret %agg.result, %struct.Mat32X32 addrspace(5)* byval align 4 %in)
 Mat64X64 __attribute__((noinline)) foo_large(Mat32X32 in) {
   Mat64X64 out;
   return out;
@@ -68,66 +72,97 @@
 // the return value.
 // X86: call void @llvm.memcpy.p0i8.p1i8.i32(i8*
 // X86: call void @llvm.memcpy.p1i8.p0i8.i32(i8 addrspace(1)*
-// AMD: call void @llvm.memcpy.p5i8.p1i8.i64(i8 addrspace(5)*
-// AMD: call void @llvm.memcpy.p1i8.p5i8.i64(i8 addrspace(1)*
+// AMDGCN: call void @llvm.memcpy.p5i8.p1i8.i64(i8 addrspace(5)*
+// AMDGCN: call void @llvm.memcpy.p1i8.p5i8.i64(i8 addrspace(1)*
 kernel void ker_large(global Mat32X32 *in, global Mat64X64 *out) {
   out[0] = foo_large(in[1]);
 }
 
-// AMD-LABEL: define void @FuncOneMember(<2 x i32> %u.coerce)
+// AMDGCN-LABEL: define void @FuncOneMember(<2 x i32> %u.coerce)
 void FuncOneMember(struct StructOneMember u) {
   u.x = (int2)(0, 0);
 }
 
-// AMD-LABEL: define void @FuncOneLargeMember(%struct.LargeStructOneMember addrspace(5)* byval align 8 %u)
+// AMDGCN-LABEL: define void @FuncOneLargeMember(%struct.LargeStructOneMember addrspace(5)* byval align 8 %u)
+// AMDGCN-NOT: addrspacecast
+// AMDGCN:   store <2 x i32> %{{.*}}, <2 x i32> addrspace(5)*
 void FuncOneLargeMember(struct LargeStructOneMember u) {
   u.x[0] = (int2)(0, 0);
 }
 
-// AMD-LABEL: define amdgpu_kernel void @KernelOneMember
-// AMD-SAME:  (<2 x i32> %[[u_coerce:.*]])
-// AMD:  %[[u:.*]] = alloca %struct.StructOneMember, align 8, addrspace(5)
-// AMD:  %[[coerce_dive:.*]] = getelementptr inbounds %struct.StructOneMember, %struct.StructOneMember addrspace(5)* %[[u]], i32 0, i32 0
-// AMD:  store <2 x i32> %[[u_coerce]], <2 x i32> addrspace(5)* %[[coerce_dive]]
-// AMD:  call void @FuncOneMember(<2 x i32>
+// AMDGCN20-LABEL: define void @test_indirect_arg_globl()
+// AMDGCN20:  %[[byval_temp:.*]] 

[PATCH] D43533: [CFG] [analyzer] NFC: Refactor ConstructionContext into a finite set of cases.

2018-02-22 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ updated this revision to Diff 135480.
NoQ added a comment.

Address comments.


https://reviews.llvm.org/D43533

Files:
  include/clang/Analysis/CFG.h
  include/clang/Analysis/ConstructionContext.h
  lib/Analysis/CFG.cpp
  lib/Analysis/CMakeLists.txt
  lib/Analysis/ConstructionContext.cpp
  lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
  lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp

Index: lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
===
--- lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
+++ lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
@@ -16,6 +16,7 @@
 #include "clang/AST/CXXInheritance.h"
 #include "clang/AST/DeclCXX.h"
 #include "clang/Analysis/Analyses/LiveVariables.h"
+#include "clang/Analysis/ConstructionContext.h"
 #include "clang/StaticAnalyzer/Core/CheckerManager.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h"
 #include "llvm/ADT/SmallSet.h"
@@ -635,10 +636,11 @@
 
 const CXXConstructExpr *CtorExpr = Ctor.getOriginExpr();
 
-auto CC = getCurrentCFGElement().getAs();
-const Stmt *ParentExpr = CC ? CC->getTriggerStmt() : nullptr;
+auto CCE = getCurrentCFGElement().getAs();
+const ConstructionContext *CC = CCE ? CCE->getConstructionContext()
+: nullptr;
 
-if (ParentExpr && isa(ParentExpr) &&
+if (CC && isa(CC) &&
 !Opts.mayInlineCXXAllocator())
   return CIP_DisallowedOnce;
 
Index: lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
===
--- lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
+++ lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
@@ -12,6 +12,7 @@
 //===--===//
 
 #include "clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h"
+#include "clang/Analysis/ConstructionContext.h"
 #include "clang/AST/DeclCXX.h"
 #include "clang/AST/StmtCXX.h"
 #include "clang/AST/ParentMap.h"
@@ -111,47 +112,20 @@
   // See if we're constructing an existing region by looking at the
   // current construction context.
   if (CC) {
-if (const Stmt *TriggerStmt = CC->getTriggerStmt()) {
-  if (const CXXNewExpr *CNE = dyn_cast(TriggerStmt)) {
-if (AMgr.getAnalyzerOptions().mayInlineCXXAllocator()) {
-  // TODO: Detect when the allocator returns a null pointer.
-  // Constructor shall not be called in this case.
-  if (const SubRegion *MR = dyn_cast_or_null(
-  getCXXNewAllocatorValue(State, CNE, LCtx).getAsRegion())) {
-if (CNE->isArray()) {
-  // TODO: In fact, we need to call the constructor for every
-  // allocated element, not just the first one!
-  CallOpts.IsArrayCtorOrDtor = true;
-  return getStoreManager().GetElementZeroRegion(
-  MR, CNE->getType()->getPointeeType());
-}
-return MR;
-  }
-}
-  } else if (auto *DS = dyn_cast(TriggerStmt)) {
-const auto *Var = cast(DS->getSingleDecl());
-SVal LValue = State->getLValue(Var, LCtx);
-QualType Ty = Var->getType();
-LValue = makeZeroElementRegion(State, LValue, Ty,
-   CallOpts.IsArrayCtorOrDtor);
-return LValue.getAsRegion();
-  } else if (isa(TriggerStmt)) {
-// TODO: We should construct into a CXXBindTemporaryExpr or a
-// MaterializeTemporaryExpr around the call-expression on the previous
-// stack frame. Currently we re-bind the temporary to the correct region
-// later, but that's not semantically correct. This of course does not
-// apply when we're in the top frame. But if we are in an inlined
-// function, we should be able to take the call-site CFG element,
-// and it should contain (but right now it wouldn't) some sort of
-// construction context that'd give us the right temporary expression.
-CallOpts.IsTemporaryCtorOrDtor = true;
-return MRMgr.getCXXTempObjectRegion(CE, LCtx);
-  } else if (isa(TriggerStmt)) {
-CallOpts.IsTemporaryCtorOrDtor = true;
-return MRMgr.getCXXTempObjectRegion(CE, LCtx);
-  }
-  // TODO: Consider other directly initialized elements.
-} else if (const CXXCtorInitializer *Init = CC->getTriggerInit()) {
+switch (CC->getKind()) {
+case ConstructionContext::SimpleVariableKind: {
+  const auto *DSCC = cast(CC);
+  const auto *DS = DSCC->getDeclStmt();
+  const auto *Var = cast(DS->getSingleDecl());
+  SVal LValue = State->getLValue(Var, LCtx);
+  QualType Ty = Var->getType();
+  LValue =
+  makeZeroElementRegion(State, LValue, Ty, CallOpts.IsArrayCtorOrDtor);
+  return LValue.getAsRegion();
+}
+case ConstructionContext::ConstructorInitializerKind: {
+  const auto *ICC = cast(CC);
+  const auto *Init = 

[PATCH] D43576: Solution to fix PR27066 - Redefinition with same mangled name as another definition (dllexport and uuid)

2018-02-22 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

It seems to me that the test here is very much lacking.  It doesn't seem to 
include the example you've mentioned, and has no validation to ensure that 
there is a single instantiation happening.  I'd like to see what happens when a 
UUID is passed as a pack, how SFINAE works on it, etc.




Comment at: include/clang/AST/RecursiveASTVisitor.h:846
 
+  case TemplateArgument::UuidExpression: {
+return getDerived().TraverseStmt(Arg.getAsUuidExpr());

No need for curly brackets.



Comment at: include/clang/AST/RecursiveASTVisitor.h:891
 
+  case TemplateArgument::UuidExpression: {
+return getDerived().TraverseStmt(ArgLoc.getSourceUuidExpression());

Curly brackets likely not necessary here.



Comment at: include/clang/AST/TemplateBase.h:214
   }
+  TemplateArgument(CXXUuidofExpr *E);
 

This function overload should be documented.



Comment at: lib/AST/ASTContext.cpp:5066
 
+case TemplateArgument::UuidExpression:
+  return Arg;

Not only for you here, but is there any reason why this cannot just be a 
fallthrough for the ones above?  I suspect we'd prefer to get those 3 all 
combined.



Comment at: lib/AST/MicrosoftMangle.cpp:1426
 break;
+  case TemplateArgument::UuidExpression: {
+const Expr *e = TA.getAsUuidExpr();

If you combine the getAsUuidExpr line and the mangleExpession line, you can get 
rid of curlies, and be more consistent with the surrounding code.



Comment at: lib/AST/TemplateBase.cpp:581
+PrintingPolicy Policy(LangOpts);
+Arg.getAsUuidExpr()->printPretty(OS, nullptr, Policy);
+return DB << OS.str();

Why is much of this required?  Wouldn't just calling printPretty with the 
current policy work?  Why use a separate stream rather than the 'DB' stream?



Comment at: lib/Sema/SemaTemplate.cpp:4629
+  ExprResult Res =
+CheckTemplateArgument(NTTP, NTTPType, 
Arg.getArgument().getAsUuidExpr(),
+  Result, CTAK);

Is this section clang-formatted?  It seems a little oddly newlined.


https://reviews.llvm.org/D43576



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


[PATCH] D43581: [clang-tidy/google] Fix the Objective-C global variable declaration check 

2018-02-22 Thread Yan Zhang via Phabricator via cfe-commits
Wizard requested changes to this revision.
Wizard added a comment.
This revision now requires changes to proceed.

Please update the warning info to indicate that prefix 'k' is not the only 
option for constants. Something like:
"const global variable '%0' must have an appropriate prefix or a name which 
starts with 'k[A-Z]'"


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D43581



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


[PATCH] D43640: add support for constants with appropriate prefix. Start with 'k' is not the only option. This is according to http://google.github.io/styleguide/objcguide.html#constants

2018-02-22 Thread Yan Zhang via Phabricator via cfe-commits
Wizard added a comment.

In https://reviews.llvm.org/D43640#1016287, @stephanemoore wrote:

> I have this change out for review as well:
>  https://reviews.llvm.org/D43581


Ah cool. Your change looks good. Technically the same as mine. I will discard 
this diff.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D43640



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


[PATCH] D43581: [clang-tidy/google] Fix the Objective-C global variable declaration check 

2018-02-22 Thread Stephane Moore via Phabricator via cfe-commits
stephanemoore updated this revision to Diff 135489.
stephanemoore added a comment.

I forgot to update the diagnostic message per the change.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D43581

Files:
  clang-tidy/google/GlobalVariableDeclarationCheck.cpp
  test/clang-tidy/google-objc-global-variable-declaration.m


Index: test/clang-tidy/google-objc-global-variable-declaration.m
===
--- test/clang-tidy/google-objc-global-variable-declaration.m
+++ test/clang-tidy/google-objc-global-variable-declaration.m
@@ -30,8 +30,16 @@
 // CHECK-FIXES: static NSString* const k_Alpha = @"SecondNotAlpha";
 
 static NSString* const kGood = @"hello";
+static NSString* const XYGood = @"hello";
 static NSString* gMyIntGood = 0;
 
+extern NSString* const GTLServiceErrorDomain;
+
+typedef NS_ENUM(NSInteger, GTLServiceError) {
+  GTLServiceErrorQueryResultMissing = -3000,
+  GTLServiceErrorWaitTimedOut   = -3001,
+};
+
 @implementation Foo
 - (void)f {
 int x = 0;
Index: clang-tidy/google/GlobalVariableDeclarationCheck.cpp
===
--- clang-tidy/google/GlobalVariableDeclarationCheck.cpp
+++ clang-tidy/google/GlobalVariableDeclarationCheck.cpp
@@ -72,7 +72,7 @@
   this);
   Finder->addMatcher(varDecl(hasGlobalStorage(), hasType(isConstQualified()),
  unless(isLocalVariable()),
- unless(matchesName("::k[A-Z]")))
+ unless(matchesName("::(k[A-Z]|[A-Z]{2,})")))
  .bind("global_const"),
  this);
 }
@@ -88,7 +88,7 @@
   if (const auto *Decl = Result.Nodes.getNodeAs("global_const")) {
 diag(Decl->getLocation(),
  "const global variable '%0' must have a name which starts with "
- "'k[A-Z]'")
+ "an appropriate prefix matching '(k[A-Z]|[A-Z]{2,})'.")
 << Decl->getName() << generateFixItHint(Decl, true);
   }
 }


Index: test/clang-tidy/google-objc-global-variable-declaration.m
===
--- test/clang-tidy/google-objc-global-variable-declaration.m
+++ test/clang-tidy/google-objc-global-variable-declaration.m
@@ -30,8 +30,16 @@
 // CHECK-FIXES: static NSString* const k_Alpha = @"SecondNotAlpha";
 
 static NSString* const kGood = @"hello";
+static NSString* const XYGood = @"hello";
 static NSString* gMyIntGood = 0;
 
+extern NSString* const GTLServiceErrorDomain;
+
+typedef NS_ENUM(NSInteger, GTLServiceError) {
+  GTLServiceErrorQueryResultMissing = -3000,
+  GTLServiceErrorWaitTimedOut   = -3001,
+};
+
 @implementation Foo
 - (void)f {
 int x = 0;
Index: clang-tidy/google/GlobalVariableDeclarationCheck.cpp
===
--- clang-tidy/google/GlobalVariableDeclarationCheck.cpp
+++ clang-tidy/google/GlobalVariableDeclarationCheck.cpp
@@ -72,7 +72,7 @@
   this);
   Finder->addMatcher(varDecl(hasGlobalStorage(), hasType(isConstQualified()),
  unless(isLocalVariable()),
- unless(matchesName("::k[A-Z]")))
+ unless(matchesName("::(k[A-Z]|[A-Z]{2,})")))
  .bind("global_const"),
  this);
 }
@@ -88,7 +88,7 @@
   if (const auto *Decl = Result.Nodes.getNodeAs("global_const")) {
 diag(Decl->getLocation(),
  "const global variable '%0' must have a name which starts with "
- "'k[A-Z]'")
+ "an appropriate prefix matching '(k[A-Z]|[A-Z]{2,})'.")
 << Decl->getName() << generateFixItHint(Decl, true);
   }
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D43576: Solution to fix PR27066 - Redefinition with same mangled name as another definition (dllexport and uuid)

2018-02-22 Thread David Majnemer via Phabricator via cfe-commits
majnemer added a comment.

We should really, really avoid making this sort of change without first trying 
to desugar uuidof into a reference to a variable. That would solve a ton of 
problems, problems like this one.


https://reviews.llvm.org/D43576



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


[PATCH] D43640: add support for constants with appropriate prefix. Start with 'k' is not the only option. This is according to http://google.github.io/styleguide/objcguide.html#constants

2018-02-22 Thread Stephane Moore via Phabricator via cfe-commits
stephanemoore added a comment.

I have this change out for review as well:
https://reviews.llvm.org/D43581


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D43640



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


[PATCH] D43322: Diagnose cases of "return x" that should be "return std::move(x)" for efficiency

2018-02-22 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone updated this revision to Diff 135484.
Quuxplusone added a reviewer: rsmith.
Quuxplusone added a subscriber: Rakete.
Quuxplusone added a comment.

Eliminate a couple of `auto` per comment by @Rakete.


Repository:
  rC Clang

https://reviews.llvm.org/D43322

Files:
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/Sema.h
  lib/Sema/SemaExprCXX.cpp
  lib/Sema/SemaStmt.cpp
  lib/Sema/SemaTemplateInstantiateDecl.cpp
  test/SemaCXX/warn-return-std-move.cpp

Index: test/SemaCXX/warn-return-std-move.cpp
===
--- /dev/null
+++ test/SemaCXX/warn-return-std-move.cpp
@@ -0,0 +1,334 @@
+// RUN: %clang_cc1 -fsyntax-only -Wreturn-std-move -Wreturn-std-move-in-cxx11 -std=c++11 -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wreturn-std-move -Wreturn-std-move-in-cxx11 -std=c++11 -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
+
+// definitions for std::move
+namespace std {
+inline namespace foo {
+template  struct remove_reference { typedef T type; };
+template  struct remove_reference { typedef T type; };
+template  struct remove_reference { typedef T type; };
+
+template  typename remove_reference::type &(T &);
+} // namespace foo
+} // namespace std
+
+struct Instrument {
+Instrument() {}
+Instrument(Instrument&&) { /* MOVE */ }
+Instrument(const Instrument&) { /* COPY */ }
+};
+struct ConvertFromBase { Instrument i; };
+struct ConvertFromDerived { Instrument i; };
+struct Base {
+Instrument i;
+operator ConvertFromBase() const& { return ConvertFromBase{i}; }
+operator ConvertFromBase() && { return ConvertFromBase{std::move(i)}; }
+};
+struct Derived : public Base {
+operator ConvertFromDerived() const& { return ConvertFromDerived{i}; }
+operator ConvertFromDerived() && { return ConvertFromDerived{std::move(i)}; }
+};
+struct ConstructFromBase {
+Instrument i;
+ConstructFromBase(const Base& b): i(b.i) {}
+ConstructFromBase(Base&& b): i(std::move(b.i)) {}
+};
+struct ConstructFromDerived {
+Instrument i;
+ConstructFromDerived(const Derived& d): i(d.i) {}
+ConstructFromDerived(Derived&& d): i(std::move(d.i)) {}
+};
+
+struct TrivialInstrument {
+int i = 42;
+};
+struct ConvertFromTrivialBase { TrivialInstrument i; };
+struct ConvertFromTrivialDerived { TrivialInstrument i; };
+struct TrivialBase {
+TrivialInstrument i;
+operator ConvertFromTrivialBase() const& { return ConvertFromTrivialBase{i}; }
+operator ConvertFromTrivialBase() && { return ConvertFromTrivialBase{std::move(i)}; }
+};
+struct TrivialDerived : public TrivialBase {
+operator ConvertFromTrivialDerived() const& { return ConvertFromTrivialDerived{i}; }
+operator ConvertFromTrivialDerived() && { return ConvertFromTrivialDerived{std::move(i)}; }
+};
+struct ConstructFromTrivialBase {
+TrivialInstrument i;
+ConstructFromTrivialBase(const TrivialBase& b): i(b.i) {}
+ConstructFromTrivialBase(TrivialBase&& b): i(std::move(b.i)) {}
+};
+struct ConstructFromTrivialDerived {
+TrivialInstrument i;
+ConstructFromTrivialDerived(const TrivialDerived& d): i(d.i) {}
+ConstructFromTrivialDerived(TrivialDerived&& d): i(std::move(d.i)) {}
+};
+
+Derived test1() {
+Derived d1;
+return d1;  // ok
+}
+Base test2() {
+Derived d2;
+return d2;  // e1
+// expected-warning@-1{{will be copied despite being returned by name}}
+// expected-note@-2{{to avoid copying}}
+// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:12-[[@LINE-3]]:14}:"std::move(d2)"
+}
+ConstructFromDerived test3() {
+Derived d3;
+return d3;  // e2-cxx11
+// expected-warning@-1{{would have been copied despite being returned by name}}
+// expected-note@-2{{to avoid copying on older compilers}}
+// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:12-[[@LINE-3]]:14}:"std::move(d3)"
+}
+ConstructFromBase test4() {
+Derived d4;
+return d4;  // e3
+// expected-warning@-1{{will be copied despite being returned by name}}
+// expected-note@-2{{to avoid copying}}
+// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:12-[[@LINE-3]]:14}:"std::move(d4)"
+}
+ConvertFromDerived test5() {
+Derived d5;
+return d5;  // e4
+// expected-warning@-1{{will be copied despite being returned by name}}
+// expected-note@-2{{to avoid copying}}
+// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:12-[[@LINE-3]]:14}:"std::move(d5)"
+}
+ConvertFromBase test6() {
+Derived d6;
+return d6;  // e5
+// expected-warning@-1{{will be copied despite being returned by name}}
+// expected-note@-2{{to avoid copying}}
+// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:12-[[@LINE-3]]:14}:"std::move(d6)"
+}
+
+// These test cases should not produce the warning.
+Derived ok1() { Derived d; return d; }
+Base ok2() { Derived d; return static_cast(d); }
+ConstructFromDerived ok3() { Derived d; return static_cast(d); }
+ConstructFromBase ok4() { 

[PATCH] D43640: add support for constants with appropriate prefix. Start with 'k' is not the only option. This is according to http://google.github.io/styleguide/objcguide.html#constants

2018-02-22 Thread Yan Zhang via Phabricator via cfe-commits
Wizard created this revision.
Herald added subscribers: cfe-commits, klimek.

Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D43640

Files:
  clang-tidy/google/GlobalVariableDeclarationCheck.cpp
  test/clang-tidy/google-objc-global-variable-declaration.m


Index: test/clang-tidy/google-objc-global-variable-declaration.m
===
--- test/clang-tidy/google-objc-global-variable-declaration.m
+++ test/clang-tidy/google-objc-global-variable-declaration.m
@@ -2,7 +2,7 @@
 
 @class NSString;
 static NSString* const myConstString = @"hello";
-// CHECK-MESSAGES: :[[@LINE-1]]:24: warning: const global variable 
'myConstString' must have a name which starts with 'k[A-Z]' 
[google-objc-global-variable-declaration]
+// CHECK-MESSAGES: :[[@LINE-1]]:24: warning: const global variable 
'myConstString' must have an appropriate prefix or a name which starts with 
'k[A-Z]' [google-objc-global-variable-declaration]
 // CHECK-FIXES: static NSString* const kMyConstString = @"hello";
 
 static NSString* MyString = @"hi";
@@ -22,14 +22,15 @@
 // CHECK-FIXES: static NSString* gNoDef;
 
 static NSString* const _notAlpha = @"NotBeginWithAlpha";
-// CHECK-MESSAGES: :[[@LINE-1]]:24: warning: const global variable '_notAlpha' 
must have a name which starts with 'k[A-Z]' 
[google-objc-global-variable-declaration]
+// CHECK-MESSAGES: :[[@LINE-1]]:24: warning: const global variable '_notAlpha' 
must have an appropriate prefix or a name which starts with 'k[A-Z]' 
[google-objc-global-variable-declaration]
 // CHECK-FIXES: static NSString* const _notAlpha = @"NotBeginWithAlpha";
 
 static NSString* const k_Alpha = @"SecondNotAlpha";
-// CHECK-MESSAGES: :[[@LINE-1]]:24: warning: const global variable 'k_Alpha' 
must have a name which starts with 'k[A-Z]' 
[google-objc-global-variable-declaration]
+// CHECK-MESSAGES: :[[@LINE-1]]:24: warning: const global variable 'k_Alpha' 
must have an appropriate prefix or a name which starts with 'k[A-Z]' 
[google-objc-global-variable-declaration]
 // CHECK-FIXES: static NSString* const k_Alpha = @"SecondNotAlpha";
 
 static NSString* const kGood = @"hello";
+static NSString* const ABCGood = @"I have a prefix";
 static NSString* gMyIntGood = 0;
 
 @implementation Foo
Index: clang-tidy/google/GlobalVariableDeclarationCheck.cpp
===
--- clang-tidy/google/GlobalVariableDeclarationCheck.cpp
+++ clang-tidy/google/GlobalVariableDeclarationCheck.cpp
@@ -24,15 +24,13 @@
 
 namespace {
 
-AST_MATCHER(VarDecl, isLocalVariable) {
-  return Node.isLocalVarDecl();
-}
+AST_MATCHER(VarDecl, isLocalVariable) { return Node.isLocalVarDecl(); }
 
 FixItHint generateFixItHint(const VarDecl *Decl, bool IsConst) {
   char FC = Decl->getName()[0];
   if (!llvm::isAlpha(FC) || Decl->getName().size() == 1) {
 // No fix available if first character is not alphabetical character, or it
-// is a single-character variable, since it is difficult to determine the 
+// is a single-character variable, since it is difficult to determine the
 // proper fix in this case. Users should create a proper variable name by
 // their own.
 return FixItHint();
@@ -72,7 +70,7 @@
   this);
   Finder->addMatcher(varDecl(hasGlobalStorage(), hasType(isConstQualified()),
  unless(isLocalVariable()),
- unless(matchesName("::k[A-Z]")))
+ unless(matchesName("::(k|[A-Z]{2,})[A-Z]")))
  .bind("global_const"),
  this);
 }
@@ -87,8 +85,8 @@
   }
   if (const auto *Decl = Result.Nodes.getNodeAs("global_const")) {
 diag(Decl->getLocation(),
- "const global variable '%0' must have a name which starts with "
- "'k[A-Z]'")
+ "const global variable '%0' must have an appropriate prefix or a name 
"
+ "which starts with 'k[A-Z]'")
 << Decl->getName() << generateFixItHint(Decl, true);
   }
 }


Index: test/clang-tidy/google-objc-global-variable-declaration.m
===
--- test/clang-tidy/google-objc-global-variable-declaration.m
+++ test/clang-tidy/google-objc-global-variable-declaration.m
@@ -2,7 +2,7 @@
 
 @class NSString;
 static NSString* const myConstString = @"hello";
-// CHECK-MESSAGES: :[[@LINE-1]]:24: warning: const global variable 'myConstString' must have a name which starts with 'k[A-Z]' [google-objc-global-variable-declaration]
+// CHECK-MESSAGES: :[[@LINE-1]]:24: warning: const global variable 'myConstString' must have an appropriate prefix or a name which starts with 'k[A-Z]' [google-objc-global-variable-declaration]
 // CHECK-FIXES: static NSString* const kMyConstString = @"hello";
 
 static NSString* MyString = @"hi";
@@ -22,14 +22,15 @@
 // CHECK-FIXES: static NSString* gNoDef;
 
 static NSString* const _notAlpha = @"NotBeginWithAlpha";
-// CHECK-MESSAGES: 

[PATCH] D41228: [ObjC] Enable __strong pointers in structs under ARC

2018-02-22 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added inline comments.



Comment at: include/clang/AST/Type.h:1121
+  /// after it is moved, as opposed to a truely destructive move in which the
+  /// source object is placed in an uninitialized state.
+  PrimitiveCopyKind isNonTrivialToPrimitiveDestructiveMove() const;

rjmccall wrote:
> "truly"
> 
> Hmm.  Now that I'm thinking more about it, I'm not sure there's any point in 
> tracking non-triviality of a C++-style destructive move separately from the 
> non-triviality of a copy.  It's hard to imagine that there would ever be a 
> non-C++ type that primitively has non-trivial copies but trivial C++-style 
> moves or vice-versa.  Type-based destructors imply that the type represents 
> some kind of resource, and a C++-style move will always be non-trivial for 
> resource types because ownership of the resource needs to be given up by the 
> old location.  Otherwise, a type might be non-trivial to copy but not destroy 
> because there's something special about how it's stored (like volatility), 
> but it's hard to imagine what could possibly cause it to be non-trivial to 
> destroy but not copy.
> 
> If we were tracking non-triviality of an *unsafe* destructive move, one that 
> leaves the source in an uninitialized state, that's quite different.
> 
> I think there are three reasonable options here:
> 
> - Ignore the argument I just made about the types that we're *likely* to care 
> about modeling and generalize your tracking to also distinguish construction 
> from assignment.  In such an environment, I think you can absolutely make an 
> argument that it's still interesting to track C++-style moves separately from 
> copies.
> 
> - Drop the tracking of destructive moves completely.  If you want to keep the 
> method around, find, but it can just call `isNonTrivialToPrimitiveCopy()`.
> 
> - Change the tracking of *destructive* moves to instead track 
> *deinitializing* moves.  The implementation would stop considering `__strong` 
> types to be non-trivial to move.
> 
> But as things stand today, I do not see any point in separately tracking 
> triviality of C++-style destructive moves.
The second option seems most reasonable to me. We can always make changes if 
someone comes up with a type that requires tracking destructive moves 
separately.



Comment at: lib/CodeGen/CGNonTrivialStruct.cpp:193
+
+TrivialFieldIsVolatile |= FT.isVolatileQualified();
+if (Start == End)

rjmccall wrote:
> ahatanak wrote:
> > rjmccall wrote:
> > > I feel like maybe volatile fields should be individually copied instead 
> > > of being aggregated into a multi-field memcpy.  This is a more natural 
> > > interpretation of the C volatile rules than we currently do.  In fact, 
> > > arguably we should really add a PrimitiveCopyKind enumerator for volatile 
> > > fields (that are otherwise trivially-copyable) and force all copies of 
> > > structs with volatile fields into this path precisely so that we can make 
> > > a point of copying the volatile fields this way.  (Obviously that part is 
> > > not something that's your responsibility to do.)
> > > 
> > > To get that right with bit-fields, you'll need to propagate the actual 
> > > FieldDecl down.  On the plus side, that should let you use 
> > > EmitLValueForField to do the field projection in the common case.
> > I added method visitVolatileTrivial that copies volatile fields 
> > individually. Please see test case test_copy_constructor_Bitfield1 in 
> > test/CodeGenObjC/strong-in-c-struct.m.
> Okay, great!  I like the name.
> 
> Does this mean we're now copying all structs that contain volatile fields 
> with one of these helper functions?  If so, please add a C test case testing 
> just that.  Also, you should retitle this review and stress that we're 
> changing how *all* non-trivial types are copied, and that that includes both 
> volatile and ARC-qualified fields.
No, the current patch doesn't copy volatile fields of a struct individually 
unless the struct is a non-trivial type (which means its primitive copy kind is 
PCK_Struct). I'll look into today how I can force structs with volatile fields 
that are not non-trivial to be copied using the helper functions.

It seems like we would need a boolean flag in RecordDecl that tracks the 
presence of volatile fields in the struct or one of its subobjects. I assume we 
want to copy volatile fields individually in C++ too, in which case the flag 
needs to be set in both C and C++ mode. Is that right?


https://reviews.llvm.org/D41228



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


[PATCH] D43634: [clangd] Extend textDocument/didChange to specify whether diagnostics should be generated.

2018-02-22 Thread Eric Liu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rCTE325813: [clangd] Extend textDocument/didChange to specify 
whether diagnostics should be… (authored by ioeric, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D43634?vs=135463=135465#toc

Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D43634

Files:
  clangd/ClangdLSPServer.cpp
  clangd/Protocol.cpp
  clangd/Protocol.h


Index: clangd/Protocol.h
===
--- clangd/Protocol.h
+++ clangd/Protocol.h
@@ -297,6 +297,12 @@
 
   /// The actual content changes.
   std::vector contentChanges;
+
+  /// Forces diagnostics to be generated, or to not be generated, for this
+  /// version of the file. If not set, diagnostics are eventually consistent:
+  /// either they will be provided for this version or some subsequent one.
+  /// This is a clangd extension.
+  llvm::Optional wantDiagnostics;
 };
 bool fromJSON(const json::Expr &, DidChangeTextDocumentParams &);
 
Index: clangd/ClangdLSPServer.cpp
===
--- clangd/ClangdLSPServer.cpp
+++ clangd/ClangdLSPServer.cpp
@@ -149,9 +149,13 @@
   if (Params.contentChanges.size() != 1)
 return replyError(ErrorCode::InvalidParams,
   "can only apply one change at a time");
+  auto WantDiags = WantDiagnostics::Auto;
+  if (Params.wantDiagnostics.hasValue())
+WantDiags = Params.wantDiagnostics.getValue() ? WantDiagnostics::Yes
+  : WantDiagnostics::No;
   // We only support full syncing right now.
   Server.addDocument(Params.textDocument.uri.file(),
- Params.contentChanges[0].text, WantDiagnostics::Auto);
+ Params.contentChanges[0].text, WantDiags);
 }
 
 void ClangdLSPServer::onFileEvent(DidChangeWatchedFilesParams ) {
Index: clangd/Protocol.cpp
===
--- clangd/Protocol.cpp
+++ clangd/Protocol.cpp
@@ -221,7 +221,8 @@
 bool fromJSON(const json::Expr , DidChangeTextDocumentParams ) {
   json::ObjectMapper O(Params);
   return O && O.map("textDocument", R.textDocument) &&
- O.map("contentChanges", R.contentChanges);
+ O.map("contentChanges", R.contentChanges) &&
+ O.map("wantDiagnostics", R.wantDiagnostics);
 }
 
 bool fromJSON(const json::Expr , FileChangeType ) {


Index: clangd/Protocol.h
===
--- clangd/Protocol.h
+++ clangd/Protocol.h
@@ -297,6 +297,12 @@
 
   /// The actual content changes.
   std::vector contentChanges;
+
+  /// Forces diagnostics to be generated, or to not be generated, for this
+  /// version of the file. If not set, diagnostics are eventually consistent:
+  /// either they will be provided for this version or some subsequent one.
+  /// This is a clangd extension.
+  llvm::Optional wantDiagnostics;
 };
 bool fromJSON(const json::Expr &, DidChangeTextDocumentParams &);
 
Index: clangd/ClangdLSPServer.cpp
===
--- clangd/ClangdLSPServer.cpp
+++ clangd/ClangdLSPServer.cpp
@@ -149,9 +149,13 @@
   if (Params.contentChanges.size() != 1)
 return replyError(ErrorCode::InvalidParams,
   "can only apply one change at a time");
+  auto WantDiags = WantDiagnostics::Auto;
+  if (Params.wantDiagnostics.hasValue())
+WantDiags = Params.wantDiagnostics.getValue() ? WantDiagnostics::Yes
+  : WantDiagnostics::No;
   // We only support full syncing right now.
   Server.addDocument(Params.textDocument.uri.file(),
- Params.contentChanges[0].text, WantDiagnostics::Auto);
+ Params.contentChanges[0].text, WantDiags);
 }
 
 void ClangdLSPServer::onFileEvent(DidChangeWatchedFilesParams ) {
Index: clangd/Protocol.cpp
===
--- clangd/Protocol.cpp
+++ clangd/Protocol.cpp
@@ -221,7 +221,8 @@
 bool fromJSON(const json::Expr , DidChangeTextDocumentParams ) {
   json::ObjectMapper O(Params);
   return O && O.map("textDocument", R.textDocument) &&
- O.map("contentChanges", R.contentChanges);
+ O.map("contentChanges", R.contentChanges) &&
+ O.map("wantDiagnostics", R.wantDiagnostics);
 }
 
 bool fromJSON(const json::Expr , FileChangeType ) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r325814 - [CUDA] Added missing functions.

2018-02-22 Thread Artem Belevich via cfe-commits
Author: tra
Date: Thu Feb 22 10:40:52 2018
New Revision: 325814

URL: http://llvm.org/viewvc/llvm-project?rev=325814=rev
Log:
[CUDA] Added missing functions.

Initial commit missed sincos(float), llabs() and few atomics that we
used to pull in from device_functions.hpp, which we no longer include.

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

Modified:
cfe/trunk/lib/Headers/__clang_cuda_device_functions.h

Modified: cfe/trunk/lib/Headers/__clang_cuda_device_functions.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/__clang_cuda_device_functions.h?rev=325814=325813=325814=diff
==
--- cfe/trunk/lib/Headers/__clang_cuda_device_functions.h (original)
+++ cfe/trunk/lib/Headers/__clang_cuda_device_functions.h Thu Feb 22 10:40:52 
2018
@@ -687,6 +687,10 @@ __DEVICE__ float __ull2float_ru(unsigned
 __DEVICE__ float __ull2float_rz(unsigned long long __a) {
   return __nv_ull2float_rz(__a);
 }
+__DEVICE__ unsigned long long __ullAtomicAdd(unsigned long long *__p,
+ unsigned long long __v) {
+  return __nvvm_atom_add_gen_ll((long long *)__p, __v);
+}
 __DEVICE__ unsigned long long __ullAtomicAdd_block(unsigned long long *__p,
unsigned long long __v) {
   return __nvvm_atom_cta_add_gen_ll((long long *)__p, __v);
@@ -707,6 +711,11 @@ __DEVICE__ unsigned long long __ullAtomi
 unsigned long long __v) {
   return __nvvm_atom_sys_and_gen_ll((long long *)__p, __v);
 }
+__DEVICE__ unsigned long long __ullAtomicCAS(unsigned long long *__p,
+ unsigned long long __cmp,
+ unsigned long long __v) {
+  return __nvvm_atom_cas_gen_ll((long long *)__p, __cmp, __v);
+}
 __DEVICE__ unsigned long long __ullAtomicCAS_block(unsigned long long *__p,
unsigned long long __cmp,
unsigned long long __v) {
@@ -717,6 +726,10 @@ __DEVICE__ unsigned long long __ullAtomi
 unsigned long long __v) {
   return __nvvm_atom_sys_cas_gen_ll((long long *)__p, __cmp, __v);
 }
+__DEVICE__ unsigned long long __ullAtomicExch(unsigned long long *__p,
+  unsigned long long __v) {
+  return __nvvm_atom_xchg_gen_ll((long long *)__p, __v);
+}
 __DEVICE__ unsigned long long __ullAtomicExch_block(unsigned long long *__p,
 unsigned long long __v) {
   return __nvvm_atom_cta_xchg_gen_ll((long long *)__p, __v);
@@ -1123,10 +1136,16 @@ __DEVICE__ double j1(double __a) { retur
 __DEVICE__ float j1f(float __a) { return __nv_j1f(__a); }
 __DEVICE__ double jn(int __n, double __a) { return __nv_jn(__n, __a); }
 __DEVICE__ float jnf(int __n, float __a) { return __nv_jnf(__n, __a); }
+#if defined(__LP64__)
+__DEVICE__ long labs(long __a) { return llabs(__a); };
+#else
+__DEVICE__ long labs(long __a) { return __nv_abs(__a); };
+#endif
 __DEVICE__ double ldexp(double __a, int __b) { return __nv_ldexp(__a, __b); }
 __DEVICE__ float ldexpf(float __a, int __b) { return __nv_ldexpf(__a, __b); }
 __DEVICE__ double lgamma(double __a) { return __nv_lgamma(__a); }
 __DEVICE__ float lgammaf(float __a) { return __nv_lgammaf(__a); }
+__DEVICE__ long long llabs(long long __a) { return __nv_llabs(__a); }
 __DEVICE__ long long llmax(long long __a, long long __b) {
   return __nv_llmax(__a, __b);
 }
@@ -1267,6 +1286,9 @@ __DEVICE__ float scalblnf(float __a, lon
   return scalbnf(__a, (int)__b);
 }
 __DEVICE__ double sin(double __a) { return __nv_sin(__a); }
+__DEVICE__ void sincos(double __a, double *__sptr, double *__cptr) {
+  return __nv_sincos(__a, __sptr, __cptr);
+}
 __DEVICE__ void sincosf(float __a, float *__sptr, float *__cptr) {
   return __FAST_OR_SLOW(__nv_fast_sincosf, __nv_sincosf)(__a, __sptr, __cptr);
 }


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


[clang-tools-extra] r325813 - [clangd] Extend textDocument/didChange to specify whether diagnostics should be generated.

2018-02-22 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Thu Feb 22 10:40:39 2018
New Revision: 325813

URL: http://llvm.org/viewvc/llvm-project?rev=325813=rev
Log:
[clangd] Extend textDocument/didChange to specify whether diagnostics should be 
generated.

Summary:
This would allow us to disable diagnostics when didChange is called but
diagnostics are not wanted (e.g. code completion).

Reviewers: sammccall

Subscribers: klimek, ilya-biryukov, jkorous-apple, cfe-commits

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

Modified:
clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
clang-tools-extra/trunk/clangd/Protocol.cpp
clang-tools-extra/trunk/clangd/Protocol.h

Modified: clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp?rev=325813=325812=325813=diff
==
--- clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp Thu Feb 22 10:40:39 2018
@@ -149,9 +149,13 @@ void ClangdLSPServer::onDocumentDidChang
   if (Params.contentChanges.size() != 1)
 return replyError(ErrorCode::InvalidParams,
   "can only apply one change at a time");
+  auto WantDiags = WantDiagnostics::Auto;
+  if (Params.wantDiagnostics.hasValue())
+WantDiags = Params.wantDiagnostics.getValue() ? WantDiagnostics::Yes
+  : WantDiagnostics::No;
   // We only support full syncing right now.
   Server.addDocument(Params.textDocument.uri.file(),
- Params.contentChanges[0].text, WantDiagnostics::Auto);
+ Params.contentChanges[0].text, WantDiags);
 }
 
 void ClangdLSPServer::onFileEvent(DidChangeWatchedFilesParams ) {

Modified: clang-tools-extra/trunk/clangd/Protocol.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Protocol.cpp?rev=325813=325812=325813=diff
==
--- clang-tools-extra/trunk/clangd/Protocol.cpp (original)
+++ clang-tools-extra/trunk/clangd/Protocol.cpp Thu Feb 22 10:40:39 2018
@@ -221,7 +221,8 @@ bool fromJSON(const json::Expr ,
 bool fromJSON(const json::Expr , DidChangeTextDocumentParams ) {
   json::ObjectMapper O(Params);
   return O && O.map("textDocument", R.textDocument) &&
- O.map("contentChanges", R.contentChanges);
+ O.map("contentChanges", R.contentChanges) &&
+ O.map("wantDiagnostics", R.wantDiagnostics);
 }
 
 bool fromJSON(const json::Expr , FileChangeType ) {

Modified: clang-tools-extra/trunk/clangd/Protocol.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Protocol.h?rev=325813=325812=325813=diff
==
--- clang-tools-extra/trunk/clangd/Protocol.h (original)
+++ clang-tools-extra/trunk/clangd/Protocol.h Thu Feb 22 10:40:39 2018
@@ -297,6 +297,12 @@ struct DidChangeTextDocumentParams {
 
   /// The actual content changes.
   std::vector contentChanges;
+
+  /// Forces diagnostics to be generated, or to not be generated, for this
+  /// version of the file. If not set, diagnostics are eventually consistent:
+  /// either they will be provided for this version or some subsequent one.
+  /// This is a clangd extension.
+  llvm::Optional wantDiagnostics;
 };
 bool fromJSON(const json::Expr &, DidChangeTextDocumentParams &);
 


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


[PATCH] D43634: [clangd] Extend textDocument/didChange to specify whether diagnostics should be generated.

2018-02-22 Thread Eric Liu via Phabricator via cfe-commits
ioeric updated this revision to Diff 135463.
ioeric marked 2 inline comments as done.
ioeric added a comment.

Addressed review comments. Removed test.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D43634

Files:
  clangd/ClangdLSPServer.cpp
  clangd/Protocol.cpp
  clangd/Protocol.h


Index: clangd/Protocol.h
===
--- clangd/Protocol.h
+++ clangd/Protocol.h
@@ -297,6 +297,12 @@
 
   /// The actual content changes.
   std::vector contentChanges;
+
+  /// Forces diagnostics to be generated, or to not be generated, for this
+  /// version of the file. If not set, diagnostics are eventually consistent:
+  /// either they will be provided for this version or some subsequent one.
+  /// This is a clangd extension.
+  llvm::Optional wantDiagnostics;
 };
 bool fromJSON(const json::Expr &, DidChangeTextDocumentParams &);
 
Index: clangd/Protocol.cpp
===
--- clangd/Protocol.cpp
+++ clangd/Protocol.cpp
@@ -221,7 +221,8 @@
 bool fromJSON(const json::Expr , DidChangeTextDocumentParams ) {
   json::ObjectMapper O(Params);
   return O && O.map("textDocument", R.textDocument) &&
- O.map("contentChanges", R.contentChanges);
+ O.map("contentChanges", R.contentChanges) &&
+ O.map("wantDiagnostics", R.wantDiagnostics);
 }
 
 bool fromJSON(const json::Expr , FileChangeType ) {
Index: clangd/ClangdLSPServer.cpp
===
--- clangd/ClangdLSPServer.cpp
+++ clangd/ClangdLSPServer.cpp
@@ -149,9 +149,13 @@
   if (Params.contentChanges.size() != 1)
 return replyError(ErrorCode::InvalidParams,
   "can only apply one change at a time");
+  auto WantDiags = WantDiagnostics::Auto;
+  if (Params.wantDiagnostics.hasValue())
+WantDiags = Params.wantDiagnostics.getValue() ? WantDiagnostics::Yes
+  : WantDiagnostics::No;
   // We only support full syncing right now.
   Server.addDocument(Params.textDocument.uri.file(),
- Params.contentChanges[0].text, WantDiagnostics::Auto);
+ Params.contentChanges[0].text, WantDiags);
 }
 
 void ClangdLSPServer::onFileEvent(DidChangeWatchedFilesParams ) {


Index: clangd/Protocol.h
===
--- clangd/Protocol.h
+++ clangd/Protocol.h
@@ -297,6 +297,12 @@
 
   /// The actual content changes.
   std::vector contentChanges;
+
+  /// Forces diagnostics to be generated, or to not be generated, for this
+  /// version of the file. If not set, diagnostics are eventually consistent:
+  /// either they will be provided for this version or some subsequent one.
+  /// This is a clangd extension.
+  llvm::Optional wantDiagnostics;
 };
 bool fromJSON(const json::Expr &, DidChangeTextDocumentParams &);
 
Index: clangd/Protocol.cpp
===
--- clangd/Protocol.cpp
+++ clangd/Protocol.cpp
@@ -221,7 +221,8 @@
 bool fromJSON(const json::Expr , DidChangeTextDocumentParams ) {
   json::ObjectMapper O(Params);
   return O && O.map("textDocument", R.textDocument) &&
- O.map("contentChanges", R.contentChanges);
+ O.map("contentChanges", R.contentChanges) &&
+ O.map("wantDiagnostics", R.wantDiagnostics);
 }
 
 bool fromJSON(const json::Expr , FileChangeType ) {
Index: clangd/ClangdLSPServer.cpp
===
--- clangd/ClangdLSPServer.cpp
+++ clangd/ClangdLSPServer.cpp
@@ -149,9 +149,13 @@
   if (Params.contentChanges.size() != 1)
 return replyError(ErrorCode::InvalidParams,
   "can only apply one change at a time");
+  auto WantDiags = WantDiagnostics::Auto;
+  if (Params.wantDiagnostics.hasValue())
+WantDiags = Params.wantDiagnostics.getValue() ? WantDiagnostics::Yes
+  : WantDiagnostics::No;
   // We only support full syncing right now.
   Server.addDocument(Params.textDocument.uri.file(),
- Params.contentChanges[0].text, WantDiagnostics::Auto);
+ Params.contentChanges[0].text, WantDiags);
 }
 
 void ClangdLSPServer::onFileEvent(DidChangeWatchedFilesParams ) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r325812 - [OPENMP] Require valid SourceLocation in function call, NFC.

2018-02-22 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Thu Feb 22 10:33:31 2018
New Revision: 325812

URL: http://llvm.org/viewvc/llvm-project?rev=325812=rev
Log:
[OPENMP] Require valid SourceLocation in function call, NFC.

Removed default empty SourceLocation argument from `emitCall` function
and require valid location.

Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=325812=325811=325812=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Thu Feb 22 10:33:31 2018
@@ -8057,9 +8057,10 @@ void CGOpenMPRuntime::emitDoacrossOrdere
   CGF.EmitRuntimeCall(RTLFn, Args);
 }
 
-void CGOpenMPRuntime::emitCall(CodeGenFunction , llvm::Value *Callee,
-   ArrayRef Args,
-   SourceLocation Loc) const {
+void CGOpenMPRuntime::emitCall(CodeGenFunction , SourceLocation Loc,
+   llvm::Value *Callee,
+   ArrayRef Args) const {
+  assert(Loc.isValid() && "Outlined function call location must be valid.");
   auto DL = ApplyDebugLocation::CreateDefaultArtificial(CGF, Loc);
 
   if (auto *Fn = dyn_cast(Callee)) {
@@ -8074,8 +8075,7 @@ void CGOpenMPRuntime::emitCall(CodeGenFu
 void CGOpenMPRuntime::emitOutlinedFunctionCall(
 CodeGenFunction , SourceLocation Loc, llvm::Value *OutlinedFn,
 ArrayRef Args) const {
-  assert(Loc.isValid() && "Outlined function call location must be valid.");
-  emitCall(CGF, OutlinedFn, Args, Loc);
+  emitCall(CGF, Loc, OutlinedFn, Args);
 }
 
 Address CGOpenMPRuntime::getParameterAddress(CodeGenFunction ,

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h?rev=325812=325811=325812=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h Thu Feb 22 10:33:31 2018
@@ -251,9 +251,8 @@ protected:
   virtual StringRef getOutlinedHelperName() const { return ".omp_outlined."; }
 
   /// Emits \p Callee function call with arguments \p Args with location \p 
Loc.
-  void emitCall(CodeGenFunction , llvm::Value *Callee,
-ArrayRef Args = llvm::None,
-SourceLocation Loc = SourceLocation()) const;
+  void emitCall(CodeGenFunction , SourceLocation Loc, llvm::Value *Callee,
+ArrayRef Args = llvm::None) const;
 
 private:
   /// \brief Default const ident_t object used for initialization of all other


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


[PATCH] D43621: [Driver] Allow using a canonical form of '-fuse-ld=' when cross-compiling on Windows.

2018-02-22 Thread Adrian McCarthy via Phabricator via cfe-commits
amccarth added a comment.

> Right now, we have to add an .exe suffix when using this switch, like 
> -fuse-ld=lld.exe.

That's weird, because lots of lldb tests compile and link test binaries on 
Windows with `-fuse-ld=lld` (without the `.exe`).  What makes you say the 
`.exe` is necessary?


Repository:
  rC Clang

https://reviews.llvm.org/D43621



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


[PATCH] D43634: [clangd] Extend textDocument/didChange to specify whether diagnostics should be generated.

2018-02-22 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added a comment.
This revision is now accepted and ready to land.

Nice,  this will be useful for at least a couple of editor integrations.




Comment at: clangd/Protocol.h:301
+
+  /// If this is not set, diagnostics will be generated for the current version
+  /// or a subsequent one.

Nit: a little weird to lead with the missing case. Suggest rephrase as:

Forces diagnostics to be generated, or to not be generated. for this version of 
the file.
If not set, diagnostics are eventually consistent: either they will be provided 
for this version
or some subsequent one.



Comment at: test/clangd/want-diagnostics.test:5
+{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"test:///main.cpp","languageId":"cpp","version":1,"text":"void
 main() {}"}}}
+#  CHECK:  "method": "textDocument/publishDiagnostics",
+---

I think this test doesn't test anything useful because the check lines are not 
sequenced with respect to the input.

I'm not sure a lit test is that useful here, the actual logic is already unit 
tested. If we really want to test the ClangdLSPServer change, a unit test might 
be easier to get right, but personally I'd be happy enough leaving the logic 
untested (and maybe throwing a wantDiagnostics into one of the updates in 
protocol.test)


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D43634



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


[PATCH] D43634: [clangd] Extend textDocument/didChange to specify whether diagnostics should be generated.

2018-02-22 Thread Eric Liu via Phabricator via cfe-commits
ioeric created this revision.
ioeric added a reviewer: sammccall.
Herald added subscribers: cfe-commits, jkorous-apple, ilya-biryukov, klimek.

This would allow us to disable diagnostics when didChange is called but
diagnostics are not wanted (e.g. code completion).


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D43634

Files:
  clangd/ClangdLSPServer.cpp
  clangd/Protocol.cpp
  clangd/Protocol.h
  test/clangd/want-diagnostics.test


Index: test/clangd/want-diagnostics.test
===
--- /dev/null
+++ test/clangd/want-diagnostics.test
@@ -0,0 +1,19 @@
+# RUN: clangd -lit-test < %s | FileCheck -strict-whitespace %s
+{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
+---
+{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"test:///main.cpp","languageId":"cpp","version":1,"text":"void
 main() {}"}}}
+#  CHECK:  "method": "textDocument/publishDiagnostics",
+---
+{"jsonrpc":"2.0","method":"textDocument/didChange","params":{"textDocument":{"uri":"test:///main.cpp","version":2},"contentChanges":[{"text":"void
 main() {}"}]}}
+---
+#  CHECK:  "method": "textDocument/publishDiagnostics",
+{"jsonrpc":"2.0","method":"textDocument/didChange","params":{"textDocument":{"uri":"test:///main.cpp","version":3},"contentChanges":[{"text":"void
 main() {}"}],"wantDiagnostics":true}}
+---
+#  CHECK:  "method": "textDocument/publishDiagnostics",
+{"jsonrpc":"2.0","method":"textDocument/didChange","params":{"textDocument":{"uri":"test:///main.cpp","version":4},"contentChanges":[{"text":"void
 main() {}"}],"wantDiagnostics":false}}
+---
+#  CHECK-NOT:  "method": "textDocument/publishDiagnostics",
+{"jsonrpc":"2.0","id":2,"method":"shutdown"}
+#  CHECK:  "method": "textDocument/publishDiagnostics",
+---
+{"jsonrpc":"2.0","method":"exit"}
Index: clangd/Protocol.h
===
--- clangd/Protocol.h
+++ clangd/Protocol.h
@@ -297,6 +297,15 @@
 
   /// The actual content changes.
   std::vector contentChanges;
+
+  /// If this is not set, diagnostics will be generated for the current version
+  /// or a subsequent one.
+  /// If this is set to true, dianostics are guaranteed to be generated for the
+  /// current version.
+  /// If this is set to false, dianostics will not be generated for this
+  /// request.
+  /// This is a clangd extension.
+  llvm::Optional wantDiagnostics;
 };
 bool fromJSON(const json::Expr &, DidChangeTextDocumentParams &);
 
Index: clangd/Protocol.cpp
===
--- clangd/Protocol.cpp
+++ clangd/Protocol.cpp
@@ -221,7 +221,8 @@
 bool fromJSON(const json::Expr , DidChangeTextDocumentParams ) {
   json::ObjectMapper O(Params);
   return O && O.map("textDocument", R.textDocument) &&
- O.map("contentChanges", R.contentChanges);
+ O.map("contentChanges", R.contentChanges) &&
+ O.map("wantDiagnostics", R.wantDiagnostics);
 }
 
 bool fromJSON(const json::Expr , FileChangeType ) {
Index: clangd/ClangdLSPServer.cpp
===
--- clangd/ClangdLSPServer.cpp
+++ clangd/ClangdLSPServer.cpp
@@ -149,9 +149,13 @@
   if (Params.contentChanges.size() != 1)
 return replyError(ErrorCode::InvalidParams,
   "can only apply one change at a time");
+  auto WantDiags = WantDiagnostics::Auto;
+  if (Params.wantDiagnostics.hasValue())
+WantDiags = Params.wantDiagnostics.getValue() ? WantDiagnostics::Yes
+  : WantDiagnostics::No;
   // We only support full syncing right now.
   Server.addDocument(Params.textDocument.uri.file(),
- Params.contentChanges[0].text, WantDiagnostics::Auto);
+ Params.contentChanges[0].text, WantDiags);
 }
 
 void ClangdLSPServer::onFileEvent(DidChangeWatchedFilesParams ) {


Index: test/clangd/want-diagnostics.test
===
--- /dev/null
+++ test/clangd/want-diagnostics.test
@@ -0,0 +1,19 @@
+# RUN: clangd -lit-test < %s | FileCheck -strict-whitespace %s
+{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
+---
+{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"test:///main.cpp","languageId":"cpp","version":1,"text":"void main() {}"}}}
+#  CHECK:  "method": "textDocument/publishDiagnostics",
+---
+{"jsonrpc":"2.0","method":"textDocument/didChange","params":{"textDocument":{"uri":"test:///main.cpp","version":2},"contentChanges":[{"text":"void main() {}"}]}}
+---
+#  CHECK:  "method": "textDocument/publishDiagnostics",

[PATCH] D41102: Setup clang-doc frontend framework

2018-02-22 Thread Julie Hockett via Phabricator via cfe-commits
juliehockett added inline comments.



Comment at: clang-doc/BitcodeWriter.cpp:219
+
+void ClangDocBitcodeWriter::emitIntRecord(int Value, RecordId ID) {
+  if (!Value) return;

lebedev.ri wrote:
> Now, all these three `emit*Record` functions now have the 'same signature':
> ```
> template 
> void ClangDocBitcodeWriter::emitRecord(const T& Record, RecordId ID);
> 
> template <>
> void ClangDocBitcodeWriter::emitRecord(StringRef Str, RecordId ID) {
> ...
> ```
> 
> **Assuming there are no implicit conversions going on**, i'd make that change.
> It, again, may open the road for further generalizations.
I overloaded the functions -- cleaner, and deals with any implicit conversions 
nicely.



Comment at: clang-doc/BitcodeWriter.h:178
+  void emitTypeBlock(const std::unique_ptr );
+  void emitMemberTypeBlock(const std::unique_ptr );
+  void emitFieldTypeBlock(const std::unique_ptr );

lebedev.ri wrote:
> Let's continue cracking down on duplication.
> I think these four functions need the same template treatment as 
> `writeBitstreamForInfo()`
> 
> (please feel free to use better names)
> ```
> template
> void emitBlock(const std::unique_ptr );
> 
> template
> void emitTypedBlock(const std::unique_ptr ) {
>   StreamSubBlockGuard Block(Stream, MapFromInfoToBlockId::ID);
>   emitBlock(B);
> }
> 
> template<>
> void ClangDocBitcodeWriter::emitBlock(const std::unique_ptr ) {
>   emitStringRecord(T->TypeUSR, FIELD_TYPE_TYPE);
>   for (const auto  : T->Description) emitCommentBlock(CI);
> }
> ```
> 
> I agree that it seems strange, and seem to actually increase the code size so 
> far,
> but i believe by exposing similar functionality under one function,
> later, it will open the road for more opportunities of further consolidation.
Since it actually ended up duplicating the `writeBitstreamForInfo()` code, I 
rolled all of this into one `emitBlock()` entry point.


https://reviews.llvm.org/D41102



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


[PATCH] D41102: Setup clang-doc frontend framework

2018-02-22 Thread Julie Hockett via Phabricator via cfe-commits
juliehockett updated this revision to Diff 135453.
juliehockett marked 13 inline comments as done.
juliehockett added a comment.

Cleaning up bitcode writer


https://reviews.llvm.org/D41102

Files:
  CMakeLists.txt
  clang-doc/BitcodeWriter.cpp
  clang-doc/BitcodeWriter.h
  clang-doc/CMakeLists.txt
  clang-doc/ClangDoc.h
  clang-doc/Mapper.cpp
  clang-doc/Mapper.h
  clang-doc/Representation.h
  clang-doc/tool/CMakeLists.txt
  clang-doc/tool/ClangDocMain.cpp
  docs/clang-doc.rst
  test/CMakeLists.txt
  test/clang-doc/mapper-class.cpp
  test/clang-doc/mapper-enum.cpp
  test/clang-doc/mapper-function.cpp
  test/clang-doc/mapper-method.cpp
  test/clang-doc/mapper-namespace.cpp
  test/clang-doc/mapper-struct.cpp
  test/clang-doc/mapper-union.cpp

Index: test/clang-doc/mapper-union.cpp
===
--- /dev/null
+++ test/clang-doc/mapper-union.cpp
@@ -0,0 +1,29 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: echo "" > %t/compile_flags.txt
+// RUN: cp "%s" "%t/test.cpp"
+// RUN: clang-doc --dump --omit-filenames -doxygen -p %t %t/test.cpp -output=%t/docs
+// RUN: llvm-bcanalyzer %t/docs/c:@u...@d.bc --dump | FileCheck %s
+
+union D { int X; int Y; };
+// CHECK: 
+// CHECK: 
+  // CHECK: 
+// CHECK: 
+// CHECK: 
+  // CHECK:  blob data = 'D'
+  // CHECK: 
+  // CHECK: 
+  // CHECK: 
+// CHECK:  blob data = 'int'
+// CHECK:  blob data = 'D::X'
+// CHECK: 
+  // CHECK: 
+  // CHECK: 
+// CHECK:  blob data = 'int'
+// CHECK:  blob data = 'D::Y'
+// CHECK: 
+  // CHECK: 
+// CHECK: 
+
+
Index: test/clang-doc/mapper-struct.cpp
===
--- /dev/null
+++ test/clang-doc/mapper-struct.cpp
@@ -0,0 +1,23 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: echo "" > %t/compile_flags.txt
+// RUN: cp "%s" "%t/test.cpp"
+// RUN: clang-doc --dump --omit-filenames -doxygen -p %t %t/test.cpp -output=%t/docs
+// RUN: llvm-bcanalyzer %t/docs/c:@s...@c.bc --dump | FileCheck %s
+
+struct C { int i; };
+// CHECK: 
+// CHECK: 
+  // CHECK: 
+// CHECK: 
+// CHECK: 
+  // CHECK:  blob data = 'C'
+  // CHECK: 
+  // CHECK: 
+// CHECK:  blob data = 'int'
+// CHECK:  blob data = 'C::i'
+// CHECK: 
+  // CHECK: 
+// CHECK: 
+
+
Index: test/clang-doc/mapper-namespace.cpp
===
--- /dev/null
+++ test/clang-doc/mapper-namespace.cpp
@@ -0,0 +1,17 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: echo "" > %t/compile_flags.txt
+// RUN: cp "%s" "%t/test.cpp"
+// RUN: clang-doc --dump --omit-filenames -doxygen -p %t %t/test.cpp -output=%t/docs
+// RUN: llvm-bcanalyzer %t/docs/c:@n...@a.bc --dump | FileCheck %s
+
+namespace A {}
+// CHECK: 
+// CHECK: 
+  // CHECK: 
+// CHECK: 
+// CHECK: 
+  // CHECK:  blob data = 'A'
+// CHECK: 
+
+
Index: test/clang-doc/mapper-method.cpp
===
--- /dev/null
+++ test/clang-doc/mapper-method.cpp
@@ -0,0 +1,31 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: echo "" > %t/compile_flags.txt
+// RUN: cp "%s" "%t/test.cpp"
+// RUN: clang-doc --dump --omit-filenames -doxygen -p %t %t/test.cpp -output=%t/docs
+// RUN: llvm-bcanalyzer %t/docs/c:@S@G@F@Method#I#.bc --dump | FileCheck %s
+
+class G {
+public: 
+	int Method(int param) { return param; }
+};
+// CHECK: 
+// CHECK: 
+  // CHECK: 
+// CHECK: 
+// CHECK: 
+  // CHECK:  blob data = 'Method'
+  // CHECK: 
+  // CHECK:  blob data = 'c:@S@G'
+  // CHECK: 
+// CHECK:  blob data = 'int'
+  // CHECK: 
+  // CHECK: 
+// CHECK:  blob data = 'int'
+// CHECK:  blob data = 'param'
+  // CHECK: 
+// CHECK: 
+
+
+
+
Index: test/clang-doc/mapper-function.cpp
===
--- /dev/null
+++ test/clang-doc/mapper-function.cpp
@@ -0,0 +1,24 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: echo "" > %t/compile_flags.txt
+// RUN: cp "%s" "%t/test.cpp"
+// RUN: clang-doc --dump --omit-filenames -doxygen -p %t %t/test.cpp -output=%t/docs
+// RUN: llvm-bcanalyzer %t/docs/c:@F@F#I#.bc --dump | FileCheck %s
+
+int F(int param) { return param; }
+// CHECK: 
+// CHECK: 
+  // CHECK: 
+// CHECK: 
+// CHECK: 
+  // CHECK:  blob data = 'F'
+  // CHECK: 
+  // CHECK: 
+// CHECK:  blob data = 'int'
+  // CHECK: 
+  // CHECK: 
+// CHECK:  blob data = 'int'
+// CHECK:  blob data = 'param'
+  // CHECK: 
+// CHECK: 
+
Index: test/clang-doc/mapper-enum.cpp
===
--- /dev/null
+++ test/clang-doc/mapper-enum.cpp
@@ -0,0 +1,25 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: echo "" > %t/compile_flags.txt
+// RUN: cp "%s" "%t/test.cpp"
+// RUN: clang-doc --dump --omit-filenames -doxygen -p %t %t/test.cpp -output=%t/docs
+// RUN: llvm-bcanalyzer %t/docs/c:@e...@b.bc --dump | FileCheck %s
+
+enum B { X, Y };
+// CHECK: 
+// CHECK: 
+  // CHECK: 
+// CHECK: 
+// CHECK: 
+  // CHECK:  blob data = 'B'
+  

[PATCH] D42366: [CodeGen] Fix generation of TBAA tags for may-alias accesses

2018-02-22 Thread Hal Finkel via Phabricator via cfe-commits
hfinkel added a comment.

In https://reviews.llvm.org/D42366#1014546, @rjmccall wrote:

> In https://reviews.llvm.org/D42366#1014157, @kosarev wrote:
>
> > I think zero would serve better as the unknown-size value. People who are 
> > not aware of TBAA internals would guess that since zero-sized accesses make 
> > no sense, they are likely to have some special meaning. Similarly, for code 
> > that is supposed to process the size fields of access descriptors zero 
> > would be an obvious "illegal size value". In contrast, UINT64_MAX is just a 
> > very large number that doesn't hint anything on its special purpose.
>
>
> My thoughts exactly.
>
> John.


SGTM. Let's do that.


Repository:
  rC Clang

https://reviews.llvm.org/D42366



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


[PATCH] D43630: [Driver] Fix search paths on x32

2018-02-22 Thread James Clarke via Phabricator via cfe-commits
jrtc27 created this revision.
Herald added a subscriber: cfe-commits.

When targeting x32, the x32 libraries and headers should be used, not
the x86_64 ones (which may not even be available), so prioritise those
and use the right multiarch triple.


Repository:
  rC Clang

https://reviews.llvm.org/D43630

Files:
  lib/Driver/ToolChains/Gnu.cpp
  lib/Driver/ToolChains/Linux.cpp


Index: lib/Driver/ToolChains/Linux.cpp
===
--- lib/Driver/ToolChains/Linux.cpp
+++ lib/Driver/ToolChains/Linux.cpp
@@ -78,10 +78,13 @@
   return "i386-linux-gnu";
 break;
   case llvm::Triple::x86_64:
-// We don't want this for x32, otherwise it will match x86_64 libs
-if (TargetEnvironment != llvm::Triple::GNUX32 &&
-D.getVFS().exists(SysRoot + "/lib/x86_64-linux-gnu"))
-  return "x86_64-linux-gnu";
+if (TargetEnvironment == llvm::Triple::GNUX32) {
+  if (D.getVFS().exists(SysRoot + "/lib/x86_64-linux-gnux32"))
+return "x86_64-linux-gnux32";
+} else {
+  if (D.getVFS().exists(SysRoot + "/lib/x86_64-linux-gnu"))
+return "x86_64-linux-gnu";
+}
 break;
   case llvm::Triple::aarch64:
 if (D.getVFS().exists(SysRoot + "/lib/aarch64-linux-gnu"))
@@ -620,6 +623,8 @@
   // in use in any released version of Debian, so we should consider
   // removing them.
   "/usr/include/i686-linux-gnu/64", "/usr/include/i486-linux-gnu/64"};
+  const StringRef X32MultiarchIncludeDirs[] = {
+  "/usr/include/x86_64-linux-gnux32"};
   const StringRef X86MultiarchIncludeDirs[] = {
   "/usr/include/i386-linux-gnu",
 
@@ -661,7 +666,10 @@
   ArrayRef MultiarchIncludeDirs;
   switch (getTriple().getArch()) {
   case llvm::Triple::x86_64:
-MultiarchIncludeDirs = X86_64MultiarchIncludeDirs;
+if (getTriple().getEnvironment() == llvm::Triple::GNUX32)
+  MultiarchIncludeDirs = X32MultiarchIncludeDirs;
+else
+  MultiarchIncludeDirs = X86_64MultiarchIncludeDirs;
 break;
   case llvm::Triple::x86:
 MultiarchIncludeDirs = X86MultiarchIncludeDirs;
Index: lib/Driver/ToolChains/Gnu.cpp
===
--- lib/Driver/ToolChains/Gnu.cpp
+++ lib/Driver/ToolChains/Gnu.cpp
@@ -1848,7 +1848,10 @@
   "x86_64-manbo-linux-gnu", "x86_64-linux-gnu",
   "x86_64-slackware-linux", "x86_64-linux-android",
   "x86_64-unknown-linux"};
-  static const char *const X32LibDirs[] = {"/libx32"};
+  static const char *const X32LibDirs[] = {"/libx32", "/lib"};
+  static const char *const X32Triples[] = {
+  "x86_64-linux-gnux32","x86_64-unknown-linux-gnux32",
+  "x86_64-pc-linux-gnux32"};
   static const char *const X86LibDirs[] = {"/lib32", "/lib"};
   static const char *const X86Triples[] = {
   "i686-linux-gnu",   "i686-pc-linux-gnu", "i486-linux-gnu",
@@ -1989,14 +1992,16 @@
 }
 break;
   case llvm::Triple::x86_64:
-LibDirs.append(begin(X86_64LibDirs), end(X86_64LibDirs));
-TripleAliases.append(begin(X86_64Triples), end(X86_64Triples));
 // x32 is always available when x86_64 is available, so adding it as
 // secondary arch with x86_64 triples
 if (TargetTriple.getEnvironment() == llvm::Triple::GNUX32) {
-  BiarchLibDirs.append(begin(X32LibDirs), end(X32LibDirs));
+  LibDirs.append(begin(X32LibDirs), end(X32LibDirs));
+  TripleAliases.append(begin(X32Triples), end(X32Triples));
+  BiarchLibDirs.append(begin(X86_64LibDirs), end(X86_64LibDirs));
   BiarchTripleAliases.append(begin(X86_64Triples), end(X86_64Triples));
 } else {
+  LibDirs.append(begin(X86_64LibDirs), end(X86_64LibDirs));
+  TripleAliases.append(begin(X86_64Triples), end(X86_64Triples));
   BiarchLibDirs.append(begin(X86LibDirs), end(X86LibDirs));
   BiarchTripleAliases.append(begin(X86Triples), end(X86Triples));
 }


Index: lib/Driver/ToolChains/Linux.cpp
===
--- lib/Driver/ToolChains/Linux.cpp
+++ lib/Driver/ToolChains/Linux.cpp
@@ -78,10 +78,13 @@
   return "i386-linux-gnu";
 break;
   case llvm::Triple::x86_64:
-// We don't want this for x32, otherwise it will match x86_64 libs
-if (TargetEnvironment != llvm::Triple::GNUX32 &&
-D.getVFS().exists(SysRoot + "/lib/x86_64-linux-gnu"))
-  return "x86_64-linux-gnu";
+if (TargetEnvironment == llvm::Triple::GNUX32) {
+  if (D.getVFS().exists(SysRoot + "/lib/x86_64-linux-gnux32"))
+return "x86_64-linux-gnux32";
+} else {
+  if (D.getVFS().exists(SysRoot + "/lib/x86_64-linux-gnu"))
+return "x86_64-linux-gnu";
+}
 break;
   case llvm::Triple::aarch64:
 if (D.getVFS().exists(SysRoot + "/lib/aarch64-linux-gnu"))
@@ -620,6 +623,8 @@
   // in use in any released version of Debian, so we should consider
   // removing them.
   "/usr/include/i686-linux-gnu/64", "/usr/include/i486-linux-gnu/64"};
+  const 

[PATCH] D43628: [Sema][NFC] Split Function MultiVersioning decl semantic analysis into its own .cpp file.

2018-02-22 Thread Erich Keane via Phabricator via cfe-commits
erichkeane created this revision.
erichkeane added reviewers: rnk, echristo, aaron.ballman, rsmith.
Herald added subscribers: mgrang, mgorny.

I'm currently working on the cpu_dispatch and cpu_specific multiversion
support, which is making this functionality require a significant amount
of functions.  It seems that it would be easier to refactor this and add
additional mechanisms if unencumbered by the rest of SemaDecl (which itself
is getting quite large).


Repository:
  rC Clang

https://reviews.llvm.org/D43628

Files:
  include/clang/Sema/Sema.h
  lib/Sema/CMakeLists.txt
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaDeclMultiVersion.cpp

Index: lib/Sema/SemaDeclMultiVersion.cpp
===
--- lib/Sema/SemaDeclMultiVersion.cpp
+++ lib/Sema/SemaDeclMultiVersion.cpp
@@ -0,0 +1,353 @@
+//==SemaDeclMultiVersion.cpp - Semantic Analysis for MultiVersion Functions===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+//  This file implements semantic analysis for MultiVersion Function
+//  Declarations.
+//
+//===--===//
+
+#include "clang/Sema/SemaInternal.h"
+
+using namespace clang;
+using namespace sema;
+
+/// \brief Check the target attribute of the function for MultiVersion
+/// validity.
+///
+/// Returns true if there was an error, false otherwise.
+static bool CheckMultiVersionValue(Sema , const FunctionDecl *FD) {
+  const auto *TA = FD->getAttr();
+  assert(TA && "MultiVersion Candidate requires a target attribute");
+  TargetAttr::ParsedTargetAttr ParseInfo = TA->parse();
+  const TargetInfo  = S.Context.getTargetInfo();
+  enum ErrType { Feature = 0, Architecture = 1 };
+
+  if (!ParseInfo.Architecture.empty() &&
+  !TargetInfo.validateCpuIs(ParseInfo.Architecture)) {
+S.Diag(FD->getLocation(), diag::err_bad_multiversion_option)
+<< Architecture << ParseInfo.Architecture;
+return true;
+  }
+
+  for (const auto  : ParseInfo.Features) {
+auto BareFeat = StringRef{Feat}.substr(1);
+if (Feat[0] == '-') {
+  S.Diag(FD->getLocation(), diag::err_bad_multiversion_option)
+  << Feature << ("no-" + BareFeat).str();
+  return true;
+}
+
+if (!TargetInfo.validateCpuSupports(BareFeat) ||
+!TargetInfo.isValidFeatureName(BareFeat)) {
+  S.Diag(FD->getLocation(), diag::err_bad_multiversion_option)
+  << Feature << BareFeat;
+  return true;
+}
+  }
+  return false;
+}
+
+static bool CheckMultiVersionAdditionalRules(Sema , const FunctionDecl *OldFD,
+ const FunctionDecl *NewFD,
+ bool CausesMV) {
+  enum DoesntSupport {
+FuncTemplates = 0,
+VirtFuncs = 1,
+DeducedReturn = 2,
+Constructors = 3,
+Destructors = 4,
+DeletedFuncs = 5,
+DefaultedFuncs = 6
+  };
+  enum Different {
+CallingConv = 0,
+ReturnType = 1,
+ConstexprSpec = 2,
+InlineSpec = 3,
+StorageClass = 4,
+Linkage = 5
+  };
+
+  // For now, disallow all other attributes.  These should be opt-in, but
+  // an analysis of all of them is a future FIXME.
+  if (CausesMV && OldFD &&
+  std::distance(OldFD->attr_begin(), OldFD->attr_end()) != 1) {
+S.Diag(OldFD->getLocation(), diag::err_multiversion_no_other_attrs);
+S.Diag(NewFD->getLocation(), diag::note_multiversioning_caused_here);
+return true;
+  }
+
+  if (std::distance(NewFD->attr_begin(), NewFD->attr_end()) != 1)
+return S.Diag(NewFD->getLocation(), diag::err_multiversion_no_other_attrs);
+
+  if (NewFD->getTemplatedKind() == FunctionDecl::TK_FunctionTemplate)
+return S.Diag(NewFD->getLocation(), diag::err_multiversion_doesnt_support)
+   << FuncTemplates;
+
+  if (const auto *NewCXXFD = dyn_cast(NewFD)) {
+if (NewCXXFD->isVirtual())
+  return S.Diag(NewCXXFD->getLocation(),
+diag::err_multiversion_doesnt_support)
+ << VirtFuncs;
+
+if (const auto *NewCXXCtor = dyn_cast(NewFD))
+  return S.Diag(NewCXXCtor->getLocation(),
+diag::err_multiversion_doesnt_support)
+ << Constructors;
+
+if (const auto *NewCXXDtor = dyn_cast(NewFD))
+  return S.Diag(NewCXXDtor->getLocation(),
+diag::err_multiversion_doesnt_support)
+ << Destructors;
+  }
+
+  if (NewFD->isDeleted())
+return S.Diag(NewFD->getLocation(), diag::err_multiversion_doesnt_support)
+   << DeletedFuncs;
+
+  if (NewFD->isDefaulted())
+return S.Diag(NewFD->getLocation(), diag::err_multiversion_doesnt_support)
+   << DefaultedFuncs;
+
+  QualType NewQType = S.getASTContext().getCanonicalType(NewFD->getType());
+  const auto 

[PATCH] D43590: [clang-format] Fix regression when getStyle() called with empty filename

2018-02-22 Thread Bjorn Pettersson via Phabricator via cfe-commits
bjope added inline comments.



Comment at: unittests/Format/FormatTest.cpp:11727
+TEST(FormatStyle, GetStyleWithEmptyFileName) {
+  auto Style1 = getStyle("file", "", "Google");
+  ASSERT_TRUE((bool)Style1);

Do you really want to try to find a ".clang-format" file here, with fallback to 
"Google" if no such file is found?

When I'm building I usually end up having my build directory inside the llvm 
repo. And since there is a .clang-format file checked in to llvm that file is 
found, as it searches for a .clang-format file somewhere in the directory 
structure above the current dir when running the test (if I remember 
correctly?). We have had such problem before.

Can't you just as well do
  auto Style1 = getStyle("Google", "", "Google");
or is that not triggering the original bug?

Right now our build bots ends up like this (I guess it has found the 
.clang-format in my llvm/clang repo and decided to use "LLVM" as format for 
"Style1"):

```
FAIL: Clang-Unit :: Format/./FormatTests/FormatStyle.GetStyleWithEmptyFileName 
(14009 of 36611)
 TEST 'Clang-Unit :: 
Format/./FormatTests/FormatStyle.GetStyleWithEmptyFileName' FAILED 

Note: Google Test filter = FormatStyle.GetStyleWithEmptyFileName
[==] Running 1 test from 1 test case.
[--] Global test environment set-up.
[--] 1 test from FormatStyle
[ RUN  ] FormatStyle.GetStyleWithEmptyFileName
../tools/clang/unittests/Format/FormatTest.cpp:11729: Failure
  Expected: *Style1
  Which is: 456-byte object 
To be equal to: getGoogleStyle()
  Which is: 456-byte object 
[  FAILED  ] FormatStyle.GetStyleWithEmptyFileName (1 ms)
[--] 1 test from FormatStyle (1 ms total)

[--] Global test environment tear-down
[==] 1 test from 1 test case ran. (1 ms total)
[  PASSED  ] 0 tests.
[  FAILED  ] 1 test, listed below:
[  FAILED  ] FormatStyle.GetStyleWithEmptyFileName

```



Repository:
  rC Clang

https://reviews.llvm.org/D43590



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


r325807 - [docs] Regenerate command line reference

2018-02-22 Thread Jonas Hahnfeld via cfe-commits
Author: hahnfeld
Date: Thu Feb 22 09:10:28 2018
New Revision: 325807

URL: http://llvm.org/viewvc/llvm-project?rev=325807=rev
Log:
[docs] Regenerate command line reference

Modified:
cfe/trunk/docs/ClangCommandLineReference.rst

Modified: cfe/trunk/docs/ClangCommandLineReference.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ClangCommandLineReference.rst?rev=325807=325806=325807=diff
==
--- cfe/trunk/docs/ClangCommandLineReference.rst (original)
+++ cfe/trunk/docs/ClangCommandLineReference.rst Thu Feb 22 09:10:28 2018
@@ -61,10 +61,10 @@ Pass  to the ptxas assembler
 Pass  to the target offloading toolchain.
 
 .. program:: clang1
-.. option:: -Xopenmp-target= 
+.. option:: -Xopenmp-target= 
 .. program:: clang
 
-Pass  to the specified target offloading toolchain. The triple that 
identifies the toolchain must be provided after the equals sign.
+Pass  to the target offloading toolchain identified by .
 
 .. option:: -Z
 
@@ -710,6 +710,14 @@ Print source range spans in numeric form
 
 .. option:: -fdiagnostics-show-category=
 
+.. option:: -fdiscard-value-names, -fno-discard-value-names
+
+Discard value names in LLVM IR
+
+.. option:: -fexperimental-isel, -fno-experimental-isel
+
+Enables the experimental global instruction selector
+
 .. option:: -fexperimental-new-pass-manager, -fno-experimental-new-pass-manager
 
 Enables an experimental new pass manager in LLVM.
@@ -744,6 +752,10 @@ Level of field padding for AddressSaniti
 
 Enable linker dead stripping of globals in AddressSanitizer
 
+.. option:: -fsanitize-address-poison-class-member-array-new-cookie, 
-fno-sanitize-address-poison-class-member-array-new-cookie
+
+Enable poisoning array cookies when using class member operator new\[\] in 
AddressSanitizer
+
 .. option:: -fsanitize-address-use-after-scope, 
-fno-sanitize-address-use-after-scope
 
 Enable use-after-scope detection in AddressSanitizer
@@ -876,6 +888,10 @@ Add directory to include search path
 
 Restrict all prior -I flags to double-quoted inclusion and remove current 
directory from include path
 
+.. option:: --cuda-path-ignore-env
+
+Ignore environment variables to detect CUDA installation
+
 .. option:: --cuda-path=
 
 CUDA installation path
@@ -1507,12 +1523,6 @@ Do not treat C++ operator name keywords
 
 .. option:: -fno-working-directory
 
-.. option:: -fnoopenmp-relocatable-target
-
-Do not compile OpenMP target code as relocatable.
-
-.. option:: -fnoopenmp-use-tls
-
 .. option:: -fobjc-abi-version=
 
 .. option:: -fobjc-arc, -fno-objc-arc
@@ -1551,18 +1561,12 @@ Enable ARC-style weak references in Obje
 
 .. option:: -fopenmp, -fno-openmp
 
-.. option:: -fopenmp-dump-offload-linker-script
-
-.. option:: -fopenmp-relocatable-target
-
-OpenMP target code is compiled as relocatable using the -c flag. For OpenMP 
targets the code is relocatable by default.
+Parse OpenMP pragmas and generate parallel code.
 
 .. option:: -fopenmp-simd, -fno-openmp-simd
 
 Emit OpenMP code only for SIMD-based constructs.
 
-.. option:: -fopenmp-use-tls
-
 .. option:: -fopenmp-version=
 
 .. program:: clang1
@@ -1748,7 +1752,7 @@ Enable the superword-level parallelism v
 
 .. option:: -fsplit-dwarf-inlining, -fno-split-dwarf-inlining
 
-Place debug types in their own section (ELF Only)
+Provide minimal debug info in the object/executable to facilitate online 
symbolication/stack traces in the absence of .dwo/.dwp files when using Split 
DWARF
 
 .. option:: -fsplit-stack
 
@@ -1974,6 +1978,10 @@ OpenCL language standard to compile for.
 
 OpenCL only. This option is added for compatibility with OpenCL 1.0.
 
+.. option:: -cl-uniform-work-group-size
+
+OpenCL only. Defines that the global work-size be a multiple of the work-group 
size specified to clEnqueueNDRangeKernel
+
 .. option:: -cl-unsafe-math-optimizations
 
 OpenCL only. Allow unsafe floating-point optimizations.  Also implies 
-cl-no-signed-zeros and -cl-mad-enable.
@@ -2086,6 +2094,10 @@ Use Intel MCU ABI
 
 (integrated-as) Emit an object file which can be used with an incremental 
linker
 
+.. option:: -mindirect-jump=
+
+Change indirect jump instructions to inhibit speculation
+
 .. option:: -miphoneos-version-min=, -mios-version-min=
 
 .. option:: -mips16
@@ -2436,6 +2448,8 @@ X86
 
 .. option:: -mrtm, -mno-rtm
 
+.. option:: -msahf, -mno-sahf
+
 .. option:: -msgx, -mno-sgx
 
 .. option:: -msha, -mno-sha


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


[PATCH] D42841: [docs] Improve help for OpenMP options

2018-02-22 Thread Jonas Hahnfeld via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL325806: [docs] Improve help for OpenMP options, NFC. 
(authored by Hahnfeld, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D42841?vs=132571=135439#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D42841

Files:
  cfe/trunk/include/clang/Driver/Options.td


Index: cfe/trunk/include/clang/Driver/Options.td
===
--- cfe/trunk/include/clang/Driver/Options.td
+++ cfe/trunk/include/clang/Driver/Options.td
@@ -466,7 +466,8 @@
 def Xopenmp_target : Separate<["-"], "Xopenmp-target">,
   HelpText<"Pass  to the target offloading toolchain.">, 
MetaVarName<"">;
 def Xopenmp_target_EQ : JoinedAndSeparate<["-"], "Xopenmp-target=">,
-  HelpText<"Pass  to the specified target offloading toolchain. The 
triple that identifies the toolchain must be provided after the equals sign.">, 
MetaVarName<"">;
+  HelpText<"Pass  to the target offloading toolchain identified by 
.">,
+  MetaVarName<" ">;
 def z : Separate<["-"], "z">, Flags<[LinkerInput, RenderAsInput]>,
   HelpText<"Pass -z  to the linker">, MetaVarName<"">,
   Group;
@@ -1397,24 +1398,26 @@
 
 def fobjc_sender_dependent_dispatch : Flag<["-"], 
"fobjc-sender-dependent-dispatch">, Group;
 def fomit_frame_pointer : Flag<["-"], "fomit-frame-pointer">, Group;
-def fopenmp : Flag<["-"], "fopenmp">, Group, Flags<[CC1Option, 
NoArgumentUnused]>;
+def fopenmp : Flag<["-"], "fopenmp">, Group, Flags<[CC1Option, 
NoArgumentUnused]>,
+  HelpText<"Parse OpenMP pragmas and generate parallel code.">;
 def fno_openmp : Flag<["-"], "fno-openmp">, Group, 
Flags<[NoArgumentUnused]>;
 def fopenmp_version_EQ : Joined<["-"], "fopenmp-version=">, Group, 
Flags<[CC1Option, NoArgumentUnused]>;
 def fopenmp_EQ : Joined<["-"], "fopenmp=">, Group;
-def fopenmp_use_tls : Flag<["-"], "fopenmp-use-tls">, Group, 
Flags<[NoArgumentUnused]>;
-def fnoopenmp_use_tls : Flag<["-"], "fnoopenmp-use-tls">, Group, 
Flags<[CC1Option, NoArgumentUnused]>;
+def fopenmp_use_tls : Flag<["-"], "fopenmp-use-tls">, Group,
+  Flags<[NoArgumentUnused, HelpHidden]>;
+def fnoopenmp_use_tls : Flag<["-"], "fnoopenmp-use-tls">, Group,
+  Flags<[CC1Option, NoArgumentUnused, HelpHidden]>;
 def fopenmp_targets_EQ : CommaJoined<["-"], "fopenmp-targets=">, 
Flags<[DriverOption, CC1Option]>,
   HelpText<"Specify comma-separated list of triples OpenMP offloading targets 
to be supported">;
-def fopenmp_dump_offload_linker_script : Flag<["-"], 
"fopenmp-dump-offload-linker-script">, Group,
-  Flags<[NoArgumentUnused]>;
-def fopenmp_relocatable_target : Flag<["-"], "fopenmp-relocatable-target">, 
Group, Flags<[CC1Option, NoArgumentUnused]>,
-  HelpText<"OpenMP target code is compiled as relocatable using the -c flag. 
For OpenMP targets the code is relocatable by default.">;
-def fnoopenmp_relocatable_target : Flag<["-"], 
"fnoopenmp-relocatable-target">, Group, Flags<[CC1Option, 
NoArgumentUnused]>,
-  HelpText<"Do not compile OpenMP target code as relocatable.">;
+def fopenmp_dump_offload_linker_script : Flag<["-"], 
"fopenmp-dump-offload-linker-script">,
+  Group, Flags<[NoArgumentUnused, HelpHidden]>;
+def fopenmp_relocatable_target : Flag<["-"], "fopenmp-relocatable-target">,
+  Group, Flags<[CC1Option, NoArgumentUnused, HelpHidden]>;
+def fnoopenmp_relocatable_target : Flag<["-"], "fnoopenmp-relocatable-target">,
+  Group, Flags<[CC1Option, NoArgumentUnused, HelpHidden]>;
 def fopenmp_simd : Flag<["-"], "fopenmp-simd">, Group, 
Flags<[CC1Option, NoArgumentUnused]>,
   HelpText<"Emit OpenMP code only for SIMD-based constructs.">;
-def fno_openmp_simd : Flag<["-"], "fno-openmp-simd">, Group, 
Flags<[CC1Option, NoArgumentUnused]>,
-  HelpText<"Disable OpenMP code for SIMD-based constructs.">;
+def fno_openmp_simd : Flag<["-"], "fno-openmp-simd">, Group, 
Flags<[CC1Option, NoArgumentUnused]>;
 def fno_optimize_sibling_calls : Flag<["-"], "fno-optimize-sibling-calls">, 
Group;
 def foptimize_sibling_calls : Flag<["-"], "foptimize-sibling-calls">, 
Group;
 def force__cpusubtype__ALL : Flag<["-"], "force_cpusubtype_ALL">;


Index: cfe/trunk/include/clang/Driver/Options.td
===
--- cfe/trunk/include/clang/Driver/Options.td
+++ cfe/trunk/include/clang/Driver/Options.td
@@ -466,7 +466,8 @@
 def Xopenmp_target : Separate<["-"], "Xopenmp-target">,
   HelpText<"Pass  to the target offloading toolchain.">, MetaVarName<"">;
 def Xopenmp_target_EQ : JoinedAndSeparate<["-"], "Xopenmp-target=">,
-  HelpText<"Pass  to the specified target offloading toolchain. The triple that identifies the toolchain must be provided after the equals sign.">, MetaVarName<"">;
+  HelpText<"Pass  to the target offloading toolchain identified by .">,
+  MetaVarName<" ">;
 def z : Separate<["-"], "z">, Flags<[LinkerInput, RenderAsInput]>,
   HelpText<"Pass -z  to the linker">, 

[PATCH] D42840: [docs] Fix duplicate arguments for JoinedAndSeparate

2018-02-22 Thread Jonas Hahnfeld via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL325805: [docs] Fix duplicate arguments for JoinedAndSeparate 
(authored by Hahnfeld, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D42840?vs=132559=135438#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D42840

Files:
  cfe/trunk/utils/TableGen/ClangOptionDocEmitter.cpp


Index: cfe/trunk/utils/TableGen/ClangOptionDocEmitter.cpp
===
--- cfe/trunk/utils/TableGen/ClangOptionDocEmitter.cpp
+++ cfe/trunk/utils/TableGen/ClangOptionDocEmitter.cpp
@@ -245,19 +245,27 @@
 void emitOptionName(StringRef Prefix, const Record *Option, raw_ostream ) {
   // Find the arguments to list after the option.
   unsigned NumArgs = getNumArgsForKind(Option->getValueAsDef("Kind"), Option);
+  bool HasMetaVarName = !Option->isValueUnset("MetaVarName");
 
   std::vector Args;
-  if (!Option->isValueUnset("MetaVarName"))
+  if (HasMetaVarName)
 Args.push_back(Option->getValueAsString("MetaVarName"));
   else if (NumArgs == 1)
 Args.push_back("");
 
-  while (Args.size() < NumArgs) {
-Args.push_back(("").str());
-// Use '--args  ...' if any number of args are allowed.
-if (Args.size() == 2 && NumArgs == UnlimitedArgs) {
-  Args.back() += "...";
-  break;
+  // Fill up arguments if this option didn't provide a meta var name or it
+  // supports an unlimited number of arguments. We can't see how many arguments
+  // already are in a meta var name, so assume it has right number. This is
+  // needed for JoinedAndSeparate options so that there arent't too many
+  // arguments.
+  if (!HasMetaVarName || NumArgs == UnlimitedArgs) {
+while (Args.size() < NumArgs) {
+  Args.push_back(("").str());
+  // Use '--args  ...' if any number of args are allowed.
+  if (Args.size() == 2 && NumArgs == UnlimitedArgs) {
+Args.back() += "...";
+break;
+  }
 }
   }
 


Index: cfe/trunk/utils/TableGen/ClangOptionDocEmitter.cpp
===
--- cfe/trunk/utils/TableGen/ClangOptionDocEmitter.cpp
+++ cfe/trunk/utils/TableGen/ClangOptionDocEmitter.cpp
@@ -245,19 +245,27 @@
 void emitOptionName(StringRef Prefix, const Record *Option, raw_ostream ) {
   // Find the arguments to list after the option.
   unsigned NumArgs = getNumArgsForKind(Option->getValueAsDef("Kind"), Option);
+  bool HasMetaVarName = !Option->isValueUnset("MetaVarName");
 
   std::vector Args;
-  if (!Option->isValueUnset("MetaVarName"))
+  if (HasMetaVarName)
 Args.push_back(Option->getValueAsString("MetaVarName"));
   else if (NumArgs == 1)
 Args.push_back("");
 
-  while (Args.size() < NumArgs) {
-Args.push_back(("").str());
-// Use '--args  ...' if any number of args are allowed.
-if (Args.size() == 2 && NumArgs == UnlimitedArgs) {
-  Args.back() += "...";
-  break;
+  // Fill up arguments if this option didn't provide a meta var name or it
+  // supports an unlimited number of arguments. We can't see how many arguments
+  // already are in a meta var name, so assume it has right number. This is
+  // needed for JoinedAndSeparate options so that there arent't too many
+  // arguments.
+  if (!HasMetaVarName || NumArgs == UnlimitedArgs) {
+while (Args.size() < NumArgs) {
+  Args.push_back(("").str());
+  // Use '--args  ...' if any number of args are allowed.
+  if (Args.size() == 2 && NumArgs == UnlimitedArgs) {
+Args.back() += "...";
+break;
+  }
 }
   }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r325806 - [docs] Improve help for OpenMP options, NFC.

2018-02-22 Thread Jonas Hahnfeld via cfe-commits
Author: hahnfeld
Date: Thu Feb 22 09:06:35 2018
New Revision: 325806

URL: http://llvm.org/viewvc/llvm-project?rev=325806=rev
Log:
[docs] Improve help for OpenMP options, NFC.

 * Add HelpText for -fopenmp so that it appears in clang --help.
 * Hide -fno-openmp-simd, only list the positive option.
 * Hide -fopenmp-relocatable-target and -fopenmp-use-tls from
   clang --help and from ClangCommandLineReference.
 * Improve MetaVarName for -Xopenmp-target=<...>.

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

Modified:
cfe/trunk/include/clang/Driver/Options.td

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=325806=325805=325806=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Thu Feb 22 09:06:35 2018
@@ -466,7 +466,8 @@ def Xcuda_ptxas : Separate<["-"], "Xcuda
 def Xopenmp_target : Separate<["-"], "Xopenmp-target">,
   HelpText<"Pass  to the target offloading toolchain.">, 
MetaVarName<"">;
 def Xopenmp_target_EQ : JoinedAndSeparate<["-"], "Xopenmp-target=">,
-  HelpText<"Pass  to the specified target offloading toolchain. The 
triple that identifies the toolchain must be provided after the equals sign.">, 
MetaVarName<"">;
+  HelpText<"Pass  to the target offloading toolchain identified by 
.">,
+  MetaVarName<" ">;
 def z : Separate<["-"], "z">, Flags<[LinkerInput, RenderAsInput]>,
   HelpText<"Pass -z  to the linker">, MetaVarName<"">,
   Group;
@@ -1397,24 +1398,26 @@ def fno_objc_nonfragile_abi : Flag<["-"]
 
 def fobjc_sender_dependent_dispatch : Flag<["-"], 
"fobjc-sender-dependent-dispatch">, Group;
 def fomit_frame_pointer : Flag<["-"], "fomit-frame-pointer">, Group;
-def fopenmp : Flag<["-"], "fopenmp">, Group, Flags<[CC1Option, 
NoArgumentUnused]>;
+def fopenmp : Flag<["-"], "fopenmp">, Group, Flags<[CC1Option, 
NoArgumentUnused]>,
+  HelpText<"Parse OpenMP pragmas and generate parallel code.">;
 def fno_openmp : Flag<["-"], "fno-openmp">, Group, 
Flags<[NoArgumentUnused]>;
 def fopenmp_version_EQ : Joined<["-"], "fopenmp-version=">, Group, 
Flags<[CC1Option, NoArgumentUnused]>;
 def fopenmp_EQ : Joined<["-"], "fopenmp=">, Group;
-def fopenmp_use_tls : Flag<["-"], "fopenmp-use-tls">, Group, 
Flags<[NoArgumentUnused]>;
-def fnoopenmp_use_tls : Flag<["-"], "fnoopenmp-use-tls">, Group, 
Flags<[CC1Option, NoArgumentUnused]>;
+def fopenmp_use_tls : Flag<["-"], "fopenmp-use-tls">, Group,
+  Flags<[NoArgumentUnused, HelpHidden]>;
+def fnoopenmp_use_tls : Flag<["-"], "fnoopenmp-use-tls">, Group,
+  Flags<[CC1Option, NoArgumentUnused, HelpHidden]>;
 def fopenmp_targets_EQ : CommaJoined<["-"], "fopenmp-targets=">, 
Flags<[DriverOption, CC1Option]>,
   HelpText<"Specify comma-separated list of triples OpenMP offloading targets 
to be supported">;
-def fopenmp_dump_offload_linker_script : Flag<["-"], 
"fopenmp-dump-offload-linker-script">, Group,
-  Flags<[NoArgumentUnused]>;
-def fopenmp_relocatable_target : Flag<["-"], "fopenmp-relocatable-target">, 
Group, Flags<[CC1Option, NoArgumentUnused]>,
-  HelpText<"OpenMP target code is compiled as relocatable using the -c flag. 
For OpenMP targets the code is relocatable by default.">;
-def fnoopenmp_relocatable_target : Flag<["-"], 
"fnoopenmp-relocatable-target">, Group, Flags<[CC1Option, 
NoArgumentUnused]>,
-  HelpText<"Do not compile OpenMP target code as relocatable.">;
+def fopenmp_dump_offload_linker_script : Flag<["-"], 
"fopenmp-dump-offload-linker-script">,
+  Group, Flags<[NoArgumentUnused, HelpHidden]>;
+def fopenmp_relocatable_target : Flag<["-"], "fopenmp-relocatable-target">,
+  Group, Flags<[CC1Option, NoArgumentUnused, HelpHidden]>;
+def fnoopenmp_relocatable_target : Flag<["-"], "fnoopenmp-relocatable-target">,
+  Group, Flags<[CC1Option, NoArgumentUnused, HelpHidden]>;
 def fopenmp_simd : Flag<["-"], "fopenmp-simd">, Group, 
Flags<[CC1Option, NoArgumentUnused]>,
   HelpText<"Emit OpenMP code only for SIMD-based constructs.">;
-def fno_openmp_simd : Flag<["-"], "fno-openmp-simd">, Group, 
Flags<[CC1Option, NoArgumentUnused]>,
-  HelpText<"Disable OpenMP code for SIMD-based constructs.">;
+def fno_openmp_simd : Flag<["-"], "fno-openmp-simd">, Group, 
Flags<[CC1Option, NoArgumentUnused]>;
 def fno_optimize_sibling_calls : Flag<["-"], "fno-optimize-sibling-calls">, 
Group;
 def foptimize_sibling_calls : Flag<["-"], "foptimize-sibling-calls">, 
Group;
 def force__cpusubtype__ALL : Flag<["-"], "force_cpusubtype_ALL">;


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


r325805 - [docs] Fix duplicate arguments for JoinedAndSeparate

2018-02-22 Thread Jonas Hahnfeld via cfe-commits
Author: hahnfeld
Date: Thu Feb 22 09:06:27 2018
New Revision: 325805

URL: http://llvm.org/viewvc/llvm-project?rev=325805=rev
Log:
[docs] Fix duplicate arguments for JoinedAndSeparate

We can't see how many arguments are in the meta var name, so just
assume that it is the right number.

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

Modified:
cfe/trunk/utils/TableGen/ClangOptionDocEmitter.cpp

Modified: cfe/trunk/utils/TableGen/ClangOptionDocEmitter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/TableGen/ClangOptionDocEmitter.cpp?rev=325805=325804=325805=diff
==
--- cfe/trunk/utils/TableGen/ClangOptionDocEmitter.cpp (original)
+++ cfe/trunk/utils/TableGen/ClangOptionDocEmitter.cpp Thu Feb 22 09:06:27 2018
@@ -245,19 +245,27 @@ void emitOptionWithArgs(StringRef Prefix
 void emitOptionName(StringRef Prefix, const Record *Option, raw_ostream ) {
   // Find the arguments to list after the option.
   unsigned NumArgs = getNumArgsForKind(Option->getValueAsDef("Kind"), Option);
+  bool HasMetaVarName = !Option->isValueUnset("MetaVarName");
 
   std::vector Args;
-  if (!Option->isValueUnset("MetaVarName"))
+  if (HasMetaVarName)
 Args.push_back(Option->getValueAsString("MetaVarName"));
   else if (NumArgs == 1)
 Args.push_back("");
 
-  while (Args.size() < NumArgs) {
-Args.push_back(("").str());
-// Use '--args  ...' if any number of args are allowed.
-if (Args.size() == 2 && NumArgs == UnlimitedArgs) {
-  Args.back() += "...";
-  break;
+  // Fill up arguments if this option didn't provide a meta var name or it
+  // supports an unlimited number of arguments. We can't see how many arguments
+  // already are in a meta var name, so assume it has right number. This is
+  // needed for JoinedAndSeparate options so that there arent't too many
+  // arguments.
+  if (!HasMetaVarName || NumArgs == UnlimitedArgs) {
+while (Args.size() < NumArgs) {
+  Args.push_back(("").str());
+  // Use '--args  ...' if any number of args are allowed.
+  if (Args.size() == 2 && NumArgs == UnlimitedArgs) {
+Args.back() += "...";
+break;
+  }
 }
   }
 


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


[PATCH] D43625: [OpenMP] Remove implicit data sharing code gen that aims to use device shared memory

2018-02-22 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp:564
+llvm::Value *FnArgs[] = {ZeroAddr.getPointer(), ZeroAddr.getPointer()};
+emitCall(CGF, Fn, FnArgs);
 

Pass non-null `SourceLocation` here as the last argument


Repository:
  rC Clang

https://reviews.llvm.org/D43625



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


  1   2   >