Clang Warning Fixes (#1131)

Builds prevented on clang-18

[ROCm/rocprofiler-sdk commit: 28a6918b33]
Este commit está contenido en:
Benjamin Welton
2024-10-15 22:20:38 -07:00
cometido por GitHub
padre b610c50913
commit 9ea02403df
Se han modificado 2 ficheros con 30 adiciones y 27 borrados
@@ -105,15 +105,17 @@ public:
std::map<uint64_t, std::string> line_addrs;
while(!dwarf_nextcu(
dbg.get(), cu_offset, &next_offset, &header_size, nullptr, nullptr, nullptr))
while(
dwarf_nextcu(
dbg.get(), cu_offset, &next_offset, &header_size, nullptr, nullptr, nullptr) ==
0)
{
Dwarf_Die die;
if(!dwarf_offdie(dbg.get(), cu_offset + header_size, &die)) continue;
Dwarf_Lines* lines;
size_t line_count;
if(dwarf_getsrclines(&die, &lines, &line_count)) continue;
if(dwarf_getsrclines(&die, &lines, &line_count) != 0) continue;
for(size_t i = 0; i < line_count; ++i)
{
@@ -121,8 +123,8 @@ public:
int line_number;
Dwarf_Line* line = dwarf_onesrcline(lines, i);
if(line && !dwarf_lineaddr(line, &addr) && !dwarf_lineno(line, &line_number) &&
line_number)
if(line && dwarf_lineaddr(line, &addr) == 0 &&
dwarf_lineno(line, &line_number) == 0 && line_number != 0)
{
std::string src = dwarf_linesrc(line, nullptr, nullptr);
auto dwarf_line = src + ':' + std::to_string(line_number);
@@ -162,9 +164,9 @@ public:
} catch(...)
{}
}
~CodeobjDecoderComponent() {}
~CodeobjDecoderComponent() = default;
std::optional<uint64_t> va2fo(uint64_t vaddr)
std::optional<uint64_t> va2fo(uint64_t vaddr) const
{
if(disassembly) return disassembly->va2fo(vaddr);
return {};
@@ -342,21 +344,21 @@ public:
CodeobjAddressTranslate() = default;
~CodeobjAddressTranslate() override = default;
virtual void addDecoder(const char* filepath,
marker_id_t id,
uint64_t load_addr,
uint64_t memsize) override
void addDecoder(const char* filepath,
marker_id_t id,
uint64_t load_addr,
uint64_t memsize) override
{
this->Super::addDecoder(filepath, id, load_addr, memsize);
auto ptr = decoders.at(id);
table.insert({ptr->begin(), ptr->size(), id});
}
virtual void addDecoder(const void* data,
size_t memory_size,
marker_id_t id,
uint64_t load_addr,
uint64_t memsize) override
void addDecoder(const void* data,
size_t memory_size,
marker_id_t id,
uint64_t load_addr,
uint64_t memsize) override
{
this->Super::addDecoder(data, memory_size, id, load_addr, memsize);
auto ptr = decoders.at(id);
@@ -396,7 +398,7 @@ public:
{
std::map<uint64_t, SymbolInfo> symbols;
for(auto& [_, dec] : decoders)
for(const auto& [_, dec] : decoders)
{
auto& smap = dec->getSymbolMap();
for(auto& [vaddr, sym] : smap)
@@ -47,7 +47,7 @@
const char* reason = ""; \
amd_comgr_status_string(status, &reason); \
std::cerr << __FILE__ << ':' << __LINE__ << " code: " << status << " failed: " << reason \
<< std::endl; \
<< "\n"; \
throw std::exception(); \
}
@@ -57,14 +57,14 @@
const char* reason = ""; \
amd_comgr_status_string(status, &reason); \
std::cerr << __FILE__ << ':' << __LINE__ << " code: " << status << " failed: " << reason \
<< std::endl; \
<< "\n"; \
return AMD_COMGR_STATUS_ERROR; \
}
#define CHECK_VA2FO(x, msg) \
if(!(x)) \
{ \
std::cerr << __FILE__ << ' ' << __LINE__ << ' ' << msg << std::endl; \
std::cerr << __FILE__ << ' ' << __LINE__ << ' ' << msg << "\n"; \
return std::nullopt; \
}
@@ -79,8 +79,8 @@ namespace disassembly
class CodeObjectBinary
{
public:
CodeObjectBinary(const std::string& _uri)
: m_uri(_uri)
CodeObjectBinary(std::string _uri)
: m_uri(std::move(_uri))
{
const std::string protocol_delim{"://"};
@@ -108,9 +108,9 @@ public:
decoded_path.reserve(path.length());
for(size_t i = 0; i < path.length(); ++i)
{
if(path[i] == '%' && std::isxdigit(path[i + 1]) && std::isxdigit(path[i + 2]))
if(path[i] == '%' && std::isxdigit(path[i + 1]) != 0 && std::isxdigit(path[i + 2]) != 0)
{
decoded_path += std::stoi(path.substr(i + 1, 2), 0, 16);
decoded_path += std::stoi(path.substr(i + 1, 2), nullptr, 16);
i += 2;
}
else
@@ -153,7 +153,7 @@ public:
if(auto size_it = params.find("size"); size_it != params.end())
{
if(!(size = std::stoul(size_it->second, nullptr, 0))) return;
if((size = std::stoul(size_it->second, nullptr, 0)) == 0) return;
}
if(protocol == "memory") throw std::runtime_error(protocol + " protocol not supported!");
@@ -161,7 +161,7 @@ public:
std::ifstream file(decoded_path, std::ios::in | std::ios::binary);
if(!file || !file.is_open()) throw std::runtime_error("could not open " + decoded_path);
if(!size)
if(size == 0)
{
file.ignore(std::numeric_limits<std::streamsize>::max());
size_t bytes = file.gcount();
@@ -174,7 +174,7 @@ public:
file.seekg(offset, std::ios_base::beg);
buffer.resize(size);
file.read(&buffer[0], size);
file.read(buffer.data(), size);
}
std::string m_uri;
@@ -269,6 +269,7 @@ public:
int64_t copysize = reinterpret_cast<int64_t>(instance.buffer.data()) +
instance.buffer.size() - static_cast<int64_t>(from);
copysize = std::min<int64_t>(size, copysize);
// NOLINTNEXTLINE(performance-no-int-to-ptr)
std::memcpy(to, (char*) from, copysize);
return copysize;
}