<div dir="ltr">Stumbling over this (much too late, of course), is this still a problem for you?</div><br><div class="gmail_quote"><div dir="ltr">On Thu, Nov 26, 2015 at 5:01 PM jean-yves desbree via cfe-commits <<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>I use clang 3.6.2 with qt creator 3.5.1 on windows 7 for parsing code in this IDE.</div><div>It works well.</div><div><br></div><div>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).</div><div>The effect is that we cannot save these h files, what is quite frustrating when using an IDE.</div><div><br></div><div>After debugging clang, I remarked that there was a file descriptor leak in the method Preprocessor::HandleIncludeDirective</div><div>(file tools/clang/lib/Lex/PPDirectives.cpp)</div><div><br></div><div>The object 'FileEntry *File' is created (for a given h file) and after some checks, the regular treatment calls EnterSourceFile.</div><div>The File object is detroyed during this call (quite deeply in the stack)</div><div><br></div><div>However, when some errors occur, the execution path goes through early returns and other code pathes.</div><div>In this case, the file descriptor associated to File is not closed and the file descriptor remains open.</div><div><br></div><div>So I did a correction that uses RAII in order to have the file descriptor closed.</div><div>So I wrapped 'FileEntry *File' in a dedicated 'FileEntryCloser fileEntryCloser(File)'</div><div><br></div><div>On regular treatment, the closer is released:</div><div> // If all is good, enter the new file!</div><div> if (EnterSourceFile(FID, CurDir, FilenameTok.getLocation()))</div><div> {</div><div> fileEntryCloser.release();</div><div> return;</div><div> }</div><div> </div><div>Otherwise, the file descriptor is closed </div><div> ~FileEntryCloser()</div><div> {</div><div> if(m_File)</div><div> m_File->closeFile();</div><div> }</div><div><br></div><div><br></div><div>Now, I have no more remaining file descriptors ...</div><div>Would it be possible to have an evaluation on that?</div><div><br></div><div>Thanks in advance.</div></div>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><br>
</blockquote></div>