aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorArthur Cohen <arthur.cohen@embecosm.com>2024-12-24 11:45:25 +0000
committerArthur Cohen <arthur.cohen@embecosm.com>2025-03-24 13:06:55 +0100
commit8c8bd50a267f13bcd78969ceb09d5b533cc52ce1 (patch)
tree7f3a4713e71661adcdaf13e3f48bff06aa13baa9 /gcc
parent8d883fbc5536f2b727a3ab7899c5b7dbccdfb7aa (diff)
downloadgcc-8c8bd50a267f13bcd78969ceb09d5b533cc52ce1.zip
gcc-8c8bd50a267f13bcd78969ceb09d5b533cc52ce1.tar.gz
gcc-8c8bd50a267f13bcd78969ceb09d5b533cc52ce1.tar.bz2
gccrs: marklive: Fix handling for lang item PathInExpressions.
gcc/rust/ChangeLog: * checks/lints/rust-lint-marklive.cc (MarkLive::visit): Adapt to lang items.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/rust/checks/lints/rust-lint-marklive.cc16
1 files changed, 12 insertions, 4 deletions
diff --git a/gcc/rust/checks/lints/rust-lint-marklive.cc b/gcc/rust/checks/lints/rust-lint-marklive.cc
index 4b524d7..6e2e2e4 100644
--- a/gcc/rust/checks/lints/rust-lint-marklive.cc
+++ b/gcc/rust/checks/lints/rust-lint-marklive.cc
@@ -22,6 +22,8 @@
#include "rust-lint-marklive.h"
#include "options.h"
#include "rust-hir-full.h"
+#include "rust-hir-map.h"
+#include "rust-hir-path.h"
#include "rust-name-resolver.h"
#include "rust-immutable-name-resolution-context.h"
#include "rust-system.h"
@@ -99,15 +101,21 @@ MarkLive::visit (HIR::PathInExpression &expr)
{
// We should iterate every path segment in order to mark the struct which
// is used in expression like Foo::bar(), we should mark the Foo alive.
- expr.iterate_path_segments ([&] (HIR::PathExprSegment &seg) -> bool {
- return visit_path_segment (seg);
- });
+ if (!expr.is_lang_item ())
+ expr.iterate_path_segments ([&] (HIR::PathExprSegment &seg) -> bool {
+ return visit_path_segment (seg);
+ });
// after iterate the path segments, we should mark functions and associated
// functions alive.
NodeId ast_node_id = expr.get_mappings ().get_nodeid ();
NodeId ref_node_id = UNKNOWN_NODEID;
- find_ref_node_id (ast_node_id, ref_node_id);
+
+ if (expr.is_lang_item ())
+ ref_node_id
+ = Analysis::Mappings::get ().get_lang_item_node (expr.get_lang_item ());
+ else
+ find_ref_node_id (ast_node_id, ref_node_id);
// node back to HIR
tl::optional<HirId> hid = mappings.lookup_node_to_hir (ref_node_id);