aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBill Wendling <isanbard@gmail.com>2009-07-20 21:38:26 +0000
committerBill Wendling <isanbard@gmail.com>2009-07-20 21:38:26 +0000
commitecc2da8efdc07cf01163b7ab6db1f6dc2f134b67 (patch)
treed47b246b17d7365fd0bc0b42bf9760f7d7f26f06
parent4cef584860acbde1d71157564e0d5f6f935b38a6 (diff)
downloadexternal_llvm-ecc2da8efdc07cf01163b7ab6db1f6dc2f134b67.zip
external_llvm-ecc2da8efdc07cf01163b7ab6db1f6dc2f134b67.tar.gz
external_llvm-ecc2da8efdc07cf01163b7ab6db1f6dc2f134b67.tar.bz2
Simplify the code in DarwinTargetAsmInfo::emitUsedDirectiveFor so that humans can understand it.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@76480 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/CodeGen/MachOWriter.cpp1
-rw-r--r--lib/Target/DarwinTargetAsmInfo.cpp32
2 files changed, 16 insertions, 17 deletions
diff --git a/lib/CodeGen/MachOWriter.cpp b/lib/CodeGen/MachOWriter.cpp
index 4e24c7c..a6a439a 100644
--- a/lib/CodeGen/MachOWriter.cpp
+++ b/lib/CodeGen/MachOWriter.cpp
@@ -774,4 +774,3 @@ MachOSym::MachOSym(const GlobalValue *gv, std::string name, uint8_t sect,
}
} // end namespace llvm
-
diff --git a/lib/Target/DarwinTargetAsmInfo.cpp b/lib/Target/DarwinTargetAsmInfo.cpp
index 3eb3d53..6540edd 100644
--- a/lib/Target/DarwinTargetAsmInfo.cpp
+++ b/lib/Target/DarwinTargetAsmInfo.cpp
@@ -107,23 +107,23 @@ DarwinTargetAsmInfo::DarwinTargetAsmInfo(const TargetMachine &TM)
/// emitUsedDirectiveFor - On Darwin, internally linked data beginning with
/// the PrivateGlobalPrefix or the LessPrivateGlobalPrefix does not have the
/// directive emitted (this occurs in ObjC metadata).
-bool
-DarwinTargetAsmInfo::emitUsedDirectiveFor(const GlobalValue* GV,
- Mangler *Mang) const {
- if (GV==0)
- return false;
+bool DarwinTargetAsmInfo::emitUsedDirectiveFor(const GlobalValue* GV,
+ Mangler *Mang) const {
+ if (!GV) return false;
- /// FIXME: WHAT IS THIS?
-
- if (GV->hasLocalLinkage() && !isa<Function>(GV) &&
- ((strlen(getPrivateGlobalPrefix()) != 0 &&
- Mang->getMangledName(GV).substr(0,strlen(getPrivateGlobalPrefix())) ==
- getPrivateGlobalPrefix()) ||
- (strlen(getLessPrivateGlobalPrefix()) != 0 &&
- Mang->getMangledName(GV).substr(0,
- strlen(getLessPrivateGlobalPrefix())) ==
- getLessPrivateGlobalPrefix())))
- return false;
+ // Check whether the mangled name has the "Private" or "LessPrivate" prefix.
+ if (GV->hasLocalLinkage() && !isa<Function>(GV)) {
+ const std::string &Name = Mang->getMangledName(GV);
+ const char *PGPrefix = getPrivateGlobalPrefix();
+ const char *LPGPrefix = getLessPrivateGlobalPrefix();
+ unsigned PGPLen = strlen(PGPrefix);
+ unsigned LPGPLen = strlen(LPGPrefix);
+
+ if ((PGPLen != 0 && Name.substr(0, PGPLen) == PGPrefix) ||
+ (LPGPLen != 0 && Name.substr(0, LPGPLen) == LPGPrefix))
+ return false;
+ }
+
return true;
}