Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/ccc/elf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace ccc {

extern const std::map<std::string, KnownElfSectionClass> KNOWN_ELF_SECTIONS = {
const std::map<std::string, KnownElfSectionClass> KNOWN_ELF_SECTIONS = {
{".bss", KnownElfSectionClass::DATA},
{".data", KnownElfSectionClass::DATA},
{".lit", KnownElfSectionClass::DATA},
Expand Down Expand Up @@ -35,7 +35,8 @@ Result<ElfFile> ElfFile::parse(std::vector<u8> image)
CCC_CHECK(header, "ELF file header out of range.");
elf.file_header = *header;

const ElfSectionHeader* shstr_section_header = get_unaligned<ElfSectionHeader>(elf.image, header->shoff + header->shstrndx * sizeof(ElfSectionHeader));
const ElfSectionHeader* shstr_section_header = get_unaligned<ElfSectionHeader>(
elf.image, header->shoff + header->shstrndx * sizeof(ElfSectionHeader));
CCC_CHECK(shstr_section_header, "ELF section name header out of range.");

for (u32 i = 0; i < header->shnum; i++) {
Expand All @@ -44,7 +45,7 @@ Result<ElfFile> ElfFile::parse(std::vector<u8> image)
CCC_CHECK(section_header, "ELF section header out of range.");

std::optional<std::string_view> name = get_string(elf.image, shstr_section_header->offset + section_header->name);
CCC_CHECK(name, "ELF section name out of range.");
CCC_CHECK(name.has_value(), "ELF section name out of range.");

ElfSection& section = elf.sections.emplace_back();
section.name = *name;
Expand Down
2 changes: 1 addition & 1 deletion src/ccc/symbol_database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ size_t SymbolList<SymbolType>::binary_search(SymbolHandle<SymbolType> handle) co
template <typename SymbolType>
void SymbolList<SymbolType>::link_address_map(SymbolType& symbol)
{
if constexpr ((SymbolType::FLAGS & WITH_ADDRESS_MAP)) {
if constexpr (SymbolType::FLAGS & WITH_ADDRESS_MAP) {
if (symbol.address().valid()) {
m_address_to_handle.emplace(symbol.address().value, symbol.handle());
}
Expand Down
2 changes: 1 addition & 1 deletion src/ccc/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace ccc {

static CustomErrorCallback custom_error_callback = nullptr;

Error format_error(const char* source_file, int source_line, const char* format, ...)
Error format_error(const char* source_file, s32 source_line, const char* format, ...)
{
va_list args;
va_start(args, format);
Expand Down
10 changes: 5 additions & 5 deletions src/ccc/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ enum ErrorLevel {

typedef void (*CustomErrorCallback)(const Error& error, ErrorLevel level);

Error format_error(const char* source_file, int source_line, const char* format, ...);
Error format_error(const char* source_file, s32 source_line, const char* format, ...);
void report_error(const Error& error);
void report_warning(const Error& warning);
void set_custom_error_callback(CustomErrorCallback callback);
Expand Down Expand Up @@ -155,9 +155,9 @@ class [[nodiscard]] CCC_WARN_UNUSED Result {
};

template <>
class [[nodiscard]] CCC_WARN_UNUSED Result<void> : public Result<int> {
class [[nodiscard]] CCC_WARN_UNUSED Result<void> : public Result<s32> {
public:
Result() : Result<int>(0) {}
Result() : Result<s32>(0) {}

// Used to propagate errors up the call stack.
template <typename OtherValue>
Expand All @@ -168,7 +168,7 @@ class [[nodiscard]] CCC_WARN_UNUSED Result<void> : public Result<int> {
}
};

#define CCC_FAILURE(...) ccc::Result<int>::failure(ccc::format_error(__FILE__, __LINE__, __VA_ARGS__))
#define CCC_FAILURE(...) ccc::Result<s32>::failure(ccc::format_error(__FILE__, __LINE__, __VA_ARGS__))

#define CCC_CHECK(condition, ...) \
if (!(condition)) { \
Expand Down Expand Up @@ -197,7 +197,7 @@ class [[nodiscard]] CCC_WARN_UNUSED Result<void> : public Result<int> {
}

template <typename... Args>
void warn_impl(const char* source_file, int source_line, const char* format, Args... args)
void warn_impl(const char* source_file, s32 source_line, const char* format, Args... args)
{
Error warning = format_error(source_file, source_line, format, args...);
report_warning(warning);
Expand Down
Loading