Fix a bug with null constants

We end up with uninit nulls in the repo for unit constants.
In RepoAuthoritative mode, we will use m_type == KindOfUninit during
constant lookup to decide whether to cast TypedValue::m_data.pref to a
ConstantInfo*, and then call a function pointer that it contains.  (We
should probably also clean that up to not cast RefData*'s to
ConstantInfo*'s, but I left that out of this diff.)
Esse commit está contido em:
Jordan DeLong
2013-05-14 14:08:39 -07:00
commit de Sara Golemon
commit dfbf27d243
4 arquivos alterados com 6 adições e 0 exclusões
+3
Ver Arquivo
@@ -1686,6 +1686,9 @@ void EmitterVisitor::visit(FileScopePtr file) {
if (func->isSimpleDefine(&name, &tv)) {
UnitMergeKind k = func->isDefineWithoutImpl(ar) ?
UnitMergeKindPersistentDefine : UnitMergeKindDefine;
if (tv.m_type == KindOfUninit) {
tv.m_type = KindOfNull;
}
m_ue.pushMergeableDef(k, name, tv);
visit(s);
continue;
+1
Ver Arquivo
@@ -1273,6 +1273,7 @@ void Unit::mergeImpl(void* tcbase, UnitMergeInfo* mi) {
Stats::inc(Stats::UnitMerge_mergeable_define);
StringData* name = (StringData*)((char*)obj - (int)k);
auto* v = (TypedValueAux*)mi->mergeableData(ix + 1);
assert(v->m_type != KindOfUninit);
mergeCns(getDataRef<TypedValue>(tcbase, v->cacheHandle()), v, name);
ix += 1 + sizeof(*v) / sizeof(void*);
obj = mi->mergeableObj(ix);
+2
Ver Arquivo
@@ -0,0 +1,2 @@
<?php
define('FOO', null);