Skip to content

Commit 6ba8540

Browse files
committed
Key unqualified dependent calls in rules
1 parent 1b1e896 commit 6ba8540

4 files changed

Lines changed: 25 additions & 2 deletions

File tree

‎cpp2rust/rule_preprocessing/cpp_rule_indexer.cpp‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,7 @@ std::string DependentExprKey(const clang::Expr *expr) {
179179
}
180180
}
181181
if (auto lookup = llvm::dyn_cast<clang::UnresolvedLookupExpr>(callee);
182-
lookup && lookup->getQualifier() &&
183-
!llvm::isa<clang::CXXOperatorCallExpr>(call) &&
182+
lookup && !llvm::isa<clang::CXXOperatorCallExpr>(call) &&
184183
lookup->decls_begin() != lookup->decls_end()) {
185184
return RulesLoader::DeclKey(
186185
(*lookup->decls_begin())->getUnderlyingDecl());

‎rules/cctype/src.cpp‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// Copyright (c) 2022-present INESC-ID.
2+
// Distributed under the MIT license that can be found in the LICENSE file.
3+
4+
#include <ctype.h>
5+
6+
template <typename T1> int f1(T1 a0) { return toupper(a0); }

‎rules/cctype/tgt_unsafe.rs‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Copyright (c) 2022-present INESC-ID.
2+
// Distributed under the MIT license that can be found in the LICENSE file.
3+
4+
unsafe fn f1<T1: Into<i32>>(a0: T1) -> i32 {
5+
let __c: i32 = a0.into();
6+
if (0..=255).contains(&__c) {
7+
(__c as u8).to_ascii_uppercase() as i32
8+
} else {
9+
__c
10+
}
11+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#include <cctype>
2+
#include <cstdio>
3+
4+
int main() {
5+
printf("%d %d %d\n", toupper('a'), toupper('Z'), toupper('5'));
6+
return 0;
7+
}

0 commit comments

Comments
 (0)