Fix JITted variables on Windows (#3590)

* Fix for JITted variables on Windows

Fixes global, static, and "const int" variables access from experimental PyROOT on Windows

* formatting

* Use mangledName.compare() instead of mangledName.find() and add comments

* Small modification from Wim
This commit is contained in:
Bertrand Bellenot 2019-10-03 11:33:14 +02:00 committed by SFT
parent 13485246a7
commit e037a02a9a

View File

@ -1654,6 +1654,21 @@ namespace cling {
// Return a symbol's address, and whether it was jitted.
std::string mangledName;
utils::Analyze::maybeMangleDeclName(GD, mangledName);
#if defined(LLVM_ON_WIN32)
// For some unknown reason, Clang 5.0 adds a special symbol ('\01') in front
// of the mangled names on Windows, making them impossible to find
// TODO: remove this piece of code and try again when updating Clang
std::string mncp = mangledName;
// use corrected symbol for "external" lookup
if (mncp.size() > 2 && mncp[1] == '?' &&
mncp.compare(1, 14, std::string("?__cling_Un1Qu"))) {
mncp.erase(0, 1);
}
void *addr = getAddressOfGlobal(mncp, fromJIT);
if (addr)
return addr;
// if failed, proceed with original symbol for lookups in JIT tables
#endif
return getAddressOfGlobal(mangledName, fromJIT);
}