mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-27 14:24:40 +00:00
TLI: Factor out sanitizeFunctionName. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@231034 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -714,20 +714,28 @@ TargetLibraryInfoImpl &TargetLibraryInfoImpl::operator=(TargetLibraryInfoImpl &&
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TargetLibraryInfoImpl::getLibFunc(StringRef funcName,
|
static StringRef sanitizeFunctionName(StringRef funcName) {
|
||||||
LibFunc::Func &F) const {
|
|
||||||
const char **Start = &StandardNames[0];
|
|
||||||
const char **End = &StandardNames[LibFunc::NumLibFuncs];
|
|
||||||
|
|
||||||
// Filter out empty names and names containing null bytes, those can't be in
|
// Filter out empty names and names containing null bytes, those can't be in
|
||||||
// our table.
|
// our table.
|
||||||
if (funcName.empty() || funcName.find('\0') != StringRef::npos)
|
if (funcName.empty() || funcName.find('\0') != StringRef::npos)
|
||||||
return false;
|
return StringRef();
|
||||||
|
|
||||||
// Check for \01 prefix that is used to mangle __asm declarations and
|
// Check for \01 prefix that is used to mangle __asm declarations and
|
||||||
// strip it if present.
|
// strip it if present.
|
||||||
if (funcName.front() == '\01')
|
if (funcName.front() == '\01')
|
||||||
funcName = funcName.substr(1);
|
funcName = funcName.substr(1);
|
||||||
|
return funcName;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TargetLibraryInfoImpl::getLibFunc(StringRef funcName,
|
||||||
|
LibFunc::Func &F) const {
|
||||||
|
const char **Start = &StandardNames[0];
|
||||||
|
const char **End = &StandardNames[LibFunc::NumLibFuncs];
|
||||||
|
|
||||||
|
funcName = sanitizeFunctionName(funcName);
|
||||||
|
if (funcName.empty())
|
||||||
|
return false;
|
||||||
|
|
||||||
const char **I = std::lower_bound(
|
const char **I = std::lower_bound(
|
||||||
Start, End, funcName, [](const char *LHS, StringRef RHS) {
|
Start, End, funcName, [](const char *LHS, StringRef RHS) {
|
||||||
return std::strncmp(LHS, RHS.data(), RHS.size()) < 0;
|
return std::strncmp(LHS, RHS.data(), RHS.size()) < 0;
|
||||||
|
Reference in New Issue
Block a user