Skip to content

Commit

Permalink
Fix compiler assertion when subscripting a call expression. (#605)
Browse files Browse the repository at this point in the history
We introduce temporary variables to hold the results of calls to functions that return pointers with bounds.  This lets us express the bounds of the result of the call in the IR, so that we can generate a bounds check.  There is an assertion failure during code generation.  The wrong map is being used to look up the LLVM value for the temporary variable for an rvalue.  Use the right map.

Testing:
- Passes tests of subscripting call expressions.
  • Loading branch information
dtarditi authored Feb 15, 2019
1 parent c9f834e commit a35072b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/CodeGen/CGExprScalar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -807,7 +807,7 @@ class ScalarExprEmitter
if (E->getKind() == BoundsValueExpr::Kind::Temporary) {
CHKCBindTemporaryExpr *Temp = E->getTemporaryBinding();
assert(!Temp->getSubExpr()->isLValue());
Result = CGF.getBoundsTemporaryLValueMapping(Temp).getPointer();
Result = CGF.getBoundsTemporaryRValueMapping(Temp).getScalarVal();
} else
llvm_unreachable("unexpected bounds value expr");
assert(Result);
Expand Down
4 changes: 2 additions & 2 deletions lib/CodeGen/CodeGenFunction.h
Original file line number Diff line number Diff line change
Expand Up @@ -2113,9 +2113,9 @@ class CodeGenFunction : public CodeGenTypeCache {
return it->second;
}

/// getBoundsTemporaryLValueMapping - Given a bounds temporary (which
/// getBoundsTemporaryRValueMapping - Given a bounds temporary (which
/// must be mapped to an l-value), return its mapping.
const RValue &getBoundsTemporaryRValueMapping(const CHKCBindTemporaryExpr *e) {
RValue getBoundsTemporaryRValueMapping(const CHKCBindTemporaryExpr *e) {
assert (!e->getSubExpr()->isLValue());

llvm::DenseMap<const CHKCBindTemporaryExpr *,RValue>::iterator
Expand Down

0 comments on commit a35072b

Please sign in to comment.