#include "llvm/CompilerDriver/BuiltinOptions.h"
#include "llvm/CompilerDriver/Tool.h"
-#include "llvm/System/Path.h"
+#include "llvm/ADT/StringExtras.h"
+#include "llvm/Support/Path.h"
+
+#include <algorithm>
using namespace llvm;
using namespace llvmc;
sys::Path Out;
if (StopCompilation) {
- if (!OutputFilename.empty() && SaveTemps != SaveTempsEnum::Obj ) {
+ if (!OutputFilename.empty()) {
Out.set(OutputFilename);
}
else if (IsJoin()) {
Out.appendSuffix(OutputSuffix);
}
else {
- Out.set(In.getBasename());
+ Out.set(sys::path::stem(In.str()));
Out.appendSuffix(OutputSuffix);
}
}
if (IsJoin())
Out = MakeTempFile(TempDir, "tmp", OutputSuffix);
else
- Out = MakeTempFile(TempDir, In.getBasename(), OutputSuffix);
+ Out = MakeTempFile(TempDir, sys::path::stem(In.str()), OutputSuffix);
+ }
+ 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;
+
+ // 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;
}