From 755035170204bc3e6dce96956a276db4408a9820 Mon Sep 17 00:00:00 2001 From: Sergey Bogolepov Date: Thu, 10 Jun 2021 16:00:11 +0700 Subject: [PATCH] [Native] Fix runtime code according to Clang 11 warnings --- kotlin-native/runtime/src/legacymm/cpp/Memory.cpp | 12 ++++++------ kotlin-native/runtime/src/main/cpp/ObjCExport.mm | 2 +- kotlin-native/runtime/src/main/cpp/Porting.cpp | 4 ++-- kotlin-native/runtime/src/main/cpp/Porting.h | 4 ++-- .../runtime/src/main/cpp/snprintf/snprintf.cpp | 2 +- kotlin-native/runtime/src/relaxed/cpp/MemoryImpl.cpp | 2 +- kotlin-native/runtime/src/strict/cpp/MemoryImpl.cpp | 2 +- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/kotlin-native/runtime/src/legacymm/cpp/Memory.cpp b/kotlin-native/runtime/src/legacymm/cpp/Memory.cpp index 7ce05d4dbe3..6856600a6c4 100644 --- a/kotlin-native/runtime/src/legacymm/cpp/Memory.cpp +++ b/kotlin-native/runtime/src/legacymm/cpp/Memory.cpp @@ -3331,10 +3331,10 @@ void ClearMemoryForTests(MemoryState*) { // Nothing to do, DeinitMemory will do the job. } -OBJ_GETTER(AllocInstanceStrict, const TypeInfo* type_info) { +RUNTIME_NOTHROW OBJ_GETTER(AllocInstanceStrict, const TypeInfo* type_info) { RETURN_RESULT_OF(allocInstance, type_info); } -OBJ_GETTER(AllocInstanceRelaxed, const TypeInfo* type_info) { +RUNTIME_NOTHROW OBJ_GETTER(AllocInstanceRelaxed, const TypeInfo* type_info) { RETURN_RESULT_OF(allocInstance, type_info); } @@ -3429,7 +3429,7 @@ RUNTIME_NOTHROW void UpdateHeapRefIfNull(ObjHeader** location, const ObjHeader* updateHeapRefIfNull(location, object); } -OBJ_GETTER(SwapHeapRefLocked, +RUNTIME_NOTHROW OBJ_GETTER(SwapHeapRefLocked, ObjHeader** location, ObjHeader* expectedValue, ObjHeader* newValue, int32_t* spinlock, int32_t* cookie) { RETURN_RESULT_OF(swapHeapRefLocked, location, expectedValue, newValue, spinlock, cookie); } @@ -3438,7 +3438,7 @@ RUNTIME_NOTHROW void SetHeapRefLocked(ObjHeader** location, ObjHeader* newValue, setHeapRefLocked(location, newValue, spinlock, cookie); } -OBJ_GETTER(ReadHeapRefLocked, ObjHeader** location, int32_t* spinlock, int32_t* cookie) { +RUNTIME_NOTHROW OBJ_GETTER(ReadHeapRefLocked, ObjHeader** location, int32_t* spinlock, int32_t* cookie) { RETURN_RESULT_OF(readHeapRefLocked, location, spinlock, cookie); } @@ -3584,11 +3584,11 @@ RUNTIME_NOTHROW void DisposeStablePointerFor(MemoryState* memoryState, KNativePt DisposeStablePointer(pointer); } -OBJ_GETTER(DerefStablePointer, KNativePtr pointer) { +RUNTIME_NOTHROW OBJ_GETTER(DerefStablePointer, KNativePtr pointer) { RETURN_RESULT_OF(derefStablePointer, pointer); } -OBJ_GETTER(AdoptStablePointer, KNativePtr pointer) { +RUNTIME_NOTHROW OBJ_GETTER(AdoptStablePointer, KNativePtr pointer) { RETURN_RESULT_OF(adoptStablePointer, pointer); } diff --git a/kotlin-native/runtime/src/main/cpp/ObjCExport.mm b/kotlin-native/runtime/src/main/cpp/ObjCExport.mm index af1cd2675b9..ac847d484b4 100644 --- a/kotlin-native/runtime/src/main/cpp/ObjCExport.mm +++ b/kotlin-native/runtime/src/main/cpp/ObjCExport.mm @@ -114,7 +114,7 @@ extern "C" id Kotlin_ObjCExport_GetAssociatedObject(ObjHeader* obj) { extern "C" OBJ_GETTER(Kotlin_ObjCExport_AllocInstanceWithAssociatedObject, const TypeInfo* typeInfo, id associatedObject) RUNTIME_NOTHROW; -extern "C" OBJ_GETTER(Kotlin_ObjCExport_AllocInstanceWithAssociatedObject, +RUNTIME_NOTHROW extern "C" OBJ_GETTER(Kotlin_ObjCExport_AllocInstanceWithAssociatedObject, const TypeInfo* typeInfo, id associatedObject) { RETURN_RESULT_OF(AllocInstanceWithAssociatedObject, typeInfo, associatedObject); } diff --git a/kotlin-native/runtime/src/main/cpp/Porting.cpp b/kotlin-native/runtime/src/main/cpp/Porting.cpp index b2be18cc11c..710f76fb0d6 100644 --- a/kotlin-native/runtime/src/main/cpp/Porting.cpp +++ b/kotlin-native/runtime/src/main/cpp/Porting.cpp @@ -59,7 +59,7 @@ void consoleInit() { #endif } -void consoleWriteUtf8(const void* utf8, uint32_t sizeBytes) { +void consoleWriteUtf8(const char* utf8, uint32_t sizeBytes) { #ifdef KONAN_ANDROID // TODO: use sizeBytes! __android_log_print(ANDROID_LOG_INFO, "Konan_main", "%s", utf8); @@ -68,7 +68,7 @@ void consoleWriteUtf8(const void* utf8, uint32_t sizeBytes) { #endif } -void consoleErrorUtf8(const void* utf8, uint32_t sizeBytes) { +void consoleErrorUtf8(const char* utf8, uint32_t sizeBytes) { #ifdef KONAN_ANDROID // TODO: use sizeBytes! __android_log_print(ANDROID_LOG_ERROR, "Konan_main", "%s", utf8); diff --git a/kotlin-native/runtime/src/main/cpp/Porting.h b/kotlin-native/runtime/src/main/cpp/Porting.h index 68a2eff78fd..7fda6ad949c 100644 --- a/kotlin-native/runtime/src/main/cpp/Porting.h +++ b/kotlin-native/runtime/src/main/cpp/Porting.h @@ -29,8 +29,8 @@ namespace konan { void consoleInit(); void consolePrintf(const char* format, ...) __attribute__((format(printf, 1, 2))); void consoleErrorf(const char* format, ...) __attribute__((format(printf, 1, 2))); -void consoleWriteUtf8(const void* utf8, uint32_t sizeBytes); -void consoleErrorUtf8(const void* utf8, uint32_t sizeBytes); +void consoleWriteUtf8(const char* utf8, uint32_t sizeBytes); +void consoleErrorUtf8(const char* utf8, uint32_t sizeBytes); // Negative return value denotes that read wasn't successful. int32_t consoleReadUtf8(void* utf8, uint32_t maxSizeBytes); void consoleFlush(); diff --git a/kotlin-native/runtime/src/main/cpp/snprintf/snprintf.cpp b/kotlin-native/runtime/src/main/cpp/snprintf/snprintf.cpp index 59f309d21a0..29585359abf 100644 --- a/kotlin-native/runtime/src/main/cpp/snprintf/snprintf.cpp +++ b/kotlin-native/runtime/src/main/cpp/snprintf/snprintf.cpp @@ -1450,7 +1450,7 @@ cast(LDOUBLE value) * comparison (cf. C99: 6.3.1.4, 2). It might then equal the LDOUBLE * value although converting the latter to UINTMAX_T would overflow. */ - if (value >= UINTMAX_MAX) + if (value >= static_cast(UINTMAX_MAX)) return UINTMAX_MAX; result = value; diff --git a/kotlin-native/runtime/src/relaxed/cpp/MemoryImpl.cpp b/kotlin-native/runtime/src/relaxed/cpp/MemoryImpl.cpp index e12cd3c5eb7..73e1678134a 100644 --- a/kotlin-native/runtime/src/relaxed/cpp/MemoryImpl.cpp +++ b/kotlin-native/runtime/src/relaxed/cpp/MemoryImpl.cpp @@ -11,7 +11,7 @@ extern "C" { const MemoryModel CurrentMemoryModel = MemoryModel::kRelaxed; -OBJ_GETTER(AllocInstance, const TypeInfo* typeInfo) { +RUNTIME_NOTHROW OBJ_GETTER(AllocInstance, const TypeInfo* typeInfo) { RETURN_RESULT_OF(AllocInstanceRelaxed, typeInfo); } diff --git a/kotlin-native/runtime/src/strict/cpp/MemoryImpl.cpp b/kotlin-native/runtime/src/strict/cpp/MemoryImpl.cpp index 113576c81e1..7957e68cd8a 100644 --- a/kotlin-native/runtime/src/strict/cpp/MemoryImpl.cpp +++ b/kotlin-native/runtime/src/strict/cpp/MemoryImpl.cpp @@ -11,7 +11,7 @@ extern "C" { const MemoryModel CurrentMemoryModel = MemoryModel::kStrict; -OBJ_GETTER(AllocInstance, const TypeInfo* typeInfo) { +RUNTIME_NOTHROW OBJ_GETTER(AllocInstance, const TypeInfo* typeInfo) { RETURN_RESULT_OF(AllocInstanceStrict, typeInfo); }