<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - libclang should not require that a CXUnsavedFile should exist on disk"
   href="https://llvm.org/bugs/show_bug.cgi?id=31112">31112</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>libclang should not require that a CXUnsavedFile should exist on disk
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>3.9
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>libclang
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>nikolai.kosjar@qt.io
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>klimek@google.com, llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>The documentation [1] states that an unsaved file must exist on disk. This
requirement makes it hard to implement IDEs supporting in-memory files of code
generators.

If the libclang client provides unsaved files that do not exist on disk yet,
the preamble generation will be part of every parse/reparse/completion
operation, at least if CXTranslationUnit_PrecompiledPreamble is used and as a
result, all those operations will be very slow.

The specific case we have in Qt / Qt Creator:

A Qt project can contain *.ui files. Those are the input for the uic tool,
which generates "ui_*.h" header files. Part of the Qt Creator IDE is the
feature that a *.ui file can be edited and behind the scenes the "ui_*.h"
header will be updated automatically (without saving anything to disk; writing
into the build directory is not an option), so that highlighting/completion in
a *.cpp files including that header file will reflect those changes. This works
fine as long unsaved file exist on disk (e.g. project was already build), but
for the case that a project is opened for the very first time (no ui_*.h files
generated yet on disk) or some new *.ui files are just added to the project
this will result in the described performance regression.

Also, because of the resulting performance regression once the requirement is
not fulfilled, special care needs to be taken to check the unsaved files for
actual existence in the file system.

Please remove this requirement and fix the described performance issue.

[1]
<a href="http://clang.llvm.org/doxygen/structCXUnsavedFile.html#aa8bf5d4351628ee8502b517421e8b418">http://clang.llvm.org/doxygen/structCXUnsavedFile.html#aa8bf5d4351628ee8502b517421e8b418</a></pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>