diff options
author | Alexander Kornienko <alexfh@google.com> | 2017-01-12 15:31:50 +0000 |
---|---|---|
committer | Alexander Kornienko <alexfh@google.com> | 2017-01-12 15:31:50 +0000 |
commit | 1b8b112db49703cd105357ce4e23aa4f08eb718c (patch) | |
tree | 8a344777828fe219508db7b7806362bac6934813 /clang-tidy/utils | |
parent | c21e894ea6c2b6fa3204f68e340b786dd35b41b7 (diff) |
Correctly classify main file includes if there is a prefix added
Summary:
Prevents misclassifying includes based on the command-line filename (e.g. if a project is in a subdirectory).
This is slightly more robust than the additional duplicate detection, however the current classification scheme is still kind of brittle for a lot of code.
Reviewers: hokein, alexfh
Subscribers: cfe-commits, #clang-tools-extra
Patch by Julian Bangert!
Differential Revision: https://reviews.llvm.org/D26015
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@291767 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'clang-tidy/utils')
-rw-r--r-- | clang-tidy/utils/IncludeSorter.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/clang-tidy/utils/IncludeSorter.cpp b/clang-tidy/utils/IncludeSorter.cpp index 2a8a9780..1502da76 100644 --- a/clang-tidy/utils/IncludeSorter.cpp +++ b/clang-tidy/utils/IncludeSorter.cpp @@ -61,7 +61,8 @@ DetermineIncludeKind(StringRef CanonicalFile, StringRef IncludeFile, : IncludeSorter::IK_CXXSystemInclude; } StringRef CanonicalInclude = MakeCanonicalName(IncludeFile, Style); - if (CanonicalFile.equals(CanonicalInclude)) { + if (CanonicalFile.endswith(CanonicalInclude) + || CanonicalInclude.endswith(CanonicalFile)) { return IncludeSorter::IK_MainTUInclude; } if (Style == IncludeSorter::IS_Google) { |