Fix getMDs() interface such that it does not expose implementation details.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84885 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Devang Patel
2009-10-22 18:55:16 +00:00
parent b5681b2293
commit f61b2371c8
5 changed files with 35 additions and 26 deletions
+6 -4
View File
@@ -561,14 +561,16 @@ static void WriteMetadataAttachment(const Function &F,
// Write metadata attachments
// METADATA_ATTACHMENT - [m x [value, [n x [id, mdnode]]]
MetadataContext &TheMetadata = F.getContext().getMetadata();
typedef SmallVector<std::pair<unsigned, TrackingVH<MDNode> >, 2> MDMapTy;
MDMapTy MDs;
for (Function::const_iterator BB = F.begin(), E = F.end(); BB != E; ++BB)
for (BasicBlock::const_iterator I = BB->begin(), E = BB->end();
I != E; ++I) {
const MetadataContext::MDMapTy *P = TheMetadata.getMDs(I);
if (!P) continue;
MDs.clear();
TheMetadata.getMDs(I, MDs);
bool RecordedInstruction = false;
for (MetadataContext::MDMapTy::const_iterator PI = P->begin(),
PE = P->end(); PI != PE; ++PI) {
for (MDMapTy::const_iterator PI = MDs.begin(), PE = MDs.end();
PI != PE; ++PI) {
if (RecordedInstruction == false) {
Record.push_back(VE.getInstructionID(I));
RecordedInstruction = true;
+7 -5
View File
@@ -87,6 +87,8 @@ ValueEnumerator::ValueEnumerator(const Module *M) {
EnumerateType(I->getType());
MetadataContext &TheMetadata = F->getContext().getMetadata();
typedef SmallVector<std::pair<unsigned, TrackingVH<MDNode> >, 2> MDMapTy;
MDMapTy MDs;
for (Function::const_iterator BB = F->begin(), E = F->end(); BB != E; ++BB)
for (BasicBlock::const_iterator I = BB->begin(), E = BB->end(); I!=E;++I){
for (User::const_op_iterator OI = I->op_begin(), E = I->op_end();
@@ -99,11 +101,11 @@ ValueEnumerator::ValueEnumerator(const Module *M) {
EnumerateAttributes(II->getAttributes());
// Enumerate metadata attached with this instruction.
const MetadataContext::MDMapTy *MDs = TheMetadata.getMDs(I);
if (MDs)
for (MetadataContext::MDMapTy::const_iterator MI = MDs->begin(),
ME = MDs->end(); MI != ME; ++MI)
EnumerateMetadata(MI->second);
MDs.clear();
TheMetadata.getMDs(I, MDs);
for (MDMapTy::const_iterator MI = MDs.begin(), ME = MDs.end(); MI != ME;
++MI)
EnumerateMetadata(MI->second);
}
}