Make .x file name mangling partial again; explain why.

This commit is contained in:
Axel Naumann 2016-11-29 08:22:06 +01:00 committed by sftnight
parent 7a682ff1d7
commit ef8d80dc57

View File

@ -88,39 +88,20 @@ namespace cling {
/// Replace non-identifier chars by '_' /// Replace non-identifier chars by '_'
std::string normalizeDotXFuncName(const std::string& FuncName) { std::string normalizeDotXFuncName(const std::string& FuncName) {
std::string ret = FuncName; std::string ret = FuncName;
// Prepend '_' if name starts with a digit.
if (ret[0] >= '0' && ret[0] <= '9') if (ret[0] >= '0' && ret[0] <= '9')
ret.insert(ret.begin(), '_'); ret.insert(ret.begin(), '_');
for (char& c: ret) { for (char& c: ret) {
switch(c) { // Instead of "escaping" all non-C++-id chars, only escape those that
case '+': // Intentional fall though. // are fairly certainly file names, to keep helpful error messages for
case '-': // Intentional fall though. // broken quoting or parsing. Example:
case '*': // Intentional fall though. // "Cannot find '_func_1___'" is much less helpful than
case '/': // Intentional fall though. // "Cannot find '/func(1)*&'"
case '&': // Intentional fall though. // I.e. find a compromise between helpful diagnostics and common file
case '%': // Intentional fall though. // name (stem) ingredients.
case '|': // Intentional fall though. if (c == '+' || c == '-' || c == '=' || c == '.' || c == ' '
case '^': // Intentional fall though. || c == '@')
case '>': // Intentional fall though. c = '_';
case '<': // Intentional fall though.
case '=': // Intentional fall though.
case '~': // Intentional fall though.
case '.': // Intentional fall though.
case '(': // Intentional fall though.
case ')': // Intentional fall though.
case '[': // Intentional fall though.
case ']': // Intentional fall though.
case '!': // Intentional fall though.
case ',': // Intentional fall though.
case '$': // Intentional fall though.
case ' ': // Intentional fall though.
case ':': // Intentional fall though.
case '"': // Intentional fall though.
case '@': // Intentional fall though.
case '\'': // Intentional fall though.
case '\\': c = '_'; break;
default: break;
/* nothing to do */
}
} }
return ret; return ret;
} }