aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJimmi HC <jimmiholstchristensen@gmail.com>2019-01-06 17:53:34 +0100
committerJimmi HC <jimmiholstchristensen@gmail.com>2019-01-06 17:53:34 +0100
commit55e95daf543a27961fe9ca7a998d3cbd25d2973b (patch)
tree04f8aabb79f53cabc5165e83858034221632a81e /src
parente410b1f915974fe3daeebae324e8c4e4b42090dd (diff)
downloadzig-55e95daf543a27961fe9ca7a998d3cbd25d2973b.tar.gz
zig-55e95daf543a27961fe9ca7a998d3cbd25d2973b.zip
Fixed issue where TypeInfo would use types from a prev CodeGen instance
When doing multible codegen passes (such as building compiler_rt and then something else) the TypeInfo cache code would point to types from the prev code gen (such as the prev 'bool' type), giving us errors like "expected type 'bool', but found type 'bool'" This disabling of caching might have a performance hit, but correctness is better than speed, so let's have this for now, until someone optimizes this correctly (probably in stage2)
Diffstat (limited to 'src')
-rw-r--r--src/ir.cpp14
1 files changed, 5 insertions, 9 deletions
diff --git a/src/ir.cpp b/src/ir.cpp
index 2353bb1086..4e401b7249 100644
--- a/src/ir.cpp
+++ b/src/ir.cpp
@@ -16882,16 +16882,12 @@ static void ensure_field_index(ZigType *type, const char *field_name, size_t ind
static ZigType *ir_type_info_get_type(IrAnalyze *ira, const char *type_name, ZigType *root) {
Error err;
- static ConstExprValue *type_info_var = nullptr; // TODO oops this global variable made it past code review
- static ZigType *type_info_type = nullptr; // TODO oops this global variable made it past code review
- if (type_info_var == nullptr) {
- type_info_var = get_builtin_value(ira->codegen, "TypeInfo");
- assert(type_info_var->type->id == ZigTypeIdMetaType);
+ ConstExprValue *type_info_var = get_builtin_value(ira->codegen, "TypeInfo"); // TODO oops this global variable made it past code review
+ assert(type_info_var->type->id == ZigTypeIdMetaType);
+ assertNoError(ensure_complete_type(ira->codegen, type_info_var->data.x_type));
- assertNoError(ensure_complete_type(ira->codegen, type_info_var->data.x_type));
- type_info_type = type_info_var->data.x_type;
- assert(type_info_type->id == ZigTypeIdUnion);
- }
+ ZigType *type_info_type = type_info_var->data.x_type; // TODO oops this global variable made it past code review
+ assert(type_info_type->id == ZigTypeIdUnion);
if (type_name == nullptr && root == nullptr)
return type_info_type;