From 98d7fe124915cec6594ffad330896319dc3cdb52 Mon Sep 17 00:00:00 2001 From: Mark Williams Date: Fri, 8 Jun 2018 12:26:48 -0700 Subject: [PATCH] Allow disabling doc-comments in hhas Summary: With hackc enabled, -vGenerateDocComments=false was doing nothing. Move it to RuntimeOption, and check it in as.cpp. Reviewed By: oulgen Differential Revision: D8322089 fbshipit-source-id: a2824ec060c542619985648de59652e17f365f77 --- hphp/compiler/analysis/emitter.cpp | 12 ++++++------ hphp/compiler/option.cpp | 5 ++--- hphp/compiler/option.h | 1 - hphp/doc/options.compiler | 5 ----- hphp/runtime/base/runtime-option.h | 1 + hphp/runtime/base/unit-cache.cpp | 1 + hphp/runtime/vm/as.cpp | 9 +++++++-- 7 files changed, 17 insertions(+), 17 deletions(-) diff --git a/hphp/compiler/analysis/emitter.cpp b/hphp/compiler/analysis/emitter.cpp index 0f80aeacbc3..e64049bb98f 100644 --- a/hphp/compiler/analysis/emitter.cpp +++ b/hphp/compiler/analysis/emitter.cpp @@ -9505,9 +9505,9 @@ Attr EmitterVisitor::bindNativeFunc(MethodStatementPtr meth, } fe->setLocation(meth->line0(), meth->line1()); - fe->docComment = makeStaticString( - Option::GenerateDocComments ? meth->getDocComment().c_str() : "" - ); + fe->docComment = RuntimeOption::EvalGenerateDocComments ? + makeStaticString(meth->getDocComment()) : staticEmptyString(); + auto retType = meth->retTypeAnnotation(); assert(retType || meth->isNamed("__construct") || @@ -9634,7 +9634,7 @@ void EmitterVisitor::emitMethodMetadata(MethodStatementPtr meth, fe->originalFilename = makeStaticString(originalFilename); } - StringData* methDoc = Option::GenerateDocComments ? + StringData* methDoc = RuntimeOption::EvalGenerateDocComments ? makeStaticString(meth->getDocComment()) : staticEmptyString(); fe->init(meth->line0(), @@ -10787,7 +10787,7 @@ Id EmitterVisitor::emitClass(Emitter& e, if (UNLIKELY(parentName->toCppString() == std::string("Closure"))) { throw IncludeTimeFatalException(is, "Class cannot extend Closure"); } - StringData* classDoc = Option::GenerateDocComments ? + StringData* classDoc = RuntimeOption::EvalGenerateDocComments ? makeStaticString(cNode->getDocComment()) : staticEmptyString(); Attr attr = cNode->isInterface() ? AttrInterface : cNode->isTrait() ? AttrTrait : @@ -10919,7 +10919,7 @@ Id EmitterVisitor::emitClass(Emitter& e, } auto const propName = makeStaticString(var->getName()); - auto const propDoc = Option::GenerateDocComments ? + auto const propDoc = RuntimeOption::EvalGenerateDocComments ? makeStaticString(var->getDocComment()) : staticEmptyString(); TypedValue tvVal; // Some properties may need to be marked with the AttrDeepInit diff --git a/hphp/compiler/option.cpp b/hphp/compiler/option.cpp index c9158ce0922..406f222a086 100644 --- a/hphp/compiler/option.cpp +++ b/hphp/compiler/option.cpp @@ -107,8 +107,6 @@ bool Option::RecordErrors = true; bool Option::AllVolatile = false; -bool Option::GenerateDocComments = true; - /////////////////////////////////////////////////////////////////////////////// // load from HDF file @@ -312,7 +310,8 @@ void Option::Load(const IniSetting::Map& ini, Hdf &config) { Config::Bind(AllVolatile, ini, config, "AllVolatile"); - Config::Bind(GenerateDocComments, ini, config, "GenerateDocComments", true); + Config::Bind(RuntimeOption::EvalGenerateDocComments, ini, config, + "GenerateDocComments", RuntimeOption::EvalGenerateDocComments); Config::Bind(DumpAst, ini, config, "DumpAst", false); Config::Bind(WholeProgram, ini, config, "WholeProgram", true); Config::Bind(RuntimeOption::EvalUseHHBBC, ini, config, "UseHHBBC", diff --git a/hphp/compiler/option.h b/hphp/compiler/option.h index 35c9969c185..6e7d92cc5c4 100644 --- a/hphp/compiler/option.h +++ b/hphp/compiler/option.h @@ -148,7 +148,6 @@ struct Option { /** * Output options */ - static bool GenerateDocComments; static bool DumpAst; static bool WholeProgram; static bool RecordErrors; diff --git a/hphp/doc/options.compiler b/hphp/doc/options.compiler index 7954536213a..7c02bfe751a 100644 --- a/hphp/doc/options.compiler +++ b/hphp/doc/options.compiler @@ -194,11 +194,6 @@ How many threads to use when parsing PHP files. By default, it's 2x CPU count. Facebook specific. Ignore. -= GenerateDocComments - -Default is true. Whether to store doc comments in class map, so they can be -queried from reflection. - = PregenerateCPP Default is false. In case clustering of output files has been requested and this diff --git a/hphp/runtime/base/runtime-option.h b/hphp/runtime/base/runtime-option.h index bf041f417d8..671274ee421 100644 --- a/hphp/runtime/base/runtime-option.h +++ b/hphp/runtime/base/runtime-option.h @@ -520,6 +520,7 @@ struct RuntimeOption { F(bool, RecordSubprocessTimes, false) \ F(bool, AllowHhas, false) \ F(bool, DisassemblerSourceMapping, true) \ + F(bool, GenerateDocComments, true) \ F(bool, DisassemblerDocComments, true) \ F(bool, DisassemblerPropDocComments, true) \ F(bool, LoadFilepathFromUnitCache, false) \ diff --git a/hphp/runtime/base/unit-cache.cpp b/hphp/runtime/base/unit-cache.cpp index eb34ef47ff6..55034918400 100644 --- a/hphp/runtime/base/unit-cache.cpp +++ b/hphp/runtime/base/unit-cache.cpp @@ -662,6 +662,7 @@ std::string mangleUnitMd5(const std::string& fileMd5) { + (RuntimeOption::EnableIsExprPrimitiveMigration ? '1' : '0') + (RuntimeOption::EnableHipHopExperimentalSyntax ? '1' : '0') + (RuntimeOption::EnableHipHopSyntax ? '1' : '0') + + (RuntimeOption::EvalGenerateDocComments ? '1' : '0') + (RuntimeOption::EnableXHP ? '1' : '0') + (RuntimeOption::EvalAllowHhas ? '1' : '0') + (RuntimeOption::EvalEmitSwitch ? '1' : '0') diff --git a/hphp/runtime/vm/as.cpp b/hphp/runtime/vm/as.cpp index 2b75b0ba96a..d17d0273716 100644 --- a/hphp/runtime/vm/as.cpp +++ b/hphp/runtime/vm/as.cpp @@ -116,6 +116,11 @@ AssemblerError::AssemblerError(int where, const std::string& what) namespace { +StringData* makeDocComment(const String& s) { + if (RuntimeOption::EvalGenerateDocComments) return makeStaticString(s); + return staticEmptyString(); +} + struct AsmState; typedef void (*ParserFunc)(AsmState& as); @@ -1853,7 +1858,7 @@ void parse_func_doccomment(AsmState& as) { auto const doc = parse_long_string(as); as.in.expectWs(';'); - as.fe->docComment = makeStaticString(doc); + as.fe->docComment = makeDocComment(doc); } /* @@ -2834,7 +2839,7 @@ void parse_cls_doccomment(AsmState& as) { auto const doc = parse_long_string(as); as.in.expectWs(';'); - as.pce->setDocComment(makeStaticString(doc)); + as.pce->setDocComment(makeDocComment(doc)); } /* -- 2.11.4.GIT