diff options
author | Reid Kleckner <reid@kleckner.net> | 2014-05-15 01:26:32 +0000 |
---|---|---|
committer | Reid Kleckner <reid@kleckner.net> | 2014-05-15 01:26:32 +0000 |
commit | d355ca77a95e8e0266c8d26c23d2b0e8e2fdd8e5 (patch) | |
tree | 2f78e5b39dd323812650871893ce87c9ca6af5db /clang/lib/CodeGen/ItaniumCXXABI.cpp | |
parent | e8c785439dc8effe976b2a3207cb7dd67f6734cc (diff) | |
download | bcm5719-llvm-d355ca77a95e8e0266c8d26c23d2b0e8e2fdd8e5.tar.gz bcm5719-llvm-d355ca77a95e8e0266c8d26c23d2b0e8e2fdd8e5.zip |
Revert Itanium parts of "Don't copy objects with trivial, deleted copy ctors"
This undoes half of r208786.
It had problems with lazily declared special members in cases like this:
struct A {
A();
A &operator=(A &&o);
void *p;
};
void foo(A);
void bar() {
foo({});
}
In this case, the copy and move constructors are implicitly deleted.
However, Clang doesn't eagerly declare the copy ctor in the AST, so we
pass the struct in registers. Furthermore, GCC passes this in registers
even though this class should be uncopyable.
Revert this for now until the dust settles.
llvm-svn: 208836
Diffstat (limited to 'clang/lib/CodeGen/ItaniumCXXABI.cpp')
-rw-r--r-- | clang/lib/CodeGen/ItaniumCXXABI.cpp | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/clang/lib/CodeGen/ItaniumCXXABI.cpp b/clang/lib/CodeGen/ItaniumCXXABI.cpp index e3605e1b9cb..07a8d8a8460 100644 --- a/clang/lib/CodeGen/ItaniumCXXABI.cpp +++ b/clang/lib/CodeGen/ItaniumCXXABI.cpp @@ -55,8 +55,11 @@ public: bool classifyReturnType(CGFunctionInfo &FI) const override; RecordArgABI getRecordArgABI(const CXXRecordDecl *RD) const override { - // If C++ prohibits us from making a copy, pass by address. - if (!canCopyArgument(RD)) + // Structures with either a non-trivial destructor or a non-trivial + // copy constructor are always indirect. + // FIXME: Use canCopyArgument() when it is fixed to handle lazily declared + // special members. + if (RD->hasNonTrivialDestructor() || RD->hasNonTrivialCopyConstructor()) return RAA_Indirect; return RAA_Default; } @@ -761,8 +764,10 @@ bool ItaniumCXXABI::classifyReturnType(CGFunctionInfo &FI) const { if (!RD) return false; - // If C++ prohibits us from making a copy, return by address. - if (!canCopyArgument(RD)) { + // Return indirectly if we have a non-trivial copy ctor or non-trivial dtor. + // FIXME: Use canCopyArgument() when it is fixed to handle lazily declared + // special members. + if (RD->hasNonTrivialDestructor() || RD->hasNonTrivialCopyConstructor()) { FI.getReturnInfo() = ABIArgInfo::getIndirect(0, /*ByVal=*/false); return true; } |