start work to getting built with clang

This commit is contained in:
Jeffrey Crowell 2022-06-20 01:28:23 -04:00
parent cc56a5a94d
commit 68795208a1
11 changed files with 35 additions and 16 deletions

View File

@ -18,7 +18,11 @@ WARN := -Wall -Wextra -Werror \
-Wno-parentheses \
-Wno-narrowing \
-Wno-missing-field-initializers \
-Wno-error=multichar
-Wno-error=multichar \
-Wno-unused-command-line-argument \
-Wno-delete-non-abstract-non-virtual-dtor \
-Wno-unused-private-field \
-Wno-deprecated-copy-with-user-provided-copy
CWARN :=
CXXWARN := -Wno-deprecated-enum-enum-conversion

View File

@ -28,7 +28,7 @@ static bool ClearCommand(const std::vector<std::string>&) {
std::string toLowerCase(std::string in) {
std::string cpy(in);
std::ranges::transform(cpy, cpy.begin(), [](unsigned char c) { return std::tolower(c); });
std::transform(cpy.begin(), cpy.end(), cpy.begin(), ::tolower);
return cpy;
}
@ -204,11 +204,11 @@ void Console::Draw() {
for (int i = 0; i < static_cast<int>(channel.size()); i++) {
ConsoleLine line = channel[i];
if(!this->filter.empty() && line.text.find(this->filter) == std::string::npos) continue;
if(this->level_filter != NULLSTR && line.priority != (std::ranges::find(priority_filters, this->level_filter) - priority_filters.begin()) - 1) continue;
if(this->level_filter != NULLSTR && line.priority != (std::find(priority_filters.begin(), priority_filters.end(), this->level_filter) - priority_filters.begin()) - 1) continue;
std::string id = line.text + "##" + std::to_string(i);
ImGui::TableNextRow();
ImGui::TableSetColumnIndex(0);
const bool is_selected = (this->selectedId == i) || std::ranges::find(this->selectedEntries, i) != this->selectedEntries.end();
const bool is_selected = (this->selectedId == i) || std::find(this->selectedEntries.begin(), this->selectedEntries.end(), i) != this->selectedEntries.end();
ImGui::PushStyleColor(ImGuiCol_Text, this->priority_colors[line.priority]);
if (ImGui::Selectable(id.c_str(), is_selected)) {
if (ImGui::IsKeyDown(ImGui::GetKeyIndex(ImGuiKey_LeftCtrl)) && !is_selected)

View File

@ -1377,7 +1377,7 @@ namespace SohImGui {
if (ImGui::BeginMenu(category.first.c_str())) {
for (const std::string& name : category.second) {
std::string varName(name);
varName.erase(std::ranges::remove_if(varName, isspace).begin(), varName.end());
varName.erase(std::remove_if(varName.begin(), varName.end(), [](unsigned char x) { return std::isspace(x); }), varName.end());
std::string toggleName = "g" + varName + "Enabled";
EnhancementCheckbox(name.c_str(), toggleName.c_str());

View File

@ -566,7 +566,7 @@ static bool gfx_texture_cache_lookup(int i, int tile) {
static void gfx_texture_cache_delete(const uint8_t* orig_addr)
{
while (gfx_texture_cache.map.bucket_count() > 0) {
TextureCacheKey key = { orig_addr, 0, 0, 0 }; // bucket index only depends on the address
TextureCacheKey key = { orig_addr, {0}, 0, 0 }; // bucket index only depends on the address
size_t bucket = gfx_texture_cache.map.bucket(key);
bool again = false;
for (auto it = gfx_texture_cache.map.begin(bucket); it != gfx_texture_cache.map.end(bucket); ++it) {

View File

@ -4,7 +4,9 @@
#include "mixer.h"
#ifndef __clang__
#pragma GCC optimize ("unroll-loops")
#endif
#define ROUND_UP_64(v) (((v) + 63) & ~63)
#define ROUND_UP_32(v) (((v) + 31) & ~31)
@ -449,10 +451,14 @@ void aFilterImpl(uint8_t flags, uint16_t count_or_buf, int16_t *state_or_filter)
int16_t *buf = BUF_S16(count_or_buf);
if (flags == A_INIT) {
#ifndef __clang__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wmemset-elt-size"
#endif
memset(tmp, 0, 8 * sizeof(int16_t));
#ifndef __clang__
#pragma GCC diagnostic pop
#endif
memset(tmp2, 0, 8 * sizeof(int16_t));
} else {
memcpy(tmp, state_or_filter, 8 * sizeof(int16_t));

View File

@ -18,8 +18,11 @@ LTO ?= 0
WARN := \
-Wno-return-type \
-Wno-unused-command-line-argument \
-Wno-implicit-function-declaration \
-Wno-c++11-narrowing \
-funsigned-char \
-fno-stack-protector -fno-common -fno-zero-initialized-in-bss -fno-strict-aliasing -fno-inline-functions -fno-inline-small-functions -fno-toplevel-reorder -ffreestanding -fwrapv \
-fno-stack-protector -fno-common -fno-zero-initialized-in-bss -fno-strict-aliasing -fno-inline-functions -fno-inline-small-functions -ffreestanding -fwrapv \
CXXFLAGS := $(WARN) -std=c++20 -D_GNU_SOURCE -fpermissive -no-pie -nostdlib
CFLAGS := $(WARN) -std=c99 -D_GNU_SOURCE -no-pie -nostdlib

View File

@ -5,6 +5,7 @@
#include <ultra64.h>
#include <functions.h>
#include <variables.h>
#include <string.h>
#include <stdarg.h>
#include <z64.h>
#include <ultra64/gbi.h>

View File

@ -509,7 +509,7 @@ void DebugConsole_LoadCVars()
if (cfg.size() < 2) continue;
if (cfg[1].find("\"") != std::string::npos) {
std::string value(cfg[1]);
value.erase(std::ranges::remove(value, '\"').begin(), value.end());
value.erase(std::remove(value.begin(), value.end(), '\"'), value.end());
CVar_SetString(cfg[0].c_str(), ImStrdup(value.c_str()));
}
if (is_number<float>(cfg[1])) {

View File

@ -1327,17 +1327,17 @@ extern "C" int16_t OTRGetRectDimensionFromRightEdge(float v) {
}
extern "C" void bswapSoundFontSound(SoundFontSound* swappable) {
swappable->sample = (SoundFontSample*)BOMSWAP32((u32)swappable->sample);
swappable->tuningAsU32 = BOMSWAP32((u32)swappable->tuningAsU32);
swappable->sample = (SoundFontSample*)BOMSWAP32((u32)(uintptr_t(swappable->sample)));
swappable->tuningAsU32 = BOMSWAP32((u32)(swappable->tuningAsU32 & 0xFFFFFFFF));
}
extern "C" void bswapDrum(Drum* swappable) {
bswapSoundFontSound(&swappable->sound);
swappable->envelope = (AdsrEnvelope*)BOMSWAP32((u32)swappable->envelope);
swappable->envelope = (AdsrEnvelope*)BOMSWAP32((u32)uintptr_t(swappable->envelope));
}
extern "C" void bswapInstrument(Instrument* swappable) {
swappable->envelope = (AdsrEnvelope*)BOMSWAP32((u32)swappable->envelope);
swappable->envelope = (AdsrEnvelope*)BOMSWAP32((u32)uintptr_t(swappable->envelope));
bswapSoundFontSound(&swappable->lowNotesSound);
bswapSoundFontSound(&swappable->normalNotesSound);
bswapSoundFontSound(&swappable->highNotesSound);
@ -1352,9 +1352,9 @@ extern "C" void bswapSoundFontSample(SoundFontSample* swappable) {
swappable->unk_bit25 = (origBitfield >> 21) & 0x01;
swappable->size = (origBitfield) & 0x00FFFFFF;
swappable->sampleAddr = (u8*)BOMSWAP32((u32)swappable->sampleAddr);
swappable->loop = (AdpcmLoop*)BOMSWAP32((u32)swappable->loop);
swappable->book = (AdpcmBook*)BOMSWAP32((u32)swappable->book);
swappable->sampleAddr = (u8*)BOMSWAP32((u32)uintptr_t(swappable->sampleAddr));
swappable->loop = (AdpcmLoop*)BOMSWAP32((u32)uintptr_t(swappable->loop));
swappable->book = (AdpcmBook*)BOMSWAP32((u32)uintptr_t(swappable->book));
}
extern "C" void bswapAdpcmLoop(AdpcmLoop* swappable) {

View File

@ -1,3 +1,4 @@
#include <math.h>
#include "z64.h"
void guMtxF2L(float mf[4][4], Mtx* m) {
@ -84,4 +85,4 @@ void guNormalize(f32* x, f32* y, f32* z) {
*x = *x * tmp;
*y = *y * tmp;
*z = *z * tmp;
}
}

View File

@ -1,3 +1,4 @@
#include <string.h>
#include "global.h"
#include "vt.h"
@ -9,6 +10,9 @@ ViMode sViMode;
FaultClient sGameFaultClient;
u16 sLastButtonPressed;
// Forward declared, because this in a C++ header.
int gfx_create_framebuffer(uint32_t width, uint32_t height);
void GameState_FaultPrint(void) {
static char sBtnChars[] = "ABZSuldr*+LRudlr";
s32 i;