Bump simplecpp
This commit is contained in:
parent
b1547a387e
commit
561e9174fa
|
@ -2804,7 +2804,7 @@ static bool preprocessToken(simplecpp::TokenList &output, const simplecpp::Token
|
|||
return true;
|
||||
}
|
||||
|
||||
void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenList &rawtokens, std::vector<std::string> &files, std::map<std::string, simplecpp::TokenList *> &filedata, const simplecpp::DUI &dui, simplecpp::OutputList *outputList, std::list<simplecpp::MacroUsage> *macroUsage)
|
||||
void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenList &rawtokens, std::vector<std::string> &files, std::map<std::string, simplecpp::TokenList *> &filedata, const simplecpp::DUI &dui, simplecpp::OutputList *outputList, std::list<simplecpp::MacroUsage> *macroUsage, std::list<simplecpp::IfCond> *ifCond)
|
||||
{
|
||||
std::map<std::string, std::size_t> sizeOfType(rawtokens.sizeOfType);
|
||||
sizeOfType.insert(std::make_pair("char", sizeof(char)));
|
||||
|
@ -3119,7 +3119,17 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL
|
|||
tok = tmp->previous;
|
||||
}
|
||||
try {
|
||||
conditionIsTrue = (evaluate(expr, sizeOfType) != 0);
|
||||
if (ifCond) {
|
||||
std::string E;
|
||||
for (const simplecpp::Token *tok = expr.cfront(); tok; tok = tok->next)
|
||||
E += (E.empty() ? "" : " ") + tok->str();
|
||||
const long long result = evaluate(expr, sizeOfType);
|
||||
conditionIsTrue = (result != 0);
|
||||
ifCond->push_back(IfCond(rawtok->location, E, result));
|
||||
} else {
|
||||
const long long result = evaluate(expr, sizeOfType);
|
||||
conditionIsTrue = (result != 0);
|
||||
}
|
||||
} catch (const std::exception &e) {
|
||||
if (outputList) {
|
||||
Output out(rawtok->location.files);
|
||||
|
|
|
@ -287,6 +287,14 @@ namespace simplecpp {
|
|||
bool macroValueKnown;
|
||||
};
|
||||
|
||||
/** Tracking #if/#elif expressions */
|
||||
struct SIMPLECPP_LIB IfCond {
|
||||
explicit IfCond(const Location& location, const std::string &E, long long result) : location(location), E(E), result(result) {}
|
||||
Location location; // location of #if/#elif
|
||||
std::string E; // preprocessed condition
|
||||
long long result; // condition result
|
||||
};
|
||||
|
||||
/**
|
||||
* Command line preprocessor settings.
|
||||
* On the command line these are configured by -D, -U, -I, --include, -std
|
||||
|
@ -314,8 +322,9 @@ namespace simplecpp {
|
|||
* @param dui defines, undefs, and include paths
|
||||
* @param outputList output: list that will receive output messages
|
||||
* @param macroUsage output: macro usage
|
||||
* @param ifCond output: #if/#elif expressions
|
||||
*/
|
||||
SIMPLECPP_LIB void preprocess(TokenList &output, const TokenList &rawtokens, std::vector<std::string> &files, std::map<std::string, TokenList*> &filedata, const DUI &dui, OutputList *outputList = NULL, std::list<MacroUsage> *macroUsage = NULL);
|
||||
SIMPLECPP_LIB void preprocess(TokenList &output, const TokenList &rawtokens, std::vector<std::string> &files, std::map<std::string, TokenList*> &filedata, const DUI &dui, OutputList *outputList = NULL, std::list<MacroUsage> *macroUsage = NULL, std::list<IfCond> *ifCond = NULL);
|
||||
|
||||
/**
|
||||
* Deallocate data
|
||||
|
|
Loading…
Reference in New Issue