From a2148402ce39fb3aad09e98a32078d3853a01ae9 Mon Sep 17 00:00:00 2001 From: Devang Patel Date: Mon, 28 Sep 2009 21:14:55 +0000 Subject: [PATCH] Do not use global typedef for MDKindID. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83016 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Metadata.h | 14 +++++--------- include/llvm/Support/IRBuilder.h | 2 +- lib/AsmParser/LLParser.cpp | 2 +- lib/AsmParser/LLParser.h | 2 +- lib/Bitcode/Reader/BitcodeReader.cpp | 4 ++-- lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp | 4 ++-- lib/VMCore/Metadata.cpp | 10 +++++----- 7 files changed, 17 insertions(+), 21 deletions(-) diff --git a/include/llvm/Metadata.h b/include/llvm/Metadata.h index aef40bf11b7..d799ea4981b 100644 --- a/include/llvm/Metadata.h +++ b/include/llvm/Metadata.h @@ -307,13 +307,9 @@ public: /// Metadata - /// Metadata manages metadata used in a context. -/// MDKindID - This id identifies metadata kind the metadata store. Valid -/// ID values are 1 or higher. This ID is set by RegisterMDKind. -typedef unsigned MDKindID; - class Metadata { public: - typedef std::pair MDPairTy; + typedef std::pair MDPairTy; typedef SmallVector MDMapTy; typedef DenseMap MDStoreTy; friend class BitcodeReader; @@ -328,21 +324,21 @@ private: public: /// RegisterMDKind - Register a new metadata kind and return its ID. /// A metadata kind can be registered only once. - MDKindID RegisterMDKind(const char *Name); + unsigned RegisterMDKind(const char *Name); /// getMDKind - Return metadata kind. If the requested metadata kind /// is not registered then return 0. - MDKindID getMDKind(const char *Name); + unsigned getMDKind(const char *Name); /// getMD - Get the metadata of given kind attached with an Instruction. /// If the metadata is not found then return 0. - MDNode *getMD(MDKindID Kind, const Instruction *Inst); + MDNode *getMD(unsigned Kind, const Instruction *Inst); /// getMDs - Get the metadata attached with an Instruction. const MDMapTy *getMDs(const Instruction *Inst); /// setMD - Attach the metadata of given kind with an Instruction. - void setMD(MDKindID Kind, MDNode *Node, Instruction *Inst); + void setMD(unsigned Kind, MDNode *Node, Instruction *Inst); /// getHandlerNames - Get handler names. This is used by bitcode /// writer. diff --git a/include/llvm/Support/IRBuilder.h b/include/llvm/Support/IRBuilder.h index 00347ba335c..b5e17871ea0 100644 --- a/include/llvm/Support/IRBuilder.h +++ b/include/llvm/Support/IRBuilder.h @@ -61,7 +61,7 @@ templategetContext().getMetadata(); - for (SmallVector, 2>::iterator + for (SmallVector, 2>::iterator MDI = MDsOnInst.begin(), MDE = MDsOnInst.end(); MDI != MDE; ++MDI) TheMetadata.setMD(MDI->first, MDI->second, Inst); MDsOnInst.clear(); diff --git a/lib/AsmParser/LLParser.h b/lib/AsmParser/LLParser.h index 3420fcf4553..7c516fac619 100644 --- a/lib/AsmParser/LLParser.h +++ b/lib/AsmParser/LLParser.h @@ -48,7 +48,7 @@ namespace llvm { /// MetadataCache - This map keeps track of parsed metadata constants. std::map MetadataCache; std::map > ForwardRefMDNodes; - SmallVector, 2> MDsOnInst; + SmallVector, 2> MDsOnInst; struct UpRefRecord { /// Loc - This is the location of the upref. LocTy Loc; diff --git a/lib/Bitcode/Reader/BitcodeReader.cpp b/lib/Bitcode/Reader/BitcodeReader.cpp index f3ab806271a..0150f000484 100644 --- a/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/lib/Bitcode/Reader/BitcodeReader.cpp @@ -836,7 +836,7 @@ bool BitcodeReader::ParseMetadata() { return Error("Invalid METADATA_KIND record"); SmallString<8> Name; Name.resize(RecordLength-1); - MDKindID Kind = Record[0]; + unsigned Kind = Record[0]; for (unsigned i = 1; i != RecordLength; ++i) Name[i-1] = Record[i]; Metadata &TheMetadata = Context.getMetadata(); @@ -1580,7 +1580,7 @@ bool BitcodeReader::ParseMetadataAttachment() { return Error ("Invalid METADATA_ATTACHMENT reader!"); Instruction *Inst = InstructionList[Record[0]]; for (unsigned i = 1; i != RecordLength; i = i+2) { - MDKindID Kind = Record[i]; + unsigned Kind = Record[i]; Value *Node = MDValueList.getValueFwdRef(Record[i+1]); TheMetadata.setMD(Kind, cast(Node), Inst); } diff --git a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp index 197b3b6b7c7..53a2e6427db 100644 --- a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp +++ b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp @@ -373,7 +373,7 @@ void SelectionDAGISel::SelectBasicBlock(BasicBlock *LLVMBB, BasicBlock::iterator End) { SDL->setCurrentBasicBlock(BB); Metadata &TheMetadata = LLVMBB->getParent()->getContext().getMetadata(); - MDKindID MDDbgKind = TheMetadata.getMDKind("dbg"); + unsigned MDDbgKind = TheMetadata.getMDKind("dbg"); // Lower all of the non-terminator instructions. If a call is emitted // as a tail call, cease emitting nodes for this block. @@ -656,7 +656,7 @@ void SelectionDAGISel::SelectAllBasicBlocks(Function &Fn, ); Metadata &TheMetadata = Fn.getContext().getMetadata(); - MDKindID MDDbgKind = TheMetadata.getMDKind("dbg"); + unsigned MDDbgKind = TheMetadata.getMDKind("dbg"); // Iterate over all basic blocks in the function. for (Function::iterator I = Fn.begin(), E = Fn.end(); I != E; ++I) { diff --git a/lib/VMCore/Metadata.cpp b/lib/VMCore/Metadata.cpp index 67bb66f30ad..3daae13dd18 100644 --- a/lib/VMCore/Metadata.cpp +++ b/lib/VMCore/Metadata.cpp @@ -259,8 +259,8 @@ NamedMDNode::~NamedMDNode() { /// RegisterMDKind - Register a new metadata kind and return its ID. /// A metadata kind can be registered only once. -MDKindID Metadata::RegisterMDKind(const char *Name) { - MDKindID Count = MDHandlerNames.size(); +unsigned Metadata::RegisterMDKind(const char *Name) { + unsigned Count = MDHandlerNames.size(); StringMap::iterator I = MDHandlerNames.find(Name); assert(I == MDHandlerNames.end() && "Already registered MDKind!"); MDHandlerNames[Name] = Count + 1; @@ -269,7 +269,7 @@ MDKindID Metadata::RegisterMDKind(const char *Name) { /// getMDKind - Return metadata kind. If the requested metadata kind /// is not registered then return 0. -MDKindID Metadata::getMDKind(const char *Name) { +unsigned Metadata::getMDKind(const char *Name) { StringMap::iterator I = MDHandlerNames.find(Name); if (I == MDHandlerNames.end()) return 0; @@ -278,7 +278,7 @@ MDKindID Metadata::getMDKind(const char *Name) { } /// setMD - Attach the metadata of given kind with an Instruction. -void Metadata::setMD(MDKindID MDKind, MDNode *Node, Instruction *Inst) { +void Metadata::setMD(unsigned MDKind, MDNode *Node, Instruction *Inst) { MDStoreTy::iterator I = MetadataStore.find(Inst); Inst->HasMetadata = true; if (I == MetadataStore.end()) { @@ -295,7 +295,7 @@ void Metadata::setMD(MDKindID MDKind, MDNode *Node, Instruction *Inst) { /// getMD - Get the metadata of given kind attached with an Instruction. /// If the metadata is not found then return 0. -MDNode *Metadata::getMD(MDKindID MDKind, const Instruction *Inst) { +MDNode *Metadata::getMD(unsigned MDKind, const Instruction *Inst) { MDNode *Node = NULL; MDStoreTy::iterator I = MetadataStore.find(Inst); if (I == MetadataStore.end()) -- 2.34.1