* Go patch committed: Unpack method names when sorting them
@ 2016-02-03 5:27 Ian Lance Taylor
0 siblings, 0 replies; only message in thread
From: Ian Lance Taylor @ 2016-02-03 5:27 UTC (permalink / raw)
To: gcc-patches, gofrontend-dev
[-- Attachment #1: Type: text/plain, Size: 426 bytes --]
When using type reflection, you occasionally need to know the order of
a type's methods. The order is simply an alphabetical sort.
Unfortunately, gccgo was not unpacking names before sorting them,
meaning that a type with a combination of exported and unexported
methods would have them in the wrong order. This patch fixes the
problem. Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu.
Committed to mainline.
Ian
[-- Attachment #2: patch.txt --]
[-- Type: text/plain, Size: 1627 bytes --]
Index: gcc/go/gofrontend/MERGE
===================================================================
--- gcc/go/gofrontend/MERGE (revision 232892)
+++ gcc/go/gofrontend/MERGE (working copy)
@@ -1,4 +1,4 @@
-8dce33f24dd3a34e3574c1d2604428586b63c1aa
+a408bef550251926c28673818db2c64302faac1d
The first line of this file holds the git revision number of the last
merge done from the gofrontend repository.
Index: gcc/go/gofrontend/types.cc
===================================================================
--- gcc/go/gofrontend/types.cc (revision 232855)
+++ gcc/go/gofrontend/types.cc (working copy)
@@ -2307,7 +2307,10 @@ class Sort_methods
bool
operator()(const std::pair<std::string, const Method*>& m1,
const std::pair<std::string, const Method*>& m2) const
- { return m1.first < m2.first; }
+ {
+ return (Gogo::unpack_hidden_name(m1.first)
+ < Gogo::unpack_hidden_name(m2.first));
+ }
};
// Return a composite literal for the type method table for this type.
@@ -7684,7 +7687,8 @@ Interface_type::get_backend_methods(Gogo
mfields[i].location = loc;
// Sanity check: the names should be sorted.
- go_assert(p->name() > last_name);
+ go_assert(Gogo::unpack_hidden_name(p->name())
+ > Gogo::unpack_hidden_name(last_name));
last_name = p->name();
}
@@ -10489,7 +10493,10 @@ struct Typed_identifier_list_sort
public:
bool
operator()(const Typed_identifier& t1, const Typed_identifier& t2) const
- { return t1.name() < t2.name(); }
+ {
+ return (Gogo::unpack_hidden_name(t1.name())
+ < Gogo::unpack_hidden_name(t2.name()));
+ }
};
void
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2016-02-03 5:27 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-03 5:27 Go patch committed: Unpack method names when sorting them Ian Lance Taylor
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).