]> granicus.if.org Git - clang/commit
[CodeGen] Fix assertion on referencing constexpr Obj-C object with ARC.
authorVolodymyr Sapsai <vsapsai@apple.com>
Thu, 1 Nov 2018 22:50:08 +0000 (22:50 +0000)
committerVolodymyr Sapsai <vsapsai@apple.com>
Thu, 1 Nov 2018 22:50:08 +0000 (22:50 +0000)
commite4c824a5a0c35ba449266034b4b2f119cf1de3b5
treeccdc9ed9a1125606a689b6c08a66e29e85af14ac
parent2597e7eac63e1aec05fd6a8cc58bdad3e125bd86
[CodeGen] Fix assertion on referencing constexpr Obj-C object with ARC.

Failed assertion is
> Assertion failed: ((ND->isUsed(false) || !isa<VarDecl>(ND) || !E->getLocation().isValid()) && "Should not use decl without marking it used!"), function EmitDeclRefLValue, file llvm-project/clang/lib/CodeGen/CGExpr.cpp, line 2437.

`EmitDeclRefLValue` mentions
> // A DeclRefExpr for a reference initialized by a constant expression can
> // appear without being odr-used. Directly emit the constant initializer.

The fix is to use the similar approach for non-references as for references. It
is achieved by trying to emit a constant before we attempt to load non-odr-used
variable as LValue.

rdar://problem/40650504

Reviewers: ahatanak, rjmccall

Reviewed By: rjmccall

Subscribers: dexonsmith, erik.pilkington, cfe-commits

Differential Revision: https://reviews.llvm.org/D53674

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@345903 91177308-0d34-0410-b5e6-96231b3b80d8
lib/CodeGen/CGObjC.cpp
test/CodeGenObjCXX/arc-constexpr.mm