[llvm-branch-commits] [clang] release/19.x: [Clang] Remove the special-casing for RequiresExprBodyDecl in BuildResolvedCallExpr() after fd87d765c0 (#111277) (PR #111324)

2024-10-06 Thread via llvm-branch-commits

https://github.com/llvmbot created 
https://github.com/llvm/llvm-project/pull/111324

Backport 8c1547055eaf65003f3e6fd024195f4926ff2356

Requested by: @zyn0217

>From 98aff7d4fcf8aa2f63643915dad08df4c4c557a6 Mon Sep 17 00:00:00 2001
From: Younan Zhang 
Date: Mon, 7 Oct 2024 09:38:19 +0800
Subject: [PATCH] [Clang] Remove the special-casing for RequiresExprBodyDecl in
 BuildResolvedCallExpr() after fd87d765c0 (#111277)

The special-casing for RequiresExprBodyDecl caused a regression, as
reported in #110785.

The original fix for #84020 has been superseded by fd87d765c0, which
establishes a `DependentScopeDeclRefExpr` instead of a
`CXXDependentScopeMemberExpr` for the case in issue. So the spurious
diagnostic in #84020 would no longer occur.

This also merges the test for #84020 together with that for #110785 into
clang/test/SemaTemplate/instantiate-requires-expr.cpp.

No release note because I think this merits a backport.

Fixes #110785

(cherry picked from commit 8c1547055eaf65003f3e6fd024195f4926ff2356)
---
 clang/lib/Sema/SemaExpr.cpp   |  3 +-
 clang/lib/Sema/TreeTransform.h|  2 +-
 clang/test/SemaCXX/PR84020.cpp| 23 --
 .../instantiate-requires-expr.cpp | 31 +++
 4 files changed, 33 insertions(+), 26 deletions(-)
 delete mode 100644 clang/test/SemaCXX/PR84020.cpp

diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index f56ca398cda81c..687b1be9459219 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -6922,8 +6922,7 @@ ExprResult Sema::BuildResolvedCallExpr(Expr *Fn, 
NamedDecl *NDecl,
   }
 
   if (CXXMethodDecl *Method = dyn_cast_or_null(FDecl))
-if (!isa(CurContext) &&
-Method->isImplicitObjectMemberFunction())
+if (Method->isImplicitObjectMemberFunction())
   return ExprError(Diag(LParenLoc, diag::err_member_call_without_object)
<< Fn->getSourceRange() << 0);
 
diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h
index 51e6a4845bf6fd..0ae393524fe03a 100644
--- a/clang/lib/Sema/TreeTransform.h
+++ b/clang/lib/Sema/TreeTransform.h
@@ -13608,7 +13608,7 @@ bool 
TreeTransform::TransformOverloadExprDecls(OverloadExpr *Old,
 }
 
 AllEmptyPacks &= Decls.empty();
-  };
+  }
 
   // C++ [temp.res]/8.4.2:
   //   The program is ill-formed, no diagnostic required, if [...] lookup for
diff --git a/clang/test/SemaCXX/PR84020.cpp b/clang/test/SemaCXX/PR84020.cpp
deleted file mode 100644
index 8ea5dcc4527ae7..00
--- a/clang/test/SemaCXX/PR84020.cpp
+++ /dev/null
@@ -1,23 +0,0 @@
-// RUN: %clang_cc1 -std=c++20 -verify %s
-// RUN: %clang_cc1 -std=c++23 -verify %s
-// expected-no-diagnostics
-
-struct B {
-template 
-void foo();
-
-void bar();
-};
-
-template 
-struct A : T {
-auto foo() {
-static_assert(requires { T::template foo(); });
-static_assert(requires { T::bar(); });
-}
-};
-
-int main() {
-A a;
-a.foo();
-}
diff --git a/clang/test/SemaTemplate/instantiate-requires-expr.cpp 
b/clang/test/SemaTemplate/instantiate-requires-expr.cpp
index 20a19d731ae169..a1f5456156a06f 100644
--- a/clang/test/SemaTemplate/instantiate-requires-expr.cpp
+++ b/clang/test/SemaTemplate/instantiate-requires-expr.cpp
@@ -237,3 +237,34 @@ constexpr bool e_v = true;
 static_assert(e_v);
 
 } // namespace GH73885
+
+namespace GH84020 {
+
+struct B {
+  template  void foo();
+  void bar();
+};
+
+template  struct A : T {
+  void foo() {
+static_assert(requires { T::template foo(); });
+static_assert(requires { T::bar(); });
+  }
+};
+
+template class A;
+
+} // namespace GH84020
+
+namespace GH110785 {
+
+struct Foo {
+  static void f(auto) requires(false) {}
+  void f(int) {}
+
+  static_assert([](auto v) {
+return requires { f(v); };
+  } (0) == false);
+};
+
+} // namespace GH110785

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


[llvm-branch-commits] [clang] release/19.x: [Clang] Remove the special-casing for RequiresExprBodyDecl in BuildResolvedCallExpr() after fd87d765c0 (#111277) (PR #111324)

2024-10-06 Thread via llvm-branch-commits

https://github.com/llvmbot milestoned 
https://github.com/llvm/llvm-project/pull/111324
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] release/19.x: [Clang] Remove the special-casing for RequiresExprBodyDecl in BuildResolvedCallExpr() after fd87d765c0 (#111277) (PR #111324)

2024-10-06 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: None (llvmbot)


Changes

Backport 8c1547055eaf65003f3e6fd024195f4926ff2356

Requested by: @zyn0217

---
Full diff: https://github.com/llvm/llvm-project/pull/111324.diff


4 Files Affected:

- (modified) clang/lib/Sema/SemaExpr.cpp (+1-2) 
- (modified) clang/lib/Sema/TreeTransform.h (+1-1) 
- (removed) clang/test/SemaCXX/PR84020.cpp (-23) 
- (modified) clang/test/SemaTemplate/instantiate-requires-expr.cpp (+31) 


``diff
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index f56ca398cda81c..687b1be9459219 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -6922,8 +6922,7 @@ ExprResult Sema::BuildResolvedCallExpr(Expr *Fn, 
NamedDecl *NDecl,
   }
 
   if (CXXMethodDecl *Method = dyn_cast_or_null(FDecl))
-if (!isa(CurContext) &&
-Method->isImplicitObjectMemberFunction())
+if (Method->isImplicitObjectMemberFunction())
   return ExprError(Diag(LParenLoc, diag::err_member_call_without_object)
<< Fn->getSourceRange() << 0);
 
diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h
index 51e6a4845bf6fd..0ae393524fe03a 100644
--- a/clang/lib/Sema/TreeTransform.h
+++ b/clang/lib/Sema/TreeTransform.h
@@ -13608,7 +13608,7 @@ bool 
TreeTransform::TransformOverloadExprDecls(OverloadExpr *Old,
 }
 
 AllEmptyPacks &= Decls.empty();
-  };
+  }
 
   // C++ [temp.res]/8.4.2:
   //   The program is ill-formed, no diagnostic required, if [...] lookup for
diff --git a/clang/test/SemaCXX/PR84020.cpp b/clang/test/SemaCXX/PR84020.cpp
deleted file mode 100644
index 8ea5dcc4527ae7..00
--- a/clang/test/SemaCXX/PR84020.cpp
+++ /dev/null
@@ -1,23 +0,0 @@
-// RUN: %clang_cc1 -std=c++20 -verify %s
-// RUN: %clang_cc1 -std=c++23 -verify %s
-// expected-no-diagnostics
-
-struct B {
-template 
-void foo();
-
-void bar();
-};
-
-template 
-struct A : T {
-auto foo() {
-static_assert(requires { T::template foo(); });
-static_assert(requires { T::bar(); });
-}
-};
-
-int main() {
-A a;
-a.foo();
-}
diff --git a/clang/test/SemaTemplate/instantiate-requires-expr.cpp 
b/clang/test/SemaTemplate/instantiate-requires-expr.cpp
index 20a19d731ae169..a1f5456156a06f 100644
--- a/clang/test/SemaTemplate/instantiate-requires-expr.cpp
+++ b/clang/test/SemaTemplate/instantiate-requires-expr.cpp
@@ -237,3 +237,34 @@ constexpr bool e_v = true;
 static_assert(e_v);
 
 } // namespace GH73885
+
+namespace GH84020 {
+
+struct B {
+  template  void foo();
+  void bar();
+};
+
+template  struct A : T {
+  void foo() {
+static_assert(requires { T::template foo(); });
+static_assert(requires { T::bar(); });
+  }
+};
+
+template class A;
+
+} // namespace GH84020
+
+namespace GH110785 {
+
+struct Foo {
+  static void f(auto) requires(false) {}
+  void f(int) {}
+
+  static_assert([](auto v) {
+return requires { f(v); };
+  } (0) == false);
+};
+
+} // namespace GH110785

``




https://github.com/llvm/llvm-project/pull/111324
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang-tools-extra] release/19.x: [clang-tidy] Fix crash in modernize-use-ranges (#100427) (PR #101482)

2024-10-06 Thread Nathan James via llvm-branch-commits

njames93 wrote:

That crash is addressed in #111318. Basically the check works fine when run in 
clang-tidy with 1 source file, but failed when ran multiple times from one 
process.

https://github.com/llvm/llvm-project/pull/101482
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] [NewPM][CodeGen] Port LiveRegMatrix to NPM (PR #109938)

2024-10-06 Thread Akshat Oke via llvm-branch-commits


@@ -57,15 +59,21 @@ class LiveRegMatrix : public MachineFunctionPass {
   unsigned RegMaskVirtReg = 0;
   BitVector RegMaskUsable;
 
-  // MachineFunctionPass boilerplate.
-  void getAnalysisUsage(AnalysisUsage &) const override;
-  bool runOnMachineFunction(MachineFunction &) override;
-  void releaseMemory() override;
+  LiveRegMatrix() = default;
+  void releaseMemory();
 
 public:
-  static char ID;
-
-  LiveRegMatrix();
+  LiveRegMatrix(LiveRegMatrix &&Other)

Akshat-Oke wrote:

One for the `make_unique` in `MFAM.getResult` and another in internals - 
`AnalysisPassModel` constructor.

https://github.com/llvm/llvm-project/pull/109938
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] [NewPM][CodeGen] Port LiveRegMatrix to NPM (PR #109938)

2024-10-06 Thread Akshat Oke via llvm-branch-commits

https://github.com/Akshat-Oke edited 
https://github.com/llvm/llvm-project/pull/109938
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [Flang][OpenMP] Derived type explicit allocatable member mapping (PR #111192)

2024-10-06 Thread Kareem Ergawy via llvm-branch-commits

https://github.com/ergawy commented:

First round, just reading through some tests to make sure I understand the 
effect of the changes. Will continue later. Thanks Andrew!

https://github.com/llvm/llvm-project/pull/92
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [Flang][OpenMP] Derived type explicit allocatable member mapping (PR #111192)

2024-10-06 Thread Kareem Ergawy via llvm-branch-commits

https://github.com/ergawy edited 
https://github.com/llvm/llvm-project/pull/92
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [Flang][OpenMP] Derived type explicit allocatable member mapping (PR #111192)

2024-10-06 Thread Kareem Ergawy via llvm-branch-commits


@@ -0,0 +1,161 @@
+!RUN: %flang_fc1 -emit-hlfir -fopenmp %s -o - | FileCheck %s
+
+!CHECK: %[[ALLOCA:.*]] = fir.alloca 
!fir.type<_QFtest_derived_type_allocatable_map_operand_and_block_additionTone_layer{i:f32,scalar:!fir.box>,array_i:!fir.array<10xi32>,j:f32,array_j:!fir.box>>,k:i32}>
 {bindc_name = "one_l", uniq_name = 
"_QFtest_derived_type_allocatable_map_operand_and_block_additionEone_l"}
+!CHECK: %[[DECLARE:.*]]:2 = hlfir.declare %[[ALLOCA]] {uniq_name = 
"_QFtest_derived_type_allocatable_map_operand_and_block_additionEone_l"} : 
(!fir.ref>,array_i:!fir.array<10xi32>,j:f32,array_j:!fir.box>>,k:i32}>>)
 -> 
(!fir.ref>,array_i:!fir.array<10xi32>,j:f32,array_j:!fir.box>>,k:i32}>>,
 
!fir.ref>,array_i:!fir.array<10xi32>,j:f32,array_j:!fir.box>>,k:i32}>>)
+!CHECK: %[[BOUNDS:.*]] = omp.map.bounds lower_bound({{.*}}) 
upper_bound({{.*}}) extent({{.*}}) stride({{.*}}) start_idx({{.*}}) 
{stride_in_bytes = true}
+!CHECK: %[[MEMBER_INDEX:.*]] = arith.constant 4 : index
+!CHECK: %[[MEMBER_COORD:.*]] = fir.coordinate_of %[[DECLARE]]#0, 
%[[MEMBER_INDEX]] : 
(!fir.ref>,array_i:!fir.array<10xi32>,j:f32,array_j:!fir.box>>,k:i32}>>,
 index) -> !fir.ref>>>
+!CHECK: %[[MEMBER_BASE_ADDR:.*]] = fir.box_offset %[[MEMBER_COORD]] base_addr 
: (!fir.ref>>>) -> 
!fir.llvm_ptr>>
+!CHECK: %[[MAP_MEMBER_BASE_ADDR:.*]] = omp.map.info var_ptr(%[[MEMBER_COORD]] 
: !fir.ref>>>, !fir.array) 
var_ptr_ptr(%[[MEMBER_BASE_ADDR]] : !fir.llvm_ptr>>) 
map_clauses(tofrom) capture(ByRef) bounds(%[[BOUNDS]]) -> 
!fir.llvm_ptr>> {name = ""}
+!CHECK: %[[MAP_MEMBER_DESCRIPTOR:.*]] = omp.map.info var_ptr(%[[MEMBER_COORD]] 
: !fir.ref>>>, 
!fir.box>>) map_clauses(to) capture(ByRef) -> 
!fir.ref>>> {name = "one_l%array_j"}
+!CHECK: %[[MAP_PARENT:.*]] = omp.map.info var_ptr(%[[DECLARE]]#1 : 
!fir.ref>,array_i:!fir.array<10xi32>,j:f32,array_j:!fir.box>>,k:i32}>>,
 
!fir.type<_QFtest_derived_type_allocatable_map_operand_and_block_additionTone_layer{i:f32,scalar:!fir.box>,array_i:!fir.array<10xi32>,j:f32,array_j:!fir.box>>,k:i32}>)
 map_clauses(tofrom) capture(ByRef) members(%[[MAP_MEMBER_DESCRIPTOR]], 
%[[MAP_MEMBER_BASE_ADDR]] : [4], [4,0] : 
!fir.ref>>>, 
!fir.llvm_ptr>>) -> 
!fir.ref>,array_i:!fir.array<10xi32>,j:f32,array_j:!fir.box>>,k:i32}>>
 {name = "one_l", partial_map = true}
+!CHECK:   omp.target map_entries(%[[MAP_MEMBER_DESCRIPTOR]] -> %[[ARG0:.*]], 
%[[MAP_MEMBER_BASE_ADDR]] -> %[[ARG1:.*]], %[[MAP_PARENT]] -> %[[ARG2:.*]] : 
!fir.ref>>>, 
!fir.llvm_ptr>>, 
!fir.ref>,array_i:!fir.array<10xi32>,j:f32,array_j:!fir.box>>,k:i32}>>)
 {
+!CHECK:%{{.*}}:2 = hlfir.declare %[[ARG2]] {uniq_name = 
"_QFtest_derived_type_allocatable_map_operand_and_block_additionEone_l"} : 
(!fir.ref>,array_i:!fir.array<10xi32>,j:f32,array_j:!fir.box>>,k:i32}>>)
 -> 
(!fir.ref>,array_i:!fir.array<10xi32>,j:f32,array_j:!fir.box>>,k:i32}>>,
 
!fir.ref>,array_i:!fir.array<10xi32>,j:f32,array_j:!fir.box>>,k:i32}>>)
+subroutine test_derived_type_allocatable_map_operand_and_block_addition()
+type :: one_layer
+real(4) :: i
+integer, allocatable :: scalar
+integer(4) :: array_i(10)
+real(4) :: j
+integer, allocatable :: array_j(:)
+integer(4) :: k
+end type one_layer
+
+type(one_layer) :: one_l
+
+allocate(one_l%array_j(10))
+
+!$omp target map(tofrom: one_l%array_j)
+one_l%array_j(1) = 10
+!$omp end target
+end subroutine
+
+!CHECK: %[[ALLOCA:.*]] = fir.alloca 
!fir.box>,array_i:!fir.array<10xi32>,j:f32,array_j:!fir.box>>,k:i32}>>>
 {bindc_name = "one_l", uniq_name = 
"_QFtest_allocatable_derived_type_map_operand_and_block_additionEone_l"}
+!CHECK: %[[DECLARE:.*]]:2 = hlfir.declare %[[ALLOCA]] {fortran_attrs = 
#fir.var_attrs, uniq_name = 
"_QFtest_allocatable_derived_type_map_operand_and_block_additionEone_l"} : 
(!fir.ref>,array_i:!fir.array<10xi32>,j:f32,array_j:!fir.box>>,k:i32})
 -> 
(!fir.ref>,array_i:!fir.array<10xi32>,j:f32,array_j:!fir.box>>,k:i32},
 
!fir.ref>,array_i:!fir.array<10xi32>,j:f32,array_j:!fir.box>>,k:i32})
+!CHECK: %[[BOUNDS:.*]] = omp.map.bounds lower_bound({{.*}}) 
upper_bound({{.*}}) extent({{.*}}) stride({{.*}}) start_idx({{.*}}) 
{stride_in_bytes = true}
+!CHECK: %[[LOAD_DTYPE:.*]] = fir.load %[[DECLARE]]#0 : 
!fir.ref>,array_i:!fir.array<10xi32>,j:f32,array_j:!fir.box>>,k:i32}
+!CHECK: %[[MEMBER_INDEX:.*]] = arith.constant 4 : index
+!CHECK: %[[MEMBER_COORD:.*]] = fir.coordinate_of %[[LOAD_DTYPE]], 
%[[MEMBER_INDEX]] : 
(!fir.box>,array_i:!fir.array<10xi32>,j:f32,array_j:!fir.box>>,k:i32}>>>,
 index) -> !fir.ref>>>
+!CHECK: %[[MEMBER_BASE_ADDR:.*]] = fir.box_offset %[[MEMBER_COORD]] base_addr 
: (!fir.ref>>>) -> 
!fir.llvm_ptr>>
+!CHECK: %[[MAP_MEMBER_BASE_ADDR:.*]] = omp.map.info var_ptr(%[[MEMBER_COORD]] 
: !fir.ref>>>, !fir.array) 
var_ptr_ptr(%[[MEMBER_BASE_ADDR]] : !fir.llvm_ptr>>) 
map_clauses(tofrom) capture(ByRef) bounds(%[[BOUNDS]]) -> 
!fir.llvm_ptr>> {name = ""}
+!CHECK: %[[MAP_MEMBER_DESC:.*]] = omp.map.info var_ptr(%[[MEMBER_COORD]] : 

[llvm-branch-commits] [Flang][OpenMP] Derived type explicit allocatable member mapping (PR #111192)

2024-10-06 Thread Kareem Ergawy via llvm-branch-commits


@@ -0,0 +1,161 @@
+!RUN: %flang_fc1 -emit-hlfir -fopenmp %s -o - | FileCheck %s

ergawy wrote:

In the whole file, can you capture the names of longs types in FileCheck 
variables and use the captured type names to improve readability and reduce 
line lengths a bit?

https://github.com/llvm/llvm-project/pull/92
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [Flang][OpenMP] Derived type explicit allocatable member mapping (PR #111192)

2024-10-06 Thread Kareem Ergawy via llvm-branch-commits


@@ -0,0 +1,161 @@
+!RUN: %flang_fc1 -emit-hlfir -fopenmp %s -o - | FileCheck %s
+
+!CHECK: %[[ALLOCA:.*]] = fir.alloca 
!fir.type<_QFtest_derived_type_allocatable_map_operand_and_block_additionTone_layer{i:f32,scalar:!fir.box>,array_i:!fir.array<10xi32>,j:f32,array_j:!fir.box>>,k:i32}>
 {bindc_name = "one_l", uniq_name = 
"_QFtest_derived_type_allocatable_map_operand_and_block_additionEone_l"}
+!CHECK: %[[DECLARE:.*]]:2 = hlfir.declare %[[ALLOCA]] {uniq_name = 
"_QFtest_derived_type_allocatable_map_operand_and_block_additionEone_l"} : 
(!fir.ref>,array_i:!fir.array<10xi32>,j:f32,array_j:!fir.box>>,k:i32}>>)
 -> 
(!fir.ref>,array_i:!fir.array<10xi32>,j:f32,array_j:!fir.box>>,k:i32}>>,
 
!fir.ref>,array_i:!fir.array<10xi32>,j:f32,array_j:!fir.box>>,k:i32}>>)
+!CHECK: %[[BOUNDS:.*]] = omp.map.bounds lower_bound({{.*}}) 
upper_bound({{.*}}) extent({{.*}}) stride({{.*}}) start_idx({{.*}}) 
{stride_in_bytes = true}
+!CHECK: %[[MEMBER_INDEX:.*]] = arith.constant 4 : index
+!CHECK: %[[MEMBER_COORD:.*]] = fir.coordinate_of %[[DECLARE]]#0, 
%[[MEMBER_INDEX]] : 
(!fir.ref>,array_i:!fir.array<10xi32>,j:f32,array_j:!fir.box>>,k:i32}>>,
 index) -> !fir.ref>>>
+!CHECK: %[[MEMBER_BASE_ADDR:.*]] = fir.box_offset %[[MEMBER_COORD]] base_addr 
: (!fir.ref>>>) -> 
!fir.llvm_ptr>>
+!CHECK: %[[MAP_MEMBER_BASE_ADDR:.*]] = omp.map.info var_ptr(%[[MEMBER_COORD]] 
: !fir.ref>>>, !fir.array) 
var_ptr_ptr(%[[MEMBER_BASE_ADDR]] : !fir.llvm_ptr>>) 
map_clauses(tofrom) capture(ByRef) bounds(%[[BOUNDS]]) -> 
!fir.llvm_ptr>> {name = ""}
+!CHECK: %[[MAP_MEMBER_DESCRIPTOR:.*]] = omp.map.info var_ptr(%[[MEMBER_COORD]] 
: !fir.ref>>>, 
!fir.box>>) map_clauses(to) capture(ByRef) -> 
!fir.ref>>> {name = "one_l%array_j"}
+!CHECK: %[[MAP_PARENT:.*]] = omp.map.info var_ptr(%[[DECLARE]]#1 : 
!fir.ref>,array_i:!fir.array<10xi32>,j:f32,array_j:!fir.box>>,k:i32}>>,
 
!fir.type<_QFtest_derived_type_allocatable_map_operand_and_block_additionTone_layer{i:f32,scalar:!fir.box>,array_i:!fir.array<10xi32>,j:f32,array_j:!fir.box>>,k:i32}>)
 map_clauses(tofrom) capture(ByRef) members(%[[MAP_MEMBER_DESCRIPTOR]], 
%[[MAP_MEMBER_BASE_ADDR]] : [4], [4,0] : 
!fir.ref>>>, 
!fir.llvm_ptr>>) -> 
!fir.ref>,array_i:!fir.array<10xi32>,j:f32,array_j:!fir.box>>,k:i32}>>
 {name = "one_l", partial_map = true}
+!CHECK:   omp.target map_entries(%[[MAP_MEMBER_DESCRIPTOR]] -> %[[ARG0:.*]], 
%[[MAP_MEMBER_BASE_ADDR]] -> %[[ARG1:.*]], %[[MAP_PARENT]] -> %[[ARG2:.*]] : 
!fir.ref>>>, 
!fir.llvm_ptr>>, 
!fir.ref>,array_i:!fir.array<10xi32>,j:f32,array_j:!fir.box>>,k:i32}>>)
 {
+!CHECK:%{{.*}}:2 = hlfir.declare %[[ARG2]] {uniq_name = 
"_QFtest_derived_type_allocatable_map_operand_and_block_additionEone_l"} : 
(!fir.ref>,array_i:!fir.array<10xi32>,j:f32,array_j:!fir.box>>,k:i32}>>)
 -> 
(!fir.ref>,array_i:!fir.array<10xi32>,j:f32,array_j:!fir.box>>,k:i32}>>,
 
!fir.ref>,array_i:!fir.array<10xi32>,j:f32,array_j:!fir.box>>,k:i32}>>)
+subroutine test_derived_type_allocatable_map_operand_and_block_addition()
+type :: one_layer
+real(4) :: i
+integer, allocatable :: scalar
+integer(4) :: array_i(10)
+real(4) :: j
+integer, allocatable :: array_j(:)
+integer(4) :: k
+end type one_layer
+
+type(one_layer) :: one_l
+
+allocate(one_l%array_j(10))
+
+!$omp target map(tofrom: one_l%array_j)
+one_l%array_j(1) = 10
+!$omp end target
+end subroutine
+
+!CHECK: %[[ALLOCA:.*]] = fir.alloca 
!fir.box>,array_i:!fir.array<10xi32>,j:f32,array_j:!fir.box>>,k:i32}>>>
 {bindc_name = "one_l", uniq_name = 
"_QFtest_allocatable_derived_type_map_operand_and_block_additionEone_l"}
+!CHECK: %[[DECLARE:.*]]:2 = hlfir.declare %[[ALLOCA]] {fortran_attrs = 
#fir.var_attrs, uniq_name = 
"_QFtest_allocatable_derived_type_map_operand_and_block_additionEone_l"} : 
(!fir.ref>,array_i:!fir.array<10xi32>,j:f32,array_j:!fir.box>>,k:i32})
 -> 
(!fir.ref>,array_i:!fir.array<10xi32>,j:f32,array_j:!fir.box>>,k:i32},
 
!fir.ref>,array_i:!fir.array<10xi32>,j:f32,array_j:!fir.box>>,k:i32})
+!CHECK: %[[BOUNDS:.*]] = omp.map.bounds lower_bound({{.*}}) 
upper_bound({{.*}}) extent({{.*}}) stride({{.*}}) start_idx({{.*}}) 
{stride_in_bytes = true}
+!CHECK: %[[LOAD_DTYPE:.*]] = fir.load %[[DECLARE]]#0 : 
!fir.ref>,array_i:!fir.array<10xi32>,j:f32,array_j:!fir.box>>,k:i32}
+!CHECK: %[[MEMBER_INDEX:.*]] = arith.constant 4 : index
+!CHECK: %[[MEMBER_COORD:.*]] = fir.coordinate_of %[[LOAD_DTYPE]], 
%[[MEMBER_INDEX]] : 
(!fir.box>,array_i:!fir.array<10xi32>,j:f32,array_j:!fir.box>>,k:i32}>>>,
 index) -> !fir.ref>>>
+!CHECK: %[[MEMBER_BASE_ADDR:.*]] = fir.box_offset %[[MEMBER_COORD]] base_addr 
: (!fir.ref>>>) -> 
!fir.llvm_ptr>>
+!CHECK: %[[MAP_MEMBER_BASE_ADDR:.*]] = omp.map.info var_ptr(%[[MEMBER_COORD]] 
: !fir.ref>>>, !fir.array) 
var_ptr_ptr(%[[MEMBER_BASE_ADDR]] : !fir.llvm_ptr>>) 
map_clauses(tofrom) capture(ByRef) bounds(%[[BOUNDS]]) -> 
!fir.llvm_ptr>> {name = ""}
+!CHECK: %[[MAP_MEMBER_DESC:.*]] = omp.map.info var_ptr(%[[MEMBER_COORD]] : 

[llvm-branch-commits] [clang] [MSVC] work-around for compile time issue 102513 (PR #111314)

2024-10-06 Thread Timm Baeder via llvm-branch-commits

https://github.com/tbaederr approved this pull request.


https://github.com/llvm/llvm-project/pull/111314
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] [AArch64][PAC] Move emission of LR checks in tail calls to AsmPrinter (PR #110705)

2024-10-06 Thread Daniil Kovalev via llvm-branch-commits

kovdan01 wrote:

@atrosinenko Here is a reproducer IR code.



```
define void @_ZN7myshape4moveEv(ptr %this) #0 {
entry:
  %0 = load ptr, ptr %this, align 8
  %vtable = load ptr, ptr %0, align 8
  %1 = ptrtoint ptr %0 to i64
  %2 = tail call i64 @llvm.ptrauth.blend(i64 %1, i64 50297)
  %3 = ptrtoint ptr %vtable to i64
  %4 = tail call i64 @llvm.ptrauth.auth(i64 %3, i32 2, i64 %2)
  %5 = inttoptr i64 %4 to ptr
  %6 = load ptr, ptr %5, align 8
  %7 = tail call i64 @llvm.ptrauth.blend(i64 %4, i64 36564)
  tail call void %6(ptr noundef nonnull align 8 dereferenceable(8) %0) [ 
"ptrauth"(i32 0, i64 %7) ]
  %r = getelementptr inbounds i8, ptr %this, i64 8
  %8 = load ptr, ptr %r, align 8
  %vtable2 = load ptr, ptr %8, align 8
  %9 = ptrtoint ptr %8 to i64
  %10 = tail call i64 @llvm.ptrauth.blend(i64 %9, i64 50297)
  %11 = ptrtoint ptr %vtable2 to i64
  %12 = tail call i64 @llvm.ptrauth.auth(i64 %11, i32 2, i64 %10)
  %13 = inttoptr i64 %12 to ptr
  %14 = load ptr, ptr %13, align 8
  %15 = tail call i64 @llvm.ptrauth.blend(i64 %12, i64 36564)
  tail call void %14(ptr noundef nonnull align 8 dereferenceable(8) %8) [ 
"ptrauth"(i32 0, i64 %15) ]
  ret void
}

declare i64 @llvm.ptrauth.blend(i64, i64)

declare i64 @llvm.ptrauth.auth(i64, i32 immarg, i64)

attributes #0 = { "ptrauth-auth-traps" "ptrauth-calls" "ptrauth-returns" }
```



When compiled with `llc -O3 -mtriple aarch64-linux-gnu -mattr=+pauth`, the 
following assembly is generated. X16 register is clobbered during check 
inserted under `else if (Method == AuthCheckMethod::HighBitsNoTBI)`. The 
previous value (containing pointer for address discrimination) is not spilled 
before and not restored after that. So, the last `braa` instructio uses 
incorrect discrimination value in X16 register, which results in authentication 
failure and trying to pass control to an address with non-zero pac field, 
causing a segfault. nProbably, a different scratch register (e.g. X17) should 
be used for check sequence if X16 is already in use for address discrimination.



```
_ZN7myshape4moveEv: // @_ZN7myshape4moveEv
.cfi_startproc
// %bb.0:   // %entry
.cfi_b_key_frame
pacibsp
stp x30, x19, [sp, #-16]!   // 16-byte Folded Spill
.cfi_negate_ra_state
.cfi_def_cfa_offset 16
.cfi_offset w19, -8
.cfi_offset w30, -16
mov x19, x0
ldr x0, [x0]
ldr x16, [x0]
mov x17, x0
movkx17, #50297, lsl #48
autda   x16, x17
mov x17, x16
xpacd   x17
cmp x16, x17
b.eq.Lauth_success_0
brk #0xc472
.Lauth_success_0:
ldr x9, [x16]
mov x8, x16
mov x17, x8
movkx17, #36564, lsl #48
blraa   x9, x17
ldr x0, [x19, #8]
ldr x16, [x0]
mov x17, x0
movkx17, #50297, lsl #48
autda   x16, x17
mov x17, x16
xpacd   x17
cmp x16, x17
b.eq.Lauth_success_1
brk #0xc472
.Lauth_success_1:
ldr x1, [x16]
ldp x30, x19, [sp], #16 // 16-byte Folded Reload
autibsp
eor x16, x30, x30, lsl #1
tbz x16, #62, .Lauth_success_2
brk #0xc471
.Lauth_success_2:
movkx16, #36564, lsl #48
braax1, x16
```



The IR corresponds to the following C++ code.



```
struct shape {
  virtual void move() = 0;
};

struct line : public shape {
  void move () override;
};

struct myshape {
  line *l;
  line *r;
  void move();
};

void myshape::move() {
  l->move();
  r->move();
}
```




https://github.com/llvm/llvm-project/pull/110705
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] [AArch64][PAC] Move emission of LR checks in tail calls to AsmPrinter (PR #110705)

2024-10-06 Thread Daniil Kovalev via llvm-branch-commits

https://github.com/kovdan01 requested changes to this pull request.

See https://github.com/llvm/llvm-project/pull/110705#issuecomment-2396047508

https://github.com/llvm/llvm-project/pull/110705
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] release/19.x: [Clang] Remove the special-casing for RequiresExprBodyDecl in BuildResolvedCallExpr() after fd87d765c0 (#111277) (PR #111324)

2024-10-06 Thread via llvm-branch-commits

llvmbot wrote:

@mizvekov What do you think about merging this PR to the release branch?

https://github.com/llvm/llvm-project/pull/111324
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] release/19.x: [Clang] Remove the special-casing for RequiresExprBodyDecl in BuildResolvedCallExpr() after fd87d765c0 (#111277) (PR #111324)

2024-10-06 Thread Matheus Izvekov via llvm-branch-commits

https://github.com/mizvekov approved this pull request.


https://github.com/llvm/llvm-project/pull/111324
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang-tools-extra] release/19.x: [clang-tidy] Avoid capturing a local variable in a static lambda in UseRangesCheck (#111282) (PR #111318)

2024-10-06 Thread via llvm-branch-commits

https://github.com/llvmbot milestoned 
https://github.com/llvm/llvm-project/pull/111318
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang-tools-extra] release/19.x: [clang-tidy] Avoid capturing a local variable in a static lambda in UseRangesCheck (#111282) (PR #111318)

2024-10-06 Thread via llvm-branch-commits

https://github.com/llvmbot created 
https://github.com/llvm/llvm-project/pull/111318

Backport acf92a47c0ece8562fd745215c478fe2d4ab5896

Requested by: @HighCommander4

>From 1ce51790c94018d5843103abcda048c4cdc242f8 Mon Sep 17 00:00:00 2001
From: Nathan Ridge 
Date: Sun, 6 Oct 2024 18:13:36 -0400
Subject: [PATCH] [clang-tidy] Avoid capturing a local variable in a static
 lambda in UseRangesCheck (#111282)

Fixes https://github.com/llvm/llvm-project/issues/109367

(cherry picked from commit acf92a47c0ece8562fd745215c478fe2d4ab5896)
---
 .../clang-tidy/boost/UseRangesCheck.cpp| 18 +-
 .../clangd/unittests/ClangdLSPServerTests.cpp  | 16 
 2 files changed, 25 insertions(+), 9 deletions(-)

diff --git a/clang-tools-extra/clang-tidy/boost/UseRangesCheck.cpp 
b/clang-tools-extra/clang-tidy/boost/UseRangesCheck.cpp
index 4022ea0cdaf5ee..e45687fde6d9f6 100644
--- a/clang-tools-extra/clang-tidy/boost/UseRangesCheck.cpp
+++ b/clang-tools-extra/clang-tidy/boost/UseRangesCheck.cpp
@@ -204,7 +204,7 @@ utils::UseRangesCheck::ReplacerMap 
UseRangesCheck::getReplacerMap() const {
   ReplacerMap Results;
   static const Signature SingleSig = {{0}};
   static const Signature TwoSig = {{0}, {2}};
-  static const auto AddFrom =
+  const auto AddFrom =
   [&Results](llvm::IntrusiveRefCntPtr Replacer,
  std::initializer_list Names, StringRef Prefix) {
 llvm::SmallString<64> Buffer;
@@ -214,17 +214,17 @@ utils::UseRangesCheck::ReplacerMap 
UseRangesCheck::getReplacerMap() const {
 }
   };
 
-  static const auto AddFromStd =
-  [](llvm::IntrusiveRefCntPtr Replacer,
- std::initializer_list Names) {
+  const auto AddFromStd =
+  [&](llvm::IntrusiveRefCntPtr Replacer,
+  std::initializer_list Names) {
 AddFrom(Replacer, Names, "std");
   };
 
-  static const auto AddFromBoost =
-  [](llvm::IntrusiveRefCntPtr Replacer,
- std::initializer_list<
- std::pair>>
- NamespaceAndNames) {
+  const auto AddFromBoost =
+  [&](llvm::IntrusiveRefCntPtr Replacer,
+  std::initializer_list<
+  std::pair>>
+  NamespaceAndNames) {
 for (auto [Namespace, Names] : NamespaceAndNames)
   AddFrom(Replacer, Names,
   SmallString<64>{"boost", (Namespace.empty() ? "" : "::"),
diff --git a/clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp 
b/clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp
index 75a140767035b2..49a94045ea4878 100644
--- a/clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp
+++ b/clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp
@@ -262,6 +262,22 @@ TEST_F(LSPTest, ClangTidyRename) {
   EXPECT_EQ(Params, std::vector{llvm::json::Value(std::move(ExpectedEdit))});
 }
 
+TEST_F(LSPTest, ClangTidyCrash_Issue109367) {
+  // This test requires clang-tidy checks to be linked in.
+  if (!CLANGD_TIDY_CHECKS)
+return;
+  Opts.ClangTidyProvider = [](tidy::ClangTidyOptions &ClangTidyOpts,
+  llvm::StringRef) {
+ClangTidyOpts.Checks = {"-*,boost-use-ranges"};
+  };
+  // Check that registering the boost-use-ranges checker's matchers
+  // on two different threads does not cause a crash.
+  auto &Client = start();
+  Client.didOpen("a.cpp", "");
+  Client.didOpen("b.cpp", "");
+  Client.sync();
+}
+
 TEST_F(LSPTest, IncomingCalls) {
   Annotations Code(R"cpp(
 void calle^e(int);

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


[llvm-branch-commits] [clang-tools-extra] release/19.x: [clang-tidy] Avoid capturing a local variable in a static lambda in UseRangesCheck (#111282) (PR #111318)

2024-10-06 Thread via llvm-branch-commits

llvmbot wrote:

@hokein What do you think about merging this PR to the release branch?

https://github.com/llvm/llvm-project/pull/111318
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang-tools-extra] release/19.x: [clang-tidy] Avoid capturing a local variable in a static lambda in UseRangesCheck (#111282) (PR #111318)

2024-10-06 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-tidy

Author: None (llvmbot)


Changes

Backport acf92a47c0ece8562fd745215c478fe2d4ab5896

Requested by: @HighCommander4

---
Full diff: https://github.com/llvm/llvm-project/pull/111318.diff


2 Files Affected:

- (modified) clang-tools-extra/clang-tidy/boost/UseRangesCheck.cpp (+9-9) 
- (modified) clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp (+16) 


``diff
diff --git a/clang-tools-extra/clang-tidy/boost/UseRangesCheck.cpp 
b/clang-tools-extra/clang-tidy/boost/UseRangesCheck.cpp
index 4022ea0cdaf5ee..e45687fde6d9f6 100644
--- a/clang-tools-extra/clang-tidy/boost/UseRangesCheck.cpp
+++ b/clang-tools-extra/clang-tidy/boost/UseRangesCheck.cpp
@@ -204,7 +204,7 @@ utils::UseRangesCheck::ReplacerMap 
UseRangesCheck::getReplacerMap() const {
   ReplacerMap Results;
   static const Signature SingleSig = {{0}};
   static const Signature TwoSig = {{0}, {2}};
-  static const auto AddFrom =
+  const auto AddFrom =
   [&Results](llvm::IntrusiveRefCntPtr Replacer,
  std::initializer_list Names, StringRef Prefix) {
 llvm::SmallString<64> Buffer;
@@ -214,17 +214,17 @@ utils::UseRangesCheck::ReplacerMap 
UseRangesCheck::getReplacerMap() const {
 }
   };
 
-  static const auto AddFromStd =
-  [](llvm::IntrusiveRefCntPtr Replacer,
- std::initializer_list Names) {
+  const auto AddFromStd =
+  [&](llvm::IntrusiveRefCntPtr Replacer,
+  std::initializer_list Names) {
 AddFrom(Replacer, Names, "std");
   };
 
-  static const auto AddFromBoost =
-  [](llvm::IntrusiveRefCntPtr Replacer,
- std::initializer_list<
- std::pair>>
- NamespaceAndNames) {
+  const auto AddFromBoost =
+  [&](llvm::IntrusiveRefCntPtr Replacer,
+  std::initializer_list<
+  std::pair>>
+  NamespaceAndNames) {
 for (auto [Namespace, Names] : NamespaceAndNames)
   AddFrom(Replacer, Names,
   SmallString<64>{"boost", (Namespace.empty() ? "" : "::"),
diff --git a/clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp 
b/clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp
index 75a140767035b2..49a94045ea4878 100644
--- a/clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp
+++ b/clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp
@@ -262,6 +262,22 @@ TEST_F(LSPTest, ClangTidyRename) {
   EXPECT_EQ(Params, std::vector{llvm::json::Value(std::move(ExpectedEdit))});
 }
 
+TEST_F(LSPTest, ClangTidyCrash_Issue109367) {
+  // This test requires clang-tidy checks to be linked in.
+  if (!CLANGD_TIDY_CHECKS)
+return;
+  Opts.ClangTidyProvider = [](tidy::ClangTidyOptions &ClangTidyOpts,
+  llvm::StringRef) {
+ClangTidyOpts.Checks = {"-*,boost-use-ranges"};
+  };
+  // Check that registering the boost-use-ranges checker's matchers
+  // on two different threads does not cause a crash.
+  auto &Client = start();
+  Client.didOpen("a.cpp", "");
+  Client.didOpen("b.cpp", "");
+  Client.sync();
+}
+
 TEST_F(LSPTest, IncomingCalls) {
   Annotations Code(R"cpp(
 void calle^e(int);

``




https://github.com/llvm/llvm-project/pull/111318
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang-tools-extra] release/19.x: [clang-tidy] Avoid capturing a local variable in a static lambda in UseRangesCheck (#111282) (PR #111318)

2024-10-06 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-tools-extra

Author: None (llvmbot)


Changes

Backport acf92a47c0ece8562fd745215c478fe2d4ab5896

Requested by: @HighCommander4

---
Full diff: https://github.com/llvm/llvm-project/pull/111318.diff


2 Files Affected:

- (modified) clang-tools-extra/clang-tidy/boost/UseRangesCheck.cpp (+9-9) 
- (modified) clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp (+16) 


``diff
diff --git a/clang-tools-extra/clang-tidy/boost/UseRangesCheck.cpp 
b/clang-tools-extra/clang-tidy/boost/UseRangesCheck.cpp
index 4022ea0cdaf5ee..e45687fde6d9f6 100644
--- a/clang-tools-extra/clang-tidy/boost/UseRangesCheck.cpp
+++ b/clang-tools-extra/clang-tidy/boost/UseRangesCheck.cpp
@@ -204,7 +204,7 @@ utils::UseRangesCheck::ReplacerMap 
UseRangesCheck::getReplacerMap() const {
   ReplacerMap Results;
   static const Signature SingleSig = {{0}};
   static const Signature TwoSig = {{0}, {2}};
-  static const auto AddFrom =
+  const auto AddFrom =
   [&Results](llvm::IntrusiveRefCntPtr Replacer,
  std::initializer_list Names, StringRef Prefix) {
 llvm::SmallString<64> Buffer;
@@ -214,17 +214,17 @@ utils::UseRangesCheck::ReplacerMap 
UseRangesCheck::getReplacerMap() const {
 }
   };
 
-  static const auto AddFromStd =
-  [](llvm::IntrusiveRefCntPtr Replacer,
- std::initializer_list Names) {
+  const auto AddFromStd =
+  [&](llvm::IntrusiveRefCntPtr Replacer,
+  std::initializer_list Names) {
 AddFrom(Replacer, Names, "std");
   };
 
-  static const auto AddFromBoost =
-  [](llvm::IntrusiveRefCntPtr Replacer,
- std::initializer_list<
- std::pair>>
- NamespaceAndNames) {
+  const auto AddFromBoost =
+  [&](llvm::IntrusiveRefCntPtr Replacer,
+  std::initializer_list<
+  std::pair>>
+  NamespaceAndNames) {
 for (auto [Namespace, Names] : NamespaceAndNames)
   AddFrom(Replacer, Names,
   SmallString<64>{"boost", (Namespace.empty() ? "" : "::"),
diff --git a/clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp 
b/clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp
index 75a140767035b2..49a94045ea4878 100644
--- a/clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp
+++ b/clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp
@@ -262,6 +262,22 @@ TEST_F(LSPTest, ClangTidyRename) {
   EXPECT_EQ(Params, std::vector{llvm::json::Value(std::move(ExpectedEdit))});
 }
 
+TEST_F(LSPTest, ClangTidyCrash_Issue109367) {
+  // This test requires clang-tidy checks to be linked in.
+  if (!CLANGD_TIDY_CHECKS)
+return;
+  Opts.ClangTidyProvider = [](tidy::ClangTidyOptions &ClangTidyOpts,
+  llvm::StringRef) {
+ClangTidyOpts.Checks = {"-*,boost-use-ranges"};
+  };
+  // Check that registering the boost-use-ranges checker's matchers
+  // on two different threads does not cause a crash.
+  auto &Client = start();
+  Client.didOpen("a.cpp", "");
+  Client.didOpen("b.cpp", "");
+  Client.sync();
+}
+
 TEST_F(LSPTest, IncomingCalls) {
   Annotations Code(R"cpp(
 void calle^e(int);

``




https://github.com/llvm/llvm-project/pull/111318
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang-tools-extra] release/19.x: [clang-tidy] Avoid capturing a local variable in a static lambda in UseRangesCheck (#111282) (PR #111318)

2024-10-06 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-clangd

Author: None (llvmbot)


Changes

Backport acf92a47c0ece8562fd745215c478fe2d4ab5896

Requested by: @HighCommander4

---
Full diff: https://github.com/llvm/llvm-project/pull/111318.diff


2 Files Affected:

- (modified) clang-tools-extra/clang-tidy/boost/UseRangesCheck.cpp (+9-9) 
- (modified) clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp (+16) 


``diff
diff --git a/clang-tools-extra/clang-tidy/boost/UseRangesCheck.cpp 
b/clang-tools-extra/clang-tidy/boost/UseRangesCheck.cpp
index 4022ea0cdaf5ee..e45687fde6d9f6 100644
--- a/clang-tools-extra/clang-tidy/boost/UseRangesCheck.cpp
+++ b/clang-tools-extra/clang-tidy/boost/UseRangesCheck.cpp
@@ -204,7 +204,7 @@ utils::UseRangesCheck::ReplacerMap 
UseRangesCheck::getReplacerMap() const {
   ReplacerMap Results;
   static const Signature SingleSig = {{0}};
   static const Signature TwoSig = {{0}, {2}};
-  static const auto AddFrom =
+  const auto AddFrom =
   [&Results](llvm::IntrusiveRefCntPtr Replacer,
  std::initializer_list Names, StringRef Prefix) {
 llvm::SmallString<64> Buffer;
@@ -214,17 +214,17 @@ utils::UseRangesCheck::ReplacerMap 
UseRangesCheck::getReplacerMap() const {
 }
   };
 
-  static const auto AddFromStd =
-  [](llvm::IntrusiveRefCntPtr Replacer,
- std::initializer_list Names) {
+  const auto AddFromStd =
+  [&](llvm::IntrusiveRefCntPtr Replacer,
+  std::initializer_list Names) {
 AddFrom(Replacer, Names, "std");
   };
 
-  static const auto AddFromBoost =
-  [](llvm::IntrusiveRefCntPtr Replacer,
- std::initializer_list<
- std::pair>>
- NamespaceAndNames) {
+  const auto AddFromBoost =
+  [&](llvm::IntrusiveRefCntPtr Replacer,
+  std::initializer_list<
+  std::pair>>
+  NamespaceAndNames) {
 for (auto [Namespace, Names] : NamespaceAndNames)
   AddFrom(Replacer, Names,
   SmallString<64>{"boost", (Namespace.empty() ? "" : "::"),
diff --git a/clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp 
b/clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp
index 75a140767035b2..49a94045ea4878 100644
--- a/clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp
+++ b/clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp
@@ -262,6 +262,22 @@ TEST_F(LSPTest, ClangTidyRename) {
   EXPECT_EQ(Params, std::vector{llvm::json::Value(std::move(ExpectedEdit))});
 }
 
+TEST_F(LSPTest, ClangTidyCrash_Issue109367) {
+  // This test requires clang-tidy checks to be linked in.
+  if (!CLANGD_TIDY_CHECKS)
+return;
+  Opts.ClangTidyProvider = [](tidy::ClangTidyOptions &ClangTidyOpts,
+  llvm::StringRef) {
+ClangTidyOpts.Checks = {"-*,boost-use-ranges"};
+  };
+  // Check that registering the boost-use-ranges checker's matchers
+  // on two different threads does not cause a crash.
+  auto &Client = start();
+  Client.didOpen("a.cpp", "");
+  Client.didOpen("b.cpp", "");
+  Client.sync();
+}
+
 TEST_F(LSPTest, IncomingCalls) {
   Annotations Code(R"cpp(
 void calle^e(int);

``




https://github.com/llvm/llvm-project/pull/111318
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] [MSVC] work-around for compile time issue 102513 (PR #111314)

2024-10-06 Thread via llvm-branch-commits

https://github.com/bd1976bris created 
https://github.com/llvm/llvm-project/pull/111314

Manual cherry-pick of #110986 to the LLVM 19 release branch.

>From c4b52d9d07533084090a183c263477feb9b195f5 Mon Sep 17 00:00:00 2001
From: bd1976bris 
Date: Sun, 6 Oct 2024 22:47:02 +0100
Subject: [PATCH] [MSVC] work-around for compile time issue 102513

Manual cherry-pick of #110986 to the LLVM 19 release branch.
---
 clang/lib/AST/Interp/Interp.cpp | 8 
 1 file changed, 8 insertions(+)

diff --git a/clang/lib/AST/Interp/Interp.cpp b/clang/lib/AST/Interp/Interp.cpp
index 6fcd90e5f58498..0f9eedc3f38ea1 100644
--- a/clang/lib/AST/Interp/Interp.cpp
+++ b/clang/lib/AST/Interp/Interp.cpp
@@ -925,6 +925,10 @@ void diagnoseEnumValue(InterpState &S, CodePtr OpPC, const 
EnumDecl *ED,
   }
 }
 
+// https://github.com/llvm/llvm-project/issues/102513
+#if defined(_WIN32) && !defined(__clang__) && !defined(NDEBUG)
+#pragma optimize("", off)
+#endif
 bool Interpret(InterpState &S, APValue &Result) {
   // The current stack frame when we started Interpret().
   // This is being used by the ops to determine wheter
@@ -949,6 +953,10 @@ bool Interpret(InterpState &S, APValue &Result) {
 }
   }
 }
+// https://github.com/llvm/llvm-project/issues/102513
+#if defined(_WIN32) && !defined(__clang__) && !defined(NDEBUG)
+#pragma optimize("", on)
+#endif
 
 } // namespace interp
 } // namespace clang

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


[llvm-branch-commits] [clang] [MSVC] work-around for compile time issue 102513 (PR #111314)

2024-10-06 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: bd1976bris (bd1976bris)


Changes

Manual cherry-pick of #110986 to the LLVM 19 release branch.

---
Full diff: https://github.com/llvm/llvm-project/pull/111314.diff


1 Files Affected:

- (modified) clang/lib/AST/Interp/Interp.cpp (+8) 


``diff
diff --git a/clang/lib/AST/Interp/Interp.cpp b/clang/lib/AST/Interp/Interp.cpp
index 6fcd90e5f58498..0f9eedc3f38ea1 100644
--- a/clang/lib/AST/Interp/Interp.cpp
+++ b/clang/lib/AST/Interp/Interp.cpp
@@ -925,6 +925,10 @@ void diagnoseEnumValue(InterpState &S, CodePtr OpPC, const 
EnumDecl *ED,
   }
 }
 
+// https://github.com/llvm/llvm-project/issues/102513
+#if defined(_WIN32) && !defined(__clang__) && !defined(NDEBUG)
+#pragma optimize("", off)
+#endif
 bool Interpret(InterpState &S, APValue &Result) {
   // The current stack frame when we started Interpret().
   // This is being used by the ops to determine wheter
@@ -949,6 +953,10 @@ bool Interpret(InterpState &S, APValue &Result) {
 }
   }
 }
+// https://github.com/llvm/llvm-project/issues/102513
+#if defined(_WIN32) && !defined(__clang__) && !defined(NDEBUG)
+#pragma optimize("", on)
+#endif
 
 } // namespace interp
 } // namespace clang

``




https://github.com/llvm/llvm-project/pull/111314
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits