public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r14-7995] gccrs: Change proc macro definition lookup to optionals
@ 2024-01-16 18:11 Arthur Cohen
0 siblings, 0 replies; only message in thread
From: Arthur Cohen @ 2024-01-16 18:11 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:7167ed8d86cc103ea85c03849dcd76933edd7972
commit r14-7995-g7167ed8d86cc103ea85c03849dcd76933edd7972
Author: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Date: Tue Aug 29 15:02:21 2023 +0200
gccrs: Change proc macro definition lookup to optionals
Continue changing the api to use optionals instead of bools and double
pointers.
gcc/rust/ChangeLog:
* util/rust-hir-map.cc (Mappings::lookup_derive_proc_macro_def):
Update function to accomodate new signature.
(Mappings::lookup_bang_proc_macro_def): Likewise.
(Mappings::lookup_attribute_proc_macro_def): Likewise.
* util/rust-hir-map.h: Update function signatures.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Diff:
---
gcc/rust/util/rust-hir-map.cc | 27 ++++++++++++---------------
gcc/rust/util/rust-hir-map.h | 8 +++++---
2 files changed, 17 insertions(+), 18 deletions(-)
diff --git a/gcc/rust/util/rust-hir-map.cc b/gcc/rust/util/rust-hir-map.cc
index 6acec3dbe13..67d589cc247 100644
--- a/gcc/rust/util/rust-hir-map.cc
+++ b/gcc/rust/util/rust-hir-map.cc
@@ -1029,37 +1029,34 @@ Mappings::insert_attribute_proc_macro_def (NodeId id, AttributeProcMacro macro)
procmacroAttributeMappings[id] = macro;
}
-bool
-Mappings::lookup_derive_proc_macro_def (NodeId id, CustomDeriveProcMacro ¯o)
+tl::optional<CustomDeriveProcMacro &>
+Mappings::lookup_derive_proc_macro_def (NodeId id)
{
auto it = procmacroDeriveMappings.find (id);
if (it == procmacroDeriveMappings.end ())
- return false;
+ return tl::nullopt;
- macro = it->second;
- return true;
+ return it->second;
}
-bool
-Mappings::lookup_bang_proc_macro_def (NodeId id, BangProcMacro ¯o)
+tl::optional<BangProcMacro &>
+Mappings::lookup_bang_proc_macro_def (NodeId id)
{
auto it = procmacroBangMappings.find (id);
if (it == procmacroBangMappings.end ())
- return false;
+ return tl::nullopt;
- macro = it->second;
- return true;
+ return it->second;
}
-bool
-Mappings::lookup_attribute_proc_macro_def (NodeId id, AttributeProcMacro ¯o)
+tl::optional<AttributeProcMacro &>
+Mappings::lookup_attribute_proc_macro_def (NodeId id)
{
auto it = procmacroAttributeMappings.find (id);
if (it == procmacroAttributeMappings.end ())
- return false;
+ return tl::nullopt;
- macro = it->second;
- return true;
+ return it->second;
}
void
diff --git a/gcc/rust/util/rust-hir-map.h b/gcc/rust/util/rust-hir-map.h
index 177bcbacfc5..85da2802640 100644
--- a/gcc/rust/util/rust-hir-map.h
+++ b/gcc/rust/util/rust-hir-map.h
@@ -306,9 +306,11 @@ public:
void insert_bang_proc_macro_def (NodeId id, BangProcMacro macro);
void insert_attribute_proc_macro_def (NodeId id, AttributeProcMacro macro);
- bool lookup_derive_proc_macro_def (NodeId id, CustomDeriveProcMacro ¯o);
- bool lookup_bang_proc_macro_def (NodeId id, BangProcMacro ¯o);
- bool lookup_attribute_proc_macro_def (NodeId id, AttributeProcMacro ¯o);
+ tl::optional<CustomDeriveProcMacro &>
+ lookup_derive_proc_macro_def (NodeId id);
+ tl::optional<BangProcMacro &> lookup_bang_proc_macro_def (NodeId id);
+ tl::optional<AttributeProcMacro &>
+ lookup_attribute_proc_macro_def (NodeId id);
tl::optional<CustomDeriveProcMacro &>
lookup_derive_proc_macro_invocation (AST::SimplePath &invoc);
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2024-01-16 18:11 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-16 18:11 [gcc r14-7995] gccrs: Change proc macro definition lookup to optionals 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).