Closed
Description
ToT Clang hangs when building under -O1.
clang++ test.i -fno-exceptions -O1 -c -emit-llvm
The reproducer, test.i
:
class MockDevice;
struct sp {
MockDevice operator*();
};
void memset(void *__dest, int __ch, unsigned __len) {
long __trans_tmp_1 = __builtin_object_size(__dest, 0);
__builtin___memset_chk(__dest, __ch, __len, __trans_tmp_1);
}
template <class>
class function;
template <class _Rp, class... _ArgTypes>
class function<_Rp(_ArgTypes...)> {
public:
template <class _Fp>
function operator=(_Fp);
};
template <typename T>
struct hidl_vec {
hidl_vec() : mSize() { memset(mPad, 0, 0); }
hidl_vec(hidl_vec &other) { *this = other; }
hidl_vec &operator=(hidl_vec &other) {
copyFrom(other, other.mSize);
return *this;
}
T &operator[](unsigned index) { return mBuffer[index]; }
T* mBuffer;
unsigned mSize;
unsigned mPad[];
template <typename Array>
void copyFrom(Array &data, unsigned size) {
mSize = size;
if (mSize) mBuffer = new T();
for (int i = 0; i < size; ++i) mBuffer[i] = data[i];
}
};
struct Capabilities {
struct OperandPerformance {
int a, b, c;
};
hidl_vec<OperandPerformance> operandPerformance;
};
template <typename>
class Action;
template <typename R, typename... Args>
class Action<R(Args...)> {
using F = R();
public:
template <typename G>
Action(G fun) {
fun_ = fun;
}
function<F> fun_;
};
struct OnCallSpec {
OnCallSpec WillByDefault(Action<void()>);
};
struct MockSpec {
OnCallSpec InternalDefaultActionSetAt();
};
struct MockDevice {
MockSpec gmock_getCapabilities();
};
sp createMockDevice_mockDevice;
MockDevice createMockDevice() {
Capabilities getCapabilities_ret;
(*createMockDevice_mockDevice)
.gmock_getCapabilities()
.InternalDefaultActionSetAt()
.WillByDefault(getCapabilities_ret);
return *createMockDevice_mockDevice;
}