[clang-tools-extra] [clang-tidy] Fix assert in performance-unnecessary-copy-init. (PR #96506)

2024-06-25 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `clang-arm64-windows-msvc` 
running on `linaro-armv8-windows-msvc-04` while building `clang-tools-extra` at 
step 4 "build stage 1".

Full details are available at: 
https://lab.llvm.org/buildbot/#/builders/161/builds/174

Here is the relevant piece of the build log for the reference:
```
Step 4 (build stage 1) failure: 'ninja' (failure)
...
[6095/7474] Linking CXX static library lib\clangTidyMain.lib
[6096/7474] Linking CXX executable bin\clang-include-cleaner.exe
[6097/7474] Building CXX object 
tools/clang/tools/extra/clangd/CMakeFiles/obj.clangDaemon.dir/ClangdServer.cpp.obj
[6098/7474] Building CXX object 
tools/clang/tools/extra/clangd/CMakeFiles/obj.clangDaemon.dir/FileDistance.cpp.obj
[6099/7474] Linking CXX executable bin\clang-tidy.exe
[6100/7474] Building CXX object 
tools/clang/tools/extra/clangd/CMakeFiles/obj.clangDaemon.dir/FS.cpp.obj
[6101/7474] Building CXX object 
tools/clang/tools/extra/clangd/CMakeFiles/obj.clangDaemon.dir/FuzzyMatch.cpp.obj
[6102/7474] Building CXX object 
tools/clang/tools/extra/clangd/CMakeFiles/obj.clangDaemon.dir/CodeComplete.cpp.obj
[6103/7474] Building CXX object 
tools/clang/tools/extra/clangd/CMakeFiles/obj.clangDaemon.dir/CompileCommands.cpp.obj
[6104/7474] Building CXX object 
tools/clang/tools/extra/clangd/CMakeFiles/obj.clangDaemon.dir/Format.cpp.obj
FAILED: 
tools/clang/tools/extra/clangd/CMakeFiles/obj.clangDaemon.dir/Format.cpp.obj 
ccache C:\PROGRA~1\LLVM\bin\clang-cl.exe  /nologo -TP -DGTEST_HAS_RTTI=0 
-DUNICODE -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_NONSTDC_NO_WARNINGS 
-D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS -D_GLIBCXX_ASSERTIONS 
-D_HAS_EXCEPTIONS=0 -D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS 
-D_UNICODE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS 
-D__STDC_LIMIT_MACROS 
-IC:/Users/tcwg/llvm-worker/clang-arm64-windows-msvc/stage1/tools/clang/tools/extra/clangd
 
-IC:/Users/tcwg/llvm-worker/clang-arm64-windows-msvc/llvm/clang-tools-extra/clangd
 
-IC:/Users/tcwg/llvm-worker/clang-arm64-windows-msvc/llvm/clang-tools-extra/clangd/../include-cleaner/include
 
-IC:/Users/tcwg/llvm-worker/clang-arm64-windows-msvc/stage1/tools/clang/tools/extra/clangd/../clang-tidy
 -IC:/Users/tcwg/llvm-worker/clang-arm64-windows-msvc/llvm/clang/include 
-IC:/Users/tcwg/llvm-worker/clang-arm64-windows-msvc/stage1/tools/clang/include 
-IC:/Users/tcwg/llvm-worker/clang-arm64-windows-msvc/stage1/include 
-IC:/Users/tcwg/llvm-worker/clang-arm64-windows-msvc/llvm/llvm/include 
-IC:/Users/tcwg/llvm-worker/clang-arm64-windows-msvc/llvm/clang-tools-extra/pseudo/lib/../include
 /DWIN32 /D_WINDOWS   /Zc:inline /Zc:__cplusplus /Oi /Brepro /bigobj 
/permissive- -Werror=unguarded-availability-new /W4  -Wextra 
-Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers 
-Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type 
-Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override 
-Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported /Gw /O2 
/Ob2  -MD  /EHs-c- /GR- -UNDEBUG -std:c++17 /showIncludes 
/Fotools/clang/tools/extra/clangd/CMakeFiles/obj.clangDaemon.dir/Format.cpp.obj 
/Fdtools\clang\tools\extra\clangd\CMakeFiles\obj.clangDaemon.dir\ -c -- 
C:/Users/tcwg/llvm-worker/clang-arm64-windows-msvc/llvm/clang-tools-extra/clangd/Format.cpp
C:/Users/tcwg/llvm-worker/clang-arm64-windows-msvc/llvm/clang-tools-extra/clangd/Format.cpp(284,11):
 error: no member named 'KeepEmptyLinesAtTheStartOfBlocks' in 
'clang::format::FormatStyle'
  284 | Style.KeepEmptyLinesAtTheStartOfBlocks = true;
  | ~ ^
1 error generated.
[6105/7474] Building CXX object 
tools/clang/tools/extra/clangd/CMakeFiles/obj.clangDaemon.dir/FindSymbols.cpp.obj
[6106/7474] Building CXX object 
tools/clang/tools/extra/clangd/CMakeFiles/obj.clangDaemon.dir/Diagnostics.cpp.obj
[6107/7474] Building CXX object 
tools/clang/tools/extra/clangd/CMakeFiles/obj.clangDaemon.dir/ClangdLSPServer.cpp.obj
[6108/7474] Building CXX object 
tools/clang/tools/extra/clangd/CMakeFiles/obj.clangDaemon.dir/AST.cpp.obj
[6109/7474] Building CXX object 
tools/clang/tools/extra/clangd/CMakeFiles/obj.clangDaemon.dir/GlobalCompilationDatabase.cpp.obj
[6110/7474] Building CXX object 
tools/clang/tools/extra/clangd/CMakeFiles/obj.clangDaemon.dir/Headers.cpp.obj
[6111/7474] Building CXX object 
tools/clang/tools/extra/clangd/CMakeFiles/obj.clangDaemon.dir/DumpAST.cpp.obj
[6112/7474] Building CXX object 
tools/clang/tools/extra/clangd/CMakeFiles/obj.clangDaemon.dir/HeaderSourceSwitch.cpp.obj
[6113/7474] Building CXX object 
tools/clang/tools/extra/clangd/CMakeFiles/obj.clangDaemon.dir/FindTarget.cpp.obj
ninja: build stopped: subcommand failed.

```

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


[clang-tools-extra] [clang-tidy] Fix assert in performance-unnecessary-copy-init. (PR #96506)

2024-06-24 Thread Clement Courbet via cfe-commits

https://github.com/legrosbuffle closed 
https://github.com/llvm/llvm-project/pull/96506
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clang-tidy] Fix assert in performance-unnecessary-copy-init. (PR #96506)

2024-06-24 Thread Clement Courbet via cfe-commits

https://github.com/legrosbuffle updated 
https://github.com/llvm/llvm-project/pull/96506

>From 834b63adeea098ec2d815a85fe47e7577ff3baa9 Mon Sep 17 00:00:00 2001
From: Clement Courbet 
Date: Mon, 24 Jun 2024 15:05:48 +
Subject: [PATCH] [clang-tidy] Fix assert in performance-unnecessary-copy-init.

`GetDirectCallee` can be null.

Fixes #96498.
---
 clang-tools-extra/clang-tidy/utils/DeclRefExprUtils.cpp  | 2 +-
 clang-tools-extra/docs/ReleaseNotes.rst  | 2 +-
 .../performance/unnecessary-copy-initialization.cpp  | 9 +
 3 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/clang-tools-extra/clang-tidy/utils/DeclRefExprUtils.cpp 
b/clang-tools-extra/clang-tidy/utils/DeclRefExprUtils.cpp
index a6062ccf42230..106feb7fb4172 100644
--- a/clang-tools-extra/clang-tidy/utils/DeclRefExprUtils.cpp
+++ b/clang-tools-extra/clang-tidy/utils/DeclRefExprUtils.cpp
@@ -296,7 +296,7 @@ AST_MATCHER_P(DeclRefExpr, doesNotMutateObject, int, 
Indirections) {
   return false;
 }
 const auto *const Method =
-dyn_cast(OpCall->getDirectCallee());
+dyn_cast_or_null(OpCall->getDirectCallee());
 
 if (Method == nullptr) {
   // This is not a member operator. Typically, a friend operator. These
diff --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index 16fdc20eafd62..7fcf5cfbe3783 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -398,7 +398,7 @@ Changes in existing checks
   analyzed, so the check now handles the common patterns
   `const auto e = (*vector_ptr)[i]` and `const auto e = vector_ptr->at(i);`.
   Calls to mutable function where there exists a `const` overload are also
-  handled.
+  handled. Fix crash in the case of a non-member operator call.
 
 - Improved :doc:`readability-avoid-return-with-void-value
   ` check by adding
diff --git 
a/clang-tools-extra/test/clang-tidy/checkers/performance/unnecessary-copy-initialization.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/performance/unnecessary-copy-initialization.cpp
index f259552dc8f1d..d02bb98cf583c 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/performance/unnecessary-copy-initialization.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/performance/unnecessary-copy-initialization.cpp
@@ -906,3 +906,12 @@ void negativeNonConstMemberExpr() {
   }
 }
 
+
+bool operator==(ExpensiveToCopyType, ExpensiveToCopyType);
+
+template bool OperatorWithNoDirectCallee(T t) {
+  ExpensiveToCopyType a1;
+  ExpensiveToCopyType a2 = a1;
+  return a1 == t;
+}
+

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


[clang-tools-extra] [clang-tidy] Fix assert in performance-unnecessary-copy-init. (PR #96506)

2024-06-24 Thread Piotr Zegar via cfe-commits

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


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


[clang-tools-extra] [clang-tidy] Fix assert in performance-unnecessary-copy-init. (PR #96506)

2024-06-24 Thread Congcong Cai via cfe-commits

https://github.com/HerrCai0907 edited 
https://github.com/llvm/llvm-project/pull/96506
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clang-tidy] Fix assert in performance-unnecessary-copy-init. (PR #96506)

2024-06-24 Thread Congcong Cai via cfe-commits

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

lgtm

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


[clang-tools-extra] [clang-tidy] Fix assert in performance-unnecessary-copy-init. (PR #96506)

2024-06-24 Thread via cfe-commits

llvmbot wrote:




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

Author: Clement Courbet (legrosbuffle)


Changes

`GetDirectCallee` can be null.

Fixes #96498.

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


2 Files Affected:

- (modified) clang-tools-extra/clang-tidy/utils/DeclRefExprUtils.cpp (+1-1) 
- (modified) 
clang-tools-extra/test/clang-tidy/checkers/performance/unnecessary-copy-initialization.cpp
 (+9) 


``diff
diff --git a/clang-tools-extra/clang-tidy/utils/DeclRefExprUtils.cpp 
b/clang-tools-extra/clang-tidy/utils/DeclRefExprUtils.cpp
index a6062ccf42230..106feb7fb4172 100644
--- a/clang-tools-extra/clang-tidy/utils/DeclRefExprUtils.cpp
+++ b/clang-tools-extra/clang-tidy/utils/DeclRefExprUtils.cpp
@@ -296,7 +296,7 @@ AST_MATCHER_P(DeclRefExpr, doesNotMutateObject, int, 
Indirections) {
   return false;
 }
 const auto *const Method =
-dyn_cast(OpCall->getDirectCallee());
+dyn_cast_or_null(OpCall->getDirectCallee());
 
 if (Method == nullptr) {
   // This is not a member operator. Typically, a friend operator. These
diff --git 
a/clang-tools-extra/test/clang-tidy/checkers/performance/unnecessary-copy-initialization.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/performance/unnecessary-copy-initialization.cpp
index f259552dc8f1d..d02bb98cf583c 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/performance/unnecessary-copy-initialization.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/performance/unnecessary-copy-initialization.cpp
@@ -906,3 +906,12 @@ void negativeNonConstMemberExpr() {
   }
 }
 
+
+bool operator==(ExpensiveToCopyType, ExpensiveToCopyType);
+
+template bool OperatorWithNoDirectCallee(T t) {
+  ExpensiveToCopyType a1;
+  ExpensiveToCopyType a2 = a1;
+  return a1 == t;
+}
+

``




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


[clang-tools-extra] [clang-tidy] Fix assert in performance-unnecessary-copy-init. (PR #96506)

2024-06-24 Thread Clement Courbet via cfe-commits

https://github.com/legrosbuffle created 
https://github.com/llvm/llvm-project/pull/96506

`GetDirectCallee` can be null.

Fixes #96498.

>From 5034dc92f9098874471b3f035fceb8275629b37a Mon Sep 17 00:00:00 2001
From: Clement Courbet 
Date: Mon, 24 Jun 2024 15:05:48 +
Subject: [PATCH] [clang-tidy] Fix assert in performance-unnecessary-copy-init.

`GetDirectCallee` can be null.

Fixes #96498.
---
 clang-tools-extra/clang-tidy/utils/DeclRefExprUtils.cpp  | 2 +-
 .../performance/unnecessary-copy-initialization.cpp  | 9 +
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/clang-tools-extra/clang-tidy/utils/DeclRefExprUtils.cpp 
b/clang-tools-extra/clang-tidy/utils/DeclRefExprUtils.cpp
index a6062ccf42230..106feb7fb4172 100644
--- a/clang-tools-extra/clang-tidy/utils/DeclRefExprUtils.cpp
+++ b/clang-tools-extra/clang-tidy/utils/DeclRefExprUtils.cpp
@@ -296,7 +296,7 @@ AST_MATCHER_P(DeclRefExpr, doesNotMutateObject, int, 
Indirections) {
   return false;
 }
 const auto *const Method =
-dyn_cast(OpCall->getDirectCallee());
+dyn_cast_or_null(OpCall->getDirectCallee());
 
 if (Method == nullptr) {
   // This is not a member operator. Typically, a friend operator. These
diff --git 
a/clang-tools-extra/test/clang-tidy/checkers/performance/unnecessary-copy-initialization.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/performance/unnecessary-copy-initialization.cpp
index f259552dc8f1d..d02bb98cf583c 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/performance/unnecessary-copy-initialization.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/performance/unnecessary-copy-initialization.cpp
@@ -906,3 +906,12 @@ void negativeNonConstMemberExpr() {
   }
 }
 
+
+bool operator==(ExpensiveToCopyType, ExpensiveToCopyType);
+
+template bool OperatorWithNoDirectCallee(T t) {
+  ExpensiveToCopyType a1;
+  ExpensiveToCopyType a2 = a1;
+  return a1 == t;
+}
+

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