[PATCH] D23434: Don't allow llvm-include-order to intermingle includes from different files.
Zachary Turner via cfe-commits
cfe-commits at lists.llvm.org
Thu Aug 11 16:32:28 PDT 2016
zturner updated this revision to Diff 67772.
zturner added a comment.
Fixed the test for this. Confirmed that it fails before the patch and succeeds after the patch.
https://reviews.llvm.org/D23434
Files:
clang-tidy/llvm/IncludeOrderCheck.cpp
test/clang-tidy/Inputs/Headers/cross-file-a.h
test/clang-tidy/Inputs/Headers/cross-file-b.h
test/clang-tidy/Inputs/Headers/cross-file-c.h
test/clang-tidy/llvm-include-order.cpp
Index: test/clang-tidy/llvm-include-order.cpp
===================================================================
--- test/clang-tidy/llvm-include-order.cpp
+++ test/clang-tidy/llvm-include-order.cpp
@@ -35,3 +35,8 @@
// CHECK-FIXES: #include "a.h"
// CHECK-FIXES-NEXT: #include "b.h"
+
+// CHECK-MESSAGES-NOT: [[@LINE+1]]:1: warning: #includes are not sorted properly
+#include "cross-file-c.h"
+
+#include "cross-file-a.h"
Index: test/clang-tidy/Inputs/Headers/cross-file-c.h
===================================================================
--- /dev/null
+++ test/clang-tidy/Inputs/Headers/cross-file-c.h
@@ -0,0 +1,41 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+#include "cross-file-b.h"
Index: clang-tidy/llvm/IncludeOrderCheck.cpp
===================================================================
--- clang-tidy/llvm/IncludeOrderCheck.cpp
+++ clang-tidy/llvm/IncludeOrderCheck.cpp
@@ -73,6 +73,9 @@
SourceLocation HashLoc, const Token &IncludeTok, StringRef FileName,
bool IsAngled, CharSourceRange FilenameRange, const FileEntry *File,
StringRef SearchPath, StringRef RelativePath, const Module *Imported) {
+ if (SM.getFileID(HashLoc) != SM.getMainFileID())
+ return;
+
// We recognize the first include as a special main module header and want
// to leave it in the top position.
IncludeDirective ID = {HashLoc, FilenameRange, FileName, IsAngled, false};
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D23434.67772.patch
Type: text/x-patch
Size: 1481 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160811/a7466e63/attachment-0001.bin>
More information about the cfe-commits
mailing list