diff mbox series

c++/modules: Assume header bindings are global module

Message ID 66b4b4c9.170a0220.28c5d.5f4f@mx.google.com
State New
Headers show
Series c++/modules: Assume header bindings are global module | expand

Commit Message

Nathaniel Shead Aug. 8, 2024, 12:06 p.m. UTC
Bootstrapped and regtested on x86_64-pc-linux-gnu, OK for trunk?

-- >8 --

While stepping through some code I noticed that we do some extra work
(finding the originating module decl, stripping the template, and
inspecting the attached-ness) for every declaration taken from a header
unit.  This doesn't seem necessary though since no declaration in a
header unit can be attached to anything but the global module, so we can
just assume that global_p will be true.

This was the original behaviour before I removed this assumption while
refactoring for r15-2807-gc592310d5275e0.

gcc/cp/ChangeLog:

	* module.cc (module_state::read_cluster): Assume header module
	declarations will require GM merging.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
---
 gcc/cp/module.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Jason Merrill Aug. 8, 2024, 12:38 p.m. UTC | #1
On 8/8/24 8:06 AM, Nathaniel Shead wrote:
> Bootstrapped and regtested on x86_64-pc-linux-gnu, OK for trunk?

OK.

> -- >8 --
> 
> While stepping through some code I noticed that we do some extra work
> (finding the originating module decl, stripping the template, and
> inspecting the attached-ness) for every declaration taken from a header
> unit.  This doesn't seem necessary though since no declaration in a
> header unit can be attached to anything but the global module, so we can
> just assume that global_p will be true.
> 
> This was the original behaviour before I removed this assumption while
> refactoring for r15-2807-gc592310d5275e0.
> 
> gcc/cp/ChangeLog:
> 
> 	* module.cc (module_state::read_cluster): Assume header module
> 	declarations will require GM merging.
> 
> Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
> ---
>   gcc/cp/module.cc | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc
> index 58ad8cbdb61..f4d137b13a1 100644
> --- a/gcc/cp/module.cc
> +++ b/gcc/cp/module.cc
> @@ -15361,7 +15361,7 @@ module_state::read_cluster (unsigned snum)
>   	    tree visible = NULL_TREE;
>   	    tree type = NULL_TREE;
>   	    bool dedup = false;
> -	    bool global_p = false;
> +	    bool global_p = is_header ();
>   
>   	    /* We rely on the bindings being in the reverse order of
>   	       the resulting overload set.  */
diff mbox series

Patch

diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc
index 58ad8cbdb61..f4d137b13a1 100644
--- a/gcc/cp/module.cc
+++ b/gcc/cp/module.cc
@@ -15361,7 +15361,7 @@  module_state::read_cluster (unsigned snum)
 	    tree visible = NULL_TREE;
 	    tree type = NULL_TREE;
 	    bool dedup = false;
-	    bool global_p = false;
+	    bool global_p = is_header ();
 
 	    /* We rely on the bindings being in the reverse order of
 	       the resulting overload set.  */