[llvm-bugs] [Bug 25741] New: libclang/Windows: preamble file is not deleted on clang_disposeTranslationUnit()

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Dec 4 08:21:46 PST 2015


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

            Bug ID: 25741
           Summary: libclang/Windows: preamble file is not deleted on
                    clang_disposeTranslationUnit()
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Windows 2000
            Status: NEW
          Severity: normal
          Priority: P
         Component: libclang
          Assignee: unassignedclangbugs at nondot.org
          Reporter: nikolai.kosjar at theqtcompany.com
                CC: klimek at google.com, llvm-bugs at lists.llvm.org
    Classification: Unclassified

Generated preamble files are deleted on Linux, but not on Windows. As a result,
the preamble files accumulate in %TEMP% until the disk is full. Preamble files
up to 20MB are not unusual for some *.cpp files.

Reproducible with libclang 3.6.2 and libclang from trunk (3.8, r253269).

Used test code (pass in a suitable file):

  #include <clang-c/Index.h>

  #include <cstdlib>
  #include <cstdio>
  #include <vector>

  int main(int argc, char *argv[])
  {
      if (argc != 2) {
          fprintf(stderr, "Usage: $0 <file>\n");
          return 0;
      }
      const char *filePath = argv[1];

      // Construct parse arguments
      std::vector<const char *> arguments;
      arguments.push_back(filePath);

      // Parse
      CXIndex index = clang_createIndex(0, /*displayDiagnostics*/ 1);
      const unsigned tuOptions = CXTranslationUnit_PrecompiledPreamble;
      CXTranslationUnit tu = clang_parseTranslationUnit(index,
                                                        NULL,
                                                        arguments.data(),
                                                        arguments.size(),
                                                        NULL,
                                                        0,
                                                        tuOptions);

      // Re-parse in order to create the preamble file
      clang_reparseTranslationUnit(tu, NULL, 0, 0);

      // Dispose the TU + index
      clang_disposeTranslationUnit(tu);
      clang_disposeIndex(index);

      return 0;
  }

-- 
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/20151204/8668dd75/attachment.html>


More information about the llvm-bugs mailing list