[PATCH] [clang-tidy] Implement the include order checker for LLVM.
Alexander Kornienko
alexfh at google.com
Fri Aug 1 07:35:16 PDT 2014
================
Comment at: clang-tidy/llvm/IncludeOrderCheck.cpp:51
@@ +50,3 @@
+ // We store a copy of the name and context pointer because clang checks die
+ // before PPCallbacks get an EndOfMainFile call.
+ Compiler.getPreprocessor().addPPCallbacks(new IncludeOrderPPCallbacks(
----------------
It's wrong to do something here after the check dies. We either need to fix the order of the EndOfMainFile call (it seems to be better to call it before EndSourceFileAction in FrontendAction::EndSourceFile()) or perform the analysis in a different callback.
================
Comment at: clang-tidy/llvm/IncludeOrderCheck.cpp:78
@@ +77,3 @@
+ while (Text[Offset] != '\0') {
+ // The end of a line can be of three forms: '\r' (old MacOS), '\n' (UNIX),
+ // or '\r\n' (DOS). Check for '\n' to cover UNIX and DOS style. or '\r'
----------------
So why do we care about CR line endings? ClangFormat doesn't support them, for example, and we didn't get any requests to add support for them, afaik.
================
Comment at: clang-tidy/llvm/IncludeOrderCheck.cpp:112
@@ +111,3 @@
+ // Form blocks of includes. We don't want to sort across blocks. This also
+ // implicitly makes #defines and #if block include sorting.
+ // FIXME: We should be more careful about sorting below comments as we don't
----------------
Does "block include sorting" correctly describe what really happens? Don't #define/#if just delimit blocks of includes?
http://reviews.llvm.org/D4741
More information about the cfe-commits
mailing list