diff options
author | Daniel Jasper <djasper@google.com> | 2016-03-03 17:34:14 +0000 |
---|---|---|
committer | Daniel Jasper <djasper@google.com> | 2016-03-03 17:34:14 +0000 |
commit | 94a96fcebee02b3785b68dd5fc980666a5e7ea41 (patch) | |
tree | 6f5938a147f14a2fa882910a1834d8fdd95577f8 /clang/lib | |
parent | faedfcbf6db7739bea35108b0b850490366145e3 (diff) | |
download | bcm5719-llvm-94a96fcebee02b3785b68dd5fc980666a5e7ea41.tar.gz bcm5719-llvm-94a96fcebee02b3785b68dd5fc980666a5e7ea41.zip |
clang-format: Use stable_sort when sorting #includes.
Otherwise, clang-format can output useless replacements in the presence
of identical #includes
llvm-svn: 262630
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/Format/Format.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp index c8f5ec9259d..91eac1328a2 100644 --- a/clang/lib/Format/Format.cpp +++ b/clang/lib/Format/Format.cpp @@ -1844,10 +1844,11 @@ static void sortIncludes(const FormatStyle &Style, SmallVector<unsigned, 16> Indices; for (unsigned i = 0, e = Includes.size(); i != e; ++i) Indices.push_back(i); - std::sort(Indices.begin(), Indices.end(), [&](unsigned LHSI, unsigned RHSI) { - return std::tie(Includes[LHSI].Category, Includes[LHSI].Filename) < - std::tie(Includes[RHSI].Category, Includes[RHSI].Filename); - }); + std::stable_sort( + Indices.begin(), Indices.end(), [&](unsigned LHSI, unsigned RHSI) { + return std::tie(Includes[LHSI].Category, Includes[LHSI].Filename) < + std::tie(Includes[RHSI].Category, Includes[RHSI].Filename); + }); // If the #includes are out of order, we generate a single replacement fixing // the entire block. Otherwise, no replacement is generated. |