Skip to content
Merged
Show file tree
Hide file tree
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
3 changes: 1 addition & 2 deletions cpp2rust/rule_preprocessing/cpp_rule_indexer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,7 @@ std::string DependentExprKey(const clang::Expr *expr) {
}
}
if (auto lookup = llvm::dyn_cast<clang::UnresolvedLookupExpr>(callee);
lookup && lookup->getQualifier() &&
!llvm::isa<clang::CXXOperatorCallExpr>(call) &&
lookup && !llvm::isa<clang::CXXOperatorCallExpr>(call) &&
lookup->decls_begin() != lookup->decls_end()) {
return RulesLoader::DeclKey(
(*lookup->decls_begin())->getUnderlyingDecl());
Expand Down
6 changes: 6 additions & 0 deletions rules/cctype/src.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// Copyright (c) 2022-present INESC-ID.
// Distributed under the MIT license that can be found in the LICENSE file.

#include <ctype.h>

template <typename T1> int f1(T1 a0) { return toupper(a0); }
11 changes: 11 additions & 0 deletions rules/cctype/tgt_unsafe.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Copyright (c) 2022-present INESC-ID.
// Distributed under the MIT license that can be found in the LICENSE file.

unsafe fn f1<T1: Into<i32>>(a0: T1) -> i32 {
let __c: i32 = a0.into();
if (0..=255).contains(&__c) {
(__c as u8).to_ascii_uppercase() as i32
} else {
__c
}
}
46 changes: 46 additions & 0 deletions tests/unit/out/refcount/template_rule_unqualified_call.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
extern crate libcc2rs;
use libcc2rs::*;
use std::cell::RefCell;
use std::collections::BTreeMap;
use std::io::prelude::*;
use std::io::{Read, Seek, Write};
use std::os::fd::AsFd;
use std::rc::{Rc, Weak};
pub fn main() {
__cpp2rust_init_globals();
std::process::exit(main_0());
}
fn main_0() -> i32 {
assert!(
({
let __c: i32 = (('a' as i8) as i32).into();
if (0..=255).contains(&__c) {
(__c as u8).to_ascii_uppercase() as i32
} else {
__c
}
} == (('A' as i8) as i32))
);
assert!(
({
let __c: i32 = (('Z' as i8) as i32).into();
if (0..=255).contains(&__c) {
(__c as u8).to_ascii_uppercase() as i32
} else {
__c
}
} == (('Z' as i8) as i32))
);
assert!(
({
let __c: i32 = (('5' as i8) as i32).into();
if (0..=255).contains(&__c) {
(__c as u8).to_ascii_uppercase() as i32
} else {
__c
}
} == (('5' as i8) as i32))
);
return 0;
}
pub fn __cpp2rust_init_globals() {}
48 changes: 48 additions & 0 deletions tests/unit/out/unsafe/template_rule_unqualified_call.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
extern crate libc;
use libc::*;
extern crate libcc2rs;
use libcc2rs::*;
use std::collections::BTreeMap;
use std::io::{Read, Seek, Write};
use std::os::fd::{AsFd, FromRawFd, IntoRawFd};
use std::rc::Rc;
pub fn main() {
unsafe {
__cpp2rust_init_globals();
std::process::exit(main_0() as i32);
}
}
unsafe fn main_0() -> i32 {
assert!(
(({
let __c: i32 = (('a' as libc::c_char) as i32).into();
if (0..=255).contains(&__c) {
(__c as u8).to_ascii_uppercase() as i32
} else {
__c
}
}) == (('A' as libc::c_char) as i32))
);
assert!(
(({
let __c: i32 = (('Z' as libc::c_char) as i32).into();
if (0..=255).contains(&__c) {
(__c as u8).to_ascii_uppercase() as i32
} else {
__c
}
}) == (('Z' as libc::c_char) as i32))
);
assert!(
(({
let __c: i32 = (('5' as libc::c_char) as i32).into();
if (0..=255).contains(&__c) {
(__c as u8).to_ascii_uppercase() as i32
} else {
__c
}
}) == (('5' as libc::c_char) as i32))
);
return 0;
}
pub unsafe fn __cpp2rust_init_globals() {}
9 changes: 9 additions & 0 deletions tests/unit/template_rule_unqualified_call.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include <cassert>
#include <cctype>

int main() {
assert(toupper('a') == 'A');
assert(toupper('Z') == 'Z');
assert(toupper('5') == '5');
return 0;
}
Loading