llvm-project/clang-tools-extra/clang-tidy/misc
Alex Cameron 9bb5685b21 [clang-tidy] misc-unconventional-assign-operator suggest to use rvalue references in C++03 mode
Summary:
Bugzilla: https://bugs.llvm.org/show_bug.cgi?id=27702
I wasn't sure how this type of thing is usually tested. So any advice would be appreciated.
`check-llvm`, `check-clang` and `check-clang-tools` are clean for me.
**C++98**
```
tetsuo@garland-c-16-sgp1-01:~/dev/llvm-project/test$ cat compile_commands.json
[
{
  "directory": "/home/tetsuo/dev/llvm-project/test",
  "command": "/usr/bin/c++      -std=gnu++98 -o CMakeFiles/test.dir/test.cpp.o -c /home/tetsuo/dev/llvm-project/test/test.cpp",
  "file": "/home/tetsuo/dev/llvm-project/test/test.cpp"
}
]
tetsuo@garland-c-16-sgp1-01:~/dev/llvm-project/test$ ../build/bin/clang-tidy --checks=misc-unconventional-assign-operator test.cpp
3053 warnings generated.
/home/tetsuo/dev/llvm-project/test/test.cpp:7:3: warning: operator=() should take 'Foo const&' or 'Foo' [misc-unconventional-assign-operator]
  Foo &operator=(Foo &Other) {
  ^
Suppressed 3052 warnings (3052 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
```
**C++17**
```
tetsuo@garland-c-16-sgp1-01:~/dev/llvm-project/test$ cat compile_commands.json
[
{
  "directory": "/home/tetsuo/dev/llvm-project/test",
  "command": "/usr/bin/c++      -std=gnu++17 -o CMakeFiles/test.dir/test.cpp.o -c /home/tetsuo/dev/llvm-project/test/test.cpp",
  "file": "/home/tetsuo/dev/llvm-project/test/test.cpp"
}
]
tetsuo@garland-c-16-sgp1-01:~/dev/llvm-project/test$ ../build/bin/clang-tidy --checks=misc-unconventional-assign-operator test.cpp
5377 warnings generated.
/home/tetsuo/dev/llvm-project/test/test.cpp:7:3: warning: operator=() should take 'Foo const&', 'Foo&&' or 'Foo' [misc-unconventional-assign-operator]
  Foo &operator=(Foo &Other) {
  ^
Suppressed 5376 warnings (5376 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
```

Reviewers: njames93, MaskRay, alexfh, hokein, aaron.ballman

Reviewed By: njames93

Subscribers: xazax.hun, cfe-commits

Tags: #clang-tools-extra, #clang

Differential Revision: https://reviews.llvm.org/D75901
2020-03-18 21:39:23 +00:00
..
CMakeLists.txt [clang-tidy] misc-no-recursion: a new check 2020-02-13 23:37:53 +03:00
DefinitionsInHeadersCheck.cpp [clang-tidy] Use ; as separator for HeaderFileExtensions 2020-03-09 11:32:44 -06:00
DefinitionsInHeadersCheck.h [clang-tidy] Use ; as separator for HeaderFileExtensions 2020-03-09 11:32:44 -06:00
MiscTidyModule.cpp [clang-tidy] misc-no-recursion: a new check 2020-02-13 23:37:53 +03:00
MisplacedConstCheck.cpp Extend misc-misplaced-const to detect using declarations as well as typedef 2020-01-22 15:26:11 -05:00
MisplacedConstCheck.h [clang-tidy] Switch checks to #include "ClangTidyCheck.h" 2019-03-25 12:38:26 +00:00
NewDeleteOverloadsCheck.cpp [clang-tidy] Change checks to use new isLanguageVersionSupported restriction 2020-03-03 16:43:45 +00:00
NewDeleteOverloadsCheck.h [clang-tidy] Change checks to use new isLanguageVersionSupported restriction 2020-03-03 16:43:45 +00:00
NoRecursionCheck.cpp [ADT][NFC] SCCIterator: Change hasLoop() to hasCycle() 2020-03-01 19:17:21 +02:00
NoRecursionCheck.h [clang-tidy] misc-no-recursion: a new check 2020-02-13 23:37:53 +03:00
NonCopyableObjects.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
NonCopyableObjects.h [clang-tidy] Switch checks to #include "ClangTidyCheck.h" 2019-03-25 12:38:26 +00:00
NonPrivateMemberVariablesInClassesCheck.cpp [clang-tidy] Change checks to use new isLanguageVersionSupported restriction 2020-03-03 16:43:45 +00:00
NonPrivateMemberVariablesInClassesCheck.h [clang-tidy] Change checks to use new isLanguageVersionSupported restriction 2020-03-03 16:43:45 +00:00
RedundantExpressionCheck.cpp [NFC] use hasAnyOperatorName and hasAnyOverloadedOperatorName functions in clang-tidy matchers 2020-03-10 00:42:21 +00:00
RedundantExpressionCheck.h [clang-tidy] Switch checks to #include "ClangTidyCheck.h" 2019-03-25 12:38:26 +00:00
StaticAssertCheck.cpp [NFC] use hasAnyOperatorName and hasAnyOverloadedOperatorName functions in clang-tidy matchers 2020-03-10 00:42:21 +00:00
StaticAssertCheck.h [clang-tidy] Change checks to use new isLanguageVersionSupported restriction 2020-03-03 16:43:45 +00:00
ThrowByValueCatchByReferenceCheck.cpp [clang-tidy] Change checks to use new isLanguageVersionSupported restriction 2020-03-03 16:43:45 +00:00
ThrowByValueCatchByReferenceCheck.h [clang-tidy] Change checks to use new isLanguageVersionSupported restriction 2020-03-03 16:43:45 +00:00
UnconventionalAssignOperatorCheck.cpp [clang-tidy] misc-unconventional-assign-operator suggest to use rvalue references in C++03 mode 2020-03-18 21:39:23 +00:00
UnconventionalAssignOperatorCheck.h [clang-tidy] Change checks to use new isLanguageVersionSupported restriction 2020-03-03 16:43:45 +00:00
UniqueptrResetReleaseCheck.cpp [clang-tidy] Change checks to use new isLanguageVersionSupported restriction 2020-03-03 16:43:45 +00:00
UniqueptrResetReleaseCheck.h [clang-tidy] Change checks to use new isLanguageVersionSupported restriction 2020-03-03 16:43:45 +00:00
UnusedAliasDeclsCheck.cpp [clang-tidy] Change checks to use new isLanguageVersionSupported restriction 2020-03-03 16:43:45 +00:00
UnusedAliasDeclsCheck.h [clang-tidy] Change checks to use new isLanguageVersionSupported restriction 2020-03-03 16:43:45 +00:00
UnusedParametersCheck.cpp [clang-tools-extra] Migrate llvm::make_unique to std::make_unique 2019-08-14 23:52:23 +00:00
UnusedParametersCheck.h [clang-tidy] Switch checks to #include "ClangTidyCheck.h" 2019-03-25 12:38:26 +00:00
UnusedUsingDeclsCheck.cpp [clang-tidy] Fix a false positive about C++17 deduced class template types in unused-using-decl check. 2020-02-03 16:25:10 +01:00
UnusedUsingDeclsCheck.h [clang-tidy] Switch checks to #include "ClangTidyCheck.h" 2019-03-25 12:38:26 +00:00