[PATCH] D89608: Make sure Objective-C category support in IncludeSorter handles top-level imports
Joe Turner via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Oct 16 17:21:47 PDT 2020
compositeprimes created this revision.
compositeprimes added reviewers: alexfh, gribozavr.
compositeprimes added a project: clang-tools-extra.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
compositeprimes requested review of this revision.
Currently, this would not correctly associate a category with the related include if it was top-level (i.e. no slashes in the path). This ensures that we explicitly think about that case.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D89608
Files:
clang-tools-extra/clang-tidy/utils/IncludeSorter.cpp
Index: clang-tools-extra/clang-tidy/utils/IncludeSorter.cpp
===================================================================
--- clang-tools-extra/clang-tidy/utils/IncludeSorter.cpp
+++ clang-tools-extra/clang-tidy/utils/IncludeSorter.cpp
@@ -45,8 +45,12 @@
// Objective-C categories have a `+suffix` format, but should be grouped
// with the file they are a category of.
+ size_t start_index = Canonical.find_last_of('/');
+ if (start_index == StringRef::npos) {
+ start_index = 0;
+ }
return Canonical.substr(
- 0, Canonical.find_first_of('+', Canonical.find_last_of('/')));
+ 0, Canonical.find_first_of('+', start_index));
}
return RemoveFirstSuffix(
RemoveFirstSuffix(Str, {".cc", ".cpp", ".c", ".h", ".hpp"}),
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D89608.298789.patch
Type: text/x-patch
Size: 776 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20201017/a852a633/attachment.bin>
More information about the cfe-commits
mailing list