From dff76894ff5fa710f8f453eaf1108440815988a7 Mon Sep 17 00:00:00 2001 From: Ted Kremenek Date: Sat, 17 Oct 2009 06:21:47 +0000 Subject: [PATCH] Resolve FIXME: delete the 'Program' object in the destructor of CIndexer. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84313 91177308-0d34-0410-b5e6-96231b3b80d8 --- tools/CIndex/CIndex.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/CIndex/CIndex.cpp b/tools/CIndex/CIndex.cpp index d355025da9..8d09b527b8 100644 --- a/tools/CIndex/CIndex.cpp +++ b/tools/CIndex/CIndex.cpp @@ -266,7 +266,9 @@ public: class CIndexer : public Indexer { public: - explicit CIndexer(Program &prog) : Indexer(prog), OnlyLocalDecls(false) { } + explicit CIndexer(Program *prog) : Indexer(*prog), OnlyLocalDecls(false) {} + + virtual ~CIndexer() { delete &getProgram(); } /// \brief Whether we only want to see "local" declarations (that did not /// come from a previous precompiled header). If false, we want to see all @@ -286,8 +288,6 @@ static const char *clangPath; CXIndex clang_createIndex() { - // FIXME: Program is leaked. - // Find the location where this library lives (libCIndex.dylib). // We do the lookup here to avoid poking dladdr too many times. // This silly cast below avoids a C++ warning. @@ -303,7 +303,7 @@ CXIndex clang_createIndex() clangPath = ClangPath.c_str(); - return new CIndexer(*new Program()); + return new CIndexer(new Program()); } void clang_disposeIndex(CXIndex CIdx) -- 2.50.1