opnsense-src/contrib/llvm/lib/Support/StringPool.cpp

36 lines
978 B
C++
Raw Normal View History

2009-06-02 13:52:33 -04:00
//===-- StringPool.cpp - Interned string pool -----------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file implements the StringPool class.
//
//===----------------------------------------------------------------------===//
#include "llvm/Support/StringPool.h"
2009-10-14 13:57:32 -04:00
#include "llvm/ADT/StringRef.h"
2009-06-02 13:52:33 -04:00
using namespace llvm;
StringPool::StringPool() {}
StringPool::~StringPool() {
assert(InternTable.empty() && "PooledStringPtr leaked!");
}
2010-07-15 13:06:11 -04:00
PooledStringPtr StringPool::intern(StringRef Key) {
2009-10-14 13:57:32 -04:00
table_t::iterator I = InternTable.find(Key);
2009-06-02 13:52:33 -04:00
if (I != InternTable.end())
return PooledStringPtr(&*I);
entry_t *S = entry_t::Create(Key);
2009-06-02 13:52:33 -04:00
S->getValue().Pool = this;
InternTable.insert(S);
return PooledStringPtr(S);
}