[llvm-bugs] [Bug 35259] New: libclang: clang_disposeTranslationUnit does not delete .pch files

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Nov 9 02:10:53 PST 2017


https://bugs.llvm.org/show_bug.cgi?id=35259

            Bug ID: 35259
           Summary: libclang: clang_disposeTranslationUnit does not delete
                    .pch files
           Product: clang
           Version: 5.0
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: libclang
          Assignee: unassignedclangbugs at nondot.org
          Reporter: william.ledoux at gmail.com
                CC: klimek at google.com, llvm-bugs at lists.llvm.org

SYMPTOM
=======

libclang clang_disposeTranslationUnit seems not to delete the .pch that was
generated

It's a problem because when using libclang for code completion, a lot of those
files are created and never deleted. 
On Windows, it gets bad because the temp folder is not cleaned at boot
If the temp folder is a ramdisk, it's even worse because it can fill it up
really quickly.

HOW TO REPRODUCE
================

The bug is very old (at least a couple of years) so I guess any version would
reproduce, but for the record the latest I tried was the head of release_50 on
both LLVM and CLANG projects

LLVM:
https://github.com/llvm-mirror/llvm/commit/f042b00be5f69c21b3fe846f7343dd44ed92a74e

CLANG:
https://github.com/llvm-mirror/clang/commit/232230afd349ceeb784720d2266e2288523d871f

PLATFORM: libclang.dll compiled and tested with VS2015 on Windows 7 64 bit

To reproduce, you need to create a dummy test.cpp file and parse it as follow:

CXIndex ClangIndex = clang_createIndex(false, true);
CXTranslationUnit myTU = clang_parseTranslationUnit(ClangIndex, "test.cpp",
NULL, 0, NULL, 0, CXTranslationUnit_PrecompiledPreamble  |
CXTranslationUnit_CreatePreambleOnFirstParse);

// If myTU is not NULL, some preamble-%%%%%%.pch has been created 
// in temp folder and a handle is hold on this file

clang_disposeTranslationUnit(myTU);

// The handle has been released but the preamble-%%%%%%.pch is still there

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20171109/485197f3/attachment.html>


More information about the llvm-bugs mailing list