diff --git a/runtime/bin/dartutils.cc b/runtime/bin/dartutils.cc index 9211fc0c337..97fd635465f 100644 --- a/runtime/bin/dartutils.cc +++ b/runtime/bin/dartutils.cc @@ -798,7 +798,7 @@ Dart_Handle DartUtils::EnvironmentCallback(Dart_Handle name) { // objects. As these will be used by different threads the use of // these depends on the fact that the marking internally in the // Dart_CObject structure is not marking simple value objects. -Dart_CObject CObject::api_null_ = {Dart_CObject_kNull, {0}}; +Dart_CObject CObject::api_null_ = {Dart_CObject_kNull, {false}}; Dart_CObject CObject::api_true_ = {Dart_CObject_kBool, {true}}; Dart_CObject CObject::api_false_ = {Dart_CObject_kBool, {false}}; CObject CObject::null_(&api_null_); diff --git a/runtime/bin/dfe.cc b/runtime/bin/dfe.cc index c7a7266cac4..3e5eaf94caf 100644 --- a/runtime/bin/dfe.cc +++ b/runtime/bin/dfe.cc @@ -233,7 +233,7 @@ class WindowsPathSanitizer { if (len > 2 && path[1] == ':') { *s++ = '/'; } - for (const char *p = path; *p; ++p, ++s) { + for (const char* p = path; *p != '\0'; ++p, ++s) { *s = *p == '\\' ? '/' : *p; } *s = '\0'; diff --git a/runtime/bin/ffi_test/ffi_test_functions.cc b/runtime/bin/ffi_test/ffi_test_functions.cc index d11a88e728b..85145b1eed0 100644 --- a/runtime/bin/ffi_test/ffi_test_functions.cc +++ b/runtime/bin/ffi_test/ffi_test_functions.cc @@ -312,7 +312,7 @@ typedef Coord* (*CoordUnOp)(Coord* coord); // Coordinate. // Used for testing function pointers with structs. DART_EXPORT Coord* CoordinateUnOpTrice(CoordUnOp unop, Coord* coord) { - std::cout << "CoordinateUnOpTrice(" << unop << ", " << coord << ")\n"; + std::cout << "CoordinateUnOpTrice(" << &unop << ", " << coord << ")\n"; Coord* retval = unop(unop(unop(coord))); std::cout << "returning " << retval << "\n"; return retval; @@ -327,7 +327,7 @@ typedef intptr_t (*IntptrBinOp)(intptr_t a, intptr_t b); DART_EXPORT IntptrBinOp IntptrAdditionClosure() { std::cout << "IntptrAdditionClosure()\n"; IntptrBinOp retval = [](intptr_t a, intptr_t b) { return a + b; }; - std::cout << "returning " << retval << "\n"; + std::cout << "returning " << &retval << "\n"; return retval; } @@ -346,7 +346,7 @@ DART_EXPORT intptr_t ApplyTo42And74(IntptrBinOp binop) { DART_EXPORT int64_t* NullableInt64ElemAt1(int64_t* a) { std::cout << "NullableInt64ElemAt1(" << a << ")\n"; int64_t* retval; - if (a) { + if (a != nullptr) { std::cout << "not null pointer, address: " << a << "\n"; retval = a + 1; } else { @@ -439,7 +439,7 @@ DART_EXPORT int64_t SumVeryLargeStruct(VeryLargeStruct* vls) { retval += vls->k; retval += vls->smallLastField; std::cout << retval << "\n"; - if (vls->parent) { + if (vls->parent != nullptr) { std::cout << "has parent\n"; retval += vls->parent->a; } diff --git a/runtime/bin/file.cc b/runtime/bin/file.cc index 3acf44aa2d2..a72d807258a 100644 --- a/runtime/bin/file.cc +++ b/runtime/bin/file.cc @@ -1507,7 +1507,7 @@ CObject* File::LockRequest(const CObjectArray& request) { // Inspired by sdk/lib/core/uri.dart UriDecoder::UriDecoder(const char* uri) : uri_(uri) { const char* ch = uri; - while ((*ch != 0) && (*ch != '%')) { + while ((*ch != '\0') && (*ch != '%')) { ch++; } if (*ch == 0) { @@ -1524,7 +1524,7 @@ UriDecoder::UriDecoder(const char* uri) : uri_(uri) { strncpy(dest, uri, i); decoded_ = dest; dest += i; - while (*ch) { + while (*ch != '\0') { if (*ch != '%') { *(dest++) = *(ch++); continue; diff --git a/runtime/bin/file_system_watcher_linux.cc b/runtime/bin/file_system_watcher_linux.cc index c23c1338ea3..f16b87cad93 100644 --- a/runtime/bin/file_system_watcher_linux.cc +++ b/runtime/bin/file_system_watcher_linux.cc @@ -132,7 +132,7 @@ Dart_Handle FileSystemWatcher::ReadEvents(intptr_t id, intptr_t path_id) { } else { Dart_ListSetAt(event, 2, Dart_Null()); } - Dart_ListSetAt(event, 3, Dart_NewBoolean(e->mask & IN_MOVED_TO)); + Dart_ListSetAt(event, 3, Dart_NewBoolean((e->mask & IN_MOVED_TO) != 0u)); Dart_ListSetAt(event, 4, Dart_NewInteger(e->wd)); Dart_ListSetAt(events, i, event); i++; diff --git a/runtime/bin/file_test.cc b/runtime/bin/file_test.cc index 967eec850c6..60adf31ba14 100644 --- a/runtime/bin/file_test.cc +++ b/runtime/bin/file_test.cc @@ -41,7 +41,7 @@ TEST_CASE(OpenUri_RelativeFilename) { strlen(kFilename) * 3 + 1)); char* t = encoded; // percent-encode all characters 'c' - for (const char* p = kFilename; *p; p++) { + for (const char* p = kFilename; *p != '\0'; p++) { if (*p == 'c') { *t++ = '%'; *t++ = '6'; @@ -70,7 +70,7 @@ TEST_CASE(OpenUri_AbsoluteFilename) { strlen(kFilename) * 3 + 1)); char* t = encoded; // percent-encode all characters 'c' - for (const char* p = kFilename; *p; p++) { + for (const char* p = kFilename; *p != '\0'; p++) { if (*p == 'c') { *t++ = '%'; *t++ = '6'; @@ -110,7 +110,7 @@ TEST_CASE(OpenUri_ValidUri) { strlen(kFilename) * 3 + 1)); char* t = encoded; // percent-encode all characters 'c' - for (const char* p = kFilename; *p; p++) { + for (const char* p = kFilename; *p != '\0'; p++) { if (*p == 'c') { *t++ = '%'; *t++ = '6'; @@ -151,7 +151,7 @@ TEST_CASE(OpenUri_UriWithSpaces) { strlen(kFilename) * 3 + 1)); char* t = encoded; // percent-encode all spaces - for (const char* p = kFilename; *p; p++) { + for (const char* p = kFilename; *p != '\0'; p++) { if (*p == ' ') { *t++ = '%'; *t++ = '2'; @@ -180,7 +180,7 @@ TEST_CASE(OpenUri_InvalidUriPercentEncoding) { strlen(kFilename) * 3 + 1)); char* t = encoded; // percent-encode all characters 'c' - for (const char* p = kFilename; *p; p++) { + for (const char* p = kFilename; *p != '\0'; p++) { if (*p == 'c') { *t++ = '%'; *t++ = 'f'; @@ -200,7 +200,7 @@ TEST_CASE(OpenUri_TruncatedUriPercentEncoding) { strlen(kFilename) * 3 + 1)); char* t = encoded; // percent-encode all characters 'c' - for (const char* p = kFilename; *p; p++) { + for (const char* p = kFilename; *p != '\0'; p++) { if (*p == 'c') { *t++ = '%'; *t++ = 'f'; diff --git a/runtime/bin/gen_snapshot.cc b/runtime/bin/gen_snapshot.cc index 63f940cd3cc..f10a328fd44 100644 --- a/runtime/bin/gen_snapshot.cc +++ b/runtime/bin/gen_snapshot.cc @@ -909,7 +909,7 @@ int main(int argc, char** argv) { MapFile(load_vm_snapshot_instructions_filename, File::kReadExecute, &init_params.vm_snapshot_instructions); } - if (load_isolate_snapshot_data_filename) { + if (load_isolate_snapshot_data_filename != nullptr) { mapped_isolate_snapshot_data = MapFile(load_isolate_snapshot_data_filename, File::kReadOnly, &isolate_snapshot_data); diff --git a/runtime/bin/loader.cc b/runtime/bin/loader.cc index 772fbcc9b2a..f6a5bd6aeb2 100644 --- a/runtime/bin/loader.cc +++ b/runtime/bin/loader.cc @@ -619,7 +619,7 @@ Dart_Handle Loader::LibraryTagHandler(Dart_LibraryTag tag, return result; } if (tag == Dart_kImportExtensionTag) { - if (strncmp(url_string, "dart-ext:", 9)) { + if (strncmp(url_string, "dart-ext:", 9) != 0) { return DartUtils::NewError( "Native extensions must use the dart-ext: scheme."); } diff --git a/runtime/bin/main.cc b/runtime/bin/main.cc index f84a3bfddf7..1ab061fa2c7 100644 --- a/runtime/bin/main.cc +++ b/runtime/bin/main.cc @@ -275,7 +275,7 @@ static bool OnIsolateInitialize(void** child_callback_data, char** error) { } } else { result = DartUtils::ResolveScript(Dart_NewStringFromCString(script_uri)); - if (Dart_IsError(result)) return result; + if (Dart_IsError(result)) return result != nullptr; if (isolate_group_data->kernel_buffer().get() != nullptr) { // Various core-library parts will send requests to the Loader to resolve @@ -284,7 +284,7 @@ static bool OnIsolateInitialize(void** child_callback_data, char** error) { // bypasses normal source code loading paths that initialize it. const char* resolved_script_uri = NULL; result = Dart_StringToCString(result, &resolved_script_uri); - if (Dart_IsError(result)) return result; + if (Dart_IsError(result)) return result != nullptr; Loader::InitForSnapshot(resolved_script_uri, isolate_data); } } @@ -661,7 +661,7 @@ static Dart_Isolate CreateIsolateGroupAndSetupHelper( } } - if (flags->copy_parent_code && callback_data) { + if (flags->copy_parent_code && callback_data != nullptr) { auto parent_isolate_group_data = reinterpret_cast(callback_data)->isolate_group_data(); parent_kernel_buffer = parent_isolate_group_data->kernel_buffer(); diff --git a/runtime/bin/main_options.cc b/runtime/bin/main_options.cc index b356da53923..ee4516e510c 100644 --- a/runtime/bin/main_options.cc +++ b/runtime/bin/main_options.cc @@ -340,7 +340,7 @@ bool Options::ProcessAbiVersionOption(const char* arg, return false; } int ver = 0; - for (int i = 0; value[i]; ++i) { + for (int i = 0; value[i] != '\0'; ++i) { if (value[i] >= '0' && value[i] <= '9') { ver = (ver * 10) + value[i] - '0'; } else { diff --git a/runtime/bin/run_vm_tests.cc b/runtime/bin/run_vm_tests.cc index b4a50200ab0..694577ec3f3 100644 --- a/runtime/bin/run_vm_tests.cc +++ b/runtime/bin/run_vm_tests.cc @@ -253,7 +253,7 @@ static Dart_Isolate CreateIsolateAndSetup(const char* script_uri, CHECK_RESULT(result); // Setup kernel service as the main script for this isolate. - if (kernel_service_buffer) { + if (kernel_service_buffer != nullptr) { result = Dart_LoadScriptFromKernel(kernel_service_buffer, kernel_service_buffer_size); CHECK_RESULT(result); diff --git a/runtime/bin/secure_socket_filter.cc b/runtime/bin/secure_socket_filter.cc index c1d9f57867c..bcb9bee75c4 100644 --- a/runtime/bin/secure_socket_filter.cc +++ b/runtime/bin/secure_socket_filter.cc @@ -677,7 +677,7 @@ int SSLFilter::ProcessReadEncryptedBuffer(int start, int end) { bytes_processed = BIO_write(socket_side_, buffers_[kReadEncrypted] + start, length); if (bytes_processed <= 0) { - bool retry = BIO_should_retry(socket_side_); + bool retry = BIO_should_retry(socket_side_) != 0; if (!retry) { if (SSL_LOG_DATA) Syslog::Print("BIO_write failed in ReadEncryptedBuffer\n"); diff --git a/runtime/bin/secure_socket_utils.cc b/runtime/bin/secure_socket_utils.cc index 362e891320a..259b06ec311 100644 --- a/runtime/bin/secure_socket_utils.cc +++ b/runtime/bin/secure_socket_utils.cc @@ -39,7 +39,7 @@ void SecureSocketUtils::FetchErrorString(const SSL* ssl, } if ((path != NULL) && (line >= 0)) { const char* file = strrchr(path, sep[0]); - path = file ? file + 1 : path; + path = file != nullptr ? file + 1 : path; text_buffer->Printf("(%s:%d)", path, line); } } diff --git a/runtime/bin/security_context.cc b/runtime/bin/security_context.cc index 3300b114ba8..983e5e23d89 100644 --- a/runtime/bin/security_context.cc +++ b/runtime/bin/security_context.cc @@ -76,7 +76,7 @@ int SSLCertContext::CertificateCallback(int preverify_ok, filter->callback_error = result; return 0; } - return DartUtils::GetBooleanValue(result); + return static_cast(DartUtils::GetBooleanValue(result)); } SSLCertContext* SSLCertContext::GetSecurityContext(Dart_NativeArguments args) { diff --git a/runtime/bin/socket_base_linux.cc b/runtime/bin/socket_base_linux.cc index 87aedbd6720..9a52d96fb88 100644 --- a/runtime/bin/socket_base_linux.cc +++ b/runtime/bin/socket_base_linux.cc @@ -46,7 +46,7 @@ bool SocketBase::FormatNumericAddress(const RawAddr& addr, int len) { socklen_t salen = SocketAddress::GetAddrLength(addr); return (NO_RETRY_EXPECTED(getnameinfo(&addr.addr, salen, address, len, NULL, - 0, NI_NUMERICHOST) == 0)); + 0, NI_NUMERICHOST) == 0)) != 0; } bool SocketBase::IsBindError(intptr_t error_number) { diff --git a/runtime/bin/stdio_linux.cc b/runtime/bin/stdio_linux.cc index 18e19e8b339..2ed9a9046a8 100644 --- a/runtime/bin/stdio_linux.cc +++ b/runtime/bin/stdio_linux.cc @@ -86,7 +86,7 @@ static bool TermHasXTerm() { } bool Stdin::AnsiSupported(intptr_t fd, bool* supported) { - *supported = isatty(fd) && TermHasXTerm(); + *supported = (isatty(fd) != 0) && TermHasXTerm(); return true; } @@ -102,7 +102,7 @@ bool Stdout::GetTerminalSize(intptr_t fd, int size[2]) { } bool Stdout::AnsiSupported(intptr_t fd, bool* supported) { - *supported = isatty(fd) && TermHasXTerm(); + *supported = (isatty(fd) != 0) && TermHasXTerm(); return true; } diff --git a/runtime/lib/developer.cc b/runtime/lib/developer.cc index f1eab3a8f21..bac0ef1bfbc 100644 --- a/runtime/lib/developer.cc +++ b/runtime/lib/developer.cc @@ -24,7 +24,7 @@ DEFINE_NATIVE_ENTRY(Developer_debugger, 0, 2) { #if !defined(PRODUCT) GET_NATIVE_ARGUMENT(String, msg, arguments->NativeArgAt(1)); Debugger* debugger = isolate->debugger(); - if (!debugger) { + if (debugger == nullptr) { return when.raw(); } if (when.value()) { diff --git a/runtime/lib/isolate.cc b/runtime/lib/isolate.cc index f8a102cdde0..058f2eced6a 100644 --- a/runtime/lib/isolate.cc +++ b/runtime/lib/isolate.cc @@ -128,7 +128,7 @@ class SpawnIsolateTask : public ThreadPool::Task { } ~SpawnIsolateTask() override { - if (parent_isolate_) { + if (parent_isolate_ != nullptr) { parent_isolate_->DecrementSpawnCount(); } } diff --git a/runtime/lib/mirrors.cc b/runtime/lib/mirrors.cc index 358029a3745..a76d721e3f0 100644 --- a/runtime/lib/mirrors.cc +++ b/runtime/lib/mirrors.cc @@ -253,20 +253,27 @@ static RawInstance* CreateMethodMirror(const Function& func, args.SetAt(4, Bool::Get(func.is_static())); intptr_t kind_flags = 0; - kind_flags |= (func.is_abstract() << Mirrors::kAbstract); - kind_flags |= (func.IsGetterFunction() << Mirrors::kGetter); - kind_flags |= (func.IsSetterFunction() << Mirrors::kSetter); + kind_flags |= + (static_cast(func.is_abstract()) << Mirrors::kAbstract); + kind_flags |= + (static_cast(func.IsGetterFunction()) << Mirrors::kGetter); + kind_flags |= + (static_cast(func.IsSetterFunction()) << Mirrors::kSetter); bool is_ctor = (func.kind() == RawFunction::kConstructor); - kind_flags |= (is_ctor << Mirrors::kConstructor); - kind_flags |= ((is_ctor && func.is_const()) << Mirrors::kConstCtor); + kind_flags |= (static_cast(is_ctor) << Mirrors::kConstructor); + kind_flags |= (static_cast(is_ctor && func.is_const()) + << Mirrors::kConstCtor); kind_flags |= - ((is_ctor && func.IsGenerativeConstructor()) << Mirrors::kGenerativeCtor); + (static_cast(is_ctor && func.IsGenerativeConstructor()) + << Mirrors::kGenerativeCtor); + kind_flags |= (static_cast(is_ctor && func.is_redirecting()) + << Mirrors::kRedirectingCtor); + kind_flags |= (static_cast(is_ctor && func.IsFactory()) + << Mirrors::kFactoryCtor); kind_flags |= - ((is_ctor && func.is_redirecting()) << Mirrors::kRedirectingCtor); - kind_flags |= ((is_ctor && func.IsFactory()) << Mirrors::kFactoryCtor); - kind_flags |= (func.is_external() << Mirrors::kExternal); + (static_cast(func.is_external()) << Mirrors::kExternal); bool is_synthetic = func.is_no_such_method_forwarder(); - kind_flags |= (is_synthetic << Mirrors::kSynthetic); + kind_flags |= (static_cast(is_synthetic) << Mirrors::kSynthetic); args.SetAt(5, Smi::Handle(Smi::New(kind_flags))); return CreateMirror(Symbols::_LocalMethodMirror(), args); diff --git a/runtime/platform/floating_point.h b/runtime/platform/floating_point.h index 0d29a707d01..730ef8573bf 100644 --- a/runtime/platform/floating_point.h +++ b/runtime/platform/floating_point.h @@ -5,6 +5,8 @@ #ifndef RUNTIME_PLATFORM_FLOATING_POINT_H_ #define RUNTIME_PLATFORM_FLOATING_POINT_H_ +#include + inline double fmod_ieee(double x, double y) { return fmod(x, y); } diff --git a/runtime/platform/utils_android.h b/runtime/platform/utils_android.h index dc16a7396c0..6d914156e64 100644 --- a/runtime/platform/utils_android.h +++ b/runtime/platform/utils_android.h @@ -5,6 +5,10 @@ #ifndef RUNTIME_PLATFORM_UTILS_ANDROID_H_ #define RUNTIME_PLATFORM_UTILS_ANDROID_H_ +#if !defined(RUNTIME_PLATFORM_UTILS_H_) +#error Do not include utils_android.h directly; use utils.h instead. +#endif + #include // NOLINT namespace dart { diff --git a/runtime/platform/utils_linux.h b/runtime/platform/utils_linux.h index a754ef41459..4a49a6a2038 100644 --- a/runtime/platform/utils_linux.h +++ b/runtime/platform/utils_linux.h @@ -5,6 +5,10 @@ #ifndef RUNTIME_PLATFORM_UTILS_LINUX_H_ #define RUNTIME_PLATFORM_UTILS_LINUX_H_ +#if !defined(RUNTIME_PLATFORM_UTILS_H_) +#error Do not include utils_linux.h directly; use utils.h instead. +#endif + #include // NOLINT namespace dart { diff --git a/runtime/platform/utils_macos.h b/runtime/platform/utils_macos.h index bc34193119e..e64711b7e64 100644 --- a/runtime/platform/utils_macos.h +++ b/runtime/platform/utils_macos.h @@ -5,6 +5,10 @@ #ifndef RUNTIME_PLATFORM_UTILS_MACOS_H_ #define RUNTIME_PLATFORM_UTILS_MACOS_H_ +#if !defined(RUNTIME_PLATFORM_UTILS_H_) +#error Do not include utils_macos.h directly; use utils.h instead. +#endif + #include #include // NOLINT diff --git a/runtime/platform/utils_win.h b/runtime/platform/utils_win.h index c3a67e79fae..ba5c9cc7d55 100644 --- a/runtime/platform/utils_win.h +++ b/runtime/platform/utils_win.h @@ -5,6 +5,10 @@ #ifndef RUNTIME_PLATFORM_UTILS_WIN_H_ #define RUNTIME_PLATFORM_UTILS_WIN_H_ +#if !defined(RUNTIME_PLATFORM_UTILS_H_) +#error Do not include utils_win.h directly; use utils.h instead. +#endif + #include #include diff --git a/runtime/tools/run_clang_tidy.dart b/runtime/tools/run_clang_tidy.dart index 3a45de129f6..d165e77b899 100644 --- a/runtime/tools/run_clang_tidy.dart +++ b/runtime/tools/run_clang_tidy.dart @@ -12,17 +12,19 @@ const String clangTidy = './buildtools/linux-x64/clang/bin/clang-tidy'; List compilerFlagsForFile(String filepath) { final flags = [ - '-I.', '-Iruntime', + '-Ithird_party', '-Iruntime/include', - '-Ithird_party/tcmalloc/gperftools/src ', + '-Ithird_party/tcmalloc/gperftools/src', + '-Ithird_party/boringssl/src/include', + '-Ithird_party/zlib', '-DTARGET_ARCH_X64', '-DDEBUG', '-DTARGET_OS_LINUX', + '-DTESTING', + '-x', + 'c++', ]; - if (filepath.endsWith("_test.cc")) { - flags.add('-DTESTING'); - } return flags; } @@ -35,24 +37,99 @@ Future runClangTidyOn(String filepath) async { final pool = new Pool(max(1, Platform.numberOfProcessors ~/ 2)); -// TODO(dartbug.com/38196): Ensure all VM sources are clang-tidy clean. -final Set migratedFiles = Set.from([ - 'runtime/vm/native_api_impl.cc', - 'runtime/vm/compiler/backend/constant_propagator.cc', - 'runtime/vm/compiler/backend/flow_graph.cc', - 'runtime/vm/compiler/backend/flow_graph_checker.cc', - 'runtime/vm/compiler/backend/il.cc', - 'runtime/vm/compiler/backend/inliner.cc', - 'runtime/vm/compiler/backend/linearscan.cc', - 'runtime/vm/compiler/backend/loops.cc', - 'runtime/vm/compiler/backend/loops_test.cc', - 'runtime/vm/compiler/backend/range_analysis.cc', +// Exclude running the linter on those files. +final Set excludedFiles = Set.from([ + // These files are not valid cc files but rather cc templates + 'runtime/bin/abi_version_in.cc', + 'runtime/bin/builtin_in.cc', + 'runtime/bin/snapshot_in.cc', + 'runtime/lib/libgen_in.cc', + 'runtime/vm/version_in.cc', + + // These files cannot be analyzed by itself (must be included indirectly). + 'runtime/bin/android.h', + 'runtime/bin/eventhandler_android.h', + 'runtime/bin/eventhandler_fuchsia.h', + 'runtime/bin/eventhandler_linux.h', + 'runtime/bin/eventhandler_macos.h', + 'runtime/bin/eventhandler_win.h', + 'runtime/bin/namespace_android.h', + 'runtime/bin/namespace_fuchsia.h', + 'runtime/bin/namespace_linux.h', + 'runtime/bin/namespace_macos.h', + 'runtime/bin/namespace_win.h', + 'runtime/bin/socket_base_android.h', + 'runtime/bin/socket_base_fuchsia.h', + 'runtime/bin/socket_base_linux.h', + 'runtime/bin/socket_base_macos.h', + 'runtime/bin/socket_base_win.h', + 'runtime/bin/thread_android.h', + 'runtime/bin/thread_fuchsia.h', + 'runtime/bin/thread_linux.h', + 'runtime/bin/thread_macos.h', + 'runtime/bin/thread_win.h', + 'runtime/platform/atomic_android.h', + 'runtime/platform/atomic_fuchsia.h', + 'runtime/platform/atomic_linux.h', + 'runtime/platform/atomic_macos.h', + 'runtime/platform/atomic_win.h', + 'runtime/platform/utils_android.h', + 'runtime/platform/utils_fuchsia.h', + 'runtime/platform/utils_linux.h', + 'runtime/platform/utils_macos.h', + 'runtime/platform/utils_win.h', + 'runtime/vm/compiler/assembler/assembler_arm64.h', + 'runtime/vm/compiler/assembler/assembler_arm.h', + 'runtime/vm/compiler/assembler/assembler_dbc.h', + 'runtime/vm/compiler/assembler/assembler_ia32.h', + 'runtime/vm/compiler/assembler/assembler_x64.h', + 'runtime/vm/compiler/runtime_offsets_extracted.h', + 'runtime/vm/constants_arm64.h', + 'runtime/vm/constants_arm.h', + 'runtime/vm/constants_dbc.h', + 'runtime/vm/constants_ia32.h', + 'runtime/vm/constants_x64.h', + 'runtime/vm/cpu_arm64.h', + 'runtime/vm/cpu_arm.h', + 'runtime/vm/cpu_dbc.h', + 'runtime/vm/cpu_ia32.h', + 'runtime/vm/cpu_x64.h', + 'runtime/vm/instructions_arm64.h', + 'runtime/vm/instructions_arm.h', + 'runtime/vm/instructions_dbc.h', + 'runtime/vm/instructions_ia32.h', + 'runtime/vm/instructions_x64.h', + 'runtime/vm/os_thread_android.h', + 'runtime/vm/os_thread_fuchsia.h', + 'runtime/vm/os_thread_linux.h', + 'runtime/vm/os_thread_macos.h', + 'runtime/vm/os_thread_win.h', + 'runtime/vm/regexp_assembler_bytecode_inl.h', + 'runtime/vm/simulator_arm64.h', + 'runtime/vm/simulator_arm.h', + 'runtime/vm/simulator_dbc.h', + 'runtime/vm/stack_frame_arm64.h', + 'runtime/vm/stack_frame_arm.h', + 'runtime/vm/stack_frame_dbc.h', + 'runtime/vm/stack_frame_ia32.h', + 'runtime/vm/stack_frame_x64.h', + + // By default the gclient checkout doesn't have llvm pulled in. + 'runtime/llvm_codegen/bit/bit.h', + 'runtime/llvm_codegen/bit/main.cc', + 'runtime/llvm_codegen/bit/test.cc', + 'runtime/llvm_codegen/codegen/main.cc', + + // Only available in special builds + 'runtime/bin/io_service_no_ssl.h', + 'runtime/bin/utils_win.h', + 'runtime/vm/compiler/backend/locations_helpers_arm.h', ]); main(List files) async { bool isFirstFailure = true; - files = files.where((filepath) => migratedFiles.contains(filepath)).toList(); + files = files.where((filepath) => !excludedFiles.contains(filepath)).toList(); // Analyze the [files] in parallel. await Future.wait(files.map((String filepath) async { diff --git a/runtime/vm/clustered_snapshot.cc b/runtime/vm/clustered_snapshot.cc index 076f41bb3c9..03a62fc04fb 100644 --- a/runtime/vm/clustered_snapshot.cc +++ b/runtime/vm/clustered_snapshot.cc @@ -5149,7 +5149,7 @@ char* SnapshotHeaderReader::VerifyVersion() { const char* version = reinterpret_cast(stream_.AddressOfCurrentPosition()); ASSERT(version != NULL); - if (strncmp(version, expected_version, version_len)) { + if (strncmp(version, expected_version, version_len) != 0) { const intptr_t kMessageBufferSize = 256; char message_buffer[kMessageBufferSize]; char* actual_version = Utils::StrNDup(version, version_len); @@ -5180,7 +5180,7 @@ char* SnapshotHeaderReader::VerifyFeatures(Isolate* isolate) { } if (features_length != expected_len || - strncmp(features, expected_features, expected_len)) { + (strncmp(features, expected_features, expected_len) != 0)) { const intptr_t kMessageBufferSize = 1024; char message_buffer[kMessageBufferSize]; char* actual_features = Utils::StrNDup( diff --git a/runtime/vm/compilation_trace.cc b/runtime/vm/compilation_trace.cc index af8d622b5a6..e2f4eb80206 100644 --- a/runtime/vm/compilation_trace.cc +++ b/runtime/vm/compilation_trace.cc @@ -500,7 +500,7 @@ void TypeFeedbackSaver::SaveFields() { WriteString(str_); WriteInt(field_.guarded_cid()); - WriteInt(field_.is_nullable()); + WriteInt(static_cast(field_.is_nullable())); } } } @@ -673,7 +673,7 @@ RawObject* TypeFeedbackLoader::CheckHeader() { const char* version = reinterpret_cast(stream_->AddressOfCurrentPosition()); ASSERT(version != NULL); - if (strncmp(version, expected_version, version_len)) { + if (strncmp(version, expected_version, version_len) != 0) { const intptr_t kMessageBufferSize = 256; char message_buffer[kMessageBufferSize]; char* actual_version = Utils::StrNDup(version, version_len); @@ -695,7 +695,7 @@ RawObject* TypeFeedbackLoader::CheckHeader() { ASSERT(features != NULL); intptr_t buffer_len = Utils::StrNLen(features, stream_->PendingBytes()); if ((buffer_len != expected_len) || - strncmp(features, expected_features, expected_len)) { + (strncmp(features, expected_features, expected_len) != 0)) { const String& msg = String::Handle(String::NewFormatted( Heap::kOld, "Feedback not compatible with the current VM configuration: " @@ -783,7 +783,7 @@ RawObject* TypeFeedbackLoader::LoadFields() { field_.set_is_nullable(true); } else { field_.set_guarded_cid(guarded_cid); - field_.set_is_nullable(is_nullable || field_.is_nullable()); + field_.set_is_nullable((is_nullable != 0) || field_.is_nullable()); } // TODO(rmacnak): Merge other field type feedback. diff --git a/runtime/vm/compiler/assembler/assembler_x64.cc b/runtime/vm/compiler/assembler/assembler_x64.cc index e5f9e7dc303..8bc626a0197 100644 --- a/runtime/vm/compiler/assembler/assembler_x64.cc +++ b/runtime/vm/compiler/assembler/assembler_x64.cc @@ -1998,7 +1998,7 @@ void Assembler::Align(int alignment, intptr_t offset) { nop(MAX_NOP_SIZE); bytes_needed -= MAX_NOP_SIZE; } - if (bytes_needed) { + if (bytes_needed != 0) { nop(bytes_needed); } ASSERT(((offset + buffer_.GetPosition()) & (alignment - 1)) == 0); diff --git a/runtime/vm/compiler/assembler/disassembler_kbc.cc b/runtime/vm/compiler/assembler/disassembler_kbc.cc index d2f0229bbcf..1cf9e00cc52 100644 --- a/runtime/vm/compiler/assembler/disassembler_kbc.cc +++ b/runtime/vm/compiler/assembler/disassembler_kbc.cc @@ -315,7 +315,7 @@ void KernelBytecodeDisassembler::DecodeInstruction(char* hex_buffer, hex_size - (i * kCharactersPerByte), " %02x", instr[i]); } } - if (out_instr_size) { + if (out_instr_size != nullptr) { *out_instr_size = instr_size; } diff --git a/runtime/vm/compiler/assembler/disassembler_x86.cc b/runtime/vm/compiler/assembler/disassembler_x86.cc index 7e4c0168e6a..6fd177ec9c0 100644 --- a/runtime/vm/compiler/assembler/disassembler_x86.cc +++ b/runtime/vm/compiler/assembler/disassembler_x86.cc @@ -1767,7 +1767,7 @@ int DisassemblerX64::InstructionDecode(uword pc) { // mov reg8,imm8 or mov reg32,imm32 uint8_t opcode = *data; data++; - uint8_t is_not_8bit = (opcode >= 0xB8); + const bool is_not_8bit = opcode >= 0xB8; int reg = (opcode & 0x7) | (rex_b() ? 8 : 0); if (is_not_8bit) { Print("mov%s %s,", operand_size_code(), NameOfCPURegister(reg)); @@ -1970,7 +1970,7 @@ void Disassembler::DecodeInstruction(char* hex_buffer, remaining_size -= 2; } hex_buffer[hex_index] = '\0'; - if (out_instr_len) { + if (out_instr_len != nullptr) { *out_instr_len = instruction_length; } diff --git a/runtime/vm/compiler/backend/il_deserializer.cc b/runtime/vm/compiler/backend/il_deserializer.cc index acd3c092eab..f4bf5355715 100644 --- a/runtime/vm/compiler/backend/il_deserializer.cc +++ b/runtime/vm/compiler/backend/il_deserializer.cc @@ -410,7 +410,9 @@ bool FlowGraphDeserializer::ParseBlocks(SExpList* list, CheckSymbol(block_sexp->ExtraLookupValue("block_type")); // Entry block headers are already parsed, but others aren't. if (block_map_.LookupValue(block_id) == nullptr) { - if (!ParseBlockHeader(block_sexp, block_id, type_tag)) return false; + if (ParseBlockHeader(block_sexp, block_id, type_tag) == nullptr) { + return false; + } } if (max_block_id_ < block_id) max_block_id_ = block_id; } diff --git a/runtime/vm/compiler/backend/il_x64.cc b/runtime/vm/compiler/backend/il_x64.cc index a07578ea146..c7612ed567f 100644 --- a/runtime/vm/compiler/backend/il_x64.cc +++ b/runtime/vm/compiler/backend/il_x64.cc @@ -4802,7 +4802,7 @@ LocationSummary* MathMinMaxInstr::MakeLocationSummary(Zone* zone, void MathMinMaxInstr::EmitNativeCode(FlowGraphCompiler* compiler) { ASSERT((op_kind() == MethodRecognizer::kMathMin) || (op_kind() == MethodRecognizer::kMathMax)); - const intptr_t is_min = (op_kind() == MethodRecognizer::kMathMin); + const bool is_min = op_kind() == MethodRecognizer::kMathMin; if (result_cid() == kDoubleCid) { compiler::Label done, returns_nan, are_equal; XmmRegister left = locs()->in(0).fpu_reg(); diff --git a/runtime/vm/compiler/backend/locations.h b/runtime/vm/compiler/backend/locations.h index 638fc842a3b..b6e7777ef38 100644 --- a/runtime/vm/compiler/backend/locations.h +++ b/runtime/vm/compiler/backend/locations.h @@ -572,7 +572,7 @@ class RegisterSet : public ValueObject { void AddAllNonReservedRegisters(bool include_fpu_registers) { for (intptr_t i = kNumberOfCpuRegisters - 1; i >= 0; --i) { - if (kReservedCpuRegisters & (1 << i)) continue; + if ((kReservedCpuRegisters & (1 << i)) != 0u) continue; Add(Location::RegisterLocation(static_cast(i))); } diff --git a/runtime/vm/compiler/backend/loops.cc b/runtime/vm/compiler/backend/loops.cc index a6415579007..8c046a6ace6 100644 --- a/runtime/vm/compiler/backend/loops.cc +++ b/runtime/vm/compiler/backend/loops.cc @@ -876,9 +876,9 @@ const char* LoopInfo::ToCString() const { num_blocks++; } f.Print("#blocks=%" Pd, num_blocks); - if (outer_) f.Print(" outer=%" Pd, outer_->id_); - if (inner_) f.Print(" inner=%" Pd, inner_->id_); - if (next_) f.Print(" next=%" Pd, next_->id_); + if (outer_ != nullptr) f.Print(" outer=%" Pd, outer_->id_); + if (inner_ != nullptr) f.Print(" inner=%" Pd, inner_->id_); + if (next_ != nullptr) f.Print(" next=%" Pd, next_->id_); f.Print(" ["); for (intptr_t i = 0, n = back_edges_.length(); i < n; i++) { f.Print(" B%" Pd, back_edges_[i]->block_id()); diff --git a/runtime/vm/compiler/backend/sexpression.cc b/runtime/vm/compiler/backend/sexpression.cc index 25e5ff96707..a314abf60d4 100644 --- a/runtime/vm/compiler/backend/sexpression.cc +++ b/runtime/vm/compiler/backend/sexpression.cc @@ -122,7 +122,7 @@ static intptr_t HandleLineBreaking(Zone* zone, const intptr_t leading_length = leading_space ? 1 : 0; if ((leading_length + single_line_width) < remaining) { - if (leading_space != 0) buffer->AddChar(' '); + if (leading_space) buffer->AddChar(' '); buffer->AddString(line_buffer->buf()); line_buffer->Clear(); return remaining - (leading_length + single_line_width); @@ -508,7 +508,7 @@ SExpression* SExpParser::TokenToSExpression(Token* token) { SExpParser::Token* SExpParser::GetNextToken() { intptr_t start_pos = cur_pos_; while (start_pos < buffer_size_) { - if (!isspace(buffer_[start_pos])) break; + if (isspace(buffer_[start_pos]) == 0) break; start_pos++; } if (start_pos >= buffer_size_) return nullptr; @@ -582,7 +582,7 @@ SExpParser::Token* SExpParser::GetNextToken() { } // If we find a character that can't appear in a number, then fall back // to symbol-ness. - if (!isdigit(start[len])) type = kSymbol; + if (isdigit(start[len]) == 0) type = kSymbol; len++; } cur_pos_ = start_pos + len; @@ -615,7 +615,7 @@ SExpParser::Token* SExpParser::GetNextToken() { } bool SExpParser::IsSymbolContinue(char c) { - return !isspace(c) && c != '(' && c != ')' && c != ',' && c != '{' && + return (isspace(c) == 0) && c != '(' && c != ')' && c != ',' && c != '{' && c != '}' && c != '"'; } diff --git a/runtime/vm/compiler/backend/slot.h b/runtime/vm/compiler/backend/slot.h index 6fbec442a6f..361532bf63e 100644 --- a/runtime/vm/compiler/backend/slot.h +++ b/runtime/vm/compiler/backend/slot.h @@ -147,7 +147,7 @@ class Slot : public ZoneAllocated { bool is_immutable() const { return IsImmutableBit::decode(flags_); } intptr_t nullable_cid() const { return cid_; } - intptr_t is_nullable() const { return IsNullableBit::decode(flags_); } + bool is_nullable() const { return IsNullableBit::decode(flags_); } // Returns true if properties of this slot were based on the guarded state // of the corresponding Dart field. diff --git a/runtime/vm/compiler/call_specializer.cc b/runtime/vm/compiler/call_specializer.cc index c6d71eb571f..5e93802d5d2 100644 --- a/runtime/vm/compiler/call_specializer.cc +++ b/runtime/vm/compiler/call_specializer.cc @@ -1107,7 +1107,7 @@ RawBool* CallSpecializer::InstanceOfAsBool( : Class::IsSubtypeOf(cls, Object::null_type_arguments(), type_class, Object::null_type_arguments(), Heap::kOld); results->Add(cls.id()); - results->Add(is_subtype); + results->Add(static_cast(is_subtype)); if (prev.IsNull()) { prev = Bool::Get(is_subtype).raw(); } else { @@ -1391,7 +1391,7 @@ static void TryAddTest(ZoneGrowableArray* results, bool result) { if (!CidTestResultsContains(*results, test_cid)) { results->Add(test_cid); - results->Add(result); + results->Add(static_cast(result)); } } @@ -1427,7 +1427,7 @@ bool CallSpecializer::SpecializeTestCidsForNumericTypes( (*results)[i] = (*results)[i - 2]; } (*results)[0] = kSmiCid; - (*results)[1] = smi_is_subtype; + (*results)[1] = static_cast(smi_is_subtype); } ASSERT(type.IsInstantiated()); diff --git a/runtime/vm/compiler/frontend/bytecode_flow_graph_builder.cc b/runtime/vm/compiler/frontend/bytecode_flow_graph_builder.cc index 01d6aed24a1..6d26197d495 100644 --- a/runtime/vm/compiler/frontend/bytecode_flow_graph_builder.cc +++ b/runtime/vm/compiler/frontend/bytecode_flow_graph_builder.cc @@ -2007,9 +2007,9 @@ void BytecodeFlowGraphBuilder::CollectControlFlow( Array::ZoneHandle(Z, handlers.GetHandledTypes(try_index)); CatchBlockEntryInstr* entry = new (Z) CatchBlockEntryInstr( - TokenPosition::kNoSource, handler_info.is_generated, + TokenPosition::kNoSource, handler_info.is_generated != 0, B->AllocateBlockId(), handler_info.outer_try_index, graph_entry, - handler_types, try_index, handler_info.needs_stacktrace, + handler_types, try_index, handler_info.needs_stacktrace != 0, B->GetNextDeoptId(), nullptr, nullptr, exception_var_, stacktrace_var_); graph_entry->AddCatchEntry(entry); diff --git a/runtime/vm/compiler/frontend/bytecode_reader.cc b/runtime/vm/compiler/frontend/bytecode_reader.cc index 138584b3de5..cfb5a68af49 100644 --- a/runtime/vm/compiler/frontend/bytecode_reader.cc +++ b/runtime/vm/compiler/frontend/bytecode_reader.cc @@ -167,10 +167,10 @@ bool BytecodeMetadataHelper::FindModifiedLibrariesForHotReload( *is_empty_program = (bytecode_component.GetNumLibraries() == 0); } if (p_num_classes != nullptr) { - *p_num_classes = (bytecode_component.GetNumClasses() == 0); + *p_num_classes = bytecode_component.GetNumClasses(); } if (p_num_procedures != nullptr) { - *p_num_procedures = (bytecode_component.GetNumCodes() == 0); + *p_num_procedures = bytecode_component.GetNumCodes(); } return true; } diff --git a/runtime/vm/compiler/frontend/kernel_fingerprints.cc b/runtime/vm/compiler/frontend/kernel_fingerprints.cc index bed6c0f7ed7..4aec4f8474e 100644 --- a/runtime/vm/compiler/frontend/kernel_fingerprints.cc +++ b/runtime/vm/compiler/frontend/kernel_fingerprints.cc @@ -645,7 +645,7 @@ void KernelFingerprintHelper::CalculateStatementFingerprint() { ReadPosition(); // read jth position. CalculateExpressionFingerprint(); // read jth expression. } - BuildHash(ReadBool()); // read is_default. + BuildHash(static_cast(ReadBool())); // read is_default. CalculateStatementFingerprint(); // read body. } return; diff --git a/runtime/vm/compiler/frontend/kernel_translation_helper.h b/runtime/vm/compiler/frontend/kernel_translation_helper.h index 87a593b7006..8f9371b114c 100644 --- a/runtime/vm/compiler/frontend/kernel_translation_helper.h +++ b/runtime/vm/compiler/frontend/kernel_translation_helper.h @@ -689,12 +689,12 @@ class ClassHelper { void SetNext(Field field) { next_read_ = field; } void SetJustRead(Field field) { next_read_ = field + 1; } - bool is_abstract() const { return flags_ & Flag::kIsAbstract; } + bool is_abstract() const { return (flags_ & Flag::kIsAbstract) != 0; } - bool is_enum_class() const { return flags_ & Flag::kIsEnumClass; } + bool is_enum_class() const { return (flags_ & Flag::kIsEnumClass) != 0; } bool is_transformed_mixin_application() const { - return flags_ & Flag::kIsEliminatedMixin; + return (flags_ & Flag::kIsEliminatedMixin) != 0; } NameIndex canonical_name_; diff --git a/runtime/vm/compiler/runtime_api.cc b/runtime/vm/compiler/runtime_api.cc index 1d651dcece6..e7f6f80d980 100644 --- a/runtime/vm/compiler/runtime_api.cc +++ b/runtime/vm/compiler/runtime_api.cc @@ -357,7 +357,7 @@ uword Class::GetInstanceSize(const dart::Class& handle) { } intptr_t Class::NumTypeArguments(const dart::Class& klass) { - return klass.NumTypeArguments() > 0; + return klass.NumTypeArguments(); } bool Class::HasTypeArgumentsField(const dart::Class& klass) { diff --git a/runtime/vm/cpu_arm.h b/runtime/vm/cpu_arm.h index 35e7dd8ce6c..6f5b77456ba 100644 --- a/runtime/vm/cpu_arm.h +++ b/runtime/vm/cpu_arm.h @@ -5,6 +5,10 @@ #ifndef RUNTIME_VM_CPU_ARM_H_ #define RUNTIME_VM_CPU_ARM_H_ +#if !defined(RUNTIME_VM_CPU_H_) +#error Do not include cpu_arm.h directly; use cpu.h instead. +#endif + #include "vm/allocation.h" #include "vm/simulator.h" diff --git a/runtime/vm/cpu_arm64.h b/runtime/vm/cpu_arm64.h index 25481cb0773..5fa7b2e5e89 100644 --- a/runtime/vm/cpu_arm64.h +++ b/runtime/vm/cpu_arm64.h @@ -5,6 +5,10 @@ #ifndef RUNTIME_VM_CPU_ARM64_H_ #define RUNTIME_VM_CPU_ARM64_H_ +#if !defined(RUNTIME_VM_CPU_H_) +#error Do not include cpu_arm64.h directly; use cpu.h instead. +#endif + #include "vm/allocation.h" #include "vm/simulator.h" diff --git a/runtime/vm/cpu_dbc.h b/runtime/vm/cpu_dbc.h index 08a4a83678c..5e0064bd29d 100644 --- a/runtime/vm/cpu_dbc.h +++ b/runtime/vm/cpu_dbc.h @@ -5,6 +5,10 @@ #ifndef RUNTIME_VM_CPU_DBC_H_ #define RUNTIME_VM_CPU_DBC_H_ +#if !defined(RUNTIME_VM_CPU_H_) +#error Do not include cpu_dbc.h directly; use cpu.h instead. +#endif + #include "vm/allocation.h" #include "vm/simulator.h" diff --git a/runtime/vm/cpu_ia32.h b/runtime/vm/cpu_ia32.h index d48632792f1..a740fb5abec 100644 --- a/runtime/vm/cpu_ia32.h +++ b/runtime/vm/cpu_ia32.h @@ -5,6 +5,10 @@ #ifndef RUNTIME_VM_CPU_IA32_H_ #define RUNTIME_VM_CPU_IA32_H_ +#if !defined(RUNTIME_VM_CPU_H_) +#error Do not include cpu_ia32.h directly; use cpu.h instead. +#endif + #include "vm/allocation.h" #include "vm/flags.h" diff --git a/runtime/vm/cpu_x64.h b/runtime/vm/cpu_x64.h index 716c5880d12..e87d2d515a2 100644 --- a/runtime/vm/cpu_x64.h +++ b/runtime/vm/cpu_x64.h @@ -5,6 +5,10 @@ #ifndef RUNTIME_VM_CPU_X64_H_ #define RUNTIME_VM_CPU_X64_H_ +#if !defined(RUNTIME_VM_CPU_H_) +#error Do not include cpu_x64.h directly; use cpu.h instead. +#endif + #include "vm/allocation.h" #include "vm/flags.h" diff --git a/runtime/vm/custom_isolate_test.cc b/runtime/vm/custom_isolate_test.cc index cf8702524f4..a9c024de640 100644 --- a/runtime/vm/custom_isolate_test.cc +++ b/runtime/vm/custom_isolate_test.cc @@ -242,7 +242,7 @@ static void native_echo(Dart_NativeArguments args) { EXPECT_VALID(toString); const char* c_str = NULL; EXPECT_VALID(Dart_StringToCString(toString, &c_str)); - if (saved_echo) { + if (saved_echo != nullptr) { free(saved_echo); } saved_echo = strdup(c_str); @@ -333,7 +333,7 @@ VM_UNIT_TEST_CASE(CustomIsolates) { OS::PrintErr("-- Starting event loop --\n"); Event* event = event_queue->Get(); - while (event) { + while (event != nullptr) { event->Process(); delete event; event = event_queue->Get(); diff --git a/runtime/vm/dart_api_impl.cc b/runtime/vm/dart_api_impl.cc index fc9608aa610..00b0d486c97 100644 --- a/runtime/vm/dart_api_impl.cc +++ b/runtime/vm/dart_api_impl.cc @@ -6479,7 +6479,7 @@ Dart_CreateAppJITSnapshotAsBlobs(uint8_t** isolate_snapshot_data_buffer, BackgroundCompiler::Stop(I); DropRegExpMatchCode(Z); - if (reused_instructions) { + if (reused_instructions != nullptr) { DropCodeWithoutReusableInstructions(reused_instructions); } ProgramVisitor::Dedup(); @@ -6506,7 +6506,7 @@ Dart_CreateAppJITSnapshotAsBlobs(uint8_t** isolate_snapshot_data_buffer, *isolate_snapshot_instructions_size = isolate_image_writer.InstructionsBlobSize(); - if (reused_instructions) { + if (reused_instructions != nullptr) { *isolate_snapshot_instructions_buffer = NULL; } diff --git a/runtime/vm/dart_api_impl_test.cc b/runtime/vm/dart_api_impl_test.cc index bf716b7e8d3..5d444dcc44d 100644 --- a/runtime/vm/dart_api_impl_test.cc +++ b/runtime/vm/dart_api_impl_test.cc @@ -4509,9 +4509,9 @@ static Dart_NativeFunction TestNativeFieldsAccess_lookup(Dart_Handle name, } const char* function_name = obj.ToCString(); ASSERT(function_name != NULL); - if (!strcmp(function_name, "TestNativeFieldsAccess_init")) { + if (strcmp(function_name, "TestNativeFieldsAccess_init") == 0) { return reinterpret_cast(&TestNativeFieldsAccess_init); - } else if (!strcmp(function_name, "TestNativeFieldsAccess_access")) { + } else if (strcmp(function_name, "TestNativeFieldsAccess_access") == 0) { return reinterpret_cast( &TestNativeFieldsAccess_access); } else { @@ -5754,9 +5754,9 @@ static Dart_NativeFunction native_args_lookup(Dart_Handle name, *auto_scope_setup = true; const char* function_name = obj.ToCString(); ASSERT(function_name != NULL); - if (!strcmp(function_name, "NativeArgument_Create")) { + if (strcmp(function_name, "NativeArgument_Create") == 0) { return reinterpret_cast(&NativeArgumentCreate); - } else if (!strcmp(function_name, "NativeArgument_Access")) { + } else if (strcmp(function_name, "NativeArgument_Access") == 0) { return reinterpret_cast(&NativeArgumentAccess); } return NULL; @@ -6958,13 +6958,13 @@ static Dart_NativeFunction MyNativeClosureResolver(Dart_Handle name, const char* kNativeFoo2 = "NativeFoo2"; const char* kNativeFoo3 = "NativeFoo3"; const char* kNativeFoo4 = "NativeFoo4"; - if (!strncmp(function_name, kNativeFoo1, strlen(kNativeFoo1))) { + if (strncmp(function_name, kNativeFoo1, strlen(kNativeFoo1)) == 0) { return &NativeFoo1; - } else if (!strncmp(function_name, kNativeFoo2, strlen(kNativeFoo2))) { + } else if (strncmp(function_name, kNativeFoo2, strlen(kNativeFoo2)) == 0) { return &NativeFoo2; - } else if (!strncmp(function_name, kNativeFoo3, strlen(kNativeFoo3))) { + } else if (strncmp(function_name, kNativeFoo3, strlen(kNativeFoo3)) == 0) { return &NativeFoo3; - } else if (!strncmp(function_name, kNativeFoo4, strlen(kNativeFoo4))) { + } else if (strncmp(function_name, kNativeFoo4, strlen(kNativeFoo4)) == 0) { return &NativeFoo4; } else { UNREACHABLE(); @@ -7098,13 +7098,13 @@ static Dart_NativeFunction MyStaticNativeClosureResolver( const char* kNativeFoo2 = "StaticNativeFoo2"; const char* kNativeFoo3 = "StaticNativeFoo3"; const char* kNativeFoo4 = "StaticNativeFoo4"; - if (!strncmp(function_name, kNativeFoo1, strlen(kNativeFoo1))) { + if (strncmp(function_name, kNativeFoo1, strlen(kNativeFoo1)) == 0) { return &StaticNativeFoo1; - } else if (!strncmp(function_name, kNativeFoo2, strlen(kNativeFoo2))) { + } else if (strncmp(function_name, kNativeFoo2, strlen(kNativeFoo2)) == 0) { return &StaticNativeFoo2; - } else if (!strncmp(function_name, kNativeFoo3, strlen(kNativeFoo3))) { + } else if (strncmp(function_name, kNativeFoo3, strlen(kNativeFoo3)) == 0) { return &StaticNativeFoo3; - } else if (!strncmp(function_name, kNativeFoo4, strlen(kNativeFoo4))) { + } else if (strncmp(function_name, kNativeFoo4, strlen(kNativeFoo4)) == 0) { return &StaticNativeFoo4; } else { UNREACHABLE(); diff --git a/runtime/vm/debugger.cc b/runtime/vm/debugger.cc index 0c085231c8f..2f9e40572a7 100644 --- a/runtime/vm/debugger.cc +++ b/runtime/vm/debugger.cc @@ -1945,7 +1945,7 @@ bool Debugger::SetupStepOverAsyncSuspension(const char** error) { ActivationFrame* top_frame = TopDartFrame(); if (!IsAtAsyncJump(top_frame)) { // Not at an async operation. - if (error) { + if (error != nullptr) { *error = "Isolate must be paused at an async suspension point"; } return false; @@ -1957,7 +1957,7 @@ bool Debugger::SetupStepOverAsyncSuspension(const char** error) { Breakpoint* bpt = SetBreakpointAtActivation(Instance::Cast(closure), true); if (bpt == NULL) { // Unable to set the breakpoint. - if (error) { + if (error != nullptr) { *error = "Unable to set breakpoint at async suspension point"; } return false; @@ -1968,7 +1968,7 @@ bool Debugger::SetupStepOverAsyncSuspension(const char** error) { bool Debugger::SetResumeAction(ResumeAction action, intptr_t frame_index, const char** error) { - if (error) { + if (error != nullptr) { *error = NULL; } resume_frame_index_ = -1; @@ -4051,7 +4051,7 @@ bool Debugger::CanRewindFrame(intptr_t frame_index, const char** error) const { DebuggerStackTrace* stack = Isolate::Current()->debugger()->StackTrace(); intptr_t num_frames = stack->Length(); if (frame_index < 1 || frame_index >= num_frames) { - if (error) { + if (error != nullptr) { *error = Thread::Current()->zone()->PrintToString( "Frame must be in bounds [1..%" Pd "]: " diff --git a/runtime/vm/elf.cc b/runtime/vm/elf.cc index ad153e209b3..63060295ed8 100644 --- a/runtime/vm/elf.cc +++ b/runtime/vm/elf.cc @@ -256,7 +256,7 @@ class SymbolTable : public Section { static uint32_t ElfHash(const unsigned char* name) { uint32_t h = 0; - while (*name) { + while (*name != '\0') { h = (h << 4) + *name++; uint32_t g = h & 0xf0000000; h ^= g; diff --git a/runtime/vm/exceptions_test.cc b/runtime/vm/exceptions_test.cc index fe090d6bb79..722ffef89e1 100644 --- a/runtime/vm/exceptions_test.cc +++ b/runtime/vm/exceptions_test.cc @@ -76,7 +76,7 @@ static Dart_NativeFunction native_lookup(Dart_Handle name, int num_entries = sizeof(BuiltinEntries) / sizeof(struct NativeEntries); for (int i = 0; i < num_entries; i++) { struct NativeEntries* entry = &(BuiltinEntries[i]); - if (!strcmp(function_name, entry->name_) && + if ((strcmp(function_name, entry->name_) == 0) && (argument_count == entry->argument_count_)) { return reinterpret_cast(entry->function_); } diff --git a/runtime/vm/frame_layout.h b/runtime/vm/frame_layout.h index 32423537cd3..43270508d34 100644 --- a/runtime/vm/frame_layout.h +++ b/runtime/vm/frame_layout.h @@ -5,6 +5,9 @@ #ifndef RUNTIME_VM_FRAME_LAYOUT_H_ #define RUNTIME_VM_FRAME_LAYOUT_H_ +#include "platform/assert.h" +#include "platform/globals.h" + // FrameLayout structure captures configuration specific properties of the // frame layout used by the runtime system and compiler. // diff --git a/runtime/vm/hash.h b/runtime/vm/hash.h index b4fc808e33e..cbd4c83690b 100644 --- a/runtime/vm/hash.h +++ b/runtime/vm/hash.h @@ -5,6 +5,8 @@ #ifndef RUNTIME_VM_HASH_H_ #define RUNTIME_VM_HASH_H_ +#include "platform/globals.h" + namespace dart { inline uint32_t CombineHashes(uint32_t hash, uint32_t other_hash) { diff --git a/runtime/vm/heap/freelist_test.cc b/runtime/vm/heap/freelist_test.cc index d3a0ae94b47..aee898fbdc3 100644 --- a/runtime/vm/heap/freelist_test.cc +++ b/runtime/vm/heap/freelist_test.cc @@ -10,7 +10,7 @@ namespace dart { static uword Allocate(FreeList* free_list, intptr_t size, bool is_protected) { uword result = free_list->TryAllocate(size, is_protected); - if (result && is_protected) { + if ((result != 0u) && is_protected) { VirtualMemory::Protect(reinterpret_cast(result), size, VirtualMemory::kReadExecute); } diff --git a/runtime/vm/heap/heap.cc b/runtime/vm/heap/heap.cc index 493a3d8d6e7..2e9d7f44f85 100644 --- a/runtime/vm/heap/heap.cc +++ b/runtime/vm/heap/heap.cc @@ -585,7 +585,7 @@ void Heap::CheckStartConcurrentMarking(Thread* thread, GCReason reason) { if (old_space_.AlmostNeedsGarbageCollection()) { if (BeginOldSpaceGC(thread)) { TIMELINE_FUNCTION_GC_DURATION_BASIC(thread, "StartConcurrentMarking"); - old_space_.CollectGarbage(kMarkSweep, false /* finish */); + old_space_.CollectGarbage(/*compact=*/false, /*finalize=*/false); EndOldSpaceGC(); } } diff --git a/runtime/vm/heap/spaces.h b/runtime/vm/heap/spaces.h index 2885ef5a90c..e2737e4e607 100644 --- a/runtime/vm/heap/spaces.h +++ b/runtime/vm/heap/spaces.h @@ -5,6 +5,8 @@ #ifndef RUNTIME_VM_HEAP_SPACES_H_ #define RUNTIME_VM_HEAP_SPACES_H_ +#include "platform/globals.h" + // This file contains utilities shared by old and new space. // TODO(koda): Create Space base class with Space::CurrentUsage(). diff --git a/runtime/vm/interpreter.cc b/runtime/vm/interpreter.cc index dea9ec38ba9..01e772604b3 100644 --- a/runtime/vm/interpreter.cc +++ b/runtime/vm/interpreter.cc @@ -2595,7 +2595,7 @@ SwitchDispatch: { BYTECODE(AssertBoolean, A); RawObject* value = SP[0]; - if (rA) { // Should we perform type check? + if (rA != 0u) { // Should we perform type check? if ((value == true_value) || (value == false_value)) { goto AssertBooleanOk; } diff --git a/runtime/vm/isolate.cc b/runtime/vm/isolate.cc index 6339d87d2f5..6849a88c930 100644 --- a/runtime/vm/isolate.cc +++ b/runtime/vm/isolate.cc @@ -676,7 +676,7 @@ void IsolateMessageHandler::MessageNotify(Message::Priority priority) { I->ScheduleInterrupts(Thread::kMessageInterrupt); } Dart_MessageNotifyCallback callback = I->message_notify_callback(); - if (callback) { + if (callback != nullptr) { // Allow the embedder to handle message notification. (*callback)(Api::CastIsolate(I)); } @@ -2819,7 +2819,7 @@ void Isolate::VisitIsolates(IsolateVisitor* visitor) { // SafepointMonitorLocker to ensure the lock has safepoint checks. SafepointMonitorLocker ml(isolates_list_monitor_); Isolate* current = isolates_list_head_; - while (current) { + while (current != nullptr) { visitor->VisitIsolate(current); current = current->next_; } @@ -2887,7 +2887,7 @@ void Isolate::RemoveIsolateFromList(Isolate* isolate) { } Isolate* previous = nullptr; Isolate* current = isolates_list_head_; - while (current) { + while (current != nullptr) { if (current == isolate) { ASSERT(previous != nullptr); previous->next_ = current->next_; diff --git a/runtime/vm/isolate_reload.cc b/runtime/vm/isolate_reload.cc index 1ddbad1a3d3..69d14493de4 100644 --- a/runtime/vm/isolate_reload.cc +++ b/runtime/vm/isolate_reload.cc @@ -83,7 +83,7 @@ void InstanceMorpher::AddObject(RawObject* object) const { } void InstanceMorpher::ComputeMapping() { - if (from_.NumTypeArguments()) { + if (from_.NumTypeArguments() > 0) { // Add copying of the optional type argument field. intptr_t from_offset = from_.type_arguments_field_offset(); ASSERT(from_offset != Class::kNoTypeArguments); @@ -217,7 +217,7 @@ void InstanceMorpher::CreateMorphedCopies() const { void InstanceMorpher::DumpFormatFor(const Class& cls) const { THR_Print("%s\n", cls.ToCString()); - if (cls.NumTypeArguments()) { + if (cls.NumTypeArguments() > 0) { intptr_t field_offset = cls.type_arguments_field_offset(); ASSERT(field_offset != Class::kNoTypeArguments); THR_Print(" - @%" Pd " \n", field_offset); diff --git a/runtime/vm/json_stream.cc b/runtime/vm/json_stream.cc index 30cddd2d029..33a990c78fa 100644 --- a/runtime/vm/json_stream.cc +++ b/runtime/vm/json_stream.cc @@ -270,7 +270,7 @@ void JSONStream::PostReply() { const char* JSONStream::LookupParam(const char* key) const { for (int i = 0; i < num_params(); i++) { - if (!strcmp(key, param_keys_[i])) { + if (strcmp(key, param_keys_[i]) == 0) { return param_values_[i]; } } diff --git a/runtime/vm/kernel_loader.cc b/runtime/vm/kernel_loader.cc index e65db731f7e..be9b671355c 100644 --- a/runtime/vm/kernel_loader.cc +++ b/runtime/vm/kernel_loader.cc @@ -1316,7 +1316,7 @@ void KernelLoader::LoadLibraryImportsAndExports(Library* library, for (intptr_t n = 0; n < name_count; ++n) { String& show_hide_name = H.DartSymbolObfuscate(helper_.ReadStringReference()); - if (flags & LibraryDependencyHelper::Show) { + if ((flags & LibraryDependencyHelper::Show) != 0) { show_list.Add(show_hide_name, Heap::kOld); } else { hide_list.Add(show_hide_name, Heap::kOld); @@ -1351,7 +1351,7 @@ void KernelLoader::LoadLibraryImportsAndExports(Library* library, } String& prefix = H.DartSymbolPlain(dependency_helper.name_index_); ns = Namespace::New(target_library, show_names, hide_names); - if (dependency_helper.flags_ & LibraryDependencyHelper::Export) { + if ((dependency_helper.flags_ & LibraryDependencyHelper::Export) != 0) { library->AddExport(ns); } else { if (prefix.IsNull() || prefix.Length() == 0) { @@ -1363,7 +1363,8 @@ void KernelLoader::LoadLibraryImportsAndExports(Library* library, } else { library_prefix = LibraryPrefix::New( prefix, ns, - dependency_helper.flags_ & LibraryDependencyHelper::Deferred, + (dependency_helper.flags_ & LibraryDependencyHelper::Deferred) != + 0, *library); library->AddObject(library_prefix, prefix); } diff --git a/runtime/vm/message_handler.cc b/runtime/vm/message_handler.cc index 0951509bc13..d945b97b69d 100644 --- a/runtime/vm/message_handler.cc +++ b/runtime/vm/message_handler.cc @@ -130,7 +130,7 @@ void MessageHandler::PostMessage(std::unique_ptr message, MonitorLocker ml(&monitor_); if (FLAG_trace_isolates) { Isolate* source_isolate = Isolate::Current(); - if (source_isolate) { + if (source_isolate != nullptr) { OS::PrintErr( "[>] Posting message:\n" "\tlen: %" Pd "\n\tsource: (%" Pd64 @@ -416,7 +416,7 @@ void MessageHandler::TaskCallback() { #endif // !defined(PRODUCT) if (status == kOK) { - if (start_callback_) { + if (start_callback_ != nullptr) { // Initialize the message handler by running its start function, // if we have one. For an isolate, this will run the isolate's // main() function. diff --git a/runtime/vm/native_arguments.h b/runtime/vm/native_arguments.h index ab948de511b..8d071431965 100644 --- a/runtime/vm/native_arguments.h +++ b/runtime/vm/native_arguments.h @@ -120,7 +120,8 @@ class NativeArguments { if ((function_bits & (kClosureFunctionBit | kInstanceFunctionBit)) == (kClosureFunctionBit | kInstanceFunctionBit)) { // Retrieve the receiver from the context. - const int closure_index = (function_bits & kGenericFunctionBit) ? 1 : 0; + const int closure_index = + (function_bits & kGenericFunctionBit) != 0 ? 1 : 0; const Object& closure = Object::Handle(ArgAt(closure_index)); const Context& context = Context::Handle(Closure::Cast(closure).context()); @@ -268,17 +269,17 @@ class NativeArguments { // Returns true if the arguments are those of an instance function call. bool ToInstanceFunction() const { - return (FunctionBits::decode(argc_tag_) & kInstanceFunctionBit); + return (FunctionBits::decode(argc_tag_) & kInstanceFunctionBit) != 0; } // Returns true if the arguments are those of a closure function call. bool ToClosureFunction() const { - return (FunctionBits::decode(argc_tag_) & kClosureFunctionBit); + return (FunctionBits::decode(argc_tag_) & kClosureFunctionBit) != 0; } // Returns true if the arguments are those of a generic function call. bool ToGenericFunction() const { - return (FunctionBits::decode(argc_tag_) & kGenericFunctionBit); + return (FunctionBits::decode(argc_tag_) & kGenericFunctionBit) != 0; } int NumHiddenArgs(int function_bits) const { diff --git a/runtime/vm/object.cc b/runtime/vm/object.cc index 2727eaa3889..256f2f57bb3 100644 --- a/runtime/vm/object.cc +++ b/runtime/vm/object.cc @@ -2986,7 +2986,7 @@ RawFunction* Function::CreateMethodExtractor(const String& getter_name) const { // Initialize signature: receiver is a single fixed parameter. const intptr_t kNumParameters = 1; extractor.set_num_fixed_parameters(kNumParameters); - extractor.SetNumOptionalParameters(0, 0); + extractor.SetNumOptionalParameters(0, false); extractor.set_parameter_types(Object::extractor_parameter_types()); extractor.set_parameter_names(Object::extractor_parameter_names()); extractor.set_result_type(Object::dynamic_type()); @@ -12938,7 +12938,7 @@ bool StackMap::GetBit(intptr_t bit_index) const { int bit_remainder = bit_index & (kBitsPerByte - 1); uint8_t byte_mask = 1U << bit_remainder; uint8_t byte = raw_ptr()->data()[byte_index]; - return (byte & byte_mask); + return (byte & byte_mask) != 0; } void StackMap::SetBit(intptr_t bit_index, bool value) const { @@ -13202,9 +13202,9 @@ void ExceptionHandlers::SetHandlerInfo(intptr_t try_index, ASSERT((handler_pc_offset == static_cast(kMaxUint32)) || (handler_pc_offset < static_cast(kMaxUint32))); info->handler_pc_offset = handler_pc_offset; - info->needs_stacktrace = needs_stacktrace; - info->has_catch_all = has_catch_all; - info->is_generated = is_generated; + info->needs_stacktrace = static_cast(needs_stacktrace); + info->has_catch_all = static_cast(has_catch_all); + info->is_generated = static_cast(is_generated); } void ExceptionHandlers::GetHandlerInfo(intptr_t try_index, @@ -13226,17 +13226,17 @@ intptr_t ExceptionHandlers::OuterTryIndex(intptr_t try_index) const { bool ExceptionHandlers::NeedsStackTrace(intptr_t try_index) const { ASSERT((try_index >= 0) && (try_index < num_entries())); - return raw_ptr()->data()[try_index].needs_stacktrace; + return raw_ptr()->data()[try_index].needs_stacktrace != 0; } bool ExceptionHandlers::IsGenerated(intptr_t try_index) const { ASSERT((try_index >= 0) && (try_index < num_entries())); - return raw_ptr()->data()[try_index].is_generated; + return raw_ptr()->data()[try_index].is_generated != 0; } bool ExceptionHandlers::HasCatchAll(intptr_t try_index) const { ASSERT((try_index >= 0) && (try_index < num_entries())); - return raw_ptr()->data()[try_index].has_catch_all; + return raw_ptr()->data()[try_index].has_catch_all != 0; } void ExceptionHandlers::SetHandledTypes(intptr_t try_index, @@ -13323,7 +13323,7 @@ const char* ExceptionHandlers::ToCString() const { handled_types.IsNull() ? 0 : handled_types.Length(); len += Utils::SNPrint(NULL, 0, FORMAT1, i, info.handler_pc_offset, num_types, info.outer_try_index, - info.is_generated ? "(generated)" : ""); + info.is_generated != 0 ? "(generated)" : ""); for (int k = 0; k < num_types; k++) { type ^= handled_types.At(k); ASSERT(!type.IsNull()); @@ -13342,7 +13342,7 @@ const char* ExceptionHandlers::ToCString() const { num_chars += Utils::SNPrint((buffer + num_chars), (len - num_chars), FORMAT1, i, info.handler_pc_offset, num_types, info.outer_try_index, - info.is_generated ? "(generated)" : ""); + info.is_generated != 0 ? "(generated)" : ""); for (int k = 0; k < num_types; k++) { type ^= handled_types.At(k); num_chars += Utils::SNPrint((buffer + num_chars), (len - num_chars), diff --git a/runtime/vm/object_graph.cc b/runtime/vm/object_graph.cc index 26b607ba626..432a6a05426 100644 --- a/runtime/vm/object_graph.cc +++ b/runtime/vm/object_graph.cc @@ -671,7 +671,8 @@ class Pass2Visitor : public ObjectVisitor, writer_->WriteUnsigned(kNullData); } else if (cid == kBoolCid) { writer_->WriteUnsigned(kBoolData); - writer_->WriteUnsigned(static_cast(obj)->ptr()->value_); + writer_->WriteUnsigned( + static_cast(static_cast(obj)->ptr()->value_)); } else if (cid == kSmiCid) { UNREACHABLE(); } else if (cid == kMintCid) { diff --git a/runtime/vm/os_linux.cc b/runtime/vm/os_linux.cc index eecf7fdb30a..9baba7e499e 100644 --- a/runtime/vm/os_linux.cc +++ b/runtime/vm/os_linux.cc @@ -599,7 +599,7 @@ char* OS::VSCreate(Zone* zone, const char* format, va_list args) { va_end(measure_args); char* buffer; - if (zone) { + if (zone != nullptr) { buffer = zone->Alloc(len + 1); } else { buffer = reinterpret_cast(malloc(len + 1)); diff --git a/runtime/vm/pointer_tagging.h b/runtime/vm/pointer_tagging.h index a4d6d9f0d1c..e4a59e617ef 100644 --- a/runtime/vm/pointer_tagging.h +++ b/runtime/vm/pointer_tagging.h @@ -5,6 +5,9 @@ #ifndef RUNTIME_VM_POINTER_TAGGING_H_ #define RUNTIME_VM_POINTER_TAGGING_H_ +#include "platform/assert.h" +#include "platform/globals.h" + // This header defines constants associated with pointer tagging: // // * which bits determine whether or not this is a Smi value or a heap diff --git a/runtime/vm/proccpuinfo.cc b/runtime/vm/proccpuinfo.cc index 3dfb2cbfe55..6278627086b 100644 --- a/runtime/vm/proccpuinfo.cc +++ b/runtime/vm/proccpuinfo.cc @@ -76,7 +76,7 @@ char* ProcCpuInfo::FieldStart(const char* field) { // Skip to the first colon followed by a space. p = strchr(p + fieldlen, ':'); - if (p == NULL || !isspace(p[1])) { + if (p == NULL || (isspace(p[1]) == 0)) { return NULL; } p += 2; diff --git a/runtime/vm/regexp.cc b/runtime/vm/regexp.cc index 12796de35ed..23efd9ddb55 100644 --- a/runtime/vm/regexp.cc +++ b/runtime/vm/regexp.cc @@ -3556,7 +3556,7 @@ class DotPrinter : public NodeVisitor { void DotPrinter::PrintNode(const char* label, RegExpNode* node) { OS::PrintErr("digraph G {\n graph [label=\""); - for (intptr_t i = 0; label[i]; i++) { + for (intptr_t i = 0; label[i] != '\0'; i++) { switch (label[i]) { case '\\': OS::PrintErr("\\\\"); @@ -5286,7 +5286,7 @@ RegExpEngine::CompilationResult RegExpEngine::CompileIR( const Function& function = parsed_function->function(); const intptr_t specialization_cid = function.string_specialization_cid(); - const intptr_t is_sticky = function.is_sticky_specialization(); + const bool is_sticky = function.is_sticky_specialization(); const bool is_one_byte = (specialization_cid == kOneByteStringCid || specialization_cid == kExternalOneByteStringCid); RegExp& regexp = RegExp::Handle(zone, function.regexp()); diff --git a/runtime/vm/regexp_ast.h b/runtime/vm/regexp_ast.h index 4fb64a3ae20..6301d4de359 100644 --- a/runtime/vm/regexp_ast.h +++ b/runtime/vm/regexp_ast.h @@ -204,10 +204,10 @@ class RegExpCharacterClass : public RegExpTree { // * : All characters uint16_t standard_type() const { return set_.standard_set_type(); } ZoneGrowableArray* ranges() { return set_.ranges(); } - bool is_negated() const { return character_class_flags_ & NEGATED; } + bool is_negated() const { return (character_class_flags_ & NEGATED) != 0; } RegExpFlags flags() const { return flags_; } bool contains_split_surrogate() const { - return character_class_flags_ & CONTAINS_SPLIT_SURROGATE; + return (character_class_flags_ & CONTAINS_SPLIT_SURROGATE) != 0; } private: diff --git a/runtime/vm/regexp_parser.cc b/runtime/vm/regexp_parser.cc index 40bf227d6d0..3f3bdf3442e 100644 --- a/runtime/vm/regexp_parser.cc +++ b/runtime/vm/regexp_parser.cc @@ -1506,7 +1506,7 @@ bool LookupPropertyValueName(UProperty property, UErrorCode ec = U_ZERO_ERROR; icu::UnicodeSet set; set.applyIntPropertyValue(property, property_value, ec); - bool success = ec == U_ZERO_ERROR && !set.isEmpty(); + bool success = ec == U_ZERO_ERROR && (set.isEmpty() == 0); if (success) { set.removeAllStrings(); diff --git a/runtime/vm/runtime_entry.cc b/runtime/vm/runtime_entry.cc index 9e0badc39d6..3641e8a3439 100644 --- a/runtime/vm/runtime_entry.cc +++ b/runtime/vm/runtime_entry.cc @@ -2054,7 +2054,7 @@ static void HandleStackOverflowTestCases(Thread* thread) { } } if (FLAG_deoptimize_filter != nullptr || FLAG_stacktrace_filter != nullptr || - FLAG_reload_every) { + (FLAG_reload_every != 0)) { DartFrameIterator iterator(thread, StackFrameIterator::kNoCrossThreadIteration); StackFrame* frame = iterator.NextFrame(); @@ -2753,11 +2753,11 @@ DEFINE_LEAF_RUNTIME_ENTRY(intptr_t, THR_Print("== Deoptimizing code for '%s', %s, %s\n", function.ToFullyQualifiedCString(), deoptimizing_code ? "code & frame" : "frame", - is_lazy_deopt ? "lazy-deopt" : ""); + (is_lazy_deopt != 0u) ? "lazy-deopt" : ""); } #if !defined(TARGET_ARCH_DBC) - if (is_lazy_deopt) { + if (is_lazy_deopt != 0u) { uword deopt_pc = isolate->FindPendingDeopt(caller_frame->fp()); if (FLAG_trace_deoptimization) { THR_Print("Lazy deopt fp=%" Pp " pc=%" Pp "\n", caller_frame->fp(), diff --git a/runtime/vm/scope_timer.h b/runtime/vm/scope_timer.h index c910e3456a3..0707980b77d 100644 --- a/runtime/vm/scope_timer.h +++ b/runtime/vm/scope_timer.h @@ -5,8 +5,11 @@ #ifndef RUNTIME_VM_SCOPE_TIMER_H_ #define RUNTIME_VM_SCOPE_TIMER_H_ +#include "platform/allocation.h" #include "platform/globals.h" +#include "vm/os.h" + namespace dart { // Simple utility class for timing a block of code. diff --git a/runtime/vm/scopes.h b/runtime/vm/scopes.h index 71ef849540f..69e8510de09 100644 --- a/runtime/vm/scopes.h +++ b/runtime/vm/scopes.h @@ -60,7 +60,7 @@ class VariableIndex { explicit VariableIndex(int value = kInvalidIndex) : value_(value) {} - int operator==(const VariableIndex& other) { return value_ == other.value_; } + bool operator==(const VariableIndex& other) { return value_ == other.value_; } bool IsValid() const { return value_ != kInvalidIndex; } diff --git a/runtime/vm/service.cc b/runtime/vm/service.cc index d212875515a..9ee2ac079d9 100644 --- a/runtime/vm/service.cc +++ b/runtime/vm/service.cc @@ -146,7 +146,7 @@ bool Service::ListenStream(const char* stream_id) { return true; } } - if (stream_listen_callback_) { + if (stream_listen_callback_ != nullptr) { Thread* T = Thread::Current(); TransitionVMToNative transition(T); return (*stream_listen_callback_)(stream_id); @@ -165,7 +165,7 @@ void Service::CancelStream(const char* stream_id) { return; } } - if (stream_cancel_callback_) { + if (stream_cancel_callback_ != nullptr) { Thread* T = Thread::Current(); TransitionVMToNative transition(T); return (*stream_cancel_callback_)(stream_id); @@ -2041,7 +2041,7 @@ static Breakpoint* LookupBreakpoint(Isolate* isolate, Breakpoint* bpt = NULL; if (GetIntegerId(rest, &bpt_id)) { bpt = isolate->debugger()->GetBreakpointById(bpt_id); - if (bpt) { + if (bpt != nullptr) { *result = ObjectIdRing::kValid; return bpt; } diff --git a/runtime/vm/snapshot.cc b/runtime/vm/snapshot.cc index b78480f4f75..7fbc4d55692 100644 --- a/runtime/vm/snapshot.cc +++ b/runtime/vm/snapshot.cc @@ -636,7 +636,7 @@ RawApiError* SnapshotReader::VerifyVersionAndFeatures(Isolate* isolate) { const char* version = reinterpret_cast(CurrentBufferAddress()); ASSERT(version != NULL); - if (strncmp(version, expected_version, version_len)) { + if (strncmp(version, expected_version, version_len) != 0) { const intptr_t kMessageBufferSize = 256; char message_buffer[kMessageBufferSize]; char* actual_version = Utils::StrNDup(version, version_len); @@ -660,7 +660,7 @@ RawApiError* SnapshotReader::VerifyVersionAndFeatures(Isolate* isolate) { ASSERT(features != NULL); intptr_t buffer_len = Utils::StrNLen(features, PendingBytes()); if ((buffer_len != expected_len) || - strncmp(features, expected_features, expected_len)) { + (strncmp(features, expected_features, expected_len) != 0)) { const intptr_t kMessageBufferSize = 256; char message_buffer[kMessageBufferSize]; char* actual_features = diff --git a/runtime/vm/source_report.cc b/runtime/vm/source_report.cc index 30bf604838d..226b4e9a0e1 100644 --- a/runtime/vm/source_report.cc +++ b/runtime/vm/source_report.cc @@ -5,6 +5,7 @@ #if !defined(PRODUCT) && !defined(DART_PRECOMPILED_RUNTIME) #include "vm/source_report.h" +#include "vm/bit_vector.h" #include "vm/compiler/jit/compiler.h" #include "vm/isolate.h" #include "vm/kernel_loader.h" @@ -330,11 +331,8 @@ void SourceReport::PrintPossibleBreakpointsData(JSONObject* jsobj, const TokenPosition begin_pos = func.token_pos(); const TokenPosition end_pos = func.end_token_pos(); intptr_t func_length = (end_pos.Pos() - begin_pos.Pos()) + 1; - GrowableArray possible(func_length); - possible.SetLength(func_length); - for (int i = 0; i < func_length; i++) { - possible[i] = false; - } + + BitVector possible(zone(), func_length); if (code.IsNull()) { const Bytecode& bytecode = Bytecode::Handle(func.bytecode()); @@ -354,7 +352,7 @@ void SourceReport::PrintPossibleBreakpointsData(JSONObject* jsobj, // source position range. if (bytecode.GetDebugCheckedOpcodeReturnAddress( pc_offset, iter.PcOffset()) != 0) { - possible[token_offset] = true; + possible.Add(token_offset); } pc_offset = kUwordMax; } @@ -373,7 +371,7 @@ void SourceReport::PrintPossibleBreakpointsData(JSONObject* jsobj, } if (pc_offset != kUwordMax && bytecode.GetDebugCheckedOpcodeReturnAddress( pc_offset, bytecode.Size()) != 0) { - possible[token_offset] = true; + possible.Add(token_offset); } } else { const uint8_t kSafepointKind = @@ -391,13 +389,13 @@ void SourceReport::PrintPossibleBreakpointsData(JSONObject* jsobj, continue; } intptr_t token_offset = token_pos.Pos() - begin_pos.Pos(); - possible[token_offset] = true; + possible.Add(token_offset); } } JSONArray bpts(jsobj, "possibleBreakpoints"); for (int i = 0; i < func_length; i++) { - if (possible[i]) { + if (possible.Contains(i)) { // Add the token position. bpts.AddValue(begin_pos.Pos() + i); } diff --git a/runtime/vm/stack_frame.cc b/runtime/vm/stack_frame.cc index 0e61b72989a..2bdde950c98 100644 --- a/runtime/vm/stack_frame.cc +++ b/runtime/vm/stack_frame.cc @@ -515,8 +515,8 @@ bool StackFrame::FindExceptionHandler(Thread* thread, ExceptionHandlerInfo* info = cache->Lookup(pc()); if (info != NULL) { *handler_pc = start + info->handler_pc_offset; - *needs_stacktrace = info->needs_stacktrace; - *has_catch_all = info->has_catch_all; + *needs_stacktrace = (info->needs_stacktrace != 0); + *has_catch_all = (info->has_catch_all != 0); return true; } @@ -544,8 +544,8 @@ bool StackFrame::FindExceptionHandler(Thread* thread, ExceptionHandlerInfo handler_info; handlers.GetHandlerInfo(try_index, &handler_info); *handler_pc = start + handler_info.handler_pc_offset; - *needs_stacktrace = handler_info.needs_stacktrace; - *has_catch_all = handler_info.has_catch_all; + *needs_stacktrace = (handler_info.needs_stacktrace != 0); + *has_catch_all = (handler_info.has_catch_all != 0); cache->Insert(pc(), handler_info); return true; } diff --git a/runtime/vm/stack_frame_arm.h b/runtime/vm/stack_frame_arm.h index 64139897627..c423a84aca3 100644 --- a/runtime/vm/stack_frame_arm.h +++ b/runtime/vm/stack_frame_arm.h @@ -5,6 +5,10 @@ #ifndef RUNTIME_VM_STACK_FRAME_ARM_H_ #define RUNTIME_VM_STACK_FRAME_ARM_H_ +#if !defined(RUNTIME_VM_STACK_FRAME_H_) +#error Do not include stack_frame_arm.h directly; use stack_frame.h instead. +#endif + namespace dart { /* ARM Dart Frame Layout diff --git a/runtime/vm/stack_frame_arm64.h b/runtime/vm/stack_frame_arm64.h index abaa49a7144..1558a220048 100644 --- a/runtime/vm/stack_frame_arm64.h +++ b/runtime/vm/stack_frame_arm64.h @@ -5,6 +5,10 @@ #ifndef RUNTIME_VM_STACK_FRAME_ARM64_H_ #define RUNTIME_VM_STACK_FRAME_ARM64_H_ +#if !defined(RUNTIME_VM_STACK_FRAME_H_) +#error Do not include stack_frame_arm64.h directly; use stack_frame.h instead. +#endif + namespace dart { /* ARM64 Dart Frame Layout diff --git a/runtime/vm/stack_frame_dbc.h b/runtime/vm/stack_frame_dbc.h index 42a1b79789b..616b01283bc 100644 --- a/runtime/vm/stack_frame_dbc.h +++ b/runtime/vm/stack_frame_dbc.h @@ -5,6 +5,10 @@ #ifndef RUNTIME_VM_STACK_FRAME_DBC_H_ #define RUNTIME_VM_STACK_FRAME_DBC_H_ +#if !defined(RUNTIME_VM_STACK_FRAME_H_) +#error Do not include stack_frame_dbc.h directly; use stack_frame.h instead. +#endif + namespace dart { /* DBC Frame Layout diff --git a/runtime/vm/stack_frame_ia32.h b/runtime/vm/stack_frame_ia32.h index 896fb050058..c8221ee09cb 100644 --- a/runtime/vm/stack_frame_ia32.h +++ b/runtime/vm/stack_frame_ia32.h @@ -5,6 +5,10 @@ #ifndef RUNTIME_VM_STACK_FRAME_IA32_H_ #define RUNTIME_VM_STACK_FRAME_IA32_H_ +#if !defined(RUNTIME_VM_STACK_FRAME_H_) +#error Do not include stack_frame_ia32.h directly; use stack_frame.h instead. +#endif + namespace dart { /* IA32 Dart Frame Layout diff --git a/runtime/vm/stack_frame_kbc.h b/runtime/vm/stack_frame_kbc.h index 3418eaa87bd..6af9a3a4bb7 100644 --- a/runtime/vm/stack_frame_kbc.h +++ b/runtime/vm/stack_frame_kbc.h @@ -5,6 +5,8 @@ #ifndef RUNTIME_VM_STACK_FRAME_KBC_H_ #define RUNTIME_VM_STACK_FRAME_KBC_H_ +#include "platform/globals.h" + namespace dart { /* Kernel Bytecode Frame Layout diff --git a/runtime/vm/stack_frame_test.cc b/runtime/vm/stack_frame_test.cc index 76a31f8c773..15800b7e3e5 100644 --- a/runtime/vm/stack_frame_test.cc +++ b/runtime/vm/stack_frame_test.cc @@ -149,7 +149,7 @@ static Dart_NativeFunction native_lookup(Dart_Handle name, int num_entries = sizeof(BuiltinEntries) / sizeof(struct NativeEntries); for (int i = 0; i < num_entries; i++) { struct NativeEntries* entry = &(BuiltinEntries[i]); - if (!strcmp(function_name, entry->name_) && + if ((strcmp(function_name, entry->name_) == 0) && (entry->argument_count_ == argument_count)) { return reinterpret_cast(entry->function_); } diff --git a/runtime/vm/stack_frame_x64.h b/runtime/vm/stack_frame_x64.h index 1507960f794..dd01d676e7c 100644 --- a/runtime/vm/stack_frame_x64.h +++ b/runtime/vm/stack_frame_x64.h @@ -5,6 +5,10 @@ #ifndef RUNTIME_VM_STACK_FRAME_X64_H_ #define RUNTIME_VM_STACK_FRAME_X64_H_ +#if !defined(RUNTIME_VM_STACK_FRAME_H_) +#error Do not include stack_frame_x64.h directly; use stack_frame.h instead. +#endif + #include "vm/constants_x64.h" namespace dart { diff --git a/runtime/vm/static_type_exactness_state.h b/runtime/vm/static_type_exactness_state.h index 17e00891f56..a55f63ada04 100644 --- a/runtime/vm/static_type_exactness_state.h +++ b/runtime/vm/static_type_exactness_state.h @@ -6,6 +6,7 @@ #define RUNTIME_VM_STATIC_TYPE_EXACTNESS_STATE_H_ #include "platform/allocation.h" +#include "platform/utils.h" // This header defines the list of VM implementation classes and their ids. // diff --git a/runtime/vm/thread.cc b/runtime/vm/thread.cc index 3429f287aca..688e88624b1 100644 --- a/runtime/vm/thread.cc +++ b/runtime/vm/thread.cc @@ -42,7 +42,7 @@ Thread::~Thread() { // There should be no top api scopes at this point. ASSERT(api_top_scope() == NULL); // Delete the resusable api scope if there is one. - if (api_reusable_scope_) { + if (api_reusable_scope_ != nullptr) { delete api_reusable_scope_; api_reusable_scope_ = NULL; } diff --git a/runtime/vm/timeline.cc b/runtime/vm/timeline.cc index 8b9a64440de..bad38fdc461 100644 --- a/runtime/vm/timeline.cc +++ b/runtime/vm/timeline.cc @@ -737,10 +737,11 @@ TimelineStream::TimelineStream(const char* name, : name_(name), fuchsia_name_(fuchsia_name), #if defined(HOST_OS_FUCHSIA) - enabled_(true) { // For generated code. + enabled_(static_cast(true)) // For generated code. #else - enabled_(enabled) { + enabled_(static_cast(enabled)) #endif +{ } TimelineEvent* TimelineStream::StartEvent() {