diff options
author | Douglas Gregor <dgregor@apple.com> | 2010-02-18 23:07:20 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2010-02-18 23:07:20 +0000 |
commit | 0a812cf707da15dadd19fdeb0178b9707f4e01a6 (patch) | |
tree | cd14c995751ba3b257fc17194175b2ac8e767601 /tools/CIndex/CIndexCodeCompletion.cpp | |
parent | 9e0493576af77dba1c48858c03e31a2897d0681e (diff) |
Re-apply my diagnostics-capture patch for CIndex, with some tweaks to
try to address the msvc failures.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96624 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/CIndex/CIndexCodeCompletion.cpp')
-rw-r--r-- | tools/CIndex/CIndexCodeCompletion.cpp | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/tools/CIndex/CIndexCodeCompletion.cpp b/tools/CIndex/CIndexCodeCompletion.cpp index 9e8946381a..08510f2e55 100644 --- a/tools/CIndex/CIndexCodeCompletion.cpp +++ b/tools/CIndex/CIndexCodeCompletion.cpp @@ -177,6 +177,9 @@ static bool ReadUnsigned(const char *&Memory, const char *MemoryEnd, /// \brief The CXCodeCompleteResults structure we allocate internally; /// the client only sees the initial CXCodeCompleteResults structure. struct AllocatedCXCodeCompleteResults : public CXCodeCompleteResults { + AllocatedCXCodeCompleteResults(); + ~AllocatedCXCodeCompleteResults(); + /// \brief The memory buffer from which we parsed the results. We /// retain this buffer because the completion strings point into it. llvm::MemoryBuffer *Buffer; @@ -194,6 +197,16 @@ struct AllocatedCXCodeCompleteResults : public CXCodeCompleteResults { FileManager FileMgr; }; +AllocatedCXCodeCompleteResults::AllocatedCXCodeCompleteResults() + : CXCodeCompleteResults(), Buffer(0) { } + +AllocatedCXCodeCompleteResults::~AllocatedCXCodeCompleteResults() { + for (unsigned I = 0, N = NumResults; I != N; ++I) + delete (CodeCompletionString *)Results[I].CompletionString; + delete [] Results; + delete Buffer; +} + CXCodeCompleteResults *clang_codeComplete(CXIndex CIdx, const char *source_filename, int num_command_line_args, @@ -368,15 +381,6 @@ void clang_disposeCodeCompleteResults(CXCodeCompleteResults *ResultsIn) { AllocatedCXCodeCompleteResults *Results = static_cast<AllocatedCXCodeCompleteResults*>(ResultsIn); - - for (unsigned I = 0, N = Results->NumResults; I != N; ++I) - delete (CXCompletionString *)Results->Results[I].CompletionString; - delete [] Results->Results; - - Results->Results = 0; - Results->NumResults = 0; - delete Results->Buffer; - Results->Buffer = 0; delete Results; } |