allow constants in systemlib
The problem was a few: * All constant declarations were wrapped in a statement list. The merge-only check was allowing top-level `define()`s but not top level statement lists. I unwrapped them. I have no idea why it was done. Probalby just cargo cult programming. * When converting a UnitEmitter to a Unit we only allowed constants in RepoAuthoritative mode and not systemlib mode. * Systemlib constants weren't being set as UnitMergeKindPersistentDefine * UnitMergeKindPersistentDefine constants weren't being marked mergeOnly when pulling out of a repro
Esse commit está contido em:
@@ -635,7 +635,7 @@ bool SimpleFunctionCall::isDefineWithoutImpl(AnalysisResultConstPtr ar) {
|
||||
if (!name) return false;
|
||||
string varName = name->getIdentifier();
|
||||
if (varName.empty()) return false;
|
||||
if (ar->isSystemConstant(varName)) {
|
||||
if (!SystemLib::s_inited || ar->isSystemConstant(varName)) {
|
||||
always_assert(!m_extra);
|
||||
return true;
|
||||
}
|
||||
|
||||
+785
-792
Diferenças do arquivo suprimidas por serem muito extensas
Carregar Diff
@@ -1986,20 +1986,24 @@ void UnitRepoProxy::GetUnitMergeablesStmt
|
||||
do {
|
||||
query.step();
|
||||
if (query.row()) {
|
||||
int mergeableIx; /**/ query.getInt(0, mergeableIx);
|
||||
int mergeableKind; /**/ query.getInt(1, mergeableKind);
|
||||
Id mergeableId; /**/ query.getInt(2, mergeableId);
|
||||
|
||||
if (UNLIKELY(!RuntimeOption::RepoAuthoritative)) {
|
||||
/*
|
||||
* We're using a repo generated in WholeProgram mode,
|
||||
* but we're not using it in RepoAuthoritative mode
|
||||
* (this is dodgy to start with). We're not going to
|
||||
* deal with requires at merge time, so drop them
|
||||
* here, and clear the mergeOnly flag for the unit
|
||||
* here, and clear the mergeOnly flag for the unit.
|
||||
* The one exception is persistent constants are allowed in systemlib.
|
||||
*/
|
||||
ue.setMergeOnly(false);
|
||||
break;
|
||||
if (mergeableKind != UnitMergeKindPersistentDefine ||
|
||||
SystemLib::s_inited) {
|
||||
ue.setMergeOnly(false);
|
||||
}
|
||||
}
|
||||
int mergeableIx; /**/ query.getInt(0, mergeableIx);
|
||||
int mergeableKind; /**/ query.getInt(1, mergeableKind);
|
||||
Id mergeableId; /**/ query.getInt(2, mergeableId);
|
||||
switch (mergeableKind) {
|
||||
case UnitMergeKindReqDoc:
|
||||
ue.insertMergeableInclude(mergeableIx,
|
||||
@@ -2583,7 +2587,7 @@ Unit* UnitEmitter::create() {
|
||||
for (MergeableStmtVec::const_iterator it = m_mergeableStmts.begin();
|
||||
it != m_mergeableStmts.end(); ++it) {
|
||||
extra++;
|
||||
if (!RuntimeOption::RepoAuthoritative) {
|
||||
if (!RuntimeOption::RepoAuthoritative && SystemLib::s_inited) {
|
||||
if (it->first != UnitMergeKindClass) {
|
||||
extra = 0;
|
||||
u->m_mergeOnly = false;
|
||||
@@ -2640,9 +2644,9 @@ Unit* UnitEmitter::create() {
|
||||
break;
|
||||
}
|
||||
case UnitMergeKindDefine:
|
||||
case UnitMergeKindPersistentDefine:
|
||||
case UnitMergeKindGlobal: {
|
||||
case UnitMergeKindGlobal:
|
||||
assert(RuntimeOption::RepoAuthoritative);
|
||||
case UnitMergeKindPersistentDefine: {
|
||||
void* name = u->lookupLitstrId(m_mergeableValues[it->second].first);
|
||||
mi->mergeableObj(ix++) = (char*)name + (int)it->first;
|
||||
auto& tv = m_mergeableValues[it->second].second;
|
||||
|
||||
@@ -126,22 +126,15 @@ static void scalar_null(Parser *_p, Token &out) {
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// converting constant declartion to "define(name, value);"
|
||||
|
||||
static void on_constant(Parser *_p, Token &out, Token *stmts,
|
||||
Token &name, Token &value) {
|
||||
static void on_constant(Parser *_p, Token &out, Token &name, Token &value) {
|
||||
Token sname; _p->onScalar(sname, T_CONSTANT_ENCAPSED_STRING, name);
|
||||
|
||||
Token fname; fname.setText("define");
|
||||
Token params1; _p->onCallParam(params1, NULL, sname, 0);
|
||||
Token params2; _p->onCallParam(params2, ¶ms1, value, 0);
|
||||
Token call; _p->onCall(call, 0, fname, params2, 0);
|
||||
Token scall; _p->onExpStatement(scall, call);
|
||||
|
||||
Token stmts0;
|
||||
if (!stmts) {
|
||||
_p->onStatementListStart(stmts0);
|
||||
stmts = &stmts0;
|
||||
}
|
||||
_p->addStatement(out, *stmts, scall);
|
||||
|
||||
_p->onExpStatement(out, call);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
@@ -898,10 +891,10 @@ constant_declaration:
|
||||
constant_declaration ','
|
||||
hh_name_with_type
|
||||
'=' static_scalar { $3.setText(_p->nsDecl($3.text()));
|
||||
on_constant(_p,$$,&$1,$3,$5);}
|
||||
on_constant(_p,$$,$3,$5);}
|
||||
| T_CONST hh_name_with_type '='
|
||||
static_scalar { $2.setText(_p->nsDecl($2.text()));
|
||||
on_constant(_p,$$, 0,$2,$4);}
|
||||
on_constant(_p,$$,$2,$4);}
|
||||
;
|
||||
|
||||
inner_statement_list:
|
||||
|
||||
Referência em uma Nova Issue
Bloquear um usuário