Simplify the code in DarwinTargetAsmInfo::emitUsedDirectiveFor so that humans can...
authorBill Wendling <isanbard@gmail.com>
Mon, 20 Jul 2009 21:38:26 +0000 (21:38 +0000)
committerBill Wendling <isanbard@gmail.com>
Mon, 20 Jul 2009 21:38:26 +0000 (21:38 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@76480 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/MachOWriter.cpp
lib/Target/DarwinTargetAsmInfo.cpp

index 4e24c7c2bb0ea9c0d4f80d7fe5e730d2e99f4e05..a6a439a226ae3a24ba6ad267f2c6c7735956ed1f 100644 (file)
@@ -774,4 +774,3 @@ MachOSym::MachOSym(const GlobalValue *gv, std::string name, uint8_t sect,
 }
 
 } // end namespace llvm
-
index 3eb3d53595433602d744190655a4bf5711abdadf..6540edd97aec7799de862b7509b2efc620d166d7 100644 (file)
@@ -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;
 }