From 59335f80d252685d6ded19c9b51e9f6317e6366b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Wed, 17 May 2017 15:38:31 +0200 Subject: [PATCH] Try to fix windows build. Reduce header dependencies --- lib/cppcheck.cpp | 3 ++- lib/tokenize.cpp | 2 +- lib/tokenize.h | 7 +++++-- lib/tokenlist.cpp | 9 +++++---- lib/tokenlist.h | 7 +++++-- 5 files changed, 18 insertions(+), 10 deletions(-) diff --git a/lib/cppcheck.cpp b/lib/cppcheck.cpp index de4eedd6b..e7472ad39 100644 --- a/lib/cppcheck.cpp +++ b/lib/cppcheck.cpp @@ -312,7 +312,8 @@ unsigned int CppCheck::processFile(const std::string& filename, const std::strin // Create tokens, skip rest of iteration if failed Timer timer("Tokenizer::createTokens", _settings.showtime, &S_timerResults); - _tokenizer.createTokens(preprocessor.preprocess(tokens1, cfg, files)); + const simplecpp::TokenList &tokensP = preprocessor.preprocess(tokens1, cfg, files); + _tokenizer.createTokens(&tokensP); timer.Stop(); // skip rest of iteration if just checking configuration diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index efce842e6..ad138f714 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -1709,7 +1709,7 @@ bool Tokenizer::createTokens(std::istream &code, return list.createTokens(code, Path::getRelativePath(Path::simplifyPath(FileName), _settings->basePaths)); } -void Tokenizer::createTokens(const simplecpp::TokenList &tokenList) +void Tokenizer::createTokens(const simplecpp::TokenList *tokenList) { // make sure settings specified assert(_settings); diff --git a/lib/tokenize.h b/lib/tokenize.h index 0d03325a1..00dd2130c 100644 --- a/lib/tokenize.h +++ b/lib/tokenize.h @@ -24,7 +24,6 @@ #include "errorlogger.h" #include "tokenlist.h" #include "config.h" -#include "simplecpp.h" #include #include @@ -36,6 +35,10 @@ class Settings; class SymbolDatabase; class TimerResults; +namespace simplecpp { + class TokenList; +} + /// @addtogroup Core /// @{ @@ -74,7 +77,7 @@ public: bool IsScopeNoReturn(const Token *endScopeToken, bool *unknown = nullptr) const; bool createTokens(std::istream &code, const std::string& FileName); - void createTokens(const simplecpp::TokenList &tokenList); + void createTokens(const simplecpp::TokenList *tokenList); bool simplifyTokens1(const std::string &configuration); /** diff --git a/lib/tokenlist.cpp b/lib/tokenlist.cpp index 70807cbcd..fe2b2c12d 100644 --- a/lib/tokenlist.cpp +++ b/lib/tokenlist.cpp @@ -25,6 +25,7 @@ #include "settings.h" #include "errorlogger.h" #include "utils.h" +#include "simplecpp.h" #include #include @@ -409,10 +410,10 @@ bool TokenList::createTokens(std::istream &code, const std::string& file0) //--------------------------------------------------------------------------- -void TokenList::createTokens(const simplecpp::TokenList &tokenList) +void TokenList::createTokens(const simplecpp::TokenList *tokenList) { - if (tokenList.cfront()) - _files = tokenList.cfront()->location.files; + if (tokenList->cfront()) + _files = tokenList->cfront()->location.files; else _files.clear(); @@ -426,7 +427,7 @@ void TokenList::createTokens(const simplecpp::TokenList &tokenList) _isCPP = (_settings->enforcedLang == Settings::CPP); } - for (const simplecpp::Token *tok = tokenList.cfront(); tok; tok = tok->next) { + for (const simplecpp::Token *tok = tokenList->cfront(); tok; tok = tok->next) { if (_back) { _back->insertToken(tok->str); } else { diff --git a/lib/tokenlist.h b/lib/tokenlist.h index 87e6f4f46..28b22aa11 100644 --- a/lib/tokenlist.h +++ b/lib/tokenlist.h @@ -24,11 +24,14 @@ #include #include #include "config.h" -#include "simplecpp.h" class Token; class Settings; +namespace simplecpp { + class TokenList; +} + /// @addtogroup Core /// @{ @@ -80,7 +83,7 @@ public: */ bool createTokens(std::istream &code, const std::string& file0 = emptyString); - void createTokens(const simplecpp::TokenList &tokenList); + void createTokens(const simplecpp::TokenList *tokenList); /** Deallocate list */ void deallocateTokens();