[PATCH] D104981: [clang-tidy] Add -line-filter to run-clang-tidy.py

2021-06-28 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev accepted this revision.
kbobyrev added a comment.
This revision is now accepted and ready to land.

LGTM, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104981

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


[PATCH] D104981: [clang-tidy] Add -line-filter to run-clang-tidy.py

2021-06-28 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev added a comment.

Do you need help landing it?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104981

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


[PATCH] D99005: [clang] Implement P2266 Simpler implicit move

2021-06-28 Thread Stephan Bergmann via Phabricator via cfe-commits
sberg added a comment.

In D99005#2843201 , @mizvekov wrote:

> I have talked to the MSVC STL maintainers. They would be open to a pull 
> request for fixing this.
> The repo can be found at https://github.com/microsoft/STL
> Be my guest if you want to submit that fix yourself.
> If not, I can probably do it in the near future.

Thanks a lot for the link.  Filed https://github.com/microsoft/STL/pull/2025 
"Adapt some return statements to P2266R1 'Simpler implicit move'" now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99005

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


[PATCH] D103849: Fix undeduced type when instanciating template member

2021-06-28 Thread serge via Phabricator via cfe-commits
serge-sans-paille added a comment.

@rsmith : gentle ping ;-)


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

https://reviews.llvm.org/D103849

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


[PATCH] D104904: [OpenMP][AMDGCN] Initial math headers support

2021-06-28 Thread Pushpinder Singh via Phabricator via cfe-commits
pdhaliwal updated this revision to Diff 354801.
pdhaliwal marked 2 inline comments as done.
pdhaliwal added a comment.

Addressed review comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104904

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Headers/__clang_hip_cmath.h
  clang/lib/Headers/__clang_hip_math.h
  clang/lib/Headers/openmp_wrappers/__clang_openmp_device_functions.h
  clang/lib/Headers/openmp_wrappers/cmath
  clang/lib/Headers/openmp_wrappers/math.h
  clang/test/Headers/Inputs/include/algorithm
  clang/test/Headers/Inputs/include/cstdlib
  clang/test/Headers/Inputs/include/utility
  clang/test/Headers/amdgcn_openmp_device_math.c
  clang/test/Headers/openmp_device_math_isnan.cpp

Index: clang/test/Headers/openmp_device_math_isnan.cpp
===
--- clang/test/Headers/openmp_device_math_isnan.cpp
+++ clang/test/Headers/openmp_device_math_isnan.cpp
@@ -21,14 +21,14 @@
 double math(float f, double d) {
   double r = 0;
   // INT_RETURN: call i32 @__nv_isnanf(float
-  // AMD_INT_RETURN: call i32 @_{{.*}}isnanf(float
+  // AMD_INT_RETURN: call i32 @__ocml_isnan_f32(float
   // BOOL_RETURN: call i32 @__nv_isnanf(float
-  // AMD_BOOL_RETURN: call zeroext i1 @_{{.*}}isnanf(float
+  // AMD_BOOL_RETURN: call i32 @__ocml_isnan_f32(float
   r += std::isnan(f);
   // INT_RETURN: call i32 @__nv_isnand(double
-  // AMD_INT_RETURN: call i32 @_{{.*}}isnand(double
+  // AMD_INT_RETURN: call i32 @__ocml_isnan_f64(double
   // BOOL_RETURN: call i32 @__nv_isnand(double
-  // AMD_BOOL_RETURN: call zeroext i1 @_{{.*}}isnand(double
+  // AMD_BOOL_RETURN: call i32 @__ocml_isnan_f64(double
   r += std::isnan(d);
   return r;
 }
Index: clang/test/Headers/amdgcn_openmp_device_math.c
===
--- /dev/null
+++ clang/test/Headers/amdgcn_openmp_device_math.c
@@ -0,0 +1,51 @@
+// RUN: %clang_cc1 -internal-isystem %S/Inputs/include -x c -fopenmp -triple x86_64-unknown-unknown -fopenmp-targets=amdgcn-amd-amdhsa -emit-llvm-bc %s -o %t-host.bc
+// RUN: %clang_cc1 -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_device_functions.h -internal-isystem %S/../../lib/Headers/openmp_wrappers -internal-isystem %S/Inputs/include -x c -fopenmp -triple amdgcn-amd-amdhsa -aux-triple x86_64-unknown-unknown -fopenmp-targets=amdgcn-amd-amdhsa -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-host.bc -o - | FileCheck %s --check-prefixes=CHECK-C,CHECK
+// RUN: %clang_cc1 -internal-isystem %S/Inputs/include -x c++ -fopenmp -triple x86_64-unknown-unknown -fopenmp-targets=amdgcn-amd-amdhsa -emit-llvm-bc %s -o %t-host.bc
+// RUN: %clang_cc1 -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_device_functions.h -internal-isystem %S/../../lib/Headers/openmp_wrappers -internal-isystem %S/Inputs/include -x c++ -fopenmp -triple amdgcn-amd-amdhsa -aux-triple x86_64-unknown-unknown -fopenmp-targets=amdgcn-amd-amdhsa -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-host.bc -o - | FileCheck %s --check-prefixes=CHECK-CPP,CHECK
+
+#ifdef __cplusplus
+#include 
+#else
+#include 
+#endif
+
+void test_math_f64(double x) {
+// CHECK-LABEL: define {{.*}}test_math_f64
+#pragma omp target
+  {
+// CHECK: call double @__ocml_sin_f64
+double l1 = sin(x);
+// CHECK: call double @__ocml_cos_f64
+double l2 = cos(x);
+// CHECK: call double @__ocml_fabs_f64
+double l3 = fabs(x);
+  }
+}
+
+void test_math_f32(float x) {
+// CHECK-LABEL: define {{.*}}test_math_f32
+#pragma omp target
+  {
+// CHECK-C: call double @__ocml_sin_f64
+// CHECK-CPP: call float @__ocml_sin_f32
+float l1 = sin(x);
+// CHECK-C: call double @__ocml_cos_f64
+// CHECK-CPP: call float @__ocml_cos_f32
+float l2 = cos(x);
+// CHECK-C: call double @__ocml_fabs_f64
+// CHECK-CPP: call float @__ocml_fabs_f32
+float l3 = fabs(x);
+  }
+}
+void test_math_f32_suffix(float x) {
+// CHECK-LABEL: define {{.*}}test_math_f32_suffix
+#pragma omp target
+  {
+// CHECK: call float @__ocml_sin_f32
+float l1 = sinf(x);
+// CHECK: call float @__ocml_cos_f32
+float l2 = cosf(x);
+// CHECK: call float @__ocml_fabs_f32
+float l3 = fabsf(x);
+  }
+}
Index: clang/test/Headers/Inputs/include/utility
===
--- /dev/null
+++ clang/test/Headers/Inputs/include/utility
@@ -0,0 +1,2 @@
+#pragma once
+
Index: clang/test/Headers/Inputs/include/cstdlib
===
--- clang/test/Headers/Inputs/include/cstdlib
+++ clang/test/Headers/Inputs/include/cstdlib
@@ -23,9 +23,13 @@
 inline long long
 abs(long long __x) { return __builtin_llabs (__x); }
 
+// amdgcn already provides definition of fabs
+#ifndef __AMDGCN__
 float fabs(float __x) { return __

[PATCH] D104904: [OpenMP][AMDGCN] Initial math headers support

2021-06-28 Thread Pushpinder Singh via Phabricator via cfe-commits
pdhaliwal added inline comments.



Comment at: clang/lib/Headers/__clang_hip_math.h:29
+#else
 #define __DEVICE__ static __device__ inline __attribute__((always_inline))
+#endif

JonChesterfield wrote:
> wonder if HIP would benefit from nothrow here
Would like to keep hip changes minimal in this patch.



Comment at: clang/lib/Headers/__clang_hip_math.h:35
+#ifdef __OPENMP_AMDGCN__
+#define __RETURN_TYPE int
+#else

jdoerfert wrote:
> JonChesterfield wrote:
> > I'd expect openmp to match the cplusplus/c distinction here, as openmp 
> > works on C source
> ^ Agreed. Though, we use a different trick because it's unfortunately not as 
> straight forward always and can be decided based on the C vs C++.
This is somewhat tricky. Since declaration of `__finite/__isnan /__isinff` is 
with int return type in standard library (and the corresponding methods in C++ 
seems to be isfinite, isnan and isinf with bool return type), the compiler 
fails to resolve these functions when using bool. I don't know how HIP is 
working.

__RETURN_TYPE macro is only being used with the following methods:
1. __finite
2. __isnan
3. __isinf
4. __signbit

and with the corresponding float versions.



Comment at: clang/lib/Headers/openmp_wrappers/cmath:83
+#include <__clang_hip_cmath.h>
+#undef __OPENMP_AMDGCN__
+

jdoerfert wrote:
> No match_any needed (here and elsewhere).
> 
> Also, don't we want all but the includes to be the same for both GPUs. Maybe 
> we have a device(kind(gpu)) variant and inside the nvptx and amdgpu just for 
> the respective include?
device(kind(gpu)) breaks nvptx and hip with lots of errors like below,

```
...
__clang_cuda_device_functions.h:29:40: error: use of undeclared identifier 
'__nvvm_vote_all'
...
```

Maybe I am doing something wrong.



Comment at: clang/test/Headers/Inputs/include/cstdlib:15
 
+#ifndef __AMDGCN__
 namespace std

jdoerfert wrote:
> JonChesterfield wrote:
> > I think I'd expect builtin_labs et al to work on amdgcn, are we missing 
> > lowering for them?
> Yeah, looks weird that we cannot compile this mock-up header.
From what I understand, hip is defining fabs to use ocml's version into the std 
namespace, which was already defined in this header. So that's causing multiple 
declaration error. I will wrap only fabs in the ifdef's


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104904

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


[clang] a498553 - [clang][ARM] Mark sanitize-coverage-old-pm.c unsupported on armv7l

2021-06-28 Thread David Spickett via cfe-commits

Author: David Spickett
Date: 2021-06-28T08:32:36Z
New Revision: a49855316251aaa3cfe62b797b5650ae55b09378

URL: 
https://github.com/llvm/llvm-project/commit/a49855316251aaa3cfe62b797b5650ae55b09378
DIFF: 
https://github.com/llvm/llvm-project/commit/a49855316251aaa3cfe62b797b5650ae55b09378.diff

LOG: [clang][ARM] Mark sanitize-coverage-old-pm.c unsupported on armv7l

Our v7 Linux bots report the arch as "armv7l", not "armv7".

Added: 


Modified: 
clang/test/CodeGen/sanitize-coverage-old-pm.c

Removed: 




diff  --git a/clang/test/CodeGen/sanitize-coverage-old-pm.c 
b/clang/test/CodeGen/sanitize-coverage-old-pm.c
index ff37eda464a8..9b4f8991864d 100644
--- a/clang/test/CodeGen/sanitize-coverage-old-pm.c
+++ b/clang/test/CodeGen/sanitize-coverage-old-pm.c
@@ -6,7 +6,7 @@
 // RUN: %clang %s -target x86_64-unknown-linux-gnu -emit-llvm -S 
-fsanitize=undefined  -fsanitize-coverage=trace-pc,trace-cmp -o - 
-flegacy-pass-manager | FileCheck %s --check-prefixes=CHECK,UBSAN
 //
 // Host armv7 is currently unsupported: 
https://bugs.llvm.org/show_bug.cgi?id=46117
-// UNSUPPORTED: armv7, thumbv7, armv8l
+// UNSUPPORTED: armv7, armv7l, thumbv7, armv8l
 // The same issue also occurs on a riscv32 host.
 // XFAIL: riscv32
 



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


[PATCH] D104904: [OpenMP][AMDGCN] Initial math headers support

2021-06-28 Thread Pushpinder Singh via Phabricator via cfe-commits
pdhaliwal updated this revision to Diff 354802.
pdhaliwal added a comment.

Typo


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104904

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Headers/__clang_hip_cmath.h
  clang/lib/Headers/__clang_hip_math.h
  clang/lib/Headers/openmp_wrappers/__clang_openmp_device_functions.h
  clang/lib/Headers/openmp_wrappers/cmath
  clang/lib/Headers/openmp_wrappers/math.h
  clang/test/Headers/Inputs/include/algorithm
  clang/test/Headers/Inputs/include/cstdlib
  clang/test/Headers/Inputs/include/utility
  clang/test/Headers/amdgcn_openmp_device_math.c
  clang/test/Headers/openmp_device_math_isnan.cpp

Index: clang/test/Headers/openmp_device_math_isnan.cpp
===
--- clang/test/Headers/openmp_device_math_isnan.cpp
+++ clang/test/Headers/openmp_device_math_isnan.cpp
@@ -21,14 +21,14 @@
 double math(float f, double d) {
   double r = 0;
   // INT_RETURN: call i32 @__nv_isnanf(float
-  // AMD_INT_RETURN: call i32 @_{{.*}}isnanf(float
+  // AMD_INT_RETURN: call i32 @__ocml_isnan_f32(float
   // BOOL_RETURN: call i32 @__nv_isnanf(float
-  // AMD_BOOL_RETURN: call zeroext i1 @_{{.*}}isnanf(float
+  // AMD_BOOL_RETURN: call i32 @__ocml_isnan_f32(float
   r += std::isnan(f);
   // INT_RETURN: call i32 @__nv_isnand(double
-  // AMD_INT_RETURN: call i32 @_{{.*}}isnand(double
+  // AMD_INT_RETURN: call i32 @__ocml_isnan_f64(double
   // BOOL_RETURN: call i32 @__nv_isnand(double
-  // AMD_BOOL_RETURN: call zeroext i1 @_{{.*}}isnand(double
+  // AMD_BOOL_RETURN: call i32 @__ocml_isnan_f64(double
   r += std::isnan(d);
   return r;
 }
Index: clang/test/Headers/amdgcn_openmp_device_math.c
===
--- /dev/null
+++ clang/test/Headers/amdgcn_openmp_device_math.c
@@ -0,0 +1,51 @@
+// RUN: %clang_cc1 -internal-isystem %S/Inputs/include -x c -fopenmp -triple x86_64-unknown-unknown -fopenmp-targets=amdgcn-amd-amdhsa -emit-llvm-bc %s -o %t-host.bc
+// RUN: %clang_cc1 -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_device_functions.h -internal-isystem %S/../../lib/Headers/openmp_wrappers -internal-isystem %S/Inputs/include -x c -fopenmp -triple amdgcn-amd-amdhsa -aux-triple x86_64-unknown-unknown -fopenmp-targets=amdgcn-amd-amdhsa -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-host.bc -o - | FileCheck %s --check-prefixes=CHECK-C,CHECK
+// RUN: %clang_cc1 -internal-isystem %S/Inputs/include -x c++ -fopenmp -triple x86_64-unknown-unknown -fopenmp-targets=amdgcn-amd-amdhsa -emit-llvm-bc %s -o %t-host.bc
+// RUN: %clang_cc1 -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_device_functions.h -internal-isystem %S/../../lib/Headers/openmp_wrappers -internal-isystem %S/Inputs/include -x c++ -fopenmp -triple amdgcn-amd-amdhsa -aux-triple x86_64-unknown-unknown -fopenmp-targets=amdgcn-amd-amdhsa -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-host.bc -o - | FileCheck %s --check-prefixes=CHECK-CPP,CHECK
+
+#ifdef __cplusplus
+#include 
+#else
+#include 
+#endif
+
+void test_math_f64(double x) {
+// CHECK-LABEL: define {{.*}}test_math_f64
+#pragma omp target
+  {
+// CHECK: call double @__ocml_sin_f64
+double l1 = sin(x);
+// CHECK: call double @__ocml_cos_f64
+double l2 = cos(x);
+// CHECK: call double @__ocml_fabs_f64
+double l3 = fabs(x);
+  }
+}
+
+void test_math_f32(float x) {
+// CHECK-LABEL: define {{.*}}test_math_f32
+#pragma omp target
+  {
+// CHECK-C: call double @__ocml_sin_f64
+// CHECK-CPP: call float @__ocml_sin_f32
+float l1 = sin(x);
+// CHECK-C: call double @__ocml_cos_f64
+// CHECK-CPP: call float @__ocml_cos_f32
+float l2 = cos(x);
+// CHECK-C: call double @__ocml_fabs_f64
+// CHECK-CPP: call float @__ocml_fabs_f32
+float l3 = fabs(x);
+  }
+}
+void test_math_f32_suffix(float x) {
+// CHECK-LABEL: define {{.*}}test_math_f32_suffix
+#pragma omp target
+  {
+// CHECK: call float @__ocml_sin_f32
+float l1 = sinf(x);
+// CHECK: call float @__ocml_cos_f32
+float l2 = cosf(x);
+// CHECK: call float @__ocml_fabs_f32
+float l3 = fabsf(x);
+  }
+}
Index: clang/test/Headers/Inputs/include/utility
===
--- /dev/null
+++ clang/test/Headers/Inputs/include/utility
@@ -0,0 +1,2 @@
+#pragma once
+
Index: clang/test/Headers/Inputs/include/cstdlib
===
--- clang/test/Headers/Inputs/include/cstdlib
+++ clang/test/Headers/Inputs/include/cstdlib
@@ -23,9 +23,13 @@
 inline long long
 abs(long long __x) { return __builtin_llabs (__x); }
 
+// amdgcn already provides definition of fabs
+#ifndef __AMDGCN__
 float fabs(float __x) { return __builtin_fabs(__x); }
+#endif
 
 float abs(float __x) { return fabs

[clang-tools-extra] 499e39c - [clang-tidy] Add 'bugprone-easily-swappable-parameters' check

2021-06-28 Thread via cfe-commits

Author: Whisperity
Date: 2021-06-28T10:49:37+02:00
New Revision: 499e39c5983dba35861b5482bd298a8da726f1b6

URL: 
https://github.com/llvm/llvm-project/commit/499e39c5983dba35861b5482bd298a8da726f1b6
DIFF: 
https://github.com/llvm/llvm-project/commit/499e39c5983dba35861b5482bd298a8da726f1b6.diff

LOG: [clang-tidy] Add 'bugprone-easily-swappable-parameters' check

Finds function definitions where parameters of convertible types follow
each other directly, making call sites prone to calling the function
with swapped (or badly ordered) arguments.

Such constructs are usually the result of inefficient design and lack of
exploitation of strong type capabilities that are possible in the
language.

This check finds and flags **function definitions** and **not** call
sites!

Reviewed By: aaron.ballman, alexfh

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

Added: 
clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp
clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.h

clang-tools-extra/docs/clang-tidy/checks/bugprone-easily-swappable-parameters.rst

clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-ignore.cpp

clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-len2.cpp

clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-len3.cpp

clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters.c

Modified: 
clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
clang-tools-extra/docs/ReleaseNotes.rst
clang-tools-extra/docs/clang-tidy/checks/list.rst

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp 
b/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
index 595a30e8d8ce3..35b5f2c37df68 100644
--- a/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
@@ -18,6 +18,7 @@
 #include "CopyConstructorInitCheck.h"
 #include "DanglingHandleCheck.h"
 #include "DynamicStaticInitializersCheck.h"
+#include "EasilySwappableParametersCheck.h"
 #include "ExceptionEscapeCheck.h"
 #include "FoldInitTypeCheck.h"
 #include "ForwardDeclarationNamespaceCheck.h"
@@ -91,6 +92,8 @@ class BugproneModule : public ClangTidyModule {
 "bugprone-dangling-handle");
 CheckFactories.registerCheck(
 "bugprone-dynamic-static-initializers");
+CheckFactories.registerCheck(
+"bugprone-easily-swappable-parameters");
 CheckFactories.registerCheck(
 "bugprone-exception-escape");
 CheckFactories.registerCheck(

diff  --git a/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt 
b/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
index 022e5c5842ee2..78a70c703dc09 100644
--- a/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
+++ b/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
@@ -13,6 +13,7 @@ add_clang_library(clangTidyBugproneModule
   CopyConstructorInitCheck.cpp
   DanglingHandleCheck.cpp
   DynamicStaticInitializersCheck.cpp
+  EasilySwappableParametersCheck.cpp
   ExceptionEscapeCheck.cpp
   FoldInitTypeCheck.cpp
   ForwardDeclarationNamespaceCheck.cpp

diff  --git 
a/clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp
new file mode 100644
index 0..07c8ef486f654
--- /dev/null
+++ b/clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp
@@ -0,0 +1,495 @@
+//===--- EasilySwappableParametersCheck.cpp - clang-tidy 
--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "EasilySwappableParametersCheck.h"
+#include "../utils/OptionsUtils.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Lex/Lexer.h"
+
+#define DEBUG_TYPE "EasilySwappableParametersCheck"
+#include "llvm/Support/Debug.h"
+
+namespace optutils = clang::tidy::utils::options;
+
+/// The default value for the MinimumLength check option.
+static constexpr std::size_t DefaultMinimumLength = 2;
+
+/// The default value for ignored parameter names.
+static const std::string DefaultIgnoredParameterNames =
+optutils::serializeStringList({"\"\"", "iterator", "Iterator", "begin",
+   "Begin", "end", "End", "first", "First",
+   "last", "Last", "lhs", "LHS", "rhs", 
"RHS"});
+
+/// The default value for ignored parameter type suffixes.
+static const std::string DefaultIgnoredPara

[clang-tools-extra] 26d864b - [clang-tidy] Extend 'bugprone-easily-swappable-parameters' with `typedef` and `const &` diagnostics

2021-06-28 Thread via cfe-commits

Author: Whisperity
Date: 2021-06-28T10:49:37+02:00
New Revision: 26d864b44b9d3326984a7041124aa0f9e8ebc5cb

URL: 
https://github.com/llvm/llvm-project/commit/26d864b44b9d3326984a7041124aa0f9e8ebc5cb
DIFF: 
https://github.com/llvm/llvm-project/commit/26d864b44b9d3326984a7041124aa0f9e8ebc5cb.diff

LOG: [clang-tidy] Extend 'bugprone-easily-swappable-parameters' with `typedef` 
and `const &` diagnostics

The base patch only deals with strict (canonical) type equality, which is
merely a subset of all the dangerous function interfaces that we intend to
find.
In addition, in the base patch, canonical type equivalence is not diagnosed in
a way that is immediately apparent to the user.

This patch extends the check with two features:

 * Proper typedef diagnostics and explanations to the user.
 * "Reference bind power" matching.

Case 2 is a necessary addition because in every case someone encounters a
function `f(T t, const T& tr)`, any expression that might be passed to either
can be passed to both. Thus, such adjacent parameter sequences should be
matched.

Reviewed By: aaron.ballman

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

Added: 


Modified: 
clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp

clang-tools-extra/docs/clang-tidy/checks/bugprone-easily-swappable-parameters.rst

clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-len2.cpp

Removed: 




diff  --git 
a/clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp
index 07c8ef486f654..d9124e6c8361b 100644
--- a/clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp
@@ -11,6 +11,7 @@
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/Lex/Lexer.h"
+#include "llvm/ADT/SmallSet.h"
 
 #define DEBUG_TYPE "EasilySwappableParametersCheck"
 #include "llvm/Support/Debug.h"
@@ -76,12 +77,15 @@ namespace model {
 enum class MixFlags : unsigned char {
   Invalid = 0, //< Sentinel bit pattern. DO NOT USE!
 
-  None = 1,  //< Mix between the two parameters is not possible.
-  Trivial = 2,   //< The two mix trivially, and are the exact same type.
-  Canonical = 4, //< The two mix because the types refer to the same
- // CanonicalType, but we do not elaborate as to how.
+  None = 1,   //< Mix between the two parameters is not possible.
+  Trivial = 2,//< The two mix trivially, and are the exact same type.
+  Canonical = 4,  //< The two mix because the types refer to the same
+  // CanonicalType, but we do not elaborate as to how.
+  TypeAlias = 8,  //< The path from one type to the other involves
+  // desugaring type aliases.
+  ReferenceBind = 16, //< The mix involves the binding power of "const &".
 
-  LLVM_MARK_AS_BITMASK_ENUM(/* LargestValue =*/Canonical)
+  LLVM_MARK_AS_BITMASK_ENUM(/* LargestValue =*/ReferenceBind)
 };
 LLVM_ENABLE_BITMASK_ENUMS_IN_NAMESPACE();
 
@@ -106,7 +110,7 @@ static inline std::string formatMixFlags(MixFlags F) {
   if (F == MixFlags::Invalid)
 return "#Inv!";
 
-  SmallString<4> Str{"---"};
+  SmallString<8> Str{"-"};
 
   if (hasFlag(F, MixFlags::None))
 // Shows the None bit explicitly, as it can be applied in the recursion
@@ -116,6 +120,10 @@ static inline std::string formatMixFlags(MixFlags F) {
 Str[1] = 'T';
   if (hasFlag(F, MixFlags::Canonical))
 Str[2] = 'C';
+  if (hasFlag(F, MixFlags::TypeAlias))
+Str[3] = 't';
+  if (hasFlag(F, MixFlags::ReferenceBind))
+Str[4] = '&';
 
   return Str.str().str();
 }
@@ -129,13 +137,44 @@ static inline std::string formatMixFlags(MixFlags F);
 /// Contains the metadata for the mixability result between two types,
 /// independently of which parameters they were calculated from.
 struct MixData {
+  /// The flag bits of the mix indicating what language features allow for it.
   MixFlags Flags;
 
+  /// A potentially calculated common underlying type after desugaring, that
+  /// both sides of the mix can originate from.
+  QualType CommonType;
+
   MixData(MixFlags Flags) : Flags(Flags) {}
+  MixData(MixFlags Flags, QualType CommonType)
+  : Flags(Flags), CommonType(CommonType) {}
 
   void sanitize() {
 assert(Flags != MixFlags::Invalid && "sanitize() called on invalid 
bitvec");
-// TODO: There will be statements here in further extensions of the check.
+
+if (hasFlag(Flags, MixFlags::None)) {
+  // If anywhere down the recursion a potential mix "path" is deemed
+  // impossible, throw away all the other bits because the mix is not
+  // possible.
+  Flags = MixFlags::None;
+  return;
+}
+
+if (Flags == MixFlags::Trivial)
+  return;
+
+if

[clang-tools-extra] 961e9e6 - [clang-tidy] Extend 'bugprone-easily-swappable-parameters' with optionally considering differently qualified types mixable

2021-06-28 Thread via cfe-commits

Author: Whisperity
Date: 2021-06-28T10:49:37+02:00
New Revision: 961e9e6af65ef097678c57fe5f1c18b825eb723f

URL: 
https://github.com/llvm/llvm-project/commit/961e9e6af65ef097678c57fe5f1c18b825eb723f
DIFF: 
https://github.com/llvm/llvm-project/commit/961e9e6af65ef097678c57fe5f1c18b825eb723f.diff

LOG: [clang-tidy] Extend 'bugprone-easily-swappable-parameters' with optionally 
considering differently qualified types mixable

Adds a relaxation option QualifiersMix which will make the check report for
cases where parameters refer to the same type if they only differ in qualifiers.

This makes cases, such as the following, not warned about by default, produce
a warning.

void* memcpy(void* dst, const void* src, unsigned size) {}

However, unless people meticulously const their local variables, unfortunately,
even such a function carry a potential swap:

T* obj = new T; // Not const!!!
void* buf = malloc(sizeof(T));

memcpy(obj, buf, sizeof(T));
// ^~~  ^~~ accidental swap here, even though the interface "specified" 
a const.

Reviewed By: aaron.ballman

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

Added: 

clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-qualifiermixing.cpp

Modified: 
clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp
clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.h

clang-tools-extra/docs/clang-tidy/checks/bugprone-easily-swappable-parameters.rst

clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-ignore.cpp

clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-len2.cpp

clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-len3.cpp

clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters.c

Removed: 




diff  --git 
a/clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp
index d9124e6c8361b..8266ee62ada64 100644
--- a/clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp
@@ -59,6 +59,9 @@ static const std::string DefaultIgnoredParameterTypeSuffixes =
"Constreverseiterator",
"constreverseiterator"});
 
+/// The default value for the QualifiersMix check option.
+static constexpr bool DefaultQualifiersMix = false;
+
 using namespace clang::ast_matchers;
 
 namespace clang {
@@ -84,8 +87,9 @@ enum class MixFlags : unsigned char {
   TypeAlias = 8,  //< The path from one type to the other involves
   // desugaring type aliases.
   ReferenceBind = 16, //< The mix involves the binding power of "const &".
+  Qualifiers = 32,//< The mix involves change in the qualifiers.
 
-  LLVM_MARK_AS_BITMASK_ENUM(/* LargestValue =*/ReferenceBind)
+  LLVM_MARK_AS_BITMASK_ENUM(/* LargestValue =*/Qualifiers)
 };
 LLVM_ENABLE_BITMASK_ENUMS_IN_NAMESPACE();
 
@@ -110,7 +114,7 @@ static inline std::string formatMixFlags(MixFlags F) {
   if (F == MixFlags::Invalid)
 return "#Inv!";
 
-  SmallString<8> Str{"-"};
+  SmallString<8> Str{"--"};
 
   if (hasFlag(F, MixFlags::None))
 // Shows the None bit explicitly, as it can be applied in the recursion
@@ -124,6 +128,8 @@ static inline std::string formatMixFlags(MixFlags F) {
 Str[3] = 't';
   if (hasFlag(F, MixFlags::ReferenceBind))
 Str[4] = '&';
+  if (hasFlag(F, MixFlags::Qualifiers))
+Str[5] = 'Q';
 
   return Str.str().str();
 }
@@ -169,13 +175,24 @@ struct MixData {
   Flags &= ~MixFlags::Trivial;
   }
 
+  /// Add the specified flag bits to the flags.
   MixData operator|(MixFlags EnableFlags) const {
 return {Flags | EnableFlags, CommonType};
   }
+
+  /// Add the specified flag bits to the flags.
   MixData &operator|=(MixFlags EnableFlags) {
 Flags |= EnableFlags;
 return *this;
   }
+
+  /// Add the specified qualifiers to the common type in the Mix.
+  MixData qualify(Qualifiers Quals) const {
+SplitQualType Split = CommonType.split();
+Split.Quals.addQualifiers(Quals);
+
+return {Flags, QualType(Split.Ty, Split.Quals.getAsOpaqueValue())};
+  }
 };
 
 /// A named tuple that contains the information for a mix between two concrete
@@ -266,18 +283,6 @@ static MixData calculateMixability(const TheCheck &Check, 
const QualType LType,
RType.getSingleStepDesugaredType(Ctx), Ctx);
   }
 
-  // Dissolve typedefs.
-  if (const auto *LTypedef = LType->getAs()) {
-LLVM_DEBUG(llvm::dbgs() << "--- calculateMixability. LHS is typedef.\n");
-return calculateMixability(Check, LTypedef->desugar(), RType, Ctx) |
-   MixFlags::TypeAlias;
-  }
-  if (const auto *RType

[clang-tools-extra] e33d047 - [clang-tidy] Extend 'bugprone-easily-swappable-parameters' with mixability because of implicit conversions

2021-06-28 Thread via cfe-commits

Author: Whisperity
Date: 2021-06-28T10:49:37+02:00
New Revision: e33d0478831e4a295cb136ce1f58587155309fa2

URL: 
https://github.com/llvm/llvm-project/commit/e33d0478831e4a295cb136ce1f58587155309fa2
DIFF: 
https://github.com/llvm/llvm-project/commit/e33d0478831e4a295cb136ce1f58587155309fa2.diff

LOG: [clang-tidy] Extend 'bugprone-easily-swappable-parameters' with mixability 
because of implicit conversions

Adds a relaxation option ModelImplicitConversions which will make the check
report for cases where parameters refer to types that are implicitly
convertible to one another.

Example:

struct IntBox { IntBox(int); operator int(); };
void foo(int i, double d, IntBox ib) {}

Implicit conversions are the last to model in the set of things that are
reasons for the possibility of a function being called the wrong way which is
not always immediately apparent when looking at the function (signature or
call).

Reviewed By: aaron.ballman, martong

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

Added: 

clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-implicit-qualifiers.cpp

clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-implicits.c

clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-implicits.cpp

Modified: 
clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp
clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.h

clang-tools-extra/docs/clang-tidy/checks/bugprone-easily-swappable-parameters.rst

clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-ignore.cpp

clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-len2.cpp

clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-len3.cpp

clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-qualifiermixing.cpp

clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters.c

Removed: 




diff  --git 
a/clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp
index 8266ee62ada64..c4896979d2e99 100644
--- a/clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp
@@ -62,6 +62,9 @@ static const std::string DefaultIgnoredParameterTypeSuffixes =
 /// The default value for the QualifiersMix check option.
 static constexpr bool DefaultQualifiersMix = false;
 
+/// The default value for the ModelImplicitConversions check option.
+static constexpr bool DefaultModelImplicitConversions = true;
+
 using namespace clang::ast_matchers;
 
 namespace clang {
@@ -80,16 +83,24 @@ namespace model {
 enum class MixFlags : unsigned char {
   Invalid = 0, //< Sentinel bit pattern. DO NOT USE!
 
-  None = 1,   //< Mix between the two parameters is not possible.
-  Trivial = 2,//< The two mix trivially, and are the exact same type.
-  Canonical = 4,  //< The two mix because the types refer to the same
+  //< Certain constructs (such as pointers to noexcept/non-noexcept functions)
+  // have the same CanonicalType, which would result in false positives.
+  // During the recursive modelling call, this flag is set if a later diagnosed
+  // canonical type equivalence should be thrown away.
+  WorkaroundDisableCanonicalEquivalence = 1,
+
+  None = 2,   //< Mix between the two parameters is not possible.
+  Trivial = 4,//< The two mix trivially, and are the exact same type.
+  Canonical = 8,  //< The two mix because the types refer to the same
   // CanonicalType, but we do not elaborate as to how.
-  TypeAlias = 8,  //< The path from one type to the other involves
+  TypeAlias = 16, //< The path from one type to the other involves
   // desugaring type aliases.
-  ReferenceBind = 16, //< The mix involves the binding power of "const &".
-  Qualifiers = 32,//< The mix involves change in the qualifiers.
+  ReferenceBind = 32, //< The mix involves the binding power of "const &".
+  Qualifiers = 64,//< The mix involves change in the qualifiers.
+  ImplicitConversion = 128, //< The mixing of the parameters is possible
+// through implicit conversions between the types.
 
-  LLVM_MARK_AS_BITMASK_ENUM(/* LargestValue =*/Qualifiers)
+  LLVM_MARK_AS_BITMASK_ENUM(/* LargestValue =*/ImplicitConversion)
 };
 LLVM_ENABLE_BITMASK_ENUMS_IN_NAMESPACE();
 
@@ -114,7 +125,7 @@ static inline std::string formatMixFlags(MixFlags F) {
   if (F == MixFlags::Invalid)
 return "#Inv!";
 
-  SmallString<8> Str{"--"};
+  SmallString<8> Str{"---"};
 
   if (hasFlag(F, MixFlags::None))
 // Shows the None bit exp

[clang-tools-extra] b9ece03 - [clang-tidy] Suppress reports to similarly used parameters in 'bugprone-easily-swappable-parameters'

2021-06-28 Thread via cfe-commits

Author: Whisperity
Date: 2021-06-28T10:49:37+02:00
New Revision: b9ece034611239d008ac11d8bb9b3af91313c41f

URL: 
https://github.com/llvm/llvm-project/commit/b9ece034611239d008ac11d8bb9b3af91313c41f
DIFF: 
https://github.com/llvm/llvm-project/commit/b9ece034611239d008ac11d8bb9b3af91313c41f.diff

LOG: [clang-tidy] Suppress reports to similarly used parameters in 
'bugprone-easily-swappable-parameters'

There are several types of functions and various reasons why some
"swappable parameters" cannot be fixed with changing the parameters' types, etc.
The most common example might be int `min(int a, int b)`... no matter what you
do, the two parameters must remain the same type.

The **filtering heuristic** implemented in this patch deals with trying to find
such functions during the modelling and building of the swappable parameter
range.
If the parameter currently scrutinised matches either of the predicates below,
it will be regarded as **not swappable** even if the type of the parameter
matches.

Reviewed By: aaron.ballman

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

Added: 

clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-relatedness.c

clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-relatedness.cpp

Modified: 
clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp
clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.h

clang-tools-extra/docs/clang-tidy/checks/bugprone-easily-swappable-parameters.rst

clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-ignore.cpp

clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-implicit-qualifiers.cpp

clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-implicits.c

clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-implicits.cpp

clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-len2.cpp

clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-len3.cpp

clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-qualifiermixing.cpp

clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters.c

Removed: 




diff  --git 
a/clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp
index c4896979d2e99..247953c25a3b8 100644
--- a/clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp
@@ -9,6 +9,7 @@
 #include "EasilySwappableParametersCheck.h"
 #include "../utils/OptionsUtils.h"
 #include "clang/AST/ASTContext.h"
+#include "clang/AST/RecursiveASTVisitor.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/Lex/Lexer.h"
 #include "llvm/ADT/SmallSet.h"
@@ -65,6 +66,10 @@ static constexpr bool DefaultQualifiersMix = false;
 /// The default value for the ModelImplicitConversions check option.
 static constexpr bool DefaultModelImplicitConversions = true;
 
+/// The default value for suppressing diagnostics about parameters that are
+/// used together.
+static constexpr bool DefaultSuppressParametersUsedTogether = true;
+
 using namespace clang::ast_matchers;
 
 namespace clang {
@@ -74,7 +79,12 @@ namespace bugprone {
 using TheCheck = EasilySwappableParametersCheck;
 
 namespace filter {
+class SimilarlyUsedParameterPairSuppressor;
+
 static bool isIgnoredParameter(const TheCheck &Check, const ParmVarDecl *Node);
+static inline bool
+isSimilarlyUsedParameter(const SimilarlyUsedParameterPairSuppressor 
&Suppressor,
+ const ParmVarDecl *Param1, const ParmVarDecl *Param2);
 } // namespace filter
 
 namespace model {
@@ -1269,9 +1279,9 @@ approximateImplicitConversion(const TheCheck &Check, 
QualType LType,
   return {MixFlags::None};
 }
 
-static MixableParameterRange modelMixingRange(const TheCheck &Check,
-  const FunctionDecl *FD,
-  std::size_t StartIndex) {
+static MixableParameterRange modelMixingRange(
+const TheCheck &Check, const FunctionDecl *FD, std::size_t StartIndex,
+const filter::SimilarlyUsedParameterPairSuppressor &UsageBasedSuppressor) {
   std::size_t NumParams = FD->getNumParams();
   assert(StartIndex < NumParams && "out of bounds for start");
   const ASTContext &Ctx = FD->getASTContext();
@@ -1297,6 +1307,19 @@ static MixableParameterRange modelMixingRange(const 
TheCheck &Check,
   LLVM_DEBUG(llvm::dbgs()
  << "Check mix of #" << J << " against #" << I << "...\n");
 
+  if (isSimilarlyUsedParameter(UsageBasedSuppressor, Ith, Jth)) {
+// Consider the two similarly us

[clang-tools-extra] 0fba450 - [clang-tidy] Suppress reports to patternedly named parameters in 'bugprone-easily-swappable-parameters'

2021-06-28 Thread via cfe-commits

Author: Whisperity
Date: 2021-06-28T10:49:37+02:00
New Revision: 0fba450b9756a496224efd06e5ba76c9a61d3e15

URL: 
https://github.com/llvm/llvm-project/commit/0fba450b9756a496224efd06e5ba76c9a61d3e15
DIFF: 
https://github.com/llvm/llvm-project/commit/0fba450b9756a496224efd06e5ba76c9a61d3e15.diff

LOG: [clang-tidy] Suppress reports to patternedly named parameters in 
'bugprone-easily-swappable-parameters'

While the original check's purpose is to identify potentially dangerous
functions based on the parameter types (as identifier names do not mean
anything when it comes to the language rules), unfortunately, such a plain
interface check rule can be incredibly noisy. While the previous
"filtering heuristic" is able to find many similar usages, there is an entire
class of parameters that should not be warned about very easily mixed by that
check: parameters that have a name and their name follows a pattern,
e.g. `text1, text2, text3, ...`.`

This patch implements a simple, but powerful rule, that allows us to detect
such cases and ensure that no warnings are emitted for parameter sequences that
follow a pattern, even if their types allow for them to be potentially mixed at 
a call site.

Given a threshold `k`, warnings about two parameters are filtered from the
result set if the names of the parameters are either prefixes or suffixes of
each other, with at most k letters difference on the non-common end.
(Assuming that the names themselves are at least `k` long.)

 - The above `text1, text2` is an example of this. (Live finding from Xerces.)
 - `LHS` and `RHS` are also fitting the bill here. (Live finding from... 
virtually any project.)
 - So does `Qmat, Tmat, Rmat`. (Live finding from I think OpenCV.)

Reviewed By: aaron.ballman

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

Added: 

clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-prefixsuffixname.cpp

Modified: 
clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp
clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.h

clang-tools-extra/docs/clang-tidy/checks/bugprone-easily-swappable-parameters.rst

clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-ignore.cpp

clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-implicit-qualifiers.cpp

clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-implicits.c

clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-implicits.cpp

clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-len2.cpp

clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-len3.cpp

clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-qualifiermixing.cpp

clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-relatedness.c

clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-relatedness.cpp

clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters.c

Removed: 




diff  --git 
a/clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp
index 247953c25a3b8..6c84cb3e55537 100644
--- a/clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp
@@ -70,6 +70,11 @@ static constexpr bool DefaultModelImplicitConversions = true;
 /// used together.
 static constexpr bool DefaultSuppressParametersUsedTogether = true;
 
+/// The default value for the NamePrefixSuffixSilenceDissimilarityTreshold
+/// check option.
+static constexpr std::size_t
+DefaultNamePrefixSuffixSilenceDissimilarityTreshold = 1;
+
 using namespace clang::ast_matchers;
 
 namespace clang {
@@ -85,6 +90,8 @@ static bool isIgnoredParameter(const TheCheck &Check, const 
ParmVarDecl *Node);
 static inline bool
 isSimilarlyUsedParameter(const SimilarlyUsedParameterPairSuppressor 
&Suppressor,
  const ParmVarDecl *Param1, const ParmVarDecl *Param2);
+static bool prefixSuffixCoverUnderThreshold(std::size_t Threshold,
+StringRef Str1, StringRef Str2);
 } // namespace filter
 
 namespace model {
@@ -1292,13 +1299,25 @@ static MixableParameterRange modelMixingRange(
 
   for (std::size_t I = StartIndex + 1; I < NumParams; ++I) {
 const ParmVarDecl *Ith = FD->getParamDecl(I);
-LLVM_DEBUG(llvm::dbgs() << "Check param #" << I << "...\n");
-
+StringRef ParamName = Ith->getName();
+LLVM_DEBUG(llvm::dbgs()
+   << "Check param #" << I << " '" << ParamName << "'...\n");
 if (filter::isIgnoredParameter(Check, Ith)) {
   LLVM_DEBUG(llvm::dbgs() <

[PATCH] D69560: [clang-tidy] Add 'bugprone-easily-swappable-parameters' check

2021-06-28 Thread Whisperity via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG499e39c5983d: [clang-tidy] Add 
'bugprone-easily-swappable-parameters' check (authored by whisperity).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69560

Files:
  clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
  clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
  clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/docs/clang-tidy/checks/bugprone-easily-swappable-parameters.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-ignore.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-len2.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-len3.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters.c

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters.c
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters.c
@@ -0,0 +1,148 @@
+// RUN: %check_clang_tidy %s bugprone-easily-swappable-parameters %t \
+// RUN:   -config='{CheckOptions: [ \
+// RUN: {key: bugprone-easily-swappable-parameters.MinimumLength, value: 2}, \
+// RUN: {key: bugprone-easily-swappable-parameters.IgnoredParameterNames, value: ""}, \
+// RUN: {key: bugprone-easily-swappable-parameters.IgnoredParameterTypeSuffixes, value: "bool;MyBool;struct U;MAKE_LOGICAL_TYPE(int)"} \
+// RUN:  ]}' -- -x c
+
+#define bool _Bool
+#define true 1
+#define false 0
+
+typedef bool MyBool;
+
+#define TheLogicalType bool
+
+void declVoid(void); // NO-WARN: Declaration only.
+void decl(); // NO-WARN: Declaration only.
+void oneParam(int I) {}  // NO-WARN: 1 parameter.
+void variadic(int I, ...) {} // NO-WARN: 1 visible parameter.
+
+void trivial(int I, int J) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:14: warning: 2 adjacent parameters of 'trivial' of similar type ('int') are easily swapped by mistake [bugprone-easily-swappable-parameters]
+// CHECK-MESSAGES: :[[@LINE-2]]:18: note: the first parameter in the range is 'I'
+// CHECK-MESSAGES: :[[@LINE-3]]:25: note: the last parameter in the range is 'J'
+
+void qualifier(int I, const int CI) {} // NO-WARN: Distinct types.
+
+void restrictQualifier(char *restrict CPR1, char *restrict CPR2) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:24: warning: 2 adjacent parameters of 'restrictQualifier' of similar type ('char *restrict')
+// CHECK-MESSAGES: :[[@LINE-2]]:39: note: the first parameter in the range is 'CPR1'
+// CHECK-MESSAGES: :[[@LINE-3]]:60: note: the last parameter in the range is 'CPR2'
+
+void pointer1(int *IP1, int *IP2) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:15: warning: 2 adjacent parameters of 'pointer1' of similar type ('int *')
+// CHECK-MESSAGES: :[[@LINE-2]]:20: note: the first parameter in the range is 'IP1'
+// CHECK-MESSAGES: :[[@LINE-3]]:30: note: the last parameter in the range is 'IP2'
+
+void pointerConversion(int *IP, long *LP) {}
+// NO-WARN: Even though C can convert any T* to U* back and forth, compiler
+// warnings already exist for this.
+
+void testVariadicsCall() {
+  int IVal = 1;
+  decl(IVal); // NO-WARN: Particular calls to "variadics" are like template
+  // instantiations, and we do not model them.
+
+  variadic(IVal);  // NO-WARN.
+  variadic(IVal, 2, 3, 4); // NO-WARN.
+}
+
+struct S {};
+struct T {};
+
+void taggedTypes1(struct S SVar, struct T TVar) {} // NO-WARN: Distinct types.
+
+void taggedTypes2(struct S SVar1, struct S SVar2) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:19: warning: 2 adjacent parameters of 'taggedTypes2' of similar type ('struct S')
+// CHECK-MESSAGES: :[[@LINE-2]]:28: note: the first parameter in the range is 'SVar1'
+// CHECK-MESSAGES: :[[@LINE-3]]:44: note: the last parameter in the range is 'SVar2'
+
+void wrappers(struct { int I; } I1, struct { int I; } I2) {} // NO-WARN: Distinct anonymous types.
+
+void knr(I, J)
+  int I;
+  int J;
+{}
+// CHECK-MESSAGES: :[[@LINE-3]]:3: warning: 2 adjacent parameters of 'knr' of similar type ('int')
+// CHECK-MESSAGES: :[[@LINE-4]]:7: note: the first parameter in the range is 'I'
+// CHECK-MESSAGES: :[[@LINE-4]]:7: note: the last parameter in the range is 'J'
+
+void boolAsWritten(bool B1, bool B2) {} // NO-WARN: The type name is ignored.
+// Note that "bool" is a macro that expands to "_Bool" internally, but it is
+// only "bool" that is ignored from the two.
+
+void underscoreBoolAsWritten(_Bool B1, _Bool B2) {}
+// Even though it is "_Bool" that is written in the code, the diagnostic message
+// resp

[PATCH] D95736: [clang-tidy] Extend 'bugprone-easily-swappable-parameters' with `typedef` and `const &` diagnostics

2021-06-28 Thread Whisperity via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG26d864b44b9d: [clang-tidy] Extend 
'bugprone-easily-swappable-parameters' with `typedef` and… (authored 
by whisperity).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95736

Files:
  clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp
  
clang-tools-extra/docs/clang-tidy/checks/bugprone-easily-swappable-parameters.rst
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-len2.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-len2.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-len2.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-len2.cpp
@@ -115,20 +115,38 @@
 // CHECK-MESSAGES: :[[@LINE-2]]:32: note: the first parameter in the range is 'I1'
 // CHECK-MESSAGES: :[[@LINE-3]]:43: note: the last parameter in the range is 'I2'
 
-void throughTypedef(int I, MyInt1 J) {}
-// CHECK-MESSAGES: :[[@LINE-1]]:21: warning: 2 adjacent parameters of 'throughTypedef' of similar type ('int')
-// CHECK-MESSAGES: :[[@LINE-2]]:25: note: the first parameter in the range is 'I'
-// CHECK-MESSAGES: :[[@LINE-3]]:35: note: the last parameter in the range is 'J'
+void typedefMultiple(MyInt1 I1, MyInt2 I2x, MyInt2 I2y) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:22: warning: 3 adjacent parameters of 'typedefMultiple' of similar type are
+// CHECK-MESSAGES: :[[@LINE-2]]:29: note: the first parameter in the range is 'I1'
+// CHECK-MESSAGES: :[[@LINE-3]]:52: note: the last parameter in the range is 'I2y'
+// CHECK-MESSAGES: :[[@LINE-4]]:22: note: after resolving type aliases, the common type of 'MyInt1' and 'MyInt2' is 'int'
+
+void throughTypedef1(int I, MyInt1 J) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:22: warning: 2 adjacent parameters of 'throughTypedef1' of similar type are
+// CHECK-MESSAGES: :[[@LINE-2]]:26: note: the first parameter in the range is 'I'
+// CHECK-MESSAGES: :[[@LINE-3]]:36: note: the last parameter in the range is 'J'
+// CHECK-MESSAGES: :[[@LINE-4]]:22: note: after resolving type aliases, 'int' and 'MyInt1' are the same
+
+void betweenTypedef2(MyInt1 I, MyInt2 J) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:22: warning: 2 adjacent parameters of 'betweenTypedef2' of similar type are
+// CHECK-MESSAGES: :[[@LINE-2]]:29: note: the first parameter in the range is 'I'
+// CHECK-MESSAGES: :[[@LINE-3]]:39: note: the last parameter in the range is 'J'
+// CHECK-MESSAGES: :[[@LINE-4]]:22: note: after resolving type aliases, the common type of 'MyInt1' and 'MyInt2' is 'int'
+
+typedef MyInt2 MyInt2b;
 
-void betweenTypedef(MyInt1 I, MyInt2 J) {}
-// CHECK-MESSAGES: :[[@LINE-1]]:21: warning: 2 adjacent parameters of 'betweenTypedef' of similar type ('MyInt1')
-// CHECK-MESSAGES: :[[@LINE-2]]:28: note: the first parameter in the range is 'I'
-// CHECK-MESSAGES: :[[@LINE-3]]:38: note: the last parameter in the range is 'J'
+void typedefChain(int I, MyInt1 MI1, MyInt2 MI2, MyInt2b MI2b) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:19: warning: 4 adjacent parameters of 'typedefChain' of similar type are
+// CHECK-MESSAGES: :[[@LINE-2]]:23: note: the first parameter in the range is 'I'
+// CHECK-MESSAGES: :[[@LINE-3]]:58: note: the last parameter in the range is 'MI2b'
+// CHECK-MESSAGES: :[[@LINE-4]]:19: note: after resolving type aliases, 'int' and 'MyInt1' are the same
+// CHECK-MESSAGES: :[[@LINE-5]]:19: note: after resolving type aliases, 'int' and 'MyInt2' are the same
+// CHECK-MESSAGES: :[[@LINE-6]]:19: note: after resolving type aliases, 'int' and 'MyInt2b' are the same
 
 typedef long MyLong1;
 using MyLong2 = long;
 
-void throughTypedefToOtherType(MyInt1 I, MyLong1 J) {} // NO-WARN: Not the same type.
+void throughTypedefToOtherType(MyInt1 I, MyLong1 J) {} // NO-WARN: int and long.
 
 void qualified1(int I, const int CI) {} // NO-WARN: Not the same type.
 
@@ -142,18 +160,73 @@
 
 void qualifiedThroughTypedef1(int I, CInt CI) {} // NO-WARN: Not the same type.
 
-void qualifiedThroughTypedef2(CInt CI1, const int CI2) {} // NO-WARN: Not the same type.
-// CHECK-MESSAGES: :[[@LINE-1]]:31: warning: 2 adjacent parameters of 'qualifiedThroughTypedef2' of similar type ('CInt')
+void qualifiedThroughTypedef2(CInt CI1, const int CI2) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:31: warning: 2 adjacent parameters of 'qualifiedThroughTypedef2' of similar type are
 // CHECK-MESSAGES: :[[@LINE-2]]:36: note: the first parameter in the range is 'CI1'
 // CHECK-MESSAGES: :[[@LINE-3]]:51: note: the last parameter in the range is 'CI2'
-
-void reference1(int I, int &IR) {} // NO-WARN: Not the same type.
-
-void reference2(int I, const int &CIR) {} // NO-WARN: Not the same type.
-
-void reference3(int I, int &&IRR) {} // NO-WARN: Not the same type.
-
-void refer

[PATCH] D96355: [clang-tidy] Extend 'bugprone-easily-swappable-parameters' with optionally considering differently qualified types mixable

2021-06-28 Thread Whisperity via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG961e9e6af65e: [clang-tidy] Extend 
'bugprone-easily-swappable-parameters' with optionally… (authored by 
whisperity).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96355

Files:
  clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.h
  
clang-tools-extra/docs/clang-tidy/checks/bugprone-easily-swappable-parameters.rst
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-ignore.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-len2.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-len3.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-qualifiermixing.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters.c

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters.c
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters.c
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters.c
@@ -2,7 +2,8 @@
 // RUN:   -config='{CheckOptions: [ \
 // RUN: {key: bugprone-easily-swappable-parameters.MinimumLength, value: 2}, \
 // RUN: {key: bugprone-easily-swappable-parameters.IgnoredParameterNames, value: ""}, \
-// RUN: {key: bugprone-easily-swappable-parameters.IgnoredParameterTypeSuffixes, value: "bool;MyBool;struct U;MAKE_LOGICAL_TYPE(int)"} \
+// RUN: {key: bugprone-easily-swappable-parameters.IgnoredParameterTypeSuffixes, value: "bool;MyBool;struct U;MAKE_LOGICAL_TYPE(int)"}, \
+// RUN: {key: bugprone-easily-swappable-parameters.QualifiersMix, value: 0} \
 // RUN:  ]}' -- -x c
 
 #define bool _Bool
Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-qualifiermixing.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-qualifiermixing.cpp
@@ -0,0 +1,112 @@
+// RUN: %check_clang_tidy %s bugprone-easily-swappable-parameters %t \
+// RUN:   -config='{CheckOptions: [ \
+// RUN: {key: bugprone-easily-swappable-parameters.MinimumLength, value: 2}, \
+// RUN: {key: bugprone-easily-swappable-parameters.IgnoredParameterNames, value: ""}, \
+// RUN: {key: bugprone-easily-swappable-parameters.IgnoredParameterTypeSuffixes, value: ""}, \
+// RUN: {key: bugprone-easily-swappable-parameters.QualifiersMix, value: 1} \
+// RUN:  ]}' --
+
+typedef int MyInt1;
+typedef int MyInt2;
+using CInt = const int;
+using CMyInt1 = const MyInt1;
+using CMyInt2 = const MyInt2;
+
+void qualified1(int I, const int CI) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:17: warning: 2 adjacent parameters of 'qualified1' of similar type are easily swapped by mistake [bugprone-easily-swappable-parameters]
+// CHECK-MESSAGES: :[[@LINE-2]]:21: note: the first parameter in the range is 'I'
+// CHECK-MESSAGES: :[[@LINE-3]]:34: note: the last parameter in the range is 'CI'
+// CHECK-MESSAGES: :[[@LINE-4]]:24: note: 'int' and 'const int' parameters accept and bind the same kind of values
+
+void qualified2(int I, volatile int VI) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:17: warning: 2 adjacent parameters of 'qualified2' of similar type are
+// CHECK-MESSAGES: :[[@LINE-2]]:21: note: the first parameter in the range is 'I'
+// CHECK-MESSAGES: :[[@LINE-3]]:37: note: the last parameter in the range is 'VI'
+// CHECK-MESSAGES: :[[@LINE-4]]:24: note: 'int' and 'volatile int' parameters accept and bind the same kind of values
+
+void qualified3(int I, const volatile int CVI) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:17: warning: 2 adjacent parameters of 'qualified3' of similar type are
+// CHECK-MESSAGES: :[[@LINE-2]]:21: note: the first parameter in the range is 'I'
+// CHECK-MESSAGES: :[[@LINE-3]]:43: note: the last parameter in the range is 'CVI'
+// CHECK-MESSAGES: :[[@LINE-4]]:24: note: 'int' and 'const volatile int' parameters accept and bind the same kind of values
+
+void qualified4(int *IP, const int *CIP) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:17: warning: 2 adjacent parameters of 'qualified4' of similar type are
+// CHECK-MESSAGES: :[[@LINE-2]]:22: note: the first parameter in the range is 'IP'
+// CHECK-MESSAGES: :[[@LINE-3]]:37: note: the last parameter in the range is 'CIP'
+// CHECK-MESSAGES: :[[@LINE-4]]:26: note: 'int *' and 'const int *' parameters accept and bind the same kind of values
+
+void qualified5(const int CI, const long CL) {} // NO-WARN: Not the same type
+
+void qualifiedPtr1(int *IP, int *const IPC) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:20: warning: 2 adjacent parameters of 'qualifiedPtr1' of s

[PATCH] D75041: [clang-tidy] Extend 'bugprone-easily-swappable-parameters' with mixability because of implicit conversions

2021-06-28 Thread Whisperity via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe33d0478831e: [clang-tidy] Extend 
'bugprone-easily-swappable-parameters' with mixability… (authored by 
whisperity).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75041

Files:
  clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.h
  
clang-tools-extra/docs/clang-tidy/checks/bugprone-easily-swappable-parameters.rst
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-ignore.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-implicit-qualifiers.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-implicits.c
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-implicits.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-len2.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-len3.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-qualifiermixing.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters.c

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters.c
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters.c
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters.c
@@ -3,7 +3,8 @@
 // RUN: {key: bugprone-easily-swappable-parameters.MinimumLength, value: 2}, \
 // RUN: {key: bugprone-easily-swappable-parameters.IgnoredParameterNames, value: ""}, \
 // RUN: {key: bugprone-easily-swappable-parameters.IgnoredParameterTypeSuffixes, value: "bool;MyBool;struct U;MAKE_LOGICAL_TYPE(int)"}, \
-// RUN: {key: bugprone-easily-swappable-parameters.QualifiersMix, value: 0} \
+// RUN: {key: bugprone-easily-swappable-parameters.QualifiersMix, value: 0}, \
+// RUN: {key: bugprone-easily-swappable-parameters.ModelImplicitConversions, value: 0} \
 // RUN:  ]}' -- -x c
 
 #define bool _Bool
Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-qualifiermixing.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-qualifiermixing.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-qualifiermixing.cpp
@@ -3,7 +3,8 @@
 // RUN: {key: bugprone-easily-swappable-parameters.MinimumLength, value: 2}, \
 // RUN: {key: bugprone-easily-swappable-parameters.IgnoredParameterNames, value: ""}, \
 // RUN: {key: bugprone-easily-swappable-parameters.IgnoredParameterTypeSuffixes, value: ""}, \
-// RUN: {key: bugprone-easily-swappable-parameters.QualifiersMix, value: 1} \
+// RUN: {key: bugprone-easily-swappable-parameters.QualifiersMix, value: 1}, \
+// RUN: {key: bugprone-easily-swappable-parameters.ModelImplicitConversions, value: 0} \
 // RUN:  ]}' --
 
 typedef int MyInt1;
Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-len3.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-len3.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-len3.cpp
@@ -3,7 +3,8 @@
 // RUN: {key: bugprone-easily-swappable-parameters.MinimumLength, value: 3}, \
 // RUN: {key: bugprone-easily-swappable-parameters.IgnoredParameterNames, value: ""}, \
 // RUN: {key: bugprone-easily-swappable-parameters.IgnoredParameterTypeSuffixes, value: ""}, \
-// RUN: {key: bugprone-easily-swappable-parameters.QualifiersMix, value: 0} \
+// RUN: {key: bugprone-easily-swappable-parameters.QualifiersMix, value: 0}, \
+// RUN: {key: bugprone-easily-swappable-parameters.ModelImplicitConversions, value: 0} \
 // RUN:  ]}' --
 
 int add(int Left, int Right) { return Left + Right; } // NO-WARN: Only 2 parameters.
Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-len2.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-len2.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-len2.cpp
@@ -3,7 +3,8 @@
 // RUN: {key: bugprone-easily-swappable-parameters.MinimumLength, value: 2}, \
 // RUN: {key: bugprone-easily-swappable-parameters.IgnoredParameterNames, value: ""}, \
 // RUN: {key: bugprone-easily-swappable-parameters.IgnoredParameterTypeSuffixes, value: ""}, \
-// RUN: {key: bugprone-easily-swappable

[PATCH] D78652: [clang-tidy] Suppress reports to similarly used parameters in 'bugprone-easily-swappable-parameters'

2021-06-28 Thread Whisperity via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb9ece0346112: [clang-tidy] Suppress reports to similarly 
used parameters in 'bugprone-easily… (authored by whisperity).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78652

Files:
  clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.h
  
clang-tools-extra/docs/clang-tidy/checks/bugprone-easily-swappable-parameters.rst
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-ignore.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-implicit-qualifiers.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-implicits.c
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-implicits.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-len2.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-len3.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-qualifiermixing.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-relatedness.c
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-relatedness.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters.c

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters.c
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters.c
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters.c
@@ -4,7 +4,8 @@
 // RUN: {key: bugprone-easily-swappable-parameters.IgnoredParameterNames, value: ""}, \
 // RUN: {key: bugprone-easily-swappable-parameters.IgnoredParameterTypeSuffixes, value: "bool;MyBool;struct U;MAKE_LOGICAL_TYPE(int)"}, \
 // RUN: {key: bugprone-easily-swappable-parameters.QualifiersMix, value: 0}, \
-// RUN: {key: bugprone-easily-swappable-parameters.ModelImplicitConversions, value: 0} \
+// RUN: {key: bugprone-easily-swappable-parameters.ModelImplicitConversions, value: 0}, \
+// RUN: {key: bugprone-easily-swappable-parameters.SuppressParametersUsedTogether, value: 0} \
 // RUN:  ]}' -- -x c
 
 #define bool _Bool
Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-relatedness.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-relatedness.cpp
@@ -0,0 +1,231 @@
+// RUN: %check_clang_tidy %s bugprone-easily-swappable-parameters %t \
+// RUN:   -config='{CheckOptions: [ \
+// RUN: {key: bugprone-easily-swappable-parameters.MinimumLength, value: 2}, \
+// RUN: {key: bugprone-easily-swappable-parameters.IgnoredParameterNames, value: ""}, \
+// RUN: {key: bugprone-easily-swappable-parameters.IgnoredParameterTypeSuffixes, value: ""}, \
+// RUN: {key: bugprone-easily-swappable-parameters.QualifiersMix, value: 0}, \
+// RUN: {key: bugprone-easily-swappable-parameters.ModelImplicitConversions, value: 0}, \
+// RUN: {key: bugprone-easily-swappable-parameters.SuppressParametersUsedTogether, value: 1} \
+// RUN:  ]}' --
+
+namespace std {
+template 
+T max(const T &A, const T &B);
+} // namespace std
+
+bool coin();
+void f(int);
+void g(int);
+void h(int, int);
+void i(int, bool);
+void i(int, char);
+
+struct Tmp {
+  int f(int);
+  int g(int, int);
+};
+
+struct Int {
+  int I;
+};
+
+void compare(int Left, int Right) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:14: warning: 2 adjacent parameters of 'compare' of similar type ('int')
+// CHECK-MESSAGES: :[[@LINE-2]]:18: note: the first parameter in the range is 'Left'
+// CHECK-MESSAGES: :[[@LINE-3]]:28: note: the last parameter in the range is 'Right'
+
+int decideSequence(int A, int B) {
+  if (A)
+return 1;
+  if (B)
+return 2;
+  return 3;
+}
+// CHECK-MESSAGES: :[[@LINE-7]]:20: warning: 2 adjacent parameters of 'decideSequence' of similar type ('int')
+// CHECK-MESSAGES: :[[@LINE-8]]:24: note: the first parameter in the range is 'A'
+// CHECK-MESSAGES: :[[@LINE-9]]:31: note: the last parameter in the range is 'B'
+
+int myMax(int A, int B) { // NO-WARN: Appears in same expression.
+  return A < B ? A : B;
+}
+
+int myMax2(int A, int B) { // NO-WARN: Appears in same expression.
+  if (A < B)
+return A;
+  return B;
+}
+
+int myMax3(int A, int B) { // NO-WARN: Appears in same expression.
+  return std::max(A, B);
+}
+
+int binaryToUnary(int A, int) {
+  return A;
+}
+// CHECK-MESSAGES: :[[@LINE-3]]:19: warning: 2 adjacent parameters of 'binaryToUnary' of similar type ('int')
+// CHECK-MESSAGES

[PATCH] D97297: [clang-tidy] Suppress reports to patternedly named parameters in 'bugprone-easily-swappable-parameters'

2021-06-28 Thread Whisperity via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0fba450b9756: [clang-tidy] Suppress reports to patternedly 
named parameters in 'bugprone… (authored by whisperity).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97297

Files:
  clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.h
  
clang-tools-extra/docs/clang-tidy/checks/bugprone-easily-swappable-parameters.rst
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-ignore.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-implicit-qualifiers.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-implicits.c
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-implicits.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-len2.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-len3.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-prefixsuffixname.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-qualifiermixing.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-relatedness.c
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-relatedness.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters.c

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters.c
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters.c
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters.c
@@ -5,7 +5,8 @@
 // RUN: {key: bugprone-easily-swappable-parameters.IgnoredParameterTypeSuffixes, value: "bool;MyBool;struct U;MAKE_LOGICAL_TYPE(int)"}, \
 // RUN: {key: bugprone-easily-swappable-parameters.QualifiersMix, value: 0}, \
 // RUN: {key: bugprone-easily-swappable-parameters.ModelImplicitConversions, value: 0}, \
-// RUN: {key: bugprone-easily-swappable-parameters.SuppressParametersUsedTogether, value: 0} \
+// RUN: {key: bugprone-easily-swappable-parameters.SuppressParametersUsedTogether, value: 0}, \
+// RUN: {key: bugprone-easily-swappable-parameters.NamePrefixSuffixSilenceDissimilarityTreshold, value: 0} \
 // RUN:  ]}' -- -x c
 
 #define bool _Bool
Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-relatedness.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-relatedness.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-relatedness.cpp
@@ -5,7 +5,8 @@
 // RUN: {key: bugprone-easily-swappable-parameters.IgnoredParameterTypeSuffixes, value: ""}, \
 // RUN: {key: bugprone-easily-swappable-parameters.QualifiersMix, value: 0}, \
 // RUN: {key: bugprone-easily-swappable-parameters.ModelImplicitConversions, value: 0}, \
-// RUN: {key: bugprone-easily-swappable-parameters.SuppressParametersUsedTogether, value: 1} \
+// RUN: {key: bugprone-easily-swappable-parameters.SuppressParametersUsedTogether, value: 1}, \
+// RUN: {key: bugprone-easily-swappable-parameters.NamePrefixSuffixSilenceDissimilarityTreshold, value: 0} \
 // RUN:  ]}' --
 
 namespace std {
Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-relatedness.c
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-relatedness.c
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-relatedness.c
@@ -5,7 +5,8 @@
 // RUN: {key: bugprone-easily-swappable-parameters.IgnoredParameterTypeSuffixes, value: ""}, \
 // RUN: {key: bugprone-easily-swappable-parameters.QualifiersMix, value: 0}, \
 // RUN: {key: bugprone-easily-swappable-parameters.ModelImplicitConversions, value: 0}, \
-// RUN: {key: bugprone-easily-swappable-parameters.SuppressParametersUsedTogether, value: 1} \
+// RUN: {key: bugprone-easily-swappable-parameters.SuppressParametersUsedTogether, value: 1}, \
+// RUN: {key: bugprone-easily-swappable-parameters.NamePrefixSuffixSilenceDissimilarityTreshold, value: 0} \
 // RUN:  ]}' -- -x c
 
 int myprint();
Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-qualifiermixing.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-qualifiermixing.cpp
+++ cla

[PATCH] D104852: [AArch64][SVEIntrinsicOpts] Convect cntb/h/w/d to vscale intrinsic or constant.

2021-06-28 Thread David Sherwood via Phabricator via cfe-commits
david-arm added a comment.

Hi @junparser, the patch looks sensible to me! I just had a couple of minor 
comments if that's ok.




Comment at: llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp:658
+return IC.replaceInstUsesWith(II, VScale);
+  } else if (Pattern >= AArch64SVEPredPattern::vl1 &&
+ Pattern <= AArch64SVEPredPattern::vl8 && NumElts >= Pattern) {

nit: Do you need to fix the clang-tidy warning here?



Comment at: llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp:662
+return IC.replaceInstUsesWith(II, StepVal);
+  } else if (Pattern == AArch64SVEPredPattern::vl16 && NumElts == 16) {
+Constant *StepVal = ConstantInt::get(II.getType(), NumElts);

Could you potentially fold these two cases into one somehow? Maybe with a 
switch-case statement? I'm just imagining a situation where we might want other 
patterns too like vl32, vl64, etc.



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104852

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


[PATCH] D105005: [analyzer][solver][NFC] Simplify function signatures

2021-06-28 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko created this revision.
vsavchenko added reviewers: NoQ, xazax.hun, martong, steakhal, Szelethus, 
ASDenysPetrov, manas, RedDocMD.
Herald added subscribers: dkrupp, donat.nagy, mikhail.ramalho, a.sidorin, 
rnkovacs, szepet, baloghadamsoftware.
vsavchenko requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Since RangeSet::Factory actually contains BasicValueFactory, we can
remove value factory from many function signatures inside the solver.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D105005

Files:
  
clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h
  clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp

Index: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
===
--- clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
+++ clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
@@ -549,14 +549,13 @@
  SymbolRef Sym);
 
   /// Merge classes for the given symbols and return a new state.
-  LLVM_NODISCARD static inline ProgramStateRef
-  merge(BasicValueFactory &BV, RangeSet::Factory &F, ProgramStateRef State,
-SymbolRef First, SymbolRef Second);
+  LLVM_NODISCARD static inline ProgramStateRef merge(RangeSet::Factory &F,
+ ProgramStateRef State,
+ SymbolRef First,
+ SymbolRef Second);
   // Merge this class with the given class and return a new state.
-  LLVM_NODISCARD inline ProgramStateRef merge(BasicValueFactory &BV,
-  RangeSet::Factory &F,
-  ProgramStateRef State,
-  EquivalenceClass Other);
+  LLVM_NODISCARD inline ProgramStateRef
+  merge(RangeSet::Factory &F, ProgramStateRef State, EquivalenceClass Other);
 
   /// Return a set of class members for the given state.
   LLVM_NODISCARD inline SymbolSet getClassMembers(ProgramStateRef State) const;
@@ -567,15 +566,14 @@
  SymbolReaper &Reaper) const;
 
   LLVM_NODISCARD static inline ProgramStateRef
-  markDisequal(BasicValueFactory &BV, RangeSet::Factory &F,
-   ProgramStateRef State, SymbolRef First, SymbolRef Second);
+  markDisequal(RangeSet::Factory &F, ProgramStateRef State, SymbolRef First,
+   SymbolRef Second);
   LLVM_NODISCARD static inline ProgramStateRef
-  markDisequal(BasicValueFactory &BV, RangeSet::Factory &F,
-   ProgramStateRef State, EquivalenceClass First,
-   EquivalenceClass Second);
+  markDisequal(RangeSet::Factory &F, ProgramStateRef State,
+   EquivalenceClass First, EquivalenceClass Second);
   LLVM_NODISCARD inline ProgramStateRef
-  markDisequal(BasicValueFactory &BV, RangeSet::Factory &F,
-   ProgramStateRef State, EquivalenceClass Other) const;
+  markDisequal(RangeSet::Factory &F, ProgramStateRef State,
+   EquivalenceClass Other) const;
   LLVM_NODISCARD static inline ClassSet
   getDisequalClasses(ProgramStateRef State, SymbolRef Sym);
   LLVM_NODISCARD inline ClassSet
@@ -636,15 +634,13 @@
   }
   static inline SymbolSet::Factory &getMembersFactory(ProgramStateRef State);
 
-  inline ProgramStateRef mergeImpl(BasicValueFactory &BV, RangeSet::Factory &F,
-   ProgramStateRef State, SymbolSet Members,
-   EquivalenceClass Other,
+  inline ProgramStateRef mergeImpl(RangeSet::Factory &F, ProgramStateRef State,
+   SymbolSet Members, EquivalenceClass Other,
SymbolSet OtherMembers);
   static inline bool
   addToDisequalityInfo(DisequalityMapTy &Info, ConstraintRangeTy &Constraints,
-   BasicValueFactory &BV, RangeSet::Factory &F,
-   ProgramStateRef State, EquivalenceClass First,
-   EquivalenceClass Second);
+   RangeSet::Factory &F, ProgramStateRef State,
+   EquivalenceClass First, EquivalenceClass Second);
 
   /// This is a unique identifier of the class.
   uintptr_t ID;
@@ -735,8 +731,7 @@
 //===--===//
 
 template 
-LLVM_NODISCARD inline RangeSet intersect(BasicValueFactory &BV,
- RangeSet::Factory &F, RangeSet Head,
+LLVM_NODISCARD inline RangeSet intersect(RangeSet::Factory &F, RangeSet Head,
  SecondTy Second, RestTy... Tail);
 
 template  struct IntersectionTraits;
@@ -759,15 +754,14 @@
 };
 
 template 
-LLVM_NODISCARD inline EndTy intersect(BasicValueFactory &BV,
-

[clang-tools-extra] f3b55a8 - [clang-tidy][NFC] Fix buildbot failures in 'bugprone-easily-swappable-parameters'

2021-06-28 Thread via cfe-commits

Author: Whisperity
Date: 2021-06-28T11:19:16+02:00
New Revision: f3b55a8a06529bee95ed9a1b55c98ce3839b40ea

URL: 
https://github.com/llvm/llvm-project/commit/f3b55a8a06529bee95ed9a1b55c98ce3839b40ea
DIFF: 
https://github.com/llvm/llvm-project/commit/f3b55a8a06529bee95ed9a1b55c98ce3839b40ea.diff

LOG: [clang-tidy][NFC] Fix buildbot failures in 
'bugprone-easily-swappable-parameters'

Added: 


Modified: 
clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp

Removed: 




diff  --git 
a/clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp
index 6c84cb3e55537..72f5b25e9f66a 100644
--- a/clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp
@@ -98,24 +98,24 @@ namespace model {
 
 /// The language features involved in allowing the mix between two parameters.
 enum class MixFlags : unsigned char {
-  Invalid = 0, //< Sentinel bit pattern. DO NOT USE!
+  Invalid = 0, ///< Sentinel bit pattern. DO NOT USE!
 
-  //< Certain constructs (such as pointers to noexcept/non-noexcept functions)
-  // have the same CanonicalType, which would result in false positives.
-  // During the recursive modelling call, this flag is set if a later diagnosed
-  // canonical type equivalence should be thrown away.
+  /// Certain constructs (such as pointers to noexcept/non-noexcept functions)
+  /// have the same CanonicalType, which would result in false positives.
+  /// During the recursive modelling call, this flag is set if a later 
diagnosed
+  /// canonical type equivalence should be thrown away.
   WorkaroundDisableCanonicalEquivalence = 1,
 
-  None = 2,   //< Mix between the two parameters is not possible.
-  Trivial = 4,//< The two mix trivially, and are the exact same type.
-  Canonical = 8,  //< The two mix because the types refer to the same
-  // CanonicalType, but we do not elaborate as to how.
-  TypeAlias = 16, //< The path from one type to the other involves
-  // desugaring type aliases.
-  ReferenceBind = 32, //< The mix involves the binding power of "const &".
-  Qualifiers = 64,//< The mix involves change in the qualifiers.
-  ImplicitConversion = 128, //< The mixing of the parameters is possible
-// through implicit conversions between the types.
+  None = 2,   ///< Mix between the two parameters is not possible.
+  Trivial = 4,///< The two mix trivially, and are the exact same type.
+  Canonical = 8,  ///< The two mix because the types refer to the same
+  /// CanonicalType, but we do not elaborate as to how.
+  TypeAlias = 16, ///< The path from one type to the other involves
+  /// desugaring type aliases.
+  ReferenceBind = 32, ///< The mix involves the binding power of "const &".
+  Qualifiers = 64,///< The mix involves change in the qualifiers.
+  ImplicitConversion = 128, ///< The mixing of the parameters is possible
+/// through implicit conversions between the types.
 
   LLVM_MARK_AS_BITMASK_ENUM(/* LargestValue =*/ImplicitConversion)
 };
@@ -546,16 +546,16 @@ struct MixableParameterRange {
 
 /// Helper enum for the recursive calls in the modelling that toggle what kinds
 /// of implicit conversions are to be modelled.
-enum ImplicitConversionModellingMode : unsigned char {
-  //< No implicit conversions are modelled.
-  ICMM_None,
+enum class ImplicitConversionModellingMode : unsigned char {
+  /// No implicit conversions are modelled.
+  None,
 
-  //< The full implicit conversion sequence is modelled.
-  ICMM_All,
+  /// The full implicit conversion sequence is modelled.
+  All,
 
-  //< Only model a unidirectional implicit conversion and within it only one
-  // standard conversion sequence.
-  ICMM_OneWaySingleStandardOnly
+  /// Only model a unidirectional implicit conversion and within it only one
+  /// standard conversion sequence.
+  OneWaySingleStandardOnly
 };
 
 static MixData
@@ -684,9 +684,9 @@ calculateMixability(const TheCheck &Check, QualType LType, 
QualType RType,
 // some other match. However, this must not consider implicit conversions.
 LLVM_DEBUG(llvm::dbgs()
<< "--- calculateMixability. LHS and RHS are Ptrs.\n");
-MixData MixOfPointee =
-calculateMixability(Check, LType->getPointeeType(),
-RType->getPointeeType(), Ctx, ICMM_None);
+MixData MixOfPointee = calculateMixability(
+Check, LType->getPointeeType(), RType->getPointeeType(), Ctx,
+ImplicitConversionModellingMode::None);
 if (hasFlag(MixOfPointee.Flags,
 MixFlags::WorkaroundDisableCanonicalEquivalence))
   RecursiveReturnDis

[PATCH] D104847: [Clang][NVPTX] Add NVPTX intrinsics and builtins for CUDA PTX 6.5 and 7.0 WMMA and MMA instructions

2021-06-28 Thread Steffen Larsen via Phabricator via cfe-commits
steffenlarsen updated this revision to Diff 354814.
steffenlarsen added a comment.

Added comment about variant ordering.


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

https://reviews.llvm.org/D104847

Files:
  clang/include/clang/Basic/BuiltinsNVPTX.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/builtins-nvptx-mma.cu
  clang/test/CodeGen/builtins-nvptx-mma.py
  llvm/include/llvm/IR/IntrinsicsNVVM.td
  llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp
  llvm/lib/Target/NVPTX/NVPTXInstrInfo.td
  llvm/lib/Target/NVPTX/NVPTXIntrinsics.td
  llvm/test/CodeGen/NVPTX/lit.local.cfg
  llvm/test/CodeGen/NVPTX/wmma.py

Index: llvm/test/CodeGen/NVPTX/wmma.py
===
--- llvm/test/CodeGen/NVPTX/wmma.py
+++ llvm/test/CodeGen/NVPTX/wmma.py
@@ -6,7 +6,7 @@
 # RUN: FileCheck %t-ptx60-sm_70.ll < %t-ptx60-sm_70.ll \
 # RUN:   --check-prefixes=INTRINSICS,M16N16
 # RUN: FileCheck %t-ptx60-sm_70.ll < %t-ptx60-sm_70.ll \
-# RUN:   --check-prefixes=INTRINSICS,NOEXTGEOM,NOINT,NOSUBINT,NOMMA
+# RUN:   --check-prefixes=INTRINSICS,NOEXTGEOM,NOINT,NOSUBINT,NOMMA,NODOUBLE,NOALTFLOAT
 # RUN: llc < %t-ptx60-sm_70.ll -march=nvptx64 -mcpu=sm_70 -mattr=+ptx60 \
 # RUN:   | FileCheck %t-ptx60-sm_70.ll
 
@@ -15,7 +15,7 @@
 # RUN: FileCheck %t-ptx61-sm_70.ll < %t-ptx61-sm_70.ll \
 # RUN:   --check-prefixes=INTRINSICS,M16N16,EXTGEOM
 # RUN: FileCheck %t-ptx61-sm_70.ll < %t-ptx61-sm_70.ll \
-# RUN:   --check-prefixes=INTRINSICS,NOINT,NOSUBINT,NOMMA
+# RUN:   --check-prefixes=INTRINSICS,NOINT,NOSUBINT,NOMMA,NODOUBLE,NOALTFLOAT
 # RUN: llc < %t-ptx61-sm_70.ll -march=nvptx64 -mcpu=sm_70 -mattr=+ptx61 \
 # RUN:   | FileCheck %t-ptx61-sm_70.ll
 
@@ -24,7 +24,7 @@
 # RUN: FileCheck %t-ptx63-sm_72.ll < %t-ptx63-sm_72.ll \
 # RUN:   --check-prefixes=INTRINSICS,M16N16,EXTGEOM,INT
 # RUN: FileCheck %t-ptx63-sm_72.ll < %t-ptx63-sm_72.ll \
-# RUN:   --check-prefixes=INTRINSICS,NOSUBINT,NOMMA
+# RUN:   --check-prefixes=INTRINSICS,NOSUBINT,NOMMA,NODOUBLE,NOALTFLOAT
 # RUN: llc < %t-ptx63-sm_72.ll -march=nvptx64 -mcpu=sm_72 -mattr=+ptx63 \
 # RUN:   | FileCheck %t-ptx63-sm_72.ll
 
@@ -33,7 +33,7 @@
 # RUN: FileCheck %t-ptx63-sm_75.ll < %t-ptx63-sm_75.ll \
 # RUN:   --check-prefixes=INTRINSICS,M16N16,EXTGEOM,INT,SUBINT
 # RUN: FileCheck %t-ptx63-sm_75.ll < %t-ptx63-sm_75.ll \
-# RUN:   --check-prefixes=INTRINSICS,NOMMA
+# RUN:   --check-prefixes=INTRINSICS,NOMMA,NODOUBLE,NOALTFLOAT
 # RUN: llc < %t-ptx63-sm_75.ll -march=nvptx64 -mcpu=sm_75 -mattr=+ptx63 \
 # RUN:   | FileCheck %t-ptx63-sm_75.ll
 
@@ -42,10 +42,28 @@
 # RUN: FileCheck %t-ptx64-sm_70.ll < %t-ptx64-sm_70.ll \
 # RUN:   --check-prefixes=INTRINSICS,M16N16,EXTGEOM,MMA
 # RUN: FileCheck %t-ptx64-sm_70.ll < %t-ptx64-sm_70.ll \
-# RUN:   --check-prefixes=INTRINSICS,NOINT,NOSUBINT
+# RUN:   --check-prefixes=INTRINSICS,NOINT,NOSUBINT,NODOUBLE,NOALTFLOAT
 # RUN: llc < %t-ptx64-sm_70.ll -march=nvptx64 -mcpu=sm_70 -mattr=+ptx64 \
 # RUN:   | FileCheck %t-ptx64-sm_70.ll
 
+# Check all variants of instructions supported by PTX65 on SM75+
+# RUN: python %s --ptx=65 --gpu-arch=75 > %t-ptx65-sm_75.ll
+# RUN: FileCheck %t-ptx65-sm_75.ll < %t-ptx65-sm_75.ll \
+# RUN:   --check-prefixes=INTRINSICS,M16N16,EXTGEOM,INT,SUBINT,MMA,PTX65MMA
+# RUN: FileCheck %t-ptx65-sm_75.ll < %t-ptx65-sm_75.ll \
+# RUN:   --check-prefixes=INTRINSICS
+# RUN: llc < %t-ptx65-sm_75.ll -march=nvptx64 -mcpu=sm_75 -mattr=+ptx65 \
+# RUN:   | FileCheck %t-ptx65-sm_75.ll
+
+# Check all variants of instructions supported by PTX70 on SM80+
+# RUN: python %s --ptx=70 --gpu-arch=80 > %t-ptx70-sm_80.ll
+# RUN: FileCheck %t-ptx70-sm_80.ll < %t-ptx70-sm_80.ll \
+# RUN:   --check-prefixes=INTRINSICS,M16N16,EXTGEOM,INT,SUBINT,MMA,ALTFLOAT,DOUBLE,PTX65MMA,PTX70MMA
+# RUN: FileCheck %t-ptx70-sm_80.ll < %t-ptx70-sm_80.ll \
+# RUN:   --check-prefixes=INTRINSICS
+# RUN: llc < %t-ptx70-sm_80.ll -march=nvptx64 -mcpu=sm_80 -mattr=+ptx70 \
+# RUN:   | FileCheck %t-ptx70-sm_80.ll
+
 from __future__ import print_function
 
 import argparse
@@ -56,19 +74,23 @@
   def __init__(self, ptx_type):
 self.ptx_type = ptx_type
 self.llvm_type = {
-"f16" : "<2 x half>",
-"f32" : "float",
-"s32" : "i32",
-"s8"  : "i32",
-"u8"  : "i32",
-"s4"  : "i32",
-"u4"  : "i32",
-"b1"  : "i32",
+"f16"  : "<2 x half>",
+"f32"  : "float",
+"f64"  : "double",
+"s32"  : "i32",
+"s8"   : "i32",
+"u8"   : "i32",
+"s4"   : "i32",
+"u4"   : "i32",
+"b1"   : "i32",
+"bf16" : "i32",
+"tf32" : "i32",
 }[ptx_type];
 
 self.ptx_reg_pattern = {
 "f16" : "%hh[0-9]+",
 "f32" : "%f[0-9]+",
+"f64" : "%fd[0-9]+",
 }.get(pt

[PATCH] D104847: [Clang][NVPTX] Add NVPTX intrinsics and builtins for CUDA PTX 6.5 and 7.0 WMMA and MMA instructions

2021-06-28 Thread Steffen Larsen via Phabricator via cfe-commits
steffenlarsen marked an inline comment as done.
steffenlarsen added a comment.

In D104847#2841242 , @tra wrote:

> LGTM. Would you like me to land the patch on your behalf?

If it isn't to much of a bother. Thank you. 😄


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

https://reviews.llvm.org/D104847

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


[PATCH] D20689: [clang-tidy] Add 'readability-suspicious-call-argument' check

2021-06-28 Thread Whisperity via Phabricator via cfe-commits
whisperity marked 12 inline comments as done.
whisperity added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/readability/SuspiciousCallArgumentCheck.cpp:408-409
+
+  bool IsParamContinuouslyConst =
+  !IsParamReference || ParamType.getNonReferenceType().isConstQualified();
+

aaron.ballman wrote:
> Should this move down closer to where it's used?
Sure!



Comment at: 
clang-tools-extra/clang-tidy/readability/SuspiciousCallArgumentCheck.cpp:801
+  }
+  llvm_unreachable("Unhandled heuristic kind");
+}

aaron.ballman wrote:
> This looks pretty reachable to me in the case where there's no bound.
I'm not sure if that is the case. I added the `llvm_unreachable` so we don't 
get a warning about the function not having a return value on every code path. 
The `switch` covers **all** potential heuristics that are in the check //right 
now//, but if we add a new heuristic (to the enum) and forget to write it in, 
we will get a `-Wswitch` warning here. A `default` case doesn't apply here, 
further developers should be encouraged to wire new heuristics in properly.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D20689

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


[PATCH] D20689: [clang-tidy] Add 'readability-suspicious-call-argument' check

2021-06-28 Thread Whisperity via Phabricator via cfe-commits
whisperity marked an inline comment as done.
whisperity added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/readability/SuspiciousCallArgumentCheck.cpp:694-695
+
+  for (std::size_t I = 0, E = CalleeFuncDecl->getNumParams(); I != E; ++I) {
+if (const auto *Param = CalleeFuncDecl->getParamDecl(I)) {
+  ParamTypes.push_back(Param->getType());

aaron.ballman wrote:
> Range-based for loop over `CalledFuncDecl->params()`?
(Note: it's `parameters()` now, not `params()`!)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D20689

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


[clang] 6f3b775 - [Analyzer][solver] Add dump methods for (dis)equality classes.

2021-06-28 Thread Gabor Marton via cfe-commits

Author: Gabor Marton
Date: 2021-06-28T12:57:14+02:00
New Revision: 6f3b775c3e9c685f74ecbe2ce1a94af52cc17c2f

URL: 
https://github.com/llvm/llvm-project/commit/6f3b775c3e9c685f74ecbe2ce1a94af52cc17c2f
DIFF: 
https://github.com/llvm/llvm-project/commit/6f3b775c3e9c685f74ecbe2ce1a94af52cc17c2f.diff

LOG: [Analyzer][solver] Add dump methods for (dis)equality classes.

This proved to be very useful during debugging.

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

Added: 
clang/test/Analysis/expr-inspection-printState-diseq-info.c
clang/test/Analysis/expr-inspection-printState-eq-classes.c

Modified: 
clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
clang/test/Analysis/expr-inspection.c

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp 
b/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
index 6d17bcb8b87f0..27367ff5ae80c 100644
--- a/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
+++ b/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
@@ -594,6 +594,11 @@ class EquivalenceClass : public llvm::FoldingSetNode {
   RangeSet::Factory &F,
   ProgramStateRef State);
 
+  void dumpToStream(ProgramStateRef State, raw_ostream &os) const;
+  LLVM_DUMP_METHOD void dump(ProgramStateRef State) const {
+dumpToStream(State, llvm::errs());
+  }
+
   /// Check equivalence data for consistency.
   LLVM_NODISCARD LLVM_ATTRIBUTE_UNUSED static bool
   isClassDataConsistent(ProgramStateRef State);
@@ -1414,6 +1419,17 @@ class RangeConstraintManager : public 
RangedConstraintManager {
 
   void printJson(raw_ostream &Out, ProgramStateRef State, const char *NL = 
"\n",
  unsigned int Space = 0, bool IsDot = false) const override;
+  void printConstraints(raw_ostream &Out, ProgramStateRef State,
+const char *NL = "\n", unsigned int Space = 0,
+bool IsDot = false) const;
+  void printEquivalenceClasses(raw_ostream &Out, ProgramStateRef State,
+   const char *NL = "\n", unsigned int Space = 0,
+   bool IsDot = false) const;
+  void printEquivalenceClass(raw_ostream &Out, ProgramStateRef State,
+ EquivalenceClass Class) const;
+  void printDisequalities(raw_ostream &Out, ProgramStateRef State,
+  const char *NL = "\n", unsigned int Space = 0,
+  bool IsDot = false) const;
 
   //===--===//
   // Implementation for interface from RangedConstraintManager.
@@ -1637,6 +1653,15 @@ ConstraintMap ento::getConstraintMap(ProgramStateRef 
State) {
 // EqualityClass implementation details
 
//===--===//
 
+LLVM_DUMP_METHOD void EquivalenceClass::dumpToStream(ProgramStateRef State,
+ raw_ostream &os) const {
+  SymbolSet ClassMembers = getClassMembers(State);
+  for (const SymbolRef &MemberSym : ClassMembers) {
+MemberSym->dump();
+os << "\n";
+  }
+}
+
 inline EquivalenceClass EquivalenceClass::find(ProgramStateRef State,
SymbolRef Sym) {
   assert(State && "State should not be null");
@@ -2483,6 +2508,16 @@ ProgramStateRef 
RangeConstraintManager::assumeSymOutsideInclusiveRange(
 void RangeConstraintManager::printJson(raw_ostream &Out, ProgramStateRef State,
const char *NL, unsigned int Space,
bool IsDot) const {
+  printConstraints(Out, State, NL, Space, IsDot);
+  printEquivalenceClasses(Out, State, NL, Space, IsDot);
+  printDisequalities(Out, State, NL, Space, IsDot);
+}
+
+void RangeConstraintManager::printConstraints(raw_ostream &Out,
+  ProgramStateRef State,
+  const char *NL,
+  unsigned int Space,
+  bool IsDot) const {
   ConstraintRangeTy Constraints = State->get();
 
   Indent(Out, Space, IsDot) << "\"constraints\": ";
@@ -2516,3 +2551,106 @@ void RangeConstraintManager::printJson(raw_ostream 
&Out, ProgramStateRef State,
   --Space;
   Indent(Out, Space, IsDot) << "]," << NL;
 }
+
+void RangeConstraintManager::printEquivalenceClass(
+raw_ostream &Out, ProgramStateRef State, EquivalenceClass Class) const {
+  bool FirstMember = true;
+  SymbolSet ClassMembers = Class.getClassMembers(State);
+  Out << "[ ";
+  for (SymbolRef ClassMember : ClassMembers) {
+if (FirstMember)
+  FirstMember = false;
+else
+  Out << ", ";
+Out << "\"" << ClassMember << "\"";
+  

[PATCH] D103967: [Analyzer][solver] Add dump methods for (dis)equality classes.

2021-06-28 Thread Gabor Marton via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6f3b775c3e9c: [Analyzer][solver] Add dump methods for 
(dis)equality classes. (authored by martong).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103967

Files:
  clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
  clang/test/Analysis/expr-inspection-printState-diseq-info.c
  clang/test/Analysis/expr-inspection-printState-eq-classes.c
  clang/test/Analysis/expr-inspection.c

Index: clang/test/Analysis/expr-inspection.c
===
--- clang/test/Analysis/expr-inspection.c
+++ clang/test/Analysis/expr-inspection.c
@@ -38,6 +38,8 @@
 // CHECK-NEXT:   "constraints": [
 // CHECK-NEXT: { "symbol": "reg_$0", "range": "{ [-2147483648, 13] }" }
 // CHECK-NEXT:   ],
+// CHECK-NEXT:   "equivalence_classes": null,
+// CHECK-NEXT:   "disequality_info": null,
 // CHECK-NEXT:   "dynamic_types": null,
 // CHECK-NEXT:   "dynamic_casts": null,
 // CHECK-NEXT:   "constructing_objects": null,
Index: clang/test/Analysis/expr-inspection-printState-eq-classes.c
===
--- /dev/null
+++ clang/test/Analysis/expr-inspection-printState-eq-classes.c
@@ -0,0 +1,21 @@
+// RUN: %clang_analyze_cc1 \
+// RUN:  -analyzer-checker=debug.ExprInspection %s 2>&1 | FileCheck %s
+
+void clang_analyzer_printState();
+
+void test_equivalence_classes(int a, int b, int c, int d) {
+  if (a + b != c)
+return;
+  if (a != d)
+return;
+  if (b != 0)
+return;
+  clang_analyzer_printState();
+  (void)(a * b * c * d);
+  return;
+}
+
+// CHECK:   "equivalence_classes": [
+// CHECK-NEXT:[ "reg_$0", "(reg_$0) + (reg_$1)", "reg_$2", "reg_$3" ],
+// CHECK-NEXT:[ "((reg_$0) + (reg_$1)) != (reg_$2)", "(reg_$0) != (reg_$2)" ]
+// CHECK-NEXT:  ],
Index: clang/test/Analysis/expr-inspection-printState-diseq-info.c
===
--- /dev/null
+++ clang/test/Analysis/expr-inspection-printState-diseq-info.c
@@ -0,0 +1,34 @@
+// RUN: %clang_analyze_cc1 \
+// RUN:  -analyzer-checker=debug.ExprInspection %s 2>&1 | FileCheck %s
+
+void clang_analyzer_printState();
+
+void test_disequality_info(int e0, int b0, int b1, int c0) {
+  int e1 = e0 - b0;
+  if (b0 == 2) {
+int e2 = e1 - b1;
+if (e2 > 0) {
+  if (b1 != c0)
+clang_analyzer_printState();
+}
+  }
+}
+
+// CHECK:   "disequality_info": [
+// CHECK-NEXT:{
+// CHECK-NEXT:  "class": [ "reg_$2" ],
+// CHECK-NEXT:  "disequal_to": [
+// CHECK-NEXT:[ "(reg_$0) - 2" ],
+// CHECK-NEXT:[ "reg_$3" ]]
+// CHECK-NEXT:},
+// CHECK-NEXT:{
+// CHECK-NEXT:  "class": [ "(reg_$0) - 2" ],
+// CHECK-NEXT:  "disequal_to": [
+// CHECK-NEXT:[ "reg_$2" ]]
+// CHECK-NEXT:},
+// CHECK-NEXT:{
+// CHECK-NEXT:  "class": [ "reg_$3" ],
+// CHECK-NEXT:  "disequal_to": [
+// CHECK-NEXT:[ "reg_$2" ]]
+// CHECK-NEXT:}
+// CHECK-NEXT:  ],
Index: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
===
--- clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
+++ clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
@@ -594,6 +594,11 @@
   RangeSet::Factory &F,
   ProgramStateRef State);
 
+  void dumpToStream(ProgramStateRef State, raw_ostream &os) const;
+  LLVM_DUMP_METHOD void dump(ProgramStateRef State) const {
+dumpToStream(State, llvm::errs());
+  }
+
   /// Check equivalence data for consistency.
   LLVM_NODISCARD LLVM_ATTRIBUTE_UNUSED static bool
   isClassDataConsistent(ProgramStateRef State);
@@ -1414,6 +1419,17 @@
 
   void printJson(raw_ostream &Out, ProgramStateRef State, const char *NL = "\n",
  unsigned int Space = 0, bool IsDot = false) const override;
+  void printConstraints(raw_ostream &Out, ProgramStateRef State,
+const char *NL = "\n", unsigned int Space = 0,
+bool IsDot = false) const;
+  void printEquivalenceClasses(raw_ostream &Out, ProgramStateRef State,
+   const char *NL = "\n", unsigned int Space = 0,
+   bool IsDot = false) const;
+  void printEquivalenceClass(raw_ostream &Out, ProgramStateRef State,
+ EquivalenceClass Class) const;
+  void printDisequalities(raw_ostream &Out, ProgramStateRef State,
+  const char *NL = "\n", unsigned int Space = 0,
+  bool IsDot = false) const;
 
   //===--===//
   // Implementation for interface from RangedConstraintManager.
@@ -1637,6 +1653,15 @@
 // EqualityClass implementat

[PATCH] D105005: [analyzer][solver][NFC] Simplify function signatures

2021-06-28 Thread Gabor Marton via Phabricator via cfe-commits
martong accepted this revision.
martong added a comment.
This revision is now accepted and ready to land.

LGTM! Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105005

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


[clang] 8474bb1 - [analyzer][solver][NFC] Simplify function signatures

2021-06-28 Thread Valeriy Savchenko via cfe-commits

Author: Valeriy Savchenko
Date: 2021-06-28T14:20:06+03:00
New Revision: 8474bb13c3270d4195a663013b95e6065075ce56

URL: 
https://github.com/llvm/llvm-project/commit/8474bb13c3270d4195a663013b95e6065075ce56
DIFF: 
https://github.com/llvm/llvm-project/commit/8474bb13c3270d4195a663013b95e6065075ce56.diff

LOG: [analyzer][solver][NFC] Simplify function signatures

Since RangeSet::Factory actually contains BasicValueFactory, we can
remove value factory from many function signatures inside the solver.

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

Added: 


Modified: 

clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h
clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp

Removed: 




diff  --git 
a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h
 
b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h
index bf00fd98a4616..c67df1e51b4ff 100644
--- 
a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h
+++ 
b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h
@@ -213,6 +213,9 @@ class RangeSet {
 /// where N = size(What)
 RangeSet negate(RangeSet What);
 
+/// Return associated value factory.
+BasicValueFactory &getValueFactory() const { return ValueFactory; }
+
   private:
 /// Return a persistent version of the given container.
 RangeSet makePersistent(ContainerType &&From);

diff  --git a/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp 
b/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
index 27367ff5ae80c..c3d8a0a87635d 100644
--- a/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
+++ b/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
@@ -549,14 +549,13 @@ class EquivalenceClass : public llvm::FoldingSetNode {
  SymbolRef Sym);
 
   /// Merge classes for the given symbols and return a new state.
-  LLVM_NODISCARD static inline ProgramStateRef
-  merge(BasicValueFactory &BV, RangeSet::Factory &F, ProgramStateRef State,
-SymbolRef First, SymbolRef Second);
+  LLVM_NODISCARD static inline ProgramStateRef merge(RangeSet::Factory &F,
+ ProgramStateRef State,
+ SymbolRef First,
+ SymbolRef Second);
   // Merge this class with the given class and return a new state.
-  LLVM_NODISCARD inline ProgramStateRef merge(BasicValueFactory &BV,
-  RangeSet::Factory &F,
-  ProgramStateRef State,
-  EquivalenceClass Other);
+  LLVM_NODISCARD inline ProgramStateRef
+  merge(RangeSet::Factory &F, ProgramStateRef State, EquivalenceClass Other);
 
   /// Return a set of class members for the given state.
   LLVM_NODISCARD inline SymbolSet getClassMembers(ProgramStateRef State) const;
@@ -567,15 +566,14 @@ class EquivalenceClass : public llvm::FoldingSetNode {
  SymbolReaper &Reaper) const;
 
   LLVM_NODISCARD static inline ProgramStateRef
-  markDisequal(BasicValueFactory &BV, RangeSet::Factory &F,
-   ProgramStateRef State, SymbolRef First, SymbolRef Second);
+  markDisequal(RangeSet::Factory &F, ProgramStateRef State, SymbolRef First,
+   SymbolRef Second);
   LLVM_NODISCARD static inline ProgramStateRef
-  markDisequal(BasicValueFactory &BV, RangeSet::Factory &F,
-   ProgramStateRef State, EquivalenceClass First,
-   EquivalenceClass Second);
+  markDisequal(RangeSet::Factory &F, ProgramStateRef State,
+   EquivalenceClass First, EquivalenceClass Second);
   LLVM_NODISCARD inline ProgramStateRef
-  markDisequal(BasicValueFactory &BV, RangeSet::Factory &F,
-   ProgramStateRef State, EquivalenceClass Other) const;
+  markDisequal(RangeSet::Factory &F, ProgramStateRef State,
+   EquivalenceClass Other) const;
   LLVM_NODISCARD static inline ClassSet
   getDisequalClasses(ProgramStateRef State, SymbolRef Sym);
   LLVM_NODISCARD inline ClassSet
@@ -641,15 +639,13 @@ class EquivalenceClass : public llvm::FoldingSetNode {
   }
   static inline SymbolSet::Factory &getMembersFactory(ProgramStateRef State);
 
-  inline ProgramStateRef mergeImpl(BasicValueFactory &BV, RangeSet::Factory &F,
-   ProgramStateRef State, SymbolSet Members,
-   EquivalenceClass Other,
+  inline ProgramStateRef mergeImpl(RangeSet::Factory &F, ProgramStateRef State,
+   SymbolSet Members, EquivalenceClass Other,
SymbolSet OtherMembers);
   static i

[PATCH] D105005: [analyzer][solver][NFC] Simplify function signatures

2021-06-28 Thread Valeriy Savchenko via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8474bb13c327: [analyzer][solver][NFC] Simplify function 
signatures (authored by vsavchenko).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105005

Files:
  
clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h
  clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp

Index: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
===
--- clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
+++ clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
@@ -549,14 +549,13 @@
  SymbolRef Sym);
 
   /// Merge classes for the given symbols and return a new state.
-  LLVM_NODISCARD static inline ProgramStateRef
-  merge(BasicValueFactory &BV, RangeSet::Factory &F, ProgramStateRef State,
-SymbolRef First, SymbolRef Second);
+  LLVM_NODISCARD static inline ProgramStateRef merge(RangeSet::Factory &F,
+ ProgramStateRef State,
+ SymbolRef First,
+ SymbolRef Second);
   // Merge this class with the given class and return a new state.
-  LLVM_NODISCARD inline ProgramStateRef merge(BasicValueFactory &BV,
-  RangeSet::Factory &F,
-  ProgramStateRef State,
-  EquivalenceClass Other);
+  LLVM_NODISCARD inline ProgramStateRef
+  merge(RangeSet::Factory &F, ProgramStateRef State, EquivalenceClass Other);
 
   /// Return a set of class members for the given state.
   LLVM_NODISCARD inline SymbolSet getClassMembers(ProgramStateRef State) const;
@@ -567,15 +566,14 @@
  SymbolReaper &Reaper) const;
 
   LLVM_NODISCARD static inline ProgramStateRef
-  markDisequal(BasicValueFactory &BV, RangeSet::Factory &F,
-   ProgramStateRef State, SymbolRef First, SymbolRef Second);
+  markDisequal(RangeSet::Factory &F, ProgramStateRef State, SymbolRef First,
+   SymbolRef Second);
   LLVM_NODISCARD static inline ProgramStateRef
-  markDisequal(BasicValueFactory &BV, RangeSet::Factory &F,
-   ProgramStateRef State, EquivalenceClass First,
-   EquivalenceClass Second);
+  markDisequal(RangeSet::Factory &F, ProgramStateRef State,
+   EquivalenceClass First, EquivalenceClass Second);
   LLVM_NODISCARD inline ProgramStateRef
-  markDisequal(BasicValueFactory &BV, RangeSet::Factory &F,
-   ProgramStateRef State, EquivalenceClass Other) const;
+  markDisequal(RangeSet::Factory &F, ProgramStateRef State,
+   EquivalenceClass Other) const;
   LLVM_NODISCARD static inline ClassSet
   getDisequalClasses(ProgramStateRef State, SymbolRef Sym);
   LLVM_NODISCARD inline ClassSet
@@ -641,15 +639,13 @@
   }
   static inline SymbolSet::Factory &getMembersFactory(ProgramStateRef State);
 
-  inline ProgramStateRef mergeImpl(BasicValueFactory &BV, RangeSet::Factory &F,
-   ProgramStateRef State, SymbolSet Members,
-   EquivalenceClass Other,
+  inline ProgramStateRef mergeImpl(RangeSet::Factory &F, ProgramStateRef State,
+   SymbolSet Members, EquivalenceClass Other,
SymbolSet OtherMembers);
   static inline bool
   addToDisequalityInfo(DisequalityMapTy &Info, ConstraintRangeTy &Constraints,
-   BasicValueFactory &BV, RangeSet::Factory &F,
-   ProgramStateRef State, EquivalenceClass First,
-   EquivalenceClass Second);
+   RangeSet::Factory &F, ProgramStateRef State,
+   EquivalenceClass First, EquivalenceClass Second);
 
   /// This is a unique identifier of the class.
   uintptr_t ID;
@@ -740,8 +736,7 @@
 //===--===//
 
 template 
-LLVM_NODISCARD inline RangeSet intersect(BasicValueFactory &BV,
- RangeSet::Factory &F, RangeSet Head,
+LLVM_NODISCARD inline RangeSet intersect(RangeSet::Factory &F, RangeSet Head,
  SecondTy Second, RestTy... Tail);
 
 template  struct IntersectionTraits;
@@ -764,15 +759,14 @@
 };
 
 template 
-LLVM_NODISCARD inline EndTy intersect(BasicValueFactory &BV,
-  RangeSet::Factory &F, EndTy End) {
+LLVM_NODISCARD inline EndTy intersect(RangeSet::Factory &F, EndTy End) {
   // If the list contains only RangeSet or Optional, simply retur

[PATCH] D93373: [Flang][Openmp] Upgrade TASKGROUP construct to 5.0.

2021-06-28 Thread Chirag Khandelwal via Phabricator via cfe-commits
AMDChirag updated this revision to Diff 354839.
AMDChirag added a comment.

Rebased


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93373

Files:
  clang/test/OpenMP/master_taskloop_simd_ast_print.cpp
  clang/test/OpenMP/parallel_master_taskloop_simd_ast_print.cpp
  clang/test/OpenMP/taskloop_simd_ast_print.cpp
  flang/lib/Semantics/resolve-directives.cpp
  flang/lib/Semantics/resolve-names.cpp
  flang/test/Semantics/omp-taskgroup01.f90
  llvm/include/llvm/Frontend/OpenMP/OMP.td

Index: llvm/include/llvm/Frontend/OpenMP/OMP.td
===
--- llvm/include/llvm/Frontend/OpenMP/OMP.td
+++ llvm/include/llvm/Frontend/OpenMP/OMP.td
@@ -473,8 +473,8 @@
 }
 def OMP_TaskGroup : Directive<"taskgroup"> {
   let allowedClauses = [
-VersionedClause,
-VersionedClause
+VersionedClause,
+VersionedClause
   ];
 }
 def OMP_Flush : Directive<"flush"> {
Index: flang/test/Semantics/omp-taskgroup01.f90
===
--- /dev/null
+++ flang/test/Semantics/omp-taskgroup01.f90
@@ -0,0 +1,47 @@
+! RUN: %S/test_errors.sh %s %t %flang -fopenmp
+use omp_lib
+  implicit none
+  integer :: xyz, abc
+  real :: reduction_var
+  !$omp parallel num_threads(4)
+!$omp single
+  print *, "The"
+!$omp taskgroup
+  !$omp task
+  print *, "almighty"
+  !$omp end task
+  !$omp task
+  print *, "sun"
+  !$omp end task
+!$omp end taskgroup
+!$omp end single
+  !$omp end parallel
+
+  !$omp parallel private(xyz)
+!$omp taskgroup allocate(xyz)
+  !$omp task
+print *, "The "
+!$omp taskgroup allocate(omp_large_cap_mem_space: abc)
+  !$omp task
+  print *, "almighty sun"
+  !$omp end task
+!$omp end taskgroup
+  !$omp end task
+!$omp end taskgroup
+  !$omp end parallel
+
+  !ERROR: PRIVATE clause is not allowed on the TASKGROUP directive
+  !$omp taskgroup private(abc)
+  !$omp end taskgroup
+
+  !$omp parallel
+!$omp task
+  !$omp taskgroup task_reduction(+ : reduction_var)
+print *, "The "
+!$omp taskgroup task_reduction(.or. : reduction_var) task_reduction(.and. : reduction_var)
+  print *, "almighty sun"
+!$omp end taskgroup
+  !$omp end taskgroup
+!$omp end task
+  !$omp end parallel
+end program
Index: flang/lib/Semantics/resolve-names.cpp
===
--- flang/lib/Semantics/resolve-names.cpp
+++ flang/lib/Semantics/resolve-names.cpp
@@ -1288,6 +1288,7 @@
   case llvm::omp::Directive::OMPD_target_data:
   case llvm::omp::Directive::OMPD_master:
   case llvm::omp::Directive::OMPD_ordered:
+  case llvm::omp::Directive::OMPD_taskgroup:
 return false;
   default:
 return true;
Index: flang/lib/Semantics/resolve-directives.cpp
===
--- flang/lib/Semantics/resolve-directives.cpp
+++ flang/lib/Semantics/resolve-directives.cpp
@@ -1069,12 +1069,12 @@
   case llvm::omp::Directive::OMPD_target:
   case llvm::omp::Directive::OMPD_target_data:
   case llvm::omp::Directive::OMPD_task:
+  case llvm::omp::Directive::OMPD_taskgroup:
   case llvm::omp::Directive::OMPD_teams:
   case llvm::omp::Directive::OMPD_workshare:
   case llvm::omp::Directive::OMPD_parallel_workshare:
   case llvm::omp::Directive::OMPD_target_teams:
   case llvm::omp::Directive::OMPD_target_parallel:
-  case llvm::omp::Directive::OMPD_taskgroup:
 PushContext(beginDir.source, beginDir.v);
 break;
   default:
@@ -1095,6 +1095,7 @@
   case llvm::omp::Directive::OMPD_single:
   case llvm::omp::Directive::OMPD_target:
   case llvm::omp::Directive::OMPD_task:
+  case llvm::omp::Directive::OMPD_taskgroup:
   case llvm::omp::Directive::OMPD_teams:
   case llvm::omp::Directive::OMPD_parallel_workshare:
   case llvm::omp::Directive::OMPD_target_teams:
Index: clang/test/OpenMP/taskloop_simd_ast_print.cpp
===
--- clang/test/OpenMP/taskloop_simd_ast_print.cpp
+++ clang/test/OpenMP/taskloop_simd_ast_print.cpp
@@ -1,13 +1,13 @@
-// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -ast-print %s | FileCheck %s --check-prefix CHECK --check-prefix OMP45
-// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -std=c++11 -emit-pch -o %t %s
-// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck %s --check-prefix CHECK --check-prefix OMP45
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=50 -DOMP5 -ast-print %s | FileCheck %s --check-prefix CHECK --check-prefix OMP50
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=50 -DOMP5 -x c++ -std=c++11 -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=50 -DOMP5 -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print | File

[PATCH] D104852: [AArch64][SVEIntrinsicOpts] Convect cntb/h/w/d to vscale intrinsic or constant.

2021-06-28 Thread JunMa via Phabricator via cfe-commits
junparser added inline comments.



Comment at: llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp:662
+return IC.replaceInstUsesWith(II, StepVal);
+  } else if (Pattern == AArch64SVEPredPattern::vl16 && NumElts == 16) {
+Constant *StepVal = ConstantInt::get(II.getType(), NumElts);

david-arm wrote:
> Could you potentially fold these two cases into one somehow? Maybe with a 
> switch-case statement? I'm just imagining a situation where we might want 
> other patterns too like vl32, vl64, etc.
> 
There is no other special pattern except vl16. But I do think switch-case is 
more straightforward


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104852

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


[PATCH] D104852: [AArch64][SVEIntrinsicOpts] Convect cntb/h/w/d to vscale intrinsic or constant.

2021-06-28 Thread JunMa via Phabricator via cfe-commits
junparser updated this revision to Diff 354846.
junparser added a comment.

Address comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104852

Files:
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cntb.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cntd.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cnth.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cntw.c
  llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp
  llvm/test/Transforms/InstCombine/AArch64/sve-intrinsic-opts-counting-elems.ll

Index: llvm/test/Transforms/InstCombine/AArch64/sve-intrinsic-opts-counting-elems.ll
===
--- /dev/null
+++ llvm/test/Transforms/InstCombine/AArch64/sve-intrinsic-opts-counting-elems.ll
@@ -0,0 +1,247 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt -S -instcombine < %s | FileCheck %s
+
+target triple = "aarch64-unknown-linux-gnu"
+
+;
+; CNTB
+;
+
+define i64 @cntb_vl1() {
+; CHECK-LABEL: @cntb_vl1(
+; CHECK-NEXT:ret i64 1
+;
+  %out = call i64 @llvm.aarch64.sve.cntb(i32 1)
+  ret i64 %out
+}
+
+define i64 @cntb_vl2() {
+; CHECK-LABEL: @cntb_vl2(
+; CHECK-NEXT:ret i64 2
+;
+  %out = call i64 @llvm.aarch64.sve.cntb(i32 2)
+  ret i64 %out
+}
+
+define i64 @cntb_vl4() {
+; CHECK-LABEL: @cntb_vl4(
+; CHECK-NEXT:ret i64 4
+;
+  %out = call i64 @llvm.aarch64.sve.cntb(i32 4)
+  ret i64 %out
+}
+
+define i64 @cntb_mul3() {
+; CHECK-LABEL: @cntb_mul3(
+; CHECK-NEXT:ret i64 24
+;
+  %cnt = call i64 @llvm.aarch64.sve.cntb(i32 8)
+  %out = mul i64 %cnt, 3
+  ret i64 %out
+}
+
+define i64 @cntb_mul4() {
+; CHECK-LABEL: @cntb_mul4(
+; CHECK-NEXT:ret i64 64
+;
+  %cnt = call i64 @llvm.aarch64.sve.cntb(i32 9)
+  %out = mul i64 %cnt, 4
+  ret i64 %out
+}
+
+define i64 @cntb_all() {
+; CHECK-LABEL: @cntb_all(
+; CHECK-NEXT:[[TMP1:%.*]] = call i64 @llvm.vscale.i64()
+; CHECK-NEXT:[[OUT:%.*]] = shl i64 [[TMP1]], 4
+; CHECK-NEXT:ret i64 [[OUT]]
+;
+  %out = call i64 @llvm.aarch64.sve.cntb(i32 31)
+  ret i64 %out
+}
+
+;
+; CNTH
+;
+
+define i64 @cnth_vl1() {
+; CHECK-LABEL: @cnth_vl1(
+; CHECK-NEXT:ret i64 1
+;
+  %out = call i64 @llvm.aarch64.sve.cnth(i32 1)
+  ret i64 %out
+}
+
+define i64 @cnth_vl2() {
+; CHECK-LABEL: @cnth_vl2(
+; CHECK-NEXT:ret i64 2
+;
+  %out = call i64 @llvm.aarch64.sve.cnth(i32 2)
+  ret i64 %out
+}
+
+define i64 @cnth_vl4() {
+; CHECK-LABEL: @cnth_vl4(
+; CHECK-NEXT:ret i64 4
+;
+  %out = call i64 @llvm.aarch64.sve.cnth(i32 4)
+  ret i64 %out
+}
+
+define i64 @cnth_mul3() {
+; CHECK-LABEL: @cnth_mul3(
+; CHECK-NEXT:ret i64 24
+;
+  %cnt = call i64 @llvm.aarch64.sve.cnth(i32 8)
+  %out = mul i64 %cnt, 3
+  ret i64 %out
+}
+
+define i64 @cnth_mul4() {
+; CHECK-LABEL: @cnth_mul4(
+; CHECK-NEXT:[[CNT:%.*]] = call i64 @llvm.aarch64.sve.cnth(i32 9)
+; CHECK-NEXT:[[OUT:%.*]] = shl i64 [[CNT]], 2
+; CHECK-NEXT:ret i64 [[OUT]]
+;
+  %cnt = call i64 @llvm.aarch64.sve.cnth(i32 9)
+  %out = mul i64 %cnt, 4
+  ret i64 %out
+}
+
+define i64 @cnth_all() {
+; CHECK-LABEL: @cnth_all(
+; CHECK-NEXT:[[TMP1:%.*]] = call i64 @llvm.vscale.i64()
+; CHECK-NEXT:[[OUT:%.*]] = shl i64 [[TMP1]], 3
+; CHECK-NEXT:ret i64 [[OUT]]
+;
+  %out = call i64 @llvm.aarch64.sve.cnth(i32 31)
+  ret i64 %out
+}
+
+;
+; CNTW
+;
+
+define i64 @cntw_vl1() {
+; CHECK-LABEL: @cntw_vl1(
+; CHECK-NEXT:ret i64 1
+;
+  %out = call i64 @llvm.aarch64.sve.cntw(i32 1)
+  ret i64 %out
+}
+
+define i64 @cntw_vl2() {
+; CHECK-LABEL: @cntw_vl2(
+; CHECK-NEXT:ret i64 2
+;
+  %out = call i64 @llvm.aarch64.sve.cntw(i32 2)
+  ret i64 %out
+}
+
+define i64 @cntw_vl4() {
+; CHECK-LABEL: @cntw_vl4(
+; CHECK-NEXT:ret i64 4
+;
+  %out = call i64 @llvm.aarch64.sve.cntw(i32 4)
+  ret i64 %out
+}
+
+define i64 @cntw_mul3() {
+; CHECK-LABEL: @cntw_mul3(
+; CHECK-NEXT:[[CNT:%.*]] = call i64 @llvm.aarch64.sve.cntw(i32 8)
+; CHECK-NEXT:[[OUT:%.*]] = mul i64 [[CNT]], 3
+; CHECK-NEXT:ret i64 [[OUT]]
+;
+  %cnt = call i64 @llvm.aarch64.sve.cntw(i32 8)
+  %out = mul i64 %cnt, 3
+  ret i64 %out
+}
+
+define i64 @cntw_mul4() {
+; CHECK-LABEL: @cntw_mul4(
+; CHECK-NEXT:[[CNT:%.*]] = call i64 @llvm.aarch64.sve.cntw(i32 9)
+; CHECK-NEXT:[[OUT:%.*]] = shl i64 [[CNT]], 2
+; CHECK-NEXT:ret i64 [[OUT]]
+;
+  %cnt = call i64 @llvm.aarch64.sve.cntw(i32 9)
+  %out = mul i64 %cnt, 4
+  ret i64 %out
+}
+
+define i64 @cntw_all() {
+; CHECK-LABEL: @cntw_all(
+; CHECK-NEXT:[[TMP1:%.*]] = call i64 @llvm.vscale.i64()
+; CHECK-NEXT:[[OUT:%.*]] = shl i64 [[TMP1]], 2
+; CHECK-NEXT:ret i64 [[OUT]]
+;
+  %out = call i64 @llvm.aarch64.sve.cntw(i32 31)
+  ret i64 %out
+}
+
+
+;
+; CNTD
+;
+
+define i64 @cntd_vl1() {
+; CHECK-LABEL: @cntd_vl1(
+; CHECK-NEXT:ret i64 1
+;
+  %out = call i64 @llvm.aarch64.sve.cntd(i32 1)
+  ret i64 %out
+}
+
+define i64 @cntd_vl2() {
+; CHE

[PATCH] D104852: [AArch64][SVEIntrinsicOpts] Convect cntb/h/w/d to vscale intrinsic or constant.

2021-06-28 Thread David Sherwood via Phabricator via cfe-commits
david-arm added inline comments.



Comment at: llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp:671
+  case AArch64SVEPredPattern::vl8:
+return NumElts >= Pattern
+   ? Optional(IC.replaceInstUsesWith(

I was actually wondering if we could commonise this code somehow. Perhaps by 
setting a MinNumElts variable in the case statements, i.e.

  unsigned MinNumElts;
  ...
  case AArch64SVEPredPattern::vl8:
MinNumElts = Pattern;
break;
  case AArch64SVEPredPattern::vl16:
MinNumElts = 16;
break;
  }

  if (NumElts < MinNumElts) return None;

  return Optional(IC.replaceInstUsesWith(
   II, ConstantInt::get(II.getType(), NumElts)));



Comment at: llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp:662
+return IC.replaceInstUsesWith(II, StepVal);
+  } else if (Pattern == AArch64SVEPredPattern::vl16 && NumElts == 16) {
+Constant *StepVal = ConstantInt::get(II.getType(), NumElts);

junparser wrote:
> david-arm wrote:
> > Could you potentially fold these two cases into one somehow? Maybe with a 
> > switch-case statement? I'm just imagining a situation where we might want 
> > other patterns too like vl32, vl64, etc.
> > 
> There is no other special pattern except vl16. But I do think switch-case is 
> more straightforward
OK, thanks for making this a switch statement. I was just thinking that in the 
developer manual we say we also support vl1-vl256 so at some point we may add 
more enums in LLVM too.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104852

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


[PATCH] D103967: [Analyzer][solver] Add dump methods for (dis)equality classes.

2021-06-28 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

This breaks tests on Windows: http://45.33.8.238/win/40864/step_7.txt

Please take a look, and please revert if it takes a while to fix.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103967

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


[PATCH] D105014: added some example code for llvm::Expected

2021-06-28 Thread Christian Kühnel via Phabricator via cfe-commits
kuhnel created this revision.
kuhnel added a reviewer: sammccall.
Herald added subscribers: dexonsmith, usaxena95, kadircet, arphaman.
kuhnel requested review of this revision.
Herald added projects: LLVM, clang-tools-extra.
Herald added subscribers: cfe-commits, llvm-commits.

Since I had some fun understanding how to properly use llvm::Expected I 
added some code examples that I would have liked to see when learning to use it.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D105014

Files:
  clang-tools-extra/clangd/index/StdLib.cpp
  llvm/include/llvm/Support/Error.h

Index: llvm/include/llvm/Support/Error.h
===
--- llvm/include/llvm/Support/Error.h
+++ llvm/include/llvm/Support/Error.h
@@ -162,7 +162,7 @@
 
   // handleErrors needs to be able to set the Checked flag.
   template 
-  friend Error handleErrors(Error E, HandlerTs &&... Handlers);
+  friend Error handleErrors(Error E, HandlerTs &&...Handlers);
 
   // Expected needs to be able to steal the payload when constructed from an
   // error.
@@ -244,7 +244,7 @@
 
   /// Returns the dynamic class id of this error, or null if this is a success
   /// value.
-  const void* dynamicClassID() const {
+  const void *dynamicClassID() const {
 if (!getPtr())
   return nullptr;
 return getPtr()->dynamicClassID();
@@ -270,9 +270,8 @@
 
   ErrorInfoBase *getPtr() const {
 #if LLVM_ENABLE_ABI_BREAKING_CHECKS
-return reinterpret_cast(
- reinterpret_cast(Payload) &
- ~static_cast(0x1));
+return reinterpret_cast(
+reinterpret_cast(Payload) & ~static_cast(0x1));
 #else
 return Payload;
 #endif
@@ -280,10 +279,9 @@
 
   void setPtr(ErrorInfoBase *EI) {
 #if LLVM_ENABLE_ABI_BREAKING_CHECKS
-Payload = reinterpret_cast(
-(reinterpret_cast(EI) &
- ~static_cast(0x1)) |
-(reinterpret_cast(Payload) & 0x1));
+Payload = reinterpret_cast(
+(reinterpret_cast(EI) & ~static_cast(0x1)) |
+(reinterpret_cast(Payload) & 0x1));
 #else
 Payload = EI;
 #endif
@@ -299,10 +297,9 @@
 
   void setChecked(bool V) {
 #if LLVM_ENABLE_ABI_BREAKING_CHECKS
-Payload = reinterpret_cast(
-(reinterpret_cast(Payload) &
-  ~static_cast(0x1)) |
-  (V ? 0 : 1));
+Payload = reinterpret_cast(
+(reinterpret_cast(Payload) & ~static_cast(0x1)) |
+(V ? 0 : 1));
 #endif
   }
 
@@ -333,7 +330,7 @@
 
 /// Make a Error instance representing failure using the given error info
 /// type.
-template  Error make_error(ArgTs &&... Args) {
+template  Error make_error(ArgTs &&...Args) {
   return Error(std::make_unique(std::forward(Args)...));
 }
 
@@ -366,7 +363,7 @@
   // handleErrors needs to be able to iterate the payload list of an
   // ErrorList.
   template 
-  friend Error handleErrors(Error E, HandlerTs &&... Handlers);
+  friend Error handleErrors(Error E, HandlerTs &&...Handlers);
 
   // joinErrors is implemented in terms of join.
   friend Error joinErrors(Error, Error);
@@ -436,6 +433,49 @@
 /// Error cannot be copied, this class replaces getError() with
 /// takeError(). It also adds an bool errorIsA() method for testing the
 /// error class type.
+///
+/// Example usage of 'Expected' as a return type:
+///
+///   @code{.cpp}
+/// Expected myDivide(int A, int B) {
+///   if (B == 0) {
+/// // return an Error
+/// return error("B must not be zero!");
+///   }
+///   // return an integer
+///   return A / B;
+/// }
+///   @endcode
+///
+///   Checking the results of to a function returning 'Expected':
+///   @code{.cpp}
+/// auto Result = myDivide(X,Y);
+/// if (!Result) {
+///   auto Error = Result.takeError();
+///   // handle the error case here
+/// } else {
+///   // handle good case here
+/// }
+///
+///   @endcode
+///
+///  Unit-testing a function returning an 'Expceted':
+///   @code{.cpp}
+///   TEST(MyTests, ExpectedDemo) {
+/// auto Passed = myDivide(10, 5);
+/// // check this call has passed, this also prints the error message
+/// // if the function returns an Error
+/// ASSERT_TRUE((bool)Passed) << llvm::toString(Passed.takeError());
+/// // checked the returned value
+/// ASSERT_EQ(2, *Passed);
+///
+/// auto Failed = myDivide(1, 0);
+/// ASSERT_FALSE((bool)Failed);
+/// // make sure Failed.takeError() does not get remove by the optimizer
+/// std::cout << "Expected failure: " << llvm::toString(Failed.takeError());
+///   }
+///   @endcode
+
 template  class LLVM_NODISCARD Expected {
   template  friend class ExpectedAsOutParameter;
   template  friend class Expected;
@@ -462,7 +502,8 @@
   : HasError(true)
 #if LLVM_ENABLE_ABI_BREAKING_CHECKS
 // Expected is unchecked upon construction in Debug builds.
-, Unchecked(true)
+,
+Unchecked(true)
 #endif
   {
 assert(E

[PATCH] D105014: added some example code for llvm::Expected

2021-06-28 Thread Christian Kühnel via Phabricator via cfe-commits
kuhnel updated this revision to Diff 354849.
kuhnel added a comment.

removed stray file


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105014

Files:
  llvm/include/llvm/Support/Error.h

Index: llvm/include/llvm/Support/Error.h
===
--- llvm/include/llvm/Support/Error.h
+++ llvm/include/llvm/Support/Error.h
@@ -162,7 +162,7 @@
 
   // handleErrors needs to be able to set the Checked flag.
   template 
-  friend Error handleErrors(Error E, HandlerTs &&... Handlers);
+  friend Error handleErrors(Error E, HandlerTs &&...Handlers);
 
   // Expected needs to be able to steal the payload when constructed from an
   // error.
@@ -244,7 +244,7 @@
 
   /// Returns the dynamic class id of this error, or null if this is a success
   /// value.
-  const void* dynamicClassID() const {
+  const void *dynamicClassID() const {
 if (!getPtr())
   return nullptr;
 return getPtr()->dynamicClassID();
@@ -270,9 +270,8 @@
 
   ErrorInfoBase *getPtr() const {
 #if LLVM_ENABLE_ABI_BREAKING_CHECKS
-return reinterpret_cast(
- reinterpret_cast(Payload) &
- ~static_cast(0x1));
+return reinterpret_cast(
+reinterpret_cast(Payload) & ~static_cast(0x1));
 #else
 return Payload;
 #endif
@@ -280,10 +279,9 @@
 
   void setPtr(ErrorInfoBase *EI) {
 #if LLVM_ENABLE_ABI_BREAKING_CHECKS
-Payload = reinterpret_cast(
-(reinterpret_cast(EI) &
- ~static_cast(0x1)) |
-(reinterpret_cast(Payload) & 0x1));
+Payload = reinterpret_cast(
+(reinterpret_cast(EI) & ~static_cast(0x1)) |
+(reinterpret_cast(Payload) & 0x1));
 #else
 Payload = EI;
 #endif
@@ -299,10 +297,9 @@
 
   void setChecked(bool V) {
 #if LLVM_ENABLE_ABI_BREAKING_CHECKS
-Payload = reinterpret_cast(
-(reinterpret_cast(Payload) &
-  ~static_cast(0x1)) |
-  (V ? 0 : 1));
+Payload = reinterpret_cast(
+(reinterpret_cast(Payload) & ~static_cast(0x1)) |
+(V ? 0 : 1));
 #endif
   }
 
@@ -333,7 +330,7 @@
 
 /// Make a Error instance representing failure using the given error info
 /// type.
-template  Error make_error(ArgTs &&... Args) {
+template  Error make_error(ArgTs &&...Args) {
   return Error(std::make_unique(std::forward(Args)...));
 }
 
@@ -366,7 +363,7 @@
   // handleErrors needs to be able to iterate the payload list of an
   // ErrorList.
   template 
-  friend Error handleErrors(Error E, HandlerTs &&... Handlers);
+  friend Error handleErrors(Error E, HandlerTs &&...Handlers);
 
   // joinErrors is implemented in terms of join.
   friend Error joinErrors(Error, Error);
@@ -436,6 +433,49 @@
 /// Error cannot be copied, this class replaces getError() with
 /// takeError(). It also adds an bool errorIsA() method for testing the
 /// error class type.
+///
+/// Example usage of 'Expected' as a return type:
+///
+///   @code{.cpp}
+/// Expected myDivide(int A, int B) {
+///   if (B == 0) {
+/// // return an Error
+/// return error("B must not be zero!");
+///   }
+///   // return an integer
+///   return A / B;
+/// }
+///   @endcode
+///
+///   Checking the results of to a function returning 'Expected':
+///   @code{.cpp}
+/// auto Result = myDivide(X,Y);
+/// if (!Result) {
+///   auto Error = Result.takeError();
+///   // handle the error case here
+/// } else {
+///   // handle good case here
+/// }
+///
+///   @endcode
+///
+///  Unit-testing a function returning an 'Expceted':
+///   @code{.cpp}
+///   TEST(MyTests, ExpectedDemo) {
+/// auto Passed = myDivide(10, 5);
+/// // check this call has passed, this also prints the error message
+/// // if the function returns an Error
+/// ASSERT_TRUE((bool)Passed) << llvm::toString(Passed.takeError());
+/// // checked the returned value
+/// ASSERT_EQ(2, *Passed);
+///
+/// auto Failed = myDivide(1, 0);
+/// ASSERT_FALSE((bool)Failed);
+/// // make sure Failed.takeError() does not get remove by the optimizer
+/// std::cout << "Expected failure: " << llvm::toString(Failed.takeError());
+///   }
+///   @endcode
+
 template  class LLVM_NODISCARD Expected {
   template  friend class ExpectedAsOutParameter;
   template  friend class Expected;
@@ -462,7 +502,8 @@
   : HasError(true)
 #if LLVM_ENABLE_ABI_BREAKING_CHECKS
 // Expected is unchecked upon construction in Debug builds.
-, Unchecked(true)
+,
+Unchecked(true)
 #endif
   {
 assert(Err && "Cannot create Expected from Error success value.");
@@ -764,7 +805,7 @@
 ///   Bar &X = cantFail(foo(false));
 ///   @endcode
 template 
-T& cantFail(Expected ValOrErr, const char *Msg = nullptr) {
+T &cantFail(Expected ValOrErr, const char *Msg = nullptr) {
   if (ValOrErr)
 return *ValOrErr;
   else {
@@ -7

[PATCH] D105014: added some example code for llvm::Expected

2021-06-28 Thread Christian Kühnel via Phabricator via cfe-commits
kuhnel added a comment.

Argh, the auto formatter seems to have done some magic. I guess I should revert 
these?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105014

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


[PATCH] D105014: added some example code for llvm::Expected

2021-06-28 Thread Christian Kühnel via Phabricator via cfe-commits
kuhnel updated this revision to Diff 354855.
kuhnel added a comment.

undo of auto formatting


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105014

Files:
  llvm/include/llvm/Support/Error.h


Index: llvm/include/llvm/Support/Error.h
===
--- llvm/include/llvm/Support/Error.h
+++ llvm/include/llvm/Support/Error.h
@@ -436,6 +436,49 @@
 /// Error cannot be copied, this class replaces getError() with
 /// takeError(). It also adds an bool errorIsA() method for testing the
 /// error class type.
+///
+/// Example usage of 'Expected' as a return type:
+///
+///   @code{.cpp}
+/// Expected myDivide(int A, int B) {
+///   if (B == 0) {
+/// // return an Error
+/// return error("B must not be zero!");
+///   }
+///   // return an integer
+///   return A / B;
+/// }
+///   @endcode
+///
+///   Checking the results of to a function returning 'Expected':
+///   @code{.cpp}
+/// auto Result = myDivide(X,Y);
+/// if (!Result) {
+///   auto Error = Result.takeError();
+///   // handle the error case here
+/// } else {
+///   // handle good case here
+/// }
+///
+///   @endcode
+///
+///  Unit-testing a function returning an 'Expceted':
+///   @code{.cpp}
+///   TEST(MyTests, ExpectedDemo) {
+/// auto Passed = myDivide(10, 5);
+/// // check this call has passed, this also prints the error message
+/// // if the function returns an Error
+/// ASSERT_TRUE((bool)Passed) << llvm::toString(Passed.takeError());
+/// // checked the returned value
+/// ASSERT_EQ(2, *Passed);
+///
+/// auto Failed = myDivide(1, 0);
+/// ASSERT_FALSE((bool)Failed);
+/// // make sure Failed.takeError() does not get remove by the optimizer
+/// std::cout << "Expected failure: " << 
llvm::toString(Failed.takeError());
+///   }
+///   @endcode
+
 template  class LLVM_NODISCARD Expected {
   template  friend class ExpectedAsOutParameter;
   template  friend class Expected;


Index: llvm/include/llvm/Support/Error.h
===
--- llvm/include/llvm/Support/Error.h
+++ llvm/include/llvm/Support/Error.h
@@ -436,6 +436,49 @@
 /// Error cannot be copied, this class replaces getError() with
 /// takeError(). It also adds an bool errorIsA() method for testing the
 /// error class type.
+///
+/// Example usage of 'Expected' as a return type:
+///
+///   @code{.cpp}
+/// Expected myDivide(int A, int B) {
+///   if (B == 0) {
+/// // return an Error
+/// return error("B must not be zero!");
+///   }
+///   // return an integer
+///   return A / B;
+/// }
+///   @endcode
+///
+///   Checking the results of to a function returning 'Expected':
+///   @code{.cpp}
+/// auto Result = myDivide(X,Y);
+/// if (!Result) {
+///   auto Error = Result.takeError();
+///   // handle the error case here
+/// } else {
+///   // handle good case here
+/// }
+///
+///   @endcode
+///
+///  Unit-testing a function returning an 'Expceted':
+///   @code{.cpp}
+///   TEST(MyTests, ExpectedDemo) {
+/// auto Passed = myDivide(10, 5);
+/// // check this call has passed, this also prints the error message
+/// // if the function returns an Error
+/// ASSERT_TRUE((bool)Passed) << llvm::toString(Passed.takeError());
+/// // checked the returned value
+/// ASSERT_EQ(2, *Passed);
+///
+/// auto Failed = myDivide(1, 0);
+/// ASSERT_FALSE((bool)Failed);
+/// // make sure Failed.takeError() does not get remove by the optimizer
+/// std::cout << "Expected failure: " << llvm::toString(Failed.takeError());
+///   }
+///   @endcode
+
 template  class LLVM_NODISCARD Expected {
   template  friend class ExpectedAsOutParameter;
   template  friend class Expected;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D20689: [clang-tidy] Add 'readability-suspicious-call-argument' check

2021-06-28 Thread Whisperity via Phabricator via cfe-commits
whisperity updated this revision to Diff 354856.
whisperity marked 2 inline comments as done.
whisperity added a comment.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

- Fix comments and code according to comments
- Turned `Substring` into a case-insensitive heuristic.
- Added some missing tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D20689

Files:
  clang-tools-extra/clang-tidy/readability/CMakeLists.txt
  clang-tools-extra/clang-tidy/readability/ReadabilityTidyModule.cpp
  clang-tools-extra/clang-tidy/readability/SuspiciousCallArgumentCheck.cpp
  clang-tools-extra/clang-tidy/readability/SuspiciousCallArgumentCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/docs/clang-tidy/checks/readability-suspicious-call-argument.rst
  
clang-tools-extra/test/clang-tidy/checkers/readability-suspicious-call-argument.cpp
  llvm/utils/gn/secondary/clang-tools-extra/clang-tidy/readability/BUILD.gn

Index: llvm/utils/gn/secondary/clang-tools-extra/clang-tidy/readability/BUILD.gn
===
--- llvm/utils/gn/secondary/clang-tools-extra/clang-tidy/readability/BUILD.gn
+++ llvm/utils/gn/secondary/clang-tools-extra/clang-tidy/readability/BUILD.gn
@@ -48,6 +48,7 @@
 "StaticAccessedThroughInstanceCheck.cpp",
 "StaticDefinitionInAnonymousNamespaceCheck.cpp",
 "StringCompareCheck.cpp",
+"SuspiciousCallArgumentCheck.cpp",
 "UniqueptrDeleteReleaseCheck.cpp",
 "UppercaseLiteralSuffixCheck.cpp",
 "UseAnyOfAllOfCheck.cpp",
Index: clang-tools-extra/test/clang-tidy/checkers/readability-suspicious-call-argument.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/readability-suspicious-call-argument.cpp
@@ -0,0 +1,487 @@
+// RUN: %check_clang_tidy %s readability-suspicious-call-argument %t -- -- -std=c++11
+
+void foo_1(int aa, int bb) {}
+
+void foo_2(int source, int aa) {}
+
+void foo_3(int valToRet, int aa) {}
+
+void foo_4(int pointer, int aa) {}
+
+void foo_5(int aa, int bb, int cc, ...) {}
+
+void foo_6(const int dd, bool &ee) {}
+
+void foo_7(int aa, int bb, int cc, int ff = 7) {}
+
+void foo_8(int frobble1, int frobble2) {}
+
+// Test functions for convertible argument--parameter types.
+void fun(const int &m);
+void fun2() {
+  int m = 3;
+  fun(m);
+}
+
+// Test cases for parameters of const reference and value.
+void value_const_reference(int ll, const int &kk);
+
+void const_ref_value_swapped() {
+  const int &kk = 42;
+  const int &ll = 42;
+  value_const_reference(kk, ll);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 1st argument 'kk' (passed to 'll') looks like it might be swapped with the 2nd, 'll' (passed to 'kk') [readability-suspicious-call-argument]
+  // CHECK-MESSAGES: :[[@LINE-7]]:6: note: in the call to 'value_const_reference', declared here
+}
+
+// Const, non const references.
+void const_nonconst_parameters(const int &mm, int &nn);
+
+void const_nonconst_swap1() {
+  const int &nn = 42;
+  int mm;
+  // Do not check, because non-const reference parameter cannot bind to const reference argument.
+  const_nonconst_parameters(nn, mm);
+}
+
+void const_nonconst_swap3() {
+  const int nn = 42;
+  int m = 42;
+  int &mm = m;
+  // Do not check, const int does not bind to non const reference.
+  const_nonconst_parameters(nn, mm);
+}
+
+void const_nonconst_swap2() {
+  int nn;
+  int mm;
+  // Check for swapped arguments. (Both arguments are non-const.)
+  const_nonconst_parameters(nn, mm);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 1st argument 'nn' (passed to 'mm') looks like it might be swapped with the 2nd, 'mm' (passed to 'nn')
+}
+
+void const_nonconst_pointers(const int *mm, int *nn);
+void const_nonconst_pointers2(const int *mm, const int *nn);
+
+void const_nonconst_pointers_swapped() {
+  int *mm;
+  const int *nn;
+  const_nonconst_pointers(nn, mm);
+}
+
+void const_nonconst_pointers_swapped2() {
+  const int *mm;
+  int *nn;
+  const_nonconst_pointers2(nn, mm);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 1st argument 'nn' (passed to 'mm') looks like it might be swapped with the 2nd, 'mm' (passed to 'nn')
+}
+
+// Test cases for pointers and arrays.
+void pointer_array_parameters(
+int *pp, int qq[4]);
+
+void pointer_array_swap() {
+  int qq[5];
+  int *pp;
+  // Check for swapped arguments. An array implicitly converts to a pointer.
+  pointer_array_parameters(qq, pp);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 1st argument 'qq' (passed to 'pp') looks like it might be swapped with

[PATCH] D103136: [AVR] Add support for the tinyAVR 0-series and tinyAVR 1-seriesø

2021-06-28 Thread Dylan McKay via Phabricator via cfe-commits
dylanmckay accepted this revision.
dylanmckay added a comment.
This revision is now accepted and ready to land.

Nope, thank you!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103136

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


[PATCH] D104852: [AArch64][SVEIntrinsicOpts] Convect cntb/h/w/d to vscale intrinsic or constant.

2021-06-28 Thread JunMa via Phabricator via cfe-commits
junparser updated this revision to Diff 354857.
junparser added a comment.

address comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104852

Files:
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cntb.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cntd.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cnth.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cntw.c
  llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp
  llvm/test/Transforms/InstCombine/AArch64/sve-intrinsic-opts-counting-elems.ll

Index: llvm/test/Transforms/InstCombine/AArch64/sve-intrinsic-opts-counting-elems.ll
===
--- /dev/null
+++ llvm/test/Transforms/InstCombine/AArch64/sve-intrinsic-opts-counting-elems.ll
@@ -0,0 +1,247 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt -S -instcombine < %s | FileCheck %s
+
+target triple = "aarch64-unknown-linux-gnu"
+
+;
+; CNTB
+;
+
+define i64 @cntb_vl1() {
+; CHECK-LABEL: @cntb_vl1(
+; CHECK-NEXT:ret i64 1
+;
+  %out = call i64 @llvm.aarch64.sve.cntb(i32 1)
+  ret i64 %out
+}
+
+define i64 @cntb_vl2() {
+; CHECK-LABEL: @cntb_vl2(
+; CHECK-NEXT:ret i64 2
+;
+  %out = call i64 @llvm.aarch64.sve.cntb(i32 2)
+  ret i64 %out
+}
+
+define i64 @cntb_vl4() {
+; CHECK-LABEL: @cntb_vl4(
+; CHECK-NEXT:ret i64 4
+;
+  %out = call i64 @llvm.aarch64.sve.cntb(i32 4)
+  ret i64 %out
+}
+
+define i64 @cntb_mul3() {
+; CHECK-LABEL: @cntb_mul3(
+; CHECK-NEXT:ret i64 24
+;
+  %cnt = call i64 @llvm.aarch64.sve.cntb(i32 8)
+  %out = mul i64 %cnt, 3
+  ret i64 %out
+}
+
+define i64 @cntb_mul4() {
+; CHECK-LABEL: @cntb_mul4(
+; CHECK-NEXT:ret i64 64
+;
+  %cnt = call i64 @llvm.aarch64.sve.cntb(i32 9)
+  %out = mul i64 %cnt, 4
+  ret i64 %out
+}
+
+define i64 @cntb_all() {
+; CHECK-LABEL: @cntb_all(
+; CHECK-NEXT:[[TMP1:%.*]] = call i64 @llvm.vscale.i64()
+; CHECK-NEXT:[[OUT:%.*]] = shl i64 [[TMP1]], 4
+; CHECK-NEXT:ret i64 [[OUT]]
+;
+  %out = call i64 @llvm.aarch64.sve.cntb(i32 31)
+  ret i64 %out
+}
+
+;
+; CNTH
+;
+
+define i64 @cnth_vl1() {
+; CHECK-LABEL: @cnth_vl1(
+; CHECK-NEXT:ret i64 1
+;
+  %out = call i64 @llvm.aarch64.sve.cnth(i32 1)
+  ret i64 %out
+}
+
+define i64 @cnth_vl2() {
+; CHECK-LABEL: @cnth_vl2(
+; CHECK-NEXT:ret i64 2
+;
+  %out = call i64 @llvm.aarch64.sve.cnth(i32 2)
+  ret i64 %out
+}
+
+define i64 @cnth_vl4() {
+; CHECK-LABEL: @cnth_vl4(
+; CHECK-NEXT:ret i64 4
+;
+  %out = call i64 @llvm.aarch64.sve.cnth(i32 4)
+  ret i64 %out
+}
+
+define i64 @cnth_mul3() {
+; CHECK-LABEL: @cnth_mul3(
+; CHECK-NEXT:ret i64 24
+;
+  %cnt = call i64 @llvm.aarch64.sve.cnth(i32 8)
+  %out = mul i64 %cnt, 3
+  ret i64 %out
+}
+
+define i64 @cnth_mul4() {
+; CHECK-LABEL: @cnth_mul4(
+; CHECK-NEXT:[[CNT:%.*]] = call i64 @llvm.aarch64.sve.cnth(i32 9)
+; CHECK-NEXT:[[OUT:%.*]] = shl i64 [[CNT]], 2
+; CHECK-NEXT:ret i64 [[OUT]]
+;
+  %cnt = call i64 @llvm.aarch64.sve.cnth(i32 9)
+  %out = mul i64 %cnt, 4
+  ret i64 %out
+}
+
+define i64 @cnth_all() {
+; CHECK-LABEL: @cnth_all(
+; CHECK-NEXT:[[TMP1:%.*]] = call i64 @llvm.vscale.i64()
+; CHECK-NEXT:[[OUT:%.*]] = shl i64 [[TMP1]], 3
+; CHECK-NEXT:ret i64 [[OUT]]
+;
+  %out = call i64 @llvm.aarch64.sve.cnth(i32 31)
+  ret i64 %out
+}
+
+;
+; CNTW
+;
+
+define i64 @cntw_vl1() {
+; CHECK-LABEL: @cntw_vl1(
+; CHECK-NEXT:ret i64 1
+;
+  %out = call i64 @llvm.aarch64.sve.cntw(i32 1)
+  ret i64 %out
+}
+
+define i64 @cntw_vl2() {
+; CHECK-LABEL: @cntw_vl2(
+; CHECK-NEXT:ret i64 2
+;
+  %out = call i64 @llvm.aarch64.sve.cntw(i32 2)
+  ret i64 %out
+}
+
+define i64 @cntw_vl4() {
+; CHECK-LABEL: @cntw_vl4(
+; CHECK-NEXT:ret i64 4
+;
+  %out = call i64 @llvm.aarch64.sve.cntw(i32 4)
+  ret i64 %out
+}
+
+define i64 @cntw_mul3() {
+; CHECK-LABEL: @cntw_mul3(
+; CHECK-NEXT:[[CNT:%.*]] = call i64 @llvm.aarch64.sve.cntw(i32 8)
+; CHECK-NEXT:[[OUT:%.*]] = mul i64 [[CNT]], 3
+; CHECK-NEXT:ret i64 [[OUT]]
+;
+  %cnt = call i64 @llvm.aarch64.sve.cntw(i32 8)
+  %out = mul i64 %cnt, 3
+  ret i64 %out
+}
+
+define i64 @cntw_mul4() {
+; CHECK-LABEL: @cntw_mul4(
+; CHECK-NEXT:[[CNT:%.*]] = call i64 @llvm.aarch64.sve.cntw(i32 9)
+; CHECK-NEXT:[[OUT:%.*]] = shl i64 [[CNT]], 2
+; CHECK-NEXT:ret i64 [[OUT]]
+;
+  %cnt = call i64 @llvm.aarch64.sve.cntw(i32 9)
+  %out = mul i64 %cnt, 4
+  ret i64 %out
+}
+
+define i64 @cntw_all() {
+; CHECK-LABEL: @cntw_all(
+; CHECK-NEXT:[[TMP1:%.*]] = call i64 @llvm.vscale.i64()
+; CHECK-NEXT:[[OUT:%.*]] = shl i64 [[TMP1]], 2
+; CHECK-NEXT:ret i64 [[OUT]]
+;
+  %out = call i64 @llvm.aarch64.sve.cntw(i32 31)
+  ret i64 %out
+}
+
+
+;
+; CNTD
+;
+
+define i64 @cntd_vl1() {
+; CHECK-LABEL: @cntd_vl1(
+; CHECK-NEXT:ret i64 1
+;
+  %out = call i64 @llvm.aarch64.sve.cntd(i32 1)
+  ret i64 %out
+}
+
+define i64 @cntd_vl2() {
+; CHE

[PATCH] D105017: [analyzer] LValueToRValueBitCasts should evaluate to an r-value

2021-06-28 Thread Balázs Benics via Phabricator via cfe-commits
steakhal created this revision.
steakhal added reviewers: NoQ, vsavchenko, martong, Szelethus, ASDenysPetrov.
Herald added subscribers: manas, dkrupp, donat.nagy, mikhail.ramalho, 
a.sidorin, rnkovacs, szepet, baloghadamsoftware, xazax.hun, whisperity.
steakhal requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Previously `LValueToRValueBitCast`s were modeled in the same way how
a regular `BitCast` was. However, this should not produce an l-value.
Modeling bitcasts accurately is tricky, so it's probably better to
model this expression by binding a fresh conjured value.

The following code should not result in a diagnostic:

__attribute__((always_inline))
static inline constexpr unsigned int_castf32_u32(float __A) {
return __builtin_bit_cast(unsigned int, __A); // no-warning
}

Previously, it reported
`Address of stack memory associated with local variable '__A' returned to 
caller [core.StackAddressEscape]`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D105017

Files:
  clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp
  clang/test/Analysis/builtin_bitcast.cpp


Index: clang/test/Analysis/builtin_bitcast.cpp
===
--- /dev/null
+++ clang/test/Analysis/builtin_bitcast.cpp
@@ -0,0 +1,17 @@
+// RUN: %clang_analyze_cc1 -verify %s \
+// RUN:   -analyzer-checker=core,debug.ExprInspection
+
+template  void clang_analyzer_dump(T);
+
+__attribute__((always_inline)) static inline constexpr unsigned int 
_castf32_u32(float __A) {
+  return __builtin_bit_cast(unsigned int, __A); // no-warning
+}
+
+void test() {
+  _castf32_u32(42);
+
+  float f = 42;
+  unsigned int g = __builtin_bit_cast(unsigned int, f);
+  clang_analyzer_dump(g);
+  // expected-warning-re@-1^conj_\$[0-9]+{unsigned int, LC[0-9]+, S[0-9]+, 
#[0-9]+}
+}
Index: clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp
===
--- clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp
+++ clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp
@@ -380,7 +380,6 @@
   case CK_Dependent:
   case CK_ArrayToPointerDecay:
   case CK_BitCast:
-  case CK_LValueToRValueBitCast:
   case CK_AddressSpaceConversion:
   case CK_BooleanToSignedIntegral:
   case CK_IntegralToPointer:
@@ -538,6 +537,7 @@
 continue;
   }
   // Various C++ casts that are not handled yet.
+  case CK_LValueToRValueBitCast:
   case CK_ToUnion:
   case CK_VectorSplat: {
 state = handleLVectorSplat(state, LCtx, CastE, Bldr, Pred);


Index: clang/test/Analysis/builtin_bitcast.cpp
===
--- /dev/null
+++ clang/test/Analysis/builtin_bitcast.cpp
@@ -0,0 +1,17 @@
+// RUN: %clang_analyze_cc1 -verify %s \
+// RUN:   -analyzer-checker=core,debug.ExprInspection
+
+template  void clang_analyzer_dump(T);
+
+__attribute__((always_inline)) static inline constexpr unsigned int _castf32_u32(float __A) {
+  return __builtin_bit_cast(unsigned int, __A); // no-warning
+}
+
+void test() {
+  _castf32_u32(42);
+
+  float f = 42;
+  unsigned int g = __builtin_bit_cast(unsigned int, f);
+  clang_analyzer_dump(g);
+  // expected-warning-re@-1^conj_\$[0-9]+{unsigned int, LC[0-9]+, S[0-9]+, #[0-9]+}
+}
Index: clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp
===
--- clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp
+++ clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp
@@ -380,7 +380,6 @@
   case CK_Dependent:
   case CK_ArrayToPointerDecay:
   case CK_BitCast:
-  case CK_LValueToRValueBitCast:
   case CK_AddressSpaceConversion:
   case CK_BooleanToSignedIntegral:
   case CK_IntegralToPointer:
@@ -538,6 +537,7 @@
 continue;
   }
   // Various C++ casts that are not handled yet.
+  case CK_LValueToRValueBitCast:
   case CK_ToUnion:
   case CK_VectorSplat: {
 state = handleLVectorSplat(state, LCtx, CastE, Bldr, Pred);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D104044: [clang-format] Fix the issue that empty lines being removed at the beginning of namespace

2021-06-28 Thread Darwin Xu via Phabricator via cfe-commits
darwin marked an inline comment as done.
darwin added inline comments.



Comment at: clang/lib/Format/UnwrappedLineFormatter.cpp:1270
   !startsExternCBlock(*PreviousLine))
 Newlines = 1;
 

MyDeveloperDay wrote:
> Nit:I do think at some point we need to have some sort of option for 
> controlling these empty lines, 
> 
> 
> EmptyLine:
>  AfterNamespace: 1
>  BeforeAccessModifier: 1
>  AfterAccessModifier: 1
>  BetweenFunctions: 1
>  ...
> 
Yes, maybe we can open a bug for it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104044

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


[PATCH] D20689: [clang-tidy] Add 'readability-suspicious-call-argument' check

2021-06-28 Thread Whisperity via Phabricator via cfe-commits
whisperity updated this revision to Diff 354867.
whisperity added a comment.

**NFC** Fix `ReleaseNotes` entry getting out of place during rebases earlier.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D20689

Files:
  clang-tools-extra/clang-tidy/readability/CMakeLists.txt
  clang-tools-extra/clang-tidy/readability/ReadabilityTidyModule.cpp
  clang-tools-extra/clang-tidy/readability/SuspiciousCallArgumentCheck.cpp
  clang-tools-extra/clang-tidy/readability/SuspiciousCallArgumentCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/docs/clang-tidy/checks/readability-suspicious-call-argument.rst
  
clang-tools-extra/test/clang-tidy/checkers/readability-suspicious-call-argument.cpp
  llvm/utils/gn/secondary/clang-tools-extra/clang-tidy/readability/BUILD.gn

Index: llvm/utils/gn/secondary/clang-tools-extra/clang-tidy/readability/BUILD.gn
===
--- llvm/utils/gn/secondary/clang-tools-extra/clang-tidy/readability/BUILD.gn
+++ llvm/utils/gn/secondary/clang-tools-extra/clang-tidy/readability/BUILD.gn
@@ -48,6 +48,7 @@
 "StaticAccessedThroughInstanceCheck.cpp",
 "StaticDefinitionInAnonymousNamespaceCheck.cpp",
 "StringCompareCheck.cpp",
+"SuspiciousCallArgumentCheck.cpp",
 "UniqueptrDeleteReleaseCheck.cpp",
 "UppercaseLiteralSuffixCheck.cpp",
 "UseAnyOfAllOfCheck.cpp",
Index: clang-tools-extra/test/clang-tidy/checkers/readability-suspicious-call-argument.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/readability-suspicious-call-argument.cpp
@@ -0,0 +1,487 @@
+// RUN: %check_clang_tidy %s readability-suspicious-call-argument %t -- -- -std=c++11
+
+void foo_1(int aa, int bb) {}
+
+void foo_2(int source, int aa) {}
+
+void foo_3(int valToRet, int aa) {}
+
+void foo_4(int pointer, int aa) {}
+
+void foo_5(int aa, int bb, int cc, ...) {}
+
+void foo_6(const int dd, bool &ee) {}
+
+void foo_7(int aa, int bb, int cc, int ff = 7) {}
+
+void foo_8(int frobble1, int frobble2) {}
+
+// Test functions for convertible argument--parameter types.
+void fun(const int &m);
+void fun2() {
+  int m = 3;
+  fun(m);
+}
+
+// Test cases for parameters of const reference and value.
+void value_const_reference(int ll, const int &kk);
+
+void const_ref_value_swapped() {
+  const int &kk = 42;
+  const int &ll = 42;
+  value_const_reference(kk, ll);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 1st argument 'kk' (passed to 'll') looks like it might be swapped with the 2nd, 'll' (passed to 'kk') [readability-suspicious-call-argument]
+  // CHECK-MESSAGES: :[[@LINE-7]]:6: note: in the call to 'value_const_reference', declared here
+}
+
+// Const, non const references.
+void const_nonconst_parameters(const int &mm, int &nn);
+
+void const_nonconst_swap1() {
+  const int &nn = 42;
+  int mm;
+  // Do not check, because non-const reference parameter cannot bind to const reference argument.
+  const_nonconst_parameters(nn, mm);
+}
+
+void const_nonconst_swap3() {
+  const int nn = 42;
+  int m = 42;
+  int &mm = m;
+  // Do not check, const int does not bind to non const reference.
+  const_nonconst_parameters(nn, mm);
+}
+
+void const_nonconst_swap2() {
+  int nn;
+  int mm;
+  // Check for swapped arguments. (Both arguments are non-const.)
+  const_nonconst_parameters(nn, mm);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 1st argument 'nn' (passed to 'mm') looks like it might be swapped with the 2nd, 'mm' (passed to 'nn')
+}
+
+void const_nonconst_pointers(const int *mm, int *nn);
+void const_nonconst_pointers2(const int *mm, const int *nn);
+
+void const_nonconst_pointers_swapped() {
+  int *mm;
+  const int *nn;
+  const_nonconst_pointers(nn, mm);
+}
+
+void const_nonconst_pointers_swapped2() {
+  const int *mm;
+  int *nn;
+  const_nonconst_pointers2(nn, mm);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 1st argument 'nn' (passed to 'mm') looks like it might be swapped with the 2nd, 'mm' (passed to 'nn')
+}
+
+// Test cases for pointers and arrays.
+void pointer_array_parameters(
+int *pp, int qq[4]);
+
+void pointer_array_swap() {
+  int qq[5];
+  int *pp;
+  // Check for swapped arguments. An array implicitly converts to a pointer.
+  pointer_array_parameters(qq, pp);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 1st argument 'qq' (passed to 'pp') looks like it might be swapped with the 2nd, 'pp' (passed to 'qq')
+}
+
+// Test cases for multilevel pointers.
+void multilevel_pointer_parameters(int *const **pp,
+ 

[clang] 22aa368 - [C++20] Support for lambdas in unevaluated context

2021-06-28 Thread Aaron Ballman via cfe-commits

Author: Corentin Jabot
Date: 2021-06-28T09:01:56-04:00
New Revision: 22aa3680eaccb9b77ca224711c4da3a354aa2d45

URL: 
https://github.com/llvm/llvm-project/commit/22aa3680eaccb9b77ca224711c4da3a354aa2d45
DIFF: 
https://github.com/llvm/llvm-project/commit/22aa3680eaccb9b77ca224711c4da3a354aa2d45.diff

LOG: [C++20] Support for lambdas in unevaluated context

Partially implement P0315R4.

This patch allow lambda in unevaluated context.
It does not implement temp.deduct/9.

Added: 
clang/test/SemaCXX/lambda-unevaluated.cpp

Modified: 
clang/lib/Sema/SemaConcept.cpp
clang/lib/Sema/SemaExpr.cpp
clang/test/SemaCXX/anonymous-struct.cpp
clang/www/cxx_status.html

Removed: 




diff  --git a/clang/lib/Sema/SemaConcept.cpp b/clang/lib/Sema/SemaConcept.cpp
index 552534824588e..f2c70d0a56efb 100644
--- a/clang/lib/Sema/SemaConcept.cpp
+++ b/clang/lib/Sema/SemaConcept.cpp
@@ -43,9 +43,12 @@ class LogicalBinOp {
   LHS = BO->getLHS();
   RHS = BO->getRHS();
 } else if (auto *OO = dyn_cast(E)) {
-  Op = OO->getOperator();
-  LHS = OO->getArg(0);
-  RHS = OO->getArg(1);
+  // If OO is not || or && it might not have exactly 2 arguments.
+  if (OO->getNumArgs() == 2) {
+Op = OO->getOperator();
+LHS = OO->getArg(0);
+RHS = OO->getArg(1);
+  }
 }
   }
 

diff  --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 2d0f314f380fe..728d7b61d4a86 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -16722,8 +16722,10 @@ void Sema::PopExpressionEvaluationContext() {
 
   if (!Rec.Lambdas.empty()) {
 using ExpressionKind = ExpressionEvaluationContextRecord::ExpressionKind;
-if (Rec.ExprContext == ExpressionKind::EK_TemplateArgument || 
Rec.isUnevaluated() ||
-(Rec.isConstantEvaluated() && !getLangOpts().CPlusPlus17)) {
+if (!getLangOpts().CPlusPlus20 &&
+(Rec.ExprContext == ExpressionKind::EK_TemplateArgument ||
+ Rec.isUnevaluated() ||
+ (Rec.isConstantEvaluated() && !getLangOpts().CPlusPlus17))) {
   unsigned D;
   if (Rec.isUnevaluated()) {
 // C++11 [expr.prim.lambda]p2:

diff  --git a/clang/test/SemaCXX/anonymous-struct.cpp 
b/clang/test/SemaCXX/anonymous-struct.cpp
index 1b6207d19e44d..0a5395e15780b 100644
--- a/clang/test/SemaCXX/anonymous-struct.cpp
+++ b/clang/test/SemaCXX/anonymous-struct.cpp
@@ -49,7 +49,7 @@ typedef struct // expected-warning {{anonymous 
non-C-compatible type given name
 : B { // expected-note {{type is not C-compatible due to this base class}}
 } C; // expected-note {{type is given name 'C' for linkage purposes by this 
typedef declaration}}
 
-#if __cplusplus > 201703L
+#if __cplusplus > 201703L && __cplusplus < 202002L
 typedef struct { // expected-warning {{anonymous non-C-compatible type given 
name for linkage purposes by typedef declaration; add a tag name here}}
   static_assert([]{ return true; }()); // expected-note {{type is not 
C-compatible due to this lambda expression}}
 } Lambda1; // expected-note {{type is given name 'Lambda1' for linkage 
purposes by this typedef declaration}}

diff  --git a/clang/test/SemaCXX/lambda-unevaluated.cpp 
b/clang/test/SemaCXX/lambda-unevaluated.cpp
new file mode 100644
index 0..07fa0d94bc8e4
--- /dev/null
+++ b/clang/test/SemaCXX/lambda-unevaluated.cpp
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 -std=c++20 %s -verify
+
+
+template  struct Nothing {};
+Nothing<[]() { return 0; }()> nothing;
+
+template  struct NothingT {};
+Nothing<[]() { return 0; }> nothingT;
+
+template 
+concept True = [] { return true; }();
+static_assert(True);
+
+static_assert(sizeof([] { return 0; }));
+static_assert(sizeof([] { return 0; }()));
+
+void f()  noexcept(noexcept([] { return 0; }()));
+
+using a = decltype([] { return 0; });
+using b = decltype([] { return 0; }());
+using c = decltype([]() noexcept(noexcept([] { return 0; }())) { return 0; });
+using d = decltype(sizeof([] { return 0; }));
+
+template 
+int unique_test1();
+static_assert(&unique_test1<[](){}> != &unique_test1<[](){}>);
+
+template 
+auto g(T) -> decltype([]() { T::invalid; } ());
+auto e = g(0); // expected-error{{no matching function for call}}
+// expected-note@-2 {{substitution failure}}

diff  --git a/clang/www/cxx_status.html b/clang/www/cxx_status.html
index a478a4487d150..b7f2501cbc534 100755
--- a/clang/www/cxx_status.html
+++ b/clang/www/cxx_status.html
@@ -1011,7 +1011,7 @@ C++20 implementation status
 
   Lambdas in unevaluated contexts
   https://wg21.link/p0315r4";>P0315R4
-  No
+  Clang 13
 
 
 



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


[PATCH] D103380: [C++20] Support for lambdas in unevaluated context

2021-06-28 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman closed this revision.
aaron.ballman added a comment.

Thank you for the patch! I've committed in 
22aa3680eaccb9b77ca224711c4da3a354aa2d45 
.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103380

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


[PATCH] D105014: added some example code for llvm::Expected

2021-06-28 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

Yes, please revert the unrelated formatting changes.

I agree Error is confusing and better docs might help.
(Not as much as removing the confusing part of the design, but I that seems 
hard at this point!)

However I don't think the "hump" you experienced can be avoided purely by 
"recipe-style" documentation, because you can quickly get into a situation 
where you have to understand Error's checking model to write proper handling 
code.
By making the examples a bit more complete and adding a little more explanation 
we can flatten it though!




Comment at: llvm/include/llvm/Support/Error.h:443
+/// // return an Error
+/// return error("B must not be zero!");
+///   }

 the error() function is a clangd-ism (and was even controversial there!)

The "plain" equivalent is, sadly, `return 
createStringError(inconvertibleErrorCode(), "B must not be zero!");`




Comment at: llvm/include/llvm/Support/Error.h:454
+/// if (!Result) {
+///   auto Error = Result.takeError();
+///   // handle the error case here

nit: we shouldn't call a variable Error if the type Error is in scope, it's 
asking for trouble (and occasionally invalid code that some compilers reject 
and others accept...)



Comment at: llvm/include/llvm/Support/Error.h:455
+///   auto Error = Result.takeError();
+///   // handle the error case here
+/// } else {

IMO the hard part here is that *the error must be consumed*/checked.

takeError doesn't actually do this, after `Err = Result.takeError()`, `Result` 
is empty with Checked=true, but `Err` is populated and has Checked=false.

Confusingly, most of the things you can actually *do* with an Error (including 
toString()) will check/consume it. But not all, and in particular if you do 
nothing with it then `~Error()` will crash.

---

Assigning the Error to a separate variable is fairly rare and runs into more of 
these complications, usually you rather either log or propagate it, in either 
case using the rvalue directly.

I'd probably replace it with this code + comment:
```
// We must consume the error. Typically one of:
// - return the error to our caller
// - toString(), when logging
// - consumeError(), to silently swallow the error
// - handleErrors(), to distinguish error types
errs() << "Problem with division " << toString(Result.takeError()) << "\n";
```



Comment at: llvm/include/llvm/Support/Error.h:456
+///   // handle the error case here
+/// } else {
+///   // handle good case here

generally the "then" block would either propagate the error or otherwise 
return, so you probably don't want else here.



Comment at: llvm/include/llvm/Support/Error.h:457
+/// } else {
+///   // handle good case here
+/// }

you haven't illustrated how to get the result.

Maybe
```
outs() << "The answer is " << *Result << "\n";
```



Comment at: llvm/include/llvm/Support/Error.h:462
+///
+///  Unit-testing a function returning an 'Expceted':
+///   @code{.cpp}

This seems too intrusive/unusual to put inline to me.
And the main thing that is non-obvious is *why* you have to structure your 
assertions in an unusual way, and that's not explained here.

Consider instead just briefly referencing the EXPECT_THAT_EXPECTED etc macros 
in llvm/Testing/Support/Error.h which are designed to simplify this a bit.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105014

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


[PATCH] D105024: Add papers adopted by the C++ committee in the June 2021 plenary.

2021-06-28 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin created this revision.
cor3ntin requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D105024

Files:
  clang/www/cxx_status.html


Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -1283,6 +1283,41 @@
   https://wg21.link/p2266r1";>P2266R1
   Clang 13
 
+
+  if consteval
+  https://wg21.link/P1938R3";>P1938R3
+  NO
+
+
+  Allow duplicate attributes
+  https://wg21.link/P2156R1";>P2156R1
+  Yes
+
+
+  Narrowing contextual conversions to bool
+  https://wg21.link/P1401R5";>P1401R5
+  NO
+
+
+  Trimming whitespaces before line splicing
+  https://wg21.link/P2223R2";>P2223R2
+  Yes
+
+
+  Make declaration order layout mandated
+  https://wg21.link/p1847r4";>P1874R4
+  Yes
+
+
+  C++ identifier syntax using UAX 31
+  https://wg21.link/P1949R7";>P1949R7
+  NO
+
+
+  Mixed string literal concatenation
+  https://wg21.link/p2201r1";>P2201R1
+  NO
+
 
 
 


Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -1283,6 +1283,41 @@
   https://wg21.link/p2266r1";>P2266R1
   Clang 13
 
+
+  if consteval
+  https://wg21.link/P1938R3";>P1938R3
+  NO
+
+
+  Allow duplicate attributes
+  https://wg21.link/P2156R1";>P2156R1
+  Yes
+
+
+  Narrowing contextual conversions to bool
+  https://wg21.link/P1401R5";>P1401R5
+  NO
+
+
+  Trimming whitespaces before line splicing
+  https://wg21.link/P2223R2";>P2223R2
+  Yes
+
+
+  Make declaration order layout mandated
+  https://wg21.link/p1847r4";>P1874R4
+  Yes
+
+
+  C++ identifier syntax using UAX 31
+  https://wg21.link/P1949R7";>P1949R7
+  NO
+
+
+  Mixed string literal concatenation
+  https://wg21.link/p2201r1";>P2201R1
+  NO
+
 
 
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D104777: PR50767: clear non-distinct debuginfo for function with nodebug definition after undecorated declaration

2021-06-28 Thread Bruno De Fraine via Phabricator via cfe-commits
brunodefraine added a comment.

Following suggestion by @dblaikie and @aaron.ballman I'm preparing a new diff 
where a function redeclaration that adds `nodebug` is flagged as an error in 
`Sema::mergeDeclAttributes`.

This triggers test failures because of violations in builtin header files, for 
example:

  In file included from clang/test/CodeGen/ms-intrinsics.c:18:
  build/lib/clang/13.0.0/include/intrin.h:451:24: error: function declared with 
'nodebug' attribute was previously declared without the 'nodebug' attribute
  static __inline__ void __DEFAULT_FN_ATTRS __movsb(unsigned char *__dst,
 ^
  build/lib/clang/13.0.0/include/intrin.h:37:62: note: expanded from macro 
'__DEFAULT_FN_ATTRS'
  #define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__))
   ^
  build/lib/clang/13.0.0/include/intrin.h:80:6: note: previous declaration is 
here
  void __movsb(unsigned char *, unsigned char const *, size_t);
   ^

From what I understand from `clang/lib/Headers/intrin.h` the functions are 
declared in general at the beginning of the headers, then implemented for 
specific architectures as inline function containing assembly. I do not know if 
it is appropriate to mark the general declarations as `nodebug`...

That I already encounter this in builtin headers is probably an indication that 
the new error will break some code in the wild. A pragmatic solution would be 
to only raise the error in `Sema::mergeDeclAttributes` if `Old->isUsed()`, i.e. 
an earlier declaration without `nodebug` can be forgiven if not yet used. I 
think that would still make it impossible to trigger the crash?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104777

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


[clang] fe0e861 - [Analyzer] Attempt to fix windows bots test failure b/c of new-line

2021-06-28 Thread Gabor Marton via cfe-commits

Author: Gabor Marton
Date: 2021-06-28T15:41:30+02:00
New Revision: fe0e861a4d9946a3e7de1bc95a3ec12fa602b492

URL: 
https://github.com/llvm/llvm-project/commit/fe0e861a4d9946a3e7de1bc95a3ec12fa602b492
DIFF: 
https://github.com/llvm/llvm-project/commit/fe0e861a4d9946a3e7de1bc95a3ec12fa602b492.diff

LOG: [Analyzer] Attempt to fix windows bots test failure b/c of new-line

Added: 


Modified: 
clang/test/Analysis/expr-inspection-printState-diseq-info.c
clang/test/Analysis/expr-inspection-printState-eq-classes.c

Removed: 




diff  --git a/clang/test/Analysis/expr-inspection-printState-diseq-info.c 
b/clang/test/Analysis/expr-inspection-printState-diseq-info.c
index fe2ee324105f..3f11ed61af5e 100644
--- a/clang/test/Analysis/expr-inspection-printState-diseq-info.c
+++ b/clang/test/Analysis/expr-inspection-printState-diseq-info.c
@@ -1,5 +1,6 @@
 // RUN: %clang_analyze_cc1 \
 // RUN:  -analyzer-checker=debug.ExprInspection %s 2>&1 | FileCheck %s
+// UNSUPPORTED: windows
 
 void clang_analyzer_printState();
 

diff  --git a/clang/test/Analysis/expr-inspection-printState-eq-classes.c 
b/clang/test/Analysis/expr-inspection-printState-eq-classes.c
index 5b40ac5cd47e..7daa8648c249 100644
--- a/clang/test/Analysis/expr-inspection-printState-eq-classes.c
+++ b/clang/test/Analysis/expr-inspection-printState-eq-classes.c
@@ -1,5 +1,6 @@
 // RUN: %clang_analyze_cc1 \
 // RUN:  -analyzer-checker=debug.ExprInspection %s 2>&1 | FileCheck %s
+// UNSUPPORTED: windows
 
 void clang_analyzer_printState();
 



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


[PATCH] D103967: [Analyzer][solver] Add dump methods for (dis)equality classes.

2021-06-28 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.

Thanks for the report @thakis ! This seems to be b/c of the different newline 
handling in windows. I've committed a change that disables the tests on windows.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103967

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


[PATCH] D105024: Add papers adopted by the C++ committee in the June 2021 plenary.

2021-06-28 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin updated this revision to Diff 354882.
cor3ntin added a comment.

Fix status of P2201 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105024

Files:
  clang/www/cxx_status.html


Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -1283,6 +1283,41 @@
   https://wg21.link/p2266r1";>P2266R1
   Clang 13
 
+
+  if consteval
+  https://wg21.link/P1938R3";>P1938R3
+  NO
+
+
+  Allow duplicate attributes
+  https://wg21.link/P2156R1";>P2156R1
+  Yes
+
+
+  Narrowing contextual conversions to bool
+  https://wg21.link/P1401R5";>P1401R5
+  NO
+
+
+  Trimming whitespaces before line splicing
+  https://wg21.link/P2223R2";>P2223R2
+  Yes
+
+
+  Make declaration order layout mandated
+  https://wg21.link/p1847r4";>P1874R4
+  Yes
+
+
+  C++ identifier syntax using UAX 31
+  https://wg21.link/P1949R7";>P1949R7
+  NO
+
+
+  Mixed string literal concatenation
+  https://wg21.link/p2201r1";>P2201R1
+  yes
+
 
 
 


Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -1283,6 +1283,41 @@
   https://wg21.link/p2266r1";>P2266R1
   Clang 13
 
+
+  if consteval
+  https://wg21.link/P1938R3";>P1938R3
+  NO
+
+
+  Allow duplicate attributes
+  https://wg21.link/P2156R1";>P2156R1
+  Yes
+
+
+  Narrowing contextual conversions to bool
+  https://wg21.link/P1401R5";>P1401R5
+  NO
+
+
+  Trimming whitespaces before line splicing
+  https://wg21.link/P2223R2";>P2223R2
+  Yes
+
+
+  Make declaration order layout mandated
+  https://wg21.link/p1847r4";>P1874R4
+  Yes
+
+
+  C++ identifier syntax using UAX 31
+  https://wg21.link/P1949R7";>P1949R7
+  NO
+
+
+  Mixed string literal concatenation
+  https://wg21.link/p2201r1";>P2201R1
+  yes
+
 
 
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D103967: [Analyzer][solver] Add dump methods for (dis)equality classes.

2021-06-28 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

Thanks. Looks like it flakily fails on mac too every now and then: 
http://45.33.8.238/mac/33005/step_7.txt

Maybe you print something in nondeterministic iteration order?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103967

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


[PATCH] D105024: Add papers adopted by the C++ committee in the June 2021 plenary.

2021-06-28 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone added a comment.

Shouldn't the "yes/Yes" entries display Clang major version numbers instead?
Throughout, "NO" should be "No" (compare to lines 1221 and 1226).




Comment at: clang/www/cxx_status.html:1287
+
+  if consteval
+  https://wg21.link/P1938R3";>P1938R3

`if consteval`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105024

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


[PATCH] D105024: Add papers adopted by the C++ committee in the June 2021 plenary.

2021-06-28 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/www/cxx_status.html:1289
+  https://wg21.link/P1938R3";>P1938R3
+  NO
+

Same fix applies elsewhere



Comment at: clang/www/cxx_status.html:1294
+  https://wg21.link/P2156R1";>P2156R1
+  Yes
+

You should find out which version of Clang this support was introduced in and 
list the version explicitly. We typically use "Yes" for "it's always been like 
this".

In this case, this one is Clang 13 and unreleased (rather than "full").



Comment at: clang/www/cxx_status.html:1319
+  https://wg21.link/p2201r1";>P2201R1
+  yes
+




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105024

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


[PATCH] D103967: [Analyzer][solver] Add dump methods for (dis)equality classes.

2021-06-28 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko added a comment.

In D103967#2844140 , @thakis wrote:

> Thanks. Looks like it flakily fails on mac too every now and then: 
> http://45.33.8.238/mac/33005/step_7.txt
>
> Maybe you print something in nondeterministic iteration order?

Yes, I think that the problem is deeper.  `ClassMembers` is 
`llvm::ImmutableSet` (i.e. sorted set), and it uses `SymbolRef` (e.g. pointer 
values) for sorting.  So, it does look like the order can be nondeterministic.
However, when we print constraints, we should see similar problems, but we 
don't 🤔


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103967

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


[PATCH] D105024: Add papers adopted by the C++ committee in the June 2021 plenary.

2021-06-28 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin updated this revision to Diff 354891.
cor3ntin added a comment.

Fix cases


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105024

Files:
  clang/www/cxx_status.html


Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -1283,6 +1283,41 @@
   https://wg21.link/p2266r1";>P2266R1
   Clang 13
 
+
+  if consteval
+  https://wg21.link/P1938R3";>P1938R3
+  No
+
+
+  Allow duplicate attributes
+  https://wg21.link/P2156R1";>P2156R1
+  Yes
+
+
+  Narrowing contextual conversions to bool
+  https://wg21.link/P1401R5";>P1401R5
+  No
+
+
+  Trimming whitespaces before line splicing
+  https://wg21.link/P2223R2";>P2223R2
+  Yes
+
+
+  Make declaration order layout mandated
+  https://wg21.link/p1847r4";>P1874R4
+  Yes
+
+
+  C++ identifier syntax using UAX 31
+  https://wg21.link/P1949R7";>P1949R7
+  No
+
+
+  Mixed string literal concatenation
+  https://wg21.link/p2201r1";>P2201R1
+  Yes
+
 
 
 


Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -1283,6 +1283,41 @@
   https://wg21.link/p2266r1";>P2266R1
   Clang 13
 
+
+  if consteval
+  https://wg21.link/P1938R3";>P1938R3
+  No
+
+
+  Allow duplicate attributes
+  https://wg21.link/P2156R1";>P2156R1
+  Yes
+
+
+  Narrowing contextual conversions to bool
+  https://wg21.link/P1401R5";>P1401R5
+  No
+
+
+  Trimming whitespaces before line splicing
+  https://wg21.link/P2223R2";>P2223R2
+  Yes
+
+
+  Make declaration order layout mandated
+  https://wg21.link/p1847r4";>P1874R4
+  Yes
+
+
+  C++ identifier syntax using UAX 31
+  https://wg21.link/P1949R7";>P1949R7
+  No
+
+
+  Mixed string literal concatenation
+  https://wg21.link/p2201r1";>P2201R1
+  Yes
+
 
 
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D103967: [Analyzer][solver] Add dump methods for (dis)equality classes.

2021-06-28 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

Cool, can we revert this for now then? Flakily failing on my m1 bot too: 
http://45.33.8.238/macm1/12514/step_7.txt


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103967

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


[PATCH] D105024: Add papers adopted by the C++ committee in the June 2021 plenary.

2021-06-28 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin updated this revision to Diff 354892.
cor3ntin added a comment.

Fix status of P2156R1


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105024

Files:
  clang/www/cxx_status.html


Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -1283,6 +1283,41 @@
   https://wg21.link/p2266r1";>P2266R1
   Clang 13
 
+
+  if consteval
+  https://wg21.link/P1938R3";>P1938R3
+  No
+
+
+  Allow duplicate attributes
+  https://wg21.link/P2156R1";>P2156R1
+  Clang 13
+
+
+  Narrowing contextual conversions to bool
+  https://wg21.link/P1401R5";>P1401R5
+  No
+
+
+  Trimming whitespaces before line splicing
+  https://wg21.link/P2223R2";>P2223R2
+  Yes
+
+
+  Make declaration order layout mandated
+  https://wg21.link/p1847r4";>P1874R4
+  Yes
+
+
+  C++ identifier syntax using UAX 31
+  https://wg21.link/P1949R7";>P1949R7
+  No
+
+
+  Mixed string literal concatenation
+  https://wg21.link/p2201r1";>P2201R1
+  Yes
+
 
 
 


Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -1283,6 +1283,41 @@
   https://wg21.link/p2266r1";>P2266R1
   Clang 13
 
+
+  if consteval
+  https://wg21.link/P1938R3";>P1938R3
+  No
+
+
+  Allow duplicate attributes
+  https://wg21.link/P2156R1";>P2156R1
+  Clang 13
+
+
+  Narrowing contextual conversions to bool
+  https://wg21.link/P1401R5";>P1401R5
+  No
+
+
+  Trimming whitespaces before line splicing
+  https://wg21.link/P2223R2";>P2223R2
+  Yes
+
+
+  Make declaration order layout mandated
+  https://wg21.link/p1847r4";>P1874R4
+  Yes
+
+
+  C++ identifier syntax using UAX 31
+  https://wg21.link/P1949R7";>P1949R7
+  No
+
+
+  Mixed string literal concatenation
+  https://wg21.link/p2201r1";>P2201R1
+  Yes
+
 
 
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D90238: [clang-format] Added ReferenceAlignmentStyle option - (Update to D31635)

2021-06-28 Thread Andrew Somerville via Phabricator via cfe-commits
catskul abandoned this revision.
catskul added a comment.

Abandoning because of: https://reviews.llvm.org/D104096


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90238

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


[PATCH] D105024: Add papers adopted by the C++ committee in the June 2021 plenary.

2021-06-28 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added inline comments.



Comment at: clang/www/cxx_status.html:1294
+  https://wg21.link/P2156R1";>P2156R1
+  Yes
+

aaron.ballman wrote:
> You should find out which version of Clang this support was introduced in and 
> list the version explicitly. We typically use "Yes" for "it's always been 
> like this".
> 
> In this case, this one is Clang 13 and unreleased (rather than "full").
Right, I did check for the wrong thing


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105024

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


[PATCH] D104904: [OpenMP][AMDGCN] Initial math headers support

2021-06-28 Thread Aaron Enye Shi via Phabricator via cfe-commits
ashi1 added a comment.

A few small comments, otherwise LGTM on the HIP header side.




Comment at: clang/lib/Headers/__clang_hip_cmath.h:30
+#ifdef __OPENMP_AMDGCN__
+#define __DEVICE__ static __attribute__((always_inline, nothrow))
+#define __CONSTEXPR__ constexpr

Does OpenMP not require `__device__` attribute here? I know constexpr defines 
`__device__` on HIP, does OMP do the same?



Comment at: clang/lib/Headers/__clang_hip_cmath.h:32
+#define __CONSTEXPR__ constexpr
+#define __constant__ __attribute__((constant))
+#else

I don't think this is the right place to define `__constant__`? It's unused in 
this header, and may get forgotten. Would it be better to define it in the 
openmp wrapper or does cmath define it in OpenMP?



Comment at: 
clang/lib/Headers/openmp_wrappers/__clang_openmp_device_functions.h:47
+#define __OPENMP_AMDGCN__
+#define __device__
+/// Include declarations for libdevice functions.

Would it be better to push and pop these macros, in case it was defined outside 
of here?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104904

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


[PATCH] D105024: Add papers adopted by the C++ committee in the June 2021 plenary.

2021-06-28 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105024

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


[PATCH] D99005: [clang] Implement P2266 Simpler implicit move

2021-06-28 Thread Zahira Ammarguellat via Phabricator via cfe-commits
zahiraam added a comment.

This change has made this snippet fail.
https://godbolt.org/z/3ehK784hY Pass
https://godbolt.org/z/9q48WvsP7 fails.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99005

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


[PATCH] D98710: [clang-tidy] Add --skip-headers, part 1 (use setTraversalScope)

2021-06-28 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clang/include/clang/ASTMatchers/ASTMatchFinder.h:148
+/// Check if a Decl should be skipped.
+std::shared_ptr Filter;
   };

chh wrote:
> sammccall wrote:
> > hokein wrote:
> > > chh wrote:
> > > > sammccall wrote:
> > > > > I don't think the filter belongs here.
> > > > > The design of traversal scope is that it's a property of the AST that 
> > > > > affects all traversals, so it shouldn't be a configuration property 
> > > > > of particular traversals like ASTMatchFinder.
> > > > > 
> > > > > There's a question of what to do about 
> > > > > `MatchFinder::newASTConsumer()`, which runs the finder immediately 
> > > > > after an AST is created, and so covers the point at which we might 
> > > > > set a scope. There are several good options, e.g.:
> > > > >  - Don't provide any facility for setting traversal scope when 
> > > > > newASTConsumer() is used - it's not commonly needed, and the 
> > > > > ASTConsumer is trivial to reimplement where that's actually needed
> > > > >  - Accept an optional `function` which should run 
> > > > > just before matching starts
> > > > > 
> > > > > This seems a bit subtle, but the difference between having this in 
> > > > > MatchFinder proper vs just in newASTConsumer() is important I think, 
> > > > > precisely because it's common to run the matchers directly on an 
> > > > > existing AST.
> > > > > 
> > > > I have some similar concerns too.
> > > > 
> > > > clangd calls MatchFinder::matchAST explicitly after setTraversalScope,
> > > > but clang-tidy uses MultiplexConsumer and MatchFinder::newASTConsumer
> > > > is just one of the two consumers.
> > > > (1) I am not sure if it would be safe or even work to make big changes 
> > > > in
> > > > ClangTidy.cpp's CreateASTConsumer to call MatchFinder::matchAST 
> > > > explicitly.
> > > > (2) Similarly, I wonder if setTraversalScope will work for both 
> > > > MatchFinder
> > > > and other consumers in the same MultiplexConsumer.
> > > > 
> > > > Could you check if my current change to 
> > > > MatchFinder::HandleTranslationUnit
> > > > is right, especially in the saving/restoring of traversal scope?
> > > > 
> > > > I am assuming that each consumer in a MultiplexConsumer will have its 
> > > > own
> > > > chance to HandleTranslationUnit and HandleTopLevelDecl.
> > > > If that's correct, it seems to me that changing those two handlers in
> > > > MatchFinder is right for clang-tidy. Then they will need the optional
> > > > MatchFinder::MatchFinderOptions::DeclFilter.
> > > > 
> > > > 
> > > > but clang-tidy uses MultiplexConsumer and MatchFinder::newASTConsumer 
> > > > is just one of the two consumers.
> > > 
> > > Yeah, `MultiplexConsumer` is a separate interface in clang, and I don't 
> > > think we have a strong reason to modify it. 
> > > 
> > > However, we could refine the bit in clang-tidy -- clang-tidy uses 
> > > `MultiplexConsumer` to dispatch all events to two consumers: the 
> > > MatcherFinder, the clang's static analyzer, we can get rid of the 
> > > `MultiplexConsumer` by implementing a new ASTConsumer, so that we have 
> > > enough flexibility to affect all traversals without touching all clang 
> > > areas, so the API will look like
> > > 
> > > ```
> > > class ClangTidyASTConsumer : public ASTConsumer {
> > > 
> > > public:
> > >   void HandleTopLevelDecl(...) override {
> > >  // collect all main file decl
> > >   }
> > >   void HandleTranslationUnit(ASTContext &Context) override {
> > > // set traversal scope.
> > > MatcherFinderConsumer->HandleTranslationUnit(Context);
> > > StaticAnalyzer->HandleTranslationUnit(Context);
> > >   }
> > >   
> > >   // implement other necessary Handle* overrides, and dispatch to 
> > > StaticAnalyzer consumers;
> > > 
> > > private:
> > >   std::unique_ptr MatcherFinderConsumer;
> > >   std::unique_ptr<...> StaticAnalyzer;
> > >   ... MainFileDecl;
> > > }; 
> > > ``` 
> > MultiplexConsumer is just used as a helper to glue together two concrete 
> > ASTConsumers, not arbitrary consumers, so we can reason about whether it's 
> > safe by reading the code.
> > 
> > The static analyzer's consumer appears to already track top-level decls 
> > rather than traversing from the root, exactly to avoid traversing stuff 
> > from the preamble. So I would expect setTraversalContext to work fine there.
> > 
> > The approach Haojian suggests of avoiding MultiplexConsumer, and making the 
> > tight coupling to the particular consumers explicit, also seems fine.
> > 
> > > If that's correct, it seems to me that changing those two handlers in 
> > > MatchFinder is right for clang-tidy
> > 
> > This might be the most convenient thing for clang-tidy, but I don't think 
> > it's the right thing for MatchFinder, which is also important.
> I looked into Hokein's suggestion. Although in general correctly used 
> inheritance is better, there are special cases that copying functionality 
> from 

[PATCH] D99005: [clang] Implement P2266 Simpler implicit move

2021-06-28 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov added a comment.

In D99005#2844332 , @zahiraam wrote:

> This change has made this snippet fail.
> https://godbolt.org/z/3ehK784hY Pass
> https://godbolt.org/z/9q48WvsP7 fails.

Hello!
That is expected breakage from the changes proposed in P2266 
.
With simpler implicit move, we no longer have a fallback second overload 
resolution where the return expression would be an l-value and would thus bind 
to that non-const copy constructor.
You can work that around by introducing an explicit cast to lvalue reference, 
like this: https://godbolt.org/z/EhYbhYjch

But is this example a reduction from a real world code base?
The committee wants feedback and we are interested how hard you believe this 
change affects you.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99005

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


[PATCH] D99005: [clang] Implement P2266 Simpler implicit move

2021-06-28 Thread Zahira Ammarguellat via Phabricator via cfe-commits
zahiraam added a comment.

In D99005#2844365 , @mizvekov wrote:

> In D99005#2844332 , @zahiraam wrote:
>
>> This change has made this snippet fail.
>> https://godbolt.org/z/3ehK784hY Pass
>> https://godbolt.org/z/9q48WvsP7 fails.
>
> Hello!
> That is expected breakage from the changes proposed in P2266 
> .
> With simpler implicit move, we no longer have a fallback second overload 
> resolution where the return expression would be an l-value and would thus 
> bind to that non-const copy constructor.
> You can work that around by introducing an explicit cast to lvalue reference, 
> like this: https://godbolt.org/z/EhYbhYjch
>
> But is this example a reduction from a real world code base?
> The committee wants feedback and we are interested how hard you believe this 
> change affects you.

Yes that's a reduced test from a  test suite.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99005

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


[clang] d5402a2 - Revert "[Analyzer][solver] Add dump methods for (dis)equality classes."

2021-06-28 Thread Nico Weber via cfe-commits

Author: Nico Weber
Date: 2021-06-28T11:32:57-04:00
New Revision: d5402a2fee5d860e20378f819e200865af3a6113

URL: 
https://github.com/llvm/llvm-project/commit/d5402a2fee5d860e20378f819e200865af3a6113
DIFF: 
https://github.com/llvm/llvm-project/commit/d5402a2fee5d860e20378f819e200865af3a6113.diff

LOG: Revert "[Analyzer][solver] Add dump methods for (dis)equality classes."

This reverts commit 6f3b775c3e9c685f74ecbe2ce1a94af52cc17c2f.
Test fails flakily, see comments on https://reviews.llvm.org/D103967

Also revert follow-up "[Analyzer] Attempt to fix windows bots test
failure b/c of new-line"
This reverts commit fe0e861a4d9946a3e7de1bc95a3ec12fa602b492.

Added: 


Modified: 
clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
clang/test/Analysis/expr-inspection.c

Removed: 
clang/test/Analysis/expr-inspection-printState-diseq-info.c
clang/test/Analysis/expr-inspection-printState-eq-classes.c



diff  --git a/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp 
b/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
index c3d8a0a87635..0e57a1a5040f 100644
--- a/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
+++ b/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
@@ -592,11 +592,6 @@ class EquivalenceClass : public llvm::FoldingSetNode {
   RangeSet::Factory &F,
   ProgramStateRef State);
 
-  void dumpToStream(ProgramStateRef State, raw_ostream &os) const;
-  LLVM_DUMP_METHOD void dump(ProgramStateRef State) const {
-dumpToStream(State, llvm::errs());
-  }
-
   /// Check equivalence data for consistency.
   LLVM_NODISCARD LLVM_ATTRIBUTE_UNUSED static bool
   isClassDataConsistent(ProgramStateRef State);
@@ -1410,17 +1405,6 @@ class RangeConstraintManager : public 
RangedConstraintManager {
 
   void printJson(raw_ostream &Out, ProgramStateRef State, const char *NL = 
"\n",
  unsigned int Space = 0, bool IsDot = false) const override;
-  void printConstraints(raw_ostream &Out, ProgramStateRef State,
-const char *NL = "\n", unsigned int Space = 0,
-bool IsDot = false) const;
-  void printEquivalenceClasses(raw_ostream &Out, ProgramStateRef State,
-   const char *NL = "\n", unsigned int Space = 0,
-   bool IsDot = false) const;
-  void printEquivalenceClass(raw_ostream &Out, ProgramStateRef State,
- EquivalenceClass Class) const;
-  void printDisequalities(raw_ostream &Out, ProgramStateRef State,
-  const char *NL = "\n", unsigned int Space = 0,
-  bool IsDot = false) const;
 
   //===--===//
   // Implementation for interface from RangedConstraintManager.
@@ -1644,15 +1628,6 @@ ConstraintMap ento::getConstraintMap(ProgramStateRef 
State) {
 // EqualityClass implementation details
 
//===--===//
 
-LLVM_DUMP_METHOD void EquivalenceClass::dumpToStream(ProgramStateRef State,
- raw_ostream &os) const {
-  SymbolSet ClassMembers = getClassMembers(State);
-  for (const SymbolRef &MemberSym : ClassMembers) {
-MemberSym->dump();
-os << "\n";
-  }
-}
-
 inline EquivalenceClass EquivalenceClass::find(ProgramStateRef State,
SymbolRef Sym) {
   assert(State && "State should not be null");
@@ -2493,16 +2468,6 @@ ProgramStateRef 
RangeConstraintManager::assumeSymOutsideInclusiveRange(
 void RangeConstraintManager::printJson(raw_ostream &Out, ProgramStateRef State,
const char *NL, unsigned int Space,
bool IsDot) const {
-  printConstraints(Out, State, NL, Space, IsDot);
-  printEquivalenceClasses(Out, State, NL, Space, IsDot);
-  printDisequalities(Out, State, NL, Space, IsDot);
-}
-
-void RangeConstraintManager::printConstraints(raw_ostream &Out,
-  ProgramStateRef State,
-  const char *NL,
-  unsigned int Space,
-  bool IsDot) const {
   ConstraintRangeTy Constraints = State->get();
 
   Indent(Out, Space, IsDot) << "\"constraints\": ";
@@ -2536,106 +2501,3 @@ void 
RangeConstraintManager::printConstraints(raw_ostream &Out,
   --Space;
   Indent(Out, Space, IsDot) << "]," << NL;
 }
-
-void RangeConstraintManager::printEquivalenceClass(
-raw_ostream &Out, ProgramStateRef State, EquivalenceClass Class) const {
-  bool FirstMember = true;
-  SymbolSet ClassMembers = Class.getClassMembers(State);
-  Out << "[ ";
- 

[PATCH] D103967: [Analyzer][solver] Add dump methods for (dis)equality classes.

2021-06-28 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

Reverted for now in d5402a2fee5d860e20378f819e200865af3a6113 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103967

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


[PATCH] D103967: [Analyzer][solver] Add dump methods for (dis)equality classes.

2021-06-28 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

(here's another flaky failure that was due to this: 
http://45.33.8.238/mac/33008/step_7.txt )


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103967

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


[PATCH] D93373: [Flang][Openmp] Upgrade TASKGROUP construct to 5.0.

2021-06-28 Thread Chirag Khandelwal via Phabricator via cfe-commits
AMDChirag added a comment.

@kiranchandramohan The tests passed now!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93373

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


Re: [clang] 4a47da2 - [Sema] turns -Wfree-nonheap-object on by default

2021-06-28 Thread David Blaikie via cfe-commits
(ping on this)

On Mon, May 10, 2021 at 8:37 AM David Blaikie  wrote:

> Christopher - had a chance to look into this any further?
>
> Roman - I'm OK either way on that. I don't think it's the most costly
> false positive - not too much code is probably freeing via a reference
> (rather than a pointer) to allocated memory.
>
>
> On Fri, Apr 30, 2021 at 10:08 AM Roman Lebedev 
> wrote:
> >
> > Should the diagnostic be backed out until then?
> >
> > Roman
> >
> > On Fri, Apr 30, 2021 at 7:52 PM Christopher Di Bella via cfe-commits
> >  wrote:
> > >
> > > Sorry, not yet. I'll talk with my TL to see if I can get some time
> allotted for this in the next few weeks.
> > >
> > > On Thu, 29 Apr 2021 at 16:13, David Blaikie 
> wrote:
> > >>
> > >> Ping on this - have you had a chance to look at this false positive?
> > >>
> > >> On Sat, Apr 3, 2021 at 4:29 PM David Blaikie 
> wrote:
> > >> >
> > >> > Looks like this has a false positive (that's firing on some mlir
> code,
> > >> > committed a workaround in  499571ea835daf786626a0db1e12f890b6cd8f8d
> )
> > >> > like this:
> > >> >
> > >> > $ cat test.cpp
> > >> > #include 
> > >> > void f1(int & x) { free(&x); }
> > >> > int main() { f1(*(int*)malloc(sizeof(int))); }
> > >> >
> > >> > Could you fix that? (& then revert the workaround)
> > >> >
> > >> > On Fri, Jan 15, 2021 at 1:44 PM Christopher Di Bella via cfe-commits
> > >> >  wrote:
> > >> > >
> > >> > >
> > >> > > Author: Christopher Di Bella
> > >> > > Date: 2021-01-15T21:38:47Z
> > >> > > New Revision: 4a47da2cf440c2f2006d9b04acfef4292de1e263
> > >> > >
> > >> > > URL:
> https://github.com/llvm/llvm-project/commit/4a47da2cf440c2f2006d9b04acfef4292de1e263
> > >> > > DIFF:
> https://github.com/llvm/llvm-project/commit/4a47da2cf440c2f2006d9b04acfef4292de1e263.diff
> > >> > >
> > >> > > LOG: [Sema] turns -Wfree-nonheap-object on by default
> > >> > >
> > >> > > We'd discussed adding the warning to -Wall in D89988. This patch
> honours that.
> > >> > >
> > >> > > Added:
> > >> > >
> > >> > >
> > >> > > Modified:
> > >> > > clang/include/clang/Basic/DiagnosticGroups.td
> > >> > > clang/include/clang/Basic/DiagnosticSemaKinds.td
> > >> > > clang/test/Analysis/NewDelete-intersections.mm
> > >> > > clang/test/Analysis/free.c
> > >> > >
> > >> > > Removed:
> > >> > >
> > >> > >
> > >> > >
> > >> > >
> 
> > >> > > diff  --git a/clang/include/clang/Basic/DiagnosticGroups.td
> b/clang/include/clang/Basic/DiagnosticGroups.td
> > >> > > index d500ab321058..04ba89aa457e 100644
> > >> > > --- a/clang/include/clang/Basic/DiagnosticGroups.td
> > >> > > +++ b/clang/include/clang/Basic/DiagnosticGroups.td
> > >> > > @@ -110,6 +110,7 @@ def FloatConversion :
> > >> > >   FloatZeroConversion]>;
> > >> > >
> > >> > >  def FrameAddress : DiagGroup<"frame-address">;
> > >> > > +def FreeNonHeapObject : DiagGroup<"free-nonheap-object">;
> > >> > >  def DoublePromotion : DiagGroup<"double-promotion">;
> > >> > >  def EnumTooLarge : DiagGroup<"enum-too-large">;
> > >> > >  def UnsupportedNan : DiagGroup<"unsupported-nan">;
> > >> > >
> > >> > > diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td
> b/clang/include/clang/Basic/DiagnosticSemaKinds.td
> > >> > > index 7d36397a7993..e93657898f58 100644
> > >> > > --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
> > >> > > +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
> > >> > > @@ -7609,7 +7609,7 @@ def err_no_typeid_with_fno_rtti : Error<
> > >> > >  def err_no_dynamic_cast_with_fno_rtti : Error<
> > >> > >"use of dynamic_cast requires -frtti">;
> > >> > >  def warn_no_dynamic_cast_with_rtti_disabled: Warning<
> > >> > > -  "dynamic_cast will not work since RTTI data is disabled by "
> > >> > > +  "dynamic_cast will not work since RTTI data is disabled by "
> > >> > >"%select{-fno-rtti-data|/GR-}0">, InGroup;
> > >> > >  def warn_no_typeid_with_rtti_disabled: Warning<
> > >> > >"typeid will not work since RTTI data is disabled by "
> > >> > > @@ -7625,8 +7625,7 @@ def warn_condition_is_assignment :
> Warning<"using the result of an "
> > >> > >InGroup;
> > >> > >  def warn_free_nonheap_object
> > >> > >: Warning<"attempt to call %0 on non-heap object %1">,
> > >> > > -InGroup>,
> > >> > > -DefaultIgnore; // FIXME: add to -Wall after sufficient
> testing
> > >> > > +InGroup;
> > >> > >
> > >> > >  // Completely identical except off by default.
> > >> > >  def warn_condition_is_idiomatic_assignment : Warning<"using the
> result "
> > >> > >
> > >> > > diff  --git a/clang/test/Analysis/NewDelete-intersections.mm
> b/clang/test/Analysis/NewDelete-intersections.mm
> > >> > > index f01d62f8d365..6f81034ee349 100644
> > >> > > --- a/clang/test/Analysis/NewDelete-intersections.mm
> > >> > > +++ b/clang/test/Analysis/NewDelete-intersections.mm
> > >> > > @@ -24,9 +24,6 @@
> > >> > >  extern "C" void free(void *);
> > >

[PATCH] D104904: [OpenMP][AMDGCN] Initial math headers support

2021-06-28 Thread Pushpinder Singh via Phabricator via cfe-commits
pdhaliwal updated this revision to Diff 354913.
pdhaliwal marked 2 inline comments as done.
pdhaliwal added a comment.

- Move __constant__ to openmp_wrappers/cmath
- Using push/pop_macro to avoid redefinition


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104904

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Headers/__clang_hip_cmath.h
  clang/lib/Headers/__clang_hip_math.h
  clang/lib/Headers/openmp_wrappers/__clang_openmp_device_functions.h
  clang/lib/Headers/openmp_wrappers/cmath
  clang/lib/Headers/openmp_wrappers/math.h
  clang/test/Headers/Inputs/include/algorithm
  clang/test/Headers/Inputs/include/cstdlib
  clang/test/Headers/Inputs/include/utility
  clang/test/Headers/amdgcn_openmp_device_math.c
  clang/test/Headers/openmp_device_math_isnan.cpp

Index: clang/test/Headers/openmp_device_math_isnan.cpp
===
--- clang/test/Headers/openmp_device_math_isnan.cpp
+++ clang/test/Headers/openmp_device_math_isnan.cpp
@@ -21,14 +21,14 @@
 double math(float f, double d) {
   double r = 0;
   // INT_RETURN: call i32 @__nv_isnanf(float
-  // AMD_INT_RETURN: call i32 @_{{.*}}isnanf(float
+  // AMD_INT_RETURN: call i32 @__ocml_isnan_f32(float
   // BOOL_RETURN: call i32 @__nv_isnanf(float
-  // AMD_BOOL_RETURN: call zeroext i1 @_{{.*}}isnanf(float
+  // AMD_BOOL_RETURN: call i32 @__ocml_isnan_f32(float
   r += std::isnan(f);
   // INT_RETURN: call i32 @__nv_isnand(double
-  // AMD_INT_RETURN: call i32 @_{{.*}}isnand(double
+  // AMD_INT_RETURN: call i32 @__ocml_isnan_f64(double
   // BOOL_RETURN: call i32 @__nv_isnand(double
-  // AMD_BOOL_RETURN: call zeroext i1 @_{{.*}}isnand(double
+  // AMD_BOOL_RETURN: call i32 @__ocml_isnan_f64(double
   r += std::isnan(d);
   return r;
 }
Index: clang/test/Headers/amdgcn_openmp_device_math.c
===
--- /dev/null
+++ clang/test/Headers/amdgcn_openmp_device_math.c
@@ -0,0 +1,51 @@
+// RUN: %clang_cc1 -internal-isystem %S/Inputs/include -x c -fopenmp -triple x86_64-unknown-unknown -fopenmp-targets=amdgcn-amd-amdhsa -emit-llvm-bc %s -o %t-host.bc
+// RUN: %clang_cc1 -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_device_functions.h -internal-isystem %S/../../lib/Headers/openmp_wrappers -internal-isystem %S/Inputs/include -x c -fopenmp -triple amdgcn-amd-amdhsa -aux-triple x86_64-unknown-unknown -fopenmp-targets=amdgcn-amd-amdhsa -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-host.bc -o - | FileCheck %s --check-prefixes=CHECK-C,CHECK
+// RUN: %clang_cc1 -internal-isystem %S/Inputs/include -x c++ -fopenmp -triple x86_64-unknown-unknown -fopenmp-targets=amdgcn-amd-amdhsa -emit-llvm-bc %s -o %t-host.bc
+// RUN: %clang_cc1 -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_device_functions.h -internal-isystem %S/../../lib/Headers/openmp_wrappers -internal-isystem %S/Inputs/include -x c++ -fopenmp -triple amdgcn-amd-amdhsa -aux-triple x86_64-unknown-unknown -fopenmp-targets=amdgcn-amd-amdhsa -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-host.bc -o - | FileCheck %s --check-prefixes=CHECK-CPP,CHECK
+
+#ifdef __cplusplus
+#include 
+#else
+#include 
+#endif
+
+void test_math_f64(double x) {
+// CHECK-LABEL: define {{.*}}test_math_f64
+#pragma omp target
+  {
+// CHECK: call double @__ocml_sin_f64
+double l1 = sin(x);
+// CHECK: call double @__ocml_cos_f64
+double l2 = cos(x);
+// CHECK: call double @__ocml_fabs_f64
+double l3 = fabs(x);
+  }
+}
+
+void test_math_f32(float x) {
+// CHECK-LABEL: define {{.*}}test_math_f32
+#pragma omp target
+  {
+// CHECK-C: call double @__ocml_sin_f64
+// CHECK-CPP: call float @__ocml_sin_f32
+float l1 = sin(x);
+// CHECK-C: call double @__ocml_cos_f64
+// CHECK-CPP: call float @__ocml_cos_f32
+float l2 = cos(x);
+// CHECK-C: call double @__ocml_fabs_f64
+// CHECK-CPP: call float @__ocml_fabs_f32
+float l3 = fabs(x);
+  }
+}
+void test_math_f32_suffix(float x) {
+// CHECK-LABEL: define {{.*}}test_math_f32_suffix
+#pragma omp target
+  {
+// CHECK: call float @__ocml_sin_f32
+float l1 = sinf(x);
+// CHECK: call float @__ocml_cos_f32
+float l2 = cosf(x);
+// CHECK: call float @__ocml_fabs_f32
+float l3 = fabsf(x);
+  }
+}
Index: clang/test/Headers/Inputs/include/utility
===
--- /dev/null
+++ clang/test/Headers/Inputs/include/utility
@@ -0,0 +1,2 @@
+#pragma once
+
Index: clang/test/Headers/Inputs/include/cstdlib
===
--- clang/test/Headers/Inputs/include/cstdlib
+++ clang/test/Headers/Inputs/include/cstdlib
@@ -23,9 +23,13 @@
 inline long long
 abs(long long __x) { return __builtin_llabs (__x); }
 
+// amdgcn already provides definition

[PATCH] D104904: [OpenMP][AMDGCN] Initial math headers support

2021-06-28 Thread Pushpinder Singh via Phabricator via cfe-commits
pdhaliwal added inline comments.



Comment at: clang/lib/Headers/__clang_hip_cmath.h:30
+#ifdef __OPENMP_AMDGCN__
+#define __DEVICE__ static __attribute__((always_inline, nothrow))
+#define __CONSTEXPR__ constexpr

ashi1 wrote:
> Does OpenMP not require `__device__` attribute here? I know constexpr defines 
> `__device__` on HIP, does OMP do the same?
It does not as these methods are inside declare variant.



Comment at: clang/lib/Headers/__clang_hip_cmath.h:32
+#define __CONSTEXPR__ constexpr
+#define __constant__ __attribute__((constant))
+#else

ashi1 wrote:
> I don't think this is the right place to define `__constant__`? It's unused 
> in this header, and may get forgotten. Would it be better to define it in the 
> openmp wrapper or does cmath define it in OpenMP?
It is being used. However, I have moved it to openmp_wrappers/cmath.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104904

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


[PATCH] D104777: PR50767: clear non-distinct debuginfo for function with nodebug definition after undecorated declaration

2021-06-28 Thread David Blaikie via Phabricator via cfe-commits
dblaikie accepted this revision.
dblaikie added a comment.
This revision is now accepted and ready to land.

In D104777#2844077 , @brunodefraine 
wrote:

> That I already encounter this in builtin headers is probably an indication 
> that the new error will break some code in the wild.

Fair point, breaking backwards compatibility isn't great.

> A pragmatic solution would be to only raise the error in 
> `Sema::mergeDeclAttributes` if `Old->isUsed()`, i.e. an earlier declaration 
> without `nodebug` can be forgiven if not yet used. I think that would still 
> make it impossible to trigger the crash?

I'm not too fussed about the original patch - just figured it might be 
nicer/cleaner to require a consistent view of the attribute value. I'm not sure 
it's worth splitting hairs on "it can be inconsistent but only in this narrow 
way".

I can appreciate that only invalidating the cases that were crashes before 
avoids increasing the feature surface area more than necessary - but I'm not 
sure it makes for a more ergonomic feature. (though, equally - the idea that 
adding a definition to a translation unit would modify the DWARF produced for 
calls to the function that were previously fine is weird too - but I guess we 
already had that property if you added the definition at the start of the 
translation unit)

Let's just go with the original patch then - thanks for your patience/working 
through the alternatives!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104777

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


[PATCH] D104680: [clang] Eliminate relational function pointer comparisons in all C++ modes

2021-06-28 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov updated this revision to Diff 354920.
mizvekov added a comment.

- Rebase after split.
- Add tests which I had forgotten, covering the builtin candidates for the 
relational operators other than spaceship.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104680

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/test/CXX/drs/dr15xx.cpp
  clang/test/CXX/drs/dr3xx.cpp
  clang/test/CXX/expr/expr.const/p2-0x.cpp
  clang/test/SemaCXX/compare-function-pointer.cpp
  clang/test/SemaTemplate/resolve-single-template-id.cpp

Index: clang/test/SemaTemplate/resolve-single-template-id.cpp
===
--- clang/test/SemaTemplate/resolve-single-template-id.cpp
+++ clang/test/SemaTemplate/resolve-single-template-id.cpp
@@ -68,11 +68,11 @@
 
   one < one; // expected-warning {{self-comparison always evaluates to false}} \
  // expected-warning {{relational comparison result unused}}   \
- // expected-warning {{ordered comparison of function pointers}}
+ // expected-error   {{ordered comparison of function pointers}}
 
   oneT < oneT; // expected-warning {{self-comparison always evaluates to false}} \
  // expected-warning {{relational comparison result unused}}   \
- // expected-warning {{ordered comparison of function pointers}}
+ // expected-error   {{ordered comparison of function pointers}}
 
   two < two; //expected-error 2 {{reference to overloaded function could not be resolved; did you mean to call it with no arguments?}} expected-error {{invalid operands to binary expression ('void' and 'void')}}
   twoT < twoT; //expected-error {{reference to overloaded function could not be resolved; did you mean to call it?}} {{cannot resolve overloaded function 'twoT' from context}}
Index: clang/test/SemaCXX/compare-function-pointer.cpp
===
--- clang/test/SemaCXX/compare-function-pointer.cpp
+++ clang/test/SemaCXX/compare-function-pointer.cpp
@@ -3,25 +3,48 @@
 using fp0_t = void (*)();
 using fp1_t = int (*)();
 
+namespace test_builtin {
+
 extern fp0_t a, b;
 extern fp1_t c;
 
 bool eq0 = a == b;
 bool ne0 = a != b;
-bool lt0 = a < b;   // expected-warning {{ordered comparison of function pointers ('fp0_t' (aka 'void (*)()') and 'fp0_t')}}
-bool le0 = a <= b;  // expected-warning {{ordered comparison of function pointers}}
-bool gt0 = a > b;   // expected-warning {{ordered comparison of function pointers}}
-bool ge0 = a >= b;  // expected-warning {{ordered comparison of function pointers}}
-auto tw0 = a <=> b; // expected-error {{ordered comparison of function pointers}}
+bool lt0 = a < b;   // expected-error {{ordered comparison of function pointers ('fp0_t' (aka 'void (*)()') and 'fp0_t')}}
+bool le0 = a <= b;  // expected-error {{ordered comparison of function pointers}}
+bool gt0 = a > b;   // expected-error {{ordered comparison of function pointers}}
+bool ge0 = a >= b;  // expected-error {{ordered comparison of function pointers}}
 
 bool eq1 = a == c;  // expected-error {{comparison of distinct pointer types}}
 bool ne1 = a != c;  // expected-error {{comparison of distinct pointer types}}
-bool lt1 = a < c;   // expected-warning {{ordered comparison of function pointers ('fp0_t' (aka 'void (*)()') and 'fp1_t' (aka 'int (*)()'))}}
-// expected-error@-1 {{comparison of distinct pointer types}}
-bool le1 = a <= c;  // expected-warning {{ordered comparison of function pointers}}
-// expected-error@-1 {{comparison of distinct pointer types}}
-bool gt1 = a > c;   // expected-warning {{ordered comparison of function pointers}}
-// expected-error@-1 {{comparison of distinct pointer types}}
-bool ge1 = a >= c;  // expected-warning {{ordered comparison of function pointers}}
-// expected-error@-1 {{comparison of distinct pointer types}}
+bool lt1 = a < c;   // expected-error {{ordered comparison of function pointers ('fp0_t' (aka 'void (*)()') and 'fp1_t' (aka 'int (*)()'))}}
+bool le1 = a <= c;  // expected-error {{ordered comparison of function pointers}}
+bool gt1 = a > c;   // expected-error {{ordered comparison of function pointers}}
+bool ge1 = a >= c;  // expected-error {{ordered comparison of function pointers}}
 auto tw1 = a <=> c; // expected-error {{ordered comparison of function pointers}}
+
+} // namespace test_builtin
+
+namespace test_overload {
+
+template struct wrapper { operator T(); };
+
+extern wrapper a, b;
+extern wrapper c;
+
+bool eq0 = a == b;
+bool ne0 = a != b;
+bool lt0 = a < b;   // expected-error {{invalid operands to binary expression}}
+bool le0 = a <= b;  // expected-error {{invalid operands to binary expression}}

[PATCH] D104777: PR50767: clear non-distinct debuginfo for function with nodebug definition after undecorated declaration

2021-06-28 Thread Bruno De Fraine via Phabricator via cfe-commits
brunodefraine updated this revision to Diff 354922.
brunodefraine added a comment.

Slightly improved test case (both C and C++).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104777

Files:
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/test/CodeGen/attr-nodebug2.c


Index: clang/test/CodeGen/attr-nodebug2.c
===
--- /dev/null
+++ clang/test/CodeGen/attr-nodebug2.c
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -x c -debug-info-kind=limited -debugger-tuning=gdb 
-dwarf-version=4 -O -disable-llvm-passes -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -x c++ -debug-info-kind=limited -debugger-tuning=gdb 
-dwarf-version=4 -O -disable-llvm-passes -emit-llvm -o - %s | FileCheck %s
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void t1();
+
+void use() { t1(); }
+
+__attribute__((nodebug)) void t1() {
+  int a = 10;
+  a++;
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+// CHECK-LABEL: define{{.*}} void @use()
+// CHECK-SAME:  !dbg
+// CHECK-SAME:  {
+// CHECK:   !dbg
+// CHECK:   }
+
+// PR50767 Function __attribute__((nodebug)) inconsistency causes crash
+// illegal (non-distinct) !dbg metadata was being added to _Z2t1v definition
+
+// CHECK-LABEL: define{{.*}} void @t1()
+// CHECK-NOT:   !dbg
+// CHECK-SAME:  {
+// CHECK-NOT:   !dbg
+// CHECK:   }
Index: clang/lib/CodeGen/CodeGenFunction.cpp
===
--- clang/lib/CodeGen/CodeGenFunction.cpp
+++ clang/lib/CodeGen/CodeGenFunction.cpp
@@ -1304,8 +1304,14 @@
   QualType ResTy = BuildFunctionArgList(GD, Args);
 
   // Check if we should generate debug info for this function.
-  if (FD->hasAttr())
-DebugInfo = nullptr; // disable debug info indefinitely for this function
+  if (FD->hasAttr()) {
+// Clear non-distinct debug info that was possibly attached to the function
+// due to an earlier declaration without the nodebug attribute
+if (Fn)
+  Fn->setSubprogram(nullptr);
+// Disable debug info indefinitely for this function
+DebugInfo = nullptr;
+  }
 
   // The function might not have a body if we're generating thunks for a
   // function declaration.


Index: clang/test/CodeGen/attr-nodebug2.c
===
--- /dev/null
+++ clang/test/CodeGen/attr-nodebug2.c
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -x c -debug-info-kind=limited -debugger-tuning=gdb -dwarf-version=4 -O -disable-llvm-passes -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -x c++ -debug-info-kind=limited -debugger-tuning=gdb -dwarf-version=4 -O -disable-llvm-passes -emit-llvm -o - %s | FileCheck %s
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void t1();
+
+void use() { t1(); }
+
+__attribute__((nodebug)) void t1() {
+  int a = 10;
+  a++;
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+// CHECK-LABEL: define{{.*}} void @use()
+// CHECK-SAME:  !dbg
+// CHECK-SAME:  {
+// CHECK:   !dbg
+// CHECK:   }
+
+// PR50767 Function __attribute__((nodebug)) inconsistency causes crash
+// illegal (non-distinct) !dbg metadata was being added to _Z2t1v definition
+
+// CHECK-LABEL: define{{.*}} void @t1()
+// CHECK-NOT:   !dbg
+// CHECK-SAME:  {
+// CHECK-NOT:   !dbg
+// CHECK:   }
Index: clang/lib/CodeGen/CodeGenFunction.cpp
===
--- clang/lib/CodeGen/CodeGenFunction.cpp
+++ clang/lib/CodeGen/CodeGenFunction.cpp
@@ -1304,8 +1304,14 @@
   QualType ResTy = BuildFunctionArgList(GD, Args);
 
   // Check if we should generate debug info for this function.
-  if (FD->hasAttr())
-DebugInfo = nullptr; // disable debug info indefinitely for this function
+  if (FD->hasAttr()) {
+// Clear non-distinct debug info that was possibly attached to the function
+// due to an earlier declaration without the nodebug attribute
+if (Fn)
+  Fn->setSubprogram(nullptr);
+// Disable debug info indefinitely for this function
+DebugInfo = nullptr;
+  }
 
   // The function might not have a body if we're generating thunks for a
   // function declaration.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D105039: [clangd] Add a flag to disable formatting of tweak edits

2021-06-28 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet added a reviewer: sammccall.
Herald added subscribers: usaxena95, arphaman.
kadircet requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang-tools-extra.

Some tweaks might edit file types not supported by clang-format. This
patch gives them a way to signal that they do not require formatting.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D105039

Files:
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/refactor/Tweak.h


Index: clang-tools-extra/clangd/refactor/Tweak.h
===
--- clang-tools-extra/clangd/refactor/Tweak.h
+++ clang-tools-extra/clangd/refactor/Tweak.h
@@ -78,6 +78,9 @@
 /// A message to be displayed to the user.
 llvm::Optional ShowMessage;
 FileEdits ApplyEdits;
+/// Whether the edits should be formatted before presenting to the client.
+/// Note that it applies to all files.
+bool FormatEdits = true;
 
 static Effect showMessage(StringRef S) {
   Effect E;
Index: clang-tools-extra/clangd/ClangdServer.cpp
===
--- clang-tools-extra/clangd/ClangdServer.cpp
+++ clang-tools-extra/clangd/ClangdServer.cpp
@@ -637,8 +637,8 @@
   Effect = T.takeError();
 }
 assert(Effect.hasValue() && "Expected at least one selection");
-if (*Effect) {
-  // Tweaks don't apply clang-format, do that centrally here.
+if (*Effect && (*Effect)->FormatEdits) {
+  // Format tweaks that require it centrally here.
   for (auto &It : (*Effect)->ApplyEdits) {
 Edit &E = It.second;
 format::FormatStyle Style =


Index: clang-tools-extra/clangd/refactor/Tweak.h
===
--- clang-tools-extra/clangd/refactor/Tweak.h
+++ clang-tools-extra/clangd/refactor/Tweak.h
@@ -78,6 +78,9 @@
 /// A message to be displayed to the user.
 llvm::Optional ShowMessage;
 FileEdits ApplyEdits;
+/// Whether the edits should be formatted before presenting to the client.
+/// Note that it applies to all files.
+bool FormatEdits = true;
 
 static Effect showMessage(StringRef S) {
   Effect E;
Index: clang-tools-extra/clangd/ClangdServer.cpp
===
--- clang-tools-extra/clangd/ClangdServer.cpp
+++ clang-tools-extra/clangd/ClangdServer.cpp
@@ -637,8 +637,8 @@
   Effect = T.takeError();
 }
 assert(Effect.hasValue() && "Expected at least one selection");
-if (*Effect) {
-  // Tweaks don't apply clang-format, do that centrally here.
+if (*Effect && (*Effect)->FormatEdits) {
+  // Format tweaks that require it centrally here.
   for (auto &It : (*Effect)->ApplyEdits) {
 Edit &E = It.second;
 format::FormatStyle Style =
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D104680: [clang] Eliminate relational function pointer comparisons in all C++ modes

2021-06-28 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov updated this revision to Diff 354924.
mizvekov added a comment.

- Fix missing period as pointed by rsmith.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104680

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/test/CXX/drs/dr15xx.cpp
  clang/test/CXX/drs/dr3xx.cpp
  clang/test/CXX/expr/expr.const/p2-0x.cpp
  clang/test/SemaCXX/compare-function-pointer.cpp
  clang/test/SemaTemplate/resolve-single-template-id.cpp

Index: clang/test/SemaTemplate/resolve-single-template-id.cpp
===
--- clang/test/SemaTemplate/resolve-single-template-id.cpp
+++ clang/test/SemaTemplate/resolve-single-template-id.cpp
@@ -68,11 +68,11 @@
 
   one < one; // expected-warning {{self-comparison always evaluates to false}} \
  // expected-warning {{relational comparison result unused}}   \
- // expected-warning {{ordered comparison of function pointers}}
+ // expected-error   {{ordered comparison of function pointers}}
 
   oneT < oneT; // expected-warning {{self-comparison always evaluates to false}} \
  // expected-warning {{relational comparison result unused}}   \
- // expected-warning {{ordered comparison of function pointers}}
+ // expected-error   {{ordered comparison of function pointers}}
 
   two < two; //expected-error 2 {{reference to overloaded function could not be resolved; did you mean to call it with no arguments?}} expected-error {{invalid operands to binary expression ('void' and 'void')}}
   twoT < twoT; //expected-error {{reference to overloaded function could not be resolved; did you mean to call it?}} {{cannot resolve overloaded function 'twoT' from context}}
Index: clang/test/SemaCXX/compare-function-pointer.cpp
===
--- clang/test/SemaCXX/compare-function-pointer.cpp
+++ clang/test/SemaCXX/compare-function-pointer.cpp
@@ -3,25 +3,48 @@
 using fp0_t = void (*)();
 using fp1_t = int (*)();
 
+namespace test_builtin {
+
 extern fp0_t a, b;
 extern fp1_t c;
 
 bool eq0 = a == b;
 bool ne0 = a != b;
-bool lt0 = a < b;   // expected-warning {{ordered comparison of function pointers ('fp0_t' (aka 'void (*)()') and 'fp0_t')}}
-bool le0 = a <= b;  // expected-warning {{ordered comparison of function pointers}}
-bool gt0 = a > b;   // expected-warning {{ordered comparison of function pointers}}
-bool ge0 = a >= b;  // expected-warning {{ordered comparison of function pointers}}
-auto tw0 = a <=> b; // expected-error {{ordered comparison of function pointers}}
+bool lt0 = a < b;   // expected-error {{ordered comparison of function pointers ('fp0_t' (aka 'void (*)()') and 'fp0_t')}}
+bool le0 = a <= b;  // expected-error {{ordered comparison of function pointers}}
+bool gt0 = a > b;   // expected-error {{ordered comparison of function pointers}}
+bool ge0 = a >= b;  // expected-error {{ordered comparison of function pointers}}
 
 bool eq1 = a == c;  // expected-error {{comparison of distinct pointer types}}
 bool ne1 = a != c;  // expected-error {{comparison of distinct pointer types}}
-bool lt1 = a < c;   // expected-warning {{ordered comparison of function pointers ('fp0_t' (aka 'void (*)()') and 'fp1_t' (aka 'int (*)()'))}}
-// expected-error@-1 {{comparison of distinct pointer types}}
-bool le1 = a <= c;  // expected-warning {{ordered comparison of function pointers}}
-// expected-error@-1 {{comparison of distinct pointer types}}
-bool gt1 = a > c;   // expected-warning {{ordered comparison of function pointers}}
-// expected-error@-1 {{comparison of distinct pointer types}}
-bool ge1 = a >= c;  // expected-warning {{ordered comparison of function pointers}}
-// expected-error@-1 {{comparison of distinct pointer types}}
+bool lt1 = a < c;   // expected-error {{ordered comparison of function pointers ('fp0_t' (aka 'void (*)()') and 'fp1_t' (aka 'int (*)()'))}}
+bool le1 = a <= c;  // expected-error {{ordered comparison of function pointers}}
+bool gt1 = a > c;   // expected-error {{ordered comparison of function pointers}}
+bool ge1 = a >= c;  // expected-error {{ordered comparison of function pointers}}
 auto tw1 = a <=> c; // expected-error {{ordered comparison of function pointers}}
+
+} // namespace test_builtin
+
+namespace test_overload {
+
+template struct wrapper { operator T(); };
+
+extern wrapper a, b;
+extern wrapper c;
+
+bool eq0 = a == b;
+bool ne0 = a != b;
+bool lt0 = a < b;   // expected-error {{invalid operands to binary expression}}
+bool le0 = a <= b;  // expected-error {{invalid operands to binary expression}}
+bool gt0 = a > b;   // expected-error {{invalid operands to binary expression}}
+bool ge0 = a >= 

[clang] c3fe847 - [Clang] Add option to handle behaviour of vector bool/vector pixel.

2021-06-28 Thread Stefan Pintilie via cfe-commits

Author: Stefan Pintilie
Date: 2021-06-28T11:16:37-05:00
New Revision: c3fe847f9d90de5a6a76fd1d5f5823ab4719accc

URL: 
https://github.com/llvm/llvm-project/commit/c3fe847f9d90de5a6a76fd1d5f5823ab4719accc
DIFF: 
https://github.com/llvm/llvm-project/commit/c3fe847f9d90de5a6a76fd1d5f5823ab4719accc.diff

LOG: [Clang] Add option to handle behaviour of vector bool/vector pixel.

Added the option `-altivec-src-compat=[mixed,gcc,xl]`. The default at this time 
is `mixed`.

The default behavior for clang is for all vector compares to return a scalar 
unless the vectors being
compared are vector bool or vector pixel. In that case the compare returns a
vector. With the gcc case all vector compares return vectors and in the xl case
all vector compares return scalars.

This patch does not change the default behavior of clang.

This option will be used in future patches to implement behaviour compatibility 
for the vector bool/pixel types.

Reviewed By: bmahjour

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

Added: 
clang/test/CodeGen/vector-compat-pixel-bool-ternary.c
clang/test/CodeGen/vector-compat-pixel-bool.c
clang/test/CodeGen/vector-compat-ternary.c
clang/test/CodeGen/vector-compat.c

Modified: 
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/include/clang/Basic/LangOptions.def
clang/include/clang/Basic/LangOptions.h
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Sema/SemaExpr.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index b5b8bc6aa3c5..70a22fd2506a 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -7441,6 +7441,12 @@ def warn_deprecated_volatile_structured_binding : 
Warning<
   "volatile qualifier in structured binding declaration is deprecated">,
   InGroup;
 
+def warn_deprecated_altivec_src_compat : Warning<
+  "Current handling of vector bool and vector pixel types in this context are "
+  "deprecated. The default behaviour will soon change to that implied by the "
+  "'-altivec-compat=xl' option">,
+  InGroup>;
+
 def err_catch_incomplete_ptr : Error<
   "cannot catch pointer to incomplete type %0">;
 def err_catch_incomplete_ref : Error<

diff  --git a/clang/include/clang/Basic/LangOptions.def 
b/clang/include/clang/Basic/LangOptions.def
index b6d9160f89a0..465bad8d7d11 100644
--- a/clang/include/clang/Basic/LangOptions.def
+++ b/clang/include/clang/Basic/LangOptions.def
@@ -126,6 +126,8 @@ LANGOPT(WritableStrings   , 1, 0, "writable string support")
 LANGOPT(ConstStrings  , 1, 0, "const-qualified string support")
 ENUM_LANGOPT(LaxVectorConversions, LaxVectorConversionKind, 2,
  LaxVectorConversionKind::All, "lax vector conversions")
+ENUM_LANGOPT(AltivecSrcCompat, AltivecSrcCompatKind, 2,
+ AltivecSrcCompatKind::Default, "Altivec source compatibility")
 LANGOPT(ConvergentFunctions, 1, 1, "Assume convergent functions")
 LANGOPT(AltiVec   , 1, 0, "AltiVec-style vector initializers")
 LANGOPT(ZVector   , 1, 0, "System z vector extensions")

diff  --git a/clang/include/clang/Basic/LangOptions.h 
b/clang/include/clang/Basic/LangOptions.h
index d618daf3d23c..d04ce52a550e 100644
--- a/clang/include/clang/Basic/LangOptions.h
+++ b/clang/include/clang/Basic/LangOptions.h
@@ -244,6 +244,18 @@ class LangOptions : public LangOptionsBase {
 All,
   };
 
+  enum class AltivecSrcCompatKind {
+// All vector compares produce scalars except vector pixel and vector bool.
+// The types vector pixel and vector bool return vector results.
+Mixed,
+// All vector compares produce vector results as in GCC.
+GCC,
+// All vector compares produce scalars as in XL.
+XL,
+// Default clang behaviour.
+Default = Mixed,
+  };
+
   enum class SignReturnAddressScopeKind {
 /// No signing for any function.
 None,

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 0122afd2eead..f1455f546199 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -3823,6 +3823,18 @@ def u : JoinedOrSeparate<["-"], "u">, Group;
 def v : Flag<["-"], "v">, Flags<[CC1Option, CoreOption]>,
   HelpText<"Show commands to run and use verbose output">,
   MarshallingInfoFlag>;
+def altivec_src_compat : Joined<["-"], "faltivec-src-compat=">,
+  Flags<[CC1Option]>, Group,
+  HelpText<"Source-level compatibility for Altivec vectors (for PowerPC "
+   "targets). This includes results of vector comparison (scalar for "
+   "'xl', vector for 'gcc') as well as behavior when initializing with 
"
+   "a scalar (splatting for 'xl', element zero only for 'gcc'). For "
+   "'mixed', the compatibility is as 'gcc' for 'vector bool/v

[PATCH] D103615: [Clang] Add option to handle behaviour of vector bool/vector pixel.

2021-06-28 Thread Stefan Pintilie via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc3fe847f9d90: [Clang] Add option to handle behaviour of 
vector bool/vector pixel. (authored by stefanp).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103615

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Basic/LangOptions.h
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/CodeGen/vector-compat-pixel-bool-ternary.c
  clang/test/CodeGen/vector-compat-pixel-bool.c
  clang/test/CodeGen/vector-compat-ternary.c
  clang/test/CodeGen/vector-compat.c

Index: clang/test/CodeGen/vector-compat.c
===
--- /dev/null
+++ clang/test/CodeGen/vector-compat.c
@@ -0,0 +1,162 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// RUN: not %clang_cc1 -target-feature +altivec -target-feature +vsx \
+// RUN:   -faltivec-src-compat=mixed -triple powerpc-unknown-unknown -S -emit-llvm %s -o - 2>&1 | FileCheck %s --check-prefix=ERROR
+// RUN: %clang_cc1 -target-feature +altivec -target-feature +vsx \
+// RUN:   -faltivec-src-compat=gcc -triple powerpc-unknown-unknown -S -emit-llvm %s -o - | FileCheck %s
+// RUN: not %clang_cc1 -target-feature +altivec -target-feature +vsx \
+// RUN:   -faltivec-src-compat=xl -triple powerpc-unknown-unknown -S -emit-llvm %s -o - 2>&1 | FileCheck %s --check-prefix=ERROR
+// RUN: %clang -mcpu=pwr8 -faltivec-src-compat=gcc --target=powerpc-unknown-unknown -S -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang -mcpu=pwr9 -faltivec-src-compat=gcc --target=powerpc-unknown-unknown -S -emit-llvm %s -o - | FileCheck %s
+
+// CHECK-LABEL: @ui8(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[A_ADDR:%.*]] = alloca <16 x i8>, align 16
+// CHECK-NEXT:[[B_ADDR:%.*]] = alloca <16 x i8>, align 16
+// CHECK-NEXT:store <16 x i8> [[A:%.*]], <16 x i8>* [[A_ADDR]], align 16
+// CHECK-NEXT:store <16 x i8> [[B:%.*]], <16 x i8>* [[B_ADDR]], align 16
+// CHECK-NEXT:[[TMP0:%.*]] = load <16 x i8>, <16 x i8>* [[A_ADDR]], align 16
+// CHECK-NEXT:[[TMP1:%.*]] = load <16 x i8>, <16 x i8>* [[B_ADDR]], align 16
+// CHECK-NEXT:[[CMP:%.*]] = icmp eq <16 x i8> [[TMP0]], [[TMP1]]
+// CHECK-NEXT:[[SEXT:%.*]] = sext <16 x i1> [[CMP]] to <16 x i8>
+// CHECK-NEXT:ret <16 x i8> [[SEXT]]
+//
+// ERROR: returning 'int' from a function with incompatible result type
+vector unsigned char ui8(vector unsigned char a, vector unsigned char b) {
+  return a == b;
+}
+
+// CHECK-LABEL: @si8(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[A_ADDR:%.*]] = alloca <16 x i8>, align 16
+// CHECK-NEXT:[[B_ADDR:%.*]] = alloca <16 x i8>, align 16
+// CHECK-NEXT:store <16 x i8> [[A:%.*]], <16 x i8>* [[A_ADDR]], align 16
+// CHECK-NEXT:store <16 x i8> [[B:%.*]], <16 x i8>* [[B_ADDR]], align 16
+// CHECK-NEXT:[[TMP0:%.*]] = load <16 x i8>, <16 x i8>* [[A_ADDR]], align 16
+// CHECK-NEXT:[[TMP1:%.*]] = load <16 x i8>, <16 x i8>* [[B_ADDR]], align 16
+// CHECK-NEXT:[[CMP:%.*]] = icmp eq <16 x i8> [[TMP0]], [[TMP1]]
+// CHECK-NEXT:[[SEXT:%.*]] = sext <16 x i1> [[CMP]] to <16 x i8>
+// CHECK-NEXT:ret <16 x i8> [[SEXT]]
+//
+// ERROR: returning 'int' from a function with incompatible result type
+vector signed char si8(vector signed char a, vector signed char b) {
+  return a == b;
+}
+
+// CHECK-LABEL: @ui16(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[A_ADDR:%.*]] = alloca <8 x i16>, align 16
+// CHECK-NEXT:[[B_ADDR:%.*]] = alloca <8 x i16>, align 16
+// CHECK-NEXT:store <8 x i16> [[A:%.*]], <8 x i16>* [[A_ADDR]], align 16
+// CHECK-NEXT:store <8 x i16> [[B:%.*]], <8 x i16>* [[B_ADDR]], align 16
+// CHECK-NEXT:[[TMP0:%.*]] = load <8 x i16>, <8 x i16>* [[A_ADDR]], align 16
+// CHECK-NEXT:[[TMP1:%.*]] = load <8 x i16>, <8 x i16>* [[B_ADDR]], align 16
+// CHECK-NEXT:[[CMP:%.*]] = icmp eq <8 x i16> [[TMP0]], [[TMP1]]
+// CHECK-NEXT:[[SEXT:%.*]] = sext <8 x i1> [[CMP]] to <8 x i16>
+// CHECK-NEXT:ret <8 x i16> [[SEXT]]
+//
+// ERROR: returning 'int' from a function with incompatible result type
+vector unsigned short ui16(vector unsigned short a, vector unsigned short b) {
+  return a == b;
+}
+
+// CHECK-LABEL: @si16(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[A_ADDR:%.*]] = alloca <8 x i16>, align 16
+// CHECK-NEXT:[[B_ADDR:%.*]] = alloca <8 x i16>, align 16
+// CHECK-NEXT:store <8 x i16> [[A:%.*]], <8 x i16>* [[A_ADDR]], align 16
+// CHECK-NEXT:store <8 x i16> [[B:%.*]], <8 x i16>* [[B_ADDR]], align 16
+// CHECK-NEXT:[[TMP0:%.*]] = load <8 x i16>, <8 x i16>* [[A_ADDR]], align 16
+// CHECK-NEXT:[[TMP1:%.*]] = load <8 x i16>, <8 x i16>* [[B_ADDR]], align 16
+// CHECK-NEXT:[[CMP:%.*]] = icmp eq <8 x i16> [[TMP0]], [[TMP1]]
+// CHECK-NEXT:  

[PATCH] D105039: [clangd] Add a flag to disable formatting of tweak edits

2021-06-28 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.

LG - I do think a config knob for this would be nice one day.
As discussed offline it would also cover rename, code complete insertion...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105039

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


[PATCH] D105001: [Clang][RISCV] Support half-precision floating point for RVV intrinsics.

2021-06-28 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: clang/include/clang/Basic/Builtins.def:27
 //  i -> int
-//  h -> half
+//  h -> half (__fp16)
+//  x -> half (_Float16)

This also includes OpenCL half



Comment at: clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfadd.c:13
 
+// ASM-NOT: warning
 #include 

Do you plan to bring back the ASM check for all tests?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105001

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


[clang] 2c02b0c - [clang][PATCH][nfc] Refactor TargetInfo::adjust to pass DiagnosticsEngine to allow diagnostics on target-unsupported options

2021-06-28 Thread Melanie Blower via cfe-commits

Author: Melanie Blower
Date: 2021-06-28T12:26:53-04:00
New Revision: 2c02b0c3f45414ac6c64583e006a26113c028304

URL: 
https://github.com/llvm/llvm-project/commit/2c02b0c3f45414ac6c64583e006a26113c028304
DIFF: 
https://github.com/llvm/llvm-project/commit/2c02b0c3f45414ac6c64583e006a26113c028304.diff

LOG: [clang][PATCH][nfc] Refactor TargetInfo::adjust to pass DiagnosticsEngine 
to allow diagnostics on target-unsupported options

Reviewed By: aaron.ballman

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

Added: 


Modified: 
clang/include/clang/Basic/TargetInfo.h
clang/lib/Basic/TargetInfo.cpp
clang/lib/Basic/Targets/AMDGPU.cpp
clang/lib/Basic/Targets/AMDGPU.h
clang/lib/Basic/Targets/PPC.cpp
clang/lib/Basic/Targets/PPC.h
clang/lib/Basic/Targets/SPIR.h
clang/lib/Basic/Targets/WebAssembly.cpp
clang/lib/Basic/Targets/WebAssembly.h
clang/lib/Frontend/ASTUnit.cpp
clang/lib/Frontend/CompilerInstance.cpp
clang/lib/Interpreter/Interpreter.cpp
clang/tools/clang-import-test/clang-import-test.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/TargetInfo.h 
b/clang/include/clang/Basic/TargetInfo.h
index d59bad30e742..20f6afa76cbb 100644
--- a/clang/include/clang/Basic/TargetInfo.h
+++ b/clang/include/clang/Basic/TargetInfo.h
@@ -1162,7 +1162,7 @@ class TargetInfo : public virtual TransferrableTargetInfo,
   /// Apply changes to the target information with respect to certain
   /// language options which change the target configuration and adjust
   /// the language based on the target options where applicable.
-  virtual void adjust(LangOptions &Opts);
+  virtual void adjust(DiagnosticsEngine &Diags, LangOptions &Opts);
 
   /// Adjust target options based on codegen options.
   virtual void adjustTargetOptions(const CodeGenOptions &CGOpts,

diff  --git a/clang/lib/Basic/TargetInfo.cpp b/clang/lib/Basic/TargetInfo.cpp
index e73b4a3a40c7..4c2859e5eda7 100644
--- a/clang/lib/Basic/TargetInfo.cpp
+++ b/clang/lib/Basic/TargetInfo.cpp
@@ -346,7 +346,7 @@ bool TargetInfo::isTypeSigned(IntType T) {
 /// Apply changes to the target information with respect to certain
 /// language options which change the target configuration and adjust
 /// the language based on the target options where applicable.
-void TargetInfo::adjust(LangOptions &Opts) {
+void TargetInfo::adjust(DiagnosticsEngine &Diags, LangOptions &Opts) {
   if (Opts.NoBitFieldTypeAlign)
 UseBitFieldTypeAlignment = false;
 

diff  --git a/clang/lib/Basic/Targets/AMDGPU.cpp 
b/clang/lib/Basic/Targets/AMDGPU.cpp
index 595132e2e70b..fac786dbcf9e 100644
--- a/clang/lib/Basic/Targets/AMDGPU.cpp
+++ b/clang/lib/Basic/Targets/AMDGPU.cpp
@@ -358,8 +358,8 @@ AMDGPUTargetInfo::AMDGPUTargetInfo(const llvm::Triple 
&Triple,
   MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 64;
 }
 
-void AMDGPUTargetInfo::adjust(LangOptions &Opts) {
-  TargetInfo::adjust(Opts);
+void AMDGPUTargetInfo::adjust(DiagnosticsEngine &Diags, LangOptions &Opts) {
+  TargetInfo::adjust(Diags, Opts);
   // ToDo: There are still a few places using default address space as private
   // address space in OpenCL, which needs to be cleaned up, then Opts.OpenCL
   // can be removed from the following line.

diff  --git a/clang/lib/Basic/Targets/AMDGPU.h 
b/clang/lib/Basic/Targets/AMDGPU.h
index fe5c61c6ba2b..244a6e044690 100644
--- a/clang/lib/Basic/Targets/AMDGPU.h
+++ b/clang/lib/Basic/Targets/AMDGPU.h
@@ -93,7 +93,7 @@ class LLVM_LIBRARY_VISIBILITY AMDGPUTargetInfo final : public 
TargetInfo {
 
   void setAddressSpaceMap(bool DefaultIsPrivate);
 
-  void adjust(LangOptions &Opts) override;
+  void adjust(DiagnosticsEngine &Diags, LangOptions &Opts) override;
 
   uint64_t getPointerWidthV(unsigned AddrSpace) const override {
 if (isR600(getTriple()))

diff  --git a/clang/lib/Basic/Targets/PPC.cpp b/clang/lib/Basic/Targets/PPC.cpp
index 6860b5e5d02f..d431dda97022 100644
--- a/clang/lib/Basic/Targets/PPC.cpp
+++ b/clang/lib/Basic/Targets/PPC.cpp
@@ -614,10 +614,10 @@ void 
PPCTargetInfo::fillValidCPUList(SmallVectorImpl &Values) const {
   Values.append(std::begin(ValidCPUNames), std::end(ValidCPUNames));
 }
 
-void PPCTargetInfo::adjust(LangOptions &Opts) {
+void PPCTargetInfo::adjust(DiagnosticsEngine &Diags, LangOptions &Opts) {
   if (HasAltivec)
 Opts.AltiVec = 1;
-  TargetInfo::adjust(Opts);
+  TargetInfo::adjust(Diags, Opts);
   if (LongDoubleFormat != &llvm::APFloat::IEEEdouble())
 LongDoubleFormat = Opts.PPCIEEELongDouble
? &llvm::APFloat::IEEEquad()

diff  --git a/clang/lib/Basic/Targets/PPC.h b/clang/lib/Basic/Targets/PPC.h
index 554f2174fee0..18ee1194c759 100644
--- a/clang/lib/Basic/Targets/PPC.h
+++ b/clang/lib/Basic/Targets/PPC.h
@@ -89,7 +89,7 @@ class LLVM_LIBRARY_VISIBILITY PPCTargetInfo : public 
TargetInfo {
   }
 
   // Set the language option for altivec based on our value.
-  void adjust(La

[clang] 4f1238e - [clang][patch][fpenv] Add builtin __arithmetic_fence and option fprotect-parens

2021-06-28 Thread Melanie Blower via cfe-commits

Author: Melanie Blower
Date: 2021-06-28T12:26:53-04:00
New Revision: 4f1238e44d803b145997fa984677a6c5cdf1f417

URL: 
https://github.com/llvm/llvm-project/commit/4f1238e44d803b145997fa984677a6c5cdf1f417
DIFF: 
https://github.com/llvm/llvm-project/commit/4f1238e44d803b145997fa984677a6c5cdf1f417.diff

LOG: [clang][patch][fpenv] Add builtin __arithmetic_fence and option 
fprotect-parens

This patch adds a new clang builtin, __arithmetic_fence. The purpose of the
builtin is to provide the user fine control, at the expression level, over
floating point optimization when -ffast-math (-ffp-model=fast) is enabled.
The builtin prevents the optimizer from rearranging floating point expression
evaluation. The new option fprotect-parens has the same effect on
parenthesized expressions, forcing the optimizer to respect the parentheses.

Reviewed By: aaron.ballman, kpn

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

Added: 
clang/test/AST/arithmetic-fence-builtin.c
clang/test/CodeGen/arithmetic-fence-builtin.c
clang/test/Sema/arithmetic-fence-builtin.c

Modified: 
clang/docs/UsersManual.rst
clang/include/clang/Basic/Builtins.def
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/include/clang/Basic/LangOptions.def
clang/include/clang/Basic/TargetInfo.h
clang/include/clang/Driver/Options.td
clang/include/clang/Sema/Sema.h
clang/lib/AST/ExprConstant.cpp
clang/lib/Basic/TargetInfo.cpp
clang/lib/Basic/Targets/X86.h
clang/lib/CodeGen/CGBuiltin.cpp
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Sema/SemaChecking.cpp
clang/lib/Sema/SemaCoroutine.cpp
clang/lib/Sema/SemaExpr.cpp
clang/test/Driver/clang_f_opts.c

Removed: 




diff  --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
index 244212a1336d..9e8bac635337 100644
--- a/clang/docs/UsersManual.rst
+++ b/clang/docs/UsersManual.rst
@@ -1478,6 +1478,26 @@ Note that floating-point operations performed as part of 
constant initialization
* ``maytrap`` The compiler avoids transformations that may raise exceptions 
that would not have been raised by the original code. Constant folding 
performed by the compiler is exempt from this option.
* ``strict`` The compiler ensures that all transformations strictly 
preserve the floating point exception semantics of the original code.
 
+.. option:: -f[no-]protect-parens:
+
+   This option pertains to floating-point types, complex types with
+   floating-point components, and vectors of these types. Some arithmetic
+   expression transformations that are mathematically correct and permissible
+   according to the C and C++ language standards may be incorrect when dealing
+   with floating-point types, such as reassociation and distribution. Further,
+   the optimizer may ignore parentheses when computing arithmetic expressions
+   in circumstances where the parenthesized and unparenthesized expression
+   express the same mathematical value. For example (a+b)+c is the same
+   mathematical value as a+(b+c), but the optimizer is free to evaluate the 
+   additions in any order regardless of the parentheses. When enabled, this
+   option forces the optimizer to honor the order of operations with respect
+   to parentheses in all circumstances.
+
+   Note that floating-point contraction (option `-ffp-contract=`) is disabled
+   when `-fprotect-parens` is enabled.  Also note that in safe floating-point
+   modes, such as `-ffp-model=precise` or `-ffp-model=strict`, this option
+   has no effect because the optimizer is prohibited from making unsafe
+   transformations.
 
 .. _fp-constant-eval:
 

diff  --git a/clang/include/clang/Basic/Builtins.def 
b/clang/include/clang/Basic/Builtins.def
index 5a9d0a001829..33d3e6dc4e7d 100644
--- a/clang/include/clang/Basic/Builtins.def
+++ b/clang/include/clang/Basic/Builtins.def
@@ -1657,6 +1657,9 @@ BUILTIN(__builtin_ms_va_start, "vc*&.", "nt")
 BUILTIN(__builtin_ms_va_end, "vc*&", "n")
 BUILTIN(__builtin_ms_va_copy, "vc*&c*&", "n")
 
+// Arithmetic Fence: to prevent FP reordering and reassociation optimizations
+LANGBUILTIN(__arithmetic_fence, "v.", "t", ALL_LANGUAGES)
+
 #undef BUILTIN
 #undef LIBBUILTIN
 #undef LANGBUILTIN

diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 70a22fd2506a..22c2a1a39ea1 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -8530,6 +8530,9 @@ def err_typecheck_expect_scalar_operand : Error<
   "operand of type %0 where arithmetic or pointer type is required">;
 def err_typecheck_cond_incompatible_operands : Error<
   "incompatible operand types%
diff { ($ and $)|}0,1">;
+def err_typecheck_expect_flt_or_vector : Error<
+  "invalid operand of type %0 where floating, complex or "
+  "a vector of such types is required">;
 def err_cast_selector_expr 

[PATCH] D99675: [llvm][clang] Create new intrinsic llvm.arithmetic.fence to control FP optimization at expression level

2021-06-28 Thread Melanie Blower via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG931e95687d6d: [llvm][clang][fpenv] Create new intrinsic 
llvm.arith.fence to control FP… (authored by mibintc).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99675

Files:
  llvm/docs/LangRef.rst
  llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
  llvm/include/llvm/CodeGen/BasicTTIImpl.h
  llvm/include/llvm/CodeGen/ISDOpcodes.h
  llvm/include/llvm/CodeGen/SelectionDAGISel.h
  llvm/include/llvm/IR/IRBuilder.h
  llvm/include/llvm/IR/Intrinsics.td
  llvm/include/llvm/Support/TargetOpcodes.def
  llvm/include/llvm/Target/Target.td
  llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
  llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
  llvm/test/CodeGen/X86/arithmetic_fence.ll
  llvm/test/CodeGen/X86/arithmetic_fence2.ll

Index: llvm/test/CodeGen/X86/arithmetic_fence2.ll
===
--- /dev/null
+++ llvm/test/CodeGen/X86/arithmetic_fence2.ll
@@ -0,0 +1,170 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc < %s -mtriple=i686-unknown-unknown -mattr=+sse2 | FileCheck %s --check-prefix=X86
+; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+sse2 | FileCheck %s --check-prefix=X64
+
+define double @f1(double %a) {
+; X86-LABEL: f1:
+; X86:   # %bb.0:
+; X86-NEXT:pushl %ebp
+; X86-NEXT:.cfi_def_cfa_offset 8
+; X86-NEXT:.cfi_offset %ebp, -8
+; X86-NEXT:movl %esp, %ebp
+; X86-NEXT:.cfi_def_cfa_register %ebp
+; X86-NEXT:andl $-8, %esp
+; X86-NEXT:subl $8, %esp
+; X86-NEXT:movsd {{.*#+}} xmm0 = mem[0],zero
+; X86-NEXT:mulsd {{\.?LCPI[0-9]+_[0-9]+}}, %xmm0
+; X86-NEXT:movsd %xmm0, (%esp)
+; X86-NEXT:fldl (%esp)
+; X86-NEXT:movl %ebp, %esp
+; X86-NEXT:popl %ebp
+; X86-NEXT:.cfi_def_cfa %esp, 4
+; X86-NEXT:retl
+;
+; X64-LABEL: f1:
+; X64:   # %bb.0:
+; X64-NEXT:mulsd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0
+; X64-NEXT:retq
+  %1 = fadd fast double %a, %a
+  %2 = fadd fast double %a, %a
+  %3 = fadd fast double %1, %2
+  ret double %3
+}
+
+define double @f2(double %a) {
+; X86-LABEL: f2:
+; X86:   # %bb.0:
+; X86-NEXT:pushl %ebp
+; X86-NEXT:.cfi_def_cfa_offset 8
+; X86-NEXT:.cfi_offset %ebp, -8
+; X86-NEXT:movl %esp, %ebp
+; X86-NEXT:.cfi_def_cfa_register %ebp
+; X86-NEXT:andl $-8, %esp
+; X86-NEXT:subl $8, %esp
+; X86-NEXT:movsd {{.*#+}} xmm0 = mem[0],zero
+; X86-NEXT:addsd %xmm0, %xmm0
+; X86-NEXT:movapd %xmm0, %xmm1
+; X86-NEXT:#ARITH_FENCE
+; X86-NEXT:addsd %xmm0, %xmm1
+; X86-NEXT:movsd %xmm1, (%esp)
+; X86-NEXT:fldl (%esp)
+; X86-NEXT:movl %ebp, %esp
+; X86-NEXT:popl %ebp
+; X86-NEXT:.cfi_def_cfa %esp, 4
+; X86-NEXT:retl
+;
+; X64-LABEL: f2:
+; X64:   # %bb.0:
+; X64-NEXT:addsd %xmm0, %xmm0
+; X64-NEXT:movapd %xmm0, %xmm1
+; X64-NEXT:#ARITH_FENCE
+; X64-NEXT:addsd %xmm0, %xmm1
+; X64-NEXT:movapd %xmm1, %xmm0
+; X64-NEXT:retq
+  %1 = fadd fast double %a, %a
+  %t = call double @llvm.arithmetic.fence.f64(double %1)
+  %2 = fadd fast double %a, %a
+  %3 = fadd fast double %t, %2
+  ret double %3
+}
+
+define <2 x float> @f3(<2 x float> %a) {
+; X86-LABEL: f3:
+; X86:   # %bb.0:
+; X86-NEXT:mulps {{\.?LCPI[0-9]+_[0-9]+}}, %xmm0
+; X86-NEXT:retl
+;
+; X64-LABEL: f3:
+; X64:   # %bb.0:
+; X64-NEXT:mulps {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0
+; X64-NEXT:retq
+  %1 = fadd fast <2 x float> %a, %a
+  %2 = fadd fast <2 x float> %a, %a
+  %3 = fadd fast <2 x float> %1, %2
+  ret <2 x float> %3
+}
+
+define <2 x float> @f4(<2 x float> %a) {
+; X86-LABEL: f4:
+; X86:   # %bb.0:
+; X86-NEXT:addps %xmm0, %xmm0
+; X86-NEXT:movaps %xmm0, %xmm1
+; X86-NEXT:#ARITH_FENCE
+; X86-NEXT:addps %xmm0, %xmm1
+; X86-NEXT:movaps %xmm1, %xmm0
+; X86-NEXT:retl
+;
+; X64-LABEL: f4:
+; X64:   # %bb.0:
+; X64-NEXT:addps %xmm0, %xmm0
+; X64-NEXT:movaps %xmm0, %xmm1
+; X64-NEXT:#ARITH_FENCE
+; X64-NEXT:addps %xmm0, %xmm1
+; X64-NEXT:movaps %xmm1, %xmm0
+; X64-NEXT:retq
+  %1 = fadd fast <2 x float> %a, %a
+  %t = call <2 x float> @llvm.arithmetic.fence.v2f32(<2 x float> %1)
+  %2 = fadd fast <2 x float> %a, %a
+  %3 = fadd fast <2 x float> %t, %2
+  ret <2 x float> %3
+}
+
+define <8 x float> @f5(<8 x float> %a) {
+; X86-LABEL: f5:
+; X86:   # %bb.0:
+; X86-NEXT:movaps {{.*#+}} xmm2 = [4.0E+0,4.0E+0,4.0E+0,4.0E+0]
+; X86-NEXT:mulps %xmm2, %xmm0
+; X86-NEXT:mulps %xmm2, %xmm1
+; X86-NEXT:retl
+;
+; X64-LABEL: f5:
+; X64:   # %bb.0:
+; X64-NEXT:movaps {{.*#+}} xmm2 = [4.0E+0,4.0E+0,4.0E+0,4.0E+0]
+; X64-NEXT:mulps %xmm2, %xmm0
+;

[PATCH] D104729: [clang][PATCH][nfc] Refactor TargetInfo::adjust to pass DiagnosticsEngine to allow diagnostics on target-unsupported options

2021-06-28 Thread Melanie Blower via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2c02b0c3f454: [clang][PATCH][nfc] Refactor 
TargetInfo::adjust to pass DiagnosticsEngine to… (authored by mibintc).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104729

Files:
  clang/include/clang/Basic/TargetInfo.h
  clang/lib/Basic/TargetInfo.cpp
  clang/lib/Basic/Targets/AMDGPU.cpp
  clang/lib/Basic/Targets/AMDGPU.h
  clang/lib/Basic/Targets/PPC.cpp
  clang/lib/Basic/Targets/PPC.h
  clang/lib/Basic/Targets/SPIR.h
  clang/lib/Basic/Targets/WebAssembly.cpp
  clang/lib/Basic/Targets/WebAssembly.h
  clang/lib/Frontend/ASTUnit.cpp
  clang/lib/Frontend/CompilerInstance.cpp
  clang/lib/Interpreter/Interpreter.cpp
  clang/tools/clang-import-test/clang-import-test.cpp

Index: clang/tools/clang-import-test/clang-import-test.cpp
===
--- clang/tools/clang-import-test/clang-import-test.cpp
+++ clang/tools/clang-import-test/clang-import-test.cpp
@@ -208,7 +208,7 @@
   TargetInfo *TI = TargetInfo::CreateTargetInfo(
   Ins->getDiagnostics(), Ins->getInvocation().TargetOpts);
   Ins->setTarget(TI);
-  Ins->getTarget().adjust(Ins->getLangOpts());
+  Ins->getTarget().adjust(Ins->getDiagnostics(), Ins->getLangOpts());
   Ins->createFileManager();
   Ins->createSourceManager(Ins->getFileManager());
   Ins->createPreprocessor(TU_Complete);
Index: clang/lib/Interpreter/Interpreter.cpp
===
--- clang/lib/Interpreter/Interpreter.cpp
+++ clang/lib/Interpreter/Interpreter.cpp
@@ -110,7 +110,7 @@
"Initialization failed. "
"Target is missing");
 
-  Clang->getTarget().adjust(Clang->getLangOpts());
+  Clang->getTarget().adjust(Clang->getDiagnostics(), Clang->getLangOpts());
 
   return std::move(Clang);
 }
Index: clang/lib/Frontend/CompilerInstance.cpp
===
--- clang/lib/Frontend/CompilerInstance.cpp
+++ clang/lib/Frontend/CompilerInstance.cpp
@@ -142,7 +142,7 @@
   // Inform the target of the language options.
   // FIXME: We shouldn't need to do this, the target should be immutable once
   // created. This complexity should be lifted elsewhere.
-  getTarget().adjust(getLangOpts());
+  getTarget().adjust(getDiagnostics(), getLangOpts());
 
   // Adjust target options based on codegen options.
   getTarget().adjustTargetOptions(getCodeGenOpts(), getTargetOpts());
@@ -457,7 +457,7 @@
   getSourceManager(), *HeaderInfo, *this,
   /*IdentifierInfoLookup=*/nullptr,
   /*OwnsHeaderSearch=*/true, TUKind);
-  getTarget().adjust(getLangOpts());
+  getTarget().adjust(getDiagnostics(), getLangOpts());
   PP->Initialize(getTarget(), getAuxTarget());
 
   if (PPOpts.DetailedRecord)
Index: clang/lib/Frontend/ASTUnit.cpp
===
--- clang/lib/Frontend/ASTUnit.cpp
+++ clang/lib/Frontend/ASTUnit.cpp
@@ -588,7 +588,7 @@
 //
 // FIXME: We shouldn't need to do this, the target should be immutable once
 // created. This complexity should be lifted elsewhere.
-Target->adjust(LangOpt);
+Target->adjust(PP.getDiagnostics(), LangOpt);
 
 // Initialize the preprocessor.
 PP.Initialize(*Target);
Index: clang/lib/Basic/Targets/WebAssembly.h
===
--- clang/lib/Basic/Targets/WebAssembly.h
+++ clang/lib/Basic/Targets/WebAssembly.h
@@ -138,7 +138,7 @@
 
   bool hasProtectedVisibility() const override { return false; }
 
-  void adjust(LangOptions &Opts) override;
+  void adjust(DiagnosticsEngine &Diags, LangOptions &Opts) override;
 };
 
 class LLVM_LIBRARY_VISIBILITY WebAssembly32TargetInfo
Index: clang/lib/Basic/Targets/WebAssembly.cpp
===
--- clang/lib/Basic/Targets/WebAssembly.cpp
+++ clang/lib/Basic/Targets/WebAssembly.cpp
@@ -234,7 +234,8 @@
  Builtin::FirstTSBuiltin);
 }
 
-void WebAssemblyTargetInfo::adjust(LangOptions &Opts) {
+void WebAssemblyTargetInfo::adjust(DiagnosticsEngine &Diags,
+   LangOptions &Opts) {
   // If the Atomics feature isn't available, turn off POSIXThreads and
   // ThreadModel, so that we don't predefine _REENTRANT or __STDCPP_THREADS__.
   if (!HasAtomics) {
Index: clang/lib/Basic/Targets/SPIR.h
===
--- clang/lib/Basic/Targets/SPIR.h
+++ clang/lib/Basic/Targets/SPIR.h
@@ -135,8 +135,8 @@
 AddrSpaceMap = DefaultIsGeneric ? &SPIRDefIsGenMap : &SPIRDefIsPrivMap;
   }
 
-  void adjust(LangOptions &Opts) override {
-TargetInfo::adjust

[PATCH] D100118: [clang] Add support for new builtin __arithmetic_fence to control floating point optimization, and new clang option fprotect-parens

2021-06-28 Thread Melanie Blower via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4f1238e44d80: [clang][patch][fpenv] Add builtin 
__arithmetic_fence and option fprotect-parens (authored by mibintc).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100118

Files:
  clang/docs/UsersManual.rst
  clang/include/clang/Basic/Builtins.def
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Basic/TargetInfo.h
  clang/include/clang/Driver/Options.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ExprConstant.cpp
  clang/lib/Basic/TargetInfo.cpp
  clang/lib/Basic/Targets/X86.h
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaCoroutine.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/AST/arithmetic-fence-builtin.c
  clang/test/CodeGen/arithmetic-fence-builtin.c
  clang/test/Driver/clang_f_opts.c
  clang/test/Sema/arithmetic-fence-builtin.c

Index: clang/test/Sema/arithmetic-fence-builtin.c
===
--- /dev/null
+++ clang/test/Sema/arithmetic-fence-builtin.c
@@ -0,0 +1,48 @@
+// RUN: %clang_cc1 -triple i386-pc-linux-gnu -emit-llvm -o - -verify -x c++ %s
+// RUN: %clang_cc1 -triple ppc64le -DPPC -emit-llvm -o - -verify -x c++ %s
+// RUN: not %clang_cc1 -triple ppc64le -DPPC -emit-llvm -o - -x c++ %s \
+// RUN:-fprotect-parens 2>&1 | FileCheck -check-prefix=PPC %s
+#ifndef PPC
+int v;
+template  T addT(T a, T b) {
+  T *q = __arithmetic_fence(&a);
+  // expected-error@-1 {{invalid operand of type 'float *' where floating, complex or a vector of such types is required}}
+  // expected-error@-2 {{invalid operand of type 'int *' where floating, complex or a vector of such types is required}}
+  return __arithmetic_fence(a + b);
+  // expected-error@-1 {{invalid operand of type 'int' where floating, complex or a vector of such types is required}}
+}
+int addit(int a, int b) {
+  float x, y;
+  typedef struct {
+int a, b;
+  } stype;
+  stype s;
+  s = __arithmetic_fence(s);// expected-error {{invalid operand of type 'stype' where floating, complex or a vector of such types is required}}
+  x = __arithmetic_fence(); // expected-error {{too few arguments to function call, expected 1, have 0}}
+  x = __arithmetic_fence(x, y); // expected-error {{too many arguments to function call, expected 1, have 2}}
+  // Complex is supported.
+  _Complex double cd, cd1;
+  cd = __arithmetic_fence(cd1);
+  // Vector is supported.
+  typedef float __v4hi __attribute__((__vector_size__(8)));
+  __v4hi vec1, vec2;
+  vec1 = __arithmetic_fence(vec2);
+
+  v = __arithmetic_fence(a + b); // expected-error {{invalid operand of type 'int' where floating, complex or a vector of such types is required}}
+  float f = addT(a, b);   // expected-note {{in instantiation of function template specialization 'addT' requested here}}
+  int i = addT(1, 2);   // expected-note {{in instantiation of function template specialization 'addT' requested here}}
+  constexpr float d = 1.0 + 2.0;
+  constexpr float c = __arithmetic_fence(1.0 + 2.0);
+  constexpr float e = __arithmetic_fence(d);
+  return 0;
+}
+bool func(float f1, float f2, float f3) {
+  return (f1 == f2 && f1 == f3) || f2 == f3; // Should not warn here
+}
+static_assert( __arithmetic_fence(1.0 + 2.0), "message" );
+#else
+float addit(float a, float b) {
+  return __arithmetic_fence(a+b); // expected-error {{builtin is not supported on this target}}
+}
+#endif
+//PPC: error: option '-fprotect-parens' cannot be specified on this target
Index: clang/test/Driver/clang_f_opts.c
===
--- clang/test/Driver/clang_f_opts.c
+++ clang/test/Driver/clang_f_opts.c
@@ -1,13 +1,14 @@
 // REQUIRES: clang-driver
 
 // RUN: %clang -### -S -fasm -fblocks -fbuiltin -fno-math-errno -fcommon -fpascal-strings -fno-blocks -fno-builtin -fmath-errno -fno-common -fno-pascal-strings -fblocks -fbuiltin -fmath-errno -fcommon -fpascal-strings -fsplit-stack %s 2>&1 | FileCheck -check-prefix=CHECK-OPTIONS1 %s
-// RUN: %clang -### -S -fasm -fblocks -fbuiltin -fno-math-errno -fcommon -fpascal-strings -fno-asm -fno-blocks -fno-builtin -fmath-errno -fno-common -fno-pascal-strings -fno-show-source-location -fshort-enums %s 2>&1 | FileCheck -check-prefix=CHECK-OPTIONS2 %s
+// RUN: %clang -### -S -fasm -fblocks -fbuiltin -fno-math-errno -fcommon -fpascal-strings -fno-asm -fno-blocks -fno-builtin -fmath-errno -fno-common -fno-pascal-strings -fno-show-source-location -fshort-enums -fprotect-parens %s 2>&1 | FileCheck -check-prefix=CHECK-OPTIONS2 %s
 
 // CHECK-OPTIONS1: -fsplit-stack
 // CHECK-OPTIONS1: -fgnu-keywords
 // CHECK-OPTIONS1: -fblocks
 // CHECK-OPTIONS1: -fpascal-strings
 
+// CHECK-OP

[PATCH] D104261: Thread safety analysis: Always warn when dropping locks on back edges

2021-06-28 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert added a subscriber: rupprecht.
aaronpuchert added a comment.

In D104261#2841356 , @delesley wrote:

> since it's restricted to relockable managed locks, I'm not too worried...

Not quite, it affects scoped locks with explicit unlock, which was supported 
before D49885 .

@rupprecht, can you still test patches on Google's code? Would be good to know 
if this breaks anything.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104261

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


[clang] 8815ef8 - Revert "[clang][PATCH][nfc] Refactor TargetInfo::adjust to pass DiagnosticsEngine to allow diagnostics on target-unsupported options"

2021-06-28 Thread Melanie Blower via cfe-commits

Author: Melanie Blower
Date: 2021-06-28T12:42:59-04:00
New Revision: 8815ef823c803e98f328068d1abde255296de9c3

URL: 
https://github.com/llvm/llvm-project/commit/8815ef823c803e98f328068d1abde255296de9c3
DIFF: 
https://github.com/llvm/llvm-project/commit/8815ef823c803e98f328068d1abde255296de9c3.diff

LOG: Revert "[clang][PATCH][nfc] Refactor TargetInfo::adjust to pass 
DiagnosticsEngine to allow diagnostics on target-unsupported options"

This reverts commit 2c02b0c3f45414ac6c64583e006a26113c028304.
buildbot fails

Added: 


Modified: 
clang/include/clang/Basic/TargetInfo.h
clang/lib/Basic/TargetInfo.cpp
clang/lib/Basic/Targets/AMDGPU.cpp
clang/lib/Basic/Targets/AMDGPU.h
clang/lib/Basic/Targets/PPC.cpp
clang/lib/Basic/Targets/PPC.h
clang/lib/Basic/Targets/SPIR.h
clang/lib/Basic/Targets/WebAssembly.cpp
clang/lib/Basic/Targets/WebAssembly.h
clang/lib/Frontend/ASTUnit.cpp
clang/lib/Frontend/CompilerInstance.cpp
clang/lib/Interpreter/Interpreter.cpp
clang/tools/clang-import-test/clang-import-test.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/TargetInfo.h 
b/clang/include/clang/Basic/TargetInfo.h
index 4f0cbf986b31..0e984eb29b81 100644
--- a/clang/include/clang/Basic/TargetInfo.h
+++ b/clang/include/clang/Basic/TargetInfo.h
@@ -1162,7 +1162,7 @@ class TargetInfo : public virtual TransferrableTargetInfo,
   /// Apply changes to the target information with respect to certain
   /// language options which change the target configuration and adjust
   /// the language based on the target options where applicable.
-  virtual void adjust(DiagnosticsEngine &Diags, LangOptions &Opts);
+  virtual void adjust(LangOptions &Opts);
 
   /// Adjust target options based on codegen options.
   virtual void adjustTargetOptions(const CodeGenOptions &CGOpts,

diff  --git a/clang/lib/Basic/TargetInfo.cpp b/clang/lib/Basic/TargetInfo.cpp
index 88086fa2fed7..ffd88dc75dba 100644
--- a/clang/lib/Basic/TargetInfo.cpp
+++ b/clang/lib/Basic/TargetInfo.cpp
@@ -346,7 +346,7 @@ bool TargetInfo::isTypeSigned(IntType T) {
 /// Apply changes to the target information with respect to certain
 /// language options which change the target configuration and adjust
 /// the language based on the target options where applicable.
-void TargetInfo::adjust(DiagnosticsEngine &Diags, LangOptions &Opts) {
+void TargetInfo::adjust(LangOptions &Opts) {
   if (Opts.NoBitFieldTypeAlign)
 UseBitFieldTypeAlignment = false;
 

diff  --git a/clang/lib/Basic/Targets/AMDGPU.cpp 
b/clang/lib/Basic/Targets/AMDGPU.cpp
index fac786dbcf9e..595132e2e70b 100644
--- a/clang/lib/Basic/Targets/AMDGPU.cpp
+++ b/clang/lib/Basic/Targets/AMDGPU.cpp
@@ -358,8 +358,8 @@ AMDGPUTargetInfo::AMDGPUTargetInfo(const llvm::Triple 
&Triple,
   MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 64;
 }
 
-void AMDGPUTargetInfo::adjust(DiagnosticsEngine &Diags, LangOptions &Opts) {
-  TargetInfo::adjust(Diags, Opts);
+void AMDGPUTargetInfo::adjust(LangOptions &Opts) {
+  TargetInfo::adjust(Opts);
   // ToDo: There are still a few places using default address space as private
   // address space in OpenCL, which needs to be cleaned up, then Opts.OpenCL
   // can be removed from the following line.

diff  --git a/clang/lib/Basic/Targets/AMDGPU.h 
b/clang/lib/Basic/Targets/AMDGPU.h
index 244a6e044690..fe5c61c6ba2b 100644
--- a/clang/lib/Basic/Targets/AMDGPU.h
+++ b/clang/lib/Basic/Targets/AMDGPU.h
@@ -93,7 +93,7 @@ class LLVM_LIBRARY_VISIBILITY AMDGPUTargetInfo final : public 
TargetInfo {
 
   void setAddressSpaceMap(bool DefaultIsPrivate);
 
-  void adjust(DiagnosticsEngine &Diags, LangOptions &Opts) override;
+  void adjust(LangOptions &Opts) override;
 
   uint64_t getPointerWidthV(unsigned AddrSpace) const override {
 if (isR600(getTriple()))

diff  --git a/clang/lib/Basic/Targets/PPC.cpp b/clang/lib/Basic/Targets/PPC.cpp
index d431dda97022..6860b5e5d02f 100644
--- a/clang/lib/Basic/Targets/PPC.cpp
+++ b/clang/lib/Basic/Targets/PPC.cpp
@@ -614,10 +614,10 @@ void 
PPCTargetInfo::fillValidCPUList(SmallVectorImpl &Values) const {
   Values.append(std::begin(ValidCPUNames), std::end(ValidCPUNames));
 }
 
-void PPCTargetInfo::adjust(DiagnosticsEngine &Diags, LangOptions &Opts) {
+void PPCTargetInfo::adjust(LangOptions &Opts) {
   if (HasAltivec)
 Opts.AltiVec = 1;
-  TargetInfo::adjust(Diags, Opts);
+  TargetInfo::adjust(Opts);
   if (LongDoubleFormat != &llvm::APFloat::IEEEdouble())
 LongDoubleFormat = Opts.PPCIEEELongDouble
? &llvm::APFloat::IEEEquad()

diff  --git a/clang/lib/Basic/Targets/PPC.h b/clang/lib/Basic/Targets/PPC.h
index 18ee1194c759..554f2174fee0 100644
--- a/clang/lib/Basic/Targets/PPC.h
+++ b/clang/lib/Basic/Targets/PPC.h
@@ -89,7 +89,7 @@ class LLVM_LIBRARY_VISIBILITY PPCTargetInfo : public 
TargetInfo {
   }
 
   // Set the language option for altivec based on our value.
-  void adjust(

[clang] c27e5a2 - Revert "[clang][patch][fpenv] Add builtin __arithmetic_fence and option fprotect-parens"

2021-06-28 Thread Melanie Blower via cfe-commits

Author: Melanie Blower
Date: 2021-06-28T12:42:59-04:00
New Revision: c27e5a2a8e34aaa4c6037498cd8d21df0a8e8e70

URL: 
https://github.com/llvm/llvm-project/commit/c27e5a2a8e34aaa4c6037498cd8d21df0a8e8e70
DIFF: 
https://github.com/llvm/llvm-project/commit/c27e5a2a8e34aaa4c6037498cd8d21df0a8e8e70.diff

LOG: Revert "[clang][patch][fpenv] Add builtin __arithmetic_fence and option 
fprotect-parens"

This reverts commit 4f1238e44d803b145997fa984677a6c5cdf1f417.
Buildbot fails on predecessor patch

Added: 


Modified: 
clang/docs/UsersManual.rst
clang/include/clang/Basic/Builtins.def
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/include/clang/Basic/LangOptions.def
clang/include/clang/Basic/TargetInfo.h
clang/include/clang/Driver/Options.td
clang/include/clang/Sema/Sema.h
clang/lib/AST/ExprConstant.cpp
clang/lib/Basic/TargetInfo.cpp
clang/lib/Basic/Targets/X86.h
clang/lib/CodeGen/CGBuiltin.cpp
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Sema/SemaChecking.cpp
clang/lib/Sema/SemaCoroutine.cpp
clang/lib/Sema/SemaExpr.cpp
clang/test/Driver/clang_f_opts.c

Removed: 
clang/test/AST/arithmetic-fence-builtin.c
clang/test/CodeGen/arithmetic-fence-builtin.c
clang/test/Sema/arithmetic-fence-builtin.c



diff  --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
index 9e8bac635337..244212a1336d 100644
--- a/clang/docs/UsersManual.rst
+++ b/clang/docs/UsersManual.rst
@@ -1478,26 +1478,6 @@ Note that floating-point operations performed as part of 
constant initialization
* ``maytrap`` The compiler avoids transformations that may raise exceptions 
that would not have been raised by the original code. Constant folding 
performed by the compiler is exempt from this option.
* ``strict`` The compiler ensures that all transformations strictly 
preserve the floating point exception semantics of the original code.
 
-.. option:: -f[no-]protect-parens:
-
-   This option pertains to floating-point types, complex types with
-   floating-point components, and vectors of these types. Some arithmetic
-   expression transformations that are mathematically correct and permissible
-   according to the C and C++ language standards may be incorrect when dealing
-   with floating-point types, such as reassociation and distribution. Further,
-   the optimizer may ignore parentheses when computing arithmetic expressions
-   in circumstances where the parenthesized and unparenthesized expression
-   express the same mathematical value. For example (a+b)+c is the same
-   mathematical value as a+(b+c), but the optimizer is free to evaluate the 
-   additions in any order regardless of the parentheses. When enabled, this
-   option forces the optimizer to honor the order of operations with respect
-   to parentheses in all circumstances.
-
-   Note that floating-point contraction (option `-ffp-contract=`) is disabled
-   when `-fprotect-parens` is enabled.  Also note that in safe floating-point
-   modes, such as `-ffp-model=precise` or `-ffp-model=strict`, this option
-   has no effect because the optimizer is prohibited from making unsafe
-   transformations.
 
 .. _fp-constant-eval:
 

diff  --git a/clang/include/clang/Basic/Builtins.def 
b/clang/include/clang/Basic/Builtins.def
index 33d3e6dc4e7d..5a9d0a001829 100644
--- a/clang/include/clang/Basic/Builtins.def
+++ b/clang/include/clang/Basic/Builtins.def
@@ -1657,9 +1657,6 @@ BUILTIN(__builtin_ms_va_start, "vc*&.", "nt")
 BUILTIN(__builtin_ms_va_end, "vc*&", "n")
 BUILTIN(__builtin_ms_va_copy, "vc*&c*&", "n")
 
-// Arithmetic Fence: to prevent FP reordering and reassociation optimizations
-LANGBUILTIN(__arithmetic_fence, "v.", "t", ALL_LANGUAGES)
-
 #undef BUILTIN
 #undef LIBBUILTIN
 #undef LANGBUILTIN

diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 22c2a1a39ea1..70a22fd2506a 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -8530,9 +8530,6 @@ def err_typecheck_expect_scalar_operand : Error<
   "operand of type %0 where arithmetic or pointer type is required">;
 def err_typecheck_cond_incompatible_operands : Error<
   "incompatible operand types%
diff { ($ and $)|}0,1">;
-def err_typecheck_expect_flt_or_vector : Error<
-  "invalid operand of type %0 where floating, complex or "
-  "a vector of such types is required">;
 def err_cast_selector_expr : Error<
   "cannot type cast @selector expression">;
 def ext_typecheck_cond_incompatible_pointers : ExtWarn<

diff  --git a/clang/include/clang/Basic/LangOptions.def 
b/clang/include/clang/Basic/LangOptions.def
index b18e957a58f4..465bad8d7d11 100644
--- a/clang/include/clang/Basic/LangOptions.def
+++ b/clang/include/clang/Basic/LangOptions.def
@@ -199,8 +199,6 @@ COMPATIBLE_LANGOPT(Deprecated, 1, 0, "__DEPRECATED 
p

[PATCH] D104946: [AMDGPU] Add builtin functions image_bvh_intersect_ray

2021-06-28 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl marked an inline comment as done.
yaxunl added inline comments.



Comment at: clang/include/clang/Basic/BuiltinsAMDGPU.def:221-224
+TARGET_BUILTIN(__builtin_amdgcn_image_bvh_intersect_ray, 
"V4UiUifV4fV4fV4fV4Ui", "nc", "gfx10-insts")
+TARGET_BUILTIN(__builtin_amdgcn_image_bvh_intersect_ray_h, 
"V4UiUifV4fV4hV4hV4Ui", "nc", "gfx10-insts")
+TARGET_BUILTIN(__builtin_amdgcn_image_bvh_intersect_ray_l, 
"V4UiWUifV4fV4fV4fV4Ui", "nc", "gfx10-insts")
+TARGET_BUILTIN(__builtin_amdgcn_image_bvh_intersect_ray_lh, 
"V4UiWUifV4fV4hV4hV4Ui", "nc", "gfx10-insts")

arsenm wrote:
> The intrinsic signature suggests the 1st and 4th/5th arguments are 
> overloadable. How does this handle the various supported types?
By convention, we do not define overloaded target specific clang builtins. In 
stead we use postfixes to indicate the types. In this case, we use the 
following naming convention:

h - 4/5-th args are half
d - 4/5-th args are double
l - first arg is i64

by default - 1st arg is i32, 4/5-th args are float.

Currently we are missing functions for 4/5-th args are double. I will add them.



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

https://reviews.llvm.org/D104946

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


[PATCH] D105039: [clangd] Add a flag to disable formatting of tweak edits

2021-06-28 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 354941.
kadircet added a comment.

Add a test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105039

Files:
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/refactor/Tweak.h
  clang-tools-extra/clangd/unittests/ClangdTests.cpp

Index: clang-tools-extra/clangd/unittests/ClangdTests.cpp
===
--- clang-tools-extra/clangd/unittests/ClangdTests.cpp
+++ clang-tools-extra/clangd/unittests/ClangdTests.cpp
@@ -18,12 +18,14 @@
 #include "TestTU.h"
 #include "TidyProvider.h"
 #include "URI.h"
+#include "refactor/Tweak.h"
 #include "support/MemoryTree.h"
 #include "support/Path.h"
 #include "support/Threading.h"
 #include "clang/Config/config.h"
 #include "clang/Sema/CodeCompleteConsumer.h"
 #include "clang/Tooling/ArgumentsAdjusters.h"
+#include "clang/Tooling/Core/Replacement.h"
 #include "llvm/ADT/None.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/SmallVector.h"
@@ -31,6 +33,7 @@
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Allocator.h"
 #include "llvm/Support/Errc.h"
+#include "llvm/Support/Error.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/Regex.h"
 #include "llvm/Support/VirtualFileSystem.h"
@@ -1259,6 +1262,60 @@
   ASSERT_TRUE(MT.children().count("tuscheduler"));
   EXPECT_TRUE(MT.child("tuscheduler").children().count(FooCpp));
 }
+
+TEST(ClangdServer, RespectsTweakFormatting) {
+  static constexpr const char *TweakID = "ModuleTweak";
+  static constexpr const char *NewContents = "{not;\nformatted;}";
+
+  // Contributes a tweak that generates a non-formatted insertion and disables
+  // formatting.
+  struct TweakContributingModule final : public FeatureModule {
+struct ModuleTweak final : public Tweak {
+  const char *id() const override { return TweakID; }
+  bool prepare(const Selection &Sel) override { return true; }
+  Expected apply(const Selection &Sel) override {
+auto &SM = Sel.AST->getSourceManager();
+llvm::StringRef FilePath = SM.getFilename(Sel.Cursor);
+tooling::Replacements Reps;
+llvm::cantFail(
+Reps.add(tooling::Replacement(FilePath, 0, 0, NewContents)));
+auto E = llvm::cantFail(Effect::mainFileEdit(SM, std::move(Reps)));
+E.FormatEdits = false;
+return E;
+  }
+  std::string title() const override { return id(); }
+  llvm::StringLiteral kind() const override {
+return llvm::StringLiteral("");
+  };
+};
+
+void contributeTweaks(std::vector> &Out) override {
+  Out.emplace_back(new ModuleTweak);
+}
+  };
+
+  MockFS FS;
+  MockCompilationDatabase CDB;
+  auto Opts = ClangdServer::optsForTest();
+  FeatureModuleSet Set;
+  Set.add(std::make_unique());
+  Opts.FeatureModules = &Set;
+  ClangdServer Server(CDB, FS, Opts);
+
+  auto FooCpp = testPath("foo.cpp");
+  Server.addDocument(FooCpp, "");
+  ASSERT_TRUE(Server.blockUntilIdleForTest());
+
+  // Ensure that disabled formatting is respected.
+  Notification N;
+  Server.applyTweak(FooCpp, {}, TweakID, [&](llvm::Expected E) {
+ASSERT_TRUE(static_cast(E));
+EXPECT_THAT(llvm::cantFail(E->ApplyEdits.lookup(FooCpp).apply()),
+NewContents);
+N.notify();
+  });
+  N.wait();
+}
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/refactor/Tweak.h
===
--- clang-tools-extra/clangd/refactor/Tweak.h
+++ clang-tools-extra/clangd/refactor/Tweak.h
@@ -78,6 +78,9 @@
 /// A message to be displayed to the user.
 llvm::Optional ShowMessage;
 FileEdits ApplyEdits;
+/// Whether the edits should be formatted before presenting to the client.
+/// Note that it applies to all files.
+bool FormatEdits = true;
 
 static Effect showMessage(StringRef S) {
   Effect E;
Index: clang-tools-extra/clangd/ClangdServer.cpp
===
--- clang-tools-extra/clangd/ClangdServer.cpp
+++ clang-tools-extra/clangd/ClangdServer.cpp
@@ -637,8 +637,8 @@
   Effect = T.takeError();
 }
 assert(Effect.hasValue() && "Expected at least one selection");
-if (*Effect) {
-  // Tweaks don't apply clang-format, do that centrally here.
+if (*Effect && (*Effect)->FormatEdits) {
+  // Format tweaks that require it centrally here.
   for (auto &It : (*Effect)->ApplyEdits) {
 Edit &E = It.second;
 format::FormatStyle Style =
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D104797: [WebAssembly] Implementation of global.get/set for reftypes in LLVM IR

2021-06-28 Thread Paulo Matos via Phabricator via cfe-commits
pmatos updated this revision to Diff 354945.
pmatos added a comment.

Checks for inttoptr and ptrtoint insts in wasm backend and bails out if 
necessary.

Also addresses @tlively's comments to the original patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104797

Files:
  clang/lib/Basic/Targets/WebAssembly.cpp
  llvm/include/llvm/CodeGen/TargetLowering.h
  llvm/include/llvm/CodeGen/ValueTypes.h
  llvm/lib/CodeGen/CodeGenPrepare.cpp
  llvm/lib/CodeGen/MachineOperand.cpp
  llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
  llvm/lib/CodeGen/TargetLoweringBase.cpp
  llvm/lib/CodeGen/ValueTypes.cpp
  llvm/lib/Target/WebAssembly/Utils/WebAssemblyUtilities.cpp
  llvm/lib/Target/WebAssembly/Utils/WebAssemblyUtilities.h
  llvm/lib/Target/WebAssembly/WebAssemblyFastISel.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyISD.def
  llvm/lib/Target/WebAssembly/WebAssemblyISelDAGToDAG.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.h
  llvm/lib/Target/WebAssembly/WebAssemblyInstrTable.td
  llvm/lib/Target/WebAssembly/WebAssemblyMCInstLower.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
  llvm/test/CodeGen/WebAssembly/externref-globalget.ll
  llvm/test/CodeGen/WebAssembly/externref-globalset.ll
  llvm/test/CodeGen/WebAssembly/externref-inttoptr.ll
  llvm/test/CodeGen/WebAssembly/externref-ptrtoint.ll
  llvm/test/CodeGen/WebAssembly/externref-undef.ll
  llvm/test/CodeGen/WebAssembly/externref-unsized-load.ll
  llvm/test/CodeGen/WebAssembly/externref-unsized-store.ll
  llvm/test/CodeGen/WebAssembly/funcref-call.ll
  llvm/test/CodeGen/WebAssembly/funcref-globalget.ll
  llvm/test/CodeGen/WebAssembly/funcref-globalset.ll

Index: llvm/test/CodeGen/WebAssembly/funcref-globalset.ll
===
--- /dev/null
+++ llvm/test/CodeGen/WebAssembly/funcref-globalset.ll
@@ -0,0 +1,20 @@
+; RUN: llc < %s --mtriple=wasm32-unknown-unknown -asm-verbose=false -mattr=+reference-types | FileCheck %s
+
+%func = type opaque
+%funcref = type %func addrspace(20)* ;; addrspace 20 is nonintegral
+
+@funcref_global = local_unnamed_addr addrspace(1) global %funcref undef
+
+define void @set_funcref_global(%funcref %g) {
+  ;; this generates a global.set of @funcref_global
+  store %funcref %g, %funcref addrspace(1)* @funcref_global
+  ret void
+}
+
+; CHECK-LABEL: set_funcref_global:
+; CHECK-NEXT: functype   set_funcref_global (funcref) -> ()
+; CHECK-NEXT: local.get  0
+; CHECK-NEXT: global.set funcref_global
+; CHECK-NEXT: end_function
+
+; CHECK: .globl funcref_global
Index: llvm/test/CodeGen/WebAssembly/funcref-globalget.ll
===
--- /dev/null
+++ llvm/test/CodeGen/WebAssembly/funcref-globalget.ll
@@ -0,0 +1,19 @@
+; RUN: llc < %s --mtriple=wasm32-unknown-unknown -asm-verbose=false -mattr=+reference-types | FileCheck %s
+
+%func = type opaque
+%funcref = type %func addrspace(20)* ;; addrspace 20 is nonintegral
+
+@funcref_global = local_unnamed_addr addrspace(1) global %funcref undef
+
+define %funcref @return_funcref_global() {
+  ;; this generates a global.get of @funcref_global
+  %ref = load %funcref, %funcref addrspace(1)* @funcref_global
+  ret %funcref %ref
+}
+
+; CHECK-LABEL: return_funcref_global:
+; CHECK-NEXT: .functype   return_funcref_global () -> (funcref)
+; CHECK-NEXT: global.get funcref_global
+; CHECK-NEXT: end_function
+
+; CHECK: .globl funcref_global
Index: llvm/test/CodeGen/WebAssembly/funcref-call.ll
===
--- /dev/null
+++ llvm/test/CodeGen/WebAssembly/funcref-call.ll
@@ -0,0 +1,23 @@
+; RUN: llc < %s --mtriple=wasm32-unknown-unknown -asm-verbose=false -mattr=+reference-types | FileCheck %s
+
+%func = type void ()
+%funcref = type %func addrspace(20)* ;; addrspace 20 is nonintegral
+
+define void @call_funcref(%funcref %ref) {
+  call addrspace(20) void %ref() 
+  ret void
+}
+
+; CHECK-LABEL: call_funcref:
+; CHECK-NEXT: functype   call_funcref (funcref) -> ()
+; CHECK-NEXT: i32.const 0
+; CHECK-NEXT: local.get 0
+; CHECK-NEXT: table.set __funcref_call_table
+; CHECK-NEXT: local.get 0
+; CHECK-NEXT: call_indirect __funcref_call_table, () -> ()
+; CHECK-NEXT: i32.const 0
+; CHECK-NEXT: ref.null func
+; CHECK-NEXT: table.set __funcref_call_table
+; CHECK-NEXT: end_function
+
+; CHECK: .tabletype __funcref_call_table, funcref
Index: llvm/test/CodeGen/WebAssembly/externref-unsized-store.ll
===
--- /dev/null
+++ llvm/test/CodeGen/WebAssembly/externref-unsized-store.ll
@@ -0,0 +1,11 @@
+; RUN: not llc --mtriple=wasm32-unknown-unknown -asm-verbose=false -mattr=+reference-types < %s 2>&1 | FileCheck %s --check-prefix=CHECK-ERROR
+
+%extern = type opaque
+%externref = type %extern addrspace(10)*
+
+define vo

[PATCH] D86049: RFC: Implement optional exportable wrapper function generation for objc_direct methods.

2021-06-28 Thread Dave MacLachlan via Phabricator via cfe-commits
dmaclach added a comment.

Has anything happened with this at all or did it get dropped?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86049

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


[PATCH] D86049: RFC: Implement optional exportable wrapper function generation for objc_direct methods.

2021-06-28 Thread Puyan Lotfi via Phabricator via cfe-commits
plotfi added a comment.

In D86049#2844766 , @dmaclach wrote:

> Has anything happened with this at all or did it get dropped?

I can work with you and @rjmccall to land a version of this. We can chat 
offline if you'd like too.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86049

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


[clang] 18c3c77 - Add papers adopted by the C++ committee in the June 2021 plenary

2021-06-28 Thread Aaron Ballman via cfe-commits

Author: Corentin Jabot
Date: 2021-06-28T13:45:12-04:00
New Revision: 18c3c7784975700ae463bb461487d46e74324a66

URL: 
https://github.com/llvm/llvm-project/commit/18c3c7784975700ae463bb461487d46e74324a66
DIFF: 
https://github.com/llvm/llvm-project/commit/18c3c7784975700ae463bb461487d46e74324a66.diff

LOG: Add papers adopted by the C++ committee in the June 2021 plenary

Added: 


Modified: 
clang/www/cxx_status.html

Removed: 




diff  --git a/clang/www/cxx_status.html b/clang/www/cxx_status.html
index b7f2501cbc534..8de688189e297 100755
--- a/clang/www/cxx_status.html
+++ b/clang/www/cxx_status.html
@@ -1283,6 +1283,41 @@ C++2b implementation status
   https://wg21.link/p2266r1";>P2266R1
   Clang 13
 
+
+  if consteval
+  https://wg21.link/P1938R3";>P1938R3
+  No
+
+
+  Allow duplicate attributes
+  https://wg21.link/P2156R1";>P2156R1
+  Clang 13
+
+
+  Narrowing contextual conversions to bool
+  https://wg21.link/P1401R5";>P1401R5
+  No
+
+
+  Trimming whitespaces before line splicing
+  https://wg21.link/P2223R2";>P2223R2
+  Yes
+
+
+  Make declaration order layout mandated
+  https://wg21.link/p1847r4";>P1874R4
+  Yes
+
+
+  C++ identifier syntax using UAX 31
+  https://wg21.link/P1949R7";>P1949R7
+  No
+
+
+  Mixed string literal concatenation
+  https://wg21.link/p2201r1";>P2201R1
+  Yes
+
 
 
 



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


  1   2   >