Cleanup Stubs.cpp (#4593)
This commit is contained in:
committed by
Stanislav Erokhin
parent
f160d8ec36
commit
92f8eff958
@@ -27,6 +27,19 @@
|
||||
|
||||
RUNTIME_NORETURN void RuntimeAssertFailed(const char* location, const char* message);
|
||||
|
||||
namespace internal {
|
||||
|
||||
inline RUNTIME_NORETURN void TODOImpl(const char* location) {
|
||||
RuntimeAssertFailed(location, "Unimplemented");
|
||||
}
|
||||
|
||||
// TODO: Support format string when `RuntimeAssertFailed` supports it.
|
||||
inline RUNTIME_NORETURN void TODOImpl(const char* location, const char* message) {
|
||||
RuntimeAssertFailed(location, message);
|
||||
}
|
||||
|
||||
} // namespace internal
|
||||
|
||||
// During codegeneration we set this constant to 1 or 0 to allow bitcode optimizer
|
||||
// to get rid of code behind condition.
|
||||
extern "C" const int KonanNeedDebugInfo;
|
||||
@@ -48,4 +61,9 @@ if (KonanNeedDebugInfo && (!(condition))) { \
|
||||
RuntimeAssertFailed(nullptr, message); \
|
||||
}
|
||||
|
||||
#define TODO(...) \
|
||||
do { \
|
||||
::internal::TODOImpl(__FILE__ ":" TOSTRING(__LINE__), ##__VA_ARGS__); \
|
||||
} while (false)
|
||||
|
||||
#endif // RUNTIME_ASSERT_H
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* Copyright 2010-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "KAssert.h"
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
TEST(TODODeathTest, EmptyTODO) {
|
||||
EXPECT_DEATH({
|
||||
TODO();
|
||||
}, "KAssertTest.cpp:12: runtime assert: Unimplemented");
|
||||
}
|
||||
|
||||
TEST(TODODeathTest, TODOWithMessage) {
|
||||
EXPECT_DEATH({
|
||||
TODO("Nope");
|
||||
}, "KAssertTest.cpp:18: runtime assert: Nope");
|
||||
}
|
||||
@@ -173,8 +173,15 @@ void InitAndRegisterGlobal(ObjHeader** location, const ObjHeader* initialValue)
|
||||
// in intermediate frames when throwing
|
||||
//
|
||||
|
||||
// NOTE: Must match `MemoryModel` in `Platform.kt`
|
||||
enum class MemoryModel {
|
||||
kStrict = 0,
|
||||
kRelaxed = 1,
|
||||
kExperimental = 2,
|
||||
};
|
||||
|
||||
// Controls the current memory model, is compile-time constant.
|
||||
extern const bool IsStrictMemoryModel;
|
||||
extern const MemoryModel CurrentMemoryModel;
|
||||
|
||||
// Sets stack location.
|
||||
void SetStackRef(ObjHeader** location, const ObjHeader* object) RUNTIME_NOTHROW;
|
||||
|
||||
@@ -314,7 +314,7 @@ KInt Konan_Platform_getCpuArchitecture() {
|
||||
}
|
||||
|
||||
KInt Konan_Platform_getMemoryModel() {
|
||||
return IsStrictMemoryModel ? 0 : 1;
|
||||
return static_cast<KInt>(CurrentMemoryModel);
|
||||
}
|
||||
|
||||
KBoolean Konan_Platform_isDebugBinary() {
|
||||
|
||||
Reference in New Issue
Block a user