Bug 1551842 - Add new clang-tidy checkers from clang 8.0.0. r=sylvestre,froydnj

Differential Revision: https://phabricator.services.mozilla.com/D31229

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Andi-Bogdan Postelnicu 2019-05-22 14:55:45 +00:00
Родитель dfd51d4000
Коммит ca4a195007
13 изменённых файлов: 62 добавлений и 0 удалений

Просмотреть файл

@ -62,6 +62,8 @@ clang_checkers:
reliability: high
- name: bugprone-swapped-arguments
reliability: high
- name: bugprone-too-small-loop-variable
reliability: high
- name: bugprone-unused-raii
reliability: high
- name: bugprone-use-after-move
@ -120,6 +122,8 @@ clang_checkers:
reliability: high
- name: clang-analyzer-unix.cstring.NullArg
reliability: high
- name: cppcoreguidelines-narrowing-conversions
reliability: high
- name: misc-non-copyable-objects
reliability: high
- name: misc-redundant-expression
@ -133,6 +137,8 @@ clang_checkers:
- win32
- win64
reliability: medium
- name: modernize-deprecated-ios-base-aliases
reliability: high
- name: modernize-loop-convert
reliability: high
- name: modernize-raw-string-literal
@ -191,6 +197,8 @@ clang_checkers:
reliability: high
- name: readability-braces-around-statements
reliability: high
- name: readability-const-return-type
reliability: high
# Note: this can be loosened up by using the ShortStatementLines option
- name: readability-container-size-empty
reliability: high
@ -211,6 +219,12 @@ clang_checkers:
value: 1
- name: readability-inconsistent-declaration-parameter-name
reliability: high
- name: readability-isolate-declaration
reliability: high
- name: readability-magic-numbers
# Bug 1553495 - we must see first its impact on our code.
publish: !!bool no
reliability: high
- name: readability-misleading-indentation
reliability: high
- name: readability-non-const-parameter

Просмотреть файл

@ -0,0 +1,4 @@
int main() {
long size = 294967296l;
for (short i = 0; i < size; ++i) {}
}

Просмотреть файл

@ -0,0 +1 @@
[["warning", "loop variable has narrower type 'short' than iteration's upper bound 'long'", "bugprone-too-small-loop-variable"], {"reliability": "high"}]

Просмотреть файл

@ -0,0 +1,4 @@
class Foo {
int f;
void a_f(double val) { f = val;}
};

Просмотреть файл

@ -0,0 +1 @@
[["warning", "narrowing conversion from 'double' to 'int'", "cppcoreguidelines-narrowing-conversions"], {"reliability": "high"}]

Просмотреть файл

@ -0,0 +1,18 @@
namespace std {
class ios_base {
public:
typedef int io_state;
typedef int open_mode;
typedef int seek_dir;
typedef int streampos;
typedef int streamoff;
};
template <class CharT>
class basic_ios : public ios_base {
};
} // namespace std
// Test function return values (declaration)
std::ios_base::io_state f_5();

Просмотреть файл

@ -0,0 +1 @@
[["warning", "'std::ios_base::io_state' is deprecated; use 'std::ios_base::iostate' instead", "modernize-deprecated-ios-base-aliases"], {"reliability": "high"}]

Просмотреть файл

@ -0,0 +1,5 @@
const int p1() {
// CHECK-MESSAGES: [[@LINE-1]]:1: warning: return type 'const int' is 'const'-qualified at the top level, which may reduce code readability without improving const correctness
// CHECK-FIXES: int p1() {
return 1;
}

Просмотреть файл

@ -0,0 +1 @@
[["warning", "return type 'const int' is 'const'-qualified at the top level, which may reduce code readability without improving const correctness", "readability-const-return-type"], {"reliability": "high"}]

Просмотреть файл

@ -0,0 +1,7 @@
void f() {
int * pointer = nullptr, value = 42, * const const_ptr = &value;
// This declaration will be diagnosed and transformed into:
// int * pointer = nullptr;
// int value = 42;
// int * const const_ptr = &value;
}

Просмотреть файл

@ -0,0 +1 @@
[["warning", "multiple declarations in a single statement reduces readability", "readability-isolate-declaration"], {"reliability": "high"}]

Просмотреть файл

@ -0,0 +1,4 @@
void func() {
int radius = 2;
double circleArea = 3.1415926535 * radius * radius;
}

Просмотреть файл

@ -0,0 +1 @@
[["warning", "3.1415926535 is a magic number; consider replacing it with a named constant", "readability-magic-numbers"], {"reliability": "high"}]