[Lldb-commits] [lldb] r177794 - If there are multiple uses of an Objective-C
Sean Callanan
scallanan at apple.com
Fri Mar 22 18:01:16 PDT 2013
Author: spyffe
Date: Fri Mar 22 20:01:16 2013
New Revision: 177794
URL: http://llvm.org/viewvc/llvm-project?rev=177794&view=rev
Log:
If there are multiple uses of an Objective-C
class symbol in the same expression, handle all
of them instead of just the first one.
<rdar://problem/13440133>
Modified:
lldb/trunk/source/Expression/IRForTarget.cpp
Modified: lldb/trunk/source/Expression/IRForTarget.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/IRForTarget.cpp?rev=177794&r1=177793&r2=177794&view=diff
==============================================================================
--- lldb/trunk/source/Expression/IRForTarget.cpp (original)
+++ lldb/trunk/source/Expression/IRForTarget.cpp Fri Mar 22 20:01:16 2013
@@ -1814,17 +1814,17 @@ IRForTarget::HandleObjCClass(Value *clas
if (global_variable->use_begin() == global_variable->use_end())
return false;
- LoadInst *load_instruction = NULL;
-
+ SmallVector<LoadInst *, 2> load_instructions;
+
for (Value::use_iterator i = global_variable->use_begin(), e = global_variable->use_end();
i != e;
++i)
{
- if ((load_instruction = dyn_cast<LoadInst>(*i)))
- break;
+ if (LoadInst *load_instruction = dyn_cast<LoadInst>(*i))
+ load_instructions.push_back(load_instruction);
}
- if (!load_instruction)
+ if (load_instructions.empty())
return false;
IntegerType *intptr_ty = Type::getIntNTy(m_module->getContext(),
@@ -1832,11 +1832,15 @@ IRForTarget::HandleObjCClass(Value *clas
== Module::Pointer64) ? 64 : 32);
Constant *class_addr = ConstantInt::get(intptr_ty, (uint64_t)class_ptr);
- Constant *class_bitcast = ConstantExpr::getIntToPtr(class_addr, load_instruction->getType());
- load_instruction->replaceAllUsesWith(class_bitcast);
+ for (LoadInst *load_instruction : load_instructions)
+ {
+ Constant *class_bitcast = ConstantExpr::getIntToPtr(class_addr, load_instruction->getType());
+
+ load_instruction->replaceAllUsesWith(class_bitcast);
- load_instruction->eraseFromParent();
+ load_instruction->eraseFromParent();
+ }
return true;
}
More information about the lldb-commits
mailing list