diff --git a/Makefile b/Makefile index c5fcd3995..c64e49480 100644 --- a/Makefile +++ b/Makefile @@ -184,7 +184,7 @@ LIBOBJ = $(libcppdir)/analyzerinfo.o \ $(libcppdir)/checkunusedfunctions.o \ $(libcppdir)/checkunusedvar.o \ $(libcppdir)/checkvaarg.o \ - $(libcppdir)/clangastdump.o \ + $(libcppdir)/clangimport.o \ $(libcppdir)/cppcheck.o \ $(libcppdir)/ctu.o \ $(libcppdir)/errorlogger.o \ @@ -226,7 +226,7 @@ TESTOBJ = test/options.o \ test/testboost.o \ test/testbufferoverrun.o \ test/testcharvar.o \ - test/testclangastdump.o \ + test/testclangimport.o \ test/testclass.o \ test/testcmdlineparser.o \ test/testcondition.o \ @@ -481,10 +481,10 @@ $(libcppdir)/checkunusedvar.o: lib/checkunusedvar.cpp lib/astutils.h lib/check.h $(libcppdir)/checkvaarg.o: lib/checkvaarg.cpp lib/astutils.h lib/check.h lib/checkvaarg.h lib/config.h lib/errorlogger.h lib/importproject.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/standards.h lib/suppressions.h lib/symboldatabase.h lib/templatesimplifier.h lib/timer.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/valueflow.h $(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CPPFILESDIR) $(CXXFLAGS) $(UNDEF_STRICT_ANSI) -c -o $(libcppdir)/checkvaarg.o $(libcppdir)/checkvaarg.cpp -$(libcppdir)/clangastdump.o: lib/clangastdump.cpp lib/clangastdump.h lib/config.h lib/errorlogger.h lib/library.h lib/mathlib.h lib/platform.h lib/standards.h lib/suppressions.h lib/symboldatabase.h lib/templatesimplifier.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/valueflow.h - $(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CPPFILESDIR) $(CXXFLAGS) $(UNDEF_STRICT_ANSI) -c -o $(libcppdir)/clangastdump.o $(libcppdir)/clangastdump.cpp +$(libcppdir)/clangimport.o: lib/clangimport.cpp lib/config.h lib/errorlogger.h lib/importproject.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/standards.h lib/suppressions.h lib/symboldatabase.h lib/templatesimplifier.h lib/timer.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/valueflow.h + $(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CPPFILESDIR) $(CXXFLAGS) $(UNDEF_STRICT_ANSI) -c -o $(libcppdir)/clangimport.o $(libcppdir)/clangimport.cpp -$(libcppdir)/cppcheck.o: lib/cppcheck.cpp externals/picojson.h externals/simplecpp/simplecpp.h externals/tinyxml/tinyxml2.h lib/analyzerinfo.h lib/check.h lib/checkunusedfunctions.h lib/clangastdump.h lib/config.h lib/cppcheck.h lib/ctu.h lib/errorlogger.h lib/exprengine.h lib/importproject.h lib/library.h lib/mathlib.h lib/path.h lib/platform.h lib/preprocessor.h lib/settings.h lib/standards.h lib/suppressions.h lib/templatesimplifier.h lib/timer.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/valueflow.h lib/version.h +$(libcppdir)/cppcheck.o: lib/cppcheck.cpp externals/picojson.h externals/simplecpp/simplecpp.h externals/tinyxml/tinyxml2.h lib/analyzerinfo.h lib/check.h lib/checkunusedfunctions.h lib/config.h lib/cppcheck.h lib/ctu.h lib/errorlogger.h lib/exprengine.h lib/importproject.h lib/library.h lib/mathlib.h lib/path.h lib/platform.h lib/preprocessor.h lib/settings.h lib/standards.h lib/suppressions.h lib/templatesimplifier.h lib/timer.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/valueflow.h lib/version.h $(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CPPFILESDIR) $(CXXFLAGS) $(UNDEF_STRICT_ANSI) -c -o $(libcppdir)/cppcheck.o $(libcppdir)/cppcheck.cpp $(libcppdir)/ctu.o: lib/ctu.cpp externals/tinyxml/tinyxml2.h lib/astutils.h lib/check.h lib/config.h lib/ctu.h lib/errorlogger.h lib/importproject.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/standards.h lib/suppressions.h lib/symboldatabase.h lib/templatesimplifier.h lib/timer.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/valueflow.h @@ -592,8 +592,8 @@ test/testbufferoverrun.o: test/testbufferoverrun.cpp externals/tinyxml/tinyxml2. test/testcharvar.o: test/testcharvar.cpp lib/check.h lib/checkother.h lib/config.h lib/errorlogger.h lib/importproject.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/standards.h lib/suppressions.h lib/templatesimplifier.h lib/timer.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/valueflow.h test/testsuite.h $(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CPPFILESDIR) $(CXXFLAGS) $(UNDEF_STRICT_ANSI) -c -o test/testcharvar.o test/testcharvar.cpp -test/testclangastdump.o: test/testclangastdump.cpp lib/clangastdump.h lib/config.h lib/errorlogger.h lib/suppressions.h test/testsuite.h - $(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CPPFILESDIR) $(CXXFLAGS) $(UNDEF_STRICT_ANSI) -c -o test/testclangastdump.o test/testclangastdump.cpp +test/testclangimport.o: test/testclangimport.cpp lib/config.h lib/errorlogger.h lib/importproject.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/standards.h lib/suppressions.h lib/templatesimplifier.h lib/timer.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/valueflow.h test/testsuite.h + $(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CPPFILESDIR) $(CXXFLAGS) $(UNDEF_STRICT_ANSI) -c -o test/testclangimport.o test/testclangimport.cpp test/testclass.o: test/testclass.cpp externals/tinyxml/tinyxml2.h lib/check.h lib/checkclass.h lib/config.h lib/errorlogger.h lib/importproject.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/standards.h lib/suppressions.h lib/templatesimplifier.h lib/timer.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/valueflow.h test/testsuite.h $(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CPPFILESDIR) $(CXXFLAGS) $(UNDEF_STRICT_ANSI) -c -o test/testclass.o test/testclass.cpp diff --git a/lib/clangastdump.cpp b/lib/clangimport.cpp similarity index 95% rename from lib/clangastdump.cpp rename to lib/clangimport.cpp index 6028a50bc..f6eb8134d 100644 --- a/lib/clangastdump.cpp +++ b/lib/clangimport.cpp @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -#include "clangastdump.h" +#include "clangimport.h" #include "settings.h" #include "symboldatabase.h" #include "tokenize.h" @@ -119,7 +119,7 @@ static std::vector splitString(const std::string &line) return ret; } -namespace clangastdump { +namespace clangimport { struct Data { struct Decl { Decl(Token *def, Variable *var) : def(def), function(nullptr), var(var) {} @@ -234,7 +234,7 @@ namespace clangastdump { }; } -std::string clangastdump::AstNode::getSpelling() const +std::string clangimport::AstNode::getSpelling() const { if (mExtTokens.back() == "extern") return mExtTokens[mExtTokens.size() - 3]; @@ -245,7 +245,7 @@ std::string clangastdump::AstNode::getSpelling() const return mExtTokens[mExtTokens.size() - 2]; } -std::string clangastdump::AstNode::getType() const +std::string clangimport::AstNode::getType() const { if (nodeType == BinaryOperator) return unquote(mExtTokens[mExtTokens.size() - 2]); @@ -270,7 +270,7 @@ std::string clangastdump::AstNode::getType() const return ""; } -std::string clangastdump::AstNode::getTemplateParameters() const +std::string clangimport::AstNode::getTemplateParameters() const { if (children.empty() || children[0]->nodeType != TemplateArgument) return ""; @@ -287,7 +287,7 @@ std::string clangastdump::AstNode::getTemplateParameters() const return templateParameters + ">"; } -void clangastdump::AstNode::dumpAst(int num, int indent) const +void clangimport::AstNode::dumpAst(int num, int indent) const { (void)num; std::cout << std::string(indent, ' ') << nodeType; @@ -302,7 +302,7 @@ void clangastdump::AstNode::dumpAst(int num, int indent) const } } -void clangastdump::AstNode::setLocations(TokenList *tokenList, int file, int line, int col) +void clangimport::AstNode::setLocations(TokenList *tokenList, int file, int line, int col) { for (const std::string &ext: mExtTokens) { if (ext.compare(0,5,"addtoken(str, mLine, mFile); @@ -334,7 +334,7 @@ Token *clangastdump::AstNode::addtoken(TokenList *tokenList, const std::string & return tokenList->back(); } -void clangastdump::AstNode::addTypeTokens(TokenList *tokenList, const std::string &str) +void clangimport::AstNode::addTypeTokens(TokenList *tokenList, const std::string &str) { if (str.find("\':\'") != std::string::npos) { addTypeTokens(tokenList, str.substr(0, str.find("\':\'") + 1)); @@ -354,7 +354,7 @@ void clangastdump::AstNode::addTypeTokens(TokenList *tokenList, const std::strin addtoken(tokenList, s, false); } -const Scope *clangastdump::AstNode::getNestedInScope(TokenList *tokenList) +const Scope *clangimport::AstNode::getNestedInScope(TokenList *tokenList) { if (!tokenList->back()) return &mData->mSymbolDatabase->scopeList.front(); @@ -363,7 +363,7 @@ const Scope *clangastdump::AstNode::getNestedInScope(TokenList *tokenList) return tokenList->back()->scope(); } -void clangastdump::AstNode::setValueType(Token *tok) +void clangimport::AstNode::setValueType(Token *tok) { const std::string &type = getType(); @@ -397,13 +397,13 @@ void clangastdump::AstNode::setValueType(Token *tok) } } -Scope *clangastdump::AstNode::createScope(TokenList *tokenList, Scope::ScopeType scopeType, AstNodePtr astNode) +Scope *clangimport::AstNode::createScope(TokenList *tokenList, Scope::ScopeType scopeType, AstNodePtr astNode) { std::vector children{astNode}; return createScope(tokenList, scopeType, children); } -Scope *clangastdump::AstNode::createScope(TokenList *tokenList, Scope::ScopeType scopeType, const std::vector &children) +Scope *clangimport::AstNode::createScope(TokenList *tokenList, Scope::ScopeType scopeType, const std::vector &children) { SymbolDatabase *symbolDatabase = mData->mSymbolDatabase; @@ -427,7 +427,7 @@ Scope *clangastdump::AstNode::createScope(TokenList *tokenList, Scope::ScopeType return scope; } -Token *clangastdump::AstNode::createTokens(TokenList *tokenList) +Token *clangimport::AstNode::createTokens(TokenList *tokenList) { if (nodeType == ArraySubscriptExpr) { Token *array = children[0]->createTokens(tokenList); @@ -716,7 +716,7 @@ Token *clangastdump::AstNode::createTokens(TokenList *tokenList) return addtoken(tokenList, "?" + nodeType + "?"); } -Token * clangastdump::AstNode::createTokensCall(TokenList *tokenList) +Token * clangimport::AstNode::createTokensCall(TokenList *tokenList) { int firstParam; Token *f; @@ -752,7 +752,7 @@ Token * clangastdump::AstNode::createTokensCall(TokenList *tokenList) return par1; } -void clangastdump::AstNode::createTokensFunctionDecl(TokenList *tokenList) +void clangimport::AstNode::createTokensFunctionDecl(TokenList *tokenList) { SymbolDatabase *symbolDatabase = mData->mSymbolDatabase; const int nameIndex = (mExtTokens.back() == "extern") ? @@ -804,7 +804,7 @@ void clangastdump::AstNode::createTokensFunctionDecl(TokenList *tokenList) } } -void clangastdump::AstNode::createTokensForCXXRecord(TokenList *tokenList) +void clangimport::AstNode::createTokensForCXXRecord(TokenList *tokenList) { Token *classToken = addtoken(tokenList, "class"); const std::string className = mExtTokens[mExtTokens.size() - 2] + getTemplateParameters(); @@ -827,7 +827,7 @@ void clangastdump::AstNode::createTokensForCXXRecord(TokenList *tokenList) scope->definedType = &mData->mSymbolDatabase->typeList.back(); } -Token * clangastdump::AstNode::createTokensVarDecl(TokenList *tokenList) +Token * clangimport::AstNode::createTokensVarDecl(TokenList *tokenList) { const std::string addr = mExtTokens.front(); int typeIndex = mExtTokens.size() - 1; @@ -850,7 +850,7 @@ Token * clangastdump::AstNode::createTokensVarDecl(TokenList *tokenList) return vartok1; } -void clangastdump::parseClangAstDump(Tokenizer *tokenizer, std::istream &f) +void clangimport::parseClangAstDump(Tokenizer *tokenizer, std::istream &f) { TokenList *tokenList = &tokenizer->list; @@ -859,7 +859,7 @@ void clangastdump::parseClangAstDump(Tokenizer *tokenizer, std::istream &f) symbolDatabase->scopeList.push_back(Scope(nullptr, nullptr, nullptr)); symbolDatabase->scopeList.back().type = Scope::ScopeType::eGlobal; - clangastdump::Data data; + clangimport::Data data; data.mSymbolDatabase = symbolDatabase; std::string line; std::vector tree; diff --git a/lib/clangastdump.h b/lib/clangimport.h similarity index 90% rename from lib/clangastdump.h rename to lib/clangimport.h index 43c5870a0..b6e0e3cb0 100644 --- a/lib/clangastdump.h +++ b/lib/clangimport.h @@ -18,19 +18,16 @@ //--------------------------------------------------------------------------- -#ifndef clangastdumpH -#define clangastdumpH +#ifndef clangimportH +#define clangimportH //--------------------------------------------------------------------------- -#include -#include +#include class Tokenizer; -namespace clangastdump { - +namespace clangimport { void parseClangAstDump(Tokenizer *tokenizer, std::istream &f); - } #endif diff --git a/lib/cppcheck.cpp b/lib/cppcheck.cpp index 307fda3a6..fd28b4605 100644 --- a/lib/cppcheck.cpp +++ b/lib/cppcheck.cpp @@ -19,7 +19,7 @@ #include "check.h" #include "checkunusedfunctions.h" -#include "clangastdump.h" +#include "clangimport.h" #include "ctu.h" #include "library.h" #include "mathlib.h" @@ -282,7 +282,7 @@ unsigned int CppCheck::check(const std::string &path) std::istringstream ast(res.second); Tokenizer tokenizer(&mSettings, this); tokenizer.list.appendFileIfNew(path); - clangastdump::parseClangAstDump(&tokenizer, ast); + clangimport::parseClangAstDump(&tokenizer, ast); //ValueFlow::setValues(&tokenizer.list, const_cast(tokenizer.getSymbolDatabase()), this, &mSettings); if (mSettings.debugnormal) tokenizer.printDebugOutput(1); diff --git a/lib/cppcheck.vcxproj b/lib/cppcheck.vcxproj index e6d141b5a..23a6238c7 100644 --- a/lib/cppcheck.vcxproj +++ b/lib/cppcheck.vcxproj @@ -74,7 +74,7 @@ - + @@ -129,7 +129,7 @@ - + diff --git a/lib/cppcheck.vcxproj.filters b/lib/cppcheck.vcxproj.filters index 931e16ca1..7f09fadf8 100644 --- a/lib/cppcheck.vcxproj.filters +++ b/lib/cppcheck.vcxproj.filters @@ -167,7 +167,7 @@ Source Files - + Source Files @@ -328,7 +328,7 @@ Header Files - + Header Files diff --git a/lib/lib.pri b/lib/lib.pri index 83b357b38..c14991ef4 100644 --- a/lib/lib.pri +++ b/lib/lib.pri @@ -31,7 +31,7 @@ HEADERS += $${PWD}/analyzerinfo.h \ $${PWD}/checkunusedfunctions.h \ $${PWD}/checkunusedvar.h \ $${PWD}/checkvaarg.h \ - $${PWD}/clangastdump.h \ + $${PWD}/clangimport.h \ $${PWD}/cppcheck.h \ $${PWD}/ctu.h \ $${PWD}/errorlogger.h \ @@ -83,7 +83,7 @@ SOURCES += $${PWD}/analyzerinfo.cpp \ $${PWD}/checkunusedfunctions.cpp \ $${PWD}/checkunusedvar.cpp \ $${PWD}/checkvaarg.cpp \ - $${PWD}/clangastdump.cpp \ + $${PWD}/clangimport.cpp \ $${PWD}/cppcheck.cpp \ $${PWD}/ctu.cpp \ $${PWD}/errorlogger.cpp \ diff --git a/test/testclangastdump.cpp b/test/testclangimport.cpp similarity index 99% rename from test/testclangastdump.cpp rename to test/testclangimport.cpp index 500b55a95..9e4c242e7 100644 --- a/test/testclangastdump.cpp +++ b/test/testclangimport.cpp @@ -14,16 +14,16 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -#include "clangastdump.h" +#include "clangimport.h" #include "settings.h" #include "tokenize.h" #include "testsuite.h" -class TestClangAstDump: public TestFixture { +class TestClangImport: public TestFixture { public: - TestClangAstDump() - :TestFixture("TestClangAstDump") { + TestClangImport() + :TestFixture("TestClangImport") { } @@ -70,7 +70,7 @@ private: Settings settings; Tokenizer tokenizer(&settings, this); std::istringstream istr(clang); - clangastdump::parseClangAstDump(&tokenizer, istr); + clangimport::parseClangAstDump(&tokenizer, istr); return tokenizer.tokens()->stringifyList(true, false, false, true, false); } @@ -485,4 +485,4 @@ private: } }; -REGISTER_TEST(TestClangAstDump) +REGISTER_TEST(TestClangImport)