public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r14-8534] gccrs: forever stack: Fix resolve_path signature
@ 2024-01-30 11:57 Arthur Cohen
0 siblings, 0 replies; only message in thread
From: Arthur Cohen @ 2024-01-30 11:57 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:5fd3de11508e7205e39b5fe00d8b4fd4789aeb86
commit r14-8534-g5fd3de11508e7205e39b5fe00d8b4fd4789aeb86
Author: Arthur Cohen <arthur.cohen@embecosm.com>
Date: Thu Sep 21 15:55:03 2023 +0200
gccrs: forever stack: Fix resolve_path signature
gcc/rust/ChangeLog:
* resolve/rust-forever-stack.h: Fix `ForeverStack::resolve_path`
signature.
* resolve/rust-forever-stack.hxx: Likewise.
* resolve/rust-early-name-resolver-2.0.cc (Early::visit): Use new API.
(Early::visit_attributes): Likewise.
Diff:
---
gcc/rust/resolve/rust-early-name-resolver-2.0.cc | 8 +++++---
gcc/rust/resolve/rust-forever-stack.h | 5 ++++-
gcc/rust/resolve/rust-forever-stack.hxx | 17 +++++++++--------
3 files changed, 18 insertions(+), 12 deletions(-)
diff --git a/gcc/rust/resolve/rust-early-name-resolver-2.0.cc b/gcc/rust/resolve/rust-early-name-resolver-2.0.cc
index 57a38078f144..2245ba31772f 100644
--- a/gcc/rust/resolve/rust-early-name-resolver-2.0.cc
+++ b/gcc/rust/resolve/rust-early-name-resolver-2.0.cc
@@ -131,7 +131,7 @@ Early::visit (AST::MacroInvocation &invoc)
// we won't have changed `definition` from `nullopt` if there are more
// than one segments in our path
if (!definition.has_value ())
- definition = ctx.macros.resolve_path (path);
+ definition = ctx.macros.resolve_path (path.get_segments ());
// if the definition still does not have a value, then it's an error
if (!definition.has_value ())
@@ -188,7 +188,8 @@ Early::visit_attributes (std::vector<AST::Attribute> &attrs)
auto traits = attr.get_traits_to_derive ();
for (auto &trait : traits)
{
- auto definition = ctx.macros.resolve_path (trait.get ());
+ auto definition
+ = ctx.macros.resolve_path (trait.get ().get_segments ());
if (!definition.has_value ())
{
// FIXME: Change to proper error message
@@ -210,7 +211,8 @@ Early::visit_attributes (std::vector<AST::Attribute> &attrs)
->lookup_builtin (name)
.is_error ()) // Do not resolve builtins
{
- auto definition = ctx.macros.resolve_path (attr.get_path ());
+ auto definition
+ = ctx.macros.resolve_path (attr.get_path ().get_segments ());
if (!definition.has_value ())
{
// FIXME: Change to proper error message
diff --git a/gcc/rust/resolve/rust-forever-stack.h b/gcc/rust/resolve/rust-forever-stack.h
index 349d0971f616..ec469a9b3fa0 100644
--- a/gcc/rust/resolve/rust-forever-stack.h
+++ b/gcc/rust/resolve/rust-forever-stack.h
@@ -470,10 +470,13 @@ public:
/**
* Resolve a path to its definition in the current `ForeverStack`
*
+ * // TODO: Add documentation for `segments`
+ *
* @return a valid option with the NodeId if the path is present in the
* current map, an empty one otherwise.
*/
- template <typename P> tl::optional<NodeId> resolve_path (const P &path);
+ template <typename S>
+ tl::optional<NodeId> resolve_path (const std::vector<S> &segments);
std::string as_debug_string ();
diff --git a/gcc/rust/resolve/rust-forever-stack.hxx b/gcc/rust/resolve/rust-forever-stack.hxx
index 211979fa9b95..8f0ab66b18b7 100644
--- a/gcc/rust/resolve/rust-forever-stack.hxx
+++ b/gcc/rust/resolve/rust-forever-stack.hxx
@@ -429,24 +429,25 @@ ForeverStack<N>::resolve_segments (
}
template <Namespace N>
-template <typename P>
+template <typename S>
tl::optional<NodeId>
-ForeverStack<N>::resolve_path (const P &path)
+ForeverStack<N>::resolve_path (const std::vector<S> &segments)
{
+ // TODO: What to do if segments.empty() ?
+
// if there's only one segment, we just use `get`
- if (path.get_segments ().size () == 1)
- return get (path.get_final_segment ().as_string ());
+ if (segments.size () == 1)
+ return get (segments.back ().as_string ());
auto starting_point = cursor ();
- auto &segments = path.get_segments ();
return find_starting_point (segments, starting_point)
.and_then ([this, &segments, &starting_point] (
- std::vector<AST::SimplePathSegment>::const_iterator iterator) {
+ typename std::vector<S>::const_iterator iterator) {
return resolve_segments (starting_point, segments, iterator);
})
- .and_then ([&path] (Node final_node) {
- return final_node.rib.get (path.get_final_segment ().as_string ());
+ .and_then ([&segments] (Node final_node) {
+ return final_node.rib.get (segments.back ().as_string ());
});
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2024-01-30 11:57 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-30 11:57 [gcc r14-8534] gccrs: forever stack: Fix resolve_path signature Arthur Cohen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).