[llvm-commits] [llvm] r89974 - /llvm/trunk/lib/VMCore/Metadata.cpp

Nick Lewycky nicholas at mxc.ca
Thu Nov 26 14:54:26 PST 2009


Author: nicholas
Date: Thu Nov 26 16:54:26 2009
New Revision: 89974

URL: http://llvm.org/viewvc/llvm-project?rev=89974&view=rev
Log:
Clean up file, no functionality change.

Modified:
    llvm/trunk/lib/VMCore/Metadata.cpp

Modified: llvm/trunk/lib/VMCore/Metadata.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Metadata.cpp?rev=89974&r1=89973&r2=89974&view=diff

==============================================================================
--- llvm/trunk/lib/VMCore/Metadata.cpp (original)
+++ llvm/trunk/lib/VMCore/Metadata.cpp Thu Nov 26 16:54:26 2009
@@ -33,10 +33,8 @@
   StringMapEntry<MDString *> &Entry = 
     pImpl->MDStringCache.GetOrCreateValue(Str);
   MDString *&S = Entry.getValue();
-  if (S) return S;
-  
-  return S = 
-    new MDString(Context, Entry.getKey());
+  if (!S) S = new MDString(Context, Entry.getKey());
+  return S;
 }
 
 MDString *MDString::get(LLVMContext &Context, const char *Str) {
@@ -44,10 +42,8 @@
   StringMapEntry<MDString *> &Entry = 
     pImpl->MDStringCache.GetOrCreateValue(Str ? StringRef(Str) : StringRef());
   MDString *&S = Entry.getValue();
-  if (S) return S;
-  
-  return S = 
-    new MDString(Context, Entry.getKey());
+  if (!S) new MDString(Context, Entry.getKey());
+  return S;
 }
 
 //===----------------------------------------------------------------------===//
@@ -74,28 +70,19 @@
     ID.AddPointer(Vals[i]);
 
   void *InsertPoint;
-  MDNode *N;
-  {
-    N = pImpl->MDNodeSet.FindNodeOrInsertPos(ID, InsertPoint);
-  }  
-  if (N) return N;
-  
-  N = pImpl->MDNodeSet.FindNodeOrInsertPos(ID, InsertPoint);
+  MDNode *N = pImpl->MDNodeSet.FindNodeOrInsertPos(ID, InsertPoint);
   if (!N) {
     // InsertPoint will have been set by the FindNodeOrInsertPos call.
     N = new MDNode(Context, Vals, NumVals);
     pImpl->MDNodeSet.InsertNode(N, InsertPoint);
   }
-
   return N;
 }
 
 /// ~MDNode - Destroy MDNode.
 MDNode::~MDNode() {
-  {
-    LLVMContextImpl *pImpl = getType()->getContext().pImpl;
-    pImpl->MDNodeSet.RemoveNode(this);
-  }
+  LLVMContextImpl *pImpl = getType()->getContext().pImpl;
+  pImpl->MDNodeSet.RemoveNode(this);
   delete [] Node;
   Node = NULL;
 }
@@ -241,7 +228,7 @@
   /// the same metadata to In2.
   void copyMD(Instruction *In1, Instruction *In2);
 
-  /// getHandlerNames - Populate client supplied smallvector using custome
+  /// getHandlerNames - Populate client-supplied smallvector using custom
   /// metadata name and ID.
   void getHandlerNames(SmallVectorImpl<std::pair<unsigned, StringRef> >&) const;
 
@@ -317,7 +304,7 @@
     }
   }
 }
-  
+
 /// removeAllMetadata - Remove all metadata attached with an instruction.
 void MetadataContextImpl::removeAllMetadata(Instruction *Inst) {
   MetadataStore.erase(Inst);
@@ -454,12 +441,12 @@
 void MetadataContext::addMD(unsigned Kind, MDNode *Node, Instruction *Inst) {
   pImpl->addMD(Kind, Node, Inst);
 }
-  
+
 /// removeMD - Remove metadata of given kind attached with an instuction.
 void MetadataContext::removeMD(unsigned Kind, Instruction *Inst) {
   pImpl->removeMD(Kind, Inst);
 }
-  
+
 /// removeAllMetadata - Remove all metadata attached with an instruction.
 void MetadataContext::removeAllMetadata(Instruction *Inst) {
   pImpl->removeAllMetadata(Inst);





More information about the llvm-commits mailing list