mirror of
https://github.com/zebrajr/pytorch.git
synced 2025-12-06 12:20:52 +01:00
Enable misc clang-tidy checks (#110283)
This PR enables the misc-XX checks in clang-tidy. Meanwhile, I excluded some of them that require a lot of code changes and have no immediate benefits. Some additional fixes and suppression were also given. Pull Request resolved: https://github.com/pytorch/pytorch/pull/110283 Approved by: https://github.com/albanD
This commit is contained in:
parent
2ead6c2f6e
commit
d0ad848aa5
|
|
@ -30,8 +30,13 @@ cppcoreguidelines-*,
|
||||||
-facebook-hte-RelativeInclude,
|
-facebook-hte-RelativeInclude,
|
||||||
hicpp-exception-baseclass,
|
hicpp-exception-baseclass,
|
||||||
hicpp-avoid-goto,
|
hicpp-avoid-goto,
|
||||||
misc-unused-alias-decls,
|
misc-*,
|
||||||
misc-unused-using-decls,
|
-misc-const-correctness,
|
||||||
|
-misc-use-anonymous-namespace,
|
||||||
|
-misc-unused-parameters,
|
||||||
|
-misc-no-recursion,
|
||||||
|
-misc-non-private-member-variables-in-classes,
|
||||||
|
-misc-confusable-identifiers,
|
||||||
modernize-*,
|
modernize-*,
|
||||||
-modernize-concat-nested-namespaces,
|
-modernize-concat-nested-namespaces,
|
||||||
-modernize-macro-to-enum,
|
-modernize-macro-to-enum,
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@ void ThrowEnforceNotMet(
|
||||||
if (FLAGS_caffe2_use_fatal_for_enforce) {
|
if (FLAGS_caffe2_use_fatal_for_enforce) {
|
||||||
LOG(FATAL) << e.msg();
|
LOG(FATAL) << e.msg();
|
||||||
}
|
}
|
||||||
throw e;
|
throw std::move(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ThrowEnforceNotMet(
|
void ThrowEnforceNotMet(
|
||||||
|
|
|
||||||
|
|
@ -79,8 +79,7 @@ void NUMAMove(void* ptr, size_t size, int numa_node_id) {
|
||||||
|
|
||||||
uintptr_t page_start_ptr =
|
uintptr_t page_start_ptr =
|
||||||
((reinterpret_cast<uintptr_t>(ptr)) & ~(getpagesize() - 1));
|
((reinterpret_cast<uintptr_t>(ptr)) & ~(getpagesize() - 1));
|
||||||
// NOLINTNEXTLINE(cppcoreguidelines-narrowing-conversions)
|
// NOLINTNEXTLINE(*-conversions)
|
||||||
// NOLINTNEXTLINE(bugprone-narrowing-conversions)
|
|
||||||
ptrdiff_t offset = reinterpret_cast<uintptr_t>(ptr) - page_start_ptr;
|
ptrdiff_t offset = reinterpret_cast<uintptr_t>(ptr) - page_start_ptr;
|
||||||
// Avoid extra dynamic allocation and NUMA api calls
|
// Avoid extra dynamic allocation and NUMA api calls
|
||||||
AT_ASSERT(
|
AT_ASSERT(
|
||||||
|
|
|
||||||
|
|
@ -247,6 +247,7 @@ PyTypeObject THPGeneratorType = {
|
||||||
nullptr, /* tp_getattro */
|
nullptr, /* tp_getattro */
|
||||||
nullptr, /* tp_setattro */
|
nullptr, /* tp_setattro */
|
||||||
nullptr, /* tp_as_buffer */
|
nullptr, /* tp_as_buffer */
|
||||||
|
// NOLINTNEXTLINE(misc-redundant-expression)
|
||||||
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
|
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
|
||||||
nullptr, /* tp_doc */
|
nullptr, /* tp_doc */
|
||||||
nullptr, /* tp_traverse */
|
nullptr, /* tp_traverse */
|
||||||
|
|
|
||||||
|
|
@ -627,6 +627,7 @@ PyTypeObject THPStorageMetaType = {
|
||||||
nullptr, /* tp_getattro */
|
nullptr, /* tp_getattro */
|
||||||
nullptr, /* tp_setattro */
|
nullptr, /* tp_setattro */
|
||||||
nullptr, /* tp_as_buffer */
|
nullptr, /* tp_as_buffer */
|
||||||
|
// NOLINTNEXTLINE(misc-redundant-expression)
|
||||||
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
|
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
|
||||||
nullptr, /* tp_doc */
|
nullptr, /* tp_doc */
|
||||||
nullptr, /* tp_traverse */
|
nullptr, /* tp_traverse */
|
||||||
|
|
@ -670,6 +671,7 @@ PyTypeObject THPStorageType = {
|
||||||
nullptr, /* tp_getattro */
|
nullptr, /* tp_getattro */
|
||||||
nullptr, /* tp_setattro */
|
nullptr, /* tp_setattro */
|
||||||
nullptr, /* tp_as_buffer */
|
nullptr, /* tp_as_buffer */
|
||||||
|
// NOLINTNEXTLINE(misc-redundant-expression)
|
||||||
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
|
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
|
||||||
nullptr, /* tp_doc */
|
nullptr, /* tp_doc */
|
||||||
nullptr, /* tp_traverse */
|
nullptr, /* tp_traverse */
|
||||||
|
|
|
||||||
|
|
@ -130,6 +130,7 @@ PyTypeObject THPStreamType = {
|
||||||
nullptr, /* tp_getattro */
|
nullptr, /* tp_getattro */
|
||||||
nullptr, /* tp_setattro */
|
nullptr, /* tp_setattro */
|
||||||
nullptr, /* tp_as_buffer */
|
nullptr, /* tp_as_buffer */
|
||||||
|
// NOLINTNEXTLINE(misc-redundant-expression)
|
||||||
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
|
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
|
||||||
nullptr, /* tp_doc */
|
nullptr, /* tp_doc */
|
||||||
nullptr, /* tp_traverse */
|
nullptr, /* tp_traverse */
|
||||||
|
|
|
||||||
|
|
@ -216,6 +216,7 @@ PyTypeObject* _initFunctionPyTypeObject(
|
||||||
const char* name,
|
const char* name,
|
||||||
PyGetSetDef* function_properties,
|
PyGetSetDef* function_properties,
|
||||||
PyMethodDef* function_methods) {
|
PyMethodDef* function_methods) {
|
||||||
|
// NOLINTNEXTLINE(misc-redundant-expression)
|
||||||
type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC;
|
type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC;
|
||||||
type.tp_name = name;
|
type.tp_name = name;
|
||||||
type.tp_basicsize = sizeof(THPCppFunction);
|
type.tp_basicsize = sizeof(THPCppFunction);
|
||||||
|
|
|
||||||
|
|
@ -422,6 +422,7 @@ PyTypeObject THPEngineType = {
|
||||||
nullptr, /* tp_getattro */
|
nullptr, /* tp_getattro */
|
||||||
nullptr, /* tp_setattro */
|
nullptr, /* tp_setattro */
|
||||||
nullptr, /* tp_as_buffer */
|
nullptr, /* tp_as_buffer */
|
||||||
|
// NOLINTNEXTLINE(misc-redundant-expression)
|
||||||
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
|
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
|
||||||
nullptr, /* tp_doc */
|
nullptr, /* tp_doc */
|
||||||
nullptr, /* tp_traverse */
|
nullptr, /* tp_traverse */
|
||||||
|
|
|
||||||
|
|
@ -68,7 +68,7 @@ namespace {
|
||||||
void throw_python_error() {
|
void throw_python_error() {
|
||||||
python_error err;
|
python_error err;
|
||||||
err.persist();
|
err.persist();
|
||||||
throw err;
|
throw std::move(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
@ -1557,6 +1557,7 @@ PyTypeObject THPFunctionType = {
|
||||||
nullptr, /* tp_getattro */
|
nullptr, /* tp_getattro */
|
||||||
nullptr, /* tp_setattro */
|
nullptr, /* tp_setattro */
|
||||||
nullptr, /* tp_as_buffer */
|
nullptr, /* tp_as_buffer */
|
||||||
|
// NOLINTNEXTLINE(misc-redundant-expression)
|
||||||
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE |
|
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE |
|
||||||
Py_TPFLAGS_HAVE_GC, /* tp_flags */
|
Py_TPFLAGS_HAVE_GC, /* tp_flags */
|
||||||
nullptr, /* tp_doc */
|
nullptr, /* tp_doc */
|
||||||
|
|
|
||||||
|
|
@ -131,6 +131,7 @@ PyTypeObject THPLegacyVariableType = {
|
||||||
nullptr, /* tp_getattro */
|
nullptr, /* tp_getattro */
|
||||||
nullptr, /* tp_setattro */
|
nullptr, /* tp_setattro */
|
||||||
nullptr, /* tp_as_buffer */
|
nullptr, /* tp_as_buffer */
|
||||||
|
// NOLINTNEXTLINE(misc-redundant-expression)
|
||||||
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
|
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
|
||||||
nullptr, /* tp_doc */
|
nullptr, /* tp_doc */
|
||||||
nullptr, /* tp_traverse */
|
nullptr, /* tp_traverse */
|
||||||
|
|
|
||||||
|
|
@ -1666,6 +1666,7 @@ PyTypeObject THPVariableMetaType = {
|
||||||
nullptr, /* tp_getattro */
|
nullptr, /* tp_getattro */
|
||||||
nullptr, /* tp_setattro */
|
nullptr, /* tp_setattro */
|
||||||
nullptr, /* tp_as_buffer */
|
nullptr, /* tp_as_buffer */
|
||||||
|
// NOLINTNEXTLINE(misc-redundant-expression)
|
||||||
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
|
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
|
||||||
nullptr, /* tp_doc */
|
nullptr, /* tp_doc */
|
||||||
nullptr, /* tp_traverse */
|
nullptr, /* tp_traverse */
|
||||||
|
|
@ -1711,6 +1712,7 @@ PyTypeObject THPVariableType = {
|
||||||
nullptr, /* tp_getattro */
|
nullptr, /* tp_getattro */
|
||||||
nullptr, /* tp_setattro */
|
nullptr, /* tp_setattro */
|
||||||
nullptr, /* tp_as_buffer */
|
nullptr, /* tp_as_buffer */
|
||||||
|
// NOLINTNEXTLINE(misc-redundant-expression)
|
||||||
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE |
|
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE |
|
||||||
Py_TPFLAGS_HAVE_GC, /* tp_flags */
|
Py_TPFLAGS_HAVE_GC, /* tp_flags */
|
||||||
nullptr, /* tp_doc */
|
nullptr, /* tp_doc */
|
||||||
|
|
|
||||||
|
|
@ -182,6 +182,7 @@ static PyTypeObject metaclass = {
|
||||||
};
|
};
|
||||||
|
|
||||||
static void py_initialize_metaclass(PyTypeObject& metaclass) {
|
static void py_initialize_metaclass(PyTypeObject& metaclass) {
|
||||||
|
// NOLINTNEXTLINE(misc-redundant-expression)
|
||||||
metaclass.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
|
metaclass.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
|
||||||
metaclass.tp_methods = metaclass_methods;
|
metaclass.tp_methods = metaclass_methods;
|
||||||
metaclass.tp_getset = metaclass_properties;
|
metaclass.tp_getset = metaclass_properties;
|
||||||
|
|
|
||||||
|
|
@ -791,7 +791,7 @@ static bool is_int_list(
|
||||||
// Make sure none of the later arguments are SymInt
|
// Make sure none of the later arguments are SymInt
|
||||||
// NB: do NOT check that the later arguments are ints, as this is
|
// NB: do NOT check that the later arguments are ints, as this is
|
||||||
// BC-breaking for FX
|
// BC-breaking for FX
|
||||||
for (int i = 1; i < len; i++) {
|
for (Py_ssize_t i = 1; i < len; i++) {
|
||||||
if (torch::is_symint(
|
if (torch::is_symint(
|
||||||
py::reinterpret_steal<py::object>(PySequence_GetItem(obj, i)))) {
|
py::reinterpret_steal<py::object>(PySequence_GetItem(obj, i)))) {
|
||||||
if (failed_idx != nullptr) {
|
if (failed_idx != nullptr) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user