diff --git a/cpp2rust/converter/rules/expr_matcher.cpp b/cpp2rust/converter/rules/expr_matcher.cpp index 13b980485..e244c861c 100644 --- a/cpp2rust/converter/rules/expr_matcher.cpp +++ b/cpp2rust/converter/rules/expr_matcher.cpp @@ -75,7 +75,7 @@ using ResolvedDecl = ResolvedDecl getResolvedDecl(clang::ASTContext &ctx, const clang::Expr *expr, bool must_resolve) { expr = RuleDecls::SkipImplicit(expr); - if (llvm::isa(expr) && + if (llvm::isa(expr) && expr->getBeginLoc().isMacroID()) { return MacroUsage{ clang::Lexer::getImmediateMacroName( diff --git a/cpp2rust/converter/rules/rule_keys.cpp b/cpp2rust/converter/rules/rule_keys.cpp index adda286d3..6a2e07322 100644 --- a/cpp2rust/converter/rules/rule_keys.cpp +++ b/cpp2rust/converter/rules/rule_keys.cpp @@ -120,7 +120,7 @@ std::optional getDeclKey(const clang::NamedDecl *decl) { std::optional getExprKey(clang::ASTContext &ctx, const clang::Expr *expr) { expr = RuleDecls::SkipImplicit(expr); - if (llvm::isa(expr) && + if (llvm::isa(expr) && expr->getBeginLoc().isMacroID()) { auto macro = clang::Lexer::getImmediateMacroName( expr->getBeginLoc(), ctx.getSourceManager(), ctx.getLangOpts()); diff --git a/cpp2rust/converter/rules/rules_loader.cpp b/cpp2rust/converter/rules/rules_loader.cpp index d1b69f724..4fbec807d 100644 --- a/cpp2rust/converter/rules/rules_loader.cpp +++ b/cpp2rust/converter/rules/rules_loader.cpp @@ -474,7 +474,7 @@ std::string DeclKey(const clang::NamedDecl *decl) { std::string ExprKey(clang::ASTContext &ctx, const clang::Expr *expr) { expr = expr->IgnoreParenImpCasts(); - if (llvm::isa(expr) && + if (llvm::isa(expr) && expr->getBeginLoc().isMacroID()) { return clang::Lexer::getImmediateMacroName( expr->getBeginLoc(), ctx.getSourceManager(), ctx.getLangOpts()) diff --git a/rules/stdatomic/src_until_cxx23.cpp b/rules/stdatomic/src_until_cxx23.cpp new file mode 100644 index 000000000..85ebbf6e4 --- /dev/null +++ b/rules/stdatomic/src_until_cxx23.cpp @@ -0,0 +1,6 @@ +// Copyright (c) 2022-present INESC-ID. +// Distributed under the MIT license that can be found in the LICENSE file. + +#include + +void f1(volatile atomic_flag *a0) { return atomic_flag_clear(a0); } diff --git a/rules/stdatomic/tgt_unsafe.rs b/rules/stdatomic/tgt_unsafe.rs new file mode 100644 index 000000000..e9384bfb8 --- /dev/null +++ b/rules/stdatomic/tgt_unsafe.rs @@ -0,0 +1,6 @@ +// Copyright (c) 2022-present INESC-ID. +// Distributed under the MIT license that can be found in the LICENSE file. + +unsafe fn f1(a0: *mut ::std::sync::atomic::AtomicBool) { + (*a0).store(false, ::std::sync::atomic::Ordering::SeqCst) +}