mirror of
https://github.com/RPCSX/llvm.git
synced 2025-01-26 14:25:18 +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:
parent
0b08b96fdd
commit
a6f1fd6465
@ -714,20 +714,28 @@ TargetLibraryInfoImpl &TargetLibraryInfoImpl::operator=(TargetLibraryInfoImpl &&
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool TargetLibraryInfoImpl::getLibFunc(StringRef funcName,
|
||||
LibFunc::Func &F) const {
|
||||
const char **Start = &StandardNames[0];
|
||||
const char **End = &StandardNames[LibFunc::NumLibFuncs];
|
||||
|
||||
static StringRef sanitizeFunctionName(StringRef funcName) {
|
||||
// Filter out empty names and names containing null bytes, those can't be in
|
||||
// our table.
|
||||
if (funcName.empty() || funcName.find('\0') != StringRef::npos)
|
||||
return false;
|
||||
return StringRef();
|
||||
|
||||
// Check for \01 prefix that is used to mangle __asm declarations and
|
||||
// strip it if present.
|
||||
if (funcName.front() == '\01')
|
||||
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(
|
||||
Start, End, funcName, [](const char *LHS, StringRef RHS) {
|
||||
return std::strncmp(LHS, RHS.data(), RHS.size()) < 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user