add ability to record accessed and declared "named defines"
Added the needed 2 sets to TIntermediate, added accessor-functions, inserter functions. Implemented recording of such named defines inside the preprocessor parser.
This commit is contained in:
parent
77d04598d3
commit
e735042306
3 changed files with 31 additions and 4 deletions
|
|
@ -102,7 +102,8 @@ int TPpContext::CPPdefine(TPpToken* ppToken)
|
|||
parseContext.ppError(ppToken->loc, "must be followed by macro name", "#define", "");
|
||||
return token;
|
||||
}
|
||||
if (ppToken->loc.string >= 0) {
|
||||
bool inUserCode(ppToken->loc.string >= 0);
|
||||
if (inUserCode) {
|
||||
// We are in user code; check for reserved name use:
|
||||
parseContext.reservedPpErrorCheck(ppToken->loc, ppToken->name, "#define");
|
||||
}
|
||||
|
|
@ -186,8 +187,11 @@ int TPpContext::CPPdefine(TPpToken* ppToken)
|
|||
}
|
||||
}
|
||||
*existing = mac;
|
||||
} else
|
||||
addMacroDef(defAtom, mac);
|
||||
} else {
|
||||
addMacroDef(defAtom, mac);
|
||||
if ( inUserCode && mac.args.empty() && mac.body.atEnd() )
|
||||
parseContext.intermediate.insertDeclaredNamedDefine( atomStrings.getString( defAtom ) );
|
||||
}
|
||||
|
||||
return '\n';
|
||||
}
|
||||
|
|
@ -248,6 +252,8 @@ int TPpContext::CPPelse(int matchelse, TPpToken* ppToken)
|
|||
} else {
|
||||
ifdepth++;
|
||||
elsetracker++;
|
||||
if ( nextAtom != PpAtomIf && scanToken( ppToken ) == PpAtomIdentifier )
|
||||
parseContext.intermediate.insertAccessedNamedDefine( ppToken->name );
|
||||
}
|
||||
} else if (nextAtom == PpAtomEndif) {
|
||||
token = extraTokenCheck(nextAtom, ppToken, scanToken(ppToken));
|
||||
|
|
@ -420,7 +426,7 @@ int TPpContext::eval(int token, int precedence, bool shortCircuit, int& res, boo
|
|||
|
||||
return token;
|
||||
}
|
||||
|
||||
parseContext.intermediate.insertAccessedNamedDefine( ppToken->name );
|
||||
MacroSymbol* macro = lookupMacroDef(atomStrings.getAtom(ppToken->name));
|
||||
res = macro != nullptr ? !macro->undef : 0;
|
||||
token = scanToken(ppToken);
|
||||
|
|
@ -577,6 +583,7 @@ int TPpContext::CPPifdef(int defined, TPpToken* ppToken)
|
|||
else
|
||||
parseContext.ppError(ppToken->loc, "must be followed by macro name", "#ifndef", "");
|
||||
} else {
|
||||
parseContext.intermediate.insertAccessedNamedDefine( ppToken->name );
|
||||
MacroSymbol* macro = lookupMacroDef(atomStrings.getAtom(ppToken->name));
|
||||
token = scanToken(ppToken);
|
||||
if (token != '\n') {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue