diff options
author | Vitaly Buka <vitalybuka@google.com> | 2019-09-11 23:19:48 +0000 |
---|---|---|
committer | Vitaly Buka <vitalybuka@google.com> | 2019-09-11 23:19:48 +0000 |
commit | 17b6c662f2f60ad2e5522694df32bde9e71c7725 (patch) | |
tree | 937fc76e3cced266c2c8846e31022b7e39cab6ec | |
parent | d40d1324c710f029866cd872825b728859d3d21f (diff) | |
download | compiler-rt-17b6c662f2f60ad2e5522694df32bde9e71c7725.tar.gz |
Remove NOLINTs from compiler-rt
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@371687 91177308-0d34-0410-b5e6-96231b3b80d8
92 files changed, 402 insertions, 398 deletions
diff --git a/include/sanitizer/dfsan_interface.h b/include/sanitizer/dfsan_interface.h index c189ee557..7960d9e02 100644 --- a/include/sanitizer/dfsan_interface.h +++ b/include/sanitizer/dfsan_interface.h @@ -111,11 +111,6 @@ void dfsan_weak_hook_strncmp(void *caller_pc, const char *s1, const char *s2, #ifdef __cplusplus } // extern "C" -template <typename T> -void dfsan_set_label(dfsan_label label, T &data) { // NOLINT - dfsan_set_label(label, (void *)&data, sizeof(T)); -} - #endif #endif // DFSAN_INTERFACE_H diff --git a/include/sanitizer/tsan_interface_atomic.h b/include/sanitizer/tsan_interface_atomic.h index 9ce041191..8052bc1d5 100644 --- a/include/sanitizer/tsan_interface_atomic.h +++ b/include/sanitizer/tsan_interface_atomic.h @@ -17,10 +17,10 @@ extern "C" { #endif -typedef char __tsan_atomic8; -typedef short __tsan_atomic16; // NOLINT -typedef int __tsan_atomic32; -typedef long __tsan_atomic64; // NOLINT +typedef char __tsan_atomic8; +typedef short __tsan_atomic16; +typedef int __tsan_atomic32; +typedef long __tsan_atomic64; #if defined(__SIZEOF_INT128__) \ || (__clang_major__ * 100 + __clang_minor__ >= 302) __extension__ typedef __int128 __tsan_atomic128; diff --git a/lib/asan/asan_allocator.cpp b/lib/asan/asan_allocator.cpp index b58116e17..c9e9f5a93 100644 --- a/lib/asan/asan_allocator.cpp +++ b/lib/asan/asan_allocator.cpp @@ -1075,7 +1075,7 @@ IgnoreObjectResult IgnoreObjectLocked(const void *p) { } // namespace __lsan // ---------------------- Interface ---------------- {{{1 -using namespace __asan; // NOLINT +using namespace __asan; // ASan allocator doesn't reserve extra bytes, so normally we would // just return "size". We don't want to expose our redzone sizes, etc here. diff --git a/lib/asan/asan_errors.cpp b/lib/asan/asan_errors.cpp index 75ee996ce..0ef97794b 100644 --- a/lib/asan/asan_errors.cpp +++ b/lib/asan/asan_errors.cpp @@ -244,7 +244,7 @@ void ErrorInvalidPosixMemalignAlignment::Print() { "ERROR: AddressSanitizer: invalid alignment requested in posix_memalign: " "%zd, alignment must be a power of two and a multiple of sizeof(void*) " "== %zd (thread %s)\n", - alignment, sizeof(void*), AsanThreadIdAndName(tid).c_str()); // NOLINT + alignment, sizeof(void *), AsanThreadIdAndName(tid).c_str()); Printf("%s", d.Default()); stack->Print(); PrintHintAllocatorCannotReturnNull(); diff --git a/lib/asan/asan_globals.cpp b/lib/asan/asan_globals.cpp index 54e75f3ce..9d7dbc6f2 100644 --- a/lib/asan/asan_globals.cpp +++ b/lib/asan/asan_globals.cpp @@ -227,8 +227,7 @@ static void RegisterGlobal(const Global *g) { list_of_all_globals = l; if (g->has_dynamic_init) { if (!dynamic_init_globals) { - dynamic_init_globals = - new (allocator_for_globals) VectorOfGlobals; // NOLINT + dynamic_init_globals = new (allocator_for_globals) VectorOfGlobals; dynamic_init_globals->reserve(kDynamicInitGlobalsInitialCapacity); } DynInitGlobal dyn_global = { *g, false }; @@ -315,8 +314,7 @@ void PrintGlobalLocation(InternalScopedString *str, const __asan_global &g) { } // namespace __asan // ---------------------- Interface ---------------- {{{1 -using namespace __asan; // NOLINT - +using namespace __asan; // Apply __asan_register_globals to all globals found in the same loaded // executable or shared library as `flag'. The flag tracks whether globals have @@ -364,7 +362,7 @@ void __asan_register_globals(__asan_global *globals, uptr n) { BlockingMutexLock lock(&mu_for_globals); if (!global_registration_site_vector) { global_registration_site_vector = - new (allocator_for_globals) GlobalRegistrationSiteVector; // NOLINT + new (allocator_for_globals) GlobalRegistrationSiteVector; global_registration_site_vector->reserve(128); } GlobalRegistrationSite site = {stack_id, &globals[0], &globals[n - 1]}; diff --git a/lib/asan/asan_globals_win.cpp b/lib/asan/asan_globals_win.cpp index ff5fe226b..19af88ab1 100644 --- a/lib/asan/asan_globals_win.cpp +++ b/lib/asan/asan_globals_win.cpp @@ -15,8 +15,8 @@ namespace __asan { -#pragma section(".ASAN$GA", read, write) // NOLINT -#pragma section(".ASAN$GZ", read, write) // NOLINT +#pragma section(".ASAN$GA", read, write) +#pragma section(".ASAN$GZ", read, write) extern "C" __declspec(allocate(".ASAN$GA")) ALIGNED(sizeof(__asan_global)) __asan_global __asan_globals_start = {}; extern "C" __declspec(allocate(".ASAN$GZ")) @@ -49,8 +49,8 @@ static void unregister_dso_globals() { } // Register globals -#pragma section(".CRT$XCU", long, read) // NOLINT -#pragma section(".CRT$XTX", long, read) // NOLINT +#pragma section(".CRT$XCU", long, read) +#pragma section(".CRT$XTX", long, read) extern "C" __declspec(allocate(".CRT$XCU")) void (*const __asan_dso_reg_hook)() = ®ister_dso_globals; extern "C" __declspec(allocate(".CRT$XTX")) diff --git a/lib/asan/asan_interceptors.cpp b/lib/asan/asan_interceptors.cpp index 482e44d83..cea4d63e6 100644 --- a/lib/asan/asan_interceptors.cpp +++ b/lib/asan/asan_interceptors.cpp @@ -79,7 +79,7 @@ int OnExit() { } // namespace __asan // ---------------------- Wrappers ---------------- {{{1 -using namespace __asan; // NOLINT +using namespace __asan; DECLARE_REAL_AND_INTERCEPTOR(void *, malloc, uptr) DECLARE_REAL_AND_INTERCEPTOR(void, free, void *) @@ -373,26 +373,26 @@ DEFINE_REAL(char*, index, const char *string, int c) // For both strcat() and strncat() we need to check the validity of |to| // argument irrespective of the |from| length. -INTERCEPTOR(char*, strcat, char *to, const char *from) { // NOLINT - void *ctx; - ASAN_INTERCEPTOR_ENTER(ctx, strcat); // NOLINT - ENSURE_ASAN_INITED(); - if (flags()->replace_str) { - uptr from_length = REAL(strlen)(from); - ASAN_READ_RANGE(ctx, from, from_length + 1); - uptr to_length = REAL(strlen)(to); - ASAN_READ_STRING_OF_LEN(ctx, to, to_length, to_length); - ASAN_WRITE_RANGE(ctx, to + to_length, from_length + 1); - // If the copying actually happens, the |from| string should not overlap - // with the resulting string starting at |to|, which has a length of - // to_length + from_length + 1. - if (from_length > 0) { - CHECK_RANGES_OVERLAP("strcat", to, from_length + to_length + 1, - from, from_length + 1); + INTERCEPTOR(char *, strcat, char *to, const char *from) { + void *ctx; + ASAN_INTERCEPTOR_ENTER(ctx, strcat); + ENSURE_ASAN_INITED(); + if (flags()->replace_str) { + uptr from_length = REAL(strlen)(from); + ASAN_READ_RANGE(ctx, from, from_length + 1); + uptr to_length = REAL(strlen)(to); + ASAN_READ_STRING_OF_LEN(ctx, to, to_length, to_length); + ASAN_WRITE_RANGE(ctx, to + to_length, from_length + 1); + // If the copying actually happens, the |from| string should not overlap + // with the resulting string starting at |to|, which has a length of + // to_length + from_length + 1. + if (from_length > 0) { + CHECK_RANGES_OVERLAP("strcat", to, from_length + to_length + 1, from, + from_length + 1); + } } + return REAL(strcat)(to, from); } - return REAL(strcat)(to, from); // NOLINT -} INTERCEPTOR(char*, strncat, char *to, const char *from, uptr size) { void *ctx; @@ -413,16 +413,17 @@ INTERCEPTOR(char*, strncat, char *to, const char *from, uptr size) { return REAL(strncat)(to, from, size); } -INTERCEPTOR(char*, strcpy, char *to, const char *from) { // NOLINT +INTERCEPTOR(char *, strcpy, char *to, const char *from) { void *ctx; - ASAN_INTERCEPTOR_ENTER(ctx, strcpy); // NOLINT + ASAN_INTERCEPTOR_ENTER(ctx, strcpy); #if SANITIZER_MAC - if (UNLIKELY(!asan_inited)) return REAL(strcpy)(to, from); // NOLINT + if (UNLIKELY(!asan_inited)) + return REAL(strcpy)(to, from); #endif // strcpy is called from malloc_default_purgeable_zone() // in __asan::ReplaceSystemAlloc() on Mac. if (asan_init_is_running) { - return REAL(strcpy)(to, from); // NOLINT + return REAL(strcpy)(to, from); } ENSURE_ASAN_INITED(); if (flags()->replace_str) { @@ -431,7 +432,7 @@ INTERCEPTOR(char*, strcpy, char *to, const char *from) { // NOLINT ASAN_READ_RANGE(ctx, from, from_size); ASAN_WRITE_RANGE(ctx, to, from_size); } - return REAL(strcpy)(to, from); // NOLINT + return REAL(strcpy)(to, from); } INTERCEPTOR(char*, strdup, const char *s) { @@ -479,8 +480,7 @@ INTERCEPTOR(char*, strncpy, char *to, const char *from, uptr size) { return REAL(strncpy)(to, from, size); } -INTERCEPTOR(long, strtol, const char *nptr, // NOLINT - char **endptr, int base) { +INTERCEPTOR(long, strtol, const char *nptr, char **endptr, int base) { void *ctx; ASAN_INTERCEPTOR_ENTER(ctx, strtol); ENSURE_ASAN_INITED(); @@ -488,7 +488,7 @@ INTERCEPTOR(long, strtol, const char *nptr, // NOLINT return REAL(strtol)(nptr, endptr, base); } char *real_endptr; - long result = REAL(strtol)(nptr, &real_endptr, base); // NOLINT + long result = REAL(strtol)(nptr, &real_endptr, base); StrtolFixAndCheck(ctx, nptr, endptr, real_endptr, base); return result; } @@ -514,7 +514,7 @@ INTERCEPTOR(int, atoi, const char *nptr) { return result; } -INTERCEPTOR(long, atol, const char *nptr) { // NOLINT +INTERCEPTOR(long, atol, const char *nptr) { void *ctx; ASAN_INTERCEPTOR_ENTER(ctx, atol); #if SANITIZER_MAC @@ -525,15 +525,14 @@ INTERCEPTOR(long, atol, const char *nptr) { // NOLINT return REAL(atol)(nptr); } char *real_endptr; - long result = REAL(strtol)(nptr, &real_endptr, 10); // NOLINT + long result = REAL(strtol)(nptr, &real_endptr, 10); FixRealStrtolEndptr(nptr, &real_endptr); ASAN_READ_STRING(ctx, nptr, (real_endptr - nptr) + 1); return result; } #if ASAN_INTERCEPT_ATOLL_AND_STRTOLL -INTERCEPTOR(long long, strtoll, const char *nptr, // NOLINT - char **endptr, int base) { +INTERCEPTOR(long long, strtoll, const char *nptr, char **endptr, int base) { void *ctx; ASAN_INTERCEPTOR_ENTER(ctx, strtoll); ENSURE_ASAN_INITED(); @@ -541,12 +540,12 @@ INTERCEPTOR(long long, strtoll, const char *nptr, // NOLINT return REAL(strtoll)(nptr, endptr, base); } char *real_endptr; - long long result = REAL(strtoll)(nptr, &real_endptr, base); // NOLINT + long long result = REAL(strtoll)(nptr, &real_endptr, base); StrtolFixAndCheck(ctx, nptr, endptr, real_endptr, base); return result; } -INTERCEPTOR(long long, atoll, const char *nptr) { // NOLINT +INTERCEPTOR(long long, atoll, const char *nptr) { void *ctx; ASAN_INTERCEPTOR_ENTER(ctx, atoll); ENSURE_ASAN_INITED(); @@ -554,7 +553,7 @@ INTERCEPTOR(long long, atoll, const char *nptr) { // NOLINT return REAL(atoll)(nptr); } char *real_endptr; - long long result = REAL(strtoll)(nptr, &real_endptr, 10); // NOLINT + long long result = REAL(strtoll)(nptr, &real_endptr, 10); FixRealStrtolEndptr(nptr, &real_endptr); ASAN_READ_STRING(ctx, nptr, (real_endptr - nptr) + 1); return result; @@ -594,8 +593,8 @@ void InitializeAsanInterceptors() { InitializeSignalInterceptors(); // Intercept str* functions. - ASAN_INTERCEPT_FUNC(strcat); // NOLINT - ASAN_INTERCEPT_FUNC(strcpy); // NOLINT + ASAN_INTERCEPT_FUNC(strcat); + ASAN_INTERCEPT_FUNC(strcpy); ASAN_INTERCEPT_FUNC(strncat); ASAN_INTERCEPT_FUNC(strncpy); ASAN_INTERCEPT_FUNC(strdup); diff --git a/lib/asan/asan_interceptors_memintrinsics.cpp b/lib/asan/asan_interceptors_memintrinsics.cpp index 56df60ba6..ccdd51590 100644 --- a/lib/asan/asan_interceptors_memintrinsics.cpp +++ b/lib/asan/asan_interceptors_memintrinsics.cpp @@ -16,7 +16,7 @@ #include "asan_stack.h" #include "asan_suppressions.h" -using namespace __asan; // NOLINT +using namespace __asan; void *__asan_memcpy(void *to, const void *from, uptr size) { ASAN_MEMCPY_IMPL(nullptr, to, from, size); diff --git a/lib/asan/asan_mac.cpp b/lib/asan/asan_mac.cpp index 769d49967..a8d3f5d34 100644 --- a/lib/asan/asan_mac.cpp +++ b/lib/asan/asan_mac.cpp @@ -205,7 +205,7 @@ void asan_dispatch_call_block_and_release(void *block) { } // namespace __asan -using namespace __asan; // NOLINT +using namespace __asan; // Wrap |ctxt| and |func| into an asan_block_context_t. // The caller retains control of the allocated context. diff --git a/lib/asan/asan_malloc_linux.cpp b/lib/asan/asan_malloc_linux.cpp index 706bc39f0..faa8968a5 100644 --- a/lib/asan/asan_malloc_linux.cpp +++ b/lib/asan/asan_malloc_linux.cpp @@ -27,7 +27,7 @@ #include "asan_stack.h" // ---------------------- Replacement functions ---------------- {{{1 -using namespace __asan; // NOLINT +using namespace __asan; static uptr allocated_for_dlsym; static uptr last_dlsym_alloc_size_in_words; diff --git a/lib/asan/asan_malloc_win.cpp b/lib/asan/asan_malloc_win.cpp index 291d411ea..9d107bee8 100644 --- a/lib/asan/asan_malloc_win.cpp +++ b/lib/asan/asan_malloc_win.cpp @@ -54,7 +54,7 @@ size_t WINAPI HeapSize(HANDLE hHeap, DWORD dwFlags, LPCVOID lpMem); BOOL WINAPI HeapValidate(HANDLE hHeap, DWORD dwFlags, LPCVOID lpMem); } -using namespace __asan; // NOLINT +using namespace __asan; // MT: Simply defining functions with the same signature in *.obj // files overrides the standard functions in the CRT. diff --git a/lib/asan/asan_new_delete.cpp b/lib/asan/asan_new_delete.cpp index c15e20809..5dfcc00fd 100644 --- a/lib/asan/asan_new_delete.cpp +++ b/lib/asan/asan_new_delete.cpp @@ -48,7 +48,7 @@ COMMENT_EXPORT("??_V@YAXPAX@Z") // operator delete[] #define CXX_OPERATOR_ATTRIBUTE INTERCEPTOR_ATTRIBUTE #endif -using namespace __asan; // NOLINT +using namespace __asan; // FreeBSD prior v9.2 have wrong definition of 'size_t'. // http://svnweb.freebsd.org/base?view=revision&revision=232261 diff --git a/lib/asan/asan_poisoning.cpp b/lib/asan/asan_poisoning.cpp index 6b36be7d1..f3fbe684e 100644 --- a/lib/asan/asan_poisoning.cpp +++ b/lib/asan/asan_poisoning.cpp @@ -92,7 +92,7 @@ void AsanPoisonOrUnpoisonIntraObjectRedzone(uptr ptr, uptr size, bool poison) { } // namespace __asan // ---------------------- Interface ---------------- {{{1 -using namespace __asan; // NOLINT +using namespace __asan; // Current implementation of __asan_(un)poison_memory_region doesn't check // that user program (un)poisons the memory it owns. It poisons memory diff --git a/lib/asan/asan_report.cpp b/lib/asan/asan_report.cpp index d36b0b4c5..5c16cb3e4 100644 --- a/lib/asan/asan_report.cpp +++ b/lib/asan/asan_report.cpp @@ -472,7 +472,7 @@ void ReportGenericError(uptr pc, uptr bp, uptr sp, uptr addr, bool is_write, } // namespace __asan // --------------------------- Interface --------------------- {{{1 -using namespace __asan; // NOLINT +using namespace __asan; void __asan_report_error(uptr pc, uptr bp, uptr sp, uptr addr, int is_write, uptr access_size, u32 exp) { diff --git a/lib/asan/asan_rtl.cpp b/lib/asan/asan_rtl.cpp index f72012609..594d7752e 100644 --- a/lib/asan/asan_rtl.cpp +++ b/lib/asan/asan_rtl.cpp @@ -542,7 +542,7 @@ void AsanInitFromRtl() { // (and thus normal initializers from .preinit_array or modules haven't run). class AsanInitializer { -public: // NOLINT + public: AsanInitializer() { AsanInitFromRtl(); } @@ -554,7 +554,7 @@ static AsanInitializer asan_initializer; } // namespace __asan // ---------------------- Interface ---------------- {{{1 -using namespace __asan; // NOLINT +using namespace __asan; void NOINLINE __asan_handle_no_return() { if (asan_init_is_running) diff --git a/lib/asan/asan_stats.cpp b/lib/asan/asan_stats.cpp index bc4e8c15c..00ded8f5e 100644 --- a/lib/asan/asan_stats.cpp +++ b/lib/asan/asan_stats.cpp @@ -133,7 +133,7 @@ static void PrintAccumulatedStats() { } // namespace __asan // ---------------------- Interface ---------------- {{{1 -using namespace __asan; // NOLINT +using namespace __asan; uptr __sanitizer_get_current_allocated_bytes() { AsanStats stats; diff --git a/lib/asan/asan_suppressions.cpp b/lib/asan/asan_suppressions.cpp index a9c0d1076..8cb2c3e3b 100644 --- a/lib/asan/asan_suppressions.cpp +++ b/lib/asan/asan_suppressions.cpp @@ -36,7 +36,7 @@ SANITIZER_INTERFACE_WEAK_DEF(const char *, __asan_default_suppressions, void) { void InitializeSuppressions() { CHECK_EQ(nullptr, suppression_ctx); - suppression_ctx = new (suppression_placeholder) // NOLINT + suppression_ctx = new (suppression_placeholder) SuppressionContext(kSuppressionTypes, ARRAY_SIZE(kSuppressionTypes)); suppression_ctx->ParseFromFile(flags()->suppressions); if (&__asan_default_suppressions) diff --git a/lib/asan/asan_thread.cpp b/lib/asan/asan_thread.cpp index d48b3414d..c75cdc2bb 100644 --- a/lib/asan/asan_thread.cpp +++ b/lib/asan/asan_thread.cpp @@ -505,7 +505,7 @@ void EnsureMainThreadIDIsCorrect() { } // namespace __lsan // ---------------------- Interface ---------------- {{{1 -using namespace __asan; // NOLINT +using namespace __asan; extern "C" { SANITIZER_INTERFACE_ATTRIBUTE diff --git a/lib/asan/asan_win.cpp b/lib/asan/asan_win.cpp index f8b98ca33..417892aae 100644 --- a/lib/asan/asan_win.cpp +++ b/lib/asan/asan_win.cpp @@ -29,7 +29,7 @@ #include "sanitizer_common/sanitizer_win.h" #include "sanitizer_common/sanitizer_win_defs.h" -using namespace __asan; // NOLINT +using namespace __asan; extern "C" { SANITIZER_INTERFACE_ATTRIBUTE @@ -106,7 +106,7 @@ INTERCEPTOR_WINAPI(void, RaiseException, void *a, void *b, void *c, void *d) { INTERCEPTOR_WINAPI(EXCEPTION_DISPOSITION, __C_specific_handler, _EXCEPTION_RECORD *a, void *b, _CONTEXT *c, - _DISPATCHER_CONTEXT *d) { // NOLINT + _DISPATCHER_CONTEXT *d) { CHECK(REAL(__C_specific_handler)); __asan_handle_no_return(); return REAL(__C_specific_handler)(a, b, c, d); @@ -362,7 +362,7 @@ bool HandleDlopenInit() { // beginning of C++ initialization. We set our priority to XCAB to run // immediately after the CRT runs. This way, our exception filter is called // first and we can delegate to their filter if appropriate. -#pragma section(".CRT$XCAB", long, read) // NOLINT +#pragma section(".CRT$XCAB", long, read) __declspec(allocate(".CRT$XCAB")) int (*__intercept_seh)() = __asan_set_seh_filter; @@ -375,7 +375,7 @@ static void NTAPI asan_thread_init(void *module, DWORD reason, void *reserved) { __asan_init(); } -#pragma section(".CRT$XLAB", long, read) // NOLINT +#pragma section(".CRT$XLAB", long, read) __declspec(allocate(".CRT$XLAB")) void(NTAPI *__asan_tls_init)( void *, unsigned long, void *) = asan_thread_init; #endif @@ -389,7 +389,7 @@ static void NTAPI asan_thread_exit(void *module, DWORD reason, void *reserved) { } } -#pragma section(".CRT$XLY", long, read) // NOLINT +#pragma section(".CRT$XLY", long, read) __declspec(allocate(".CRT$XLY")) void(NTAPI *__asan_tls_exit)( void *, unsigned long, void *) = asan_thread_exit; diff --git a/lib/asan/asan_win_dll_thunk.cpp b/lib/asan/asan_win_dll_thunk.cpp index 95eee5eed..a5671cc9d 100644 --- a/lib/asan/asan_win_dll_thunk.cpp +++ b/lib/asan/asan_win_dll_thunk.cpp @@ -67,10 +67,10 @@ INTERCEPT_LIBRARY_FUNCTION(memcmp); INTERCEPT_LIBRARY_FUNCTION(memcpy); INTERCEPT_LIBRARY_FUNCTION(memmove); INTERCEPT_LIBRARY_FUNCTION(memset); -INTERCEPT_LIBRARY_FUNCTION(strcat); // NOLINT +INTERCEPT_LIBRARY_FUNCTION(strcat); INTERCEPT_LIBRARY_FUNCTION(strchr); INTERCEPT_LIBRARY_FUNCTION(strcmp); -INTERCEPT_LIBRARY_FUNCTION(strcpy); // NOLINT +INTERCEPT_LIBRARY_FUNCTION(strcpy); INTERCEPT_LIBRARY_FUNCTION(strcspn); INTERCEPT_LIBRARY_FUNCTION(strdup); INTERCEPT_LIBRARY_FUNCTION(strlen); @@ -135,7 +135,7 @@ static int asan_dll_thunk_init() { return 0; } -#pragma section(".CRT$XIB", long, read) // NOLINT +#pragma section(".CRT$XIB", long, read) __declspec(allocate(".CRT$XIB")) int (*__asan_preinit)() = asan_dll_thunk_init; static void WINAPI asan_thread_init(void *mod, unsigned long reason, @@ -143,7 +143,7 @@ static void WINAPI asan_thread_init(void *mod, unsigned long reason, if (reason == /*DLL_PROCESS_ATTACH=*/1) asan_dll_thunk_init(); } -#pragma section(".CRT$XLAB", long, read) // NOLINT +#pragma section(".CRT$XLAB", long, read) __declspec(allocate(".CRT$XLAB")) void (WINAPI *__asan_tls_init)(void *, unsigned long, void *) = asan_thread_init; diff --git a/lib/asan/asan_win_dynamic_runtime_thunk.cpp b/lib/asan/asan_win_dynamic_runtime_thunk.cpp index 5bd457a22..f0b5ec9ee 100644 --- a/lib/asan/asan_win_dynamic_runtime_thunk.cpp +++ b/lib/asan/asan_win_dynamic_runtime_thunk.cpp @@ -32,12 +32,12 @@ #include "asan_interface.inc" // First, declare CRT sections we'll be using in this file -#pragma section(".CRT$XIB", long, read) // NOLINT -#pragma section(".CRT$XID", long, read) // NOLINT -#pragma section(".CRT$XCAB", long, read) // NOLINT -#pragma section(".CRT$XTW", long, read) // NOLINT -#pragma section(".CRT$XTY", long, read) // NOLINT -#pragma section(".CRT$XLAB", long, read) // NOLINT +#pragma section(".CRT$XIB", long, read) +#pragma section(".CRT$XID", long, read) +#pragma section(".CRT$XCAB", long, read) +#pragma section(".CRT$XTW", long, read) +#pragma section(".CRT$XTY", long, read) +#pragma section(".CRT$XLAB", long, read) //////////////////////////////////////////////////////////////////////////////// // Define a copy of __asan_option_detect_stack_use_after_return that should be diff --git a/lib/dfsan/dfsan.h b/lib/dfsan/dfsan.h index d66239121..df6847cdb 100644 --- a/lib/dfsan/dfsan.h +++ b/lib/dfsan/dfsan.h @@ -38,7 +38,7 @@ dfsan_label dfsan_union(dfsan_label l1, dfsan_label l2); } // extern "C" template <typename T> -void dfsan_set_label(dfsan_label label, T &data) { // NOLINT +void dfsan_set_label(dfsan_label label, T &data) { dfsan_set_label(label, (void *)&data, sizeof(T)); } diff --git a/lib/hwasan/hwasan_new_delete.cpp b/lib/hwasan/hwasan_new_delete.cpp index 4a9c79fe4..191c17e56 100644 --- a/lib/hwasan/hwasan_new_delete.cpp +++ b/lib/hwasan/hwasan_new_delete.cpp @@ -20,7 +20,7 @@ #include <stddef.h> -using namespace __hwasan; // NOLINT +using namespace __hwasan; // Fake std::nothrow_t to avoid including <new>. namespace std { diff --git a/lib/interception/interception.h b/lib/interception/interception.h index dacfa5ede..d27a8ccf9 100644 --- a/lib/interception/interception.h +++ b/lib/interception/interception.h @@ -272,9 +272,9 @@ const interpose_substitution substitution_##func_name[] \ // INTERCEPT_FUNCTION macro, only its name. namespace __interception { #if defined(_WIN64) -typedef unsigned long long uptr; // NOLINT +typedef unsigned long long uptr; #else -typedef unsigned long uptr; // NOLINT +typedef unsigned long uptr; #endif // _WIN64 } // namespace __interception diff --git a/lib/lsan/lsan.cpp b/lib/lsan/lsan.cpp index 5b5f6198a..deabf044a 100644 --- a/lib/lsan/lsan.cpp +++ b/lib/lsan/lsan.cpp @@ -50,7 +50,7 @@ void __sanitizer::BufferedStackTrace::UnwindImpl( } } -using namespace __lsan; // NOLINT +using namespace __lsan; static void InitializeFlags() { // Set all the default values. diff --git a/lib/lsan/lsan_common.cpp b/lib/lsan/lsan_common.cpp index c39fab97c..529daee43 100644 --- a/lib/lsan/lsan_common.cpp +++ b/lib/lsan/lsan_common.cpp @@ -84,7 +84,7 @@ static const char kStdSuppressions[] = void InitializeSuppressions() { CHECK_EQ(nullptr, suppression_ctx); - suppression_ctx = new (suppression_placeholder) // NOLINT + suppression_ctx = new (suppression_placeholder) SuppressionContext(kSuppressionTypes, ARRAY_SIZE(kSuppressionTypes)); suppression_ctx->ParseFromFile(flags()->suppressions); if (&__lsan_default_suppressions) @@ -104,7 +104,7 @@ InternalMmapVector<RootRegion> const *GetRootRegions() { return root_regions; } void InitializeRootRegions() { CHECK(!root_regions); ALIGNED(64) static char placeholder[sizeof(InternalMmapVector<RootRegion>)]; - root_regions = new (placeholder) InternalMmapVector<RootRegion>(); // NOLINT + root_regions = new (placeholder) InternalMmapVector<RootRegion>(); } const char *MaybeCallLsanDefaultOptions() { @@ -162,7 +162,7 @@ void ScanRangeForPointers(uptr begin, uptr end, uptr pp = begin; if (pp % alignment) pp = pp + alignment - pp % alignment; - for (; pp + sizeof(void *) <= end; pp += alignment) { // NOLINT + for (; pp + sizeof(void *) <= end; pp += alignment) { void *p = *reinterpret_cast<void **>(pp); if (!CanBeAHeapPointer(reinterpret_cast<uptr>(p))) continue; uptr chunk = PointsIntoChunk(p); @@ -794,7 +794,7 @@ void EnableInThisThread() { } } #endif // CAN_SANITIZE_LEAKS -using namespace __lsan; // NOLINT +using namespace __lsan; extern "C" { SANITIZER_INTERFACE_ATTRIBUTE diff --git a/lib/lsan/lsan_mac.cpp b/lib/lsan/lsan_mac.cpp index 7bcd9c828..b96893e28 100644 --- a/lib/lsan/lsan_mac.cpp +++ b/lib/lsan/lsan_mac.cpp @@ -90,7 +90,7 @@ extern "C" void lsan_dispatch_call_block_and_release(void *block) { } // namespace __lsan -using namespace __lsan; // NOLINT +using namespace __lsan; // Wrap |ctxt| and |func| into an lsan_block_context_t. // The caller retains control of the allocated context. diff --git a/lib/msan/msan.cpp b/lib/msan/msan.cpp index f5b05c460..da3534bc5 100644 --- a/lib/msan/msan.cpp +++ b/lib/msan/msan.cpp @@ -130,8 +130,8 @@ static void RegisterMsanFlags(FlagParser *parser, Flags *f) { #include "msan_flags.inc" #undef MSAN_FLAG - FlagHandlerKeepGoing *fh_keep_going = new (FlagParser::Alloc) // NOLINT - FlagHandlerKeepGoing(&f->halt_on_error); + FlagHandlerKeepGoing *fh_keep_going = + new (FlagParser::Alloc) FlagHandlerKeepGoing(&f->halt_on_error); parser->RegisterHandler("keep_going", fh_keep_going, "deprecated, use halt_on_error"); } diff --git a/lib/msan/msan_interceptors.cpp b/lib/msan/msan_interceptors.cpp index 41a5aa767..ff760e43d 100644 --- a/lib/msan/msan_interceptors.cpp +++ b/lib/msan/msan_interceptors.cpp @@ -282,35 +282,35 @@ INTERCEPTOR(void, malloc_stats, void) { #define MSAN_MAYBE_INTERCEPT_MALLOC_STATS #endif -INTERCEPTOR(char *, strcpy, char *dest, const char *src) { // NOLINT +INTERCEPTOR(char *, strcpy, char *dest, const char *src) { ENSURE_MSAN_INITED(); GET_STORE_STACK_TRACE; SIZE_T n = REAL(strlen)(src); CHECK_UNPOISONED_STRING(src + n, 0); - char *res = REAL(strcpy)(dest, src); // NOLINT + char *res = REAL(strcpy)(dest, src); CopyShadowAndOrigin(dest, src, n + 1, &stack); return res; } -INTERCEPTOR(char *, strncpy, char *dest, const char *src, SIZE_T n) { // NOLINT +INTERCEPTOR(char *, strncpy, char *dest, const char *src, SIZE_T n) { ENSURE_MSAN_INITED(); GET_STORE_STACK_TRACE; SIZE_T copy_size = REAL(strnlen)(src, n); if (copy_size < n) copy_size++; // trailing \0 - char *res = REAL(strncpy)(dest, src, n); // NOLINT + char *res = REAL(strncpy)(dest, src, n); CopyShadowAndOrigin(dest, src, copy_size, &stack); __msan_unpoison(dest + copy_size, n - copy_size); return res; } #if !SANITIZER_NETBSD -INTERCEPTOR(char *, stpcpy, char *dest, const char *src) { // NOLINT +INTERCEPTOR(char *, stpcpy, char *dest, const char *src) { ENSURE_MSAN_INITED(); GET_STORE_STACK_TRACE; SIZE_T n = REAL(strlen)(src); CHECK_UNPOISONED_STRING(src + n, 0); - char *res = REAL(stpcpy)(dest, src); // NOLINT + char *res = REAL(stpcpy)(dest, src); CopyShadowAndOrigin(dest, src, n + 1, &stack); return res; } @@ -359,25 +359,25 @@ INTERCEPTOR(char *, gcvt, double number, SIZE_T ndigit, char *buf) { #define MSAN_MAYBE_INTERCEPT_GCVT #endif -INTERCEPTOR(char *, strcat, char *dest, const char *src) { // NOLINT +INTERCEPTOR(char *, strcat, char *dest, const char *src) { ENSURE_MSAN_INITED(); GET_STORE_STACK_TRACE; SIZE_T src_size = REAL(strlen)(src); SIZE_T dest_size = REAL(strlen)(dest); CHECK_UNPOISONED_STRING(src + src_size, 0); CHECK_UNPOISONED_STRING(dest + dest_size, 0); - char *res = REAL(strcat)(dest, src); // NOLINT + char *res = REAL(strcat)(dest, src); CopyShadowAndOrigin(dest + dest_size, src, src_size + 1, &stack); return res; } -INTERCEPTOR(char *, strncat, char *dest, const char *src, SIZE_T n) { // NOLINT +INTERCEPTOR(char *, strncat, char *dest, const char *src, SIZE_T n) { ENSURE_MSAN_INITED(); GET_STORE_STACK_TRACE; SIZE_T dest_size = REAL(strlen)(dest); SIZE_T copy_size = REAL(strnlen)(src, n); CHECK_UNPOISONED_STRING(dest + dest_size, 0); - char *res = REAL(strncat)(dest, src, n); // NOLINT + char *res = REAL(strncat)(dest, src, n); CopyShadowAndOrigin(dest + dest_size, src, copy_size, &stack); __msan_unpoison(dest + dest_size + copy_size, 1); // \0 return res; @@ -437,22 +437,22 @@ INTERCEPTOR(char *, strncat, char *dest, const char *src, SIZE_T n) { // NOLINT INTERCEPTOR_STRTO_BASE_LOC(ret_type, __##func##_internal, char_type) #endif -INTERCEPTORS_STRTO(double, strtod, char) // NOLINT -INTERCEPTORS_STRTO(float, strtof, char) // NOLINT -INTERCEPTORS_STRTO(long double, strtold, char) // NOLINT -INTERCEPTORS_STRTO_BASE(long, strtol, char) // NOLINT -INTERCEPTORS_STRTO_BASE(long long, strtoll, char) // NOLINT -INTERCEPTORS_STRTO_BASE(unsigned long, strtoul, char) // NOLINT -INTERCEPTORS_STRTO_BASE(unsigned long long, strtoull, char) // NOLINT -INTERCEPTORS_STRTO_BASE(u64, strtouq, char) // NOLINT - -INTERCEPTORS_STRTO(double, wcstod, wchar_t) // NOLINT -INTERCEPTORS_STRTO(float, wcstof, wchar_t) // NOLINT -INTERCEPTORS_STRTO(long double, wcstold, wchar_t) // NOLINT -INTERCEPTORS_STRTO_BASE(long, wcstol, wchar_t) // NOLINT -INTERCEPTORS_STRTO_BASE(long long, wcstoll, wchar_t) // NOLINT -INTERCEPTORS_STRTO_BASE(unsigned long, wcstoul, wchar_t) // NOLINT -INTERCEPTORS_STRTO_BASE(unsigned long long, wcstoull, wchar_t) // NOLINT +INTERCEPTORS_STRTO(double, strtod, char) +INTERCEPTORS_STRTO(float, strtof, char) +INTERCEPTORS_STRTO(long double, strtold, char) +INTERCEPTORS_STRTO_BASE(long, strtol, char) +INTERCEPTORS_STRTO_BASE(long long, strtoll, char) +INTERCEPTORS_STRTO_BASE(unsigned long, strtoul, char) +INTERCEPTORS_STRTO_BASE(unsigned long long, strtoull, char) +INTERCEPTORS_STRTO_BASE(u64, strtouq, char) + +INTERCEPTORS_STRTO(double, wcstod, wchar_t) +INTERCEPTORS_STRTO(float, wcstof, wchar_t) +INTERCEPTORS_STRTO(long double, wcstold, wchar_t) +INTERCEPTORS_STRTO_BASE(long, wcstol, wchar_t) +INTERCEPTORS_STRTO_BASE(long long, wcstoll, wchar_t) +INTERCEPTORS_STRTO_BASE(unsigned long, wcstoul, wchar_t) +INTERCEPTORS_STRTO_BASE(unsigned long long, wcstoull, wchar_t) #if SANITIZER_NETBSD #define INTERCEPT_STRTO(func) \ @@ -1514,13 +1514,12 @@ INTERCEPTOR(wchar_t *, wcscpy, wchar_t *dest, const wchar_t *src) { return res; } -INTERCEPTOR(wchar_t *, wcsncpy, wchar_t *dest, const wchar_t *src, - SIZE_T n) { // NOLINT +INTERCEPTOR(wchar_t *, wcsncpy, wchar_t *dest, const wchar_t *src, SIZE_T n) { ENSURE_MSAN_INITED(); GET_STORE_STACK_TRACE; SIZE_T copy_size = REAL(wcsnlen)(src, n); if (copy_size < n) copy_size++; // trailing \0 - wchar_t *res = REAL(wcsncpy)(dest, src, n); // NOLINT + wchar_t *res = REAL(wcsncpy)(dest, src, n); CopyShadowAndOrigin(dest, src, copy_size * sizeof(wchar_t), &stack); __msan_unpoison(dest + copy_size, (n - copy_size) * sizeof(wchar_t)); return res; @@ -1620,14 +1619,14 @@ void InitializeInterceptors() { INTERCEPT_FUNCTION(wmemcpy); MSAN_MAYBE_INTERCEPT_WMEMPCPY; INTERCEPT_FUNCTION(wmemmove); - INTERCEPT_FUNCTION(strcpy); // NOLINT - MSAN_MAYBE_INTERCEPT_STPCPY; // NOLINT + INTERCEPT_FUNCTION(strcpy); + MSAN_MAYBE_INTERCEPT_STPCPY; INTERCEPT_FUNCTION(strdup); MSAN_MAYBE_INTERCEPT___STRDUP; - INTERCEPT_FUNCTION(strncpy); // NOLINT + INTERCEPT_FUNCTION(strncpy); MSAN_MAYBE_INTERCEPT_GCVT; - INTERCEPT_FUNCTION(strcat); // NOLINT - INTERCEPT_FUNCTION(strncat); // NOLINT + INTERCEPT_FUNCTION(strcat); + INTERCEPT_FUNCTION(strncat); INTERCEPT_STRTO(strtod); INTERCEPT_STRTO(strtof); INTERCEPT_STRTO(strtold); diff --git a/lib/msan/msan_new_delete.cpp b/lib/msan/msan_new_delete.cpp index 04b77d64d..d4e95c0f6 100644 --- a/lib/msan/msan_new_delete.cpp +++ b/lib/msan/msan_new_delete.cpp @@ -20,7 +20,7 @@ #include <stddef.h> -using namespace __msan; // NOLINT +using namespace __msan; // Fake std::nothrow_t and std::align_val_t to avoid including <new>. namespace std { diff --git a/lib/msan/tests/msan_test.cpp b/lib/msan/tests/msan_test.cpp index 33a3fbb1f..c1cae3dad 100644 --- a/lib/msan/tests/msan_test.cpp +++ b/lib/msan/tests/msan_test.cpp @@ -130,14 +130,14 @@ static uintptr_t GetPageSize() { const size_t kMaxPathLength = 4096; -typedef unsigned char U1; -typedef unsigned short U2; // NOLINT -typedef unsigned int U4; -typedef unsigned long long U8; // NOLINT -typedef signed char S1; -typedef signed short S2; // NOLINT -typedef signed int S4; -typedef signed long long S8; // NOLINT +typedef unsigned char U1; +typedef unsigned short U2; +typedef unsigned int U4; +typedef unsigned long long U8; +typedef signed char S1; +typedef signed short S2; +typedef signed int S4; +typedef signed long long S8; #define NOINLINE __attribute__((noinline)) #define INLINE __attribute__((always_inline)) @@ -1654,25 +1654,25 @@ TEST(MemorySanitizer, overlap_memmove) { TestOverlapMemmove<U8, 1000>(); } -TEST(MemorySanitizer, strcpy) { // NOLINT +TEST(MemorySanitizer, strcpy) { char* x = new char[3]; char* y = new char[3]; x[0] = 'a'; x[1] = *GetPoisoned<char>(1, 1); x[2] = 0; - strcpy(y, x); // NOLINT + strcpy(y, x); EXPECT_NOT_POISONED(y[0]); EXPECT_POISONED(y[1]); EXPECT_NOT_POISONED(y[2]); } -TEST(MemorySanitizer, strncpy) { // NOLINT +TEST(MemorySanitizer, strncpy) { char* x = new char[3]; char* y = new char[5]; x[0] = 'a'; x[1] = *GetPoisoned<char>(1, 1); x[2] = '\0'; - strncpy(y, x, 4); // NOLINT + strncpy(y, x, 4); EXPECT_NOT_POISONED(y[0]); EXPECT_POISONED(y[1]); EXPECT_NOT_POISONED(y[2]); @@ -1680,20 +1680,20 @@ TEST(MemorySanitizer, strncpy) { // NOLINT EXPECT_POISONED(y[4]); } -TEST(MemorySanitizer, stpcpy) { // NOLINT +TEST(MemorySanitizer, stpcpy) { char* x = new char[3]; char* y = new char[3]; x[0] = 'a'; x[1] = *GetPoisoned<char>(1, 1); x[2] = 0; - char *res = stpcpy(y, x); // NOLINT + char *res = stpcpy(y, x); ASSERT_EQ(res, y + 2); EXPECT_NOT_POISONED(y[0]); EXPECT_POISONED(y[1]); EXPECT_NOT_POISONED(y[2]); } -TEST(MemorySanitizer, strcat) { // NOLINT +TEST(MemorySanitizer, strcat) { char a[10]; char b[] = "def"; strcpy(a, "abc"); @@ -1706,7 +1706,7 @@ TEST(MemorySanitizer, strcat) { // NOLINT EXPECT_POISONED(a[7]); } -TEST(MemorySanitizer, strncat) { // NOLINT +TEST(MemorySanitizer, strncat) { char a[10]; char b[] = "def"; strcpy(a, "abc"); @@ -1719,7 +1719,7 @@ TEST(MemorySanitizer, strncat) { // NOLINT EXPECT_POISONED(a[7]); } -TEST(MemorySanitizer, strncat_overflow) { // NOLINT +TEST(MemorySanitizer, strncat_overflow) { char a[10]; char b[] = "def"; strcpy(a, "abc"); @@ -2005,11 +2005,11 @@ TEST(MemorySanitizer, lrand48_r) { } #endif -TEST(MemorySanitizer, sprintf) { // NOLINT +TEST(MemorySanitizer, sprintf) { char buff[10]; break_optimization(buff); EXPECT_POISONED(buff[0]); - int res = sprintf(buff, "%d", 1234567); // NOLINT + int res = sprintf(buff, "%d", 1234567); ASSERT_EQ(res, 7); ASSERT_EQ(buff[0], '1'); ASSERT_EQ(buff[1], '2'); @@ -2048,10 +2048,10 @@ TEST(MemorySanitizer, swprintf) { EXPECT_POISONED(buff[8]); } -TEST(MemorySanitizer, asprintf) { // NOLINT +TEST(MemorySanitizer, asprintf) { char *pbuf; EXPECT_POISONED(pbuf); - int res = asprintf(&pbuf, "%d", 1234567); // NOLINT + int res = asprintf(&pbuf, "%d", 1234567); ASSERT_EQ(res, 7); EXPECT_NOT_POISONED(pbuf); ASSERT_EQ(pbuf[0], '1'); @@ -4292,7 +4292,7 @@ TEST(MemorySanitizerOrigins, InitializedStoreDoesNotChangeOrigin) { if (!TrackingOrigins()) return; S s; - U4 origin = rand(); // NOLINT + U4 origin = rand(); s.a = *GetPoisonedO<U2>(0, origin); EXPECT_ORIGIN(origin, __msan_get_origin(&s.a)); EXPECT_ORIGIN(origin, __msan_get_origin(&s.b)); diff --git a/lib/sanitizer_common/sanitizer_allocator_checks.h b/lib/sanitizer_common/sanitizer_allocator_checks.h index f436ce9ec..fc426f0e7 100644 --- a/lib/sanitizer_common/sanitizer_allocator_checks.h +++ b/lib/sanitizer_common/sanitizer_allocator_checks.h @@ -54,7 +54,7 @@ INLINE bool CheckAlignedAllocAlignmentAndSize(uptr alignment, uptr size) { // and a multiple of sizeof(void *). INLINE bool CheckPosixMemalignAlignment(uptr alignment) { return alignment != 0 && IsPowerOfTwo(alignment) && - (alignment % sizeof(void *)) == 0; // NOLINT + (alignment % sizeof(void *)) == 0; } // Returns true if calloc(size, n) call overflows on size*n calculation. diff --git a/lib/sanitizer_common/sanitizer_allocator_report.cpp b/lib/sanitizer_common/sanitizer_allocator_report.cpp index dbcf2b7bf..d74e08010 100644 --- a/lib/sanitizer_common/sanitizer_allocator_report.cpp +++ b/lib/sanitizer_common/sanitizer_allocator_report.cpp @@ -106,10 +106,11 @@ void NORETURN ReportInvalidPosixMemalignAlignment(uptr alignment, { ScopedAllocatorErrorReport report("invalid-posix-memalign-alignment", stack); - Report("ERROR: %s: invalid alignment requested in " - "posix_memalign: %zd, alignment must be a power of two and a " - "multiple of sizeof(void*) == %zd\n", SanitizerToolName, alignment, - sizeof(void*)); // NOLINT + Report( + "ERROR: %s: invalid alignment requested in " + "posix_memalign: %zd, alignment must be a power of two and a " + "multiple of sizeof(void*) == %zd\n", + SanitizerToolName, alignment, sizeof(void *)); } Die(); } diff --git a/lib/sanitizer_common/sanitizer_asm.h b/lib/sanitizer_common/sanitizer_asm.h index 184d118d9..803af3285 100644 --- a/lib/sanitizer_common/sanitizer_asm.h +++ b/lib/sanitizer_common/sanitizer_asm.h @@ -60,7 +60,9 @@ #if defined(__ELF__) && (defined(__GNU__) || defined(__FreeBSD__) || \ defined(__Fuchsia__) || defined(__linux__)) -#define NO_EXEC_STACK_DIRECTIVE .section .note.GNU-stack,"",%progbits // NOLINT +// clang-format off +#define NO_EXEC_STACK_DIRECTIVE .section .note.GNU-stack,"",%progbits // NOLINT +// clang-format on #else #define NO_EXEC_STACK_DIRECTIVE #endif diff --git a/lib/sanitizer_common/sanitizer_atomic_msvc.h b/lib/sanitizer_common/sanitizer_atomic_msvc.h index a249657d6..6a7c5465d 100644 --- a/lib/sanitizer_common/sanitizer_atomic_msvc.h +++ b/lib/sanitizer_common/sanitizer_atomic_msvc.h @@ -20,44 +20,35 @@ extern "C" void _mm_mfence(); #pragma intrinsic(_mm_mfence) extern "C" void _mm_pause(); #pragma intrinsic(_mm_pause) -extern "C" char _InterlockedExchange8( // NOLINT - char volatile *Addend, char Value); // NOLINT +extern "C" char _InterlockedExchange8(char volatile *Addend, char Value); #pragma intrinsic(_InterlockedExchange8) -extern "C" short _InterlockedExchange16( // NOLINT - short volatile *Addend, short Value); // NOLINT +extern "C" short _InterlockedExchange16(short volatile *Addend, short Value); #pragma intrinsic(_InterlockedExchange16) -extern "C" long _InterlockedExchange( // NOLINT - long volatile *Addend, long Value); // NOLINT +extern "C" long _InterlockedExchange(long volatile *Addend, long Value); #pragma intrinsic(_InterlockedExchange) -extern "C" long _InterlockedExchangeAdd( // NOLINT - long volatile * Addend, long Value); // NOLINT +extern "C" long _InterlockedExchangeAdd(long volatile *Addend, long Value); #pragma intrinsic(_InterlockedExchangeAdd) -extern "C" char _InterlockedCompareExchange8( // NOLINT - char volatile *Destination, // NOLINT - char Exchange, char Comparand); // NOLINT +extern "C" char _InterlockedCompareExchange8(char volatile *Destination, + char Exchange, char Comparand); #pragma intrinsic(_InterlockedCompareExchange8) -extern "C" short _InterlockedCompareExchange16( // NOLINT - short volatile *Destination, // NOLINT - short Exchange, short Comparand); // NOLINT +extern "C" short _InterlockedCompareExchange16(short volatile *Destination, + short Exchange, short Comparand); #pragma intrinsic(_InterlockedCompareExchange16) -extern "C" -long long _InterlockedCompareExchange64( // NOLINT - long long volatile *Destination, // NOLINT - long long Exchange, long long Comparand); // NOLINT +extern "C" long long _InterlockedCompareExchange64( + long long volatile *Destination, long long Exchange, long long Comparand); #pragma intrinsic(_InterlockedCompareExchange64) extern "C" void *_InterlockedCompareExchangePointer( void *volatile *Destination, void *Exchange, void *Comparand); #pragma intrinsic(_InterlockedCompareExchangePointer) -extern "C" -long __cdecl _InterlockedCompareExchange( // NOLINT - long volatile *Destination, // NOLINT - long Exchange, long Comparand); // NOLINT +extern "C" long __cdecl _InterlockedCompareExchange(long volatile *Destination, + long Exchange, + long Comparand); #pragma intrinsic(_InterlockedCompareExchange) #ifdef _WIN64 -extern "C" long long _InterlockedExchangeAdd64( // NOLINT - long long volatile * Addend, long long Value); // NOLINT +extern "C" long long _InterlockedExchangeAdd64(long long volatile *Addend, + long long Value); #pragma intrinsic(_InterlockedExchangeAdd64) #endif @@ -115,8 +106,8 @@ INLINE u32 atomic_fetch_add(volatile atomic_uint32_t *a, u32 v, memory_order mo) { (void)mo; DCHECK(!((uptr)a % sizeof(*a))); - return (u32)_InterlockedExchangeAdd( - (volatile long*)&a->val_dont_use, (long)v); // NOLINT + return (u32)_InterlockedExchangeAdd((volatile long *)&a->val_dont_use, + (long)v); } INLINE uptr atomic_fetch_add(volatile atomic_uintptr_t *a, @@ -124,11 +115,11 @@ INLINE uptr atomic_fetch_add(volatile atomic_uintptr_t *a, (void)mo; DCHECK(!((uptr)a % sizeof(*a))); #ifdef _WIN64 - return (uptr)_InterlockedExchangeAdd64( - (volatile long long*)&a->val_dont_use, (long long)v); // NOLINT + return (uptr)_InterlockedExchangeAdd64((volatile long long *)&a->val_dont_use, + (long long)v); #else - return (uptr)_InterlockedExchangeAdd( - (volatile long*)&a->val_dont_use, (long)v); // NOLINT + return (uptr)_InterlockedExchangeAdd((volatile long *)&a->val_dont_use, + (long)v); #endif } @@ -136,8 +127,8 @@ INLINE u32 atomic_fetch_sub(volatile atomic_uint32_t *a, u32 v, memory_order mo) { (void)mo; DCHECK(!((uptr)a % sizeof(*a))); - return (u32)_InterlockedExchangeAdd( - (volatile long*)&a->val_dont_use, -(long)v); // NOLINT + return (u32)_InterlockedExchangeAdd((volatile long *)&a->val_dont_use, + -(long)v); } INLINE uptr atomic_fetch_sub(volatile atomic_uintptr_t *a, @@ -145,11 +136,11 @@ INLINE uptr atomic_fetch_sub(volatile atomic_uintptr_t *a, (void)mo; DCHECK(!((uptr)a % sizeof(*a))); #ifdef _WIN64 - return (uptr)_InterlockedExchangeAdd64( - (volatile long long*)&a->val_dont_use, -(long long)v); // NOLINT + return (uptr)_InterlockedExchangeAdd64((volatile long long *)&a->val_dont_use, + -(long long)v); #else - return (uptr)_InterlockedExchangeAdd( - (volatile long*)&a->val_dont_use, -(long)v); // NOLINT + return (uptr)_InterlockedExchangeAdd((volatile long *)&a->val_dont_use, + -(long)v); #endif } diff --git a/lib/sanitizer_common/sanitizer_common.cpp b/lib/sanitizer_common/sanitizer_common.cpp index 451c9e526..f5f9f49d8 100644 --- a/lib/sanitizer_common/sanitizer_common.cpp +++ b/lib/sanitizer_common/sanitizer_common.cpp @@ -323,7 +323,7 @@ static int InstallMallocFreeHooks(void (*malloc_hook)(const void *, uptr), } // namespace __sanitizer -using namespace __sanitizer; // NOLINT +using namespace __sanitizer; extern "C" { SANITIZER_INTERFACE_WEAK_DEF(void, __sanitizer_report_error_summary, diff --git a/lib/sanitizer_common/sanitizer_common.h b/lib/sanitizer_common/sanitizer_common.h index b5dc6e1d0..ad056df38 100644 --- a/lib/sanitizer_common/sanitizer_common.h +++ b/lib/sanitizer_common/sanitizer_common.h @@ -339,18 +339,18 @@ void ReportMmapWriteExec(int prot); // Math #if SANITIZER_WINDOWS && !defined(__clang__) && !defined(__GNUC__) extern "C" { -unsigned char _BitScanForward(unsigned long *index, unsigned long mask); // NOLINT -unsigned char _BitScanReverse(unsigned long *index, unsigned long mask); // NOLINT +unsigned char _BitScanForward(unsigned long *index, unsigned long mask); +unsigned char _BitScanReverse(unsigned long *index, unsigned long mask); #if defined(_WIN64) -unsigned char _BitScanForward64(unsigned long *index, unsigned __int64 mask); // NOLINT -unsigned char _BitScanReverse64(unsigned long *index, unsigned __int64 mask); // NOLINT +unsigned char _BitScanForward64(unsigned long *index, unsigned __int64 mask); +unsigned char _BitScanReverse64(unsigned long *index, unsigned __int64 mask); #endif } #endif INLINE uptr MostSignificantSetBitIndex(uptr x) { CHECK_NE(x, 0U); - unsigned long up; // NOLINT + unsigned long up; #if !SANITIZER_WINDOWS || defined(__clang__) || defined(__GNUC__) # ifdef _WIN64 up = SANITIZER_WORDSIZE - 1 - __builtin_clzll(x); @@ -367,7 +367,7 @@ INLINE uptr MostSignificantSetBitIndex(uptr x) { INLINE uptr LeastSignificantSetBitIndex(uptr x) { CHECK_NE(x, 0U); - unsigned long up; // NOLINT + unsigned long up; #if !SANITIZER_WINDOWS || defined(__clang__) || defined(__GNUC__) # ifdef _WIN64 up = __builtin_ctzll(x); diff --git a/lib/sanitizer_common/sanitizer_common_interceptors.inc b/lib/sanitizer_common/sanitizer_common_interceptors.inc index 9975f5321..fe992bf29 100644 --- a/lib/sanitizer_common/sanitizer_common_interceptors.inc +++ b/lib/sanitizer_common/sanitizer_common_interceptors.inc @@ -1267,9 +1267,8 @@ INTERCEPTOR(int, puts, char *s) { #endif #if SANITIZER_INTERCEPT_PRCTL -INTERCEPTOR(int, prctl, int option, unsigned long arg2, - unsigned long arg3, // NOLINT - unsigned long arg4, unsigned long arg5) { // NOLINT +INTERCEPTOR(int, prctl, int option, unsigned long arg2, unsigned long arg3, + unsigned long arg4, unsigned long arg5) { void *ctx; COMMON_INTERCEPTOR_ENTER(ctx, prctl, option, arg2, arg3, arg4, arg5); static const int PR_SET_NAME = 15; @@ -1701,13 +1700,13 @@ INTERCEPTOR(int, __fprintf_chk, __sanitizer_FILE *stream, SIZE_T size, FORMAT_INTERCEPTOR_IMPL(__fprintf_chk, vfprintf, stream, format) #endif -INTERCEPTOR(int, sprintf, char *str, const char *format, ...) // NOLINT -FORMAT_INTERCEPTOR_IMPL(sprintf, vsprintf, str, format) // NOLINT +INTERCEPTOR(int, sprintf, char *str, const char *format, ...) +FORMAT_INTERCEPTOR_IMPL(sprintf, vsprintf, str, format) #if SANITIZER_INTERCEPT___PRINTF_CHK INTERCEPTOR(int, __sprintf_chk, char *str, int flag, SIZE_T size_to, - const char *format, ...) // NOLINT -FORMAT_INTERCEPTOR_IMPL(__sprintf_chk, vsprintf, str, format) // NOLINT + const char *format, ...) +FORMAT_INTERCEPTOR_IMPL(__sprintf_chk, vsprintf, str, format) #endif INTERCEPTOR(int, snprintf, char *str, SIZE_T size, const char *format, ...) @@ -1715,8 +1714,8 @@ FORMAT_INTERCEPTOR_IMPL(snprintf, vsnprintf, str, size, format) #if SANITIZER_INTERCEPT___PRINTF_CHK INTERCEPTOR(int, __snprintf_chk, char *str, SIZE_T size, int flag, - SIZE_T size_to, const char *format, ...) // NOLINT -FORMAT_INTERCEPTOR_IMPL(__snprintf_chk, vsnprintf, str, size, format) // NOLINT + SIZE_T size_to, const char *format, ...) +FORMAT_INTERCEPTOR_IMPL(__snprintf_chk, vsnprintf, str, size, format) #endif INTERCEPTOR(int, asprintf, char **strp, const char *format, ...) @@ -6716,7 +6715,7 @@ INTERCEPTOR(wchar_t *, wcscat, wchar_t *dst, const wchar_t *src) { COMMON_INTERCEPTOR_READ_RANGE(ctx, dst, (dst_size + 1) * sizeof(wchar_t)); COMMON_INTERCEPTOR_WRITE_RANGE(ctx, dst + dst_size, (src_size + 1) * sizeof(wchar_t)); - return REAL(wcscat)(dst, src); // NOLINT + return REAL(wcscat)(dst, src); } INTERCEPTOR(wchar_t *, wcsncat, wchar_t *dst, const wchar_t *src, SIZE_T n) { @@ -6729,7 +6728,7 @@ INTERCEPTOR(wchar_t *, wcsncat, wchar_t *dst, const wchar_t *src, SIZE_T n) { COMMON_INTERCEPTOR_READ_RANGE(ctx, dst, (dst_size + 1) * sizeof(wchar_t)); COMMON_INTERCEPTOR_WRITE_RANGE(ctx, dst + dst_size, (src_size + 1) * sizeof(wchar_t)); - return REAL(wcsncat)(dst, src, n); // NOLINT + return REAL(wcsncat)(dst, src, n); } #define INIT_WCSCAT \ COMMON_INTERCEPT_FUNCTION(wcscat); \ @@ -9568,8 +9567,7 @@ INTERCEPTOR(SSIZE_T, getrandom, void *buf, SIZE_T buflen, unsigned int flags) { static void InitializeCommonInterceptors() { #if SI_POSIX static u64 metadata_mem[sizeof(MetadataHashMap) / sizeof(u64) + 1]; - interceptor_metadata_map = - new ((void *)&metadata_mem) MetadataHashMap(); // NOLINT + interceptor_metadata_map = new ((void *)&metadata_mem) MetadataHashMap(); #endif INIT_MMAP; diff --git a/lib/sanitizer_common/sanitizer_coverage_fuchsia.cpp b/lib/sanitizer_common/sanitizer_coverage_fuchsia.cpp index 5451d1e75..f18cee66b 100644 --- a/lib/sanitizer_common/sanitizer_coverage_fuchsia.cpp +++ b/lib/sanitizer_common/sanitizer_coverage_fuchsia.cpp @@ -36,7 +36,7 @@ #include <zircon/sanitizer.h> #include <zircon/syscalls.h> -using namespace __sanitizer; // NOLINT +using namespace __sanitizer; namespace __sancov { namespace { @@ -198,8 +198,8 @@ void InitializeCoverage(bool enabled, const char *dir) { } // namespace __sanitizer extern "C" { -SANITIZER_INTERFACE_ATTRIBUTE void __sanitizer_dump_coverage( // NOLINT - const uptr *pcs, uptr len) { +SANITIZER_INTERFACE_ATTRIBUTE void __sanitizer_dump_coverage(const uptr *pcs, + uptr len) { UNIMPLEMENTED(); } diff --git a/lib/sanitizer_common/sanitizer_coverage_libcdep_new.cpp b/lib/sanitizer_common/sanitizer_coverage_libcdep_new.cpp index ad137f936..6a75792f9 100644 --- a/lib/sanitizer_common/sanitizer_coverage_libcdep_new.cpp +++ b/lib/sanitizer_common/sanitizer_coverage_libcdep_new.cpp @@ -166,8 +166,8 @@ void InitializeCoverage(bool enabled, const char *dir) { } // namespace __sanitizer extern "C" { -SANITIZER_INTERFACE_ATTRIBUTE void __sanitizer_dump_coverage( // NOLINT - const uptr* pcs, uptr len) { +SANITIZER_INTERFACE_ATTRIBUTE void __sanitizer_dump_coverage(const uptr* pcs, + uptr len) { return __sancov::SanitizerDumpCoverage(pcs, len); } diff --git a/lib/sanitizer_common/sanitizer_coverage_win_sections.cpp b/lib/sanitizer_common/sanitizer_coverage_win_sections.cpp index 40184bbb9..e7d656339 100644 --- a/lib/sanitizer_common/sanitizer_coverage_win_sections.cpp +++ b/lib/sanitizer_common/sanitizer_coverage_win_sections.cpp @@ -31,7 +31,7 @@ extern "C" { // Use uint64_t so the linker won't need to add any padding if it tries to word // align the start of the 8-bit counters array. The array will always start 8 // bytes after __start_sancov_cntrs. -#pragma section(".SCOV$CA", read, write) // NOLINT +#pragma section(".SCOV$CA", read, write) __declspec(allocate(".SCOV$CA")) uint64_t __start___sancov_cntrs = 0; // Even though we said not to align __stop__sancov_cntrs (using the "align" @@ -41,13 +41,13 @@ __declspec(allocate(".SCOV$CA")) uint64_t __start___sancov_cntrs = 0; // padding would be added to align .SCOVP$Z, However, if .SCOV$CZ section is 1 // byte, the linker won't try to align it on an 8-byte boundary, so use a // uint8_t for __stop_sancov_cntrs. -#pragma section(".SCOV$CZ", read, write) // NOLINT +#pragma section(".SCOV$CZ", read, write) __declspec(allocate(".SCOV$CZ")) __declspec(align(1)) uint8_t __stop___sancov_cntrs = 0; -#pragma section(".SCOV$GA", read, write) // NOLINT +#pragma section(".SCOV$GA", read, write) __declspec(allocate(".SCOV$GA")) uint64_t __start___sancov_guards = 0; -#pragma section(".SCOV$GZ", read, write) // NOLINT +#pragma section(".SCOV$GZ", read, write) __declspec(allocate(".SCOV$GZ")) __declspec(align(1)) uint8_t __stop___sancov_guards = 0; @@ -56,9 +56,9 @@ __declspec(allocate(".SCOV$GZ")) __declspec(align(1)) uint8_t // constant it should be merged with the .rdata section. #pragma comment(linker, "/MERGE:.SCOV=.data") -#pragma section(".SCOVP$A", read) // NOLINT +#pragma section(".SCOVP$A", read) __declspec(allocate(".SCOVP$A")) uint64_t __start___sancov_pcs = 0; -#pragma section(".SCOVP$Z", read) // NOLINT +#pragma section(".SCOVP$Z", read) __declspec(allocate(".SCOVP$Z")) __declspec(align(1)) uint8_t __stop___sancov_pcs = 0; diff --git a/lib/sanitizer_common/sanitizer_file.cpp b/lib/sanitizer_common/sanitizer_file.cpp index c8c0b33cd..79930d794 100644 --- a/lib/sanitizer_common/sanitizer_file.cpp +++ b/lib/sanitizer_common/sanitizer_file.cpp @@ -199,7 +199,7 @@ char *FindPathToBinary(const char *name) { } // namespace __sanitizer -using namespace __sanitizer; // NOLINT +using namespace __sanitizer; extern "C" { void __sanitizer_set_report_path(const char *path) { diff --git a/lib/sanitizer_common/sanitizer_flag_parser.h b/lib/sanitizer_common/sanitizer_flag_parser.h index 8e12700bb..b68e29cd9 100644 --- a/lib/sanitizer_common/sanitizer_flag_parser.h +++ b/lib/sanitizer_common/sanitizer_flag_parser.h @@ -144,7 +144,7 @@ class FlagParser { template <typename T> static void RegisterFlag(FlagParser *parser, const char *name, const char *desc, T *var) { - FlagHandler<T> *fh = new (FlagParser::Alloc) FlagHandler<T>(var); // NOLINT + FlagHandler<T> *fh = new (FlagParser::Alloc) FlagHandler<T>(var); parser->RegisterHandler(name, fh, desc); } diff --git a/lib/sanitizer_common/sanitizer_flags.cpp b/lib/sanitizer_common/sanitizer_flags.cpp index acc7ed39c..66a0a5579 100644 --- a/lib/sanitizer_common/sanitizer_flags.cpp +++ b/lib/sanitizer_common/sanitizer_flags.cpp @@ -92,11 +92,11 @@ class FlagHandlerInclude : public FlagHandlerBase { }; void RegisterIncludeFlags(FlagParser *parser, CommonFlags *cf) { - FlagHandlerInclude *fh_include = new (FlagParser::Alloc) // NOLINT + FlagHandlerInclude *fh_include = new (FlagParser::Alloc) FlagHandlerInclude(parser, /*ignore_missing*/ false); parser->RegisterHandler("include", fh_include, "read more options from the given file"); - FlagHandlerInclude *fh_include_if_exists = new (FlagParser::Alloc) // NOLINT + FlagHandlerInclude *fh_include_if_exists = new (FlagParser::Alloc) FlagHandlerInclude(parser, /*ignore_missing*/ true); parser->RegisterHandler( "include_if_exists", fh_include_if_exists, diff --git a/lib/sanitizer_common/sanitizer_fuchsia.cpp b/lib/sanitizer_common/sanitizer_fuchsia.cpp index 3dc6863a0..6e2c6137f 100644 --- a/lib/sanitizer_common/sanitizer_fuchsia.cpp +++ b/lib/sanitizer_common/sanitizer_fuchsia.cpp @@ -502,7 +502,7 @@ uptr GetRSS() { UNIMPLEMENTED(); } } // namespace __sanitizer -using namespace __sanitizer; // NOLINT +using namespace __sanitizer; extern "C" { void __sanitizer_startup_hook(int argc, char **argv, char **envp, diff --git a/lib/sanitizer_common/sanitizer_getauxval.h b/lib/sanitizer_common/sanitizer_getauxval.h index cbd1af12c..f1ca0be43 100644 --- a/lib/sanitizer_common/sanitizer_getauxval.h +++ b/lib/sanitizer_common/sanitizer_getauxval.h @@ -38,8 +38,7 @@ // The weak getauxval definition allows to check for the function at runtime. // This is useful for Android, when compiled at a lower API level yet running // on a more recent platform that offers the function. -extern "C" SANITIZER_WEAK_ATTRIBUTE -unsigned long getauxval(unsigned long type); // NOLINT +extern "C" SANITIZER_WEAK_ATTRIBUTE unsigned long getauxval(unsigned long type); # endif #endif // SANITIZER_LINUX || SANITIZER_FUCHSIA diff --git a/lib/sanitizer_common/sanitizer_internal_defs.h b/lib/sanitizer_common/sanitizer_internal_defs.h index e0c6506be..00226305e 100644 --- a/lib/sanitizer_common/sanitizer_internal_defs.h +++ b/lib/sanitizer_common/sanitizer_internal_defs.h @@ -133,27 +133,27 @@ namespace __sanitizer { #if defined(_WIN64) // 64-bit Windows uses LLP64 data model. -typedef unsigned long long uptr; // NOLINT -typedef signed long long sptr; // NOLINT +typedef unsigned long long uptr; +typedef signed long long sptr; #else -typedef unsigned long uptr; // NOLINT -typedef signed long sptr; // NOLINT +typedef unsigned long uptr; +typedef signed long sptr; #endif // defined(_WIN64) #if defined(__x86_64__) // Since x32 uses ILP32 data model in 64-bit hardware mode, we must use // 64-bit pointer to unwind stack frame. -typedef unsigned long long uhwptr; // NOLINT +typedef unsigned long long uhwptr; #else -typedef uptr uhwptr; // NOLINT +typedef uptr uhwptr; #endif typedef unsigned char u8; -typedef unsigned short u16; // NOLINT +typedef unsigned short u16; typedef unsigned int u32; -typedef unsigned long long u64; // NOLINT -typedef signed char s8; -typedef signed short s16; // NOLINT -typedef signed int s32; -typedef signed long long s64; // NOLINT +typedef unsigned long long u64; +typedef signed char s8; +typedef signed short s16; +typedef signed int s32; +typedef signed long long s64; #if SANITIZER_WINDOWS // On Windows, files are HANDLE, which is a synonim of void*. // Use void* to avoid including <windows.h> everywhere. @@ -264,7 +264,7 @@ typedef ALIGNED(1) s64 us64; #if SANITIZER_WINDOWS } // namespace __sanitizer -typedef unsigned long DWORD; // NOLINT +typedef unsigned long DWORD; namespace __sanitizer { typedef DWORD thread_return_t; # define THREAD_CALLING_CONV __stdcall @@ -419,18 +419,41 @@ inline void Trap() { } // namespace __sanitizer -namespace __asan { using namespace __sanitizer; } // NOLINT -namespace __dsan { using namespace __sanitizer; } // NOLINT -namespace __dfsan { using namespace __sanitizer; } // NOLINT -namespace __lsan { using namespace __sanitizer; } // NOLINT -namespace __msan { using namespace __sanitizer; } // NOLINT -namespace __hwasan { using namespace __sanitizer; } // NOLINT -namespace __tsan { using namespace __sanitizer; } // NOLINT -namespace __scudo { using namespace __sanitizer; } // NOLINT -namespace __ubsan { using namespace __sanitizer; } // NOLINT -namespace __xray { using namespace __sanitizer; } // NOLINT -namespace __interception { using namespace __sanitizer; } // NOLINT -namespace __hwasan { using namespace __sanitizer; } // NOLINT - +namespace __asan { +using namespace __sanitizer; +} +namespace __dsan { +using namespace __sanitizer; +} +namespace __dfsan { +using namespace __sanitizer; +} +namespace __lsan { +using namespace __sanitizer; +} +namespace __msan { +using namespace __sanitizer; +} +namespace __hwasan { +using namespace __sanitizer; +} +namespace __tsan { +using namespace __sanitizer; +} +namespace __scudo { +using namespace __sanitizer; +} +namespace __ubsan { +using namespace __sanitizer; +} +namespace __xray { +using namespace __sanitizer; +} +namespace __interception { +using namespace __sanitizer; +} +namespace __hwasan { +using namespace __sanitizer; +} #endif // SANITIZER_DEFS_H diff --git a/lib/sanitizer_common/sanitizer_platform_interceptors.h b/lib/sanitizer_common/sanitizer_platform_interceptors.h index 97afb5ea2..cf079c435 100644 --- a/lib/sanitizer_common/sanitizer_platform_interceptors.h +++ b/lib/sanitizer_common/sanitizer_platform_interceptors.h @@ -331,10 +331,9 @@ #define SANITIZER_INTERCEPT_ETHER_HOST \ (SI_FREEBSD || SI_MAC || SI_LINUX_NOT_ANDROID) #define SANITIZER_INTERCEPT_ETHER_R (SI_FREEBSD || SI_LINUX_NOT_ANDROID) -#define SANITIZER_INTERCEPT_SHMCTL \ - (SI_NETBSD || SI_OPENBSD || SI_SOLARIS || \ - ((SI_FREEBSD || SI_LINUX_NOT_ANDROID) && \ - SANITIZER_WORDSIZE == 64)) // NOLINT +#define SANITIZER_INTERCEPT_SHMCTL \ + (((SI_FREEBSD || SI_LINUX_NOT_ANDROID) && SANITIZER_WORDSIZE == 64) || \ + SI_NETBSD || SI_OPENBSD || SI_SOLARIS) // NOLINT #define SANITIZER_INTERCEPT_RANDOM_R SI_LINUX_NOT_ANDROID #define SANITIZER_INTERCEPT_PTHREAD_ATTR_GET SI_POSIX #define SANITIZER_INTERCEPT_PTHREAD_ATTR_GETINHERITSCHED \ diff --git a/lib/sanitizer_common/sanitizer_platform_limits_freebsd.h b/lib/sanitizer_common/sanitizer_platform_limits_freebsd.h index 6b09cdca2..71cf5b9c3 100644 --- a/lib/sanitizer_common/sanitizer_platform_limits_freebsd.h +++ b/lib/sanitizer_common/sanitizer_platform_limits_freebsd.h @@ -268,9 +268,8 @@ typedef struct { // This thing depends on the platform. We are only interested in the upper // limit. Verified with a compiler assert in .cpp. -const int pthread_attr_t_max_sz = 128; union __sanitizer_pthread_attr_t { - char size[pthread_attr_t_max_sz]; // NOLINT + char size[128]; void *align; }; diff --git a/lib/sanitizer_common/sanitizer_platform_limits_posix.h b/lib/sanitizer_common/sanitizer_platform_limits_posix.h index 1a4353cdf..b53ca112e 100644 --- a/lib/sanitizer_common/sanitizer_platform_limits_posix.h +++ b/lib/sanitizer_common/sanitizer_platform_limits_posix.h @@ -546,9 +546,8 @@ typedef struct { // This thing depends on the platform. We are only interested in the upper // limit. Verified with a compiler assert in .cpp. -const int pthread_attr_t_max_sz = 128; union __sanitizer_pthread_attr_t { - char size[pthread_attr_t_max_sz]; // NOLINT + char size[128]; void *align; }; diff --git a/lib/sanitizer_common/sanitizer_platform_limits_solaris.h b/lib/sanitizer_common/sanitizer_platform_limits_solaris.h index 018201895..77ae6e6a4 100644 --- a/lib/sanitizer_common/sanitizer_platform_limits_solaris.h +++ b/lib/sanitizer_common/sanitizer_platform_limits_solaris.h @@ -237,9 +237,8 @@ typedef int __sanitizer_clockid_t; // This thing depends on the platform. We are only interested in the upper // limit. Verified with a compiler assert in .cpp. -const int pthread_attr_t_max_sz = 128; union __sanitizer_pthread_attr_t { - char size[pthread_attr_t_max_sz]; // NOLINT + char size[128]; void *align; }; diff --git a/lib/sanitizer_common/sanitizer_stacktrace_libcdep.cpp b/lib/sanitizer_common/sanitizer_stacktrace_libcdep.cpp index 2c08274f3..4ef305cf1 100644 --- a/lib/sanitizer_common/sanitizer_stacktrace_libcdep.cpp +++ b/lib/sanitizer_common/sanitizer_stacktrace_libcdep.cpp @@ -150,8 +150,9 @@ void __sanitizer_symbolize_global(uptr data_addr, const char *fmt, } SANITIZER_INTERFACE_ATTRIBUTE -int __sanitizer_get_module_and_offset_for_pc( // NOLINT - uptr pc, char *module_name, uptr module_name_len, uptr *pc_offset) { +int __sanitizer_get_module_and_offset_for_pc(uptr pc, char *module_name, + uptr module_name_len, + uptr *pc_offset) { return __sanitizer::GetModuleAndOffsetForPc(pc, module_name, module_name_len, pc_offset); } diff --git a/lib/sanitizer_common/sanitizer_termination.cpp b/lib/sanitizer_common/sanitizer_termination.cpp index e588c93b9..84be6fc32 100644 --- a/lib/sanitizer_common/sanitizer_termination.cpp +++ b/lib/sanitizer_common/sanitizer_termination.cpp @@ -84,7 +84,7 @@ void NORETURN CheckFailed(const char *file, int line, const char *cond, } // namespace __sanitizer -using namespace __sanitizer; // NOLINT +using namespace __sanitizer; extern "C" { SANITIZER_INTERFACE_ATTRIBUTE diff --git a/lib/sanitizer_common/sanitizer_win.cpp b/lib/sanitizer_common/sanitizer_win.cpp index 9f72ec159..ce2a4314a 100644 --- a/lib/sanitizer_common/sanitizer_win.cpp +++ b/lib/sanitizer_common/sanitizer_win.cpp @@ -676,7 +676,7 @@ static int RunAtexit() { return ret; } -#pragma section(".CRT$XID", long, read) // NOLINT +#pragma section(".CRT$XID", long, read) __declspec(allocate(".CRT$XID")) int (*__run_atexit)() = RunAtexit; #endif diff --git a/lib/sanitizer_common/sanitizer_win_dll_thunk.cpp b/lib/sanitizer_common/sanitizer_win_dll_thunk.cpp index aa0eb4d43..1562c161a 100644 --- a/lib/sanitizer_common/sanitizer_win_dll_thunk.cpp +++ b/lib/sanitizer_common/sanitizer_win_dll_thunk.cpp @@ -54,8 +54,8 @@ int dllThunkInterceptWhenPossible(const char* main_function, #define INTERFACE_WEAK_FUNCTION(Name) INTERCEPT_SANITIZER_WEAK_FUNCTION(Name) #include "sanitizer_common_interface.inc" -#pragma section(".DLLTH$A", read) // NOLINT -#pragma section(".DLLTH$Z", read) // NOLINT +#pragma section(".DLLTH$A", read) +#pragma section(".DLLTH$Z", read) typedef void (*DllThunkCB)(); extern "C" { @@ -85,7 +85,7 @@ extern "C" int __dll_thunk_init() { // We want to call dll_thunk_init before C/C++ initializers / constructors are // executed, otherwise functions like memset might be invoked. -#pragma section(".CRT$XIB", long, read) // NOLINT +#pragma section(".CRT$XIB", long, read) __declspec(allocate(".CRT$XIB")) int (*__dll_thunk_preinit)() = __dll_thunk_init; @@ -94,7 +94,7 @@ static void WINAPI dll_thunk_thread_init(void *mod, unsigned long reason, if (reason == /*DLL_PROCESS_ATTACH=*/1) __dll_thunk_init(); } -#pragma section(".CRT$XLAB", long, read) // NOLINT +#pragma section(".CRT$XLAB", long, read) __declspec(allocate(".CRT$XLAB")) void (WINAPI *__dll_thunk_tls_init)(void *, unsigned long, void *) = dll_thunk_thread_init; diff --git a/lib/sanitizer_common/sanitizer_win_weak_interception.cpp b/lib/sanitizer_common/sanitizer_win_weak_interception.cpp index a6f34c277..a6081a893 100644 --- a/lib/sanitizer_common/sanitizer_win_weak_interception.cpp +++ b/lib/sanitizer_common/sanitizer_win_weak_interception.cpp @@ -53,8 +53,8 @@ void __sanitizer_weak_hook_strstr(uptr called_pc, const char *s1, #define INTERFACE_WEAK_FUNCTION(Name) INTERCEPT_SANITIZER_WEAK_FUNCTION(Name) #include "sanitizer_common_interface.inc" -#pragma section(".WEAK$A", read) // NOLINT -#pragma section(".WEAK$Z", read) // NOLINT +#pragma section(".WEAK$A", read) +#pragma section(".WEAK$Z", read) typedef void (*InterceptCB)(); extern "C" { @@ -77,7 +77,7 @@ static int weak_intercept_init() { return 0; } -#pragma section(".CRT$XIB", long, read) // NOLINT +#pragma section(".CRT$XIB", long, read) __declspec(allocate(".CRT$XIB")) int (*__weak_intercept_preinit)() = weak_intercept_init; @@ -86,7 +86,7 @@ static void WINAPI weak_intercept_thread_init(void *mod, unsigned long reason, if (reason == /*DLL_PROCESS_ATTACH=*/1) weak_intercept_init(); } -#pragma section(".CRT$XLAB", long, read) // NOLINT +#pragma section(".CRT$XLAB", long, read) __declspec(allocate(".CRT$XLAB")) void(WINAPI *__weak_intercept_tls_init)( void *, unsigned long, void *) = weak_intercept_thread_init; diff --git a/lib/sanitizer_common/scripts/check_lint.sh b/lib/sanitizer_common/scripts/check_lint.sh index fb7eeecf4..fc5bfca66 100755 --- a/lib/sanitizer_common/scripts/check_lint.sh +++ b/lib/sanitizer_common/scripts/check_lint.sh @@ -17,16 +17,16 @@ fi # Filters # TODO: remove some of these filters COMMON_LINT_FILTER=-build/include,-build/header_guard,-legal/copyright,-whitespace/comments,-readability/casting,\ --build/namespaces,-readability/braces,-build/c++11 +-build/namespaces,-readability/braces,-build/c++11,-runtime/int -COMMON_LIT_TEST_LINT_FILTER=-whitespace/indent,-whitespace/line_length +COMMON_LIT_TEST_LINT_FILTER=-whitespace/indent,-whitespace/line_length,-runtime/arrays -ASAN_RTL_LINT_FILTER=${COMMON_LINT_FILTER},-runtime/int -ASAN_TEST_LINT_FILTER=${COMMON_LINT_FILTER},-runtime/sizeof,-runtime/int,-runtime/printf,-runtime/threadsafe_fn +ASAN_RTL_LINT_FILTER=${COMMON_LINT_FILTER} +ASAN_TEST_LINT_FILTER=${COMMON_LINT_FILTER},-runtime/sizeof,-runtime/printf,-runtime/threadsafe_fn ASAN_LIT_TEST_LINT_FILTER=${ASAN_TEST_LINT_FILTER},${COMMON_LIT_TEST_LINT_FILTER} TSAN_RTL_LINT_FILTER=${COMMON_LINT_FILTER} -TSAN_TEST_LINT_FILTER=${TSAN_RTL_LINT_FILTER},-runtime/threadsafe_fn,-runtime/int +TSAN_TEST_LINT_FILTER=${TSAN_RTL_LINT_FILTER},-runtime/threadsafe_fn TSAN_LIT_TEST_LINT_FILTER=${TSAN_TEST_LINT_FILTER},${COMMON_LIT_TEST_LINT_FILTER} MSAN_RTL_LINT_FILTER=${COMMON_LINT_FILTER} @@ -34,12 +34,12 @@ MSAN_RTL_LINT_FILTER=${COMMON_LINT_FILTER} LSAN_RTL_LINT_FILTER=${COMMON_LINT_FILTER} LSAN_LIT_TEST_LINT_FILTER=${LSAN_RTL_LINT_FILTER},${COMMON_LIT_TEST_LINT_FILTER} -DFSAN_RTL_LINT_FILTER=${COMMON_LINT_FILTER},-runtime/int,-runtime/printf,-runtime/references,-readability/function +DFSAN_RTL_LINT_FILTER=${COMMON_LINT_FILTER},-runtime/printf,-runtime/references,-readability/function SCUDO_RTL_LINT_FILTER=${COMMON_LINT_FILTER} -COMMON_RTL_INC_LINT_FILTER=${COMMON_LINT_FILTER},-runtime/int,-runtime/sizeof,-runtime/printf,-readability/fn_size +COMMON_RTL_INC_LINT_FILTER=${COMMON_LINT_FILTER},-runtime/sizeof,-runtime/printf,-readability/fn_size -SANITIZER_INCLUDES_LINT_FILTER=${COMMON_LINT_FILTER},-runtime/int +SANITIZER_INCLUDES_LINT_FILTER=${COMMON_LINT_FILTER} MKTEMP_DIR=$(mktemp -qd /tmp/check_lint.XXXXXXXXXX) MKTEMP="mktemp -q ${MKTEMP_DIR}/tmp.XXXXXXXXXX" diff --git a/lib/sanitizer_common/tests/sanitizer_allocator_test.cpp b/lib/sanitizer_common/tests/sanitizer_allocator_test.cpp index 1015a60b4..782011b25 100644 --- a/lib/sanitizer_common/tests/sanitizer_allocator_test.cpp +++ b/lib/sanitizer_common/tests/sanitizer_allocator_test.cpp @@ -868,10 +868,10 @@ TEST(Allocator, ScopedBuffer) { const int kSize = 512; { InternalMmapVector<int> int_buf(kSize); - EXPECT_EQ((uptr)kSize, int_buf.size()); // NOLINT + EXPECT_EQ((uptr)kSize, int_buf.size()); } InternalMmapVector<char> char_buf(kSize); - EXPECT_EQ((uptr)kSize, char_buf.size()); // NOLINT + EXPECT_EQ((uptr)kSize, char_buf.size()); internal_memset(char_buf.data(), 'c', kSize); for (int i = 0; i < kSize; i++) { EXPECT_EQ('c', char_buf[i]); diff --git a/lib/sanitizer_common/tests/sanitizer_libc_test.cpp b/lib/sanitizer_common/tests/sanitizer_libc_test.cpp index 897036c2c..c3fddc57f 100644 --- a/lib/sanitizer_common/tests/sanitizer_libc_test.cpp +++ b/lib/sanitizer_common/tests/sanitizer_libc_test.cpp @@ -167,9 +167,7 @@ TEST(SanitizerCommon, FileOps) { class SanitizerCommonFileTest : public ::testing::TestWithParam<uptr> { void SetUp() override { data_.resize(GetParam()); - std::generate(data_.begin(), data_.end(), [] { - return rand() % 256; // NOLINT - }); + std::generate(data_.begin(), data_.end(), [] { return rand() % 256; }); temp_file_name(file_name_, sizeof(file_name_), "sanitizer_common.ReadFile.tmp."); diff --git a/lib/sanitizer_common/tests/sanitizer_printf_test.cpp b/lib/sanitizer_common/tests/sanitizer_printf_test.cpp index 699a363bf..d213d107c 100644 --- a/lib/sanitizer_common/tests/sanitizer_printf_test.cpp +++ b/lib/sanitizer_common/tests/sanitizer_printf_test.cpp @@ -20,12 +20,9 @@ namespace __sanitizer { TEST(Printf, Basic) { char buf[1024]; - uptr len = internal_snprintf(buf, sizeof(buf), - "a%db%zdc%ue%zuf%xh%zxq%pe%sr", - (int)-1, (uptr)-2, // NOLINT - (unsigned)-4, (uptr)5, // NOLINT - (unsigned)10, (uptr)11, // NOLINT - (void*)0x123, "_string_"); + uptr len = internal_snprintf( + buf, sizeof(buf), "a%db%zdc%ue%zuf%xh%zxq%pe%sr", (int)-1, (uptr)-2, + (unsigned)-4, (uptr)5, (unsigned)10, (uptr)11, (void *)0x123, "_string_"); EXPECT_EQ(len, strlen(buf)); std::string expectedString = "a-1b-2c4294967292e5fahbq0x"; @@ -36,7 +33,7 @@ TEST(Printf, Basic) { TEST(Printf, OverflowStr) { char buf[] = "123456789"; - uptr len = internal_snprintf(buf, 4, "%s", "abcdef"); // NOLINT + uptr len = internal_snprintf(buf, 4, "%s", "abcdef"); EXPECT_EQ(len, (uptr)6); EXPECT_STREQ("abc", buf); EXPECT_EQ(buf[3], 0); @@ -50,7 +47,7 @@ TEST(Printf, OverflowStr) { TEST(Printf, OverflowInt) { char buf[] = "123456789"; - internal_snprintf(buf, 4, "%d", -123456789); // NOLINT + internal_snprintf(buf, 4, "%d", -123456789); EXPECT_STREQ("-12", buf); EXPECT_EQ(buf[3], 0); EXPECT_EQ(buf[4], '5'); @@ -69,7 +66,7 @@ TEST(Printf, OverflowUint) { } else { val = (uptr)0x123456789ULL; } - internal_snprintf(buf, 4, "a%zx", val); // NOLINT + internal_snprintf(buf, 4, "a%zx", val); EXPECT_STREQ("a12", buf); EXPECT_EQ(buf[3], 0); EXPECT_EQ(buf[4], '5'); @@ -88,7 +85,7 @@ TEST(Printf, OverflowPtr) { } else { p = (void*)0x123456789ULL; } - internal_snprintf(buf, 4, "%p", p); // NOLINT + internal_snprintf(buf, 4, "%p", p); EXPECT_STREQ("0x0", buf); EXPECT_EQ(buf[3], 0); EXPECT_EQ(buf[4], '5'); @@ -115,14 +112,14 @@ static void TestAgainstLibc(const char *fmt, T arg1, T arg2) { } TEST(Printf, MinMax) { - TestAgainstLibc<int>("%d-%d", INT_MIN, INT_MAX); // NOLINT - TestAgainstLibc<unsigned>("%u-%u", 0, UINT_MAX); // NOLINT - TestAgainstLibc<unsigned>("%x-%x", 0, UINT_MAX); // NOLINT + TestAgainstLibc<int>("%d-%d", INT_MIN, INT_MAX); + TestAgainstLibc<unsigned>("%u-%u", 0, UINT_MAX); + TestAgainstLibc<unsigned>("%x-%x", 0, UINT_MAX); #if !defined(_WIN32) // %z* format doesn't seem to be supported by MSVS. - TestAgainstLibc<long>("%zd-%zd", LONG_MIN, LONG_MAX); // NOLINT - TestAgainstLibc<unsigned long>("%zu-%zu", 0, ULONG_MAX); // NOLINT - TestAgainstLibc<unsigned long>("%zx-%zx", 0, ULONG_MAX); // NOLINT + TestAgainstLibc<long>("%zd-%zd", LONG_MIN, LONG_MAX); + TestAgainstLibc<unsigned long>("%zu-%zu", 0, ULONG_MAX); + TestAgainstLibc<unsigned long>("%zx-%zx", 0, ULONG_MAX); #endif } diff --git a/lib/sanitizer_common/tests/sanitizer_suppressions_test.cpp b/lib/sanitizer_common/tests/sanitizer_suppressions_test.cpp index 8bbb11c40..6fce03a57 100644 --- a/lib/sanitizer_common/tests/sanitizer_suppressions_test.cpp +++ b/lib/sanitizer_common/tests/sanitizer_suppressions_test.cpp @@ -18,7 +18,7 @@ namespace __sanitizer { static bool MyMatch(const char *templ, const char *func) { char tmp[1024]; - strcpy(tmp, templ); // NOLINT + strcpy(tmp, templ); return TemplateMatch(tmp, func); } @@ -80,43 +80,41 @@ class SuppressionContextTest : public ::testing::Test { }; TEST_F(SuppressionContextTest, Parse) { - ctx_.Parse("race:foo\n" - " race:bar\n" // NOLINT - "race:baz \n" // NOLINT - "# a comment\n" - "race:quz\n"); // NOLINT + ctx_.Parse( + "race:foo\n" + " \trace:bar\n" + "race:baz\t \n" + "# a comment\n" + "race:quz\n"); CheckSuppressions(4, {"race", "race", "race", "race"}, {"foo", "bar", "baz", "quz"}); } TEST_F(SuppressionContextTest, Parse2) { ctx_.Parse( - " # first line comment\n" // NOLINT - " race:bar \n" // NOLINT - "race:baz* *baz\n" - "# a comment\n" - "# last line comment\n" - ); // NOLINT + " \t# first line comment\n" + " \trace:bar \t\n" + "race:baz* *baz\n" + "# a comment\n" + "# last line comment\n"); CheckSuppressions(2, {"race", "race"}, {"bar", "baz* *baz"}); } TEST_F(SuppressionContextTest, Parse3) { ctx_.Parse( - "# last suppression w/o line-feed\n" - "race:foo\n" - "race:bar\r\n" - "race:baz" - ); // NOLINT + "# last suppression w/o line-feed\n" + "race:foo\n" + "race:bar\r\n" + "race:baz"); CheckSuppressions(3, {"race", "race", "race"}, {"foo", "bar", "baz"}); } TEST_F(SuppressionContextTest, ParseType) { ctx_.Parse( - "race:foo\n" - "thread:bar\n" - "mutex:baz\n" - "signal:quz\n" - ); // NOLINT + "race:foo\n" + "thread:bar\n" + "mutex:baz\n" + "signal:quz\n"); CheckSuppressions(4, {"race", "thread", "mutex", "signal"}, {"foo", "bar", "baz", "quz"}); } diff --git a/lib/scudo/scudo_errors.cpp b/lib/scudo/scudo_errors.cpp index 34e57bf71..4bea9ebc6 100644 --- a/lib/scudo/scudo_errors.cpp +++ b/lib/scudo/scudo_errors.cpp @@ -39,9 +39,10 @@ void NORETURN reportAllocationAlignmentNotPowerOfTwo(uptr Alignment) { } void NORETURN reportInvalidPosixMemalignAlignment(uptr Alignment) { - dieWithMessage("invalid alignment requested in posix_memalign: %zd, alignment" + dieWithMessage( + "invalid alignment requested in posix_memalign: %zd, alignment" " must be a power of two and a multiple of sizeof(void *) == %zd\n", - Alignment, sizeof(void *)); // NOLINT + Alignment, sizeof(void *)); } void NORETURN reportInvalidAlignedAllocAlignment(uptr Size, uptr Alignment) { diff --git a/lib/tsan/rtl/tsan_dispatch_defs.h b/lib/tsan/rtl/tsan_dispatch_defs.h index 6f1d1f75f..298297af3 100644 --- a/lib/tsan/rtl/tsan_dispatch_defs.h +++ b/lib/tsan/rtl/tsan_dispatch_defs.h @@ -31,11 +31,11 @@ typedef void (^dispatch_block_t)(void); typedef void (^dispatch_io_handler_t)(bool done, dispatch_data_t data, int error); -typedef long dispatch_once_t; // NOLINT +typedef long dispatch_once_t; typedef __sanitizer::u64 dispatch_time_t; -typedef int dispatch_fd_t; // NOLINT -typedef unsigned long dispatch_io_type_t; // NOLINT -typedef unsigned long dispatch_io_close_flags_t; // NOLINT +typedef int dispatch_fd_t; +typedef unsigned long dispatch_io_type_t; +typedef unsigned long dispatch_io_close_flags_t; extern "C" { void *dispatch_get_context(dispatch_object_t object); @@ -57,10 +57,10 @@ extern const dispatch_block_t _dispatch_data_destructor_munmap; #endif // Data types used in dispatch APIs -typedef unsigned long size_t; // NOLINT -typedef unsigned long uintptr_t; // NOLINT +typedef unsigned long size_t; +typedef unsigned long uintptr_t; typedef __sanitizer::s64 off_t; typedef __sanitizer::u16 mode_t; -typedef long long_t; // NOLINT +typedef long long_t; #endif // TSAN_DISPATCH_DEFS_H diff --git a/lib/tsan/rtl/tsan_external.cpp b/lib/tsan/rtl/tsan_external.cpp index efc101308..0faa1ee93 100644 --- a/lib/tsan/rtl/tsan_external.cpp +++ b/lib/tsan/rtl/tsan_external.cpp @@ -25,7 +25,7 @@ static TagData registered_tags[kExternalTagMax] = { {}, {"Swift variable", "Swift access race"}, }; -static atomic_uint32_t used_tags{kExternalTagFirstUserAvailable}; // NOLINT. +static atomic_uint32_t used_tags{kExternalTagFirstUserAvailable}; static TagData *GetTagData(uptr tag) { // Invalid/corrupted tag? Better return NULL and let the caller deal with it. if (tag >= atomic_load(&used_tags, memory_order_relaxed)) return nullptr; diff --git a/lib/tsan/rtl/tsan_fd.cpp b/lib/tsan/rtl/tsan_fd.cpp index db01d8095..50a6b5691 100644 --- a/lib/tsan/rtl/tsan_fd.cpp +++ b/lib/tsan/rtl/tsan_fd.cpp @@ -86,7 +86,8 @@ static FdDesc *fddesc(ThreadState *thr, uptr pc, int fd) { else user_free(thr, pc, p, false); } - return &((FdDesc*)l1)[fd % kTableSizeL2]; // NOLINT + FdDesc *fds = reinterpret_cast<FdDesc *>(l1); + return &fds[fd % kTableSizeL2]; } // pd must be already ref'ed. diff --git a/lib/tsan/rtl/tsan_interceptors.cpp b/lib/tsan/rtl/tsan_interceptors.cpp index cf84e2870..4aa9086a2 100644 --- a/lib/tsan/rtl/tsan_interceptors.cpp +++ b/lib/tsan/rtl/tsan_interceptors.cpp @@ -31,8 +31,7 @@ #include "tsan_mman.h" #include "tsan_fd.h" - -using namespace __tsan; // NOLINT +using namespace __tsan; #if SANITIZER_FREEBSD || SANITIZER_MAC #define stdout __stdoutp @@ -41,9 +40,10 @@ using namespace __tsan; // NOLINT #if SANITIZER_NETBSD #define dirfd(dirp) (*(int *)(dirp)) -#define fileno_unlocked(fp) \ - (((__sanitizer_FILE*)fp)->_file == -1 ? -1 : \ - (int)(unsigned short)(((__sanitizer_FILE*)fp)->_file)) // NOLINT +#define fileno_unlocked(fp) \ + (((__sanitizer_FILE *)fp)->_file == -1 \ + ? -1 \ + : (int)(unsigned short)(((__sanitizer_FILE *)fp)->_file)) #define stdout ((__sanitizer_FILE*)&__sF[1]) #define stderr ((__sanitizer_FILE*)&__sF[2]) @@ -133,7 +133,7 @@ const int PTHREAD_BARRIER_SERIAL_THREAD = 1234567; const int PTHREAD_BARRIER_SERIAL_THREAD = -1; #endif const int MAP_FIXED = 0x10; -typedef long long_t; // NOLINT +typedef long long_t; // From /usr/include/unistd.h # define F_ULOCK 0 /* Unlock a previously locked region. */ @@ -723,12 +723,12 @@ TSAN_INTERCEPTOR(uptr, malloc_usable_size, void *p) { } #endif -TSAN_INTERCEPTOR(char*, strcpy, char *dst, const char *src) { // NOLINT - SCOPED_TSAN_INTERCEPTOR(strcpy, dst, src); // NOLINT +TSAN_INTERCEPTOR(char *, strcpy, char *dst, const char *src) { + SCOPED_TSAN_INTERCEPTOR(strcpy, dst, src); uptr srclen = internal_strlen(src); MemoryAccessRange(thr, pc, (uptr)dst, srclen + 1, true); MemoryAccessRange(thr, pc, (uptr)src, srclen + 1, false); - return REAL(strcpy)(dst, src); // NOLINT + return REAL(strcpy)(dst, src); } TSAN_INTERCEPTOR(char*, strncpy, char *dst, char *src, uptr n) { @@ -2660,7 +2660,7 @@ void InitializeInterceptors() { TSAN_MAYBE_INTERCEPT_PVALLOC; TSAN_INTERCEPT(posix_memalign); - TSAN_INTERCEPT(strcpy); // NOLINT + TSAN_INTERCEPT(strcpy); TSAN_INTERCEPT(strncpy); TSAN_INTERCEPT(strdup); diff --git a/lib/tsan/rtl/tsan_interceptors_mac.cpp b/lib/tsan/rtl/tsan_interceptors_mac.cpp index 8b748c110..aa29536d8 100644 --- a/lib/tsan/rtl/tsan_interceptors_mac.cpp +++ b/lib/tsan/rtl/tsan_interceptors_mac.cpp @@ -30,7 +30,7 @@ #include <xpc/xpc.h> #endif // #if defined(__has_include) && __has_include(<xpc/xpc.h>) -typedef long long_t; // NOLINT +typedef long long_t; extern "C" { int getcontext(ucontext_t *ucp) __attribute__((returns_twice)); diff --git a/lib/tsan/rtl/tsan_interface.cpp b/lib/tsan/rtl/tsan_interface.cpp index 845d8c852..2b3a0889b 100644 --- a/lib/tsan/rtl/tsan_interface.cpp +++ b/lib/tsan/rtl/tsan_interface.cpp @@ -17,7 +17,7 @@ #define CALLERPC ((uptr)__builtin_return_address(0)) -using namespace __tsan; // NOLINT +using namespace __tsan; typedef u16 uint16_t; typedef u32 uint32_t; diff --git a/lib/tsan/rtl/tsan_interface.h b/lib/tsan/rtl/tsan_interface.h index fac57809a..b2f0f30c4 100644 --- a/lib/tsan/rtl/tsan_interface.h +++ b/lib/tsan/rtl/tsan_interface.h @@ -90,9 +90,9 @@ SANITIZER_INTERFACE_ATTRIBUTE void __tsan_external_write(void *addr, void *caller_pc, void *tag); SANITIZER_INTERFACE_ATTRIBUTE -void __tsan_read_range(void *addr, unsigned long size); // NOLINT +void __tsan_read_range(void *addr, unsigned long size); SANITIZER_INTERFACE_ATTRIBUTE -void __tsan_write_range(void *addr, unsigned long size); // NOLINT +void __tsan_write_range(void *addr, unsigned long size); // User may provide function that would be called right when TSan detects // an error. The argument 'report' is an opaque pointer that can be used to @@ -187,9 +187,9 @@ namespace __tsan { // These should match declarations from public tsan_interface_atomic.h header. typedef unsigned char a8; -typedef unsigned short a16; // NOLINT +typedef unsigned short a16; typedef unsigned int a32; -typedef unsigned long long a64; // NOLINT +typedef unsigned long long a64; #if !SANITIZER_GO && (defined(__SIZEOF_INT128__) \ || (__clang_major__ * 100 + __clang_minor__ >= 302)) && !defined(__mips64) __extension__ typedef __int128 a128; diff --git a/lib/tsan/rtl/tsan_interface_ann.cpp b/lib/tsan/rtl/tsan_interface_ann.cpp index 288485c17..99516d94b 100644 --- a/lib/tsan/rtl/tsan_interface_ann.cpp +++ b/lib/tsan/rtl/tsan_interface_ann.cpp @@ -24,7 +24,7 @@ #define CALLERPC ((uptr)__builtin_return_address(0)) -using namespace __tsan; // NOLINT +using namespace __tsan; namespace __tsan { @@ -220,7 +220,7 @@ static void ReportMissedExpectedRace(ExpectRace *race) { } } // namespace __tsan -using namespace __tsan; // NOLINT +using namespace __tsan; extern "C" { void INTERFACE_ATTRIBUTE AnnotateHappensBefore(char *f, int l, uptr addr) { diff --git a/lib/tsan/rtl/tsan_interface_atomic.cpp b/lib/tsan/rtl/tsan_interface_atomic.cpp index 730a8e63f..3f459aff5 100644 --- a/lib/tsan/rtl/tsan_interface_atomic.cpp +++ b/lib/tsan/rtl/tsan_interface_atomic.cpp @@ -25,7 +25,7 @@ #include "tsan_interface.h" #include "tsan_rtl.h" -using namespace __tsan; // NOLINT +using namespace __tsan; #if !SANITIZER_GO && __TSAN_HAS_INT128 // Protects emulation of 128-bit atomic operations. diff --git a/lib/tsan/rtl/tsan_interface_inl.h b/lib/tsan/rtl/tsan_interface_inl.h index bf4a16586..193b91b2e 100644 --- a/lib/tsan/rtl/tsan_interface_inl.h +++ b/lib/tsan/rtl/tsan_interface_inl.h @@ -15,7 +15,7 @@ #define CALLERPC ((uptr)__builtin_return_address(0)) -using namespace __tsan; // NOLINT +using namespace __tsan; void __tsan_read1(void *addr) { MemoryRead(cur_thread(), CALLERPC, (uptr)addr, kSizeLog1); diff --git a/lib/tsan/rtl/tsan_interface_java.cpp b/lib/tsan/rtl/tsan_interface_java.cpp index 7d3d32fdb..081c6ff10 100644 --- a/lib/tsan/rtl/tsan_interface_java.cpp +++ b/lib/tsan/rtl/tsan_interface_java.cpp @@ -19,7 +19,7 @@ #include "sanitizer_common/sanitizer_stacktrace.h" #include "sanitizer_common/sanitizer_procmaps.h" -using namespace __tsan; // NOLINT +using namespace __tsan; const jptr kHeapAlignment = 8; diff --git a/lib/tsan/rtl/tsan_interface_java.h b/lib/tsan/rtl/tsan_interface_java.h index 93e67bd10..51b445251 100644 --- a/lib/tsan/rtl/tsan_interface_java.h +++ b/lib/tsan/rtl/tsan_interface_java.h @@ -31,7 +31,7 @@ extern "C" { #endif -typedef unsigned long jptr; // NOLINT +typedef unsigned long jptr; // Must be called before any other callback from Java. void __tsan_java_init(jptr heap_begin, jptr heap_size) INTERFACE_ATTRIBUTE; diff --git a/lib/tsan/rtl/tsan_md5.cpp b/lib/tsan/rtl/tsan_md5.cpp index d146e1cc3..72857b773 100644 --- a/lib/tsan/rtl/tsan_md5.cpp +++ b/lib/tsan/rtl/tsan_md5.cpp @@ -29,7 +29,7 @@ namespace __tsan { SET(n) typedef unsigned int MD5_u32plus; -typedef unsigned long ulong_t; // NOLINT +typedef unsigned long ulong_t; typedef struct { MD5_u32plus lo, hi; diff --git a/lib/tsan/rtl/tsan_mman.h b/lib/tsan/rtl/tsan_mman.h index 313c3bf26..a5280d447 100644 --- a/lib/tsan/rtl/tsan_mman.h +++ b/lib/tsan/rtl/tsan_mman.h @@ -80,10 +80,9 @@ void *internal_alloc(MBlockType typ, uptr sz); void internal_free(void *p); template <typename T> -void DestroyAndFree(T *&p) { // NOLINT +void DestroyAndFree(T *p) { p->~T(); internal_free(p); - p = 0; } } // namespace __tsan diff --git a/lib/tsan/rtl/tsan_new_delete.cpp b/lib/tsan/rtl/tsan_new_delete.cpp index 3ed3c847a..fc44a5221 100644 --- a/lib/tsan/rtl/tsan_new_delete.cpp +++ b/lib/tsan/rtl/tsan_new_delete.cpp @@ -17,7 +17,7 @@ #include "tsan_interceptors.h" #include "tsan_rtl.h" -using namespace __tsan; // NOLINT +using namespace __tsan; namespace std { struct nothrow_t {}; diff --git a/lib/tsan/rtl/tsan_rtl.h b/lib/tsan/rtl/tsan_rtl.h index 53367d9cf..c38fc43a9 100644 --- a/lib/tsan/rtl/tsan_rtl.h +++ b/lib/tsan/rtl/tsan_rtl.h @@ -238,7 +238,7 @@ class Shadow : public FastState { unsigned kS2AccessSize) { bool res = false; u64 diff = s1.addr0() - s2.addr0(); - if ((s64)diff < 0) { // s1.addr0 < s2.addr0 // NOLINT + if ((s64)diff < 0) { // s1.addr0 < s2.addr0 // if (s1.addr0() + size1) > s2.addr0()) return true; if (s1.size() > -diff) res = true; diff --git a/lib/tsan/rtl/tsan_rtl_report.cpp b/lib/tsan/rtl/tsan_rtl_report.cpp index 47b8bf77d..949beac1c 100644 --- a/lib/tsan/rtl/tsan_rtl_report.cpp +++ b/lib/tsan/rtl/tsan_rtl_report.cpp @@ -27,7 +27,7 @@ namespace __tsan { -using namespace __sanitizer; // NOLINT +using namespace __sanitizer; static ReportStack *SymbolizeStack(StackTrace trace); @@ -154,6 +154,7 @@ ScopedReportBase::ScopedReportBase(ReportType typ, uptr tag) { ScopedReportBase::~ScopedReportBase() { ctx->report_mtx.Unlock(); DestroyAndFree(rep_); + rep_ = nullptr; } void ScopedReportBase::AddStack(StackTrace stack, bool suppressable) { @@ -700,7 +701,7 @@ void ReportRace(ThreadState *thr) { rep.AddLocation(addr_min, addr_max - addr_min); #if !SANITIZER_GO - { // NOLINT + { Shadow s(thr->racy_state[1]); if (s.epoch() <= thr->last_sleep_clock.get(s.tid())) rep.AddSleep(thr->last_sleep_stack_id); diff --git a/lib/tsan/rtl/tsan_suppressions.cpp b/lib/tsan/rtl/tsan_suppressions.cpp index 6bf672021..a1c1bf81b 100644 --- a/lib/tsan/rtl/tsan_suppressions.cpp +++ b/lib/tsan/rtl/tsan_suppressions.cpp @@ -50,7 +50,7 @@ static const char *kSuppressionTypes[] = { void InitializeSuppressions() { CHECK_EQ(nullptr, suppression_ctx); - suppression_ctx = new (suppression_placeholder) // NOLINT + suppression_ctx = new (suppression_placeholder) SuppressionContext(kSuppressionTypes, ARRAY_SIZE(kSuppressionTypes)); suppression_ctx->ParseFromFile(flags()->suppressions); #if !SANITIZER_GO diff --git a/lib/tsan/tests/rtl/tsan_posix.cpp b/lib/tsan/tests/rtl/tsan_posix.cpp index 0eb8dc14d..ad8b07e26 100644 --- a/lib/tsan/tests/rtl/tsan_posix.cpp +++ b/lib/tsan/tests/rtl/tsan_posix.cpp @@ -82,7 +82,8 @@ static void *local_thread(void *p) { pthread_t th[kThreads]; for (int i = 0; i < kThreads; i++) EXPECT_EQ(__interceptor_pthread_create(&th[i], 0, local_thread, - (void*)((long)p - 1)), 0); // NOLINT + (void *)((long)p - 1)), + 0); for (int i = 0; i < kThreads; i++) EXPECT_EQ(__interceptor_pthread_join(th[i], 0), 0); return 0; diff --git a/lib/tsan/tests/rtl/tsan_test_util_posix.cpp b/lib/tsan/tests/rtl/tsan_test_util_posix.cpp index 8e2852d39..a24d04f47 100644 --- a/lib/tsan/tests/rtl/tsan_test_util_posix.cpp +++ b/lib/tsan/tests/rtl/tsan_test_util_posix.cpp @@ -27,7 +27,7 @@ #include <unistd.h> #include <errno.h> -using namespace __tsan; // NOLINT +using namespace __tsan; static __thread bool expect_report; static __thread bool expect_report_reported; diff --git a/lib/ubsan/ubsan_diag.cpp b/lib/ubsan/ubsan_diag.cpp index c8f7960db..1b2828d23 100644 --- a/lib/ubsan/ubsan_diag.cpp +++ b/lib/ubsan/ubsan_diag.cpp @@ -404,7 +404,7 @@ static const char *kSuppressionTypes[] = { void __ubsan::InitializeSuppressions() { CHECK_EQ(nullptr, suppression_ctx); - suppression_ctx = new (suppression_placeholder) // NOLINT + suppression_ctx = new (suppression_placeholder) SuppressionContext(kSuppressionTypes, ARRAY_SIZE(kSuppressionTypes)); suppression_ctx->ParseFromFile(flags()->suppressions); } diff --git a/test/asan/TestCases/alloca_loop_unpoisoning.cpp b/test/asan/TestCases/alloca_loop_unpoisoning.cpp index f9d32aafd..a3d7ca1dc 100644 --- a/test/asan/TestCases/alloca_loop_unpoisoning.cpp +++ b/test/asan/TestCases/alloca_loop_unpoisoning.cpp @@ -24,11 +24,11 @@ void *top, *bot; __attribute__((noinline)) void foo(int len) { char x; top = &x; - char array[len]; // NOLINT + char array[len]; assert(!(reinterpret_cast<uintptr_t>(array) & 31L)); alloca(len); for (int i = 0; i < 32; ++i) { - char array[i]; // NOLINT + char array[i]; bot = alloca(i); assert(!(reinterpret_cast<uintptr_t>(bot) & 31L)); } diff --git a/test/asan/TestCases/time_interceptor.cpp b/test/asan/TestCases/time_interceptor.cpp index f78af1056..91e056bfc 100644 --- a/test/asan/TestCases/time_interceptor.cpp +++ b/test/asan/TestCases/time_interceptor.cpp @@ -13,7 +13,7 @@ int main() { time_t *tm = (time_t*)malloc(sizeof(time_t)); free(tm); time_t t = time(tm); - printf("Time: %s\n", ctime(&t)); // NOLINT + printf("Time: %s\n", ctime(&t)); // CHECK: use-after-free // Regression check for // https://code.google.com/p/address-sanitizer/issues/detail?id=321 diff --git a/test/asan/TestCases/use-after-scope-conversion.cpp b/test/asan/TestCases/use-after-scope-conversion.cpp index b3ab50170..4ada3ba5d 100644 --- a/test/asan/TestCases/use-after-scope-conversion.cpp +++ b/test/asan/TestCases/use-after-scope-conversion.cpp @@ -15,7 +15,7 @@ struct B { struct C { const char *p; explicit C(const char *c) : p(c) {} - C(const B &b) : p(&b.p) {} // NOLINT + explicit C(const B &b) : p(&b.p) {} }; struct A { diff --git a/test/asan/TestCases/vla_chrome_testcase.cpp b/test/asan/TestCases/vla_chrome_testcase.cpp index a87718006..613d4bb27 100644 --- a/test/asan/TestCases/vla_chrome_testcase.cpp +++ b/test/asan/TestCases/vla_chrome_testcase.cpp @@ -18,7 +18,7 @@ __attribute__((noinline)) void fn3(int *first, int second) { int main() { int d = b && c; - int e[a]; // NOLINT + int e[a]; assert(!(reinterpret_cast<uintptr_t>(e) & 31L)); int f; if (d) diff --git a/test/asan/TestCases/vla_loop_overfow.cpp b/test/asan/TestCases/vla_loop_overfow.cpp index b6a5864c0..370e0dc72 100644 --- a/test/asan/TestCases/vla_loop_overfow.cpp +++ b/test/asan/TestCases/vla_loop_overfow.cpp @@ -8,7 +8,7 @@ void foo(int index, int len) { for (int i = 1; i < len; ++i) { - char array[len]; // NOLINT + char array[len]; assert(!(reinterpret_cast<uintptr_t>(array) & 31L)); array[index + i] = 0; // CHECK: ERROR: AddressSanitizer: dynamic-stack-buffer-overflow on address [[ADDR:0x[0-9a-f]+]] diff --git a/test/lsan/TestCases/Linux/use_tls_dynamic.cpp b/test/lsan/TestCases/Linux/use_tls_dynamic.cpp index 8093d6f0e..b7ca2d754 100644 --- a/test/lsan/TestCases/Linux/use_tls_dynamic.cpp +++ b/test/lsan/TestCases/Linux/use_tls_dynamic.cpp @@ -48,7 +48,7 @@ int main(int argc, char *argv[]) { // This must be large enough that it doesn't fit into preallocated static TLS // space (see STATIC_TLS_SURPLUS in glibc). -__thread void *huge_thread_local_array[(1 << 20) / sizeof(void *)]; // NOLINT +__thread void *huge_thread_local_array[(1 << 20) / sizeof(void *)]; extern "C" void **StoreToTLS(void *p) { huge_thread_local_array[0] = p; diff --git a/test/tsan/exceptions.cpp b/test/tsan/exceptions.cpp index 193e115f7..386145d32 100644 --- a/test/tsan/exceptions.cpp +++ b/test/tsan/exceptions.cpp @@ -11,7 +11,7 @@ __attribute__((noinline)) void throws_int() { __attribute__((noinline)) void callee_throws() { try { throws_int(); - } catch (int) { // NOLINT + } catch (int) { fprintf(stderr, "callee_throws caught exception\n"); } } @@ -19,7 +19,7 @@ __attribute__((noinline)) void callee_throws() { __attribute__((noinline)) void throws_catches_rethrows() { try { throws_int(); - } catch (int) { // NOLINT + } catch (int) { fprintf(stderr, "throws_catches_rethrows caught exception\n"); throw; } @@ -28,7 +28,7 @@ __attribute__((noinline)) void throws_catches_rethrows() { __attribute__((noinline)) void callee_rethrows() { try { throws_catches_rethrows(); - } catch (int) { // NOLINT + } catch (int) { fprintf(stderr, "callee_rethrows caught exception\n"); } } @@ -36,7 +36,7 @@ __attribute__((noinline)) void callee_rethrows() { __attribute__((noinline)) void throws_and_catches() { try { throws_int(); - } catch (int) { // NOLINT + } catch (int) { fprintf(stderr, "throws_and_catches caught exception\n"); } } @@ -45,10 +45,10 @@ __attribute__((noinline)) void nested_try() { try { try { throws_int(); - } catch (double) { // NOLINT + } catch (double) { fprintf(stderr, "nested_try inner block caught exception\n"); } - } catch (int) { // NOLINT + } catch (int) { fprintf(stderr, "nested_try outer block caught exception\n"); } } @@ -57,10 +57,10 @@ __attribute__((noinline)) void nested_try2() { try { try { throws_int(); - } catch (int) { // NOLINT + } catch (int) { fprintf(stderr, "nested_try inner block caught exception\n"); } - } catch (double) { // NOLINT + } catch (double) { fprintf(stderr, "nested_try outer block caught exception\n"); } } @@ -83,7 +83,7 @@ __attribute__((noinline)) void local_object_then_throw() { __attribute__((noinline)) void cpp_object_with_destructor() { try { local_object_then_throw(); - } catch (int) { // NOLINT + } catch (int) { fprintf(stderr, "cpp_object_with_destructor caught exception\n"); } } @@ -99,7 +99,7 @@ __attribute__((noinline)) void recursive_call(long n) { __attribute__((noinline)) void multiframe_unwind() { try { recursive_call(5); - } catch (int) { // NOLINT + } catch (int) { fprintf(stderr, "multiframe_unwind caught exception\n"); } } @@ -114,7 +114,7 @@ __attribute__((noinline)) void longjmp_unwind() { try { longjmp(env, 42); - } catch (int) { // NOLINT + } catch (int) { fprintf(stderr, "longjmp_unwind caught exception\n"); } } @@ -137,7 +137,7 @@ __attribute__((noinline)) void longjmp_unwind_multiple_frames() { try { recursive_call_longjmp(env, 5); - } catch (int) { // NOLINT + } catch (int) { fprintf(stderr, "longjmp_unwind_multiple_frames caught exception\n"); } } diff --git a/test/tsan/java.h b/test/tsan/java.h index e9aa4ee24..765bae0e8 100644 --- a/test/tsan/java.h +++ b/test/tsan/java.h @@ -1,7 +1,7 @@ #include "test.h" extern "C" { -typedef unsigned long jptr; // NOLINT +typedef unsigned long jptr; void __tsan_java_preinit(const char *libjvm_path); void __tsan_java_init(jptr heap_begin, jptr heap_size); int __tsan_java_fini(); diff --git a/test/tsan/virtual_inheritance_compile_bug.cpp b/test/tsan/virtual_inheritance_compile_bug.cpp index 3b1e08b16..69fda3a00 100644 --- a/test/tsan/virtual_inheritance_compile_bug.cpp +++ b/test/tsan/virtual_inheritance_compile_bug.cpp @@ -3,10 +3,16 @@ // RUN: %clangxx_tsan -O1 %s -o %t && %run %t 2>&1 | FileCheck %s #include <stdio.h> -struct AAA { virtual long aaa () { return 0; } }; // NOLINT -struct BBB: virtual AAA { unsigned long bbb; }; // NOLINT +struct AAA { + virtual long aaa() { return 0; } +}; +struct BBB : virtual AAA { + unsigned long bbb; +}; struct CCC: virtual AAA { }; -struct DDD: CCC, BBB { DDD(); }; // NOLINT +struct DDD : CCC, BBB { + DDD(); +}; DDD::DDD() { } int main() { DDD d; |