diff options
author | Philip Herron <philip.herron@embecosm.com> | 2021-07-05 12:42:31 +0100 |
---|---|---|
committer | Philip Herron <philip.herron@embecosm.com> | 2021-07-05 12:48:11 +0100 |
commit | dc5e01832772304e2a988406e78d3d83fe83f278 (patch) | |
tree | a7b2fca46909c8d6c44d3fba5a77b58d10544ef7 /gcc/rust/backend/rust-compile-context.h | |
parent | 210ae4f7b0fea9671482b8f01354fd5b9274f878 (diff) | |
download | gcc-dc5e01832772304e2a988406e78d3d83fe83f278.zip gcc-dc5e01832772304e2a988406e78d3d83fe83f278.tar.gz gcc-dc5e01832772304e2a988406e78d3d83fe83f278.tar.bz2 |
Fix bad naming of primitive types such as u64 which ended up as usize
There was a bad port over of the gccgo named_type implementation to try
be simple but this ended up overwriting the names of other primitive types
leading to confusing gimple debug sessions.
In debugging this I have added a set of ids which are the builtin primitive
types ids and we assert that this range of ids will never be overriten by
other types during compilation.
Diffstat (limited to 'gcc/rust/backend/rust-compile-context.h')
-rw-r--r-- | gcc/rust/backend/rust-compile-context.h | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/gcc/rust/backend/rust-compile-context.h b/gcc/rust/backend/rust-compile-context.h index e0c9352..5d19099 100644 --- a/gcc/rust/backend/rust-compile-context.h +++ b/gcc/rust/backend/rust-compile-context.h @@ -58,8 +58,9 @@ public: TyTy::BaseType *lookup; rust_assert (tyctx->lookup_type (ref, &lookup)); - auto compiled = TyTyCompile::compile (backend, lookup); - compiled_type_map[ref] = compiled; + Btype *compiled = TyTyCompile::compile (backend, lookup); + compiled_type_map.insert (std::pair<HirId, Btype *> (ref, compiled)); + builtin_range.insert (ref); } } @@ -94,7 +95,8 @@ public: void insert_compiled_type (HirId id, ::Btype *type, const TyTy::BaseType *ref = nullptr) { - compiled_type_map[id] = type; + rust_assert (builtin_range.find (id) == builtin_range.end ()); + compiled_type_map.insert (std::pair<HirId, Btype *> (id, type)); if (ref != nullptr) { std::pair<HirId, ::Btype *> elem (id, type); @@ -297,6 +299,7 @@ private: Resolver::TypeCheckContext *tyctx; Analysis::Mappings *mappings; ConstFold::Context *const_ctx; + std::set<HirId> builtin_range; // state std::vector<fncontext> fn_stack; |