summaryrefslogtreecommitdiff
path: root/libiberty
diff options
context:
space:
mode:
authoribuclaw <ibuclaw@138bc75d-0d04-0410-961f-82ee72b054a4>2015-05-16 16:49:46 +0000
committeribuclaw <ibuclaw@138bc75d-0d04-0410-961f-82ee72b054a4>2015-05-16 16:49:46 +0000
commit7b3c2ca8f43a981d7752dc3a2cc834f89af1e9b6 (patch)
tree849e12cd5674304735a6ea98e6f186f5925764b2 /libiberty
parentb5e0673b2782c7509b782504d6b312fba3d9dcfe (diff)
downloadgcc-7b3c2ca8f43a981d7752dc3a2cc834f89af1e9b6.tar.gz
libiberty/ChangeLog:
2015-05-16 Iain Buclaw <ibuclaw@gdcproject.org> * d-demangle.c (dlang_identifier): Check encoded length of identifier to verify strncmp matches entire string. * testsuite/d-demangle-expected: Fix wrong test for postblit symbol. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@223243 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libiberty')
-rw-r--r--libiberty/ChangeLog6
-rw-r--r--libiberty/d-demangle.c133
-rw-r--r--libiberty/testsuite/d-demangle-expected2
3 files changed, 82 insertions, 59 deletions
diff --git a/libiberty/ChangeLog b/libiberty/ChangeLog
index 3eac5226392..37425c8df81 100644
--- a/libiberty/ChangeLog
+++ b/libiberty/ChangeLog
@@ -1,5 +1,11 @@
2015-05-16 Iain Buclaw <ibuclaw@gdcproject.org>
+ * d-demangle.c (dlang_identifier): Check encoded length of identifier
+ to verify strncmp matches entire string.
+ * testsuite/d-demangle-expected: Fix wrong test for postblit symbol.
+
+2015-05-16 Iain Buclaw <ibuclaw@gdcproject.org>
+
* d-demangle.c (dlang_type_modifiers): New function.
(dlang_type_modifier_p): New function.
(dlang_call_convention_p): Ignore any kind of type modifier.
diff --git a/libiberty/d-demangle.c b/libiberty/d-demangle.c
index 98e81606b58..011e62bc662 100644
--- a/libiberty/d-demangle.c
+++ b/libiberty/d-demangle.c
@@ -672,65 +672,82 @@ dlang_identifier (string *decl, const char *mangled)
return NULL;
}
- if (strncmp (mangled, "__ctor", i) == 0)
+ switch (i)
{
- /* Constructor symbol for a class/struct. */
- string_append (decl, "this");
- mangled += i;
- return mangled;
- }
- else if (strncmp (mangled, "__dtor", i) == 0)
- {
- /* Destructor symbol for a class/struct. */
- string_append (decl, "~this");
- mangled += i;
- return mangled;
- }
- else if (strncmp (mangled, "__postblit", i) == 0)
- {
- /* Postblit symbol for a struct. */
- string_append (decl, "this(this)");
- mangled += i;
- return mangled;
- }
- else if (strncmp (mangled, "__initZ", i+1) == 0)
- {
- /* The static initialiser for a given symbol. */
- string_append (decl, "init$");
- mangled += i + 1;
- return mangled;
- }
- else if (strncmp (mangled, "__ClassZ", i+1) == 0)
- {
- /* The classinfo symbol for a given class. */
- string_prepend (decl, "ClassInfo for ");
- string_setlength (decl, string_length (decl) - 1);
- mangled += i + 1;
- return mangled;
- }
- else if (strncmp (mangled, "__vtblZ", i+1) == 0)
- {
- /* The vtable symbol for a given class. */
- string_prepend (decl, "vtable for ");
- string_setlength (decl, string_length (decl) - 1);
- mangled += i + 1;
- return mangled;
- }
- else if (strncmp (mangled, "__InterfaceZ", i+1) == 0)
- {
- /* The interface symbol for a given class. */
- string_prepend (decl, "Interface for ");
- string_setlength (decl, string_length (decl) - 1);
- mangled += i + 1;
- return mangled;
- }
- else if (strncmp (mangled, "__ModuleInfoZ", i+1) == 0)
- {
- /* The ModuleInfo symbol for a given module. */
- string_prepend (decl, "ModuleInfo for ");
- string_setlength (decl, string_length (decl) - 1);
- mangled += i + 1;
- return mangled;
+ case 6:
+ if (strncmp (mangled, "__ctor", i) == 0)
+ {
+ /* Constructor symbol for a class/struct. */
+ string_append (decl, "this");
+ mangled += i;
+ return mangled;
+ }
+ else if (strncmp (mangled, "__dtor", i) == 0)
+ {
+ /* Destructor symbol for a class/struct. */
+ string_append (decl, "~this");
+ mangled += i;
+ return mangled;
+ }
+ else if (strncmp (mangled, "__initZ", i+1) == 0)
+ {
+ /* The static initialiser for a given symbol. */
+ string_append (decl, "init$");
+ mangled += i;
+ return mangled;
+ }
+ else if (strncmp (mangled, "__vtblZ", i+1) == 0)
+ {
+ /* The vtable symbol for a given class. */
+ string_prepend (decl, "vtable for ");
+ string_setlength (decl, string_length (decl) - 1);
+ mangled += i;
+ return mangled;
+ }
+ break;
+
+ case 7:
+ if (strncmp (mangled, "__ClassZ", i+1) == 0)
+ {
+ /* The classinfo symbol for a given class. */
+ string_prepend (decl, "ClassInfo for ");
+ string_setlength (decl, string_length (decl) - 1);
+ mangled += i;
+ return mangled;
+ }
+ break;
+
+ case 10:
+ if (strncmp (mangled, "__postblitMFZ", i+3) == 0)
+ {
+ /* Postblit symbol for a struct. */
+ string_append (decl, "this(this)");
+ mangled += i + 3;
+ return mangled;
+ }
+ break;
+
+ case 11:
+ if (strncmp (mangled, "__InterfaceZ", i+1) == 0)
+ {
+ /* The interface symbol for a given class. */
+ string_prepend (decl, "Interface for ");
+ string_setlength (decl, string_length (decl) - 1);
+ mangled += i;
+ return mangled;
+ }
+ break;
+
+ case 12:
+ if (strncmp (mangled, "__ModuleInfoZ", i+1) == 0)
+ {
+ /* The ModuleInfo symbol for a given module. */
+ string_prepend (decl, "ModuleInfo for ");
+ string_setlength (decl, string_length (decl) - 1);
+ mangled += i;
+ return mangled;
+ }
+ break;
}
string_appendn (decl, mangled, i);
diff --git a/libiberty/testsuite/d-demangle-expected b/libiberty/testsuite/d-demangle-expected
index 80445066e72..b0b9ca0b49d 100644
--- a/libiberty/testsuite/d-demangle-expected
+++ b/libiberty/testsuite/d-demangle-expected
@@ -502,7 +502,7 @@ _D8demangle4test6__dtorMFZv
demangle.test.~this()
#
--format=dlang
-_D8demangle4test6__postblitMFZv
+_D8demangle4test10__postblitMFZv
demangle.test.this(this)
#
--format=dlang