llvm.org GIT mirror llvm / 1d94ec7
Demangle: only demangle mangled symbols Only attempt to demangle symbols which have the itanium C++ prefix of `_Z`. This ensures that we do not treat any symbol name as a managled named. We would previously treat a C function `f` as a mangled name and decode that to `float` incorrectly. While it is easy to add tests for this, Mehdi recommended against introducing tests for the demangler as libc++abi should cover the testing. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@286795 91177308-0d34-0410-b5e6-96231b3b80d8 Saleem Abdulrasool 2 years ago
1 changed file(s) with 10 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
42514251 *status = invalid_args;
42524252 return nullptr;
42534253 }
4254
4255 size_t len = std::strlen(mangled_name);
4256 if (len < 2 || strncmp(mangled_name, "_Z", 2)) {
4257 if (len < 4 || strncmp(mangled_name, "___Z", 4)) {
4258 if (status)
4259 *status = invalid_mangled_name;
4260 return nullptr;
4261 }
4262 }
4263
42544264 size_t internal_size = buf != nullptr ? *n : 0;
42554265 Db db;
42564266 db.cv = 0;
42624272 db.fix_forward_references = false;
42634273 db.try_to_parse_template_args = true;
42644274 int internal_status = success;
4265 size_t len = std::strlen(mangled_name);
42664275 demangle(mangled_name, mangled_name + len, db, internal_status);
42674276 if (internal_status == success && db.fix_forward_references &&
42684277 !db.template_param.empty() && !db.template_param.front().empty()) {