Skip to content

Commit 04c08f4

Browse files
authored
Key atomic expressions (#555)
1 parent 01d9f7a commit 04c08f4

5 files changed

Lines changed: 15 additions & 3 deletions

File tree

‎cpp2rust/converter/rules/expr_matcher.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ using ResolvedDecl =
7575
ResolvedDecl getResolvedDecl(clang::ASTContext &ctx, const clang::Expr *expr,
7676
bool must_resolve) {
7777
expr = RuleDecls::SkipImplicit(expr);
78-
if (llvm::isa<clang::IntegerLiteral>(expr) &&
78+
if (llvm::isa<clang::IntegerLiteral, clang::AtomicExpr>(expr) &&
7979
expr->getBeginLoc().isMacroID()) {
8080
return MacroUsage{
8181
clang::Lexer::getImmediateMacroName(

‎cpp2rust/converter/rules/rule_keys.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ std::optional<ExprKey> getDeclKey(const clang::NamedDecl *decl) {
120120
std::optional<ExprKey> getExprKey(clang::ASTContext &ctx,
121121
const clang::Expr *expr) {
122122
expr = RuleDecls::SkipImplicit(expr);
123-
if (llvm::isa<clang::IntegerLiteral>(expr) &&
123+
if (llvm::isa<clang::IntegerLiteral, clang::AtomicExpr>(expr) &&
124124
expr->getBeginLoc().isMacroID()) {
125125
auto macro = clang::Lexer::getImmediateMacroName(
126126
expr->getBeginLoc(), ctx.getSourceManager(), ctx.getLangOpts());

‎cpp2rust/converter/rules/rules_loader.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ std::string DeclKey(const clang::NamedDecl *decl) {
474474

475475
std::string ExprKey(clang::ASTContext &ctx, const clang::Expr *expr) {
476476
expr = expr->IgnoreParenImpCasts();
477-
if (llvm::isa<clang::IntegerLiteral>(expr) &&
477+
if (llvm::isa<clang::IntegerLiteral, clang::AtomicExpr>(expr) &&
478478
expr->getBeginLoc().isMacroID()) {
479479
return clang::Lexer::getImmediateMacroName(
480480
expr->getBeginLoc(), ctx.getSourceManager(), ctx.getLangOpts())
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 <stdatomic.h>
5+
6+
void f1(volatile atomic_flag *a0) { return atomic_flag_clear(a0); }

‎rules/stdatomic/tgt_unsafe.rs‎

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+
unsafe fn f1(a0: *mut ::std::sync::atomic::AtomicBool) {
5+
(*a0).store(false, ::std::sync::atomic::Ordering::SeqCst)
6+
}

0 commit comments

Comments
 (0)