Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,6 @@ TESTOBJ = test/fixture.o \
test/testbufferoverrun.o \
test/testcharvar.o \
test/testcheck.o \
test/testclangimport.o \
test/testclass.o \
test/testcmdlineparser.o \
test/testcolor.o \
Expand Down Expand Up @@ -549,7 +548,7 @@ $(libcppdir)/checkunusedvar.o: lib/checkunusedvar.cpp lib/addoninfo.h lib/astuti
$(libcppdir)/checkvaarg.o: lib/checkvaarg.cpp lib/addoninfo.h lib/astutils.h lib/check.h lib/checkvaarg.h lib/config.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/smallvector.h lib/sourcelocation.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/vfvalue.h
$(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/checkvaarg.cpp

$(libcppdir)/clangimport.o: lib/clangimport.cpp lib/addoninfo.h lib/clangimport.h lib/config.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/sourcelocation.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/vfvalue.h
$(libcppdir)/clangimport.o: lib/clangimport.cpp externals/picojson/picojson.h externals/simplecpp/simplecpp.h lib/addoninfo.h lib/clangimport.h lib/config.h lib/errortypes.h lib/json.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/sourcelocation.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/vfvalue.h
$(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/clangimport.cpp

$(libcppdir)/color.o: lib/color.cpp lib/color.h lib/config.h
Expand Down Expand Up @@ -723,9 +722,6 @@ test/testcharvar.o: test/testcharvar.cpp externals/simplecpp/simplecpp.h lib/add
test/testcheck.o: test/testcheck.cpp lib/addoninfo.h lib/check.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/standards.h lib/suppressions.h lib/utils.h test/fixture.h
$(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testcheck.cpp

test/testclangimport.o: test/testclangimport.cpp lib/addoninfo.h lib/check.h lib/clangimport.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/sourcelocation.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/vfvalue.h test/fixture.h
$(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testclangimport.cpp

test/testclass.o: test/testclass.cpp externals/simplecpp/simplecpp.h lib/addoninfo.h lib/check.h lib/checkclass.h lib/color.h lib/config.h lib/ctu.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/preprocessor.h lib/settings.h lib/sourcelocation.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/vfvalue.h test/fixture.h test/helpers.h
$(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testclass.cpp

Expand Down
16 changes: 8 additions & 8 deletions lib/clangimport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ std::string clangimport::AstNode::getTemplateParameters() const
void clangimport::AstNode::dumpAst(int num, int indent) const
{
(void)num;
std::cout << std::string(indent, ' ') << mKind;
std::cout << std::string(indent, ' ') << mKind << " " << mJsonObject.at("id").get<std::string>() << " " << getSpelling();
// JSON for (const auto& tok: mExtTokens)
// JSON std::cout << " " << tok;
std::cout << std::endl;
Expand Down Expand Up @@ -873,15 +873,15 @@ Token *clangimport::AstNode::createTokens(TokenList &tokenList)
return nullptr;
}
if (mKind == CXXForRangeStmt) {
/*JSON
Token *forToken = addtoken(tokenList, "for");
Token *par1 = addtoken(tokenList, "(");
AstNodePtr varDecl;
if (children[6]->mKind == DeclStmt)
varDecl = getChild(6)->getChild(0);
else
varDecl = getChild(5)->getChild(0);
varDecl->mExtTokens.pop_back();
for (auto it = children.rbegin(); it != children.rend(); ++it) {
if ((*it)->mKind == DeclStmt) {
varDecl = (*it)->getChild(0);
break;
}
}
varDecl->children.clear();
Token *expr1 = varDecl->createTokens(tokenList);
Token *colon = addtoken(tokenList, ":");
Expand All @@ -906,7 +906,7 @@ Token *clangimport::AstNode::createTokens(TokenList &tokenList)
par1->astOperand2(colon);

createScope(tokenList, Scope::ScopeType::eFor, children.back(), forToken);
*/

return nullptr;
}
if (mKind == CXXMethodDecl) {
Expand Down
2 changes: 1 addition & 1 deletion oss-fuzz/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ $(libcppdir)/checkunusedvar.o: ../lib/checkunusedvar.cpp ../lib/addoninfo.h ../l
$(libcppdir)/checkvaarg.o: ../lib/checkvaarg.cpp ../lib/addoninfo.h ../lib/astutils.h ../lib/check.h ../lib/checkvaarg.h ../lib/config.h ../lib/errortypes.h ../lib/library.h ../lib/mathlib.h ../lib/platform.h ../lib/settings.h ../lib/smallvector.h ../lib/sourcelocation.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/vfvalue.h
$(CXX) ${LIB_FUZZING_ENGINE} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/checkvaarg.cpp

$(libcppdir)/clangimport.o: ../lib/clangimport.cpp ../lib/addoninfo.h ../lib/clangimport.h ../lib/config.h ../lib/errortypes.h ../lib/library.h ../lib/mathlib.h ../lib/platform.h ../lib/settings.h ../lib/sourcelocation.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/vfvalue.h
$(libcppdir)/clangimport.o: ../lib/clangimport.cpp ../externals/picojson/picojson.h ../externals/simplecpp/simplecpp.h ../lib/addoninfo.h ../lib/clangimport.h ../lib/config.h ../lib/errortypes.h ../lib/json.h ../lib/library.h ../lib/mathlib.h ../lib/platform.h ../lib/settings.h ../lib/sourcelocation.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/vfvalue.h
$(CXX) ${LIB_FUZZING_ENGINE} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/clangimport.cpp

$(libcppdir)/color.o: ../lib/color.cpp ../lib/color.h ../lib/config.h
Expand Down
6 changes: 6 additions & 0 deletions test/cli/clang-import_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,12 @@ def test_tokens_function2(tmp_path):
assert '4: return 12 ;' in stdout


def test_tokens_for(tmp_path):
test_file = tmp_path / 'test.cpp'
stdout = _run_cppcheck_debug(test_file, '\nint buf[10]; void foo() { for (int i:buf){} }')
assert '2: int buf@var1 [ 10 ] ; void foo ( ) { for ( int i@var2 :@exprUNIQUE buf@var1 ) { } }' in stdout


def test_tokens_template1(tmp_path):
test_file = tmp_path / 'test.cpp'
stdout = _run_cppcheck_debug(test_file, '\ntemplate<class T> struct Foo {\nT x; };\nFoo<int> foo;\n')
Expand Down
Loading
Loading