aboutsummaryrefslogtreecommitdiff
path: root/tools/CIndex/CIndexCodeCompletion.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2010-02-18 23:35:40 +0000
committerDouglas Gregor <dgregor@apple.com>2010-02-18 23:35:40 +0000
commit313e26c4e81f0e467490a530548450f4c824a6c4 (patch)
tree60d86a9e8ca3982724716e4b12dee9fa39f0ec4e /tools/CIndex/CIndexCodeCompletion.cpp
parent0a812cf707da15dadd19fdeb0178b9707f4e01a6 (diff)
Teach ASTUnit to keep track of temporary files, then delete them when
the ASTUnit itself is destroyed. Fixes <rdar://problem/7649385>. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96628 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/CIndex/CIndexCodeCompletion.cpp')
-rw-r--r--tools/CIndex/CIndexCodeCompletion.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/tools/CIndex/CIndexCodeCompletion.cpp b/tools/CIndex/CIndexCodeCompletion.cpp
index 08510f2e55..b646474c81 100644
--- a/tools/CIndex/CIndexCodeCompletion.cpp
+++ b/tools/CIndex/CIndexCodeCompletion.cpp
@@ -195,6 +195,10 @@ struct AllocatedCXCodeCompleteResults : public CXCodeCompleteResults {
/// \brief File manager, used for diagnostics.
FileManager FileMgr;
+
+ /// \brief Temporary files that should be removed once we have finished
+ /// with the code-completion results.
+ std::vector<llvm::sys::Path> TemporaryFiles;
};
AllocatedCXCodeCompleteResults::AllocatedCXCodeCompleteResults()
@@ -205,6 +209,9 @@ AllocatedCXCodeCompleteResults::~AllocatedCXCodeCompleteResults() {
delete (CodeCompletionString *)Results[I].CompletionString;
delete [] Results;
delete Buffer;
+
+ for (unsigned I = 0, N = TemporaryFiles.size(); I != N; ++I)
+ TemporaryFiles[I].eraseFromDisk();
}
CXCodeCompleteResults *clang_codeComplete(CXIndex CIdx,
@@ -369,8 +376,9 @@ CXCodeCompleteResults *clang_codeComplete(CXIndex CIdx,
Results->FileMgr, Results->SourceMgr,
Results->Diagnostics);
- for (unsigned i = 0, e = TemporaryFiles.size(); i != e; ++i)
- TemporaryFiles[i].eraseFromDisk();
+ // Make sure we delete temporary files when the code-completion results are
+ // destroyed.
+ Results->TemporaryFiles.swap(TemporaryFiles);
return Results;
}