Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

trans: add range asserts to loads of char #10056

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/librustc/middle/trans/datum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,9 @@ use middle::ty;
use util::common::indenter;
use util::ppaux::ty_to_str;

use std::char;
use std::uint;
use std::libc::c_ulonglong;
use syntax::ast;
use syntax::codemap::Span;
use syntax::parse::token::special_idents;
Expand Down Expand Up @@ -439,7 +441,10 @@ impl Datum {
ByValue => self.val,
ByRef(_) => {
if ty::type_is_bool(self.ty) {
LoadRangeAssert(bcx, self.val, 0, 2, lib::llvm::True)
LoadRangeAssert(bcx, self.val, 0, 2, lib::llvm::False)
} else if ty::type_is_char(self.ty) {
LoadRangeAssert(bcx, self.val, 0, char::MAX as c_ulonglong + 1,
lib::llvm::False)
} else {
Load(bcx, self.val)
}
Expand Down