aboutsummaryrefslogtreecommitdiff
path: root/clang/tools/libclang/CXCompilationDatabase.cpp
diff options
context:
space:
mode:
authorDavid Blaikie <dblaikie@gmail.com>2014-08-08 16:06:15 +0000
committerDavid Blaikie <dblaikie@gmail.com>2014-08-08 16:06:15 +0000
commitcdba84c0d309be4312b08d0e7daa293c5305eba4 (patch)
tree76b02ab4e181c1519c6ca40294ebcb34c59df1fd /clang/tools/libclang/CXCompilationDatabase.cpp
parent590e5ff473fba9dcace9eee5fc59cb321a22811f (diff)
downloadllvm-cdba84c0d309be4312b08d0e7daa293c5305eba4.zip
llvm-cdba84c0d309be4312b08d0e7daa293c5305eba4.tar.gz
llvm-cdba84c0d309be4312b08d0e7daa293c5305eba4.tar.bz2
CompilationDatabase: Sure-up ownership of compilation databases using std::unique_ptr
Diving into the memory leaks fixed by r213851 there was one case of a memory leak of a CompilationDatabase due to not properly taking ownership of the result of "CompilationDatabase::autoDetectFromSource". Given that both implementations and callers have been using unique_ptr to own CompilationDatabase objects - make this explicit in the API to reduce the risk of further leaks. llvm-svn: 215215
Diffstat (limited to 'clang/tools/libclang/CXCompilationDatabase.cpp')
-rw-r--r--clang/tools/libclang/CXCompilationDatabase.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/clang/tools/libclang/CXCompilationDatabase.cpp b/clang/tools/libclang/CXCompilationDatabase.cpp
index 51677e7..1e4a2cd 100644
--- a/clang/tools/libclang/CXCompilationDatabase.cpp
+++ b/clang/tools/libclang/CXCompilationDatabase.cpp
@@ -16,8 +16,8 @@ clang_CompilationDatabase_fromDirectory(const char *BuildDir,
std::string ErrorMsg;
CXCompilationDatabase_Error Err = CXCompilationDatabase_NoError;
- CompilationDatabase *db = CompilationDatabase::loadFromDirectory(BuildDir,
- ErrorMsg);
+ std::unique_ptr<CompilationDatabase> db =
+ CompilationDatabase::loadFromDirectory(BuildDir, ErrorMsg);
if (!db) {
fprintf(stderr, "LIBCLANG TOOLING ERROR: %s\n", ErrorMsg.c_str());
@@ -27,7 +27,7 @@ clang_CompilationDatabase_fromDirectory(const char *BuildDir,
if (ErrorCode)
*ErrorCode = Err;
- return db;
+ return db.release();
}
void