Enable unused-function warning for runtime (#4628)

This commit is contained in:
Alexander Shabalin
2021-01-11 20:45:02 +03:00
committed by Nikolay Krasko
parent 8bb76c67e3
commit 32e3deace1
6 changed files with 12 additions and 35 deletions
@@ -71,7 +71,6 @@ open class CompileToBitcode @Inject constructor(
listOfNotNull("-std=c++14", "-Werror", "-O2",
"-Wall", "-Wextra",
"-Wno-unused-parameter", // False positives with polymorphic functions.
"-Wno-unused-function", // TODO: Enable this warning when we have C++ runtime tests.
"-fPIC".takeIf { !HostManager().targetByName(target).isMINGW })
}
return commonFlags + languageFlags + compilerArgs
@@ -151,4 +150,4 @@ open class CompileToBitcode @Inject constructor(
}
}
}
}
}
@@ -57,11 +57,6 @@ uint32_t Fetch32(const char *p) {
return uint32_in_expected_order(UNALIGNED_LOAD32(p));
}
uint32_t Rotate32(uint32_t val, int shift) {
// Avoid shifting by 32: doing so yields an undefined result.
return shift == 0 ? val : ((val >> shift) | (val << (32 - shift)));
}
// Bitwise right rotate. Normally this will compile to a single
// instruction, especially if the shift is a manifest constant.
uint64_t Rotate(uint64_t val, int shift) {
@@ -23,18 +23,6 @@
namespace {
constexpr uint32_t PrintableHexSize(uint32_t input_length) {
return input_length * 2;
}
void PrintableHex(const uint8_t* data, uint32_t data_length, char* hex) {
static const char* hex_digits = "0123456789ABCDEF";
for (uint32_t i = 0; i < data_length; ++i) {
*hex++ = hex_digits[(*data >> 4) & 0xf];
*hex++ = hex_digits[(*data++) & 0xf];
}
}
constexpr uint32_t PrintableBase64Size(uint32_t input_length) {
return ((input_length + 2) / 3 * 4) + 1;
}
@@ -798,7 +798,6 @@ namespace {
void freeContainer(ContainerHeader* header) NO_INLINE;
#if USE_GC
void garbageCollect(MemoryState* state, bool force) NO_INLINE;
void cyclicGarbageCollect() NO_INLINE;
void rememberNewContainer(ContainerHeader* container);
#endif // USE_GC
@@ -1017,10 +1016,6 @@ inline FrameOverlay* asFrameOverlay(ObjHeader** slot) {
return reinterpret_cast<FrameOverlay*>(slot);
}
inline bool isRefCounted(KConstRef object) {
return isFreeable(containerFor(object));
}
inline void lock(KInt* spinlock) {
while (compareAndSwap(spinlock, 0, 1) != 0) {}
}
@@ -1698,6 +1693,7 @@ void collectWhite(MemoryState* state, ContainerHeader* start) {
}
#endif
#if COLLECT_STATISTIC
inline bool needAtomicAccess(ContainerHeader* container) {
return container->shareable();
}
@@ -1707,6 +1703,7 @@ inline bool canBeCyclic(ContainerHeader* container) {
if (container->color() == CONTAINER_TAG_GC_GREEN) return false;
return true;
}
#endif
inline void addHeapRef(ContainerHeader* container) {
MEMORY_LOG("AddHeapRef %p: rc=%d\n", container, container->refCount())
@@ -1774,6 +1771,11 @@ inline void releaseHeapRef(const ObjHeader* header) {
releaseHeapRef<Strict, CanCollect>(const_cast<ContainerHeader*>(container));
}
// TODO: Consider removing this unused stuff.
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-function"
// We use first slot as place to store frame-local arena container.
// TODO: create ArenaContainer object on the stack, so that we don't
// do two allocations per frame (ArenaContainer + actual container).
@@ -1800,6 +1802,8 @@ inline size_t containerSize(const ContainerHeader* container) {
return result;
}
#pragma clang diagnostic pop
#if USE_GC
void incrementStack(MemoryState* state) {
FrameOverlay* frame = currentFrame;
@@ -107,11 +107,13 @@ _Unwind_Reason_Code unwindCallback(
THREAD_LOCAL_VARIABLE bool disallowSourceInfo = false;
#if !OMIT_BACKTRACE && !USE_GCC_UNWIND
SourceInfo getSourceInfo(KConstRef stackTrace, int index) {
return disallowSourceInfo
? SourceInfo { .fileName = nullptr, .lineNumber = -1, .column = -1 }
: Kotlin_getSourceInfo(*PrimitiveArrayAddressOfElementAt<KNativePtr>(stackTrace->array(), index));
}
#endif
} // namespace
@@ -124,7 +124,6 @@ extern "C" OBJ_GETTER(Kotlin_ObjCExport_AllocInstanceWithAssociatedObject,
}
static Class getOrCreateClass(const TypeInfo* typeInfo);
static void initializeClass(Class clazz);
extern "C" id objc_retainAutoreleaseReturnValue(id self);
@@ -768,16 +767,6 @@ static KStdVector<const TypeInfo*> getProtocolsAsInterfaces(Class clazz) {
return result;
}
static const TypeInfo* getMostSpecificKotlinClass(const TypeInfo* typeInfo) {
const TypeInfo* result = typeInfo;
while (getTypeAdapter(result) == nullptr) {
result = result->superType_;
RuntimeAssert(result != nullptr, "");
}
return result;
}
static int getVtableSize(const TypeInfo* typeInfo) {
for (const TypeInfo* current = typeInfo; current != nullptr; current = current->superType_) {
auto typeAdapter = getTypeAdapter(current);