[llvm-commits] [llvm] r77511 - in /llvm/trunk: include/llvm/Metadata.h lib/AsmParser/LLParser.cpp lib/VMCore/Metadata.cpp
Devang Patel
dpatel at apple.com
Wed Jul 29 14:58:56 PDT 2009
Author: dpatel
Date: Wed Jul 29 16:58:56 2009
New Revision: 77511
URL: http://llvm.org/viewvc/llvm-project?rev=77511&view=rev
Log:
There is no need to keep name ref in NamedMDNode.
Modified:
llvm/trunk/include/llvm/Metadata.h
llvm/trunk/lib/AsmParser/LLParser.cpp
llvm/trunk/lib/VMCore/Metadata.cpp
Modified: llvm/trunk/include/llvm/Metadata.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Metadata.h?rev=77511&r1=77510&r2=77511&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Metadata.h (original)
+++ llvm/trunk/include/llvm/Metadata.h Wed Jul 29 16:58:56 2009
@@ -185,31 +185,26 @@
friend class LLVMContextImpl;
Module *Parent;
- StringRef Name;
SmallVector<WeakMetadataVH, 4> Node;
typedef SmallVectorImpl<WeakMetadataVH>::iterator elem_iterator;
protected:
- explicit NamedMDNode(const char *N, unsigned NameLength,
- MetadataBase*const* Vals, unsigned NumVals,
- Module *M = 0);
+ explicit NamedMDNode(const Twine &N, MetadataBase*const* Vals,
+ unsigned NumVals, Module *M = 0);
public:
- static NamedMDNode *Create(const char *N, unsigned NamedLength,
- MetadataBase*const*MDs, unsigned NumMDs,
- Module *M = 0) {
- return new NamedMDNode(N, NamedLength, MDs, NumMDs, M);
+ static NamedMDNode *Create(const Twine &N, MetadataBase*const*MDs,
+ unsigned NumMDs, Module *M = 0) {
+ return new NamedMDNode(N, MDs, NumMDs, M);
}
typedef SmallVectorImpl<WeakMetadataVH>::const_iterator const_elem_iterator;
- StringRef getName() const { return Name; }
-
/// getParent - Get the module that holds this named metadata collection.
inline Module *getParent() { return Parent; }
inline const Module *getParent() const { return Parent; }
void setParent(Module *M) { Parent = M; }
- Value *getElement(unsigned i) const {
+ MetadataBase *getElement(unsigned i) const {
return Node[i];
}
Modified: llvm/trunk/lib/AsmParser/LLParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLParser.cpp?rev=77511&r1=77510&r2=77511&view=diff
==============================================================================
--- llvm/trunk/lib/AsmParser/LLParser.cpp (original)
+++ llvm/trunk/lib/AsmParser/LLParser.cpp Wed Jul 29 16:58:56 2009
@@ -440,8 +440,7 @@
if (ParseToken(lltok::rbrace, "expected end of metadata node"))
return true;
- NamedMDNode::Create(Name.c_str(), Name.length(),
- Elts.data(), Elts.size(), M);
+ NamedMDNode::Create(Name, Elts.data(), Elts.size(), M);
return false;
}
Modified: llvm/trunk/lib/VMCore/Metadata.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Metadata.cpp?rev=77511&r1=77510&r2=77511&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/Metadata.cpp (original)
+++ llvm/trunk/lib/VMCore/Metadata.cpp Wed Jul 29 16:58:56 2009
@@ -33,15 +33,12 @@
//===----------------------------------------------------------------------===//
//NamedMDNode implementation
//
-NamedMDNode::NamedMDNode(const char *N, unsigned NameLength,
- MetadataBase*const* MDs, unsigned NumMDs,
- Module *M)
- : MetadataBase(Type::MetadataTy, Value::NamedMDNodeVal),
- Name(N, NameLength) {
+NamedMDNode::NamedMDNode(const Twine &N, MetadataBase*const* MDs,
+ unsigned NumMDs, Module *ParentModule)
+ : MetadataBase(Type::MetadataTy, Value::NamedMDNodeVal) {
setName(N);
for (unsigned i = 0; i != NumMDs; ++i)
Node.push_back(WeakMetadataVH(MDs[i]));
-
- if (M)
- M->getNamedMDList().push_back(this);
+ if (ParentModule)
+ ParentModule->getNamedMDList().push_back(this);
}
More information about the llvm-commits
mailing list