From 879f38b3fdc4e97c07fe9c811b98fe1f276b0ee2 Mon Sep 17 00:00:00 2001 From: Alexey Toptygin Date: Mon, 15 Jul 2019 10:28:17 -0700 Subject: [PATCH] Stop using false_varNR in places that don't call tv() on it. Summary: Convert all the places that use false_varNR without calling tv() on it to return TypedValue instead of Variant (and have them stop using false_varNR). Reviewed By: markw65 Differential Revision: D16260067 fbshipit-source-id: 49cc389590b8946665340d77810a2ca65586c982 --- hphp/runtime/ext/reflection/ext_reflection.cpp | 32 +++++++++++++++----------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/hphp/runtime/ext/reflection/ext_reflection.cpp b/hphp/runtime/ext/reflection/ext_reflection.cpp index 1b0814b7902..d1235e87623 100644 --- a/hphp/runtime/ext/reflection/ext_reflection.cpp +++ b/hphp/runtime/ext/reflection/ext_reflection.cpp @@ -651,14 +651,14 @@ static Variant HHVM_METHOD(ReflectionFunctionAbstract, getEndLine) { return func->line2(); } -static Variant HHVM_METHOD(ReflectionFunctionAbstract, getDocComment) { +static TypedValue HHVM_METHOD(ReflectionFunctionAbstract, getDocComment) { auto const func = ReflectionFuncHandle::GetFuncFor(this_); auto const comment = func->docComment(); if (comment == nullptr || comment->empty()) { - return false_varNR; + return make_tv(false); } else { - auto ret = const_cast(comment); - return VarNR(ret); + assertx(!comment->isRefCounted()); + return make_tv(const_cast(comment)); } } @@ -1111,17 +1111,19 @@ static int HHVM_METHOD(ReflectionClass, getModifiers) { return get_modifiers(cls->attrs(), true, false); } -static Variant HHVM_METHOD(ReflectionClass, getFileName) { +static TypedValue HHVM_METHOD(ReflectionClass, getFileName) { auto const cls = ReflectionClassHandle::GetClassFor(this_); if (cls->attrs() & AttrBuiltin) { - return false_varNR; + return make_tv(false); } auto file = cls->preClass()->unit()->filepath()->data(); if (!file) { file = ""; } if (file[0] != '/') { - return String(RuntimeOption::SourceRoot + file); + String path(RuntimeOption::SourceRoot + file); + return make_tv(path.detach()); } else { - return String(file); + String path(file); + return make_tv(path.detach()); } } @@ -1141,15 +1143,15 @@ static Variant HHVM_METHOD(ReflectionClass, getEndLine) { return cls->preClass()->line2(); } -static Variant HHVM_METHOD(ReflectionClass, getDocComment) { +static TypedValue HHVM_METHOD(ReflectionClass, getDocComment) { auto const cls = ReflectionClassHandle::GetClassFor(this_); auto const pcls = cls->preClass(); auto const comment = pcls->docComment(); if (comment == nullptr || comment->empty()) { - return false_varNR; + return make_tv(false); } else { - auto ret = const_cast(comment); - return VarNR(ret); + assertx(!comment->isRefCounted()); + return make_tv(const_cast(comment)); } } @@ -1350,10 +1352,12 @@ static bool HHVM_METHOD(ReflectionClass, hasConstant, const String& name) { return cls->hasConstant(name.get()); } -static Variant HHVM_METHOD(ReflectionClass, getConstant, const String& name) { +static TypedValue HHVM_METHOD(ReflectionClass, getConstant, const String& name) { auto const cls = ReflectionClassHandle::GetClassFor(this_); auto value = cls->clsCnsGet(name.get()); - return (value.m_type == KindOfUninit) ? false_varNR : cellAsCVarRef(value); + if (value.m_type == KindOfUninit) return make_tv(false); + tvIncRefGen(value); + return value; } static -- 2.11.4.GIT