Fix uninitialized variable
[llvm-core.git] / lib / IR / MetadataImpl.h
blobb9137460bd203142f219a2e32c7cf1ca03aa6b4f
1 //===- MetadataImpl.h - Helpers for implementing metadata -----------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file has private helpers for implementing metadata types.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_IR_METADATAIMPL_H
15 #define LLVM_IR_METADATAIMPL_H
17 #include "llvm/ADT/DenseSet.h"
18 #include "llvm/IR/Metadata.h"
20 namespace llvm {
22 template <class T, class InfoT>
23 static T *getUniqued(DenseSet<T *, InfoT> &Store,
24 const typename InfoT::KeyTy &Key) {
25 auto I = Store.find_as(Key);
26 return I == Store.end() ? nullptr : *I;
29 template <class T> T *MDNode::storeImpl(T *N, StorageType Storage) {
30 switch (Storage) {
31 case Uniqued:
32 llvm_unreachable("Cannot unique without a uniquing-store");
33 case Distinct:
34 N->storeDistinctInContext();
35 break;
36 case Temporary:
37 break;
39 return N;
42 template <class T, class StoreT>
43 T *MDNode::storeImpl(T *N, StorageType Storage, StoreT &Store) {
44 switch (Storage) {
45 case Uniqued:
46 Store.insert(N);
47 break;
48 case Distinct:
49 N->storeDistinctInContext();
50 break;
51 case Temporary:
52 break;
54 return N;
57 } // end namespace llvm
59 #endif