Bug 1625884 - move clang-tidy and clang-format to clang-10. r=nalexander

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Andi-Bogdan Postelnicu 2020-04-09 05:28:34 +00:00
parent 06de4a861d
commit ffe0a6a754
9 changed files with 28 additions and 57 deletions

View File

@ -1,26 +1,26 @@
diff --git a/clang-tools-extra/clang-tidy/ClangTidy.cpp b/clang-tools-extra/clang-tidy/ClangTidy.cpp
index 1d813d65f8d..5ef2e6fe9cd 100644
index 40aaf402ec0..2184d51c643 100644
--- a/clang-tools-extra/clang-tidy/ClangTidy.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidy.cpp
@@ -407,6 +407,7 @@ ClangTidyASTConsumerFactory::CreateASTConsumer(
@@ -410,6 +410,7 @@ ClangTidyASTConsumerFactory::CreateASTConsumer(
for (auto &Check : Checks) {
Check->registerMatchers(&*Finder);
+ Check->registerPPCallbacks(Compiler);
Check->registerPPCallbacks(*SM, PP, ModuleExpanderPP);
}
diff --git a/clang-tools-extra/clang-tidy/ClangTidyCheck.h b/clang-tools-extra/clang-tidy/ClangTidyCheck.h
index 3064a41caa1..9c7eb4815c4 100644
index 1ad881f673a..59982bd377e 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyCheck.h
+++ b/clang-tools-extra/clang-tidy/ClangTidyCheck.h
@@ -53,6 +53,9 @@ public:
/// constructor using the Options.get() methods below.
ClangTidyCheck(StringRef CheckName, ClangTidyContext *Context);
+ /// This has been deprecated in clang 9 - needed by mozilla-must-override
+ virtual void registerPPCallbacks(CompilerInstance &Compiler) {}
+ virtual void registerPPCallbacks(CompilerInstance &Compiler) {}
+
/// \brief Override this to register ``PPCallbacks`` in the preprocessor.
/// Override this to register ``PPCallbacks`` in the preprocessor.
///
/// This should be used for clang-tidy checks that analyze preprocessor-

View File

@ -11,8 +11,6 @@
"as": "{MOZ_FETCHES_DIR}/gcc/bin/gcc",
"patches": [
"clang-tidy-ci.patch",
"clang-tidy-no-errors.patch",
"bug-1605181-isConstexpr.patch",
"bug-1606630-if_constexpr.patch"
"clang-tidy-no-errors.patch"
]
}

View File

@ -17,8 +17,6 @@
"patches": [
"clang-tidy-ci.patch",
"clang-tidy-no-errors.patch",
"compiler-rt-no-codesign.patch",
"bug-1605181-isConstexpr.patch",
"bug-1606630-if_constexpr.patch"
"compiler-rt-no-codesign.patch"
]
}

View File

@ -10,8 +10,6 @@
"ml": "ml64.exe",
"patches": [
"clang-tidy-ci.patch",
"clang-tidy-no-errors.patch",
"bug-1605181-isConstexpr.patch",
"bug-1606630-if_constexpr.patch"
"clang-tidy-no-errors.patch"
]
}

View File

@ -62,40 +62,20 @@ add_clang_library(clangTidyMozillaModule
)""" % {'names': "\n".join(names)})
def add_item_to_cmake_section(cmake_path, section, library):
def add_moz_module(cmake_path):
with open(cmake_path, 'r') as f:
lines = f.readlines()
f.close()
libs = []
seen_target_libs = False
for line in lines:
if line.find(section) > -1:
seen_target_libs = True
elif seen_target_libs:
if line.find(')') > -1:
break
else:
libs.append(line.strip())
libs.append(library)
libs = sorted(libs, key=lambda s: s.lower())
try:
idx = lines.index('set(ALL_CLANG_TIDY_CHECKS\n')
lines.insert(idx + 1, ' clangTidyMozillaModule\n')
with open(cmake_path, 'w') as f:
seen_target_libs = False
for line in lines:
if line.find(section) > -1:
seen_target_libs = True
with open(cmake_path, 'w') as f:
for line in lines:
f.write(line)
f.writelines([' ' + p + '\n' for p in libs])
continue
elif seen_target_libs:
if line.find(')') > -1:
seen_target_libs = False
else:
continue
f.write(line)
f.close()
except ValueError:
raise Exception('Unable to find ALL_CLANG_TIDY_CHECKS in {}'.format(cmake_path))
def write_third_party_paths(mozilla_path, module_path):
@ -131,14 +111,11 @@ def do_import(mozilla_path, clang_tidy_path, import_alpha):
write_third_party_paths(mozilla_path, module_path)
generate_thread_allows(mozilla_path, module_path)
write_cmake(module_path, import_alpha)
add_item_to_cmake_section(os.path.join(module_path, '..', 'plugin',
'CMakeLists.txt'),
'LINK_LIBS', 'clangTidyMozillaModule')
add_item_to_cmake_section(os.path.join(module_path, '..', 'tool',
'CMakeLists.txt'),
'PRIVATE', 'clangTidyMozillaModule')
add_moz_module(os.path.join(module_path, '..', 'CMakeLists.txt'))
with open(os.path.join(module_path, '..', 'CMakeLists.txt'), 'a') as f:
f.write('add_subdirectory(%s)\n' % module)
# A better place for this would be in `ClangTidyForceLinker.h` but `ClangTidyMain.cpp`
# is also OK.
with open(os.path.join(module_path, '..', 'tool', 'ClangTidyMain.cpp'), 'a') as f:
f.write('''
// This anchor is used to force the linker to link the MozillaModule.

View File

@ -24,7 +24,7 @@ job-defaults:
- try
fetches:
fetch:
- clang-9
- clang-10
linux64-clang-tidy:
index:
@ -63,8 +63,8 @@ macosx64-clang-tidy:
fetches:
toolchain:
- linux64-binutils
- linux64-cctools-port
- linux64-clang-9
- linux64-cctools-clang-10-port
- linux64-clang-10
- linux64-gcc-7
- linux64-node

View File

@ -1 +1 @@
[["warning", "Null pointer passed as an argument to a 'nonnull' parameter", "clang-analyzer-core.NonNullParamChecker"], {"reliability": "high"}]
[["warning", "Null pointer passed to 1st parameter expecting 'nonnull'", "clang-analyzer-core.NonNullParamChecker"], {"reliability": "high"}]

View File

@ -1 +1 @@
[["warning", "Null pointer argument in call to string length function", "clang-analyzer-unix.cstring.NullArg"], {"reliability": "high"}]
[["warning", "Null pointer passed as 1st argument to string length function", "clang-analyzer-unix.cstring.NullArg"], {"reliability": "high"}]

View File

@ -1 +1 @@
[["warning", "'push_back' is called inside a loop; consider pre-allocating the vector capacity before the loop", "performance-inefficient-vector-operation"], {"reliability": "high"}]
[["warning", "'push_back' is called inside a loop; consider pre-allocating the container capacity before the loop", "performance-inefficient-vector-operation"], {"reliability": "high"}]