]> granicus.if.org Git - clang/commitdiff
Resolve FIXME: delete the 'Program' object in the destructor of CIndexer.
authorTed Kremenek <kremenek@apple.com>
Sat, 17 Oct 2009 06:21:47 +0000 (06:21 +0000)
committerTed Kremenek <kremenek@apple.com>
Sat, 17 Oct 2009 06:21:47 +0000 (06:21 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84313 91177308-0d34-0410-b5e6-96231b3b80d8

tools/CIndex/CIndex.cpp

index d355025da918fb6087e78497da2135079e7bce52..8d09b527b826f9d1b47fe707fb61e8198ba2c0f5 100644 (file)
@@ -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)