mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[driver] Implemented support for -driver-print-output-file-map.
This option asks the driver to print its OutputFileMap. To support this, added OutputFileMap::dump(). Swift SVN r12773
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
|
||||
#include "llvm/ADT/OwningPtr.h"
|
||||
#include "llvm/ADT/StringRef.h"
|
||||
#include "llvm/Support/raw_ostream.h"
|
||||
#include "llvm/Support/system_error.h"
|
||||
|
||||
using namespace swift;
|
||||
@@ -52,6 +53,44 @@ const TypeToPathMap *OutputFileMap::getOutputMapForInput(StringRef Input) const{
|
||||
return &iter->second;
|
||||
}
|
||||
|
||||
void OutputFileMap::dump(llvm::raw_ostream &os, bool Sort) const {
|
||||
typedef std::pair<types::ID, std::string> TypePathPair;
|
||||
|
||||
auto printOutputPair = [&os] (StringRef InputPath,
|
||||
const TypePathPair &OutputPair) -> void {
|
||||
os << InputPath << " -> " << types::getTypeName(OutputPair.first) << ": \""
|
||||
<< OutputPair.second << "\"\n";
|
||||
};
|
||||
|
||||
if (Sort) {
|
||||
typedef std::pair<StringRef, TypeToPathMap> PathMapPair;
|
||||
std::vector<PathMapPair> Maps;
|
||||
for (auto &InputPair : InputToOutputsMap) {
|
||||
Maps.emplace_back(InputPair.first(), InputPair.second);
|
||||
}
|
||||
std::sort(Maps.begin(), Maps.end(), [] (const PathMapPair &LHS,
|
||||
const PathMapPair &RHS) -> bool {
|
||||
return LHS.first < RHS.first;
|
||||
});
|
||||
for (auto &InputPair : Maps) {
|
||||
const TypeToPathMap &Map = InputPair.second;
|
||||
std::vector<TypePathPair> Pairs;
|
||||
Pairs.insert(Pairs.end(), Map.begin(), Map.end());
|
||||
std::sort(Pairs.begin(), Pairs.end());
|
||||
for (auto &OutputPair : Pairs) {
|
||||
printOutputPair(InputPair.first, OutputPair);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (auto &InputPair : InputToOutputsMap) {
|
||||
const TypeToPathMap &Map = InputPair.second;
|
||||
for (const TypePathPair &OutputPair : Map) {
|
||||
printOutputPair(InputPair.first(), OutputPair);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool OutputFileMap::parse(llvm::MemoryBuffer *Buffer) {
|
||||
llvm::SourceMgr SM;
|
||||
llvm::yaml::Stream YAMLStream(Buffer, SM);
|
||||
|
||||
Reference in New Issue
Block a user