Refactoring: Made Preprocessor::simplifyCondition nonstatic

This commit is contained in:
Daniel Marjamäki 2012-01-06 08:42:07 +01:00
parent 66472b09c0
commit bd8c21fc6b
3 changed files with 5 additions and 4 deletions

View File

@ -1221,8 +1221,8 @@ std::list<std::string> Preprocessor::getcfgs(const std::string &filedata, const
void Preprocessor::simplifyCondition(const std::map<std::string, std::string> &cfg, std::string &condition, bool match)
{
Settings settings;
Tokenizer tokenizer(&settings, NULL);
const Settings settings;
Tokenizer tokenizer(&settings, _errorLogger);
std::istringstream istr("(" + condition + ")");
if (!tokenizer.tokenize(istr, "", "", true)) {
// If tokenize returns false, then there is syntax error in the

View File

@ -99,7 +99,7 @@ public:
* @param condition The condition to simplify
* @param match if true, 'defined(A)' is replaced with 0 if A is not defined
*/
static void simplifyCondition(const std::map<std::string, std::string> &variables, std::string &condition, bool match);
void simplifyCondition(const std::map<std::string, std::string> &variables, std::string &condition, bool match);
/**
* preprocess all whitespaces

View File

@ -2858,7 +2858,8 @@ private:
std::map<std::string, std::string> cfg;
cfg["C"] = "";
std::string condition("defined(A) || defined(B) || defined(C)");
Preprocessor::simplifyCondition(cfg, condition, true);
Preprocessor preprocessor(NULL, this);
preprocessor.simplifyCondition(cfg, condition, true);
ASSERT_EQUALS("1", condition);
}