diff options
author | Akira Hatanaka <ahatanaka@apple.com> | 2019-07-26 00:02:17 +0000 |
---|---|---|
committer | Akira Hatanaka <ahatanaka@apple.com> | 2019-07-26 00:02:17 +0000 |
commit | 6f6156b9fc81b64b61c53360735c2771c381187f (patch) | |
tree | d90fd21e7f39b321b58c58eb15523d6eb2895e6d /clang/lib/Sema/SemaExpr.cpp | |
parent | c07fe307b48a98a149578948b167802f7b2825cf (diff) | |
download | bcm5719-llvm-6f6156b9fc81b64b61c53360735c2771c381187f.tar.gz bcm5719-llvm-6f6156b9fc81b64b61c53360735c2771c381187f.zip |
Revert "[Sema] Diagnose default-initialization, destruction, and copying of"
This reverts commit r365985.
Prior to r365985, clang used to mark C union fields that have
non-trivial ObjC ownership qualifiers as unavailable if the union was
declared in a system header. r365985 stopped doing so, which caused the
swift compiler to crash when it tried to import a non-trivial union.
I have a patch that fixes the crash (https://reviews.llvm.org/D65256),
but I'm temporarily reverting the original patch until we can decide on
whether it's taking the right approach.
llvm-svn: 367076
Diffstat (limited to 'clang/lib/Sema/SemaExpr.cpp')
-rw-r--r-- | clang/lib/Sema/SemaExpr.cpp | 33 |
1 files changed, 1 insertions, 32 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index 8f5a892b9a2..52fa932eee8 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -6076,7 +6076,7 @@ Sema::BuildCompoundLiteralExpr(SourceLocation LParenLoc, TypeSourceInfo *TInfo, ILE->setInit(i, ConstantExpr::Create(Context, Init)); } - auto *E = new (Context) CompoundLiteralExpr(LParenLoc, TInfo, literalType, + Expr *E = new (Context) CompoundLiteralExpr(LParenLoc, TInfo, literalType, VK, LiteralExpr, isFileScope); if (isFileScope) { if (!LiteralExpr->isTypeDependent() && @@ -6094,19 +6094,6 @@ Sema::BuildCompoundLiteralExpr(SourceLocation LParenLoc, TypeSourceInfo *TInfo, return ExprError(); } - // Compound literals that have automatic storage duration are destroyed at - // the end of the scope. Emit diagnostics if it is or contains a C union type - // that is non-trivial to destruct. - if (!isFileScope) - if (E->getType().hasNonTrivialToPrimitiveDestructCUnion()) - checkNonTrivialCUnion(E->getType(), E->getExprLoc(), - NTCUC_CompoundLiteral, NTCUK_Destruct); - - if (E->getType().hasNonTrivialToPrimitiveDefaultInitializeCUnion() || - E->getType().hasNonTrivialToPrimitiveCopyCUnion()) - checkNonTrivialCUnionInInitializer(E->getInitializer(), - E->getInitializer()->getExprLoc()); - return MaybeBindToTemporary(E); } @@ -12556,10 +12543,6 @@ ExprResult Sema::CreateBuiltinBinOp(SourceLocation OpLoc, if (auto *VD = dyn_cast<VarDecl>(DRE->getDecl())) if (VD->hasLocalStorage() && getCurScope()->isDeclScope(VD)) BE->getBlockDecl()->setCanAvoidCopyToHeap(); - - if (LHS.get()->getType().hasNonTrivialToPrimitiveCopyCUnion()) - checkNonTrivialCUnion(LHS.get()->getType(), LHS.get()->getExprLoc(), - NTCUC_Assignment, NTCUK_Copy); } RecordModifiableNonNullParam(*this, LHS.get()); break; @@ -13972,11 +13955,6 @@ ExprResult Sema::ActOnBlockStmtExpr(SourceLocation CaretLoc, !BD->isDependentContext()) computeNRVO(Body, BSI); - if (RetTy.hasNonTrivialToPrimitiveDestructCUnion() || - RetTy.hasNonTrivialToPrimitiveCopyCUnion()) - checkNonTrivialCUnion(RetTy, BD->getCaretLocation(), NTCUC_FunctionReturn, - NTCUK_Destruct|NTCUK_Copy); - PopDeclContext(); // Pop the block scope now but keep it alive to the end of this function. @@ -16228,15 +16206,6 @@ static ExprResult rebuildPotentialResultsAsNonOdrUsed(Sema &S, Expr *E, } ExprResult Sema::CheckLValueToRValueConversionOperand(Expr *E) { - // Check whether the operand is or contains an object of non-trivial C union - // type. - if (E->getType().isVolatileQualified() && - (E->getType().hasNonTrivialToPrimitiveDestructCUnion() || - E->getType().hasNonTrivialToPrimitiveCopyCUnion())) - checkNonTrivialCUnion(E->getType(), E->getExprLoc(), - Sema::NTCUC_LValueToRValueVolatile, - NTCUK_Destruct|NTCUK_Copy); - // C++2a [basic.def.odr]p4: // [...] an expression of non-volatile-qualified non-class type to which // the lvalue-to-rvalue conversion is applied [...] |