I use clang 3.6.2 with qt creator 3.5.1 on windows 7 for parsing code in this IDE. It works well.
However, I can see that clang keeps a few times some file descriptors opened on c++ header files (h files) after having parsed a cpp file (that includes these h files). The effect is that we cannot save these h files, what is quite frustrating when using an IDE. After debugging clang, I remarked that there was a file descriptor leak in the method Preprocessor::HandleIncludeDirective (file tools/clang/lib/Lex/PPDirectives.cpp) The object 'FileEntry *File' is created (for a given h file) and after some checks, the regular treatment calls EnterSourceFile. The File object is detroyed during this call (quite deeply in the stack) However, when some errors occur, the execution path goes through early returns and other code pathes. In this case, the file descriptor associated to File is not closed and the file descriptor remains open. So I did a correction that uses RAII in order to have the file descriptor closed. So I wrapped 'FileEntry *File' in a dedicated 'FileEntryCloser fileEntryCloser(File)' On regular treatment, the closer is released: // If all is good, enter the new file! if (EnterSourceFile(FID, CurDir, FilenameTok.getLocation())) { fileEntryCloser.release(); return; } Otherwise, the file descriptor is closed ~FileEntryCloser() { if(m_File) m_File->closeFile(); } Now, I have no more remaining file descriptors ... Would it be possible to have an evaluation on that? Thanks in advance.
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits