[cfe-commits] r84313 - /cfe/trunk/tools/CIndex/CIndex.cpp

Ted Kremenek kremenek at apple.com
Fri Oct 16 23:21:47 PDT 2009


Author: kremenek
Date: Sat Oct 17 01:21:47 2009
New Revision: 84313

URL: http://llvm.org/viewvc/llvm-project?rev=84313&view=rev
Log:
Resolve FIXME: delete the 'Program' object in the destructor of CIndexer.

Modified:
    cfe/trunk/tools/CIndex/CIndex.cpp

Modified: cfe/trunk/tools/CIndex/CIndex.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/CIndex/CIndex.cpp?rev=84313&r1=84312&r2=84313&view=diff

==============================================================================
--- cfe/trunk/tools/CIndex/CIndex.cpp (original)
+++ cfe/trunk/tools/CIndex/CIndex.cpp Sat Oct 17 01:21:47 2009
@@ -266,7 +266,9 @@
 
 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 @@
 
 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 @@
   
   clangPath = ClangPath.c_str();
   
-  return new CIndexer(*new Program());
+  return new CIndexer(new Program());
 }
 
 void clang_disposeIndex(CXIndex CIdx)





More information about the cfe-commits mailing list