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"}),
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"}),
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits