hanchenye-llvm-project/clang/tools/clang-format-vs
Daniel Jasper 36e979af73 clang-format sort include use the source file name to determine the
"main include" that will be the 1st include (category 0).

Because the clang-format visual studio extension does not pass the file
name and use the standard input, sort include cannot find a "main
include":

Testing fix on llvm\tools\clang\lib\Format\Format.cpp:
Original file:
  #include "clang/Format/Format.h"
  ...
  #include "clang/Basic/SourceManager.h"
  #include "clang/Lex/Lexer.h"

Without fix, selecting the includes and running visual studio
clang-format:
  ...
  #include "clang/Basic/SourceManager.h"
  #include "clang/Format/Format.h"
  #include "clang/Lex/Lexer.h"

With fix, selecting the includes and running visual studio clang-format:
  #include "clang/Format/Format.h"
  ...
  #include "clang/Basic/SourceManager.h"
  #include "clang/Lex/Lexer.h"

Test 2 with main header not at the start:
Original file:
  ...
  #include "clang/Format/Format.h"
  #include "clang/Basic/SourceManager.h"
  #include "clang/Lex/Lexer.h"

Without fix, selecting the includes and running visual studio
clang-format:
  ...
  #include "clang/Basic/SourceManager.h"
  #include "clang/Format/Format.h"
  #include "clang/Lex/Lexer.h"

With fix, selecting the includes and running visual studio clang-format:
  #include "clang/Format/Format.h"
  ...
  #include "clang/Basic/SourceManager.h"
  #include "clang/Lex/Lexer.h"

Patch by Jean-Philippe Dufraigne, thank you.
Review: http://reviews.llvm.org/D16524

llvm-svn: 260378
2016-02-10 12:42:58 +00:00
..
ClangFormat clang-format sort include use the source file name to determine the 2016-02-10 12:42:58 +00:00
CMakeLists.txt
ClangFormat.sln
README.txt Update clang-format-vs README 2015-12-08 17:54:27 +00:00
source.extension.vsixmanifest.in

README.txt

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This directory contains a VSPackage project to generate a Visual Studio extension
for clang-format.

Build prerequisites are:
- Visual Studio 2013 Professional
- Visual Studio 2013 SDK
- Visual Studio 2010 Professional (?)
- Visual Studio 2010 SDK (?)

The extension is built using CMake by setting BUILD_CLANG_FORMAT_VS_PLUGIN=ON
when configuring a Clang build, and building the clang_format_vsix target.

The CMake build will copy clang-format.exe and LICENSE.TXT into the ClangFormat/
directory so they can be bundled with the plug-in, as well as creating
ClangFormat/source.extension.vsixmanifest. Once the plug-in has been built with
CMake once, it can be built manually from the ClangFormat.sln solution in Visual
Studio.