From 4d01fff4923795055c19272d08247d66cc2ed1fd Mon Sep 17 00:00:00 2001 From: Chandler Carruth Date: Sun, 9 Mar 2014 03:16:50 +0000 Subject: [PATCH] [C++11] Update Clang for the change to LLVM's Use-Def chain iterators in r203364: what was use_iterator is now user_iterator, and there is a use_iterator for directly iterating over the uses. This also switches to use the range-based APIs where appropriate. llvm-svn: 203365 --- clang/lib/CodeGen/CGCall.cpp | 2 +- clang/lib/CodeGen/CGCleanup.cpp | 2 +- clang/lib/CodeGen/CGException.cpp | 9 +++------ clang/lib/CodeGen/CGStmt.cpp | 5 ++--- clang/lib/CodeGen/CodeGenFunction.cpp | 2 +- clang/lib/CodeGen/CodeGenModule.cpp | 4 ++-- 6 files changed, 10 insertions(+), 14 deletions(-) diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp index 4f564df..a39f13b 100644 --- a/clang/lib/CodeGen/CGCall.cpp +++ b/clang/lib/CodeGen/CGCall.cpp @@ -1742,7 +1742,7 @@ static llvm::StoreInst *findDominatingStoreToReturnValue(CodeGenFunction &CGF) { } llvm::StoreInst *store = - dyn_cast(CGF.ReturnValue->use_back()); + dyn_cast(CGF.ReturnValue->user_back()); if (!store) return 0; // These aren't actually possible for non-coerced returns, and we diff --git a/clang/lib/CodeGen/CGCleanup.cpp b/clang/lib/CodeGen/CGCleanup.cpp index 3cf21bb..8748224 100644 --- a/clang/lib/CodeGen/CGCleanup.cpp +++ b/clang/lib/CodeGen/CGCleanup.cpp @@ -528,7 +528,7 @@ static void destroyOptimisticNormalEntry(CodeGenFunction &CGF, llvm::BasicBlock *unreachableBB = CGF.getUnreachableBlock(); for (llvm::BasicBlock::use_iterator i = entry->use_begin(), e = entry->use_end(); i != e; ) { - llvm::Use &use = i.getUse(); + llvm::Use &use = *i; ++i; use.set(unreachableBB); diff --git a/clang/lib/CodeGen/CGException.cpp b/clang/lib/CodeGen/CGException.cpp index 97d9fbb..607566c 100644 --- a/clang/lib/CodeGen/CGException.cpp +++ b/clang/lib/CodeGen/CGException.cpp @@ -263,12 +263,9 @@ static llvm::Constant *getOpaquePersonalityFn(CodeGenModule &CGM, /// Check whether a personality function could reasonably be swapped /// for a C++ personality function. static bool PersonalityHasOnlyCXXUses(llvm::Constant *Fn) { - for (llvm::Constant::use_iterator - I = Fn->use_begin(), E = Fn->use_end(); I != E; ++I) { - llvm::User *User = *I; - + for (llvm::User *U : Fn->users()) { // Conditionally white-list bitcasts. - if (llvm::ConstantExpr *CE = dyn_cast(User)) { + if (llvm::ConstantExpr *CE = dyn_cast(U)) { if (CE->getOpcode() != llvm::Instruction::BitCast) return false; if (!PersonalityHasOnlyCXXUses(CE)) return false; @@ -276,7 +273,7 @@ static bool PersonalityHasOnlyCXXUses(llvm::Constant *Fn) { } // Otherwise, it has to be a landingpad instruction. - llvm::LandingPadInst *LPI = dyn_cast(User); + llvm::LandingPadInst *LPI = dyn_cast(U); if (!LPI) return false; for (unsigned I = 0, E = LPI->getNumClauses(); I != E; ++I) { diff --git a/clang/lib/CodeGen/CGStmt.cpp b/clang/lib/CodeGen/CGStmt.cpp index 80a8da7..d69c5cd 100644 --- a/clang/lib/CodeGen/CGStmt.cpp +++ b/clang/lib/CodeGen/CGStmt.cpp @@ -311,9 +311,8 @@ void CodeGenFunction::EmitBranch(llvm::BasicBlock *Target) { void CodeGenFunction::EmitBlockAfterUses(llvm::BasicBlock *block) { bool inserted = false; - for (llvm::BasicBlock::use_iterator - i = block->use_begin(), e = block->use_end(); i != e; ++i) { - if (llvm::Instruction *insn = dyn_cast(*i)) { + for (llvm::User *u : block->users()) { + if (llvm::Instruction *insn = dyn_cast(u)) { CurFn->getBasicBlockList().insertAfter(insn->getParent(), block); inserted = true; break; diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp index d35ab73..5028d5d 100644 --- a/clang/lib/CodeGen/CodeGenFunction.cpp +++ b/clang/lib/CodeGen/CodeGenFunction.cpp @@ -158,7 +158,7 @@ void CodeGenFunction::EmitReturnBlock() { // cleans up functions which started with a unified return block. if (ReturnBlock.getBlock()->hasOneUse()) { llvm::BranchInst *BI = - dyn_cast(*ReturnBlock.getBlock()->use_begin()); + dyn_cast(*ReturnBlock.getBlock()->user_begin()); if (BI && BI->isUnconditional() && BI->getSuccessor(0) == ReturnBlock.getBlock()) { // Reset insertion point, including debug location, and delete the diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index a5cd9e3..c8dd813 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -1938,7 +1938,7 @@ static void replaceUsesOfNonProtoConstant(llvm::Constant *old, for (llvm::Value::use_iterator ui = old->use_begin(), ue = old->use_end(); ui != ue; ) { llvm::Value::use_iterator use = ui++; // Increment before the use is erased. - llvm::User *user = *use; + llvm::User *user = use->getUser(); // Recognize and replace uses of bitcasts. Most calls to // unprototyped functions will use bitcasts. @@ -1951,7 +1951,7 @@ static void replaceUsesOfNonProtoConstant(llvm::Constant *old, // Recognize calls to the function. llvm::CallSite callSite(user); if (!callSite) continue; - if (!callSite.isCallee(use)) continue; + if (!callSite.isCallee(&*use)) continue; // If the return types don't match exactly, then we can't // transform this call unless it's dead. -- 2.7.4