diff options
author | Eugene Leviant <eleviant@accesssoftek.com> | 2018-02-14 10:32:47 +0000 |
---|---|---|
committer | Eugene Leviant <eleviant@accesssoftek.com> | 2018-02-14 10:32:47 +0000 |
commit | 6a77bdb1ebca2f9b5cc8b9e8b9b25a860453bc42 (patch) | |
tree | 1b3ab8abd120afc2b70085a5454531e497ceb787 /llvm/lib/Linker/IRMover.cpp | |
parent | 84e59046e1b564bd048ed0f7466c4d07f83a079e (diff) | |
download | bcm5719-llvm-6a77bdb1ebca2f9b5cc8b9e8b9b25a860453bc42.tar.gz bcm5719-llvm-6a77bdb1ebca2f9b5cc8b9e8b9b25a860453bc42.zip |
[IRMover] Move type name extraction to a separate function. NFC
llvm-svn: 325110
Diffstat (limited to 'llvm/lib/Linker/IRMover.cpp')
-rw-r--r-- | llvm/lib/Linker/IRMover.cpp | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/llvm/lib/Linker/IRMover.cpp b/llvm/lib/Linker/IRMover.cpp index 6863a895cb1..ec15bbfc658 100644 --- a/llvm/lib/Linker/IRMover.cpp +++ b/llvm/lib/Linker/IRMover.cpp @@ -682,6 +682,14 @@ GlobalValue *IRLinker::copyGlobalValueProto(const GlobalValue *SGV, return NewGV; } +static StringRef getTypeNamePrefix(StringRef Name) { + size_t DotPos = Name.rfind('.'); + return (DotPos == 0 || DotPos == StringRef::npos || Name.back() == '.' || + !isdigit(static_cast<unsigned char>(Name[DotPos + 1]))) + ? Name + : Name.substr(0, DotPos); +} + /// Loop over all of the linked values to compute type mappings. For example, /// if we link "extern Foo *x" and "Foo *x = NULL", then we have two struct /// types 'Foo' but one got renamed when the module was loaded into the same @@ -728,15 +736,12 @@ void IRLinker::computeTypeMapping() { continue; } - // Check to see if there is a dot in the name followed by a digit. - size_t DotPos = ST->getName().rfind('.'); - if (DotPos == 0 || DotPos == StringRef::npos || - ST->getName().back() == '.' || - !isdigit(static_cast<unsigned char>(ST->getName()[DotPos + 1]))) + auto STTypePrefix = getTypeNamePrefix(ST->getName()); + if (STTypePrefix.size()== ST->getName().size()) continue; // Check to see if the destination module has a struct with the prefix name. - StructType *DST = DstM.getTypeByName(ST->getName().substr(0, DotPos)); + StructType *DST = DstM.getTypeByName(STTypePrefix); if (!DST) continue; |