Clang import; Rename files/namespace

This commit is contained in:
Daniel Marjamäki 2020-01-10 16:29:06 +01:00
parent 8f1a50ffc0
commit 4c778e0999
8 changed files with 45 additions and 48 deletions

View File

@ -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

View File

@ -16,7 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "clangastdump.h"
#include "clangimport.h"
#include "settings.h"
#include "symboldatabase.h"
#include "tokenize.h"
@ -119,7 +119,7 @@ static std::vector<std::string> 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,"<col:") == 0)
@ -323,7 +323,7 @@ void clangastdump::AstNode::setLocations(TokenList *tokenList, int file, int lin
}
}
Token *clangastdump::AstNode::addtoken(TokenList *tokenList, const std::string &str, bool valueType)
Token *clangimport::AstNode::addtoken(TokenList *tokenList, const std::string &str, bool valueType)
{
const Scope *scope = getNestedInScope(tokenList);
tokenList->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<AstNodePtr> children{astNode};
return createScope(tokenList, scopeType, children);
}
Scope *clangastdump::AstNode::createScope(TokenList *tokenList, Scope::ScopeType scopeType, const std::vector<AstNodePtr> &children)
Scope *clangimport::AstNode::createScope(TokenList *tokenList, Scope::ScopeType scopeType, const std::vector<AstNodePtr> &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<AstNodePtr> tree;

View File

@ -18,19 +18,16 @@
//---------------------------------------------------------------------------
#ifndef clangastdumpH
#define clangastdumpH
#ifndef clangimportH
#define clangimportH
//---------------------------------------------------------------------------
#include <string>
#include <vector>
#include <istream>
class Tokenizer;
namespace clangastdump {
namespace clangimport {
void parseClangAstDump(Tokenizer *tokenizer, std::istream &f);
}
#endif

View File

@ -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<SymbolDatabase *>(tokenizer.getSymbolDatabase()), this, &mSettings);
if (mSettings.debugnormal)
tokenizer.printDebugOutput(1);

View File

@ -74,7 +74,7 @@
<ClCompile Include="checkunusedfunctions.cpp" />
<ClCompile Include="checkunusedvar.cpp" />
<ClCompile Include="checkvaarg.cpp" />
<ClCompile Include="clangastdump.cpp" />
<ClCompile Include="clangimport.cpp" />
<ClCompile Include="cppcheck.cpp" />
<ClCompile Include="ctu.cpp" />
<ClCompile Include="errorlogger.cpp" />
@ -129,7 +129,7 @@
<ClInclude Include="checkunusedfunctions.h" />
<ClInclude Include="checkunusedvar.h" />
<ClInclude Include="checkvaarg.h" />
<ClInclude Include="clangastdump.h" />
<ClInclude Include="clangimport.h" />
<ClInclude Include="config.h" />
<ClInclude Include="cppcheck.h" />
<ClInclude Include="ctu.h" />

View File

@ -167,7 +167,7 @@
<ClCompile Include="programmemory.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="clangastdump.cpp">
<ClCompile Include="clangimport.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
@ -328,7 +328,7 @@
<ClInclude Include="ctu.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="clangastdump.h">
<ClInclude Include="clangimport.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>

View File

@ -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 \

View File

@ -14,16 +14,16 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#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)