summaryrefslogtreecommitdiffstats
path: root/clang/lib/Lex
diff options
context:
space:
mode:
authorDavid Blaikie <dblaikie@gmail.com>2014-08-29 22:04:45 +0000
committerDavid Blaikie <dblaikie@gmail.com>2014-08-29 22:04:45 +0000
commit02118cedd5c85f8288e55f96afd5a422e5b3a0ac (patch)
tree801257a2645f90f310e6b804e45a5c8945cd6202 /clang/lib/Lex
parent60e836ba99172e80b0dbce29b3ab2b7582ce6fa8 (diff)
downloadbcm5719-llvm-02118cedd5c85f8288e55f96afd5a422e5b3a0ac.tar.gz
bcm5719-llvm-02118cedd5c85f8288e55f96afd5a422e5b3a0ac.zip
unique_ptrify PTHManager's PerIDCache using the newly added llvm::FreeDeleter
llvm-svn: 216786
Diffstat (limited to 'clang/lib/Lex')
-rw-r--r--clang/lib/Lex/PTHLexer.cpp26
1 files changed, 12 insertions, 14 deletions
diff --git a/clang/lib/Lex/PTHLexer.cpp b/clang/lib/Lex/PTHLexer.cpp
index cff160b6ff4..af7a15384e3 100644
--- a/clang/lib/Lex/PTHLexer.cpp
+++ b/clang/lib/Lex/PTHLexer.cpp
@@ -413,20 +413,18 @@ public:
// PTHManager methods.
//===----------------------------------------------------------------------===//
-PTHManager::PTHManager(std::unique_ptr<const llvm::MemoryBuffer> buf,
- std::unique_ptr<PTHFileLookup> fileLookup,
- const unsigned char *idDataTable,
- IdentifierInfo **perIDCache,
- std::unique_ptr<PTHStringIdLookup> stringIdLookup,
- unsigned numIds, const unsigned char *spellingBase,
- const char *originalSourceFile)
- : Buf(std::move(buf)), PerIDCache(perIDCache),
+PTHManager::PTHManager(
+ std::unique_ptr<const llvm::MemoryBuffer> buf,
+ std::unique_ptr<PTHFileLookup> fileLookup, const unsigned char *idDataTable,
+ std::unique_ptr<IdentifierInfo *[], llvm::FreeDeleter> perIDCache,
+ std::unique_ptr<PTHStringIdLookup> stringIdLookup, unsigned numIds,
+ const unsigned char *spellingBase, const char *originalSourceFile)
+ : Buf(std::move(buf)), PerIDCache(std::move(perIDCache)),
FileLookup(std::move(fileLookup)), IdDataTable(idDataTable),
StringIdLookup(std::move(stringIdLookup)), NumIds(numIds), PP(nullptr),
SpellingBase(spellingBase), OriginalSourceFile(originalSourceFile) {}
PTHManager::~PTHManager() {
- free(PerIDCache);
}
static void InvalidPTH(DiagnosticsEngine &Diags, const char *Msg) {
@@ -537,10 +535,10 @@ PTHManager *PTHManager::Create(const std::string &file,
// Pre-allocate the persistent ID -> IdentifierInfo* cache. We use calloc()
// so that we in the best case only zero out memory once when the OS returns
// us new pages.
- IdentifierInfo **PerIDCache = nullptr;
+ std::unique_ptr<IdentifierInfo *[], llvm::FreeDeleter> PerIDCache;
if (NumIds) {
- PerIDCache = (IdentifierInfo**)calloc(NumIds, sizeof(*PerIDCache));
+ PerIDCache.reset((IdentifierInfo **)calloc(NumIds, sizeof(PerIDCache[0])));
if (!PerIDCache) {
InvalidPTH(Diags, "Could not allocate memory for processing PTH file");
return nullptr;
@@ -554,9 +552,9 @@ PTHManager *PTHManager::Create(const std::string &file,
if (!len) originalSourceBase = nullptr;
// Create the new PTHManager.
- return new PTHManager(std::move(File), std::move(FL), IData, PerIDCache,
- std::move(SL), NumIds, spellingBase,
- (const char *)originalSourceBase);
+ return new PTHManager(std::move(File), std::move(FL), IData,
+ std::move(PerIDCache), std::move(SL), NumIds,
+ spellingBase, (const char *)originalSourceBase);
}
IdentifierInfo* PTHManager::LazilyCreateIdentifierInfo(unsigned PersistentID) {
OpenPOWER on IntegriCloud