[AST] Make ValueDecls displayable via their DeclRefs.

This commit is contained in:
Doug Gregor
2018-06-21 06:24:55 -07:00
parent b6c5830277
commit 81bee08369
4 changed files with 40 additions and 2 deletions

View File

@@ -25,7 +25,36 @@
namespace swift {
template<typename T>
void simple_display(llvm::raw_ostream &out, const T &value) {
struct HasTrivialDisplay {
static const bool value = false;
};
#define HAS_TRIVIAL_DISPLAY(Type) \
template<> \
struct HasTrivialDisplay<Type> { \
static const bool value = true; \
}
HAS_TRIVIAL_DISPLAY(unsigned char);
HAS_TRIVIAL_DISPLAY(signed char);
HAS_TRIVIAL_DISPLAY(char);
HAS_TRIVIAL_DISPLAY(short);
HAS_TRIVIAL_DISPLAY(unsigned short);
HAS_TRIVIAL_DISPLAY(int);
HAS_TRIVIAL_DISPLAY(unsigned int);
HAS_TRIVIAL_DISPLAY(long);
HAS_TRIVIAL_DISPLAY(unsigned long);
HAS_TRIVIAL_DISPLAY(long long);
HAS_TRIVIAL_DISPLAY(unsigned long long);
HAS_TRIVIAL_DISPLAY(float);
HAS_TRIVIAL_DISPLAY(double);
HAS_TRIVIAL_DISPLAY(bool);
#undef HAS_TRIVIAL_DISPLAY
template<typename T>
typename std::enable_if<HasTrivialDisplay<T>::value>::type
simple_display(llvm::raw_ostream &out, const T &value) {
out << value;
}