Formatting

This commit is contained in:
David Ungar
2018-03-09 20:11:22 -08:00
parent c9db72c1cb
commit ba1a714dbe
10 changed files with 185 additions and 142 deletions

View File

@@ -47,8 +47,11 @@ public:
static llvm::Expected<OutputFileMap>
loadFromBuffer(StringRef Data, StringRef workingDirectory);
/// Loads into the OutputFileMap receiver from the given \p Buffer, taking
/// ownership of the buffer in the process.
/// Loads an OutputFileMap from the given \p Buffer, taking ownership
/// of the buffer in the process.
///
/// When non-empty, \p workingDirectory is used to resolve relative paths in
/// the output file map.
static llvm::Expected<OutputFileMap>
loadFromBuffer(std::unique_ptr<llvm::MemoryBuffer> Buffer,
StringRef workingDirectory);

View File

@@ -20,64 +20,72 @@
namespace swift {
namespace types {
enum ID : uint8_t {
enum ID : uint8_t {
#define TYPE(NAME, ID, TEMP_SUFFIX, FLAGS) TY_##ID,
#include "swift/Frontend/Types.def"
#undef TYPE
TY_INVALID
};
TY_INVALID
};
/// Return the name of the type for \p Id.
StringRef getTypeName(ID Id);
/// Return the name of the type for \p Id.
StringRef getTypeName(ID Id);
/// Return the suffix to use when creating a temp file of this type,
/// or null if unspecified.
StringRef getTypeTempSuffix(ID Id);
/// Return the suffix to use when creating a temp file of this type,
/// or null if unspecified.
StringRef getTypeTempSuffix(ID Id);
/// Lookup the type to use for the file extension \p Ext.
/// If the extension is empty or is otherwise not recognized, return
/// the invalid type \c TY_INVALID.
ID lookupTypeForExtension(StringRef Ext);
/// Lookup the type to use for the file extension \p Ext.
/// If the extension is empty or is otherwise not recognized, return
/// the invalid type \c TY_INVALID.
ID lookupTypeForExtension(StringRef Ext);
/// Lookup the type to use for the name \p Name.
ID lookupTypeForName(StringRef Name);
/// Lookup the type to use for the name \p Name.
ID lookupTypeForName(StringRef Name);
/// Returns true if the type represents textual data.
bool isTextual(ID Id);
/// Returns true if the type represents textual data.
bool isTextual(ID Id);
/// Returns true if the type is produced in the compiler after the LLVM
/// passes.
///
/// For those types the compiler produces multiple output files in multi-
/// threaded compilation.
bool isAfterLLVM(ID Id);
/// Returns true if the type is produced in the compiler after the LLVM
/// passes.
///
/// For those types the compiler produces multiple output files in multi-
/// threaded compilation.
bool isAfterLLVM(ID Id);
/// Returns true if the type is a file that contributes to the Swift module
/// being compiled.
///
/// These need to be passed to the Swift frontend
bool isPartOfSwiftCompilation(ID Id);
/// Returns true if the type is a file that contributes to the Swift module
/// being compiled.
///
/// These need to be passed to the Swift frontend
bool isPartOfSwiftCompilation(ID Id);
template <typename Fn> void forAllTypes(const Fn &fn);
template <typename Fn>
void forAllTypes(const Fn &fn);
} // end namespace types
} // end namespace swift
namespace llvm {
template <> struct DenseMapInfo<swift::types::ID> {
using ID = swift::types::ID;
static inline ID getEmptyKey() { return ID::TY_INVALID; }
static inline ID getTombstoneKey() {
return static_cast<ID>(ID::TY_INVALID + 1);
}
static unsigned getHashValue(ID Val) { return (unsigned)Val * 37U; }
static bool isEqual(ID LHS, ID RHS) { return LHS == RHS; }
};
} // namespace llvm
template<>
struct DenseMapInfo<swift::types::ID> {
using ID = swift::types::ID;
static inline ID getEmptyKey() {
return ID::TY_INVALID;
}
static inline ID getTombstoneKey() {
return static_cast<ID>(ID::TY_INVALID + 1);
}
static unsigned getHashValue(ID Val) {
return (unsigned)Val * 37U;
}
static bool isEqual(ID LHS, ID RHS) {
return LHS == RHS;
}
};
}
template <typename Fn> void swift::types::forAllTypes(const Fn &fn) {
static_assert(
std::is_constructible<std::function<void(types::ID)>, Fn>::value,
"must have the signature 'void(types::ID)'");
template <typename Fn>
void swift::types::forAllTypes(const Fn &fn) {
static_assert(std::is_constructible<std::function<void(types::ID)>,Fn>::value,
"must have the signature 'void(types::ID)'");
for (uint8_t i = 0; i < static_cast<uint8_t>(TY_INVALID); ++i)
fn(static_cast<ID>(i));
}