diff --git a/include/llvm/ADT/STLExtras.h b/include/llvm/ADT/STLExtras.h index 0b0346be2cc..5da906dc8cf 100644 --- a/include/llvm/ADT/STLExtras.h +++ b/include/llvm/ADT/STLExtras.h @@ -186,25 +186,21 @@ inline ItTy prior(ItTy it) // // do stuff // else // // do other stuff +template +struct tier { + typedef T1 &first_type; + typedef T2 &second_type; -namespace -{ - template - struct tier { - typedef T1 &first_type; - typedef T2 &second_type; + first_type first; + second_type second; - first_type first; - second_type second; - - tier(first_type f, second_type s) : first(f), second(s) { } - tier& operator=(const std::pair& p) { - first = p.first; - second = p.second; - return *this; - } - }; -} + tier(first_type f, second_type s) : first(f), second(s) { } + tier& operator=(const std::pair& p) { + first = p.first; + second = p.second; + return *this; + } +}; template inline tier tie(T1& f, T2& s) { diff --git a/lib/Support/StringExtras.cpp b/lib/Support/StringExtras.cpp index eb2fa084218..49c5ac4252c 100644 --- a/lib/Support/StringExtras.cpp +++ b/lib/Support/StringExtras.cpp @@ -51,11 +51,10 @@ std::pair llvm::getToken(StringRef Source, void llvm::SplitString(StringRef Source, SmallVectorImpl &OutFragments, StringRef Delimiters) { - StringRef S2, S; - tie(S2, S) = getToken(Source, Delimiters); - while (!S2.empty()) { - OutFragments.push_back(S2); - tie(S2, S) = getToken(S, Delimiters); + std::pair S = getToken(Source, Delimiters); + while (!S.first.empty()) { + OutFragments.push_back(S.first); + S = getToken(S.second, Delimiters); } } diff --git a/lib/Transforms/IPO/GlobalOpt.cpp b/lib/Transforms/IPO/GlobalOpt.cpp index d817b6ed4aa..5c2b7e1a10b 100644 --- a/lib/Transforms/IPO/GlobalOpt.cpp +++ b/lib/Transforms/IPO/GlobalOpt.cpp @@ -1260,11 +1260,9 @@ static void RewriteHeapSROALoadUser(Instruction *LoadUser, // already been seen first by another load, so its uses have already been // processed. PHINode *PN = cast(LoadUser); - bool Inserted; - DenseMap >::iterator InsertPos; - tie(InsertPos, Inserted) = - InsertedScalarizedValues.insert(std::make_pair(PN, std::vector())); - if (!Inserted) return; + if (!InsertedScalarizedValues.insert(std::make_pair(PN, + std::vector())).second) + return; // If this is the first time we've seen this PHI, recursively process all // users. diff --git a/lib/Transforms/Scalar/IndVarSimplify.cpp b/lib/Transforms/Scalar/IndVarSimplify.cpp index 24d996c95ac..3f810cdf5a2 100644 --- a/lib/Transforms/Scalar/IndVarSimplify.cpp +++ b/lib/Transforms/Scalar/IndVarSimplify.cpp @@ -1389,24 +1389,23 @@ void IndVarSimplify::SimplifyIVUsersNoRewrite(Loop *L, SCEVExpander &Rewriter) { pushIVUsers(CurrIV, Simplified, SimpleIVUsers); while (!SimpleIVUsers.empty()) { - Instruction *UseInst, *Operand; - tie(UseInst, Operand) = SimpleIVUsers.pop_back_val(); + std::pair Use =SimpleIVUsers.pop_back_val(); // Bypass back edges to avoid extra work. - if (UseInst == CurrIV) continue; + if (Use.first == CurrIV) continue; - if (EliminateIVUser(UseInst, Operand)) { - pushIVUsers(Operand, Simplified, SimpleIVUsers); + if (EliminateIVUser(Use.first, Use.second)) { + pushIVUsers(Use.second, Simplified, SimpleIVUsers); continue; } - if (CastInst *Cast = dyn_cast(UseInst)) { + if (CastInst *Cast = dyn_cast(Use.first)) { bool IsSigned = Cast->getOpcode() == Instruction::SExt; if (IsSigned || Cast->getOpcode() == Instruction::ZExt) { CollectExtend(Cast, IsSigned, WI, SE, TD); } continue; } - if (isSimpleIVUser(UseInst, L, SE)) { - pushIVUsers(UseInst, Simplified, SimpleIVUsers); + if (isSimpleIVUser(Use.first, L, SE)) { + pushIVUsers(Use.first, Simplified, SimpleIVUsers); } } if (WI.WidestNativeType) { @@ -1437,12 +1436,11 @@ void IndVarSimplify::SimplifyCongruentIVs(Loop *L) { continue; const SCEV *S = SE->getSCEV(Phi); - DenseMap::const_iterator Pos; - bool Inserted; - tie(Pos, Inserted) = ExprToIVMap.insert(std::make_pair(S, Phi)); - if (Inserted) + std::pair::const_iterator, bool> Tmp = + ExprToIVMap.insert(std::make_pair(S, Phi)); + if (Tmp.second) continue; - PHINode *OrigPhi = Pos->second; + PHINode *OrigPhi = Tmp.first->second; // If one phi derives from the other via GEPs, types may differ. if (OrigPhi->getType() != Phi->getType()) diff --git a/lib/Transforms/Scalar/SCCP.cpp b/lib/Transforms/Scalar/SCCP.cpp index 5b12c927622..9db2555e373 100644 --- a/lib/Transforms/Scalar/SCCP.cpp +++ b/lib/Transforms/Scalar/SCCP.cpp @@ -471,9 +471,9 @@ private: /// UsersOfOverdefinedPHIs map for PN, remove them now. void RemoveFromOverdefinedPHIs(Instruction *I, PHINode *PN) { if (UsersOfOverdefinedPHIs.empty()) return; - std::multimap::iterator It, E; - tie(It, E) = UsersOfOverdefinedPHIs.equal_range(PN); - while (It != E) { + typedef std::multimap::iterator ItTy; + std::pair Range = UsersOfOverdefinedPHIs.equal_range(PN); + for (ItTy It = Range.first, E = Range.second; It != E;) { if (It->second == I) UsersOfOverdefinedPHIs.erase(It++); else @@ -486,9 +486,9 @@ private: /// (Duplicate entries do not break anything directly, but can lead to /// exponential growth of the table in rare cases.) void InsertInOverdefinedPHIs(Instruction *I, PHINode *PN) { - std::multimap::iterator J, E; - tie(J, E) = UsersOfOverdefinedPHIs.equal_range(PN); - for (; J != E; ++J) + typedef std::multimap::iterator ItTy; + std::pair Range = UsersOfOverdefinedPHIs.equal_range(PN); + for (ItTy J = Range.first, E = Range.second; J != E; ++J) if (J->second == I) return; UsersOfOverdefinedPHIs.insert(std::make_pair(PN, I)); @@ -692,13 +692,14 @@ void SCCPSolver::visitPHINode(PHINode &PN) { // There may be instructions using this PHI node that are not overdefined // themselves. If so, make sure that they know that the PHI node operand // changed. - std::multimap::iterator I, E; - tie(I, E) = UsersOfOverdefinedPHIs.equal_range(&PN); - if (I == E) + typedef std::multimap::iterator ItTy; + std::pair Range = UsersOfOverdefinedPHIs.equal_range(&PN); + + if (Range.first == Range.second) return; SmallVector Users; - for (; I != E; ++I) + for (ItTy I = Range.first, E = Range.second; I != E; ++I) Users.push_back(I->second); while (!Users.empty()) visit(Users.pop_back_val()); diff --git a/lib/VMCore/Module.cpp b/lib/VMCore/Module.cpp index 25d5391b9ed..ee63d696d54 100644 --- a/lib/VMCore/Module.cpp +++ b/lib/VMCore/Module.cpp @@ -82,8 +82,10 @@ Module::Endianness Module::getEndianness() const { Module::Endianness ret = AnyEndianness; while (!temp.empty()) { - StringRef token = DataLayout; - tie(token, temp) = getToken(temp, "-"); + std::pair P = getToken(temp, "-"); + + StringRef token = P.first; + temp = P.second; if (token[0] == 'e') { ret = LittleEndian; @@ -95,15 +97,16 @@ Module::Endianness Module::getEndianness() const { return ret; } -/// Target Pointer Size information... +/// Target Pointer Size information. Module::PointerSize Module::getPointerSize() const { StringRef temp = DataLayout; Module::PointerSize ret = AnyPointerSize; while (!temp.empty()) { - StringRef token, signalToken; - tie(token, temp) = getToken(temp, "-"); - tie(signalToken, token) = getToken(token, ":"); + std::pair TmpP = getToken(temp, "-"); + temp = TmpP.second; + TmpP = getToken(TmpP.first, ":"); + StringRef token = TmpP.second, signalToken = TmpP.first; if (signalToken[0] == 'p') { int size = 0; diff --git a/utils/TableGen/CodeGenInstruction.cpp b/utils/TableGen/CodeGenInstruction.cpp index a52ce86c485..86a377b7a8a 100644 --- a/utils/TableGen/CodeGenInstruction.cpp +++ b/utils/TableGen/CodeGenInstruction.cpp @@ -267,8 +267,9 @@ static void ParseConstraints(const std::string &CStr, CGIOperandList &Ops) { void CGIOperandList::ProcessDisableEncoding(std::string DisableEncoding) { while (1) { - std::string OpName; - tie(OpName, DisableEncoding) = getToken(DisableEncoding, " ,\t"); + std::pair P = getToken(DisableEncoding, " ,\t"); + std::string OpName = P.first; + DisableEncoding = P.second; if (OpName.empty()) break; // Figure out which operand this is.