[orc-rt] Hold const void* rather than void* in ControllerInterface. (#186954)

We only care about addresses in ControllerInterface, not the underlying
memory.
This commit is contained in:
Lang Hames 2026-03-17 17:12:43 +11:00 committed by GitHub
parent 33cfc6ba61
commit f1b16eaedd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 13 additions and 1 deletions

View File

@ -26,7 +26,7 @@ namespace orc_rt {
/// duplicates with an error.
class ControllerInterface {
public:
using SymbolTable = std::unordered_map<std::string, void *>;
using SymbolTable = std::unordered_map<std::string, const void *>;
using iterator = SymbolTable::const_iterator;
bool empty() const noexcept { return Symbols.empty(); }

View File

@ -41,6 +41,18 @@ TEST(ControllerInterfaceTest, AddSymbolsUnique) {
EXPECT_EQ(CI.at("orc_rt_B"), &Y);
}
TEST(ControllerInterfaceTest, AddConstPointers) {
ControllerInterface CI;
const int X = 42;
const int Y = 7;
std::pair<const char *, const void *> Syms[] = {{"orc_rt_A", &X},
{"orc_rt_B", &Y}};
cantFail(CI.addSymbolsUnique(Syms));
EXPECT_EQ(CI.at("orc_rt_A"), &X);
EXPECT_EQ(CI.at("orc_rt_B"), &Y);
}
TEST(ControllerInterfaceTest, AddSymbolsUniqueMultipleCalls) {
ControllerInterface CI;
int X = 0, Y = 0;