diff --git a/clang/lib/AST/Interp/Boolean.h b/clang/lib/AST/Interp/Boolean.h index 336f7941dfc479..1bfb26b1b669f9 100644 --- a/clang/lib/AST/Interp/Boolean.h +++ b/clang/lib/AST/Interp/Boolean.h @@ -45,15 +45,10 @@ class Boolean final { Boolean operator-(const Boolean &Other) const { return Boolean(V - Other.V); } Boolean operator~() const { return Boolean(true); } - explicit operator int8_t() const { return V; } - explicit operator uint8_t() const { return V; } - explicit operator int16_t() const { return V; } - explicit operator uint16_t() const { return V; } - explicit operator int32_t() const { return V; } - explicit operator uint32_t() const { return V; } - explicit operator int64_t() const { return V; } - explicit operator uint64_t() const { return V; } - explicit operator bool() const { return V; } + template >> + explicit operator Ty() const { + return V; + } APSInt toAPSInt() const { return APSInt(APInt(1, static_cast(V), false), true); diff --git a/clang/lib/AST/Interp/Integral.h b/clang/lib/AST/Interp/Integral.h index cc1cab8f39fb1e..db4cc9ae45b491 100644 --- a/clang/lib/AST/Interp/Integral.h +++ b/clang/lib/AST/Interp/Integral.h @@ -98,10 +98,10 @@ template class Integral final { return Integral(V); } - explicit operator unsigned() const { return V; } - explicit operator int64_t() const { return V; } - explicit operator uint64_t() const { return V; } - explicit operator int32_t() const { return V; } + template >> + explicit operator Ty() const { + return V; + } APSInt toAPSInt() const { return APSInt(APInt(Bits, static_cast(V), Signed), !Signed);