mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-09-24 23:28:41 +00:00
Implement order-preserving option forwarding.
Needed to correctly handle things like 'llvmc -framework Foo foo.o -framework Bar bar.o' - before this commit all '-framework' options would've been grouped together in the beginning. Due to our dependence on CommandLine this turned out to be a giant hack; we will migrate away from CommandLine eventually. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96922 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -17,6 +17,8 @@
|
||||
#include "llvm/ADT/StringExtras.h"
|
||||
#include "llvm/System/Path.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
using namespace llvm;
|
||||
using namespace llvmc;
|
||||
|
||||
@@ -72,11 +74,21 @@ sys::Path Tool::OutFilename(const sys::Path& In,
|
||||
return Out;
|
||||
}
|
||||
|
||||
namespace {
|
||||
template <class A, class B>
|
||||
bool CompareFirst (std::pair<A,B> p1, std::pair<A,B> p2) {
|
||||
return std::less<A>()(p1.first, p2.first);
|
||||
}
|
||||
}
|
||||
|
||||
StrVector Tool::SortArgs(ArgsVector& Args) const {
|
||||
StrVector Out;
|
||||
|
||||
for (ArgsVector::iterator B = Args.begin(), E = Args.end(); B != E; ++B)
|
||||
// HACK: this won't be needed when we'll migrate away from CommandLine.
|
||||
std::stable_sort(Args.begin(), Args.end(), &CompareFirst<unsigned, std::string>);
|
||||
for (ArgsVector::iterator B = Args.begin(), E = Args.end(); B != E; ++B) {
|
||||
Out.push_back(B->second);
|
||||
}
|
||||
|
||||
return Out;
|
||||
}
|
||||
|
Reference in New Issue
Block a user