From 0e9288493adc6c53169b264250f7763656815d4b Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Tue, 23 Jun 2015 14:11:09 +0000 Subject: [PATCH] Remove unused arguments and move ManglerPrefixTy to the implementation. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@240408 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/Mangler.h | 14 ++------------ lib/IR/Mangler.cpp | 38 +++++++++++++++++++++++++------------- 2 files changed, 27 insertions(+), 25 deletions(-) diff --git a/include/llvm/IR/Mangler.h b/include/llvm/IR/Mangler.h index b8c3cba48c7..b72b259097c 100644 --- a/include/llvm/IR/Mangler.h +++ b/include/llvm/IR/Mangler.h @@ -25,14 +25,6 @@ template class SmallVectorImpl; class Twine; class Mangler { -public: - enum ManglerPrefixTy { - Default, ///< Emit default string before each symbol. - Private, ///< Emit "private" prefix before each symbol. - LinkerPrivate ///< Emit "linker private" prefix before each symbol. - }; - -private: /// We need to give global values the same name every time they are mangled. /// This keeps track of the number we give to anonymous ones. mutable DenseMap AnonGlobalIDs; @@ -54,11 +46,9 @@ public: /// Print the appropriate prefix and the specified name as the global variable /// name. GVName must not be empty. static void getNameWithPrefix(raw_ostream &OS, const Twine &GVName, - const DataLayout &DL, - ManglerPrefixTy PrefixTy = Mangler::Default); + const DataLayout &DL); static void getNameWithPrefix(SmallVectorImpl &OutName, - const Twine &GVName, const DataLayout &DL, - ManglerPrefixTy PrefixTy = Mangler::Default); + const Twine &GVName, const DataLayout &DL); }; } // End llvm namespace diff --git a/lib/IR/Mangler.cpp b/lib/IR/Mangler.cpp index aac87ce0bb0..016cb9eb689 100644 --- a/lib/IR/Mangler.cpp +++ b/lib/IR/Mangler.cpp @@ -21,8 +21,16 @@ #include "llvm/Support/raw_ostream.h" using namespace llvm; +namespace { +enum ManglerPrefixTy { + Default, ///< Emit default string before each symbol. + Private, ///< Emit "private" prefix before each symbol. + LinkerPrivate ///< Emit "linker private" prefix before each symbol. +}; +} + static void getNameWithPrefixImpl(raw_ostream &OS, const Twine &GVName, - Mangler::ManglerPrefixTy PrefixTy, + ManglerPrefixTy PrefixTy, const DataLayout &DL, char Prefix) { SmallString<256> TmpData; StringRef Name = GVName.toStringRef(TmpData); @@ -35,9 +43,9 @@ static void getNameWithPrefixImpl(raw_ostream &OS, const Twine &GVName, return; } - if (PrefixTy == Mangler::Private) + if (PrefixTy == Private) OS << DL.getPrivateGlobalPrefix(); - else if (PrefixTy == Mangler::LinkerPrivate) + else if (PrefixTy == LinkerPrivate) OS << DL.getLinkerPrivateGlobalPrefix(); if (Prefix != '\0') @@ -47,19 +55,23 @@ static void getNameWithPrefixImpl(raw_ostream &OS, const Twine &GVName, OS << Name; } -void Mangler::getNameWithPrefix(raw_ostream &OS, const Twine &GVName, - const DataLayout &DL, - ManglerPrefixTy PrefixTy) { +static void getNameWithPrefixImpl(raw_ostream &OS, const Twine &GVName, + const DataLayout &DL, + ManglerPrefixTy PrefixTy) { char Prefix = DL.getGlobalPrefix(); return getNameWithPrefixImpl(OS, GVName, PrefixTy, DL, Prefix); } +void Mangler::getNameWithPrefix(raw_ostream &OS, const Twine &GVName, + const DataLayout &DL) { + return getNameWithPrefixImpl(OS, GVName, DL, Default); +} + void Mangler::getNameWithPrefix(SmallVectorImpl &OutName, - const Twine &GVName, const DataLayout &DL, - ManglerPrefixTy PrefixTy) { + const Twine &GVName, const DataLayout &DL) { raw_svector_ostream OS(OutName); char Prefix = DL.getGlobalPrefix(); - return getNameWithPrefixImpl(OS, GVName, PrefixTy, DL, Prefix); + return getNameWithPrefixImpl(OS, GVName, Default, DL, Prefix); } static bool hasByteCountSuffix(CallingConv::ID CC) { @@ -95,12 +107,12 @@ static void addByteCountSuffix(raw_ostream &OS, const Function *F, void Mangler::getNameWithPrefix(raw_ostream &OS, const GlobalValue *GV, bool CannotUsePrivateLabel) const { - ManglerPrefixTy PrefixTy = Mangler::Default; + ManglerPrefixTy PrefixTy = Default; if (GV->hasPrivateLinkage()) { if (CannotUsePrivateLabel) - PrefixTy = Mangler::LinkerPrivate; + PrefixTy = LinkerPrivate; else - PrefixTy = Mangler::Private; + PrefixTy = Private; } const DataLayout &DL = GV->getParent()->getDataLayout(); @@ -112,7 +124,7 @@ void Mangler::getNameWithPrefix(raw_ostream &OS, const GlobalValue *GV, ID = NextAnonGlobalID++; // Must mangle the global into a unique ID. - getNameWithPrefix(OS, "__unnamed_" + Twine(ID), DL, PrefixTy); + getNameWithPrefixImpl(OS, "__unnamed_" + Twine(ID), DL, PrefixTy); return; } -- 2.34.1