[cfe-dev] [clang-format] Sort include does not handle pre-compiled headers well.

Jean-philippe Dufraigne via cfe-dev cfe-dev at lists.llvm.org
Sun Dec 6 10:17:43 PST 2015


Hi Daniel,
Sorry, I sent the initial message to the wrong list.

When using pre-compiled header, the Main Header for the file will not be
detected since the first header needs to be the precompiled header.

I was looking at fixing it, but I am not quite sure how to go fixing it?

This will result in the main header being moved.

Expected:
MyFile.cpp:

  #include "stdafx.h"
  #include "MyFile.h"
  #include "AnotherHeader.h"

Actual:
MyFile.cpp:

  #include "stdafx.h"
  #include "AnotherHeader.h"
  #include "MyFile.h"

This can be somewhat worked around by leaving a line after the Main Header.

Fix Option 1:
Add a new option: PercompiledHeaderRegEx, and if detected assign priority
-1, and keep on looking for MainHeader (Not great since we use unsigned)

Fix Option 2:
Add a keyword that can be used instead of the regular expression to refer
to the MainHeader. This way one can add a regular expression for the
pre-compiled header priority 0, and one for MainHeader priority 1. Consider
it main header if first header with category >= MainHeaderCategory.

Fix Option 3:
A better plan?

Do you have any thought on the problem?
Kind Regards,
Jean-Philippe.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20151206/f7a6fd35/attachment.html>


More information about the cfe-dev mailing list