summaryrefslogtreecommitdiffhomepage
path: root/ir/ident
diff options
context:
space:
mode:
authorChristoph Mallon <mallon@cs.uni-saarland.de>2014-10-19 11:53:11 +0200
committerChristoph Mallon <mallon@cs.uni-saarland.de>2014-10-19 18:37:03 +0200
commitf00a02f21bb1e4e519d82c589286da83b20b3e41 (patch)
treeb8a010eb843b857655dbaccd77d02d5de17b9175 /ir/ident
parentfb45ad91e9a3505118eadd869a5f679b36ff218d (diff)
ident: Cleanup.
Diffstat (limited to 'ir/ident')
-rw-r--r--ir/ident/ident.c8
-rw-r--r--ir/ident/mangle.c28
2 files changed, 10 insertions, 26 deletions
diff --git a/ir/ident/ident.c b/ir/ident/ident.c
index 9caed1b..d422a83 100644
--- a/ir/ident/ident.c
+++ b/ir/ident/ident.c
@@ -8,17 +8,12 @@
* @brief Hash table to store names.
* @author Goetz Lindenmaier
*/
-#include <assert.h>
-#include <ctype.h>
#include <stdio.h>
#include <string.h>
-#include <stddef.h>
-#include <stdlib.h>
+#include "hashptr.h"
#include "ident_t.h"
#include "set.h"
-#include "xmalloc.h"
-#include "hashptr.h"
static set *id_set;
@@ -37,7 +32,6 @@ ident *new_id_from_chars(const char *str, size_t len)
ident *new_id_from_str(const char *str)
{
- assert(str != NULL);
return new_id_from_chars(str, strlen(str));
}
diff --git a/ir/ident/mangle.c b/ir/ident/mangle.c
index 24569ba..c74220b 100644
--- a/ir/ident/mangle.c
+++ b/ir/ident/mangle.c
@@ -8,27 +8,12 @@
* @brief Methods to manipulate names.
* @author Martin Trapp, Christian Schaefer, Goetz Lindenmaier, Michael Beck
*/
-#include <stdio.h>
-
#include "ident_t.h"
#include "obst.h"
-/* Make types visible to allow most efficient access */
-#include "entity_t.h"
-#include "type_t.h"
-#include "tpop_t.h"
-
/** An obstack used for temporary space */
static struct obstack mangle_obst;
-static void obstack_grow_ident(struct obstack *obst, ident *id)
-{
- const char *c = get_id_str(id);
- for ( ; *c != '\0'; ++c) {
- obstack_1grow(obst, *c);
- }
-}
-
static ident *new_ident_from_obst(struct obstack *obst)
{
size_t len = obstack_object_size(obst);
@@ -38,12 +23,17 @@ static ident *new_ident_from_obst(struct obstack *obst)
return res;
}
+static void grow_string(char const *const s)
+{
+ obstack_grow(&mangle_obst, s, strlen(s));
+}
+
/** Returns a new ident that represents 'prefixscndsuffix'. */
-ident *id_mangle3(const char *prefix, ident *scnd, const char *suffix)
+ident *id_mangle3(char const *const prefix, ident *const middle, char const *const suffix)
{
- obstack_grow(&mangle_obst, prefix, strlen(prefix));
- obstack_grow_ident(&mangle_obst, scnd);
- obstack_grow(&mangle_obst, suffix, strlen(suffix));
+ grow_string(prefix);
+ grow_string(get_id_str(middle));
+ grow_string(suffix);
return new_ident_from_obst(&mangle_obst);
}