diff --git a/Makefile b/Makefile index a720612033f8..b59a07726240 100644 --- a/Makefile +++ b/Makefile @@ -693,31 +693,31 @@ test/main.o: test/main.cpp externals/simplecpp/simplecpp.h lib/addoninfo.h lib/c test/options.o: test/options.cpp test/options.h $(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/options.cpp -test/test64bit.o: test/test64bit.cpp lib/addoninfo.h lib/check.h lib/check64bit.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/tokenize.h lib/tokenlist.h lib/utils.h test/fixture.h +test/test64bit.o: test/test64bit.cpp externals/simplecpp/simplecpp.h lib/addoninfo.h lib/check.h lib/check64bit.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/preprocessor.h lib/settings.h lib/standards.h lib/suppressions.h lib/tokenize.h lib/tokenlist.h lib/utils.h test/fixture.h test/helpers.h $(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/test64bit.cpp test/testanalyzerinformation.o: test/testanalyzerinformation.cpp lib/addoninfo.h lib/analyzerinfo.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/testanalyzerinformation.cpp -test/testassert.o: test/testassert.cpp lib/addoninfo.h lib/check.h lib/checkassert.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/tokenize.h lib/tokenlist.h lib/utils.h test/fixture.h +test/testassert.o: test/testassert.cpp externals/simplecpp/simplecpp.h lib/addoninfo.h lib/check.h lib/checkassert.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/preprocessor.h lib/settings.h lib/standards.h lib/suppressions.h lib/tokenize.h lib/tokenlist.h lib/utils.h test/fixture.h test/helpers.h $(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testassert.cpp -test/testastutils.o: test/testastutils.cpp lib/addoninfo.h lib/astutils.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/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 test/fixture.h +test/testastutils.o: test/testastutils.cpp externals/simplecpp/simplecpp.h lib/addoninfo.h lib/astutils.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/preprocessor.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 test/fixture.h test/helpers.h $(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testastutils.cpp -test/testautovariables.o: test/testautovariables.cpp lib/addoninfo.h lib/check.h lib/checkautovariables.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/tokenize.h lib/tokenlist.h lib/utils.h test/fixture.h +test/testautovariables.o: test/testautovariables.cpp externals/simplecpp/simplecpp.h lib/addoninfo.h lib/check.h lib/checkautovariables.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/preprocessor.h lib/settings.h lib/standards.h lib/suppressions.h lib/tokenize.h lib/tokenlist.h lib/utils.h test/fixture.h test/helpers.h $(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testautovariables.cpp -test/testbool.o: test/testbool.cpp lib/addoninfo.h lib/check.h lib/checkbool.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/tokenize.h lib/tokenlist.h lib/utils.h test/fixture.h +test/testbool.o: test/testbool.cpp externals/simplecpp/simplecpp.h lib/addoninfo.h lib/check.h lib/checkbool.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/preprocessor.h lib/settings.h lib/standards.h lib/suppressions.h lib/tokenize.h lib/tokenlist.h lib/utils.h test/fixture.h test/helpers.h $(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testbool.cpp -test/testboost.o: test/testboost.cpp lib/addoninfo.h lib/check.h lib/checkboost.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/tokenize.h lib/tokenlist.h lib/utils.h test/fixture.h +test/testboost.o: test/testboost.cpp externals/simplecpp/simplecpp.h lib/addoninfo.h lib/check.h lib/checkboost.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/preprocessor.h lib/settings.h lib/standards.h lib/suppressions.h lib/tokenize.h lib/tokenlist.h lib/utils.h test/fixture.h test/helpers.h $(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testboost.cpp -test/testbufferoverrun.o: test/testbufferoverrun.cpp lib/addoninfo.h lib/check.h lib/checkbufferoverrun.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/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 +test/testbufferoverrun.o: test/testbufferoverrun.cpp externals/simplecpp/simplecpp.h lib/addoninfo.h lib/check.h lib/checkbufferoverrun.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/testbufferoverrun.cpp -test/testcharvar.o: test/testcharvar.cpp lib/addoninfo.h lib/check.h lib/checkother.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/tokenize.h lib/tokenlist.h lib/utils.h test/fixture.h +test/testcharvar.o: test/testcharvar.cpp externals/simplecpp/simplecpp.h lib/addoninfo.h lib/check.h lib/checkother.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/preprocessor.h lib/settings.h lib/standards.h lib/suppressions.h lib/tokenize.h lib/tokenlist.h lib/utils.h test/fixture.h test/helpers.h $(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testcharvar.cpp 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 @@ -729,7 +729,7 @@ test/testclangimport.o: test/testclangimport.cpp lib/addoninfo.h lib/check.h lib 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/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 -test/testcmdlineparser.o: test/testcmdlineparser.cpp cli/cmdlinelogger.h cli/cmdlineparser.h cli/cppcheckexecutor.h lib/addoninfo.h lib/check.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/filesettings.h lib/library.h lib/mathlib.h lib/path.h lib/platform.h lib/settings.h lib/standards.h lib/suppressions.h lib/timer.h lib/tokenize.h lib/tokenlist.h lib/utils.h test/fixture.h test/helpers.h test/redirect.h +test/testcmdlineparser.o: test/testcmdlineparser.cpp cli/cmdlinelogger.h cli/cmdlineparser.h cli/cppcheckexecutor.h externals/simplecpp/simplecpp.h lib/addoninfo.h lib/check.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/filesettings.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/timer.h lib/tokenize.h lib/tokenlist.h lib/utils.h test/fixture.h test/helpers.h test/redirect.h $(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testcmdlineparser.cpp test/testcolor.o: test/testcolor.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 @@ -738,52 +738,52 @@ test/testcolor.o: test/testcolor.cpp lib/addoninfo.h lib/check.h lib/color.h lib test/testcondition.o: test/testcondition.cpp externals/simplecpp/simplecpp.h lib/addoninfo.h lib/check.h lib/checkcondition.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/preprocessor.h lib/settings.h lib/standards.h lib/suppressions.h lib/tokenize.h lib/tokenlist.h lib/utils.h test/fixture.h test/helpers.h $(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testcondition.cpp -test/testconstructors.o: test/testconstructors.cpp lib/addoninfo.h lib/check.h lib/checkclass.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 +test/testconstructors.o: test/testconstructors.cpp externals/simplecpp/simplecpp.h lib/addoninfo.h lib/check.h lib/checkclass.h lib/color.h lib/config.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/testconstructors.cpp -test/testcppcheck.o: test/testcppcheck.cpp lib/addoninfo.h lib/analyzerinfo.h lib/check.h lib/color.h lib/config.h lib/cppcheck.h lib/errorlogger.h lib/errortypes.h lib/filesettings.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/standards.h lib/suppressions.h lib/tokenize.h lib/tokenlist.h lib/utils.h test/fixture.h test/helpers.h +test/testcppcheck.o: test/testcppcheck.cpp externals/simplecpp/simplecpp.h lib/addoninfo.h lib/analyzerinfo.h lib/check.h lib/color.h lib/config.h lib/cppcheck.h lib/errorlogger.h lib/errortypes.h lib/filesettings.h lib/library.h lib/mathlib.h lib/platform.h lib/preprocessor.h lib/settings.h lib/standards.h lib/suppressions.h lib/tokenize.h lib/tokenlist.h lib/utils.h test/fixture.h test/helpers.h $(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testcppcheck.cpp test/testerrorlogger.o: test/testerrorlogger.cpp externals/tinyxml2/tinyxml2.h lib/addoninfo.h lib/analyzerinfo.h lib/check.h lib/color.h lib/config.h lib/cppcheck.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 lib/xml.h test/fixture.h $(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testerrorlogger.cpp -test/testexceptionsafety.o: test/testexceptionsafety.cpp lib/addoninfo.h lib/check.h lib/checkexceptionsafety.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/tokenize.h lib/tokenlist.h lib/utils.h test/fixture.h +test/testexceptionsafety.o: test/testexceptionsafety.cpp externals/simplecpp/simplecpp.h lib/addoninfo.h lib/check.h lib/checkexceptionsafety.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/preprocessor.h lib/settings.h lib/standards.h lib/suppressions.h lib/tokenize.h lib/tokenlist.h lib/utils.h test/fixture.h test/helpers.h $(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testexceptionsafety.cpp test/testfilelister.o: test/testfilelister.cpp cli/filelister.h 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/path.h lib/pathmatch.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/testfilelister.cpp -test/testfunctions.o: test/testfunctions.cpp lib/addoninfo.h lib/check.h lib/checkfunctions.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/tokenize.h lib/tokenlist.h lib/utils.h test/fixture.h test/helpers.h +test/testfunctions.o: test/testfunctions.cpp externals/simplecpp/simplecpp.h lib/addoninfo.h lib/check.h lib/checkfunctions.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/preprocessor.h lib/settings.h lib/standards.h lib/suppressions.h lib/tokenize.h lib/tokenlist.h lib/utils.h test/fixture.h test/helpers.h $(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testfunctions.cpp -test/testgarbage.o: test/testgarbage.cpp externals/simplecpp/simplecpp.h 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/preprocessor.h lib/settings.h lib/standards.h lib/suppressions.h lib/templatesimplifier.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/vfvalue.h test/fixture.h +test/testgarbage.o: test/testgarbage.cpp externals/simplecpp/simplecpp.h 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/preprocessor.h lib/settings.h lib/standards.h lib/suppressions.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/testgarbage.cpp test/testimportproject.o: test/testimportproject.cpp lib/addoninfo.h lib/check.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/filesettings.h lib/importproject.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 test/redirect.h $(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testimportproject.cpp -test/testincompletestatement.o: test/testincompletestatement.cpp lib/addoninfo.h lib/check.h lib/checkother.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/tokenize.h lib/tokenlist.h lib/utils.h test/fixture.h test/helpers.h +test/testincompletestatement.o: test/testincompletestatement.cpp externals/simplecpp/simplecpp.h lib/addoninfo.h lib/check.h lib/checkother.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/preprocessor.h lib/settings.h lib/standards.h lib/suppressions.h lib/tokenize.h lib/tokenlist.h lib/utils.h test/fixture.h test/helpers.h $(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testincompletestatement.cpp -test/testinternal.o: test/testinternal.cpp lib/addoninfo.h lib/check.h lib/checkinternal.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/tokenize.h lib/tokenlist.h lib/utils.h test/fixture.h +test/testinternal.o: test/testinternal.cpp externals/simplecpp/simplecpp.h lib/addoninfo.h lib/check.h lib/checkinternal.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/preprocessor.h lib/settings.h lib/standards.h lib/suppressions.h lib/tokenize.h lib/tokenlist.h lib/utils.h test/fixture.h test/helpers.h $(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testinternal.cpp -test/testio.o: test/testio.cpp lib/addoninfo.h lib/check.h lib/checkio.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/tokenize.h lib/tokenlist.h lib/utils.h test/fixture.h test/helpers.h +test/testio.o: test/testio.cpp externals/simplecpp/simplecpp.h lib/addoninfo.h lib/check.h lib/checkio.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/preprocessor.h lib/settings.h lib/standards.h lib/suppressions.h lib/tokenize.h lib/tokenlist.h lib/utils.h test/fixture.h test/helpers.h $(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testio.cpp -test/testleakautovar.o: test/testleakautovar.cpp lib/addoninfo.h lib/check.h lib/checkleakautovar.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/tokenize.h lib/tokenlist.h lib/utils.h test/fixture.h test/helpers.h +test/testleakautovar.o: test/testleakautovar.cpp externals/simplecpp/simplecpp.h lib/addoninfo.h lib/check.h lib/checkleakautovar.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/preprocessor.h lib/settings.h lib/standards.h lib/suppressions.h lib/tokenize.h lib/tokenlist.h lib/utils.h test/fixture.h test/helpers.h $(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testleakautovar.cpp -test/testlibrary.o: test/testlibrary.cpp externals/tinyxml2/tinyxml2.h 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/templatesimplifier.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/vfvalue.h lib/xml.h test/fixture.h test/helpers.h +test/testlibrary.o: test/testlibrary.cpp externals/simplecpp/simplecpp.h externals/tinyxml2/tinyxml2.h 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/preprocessor.h lib/settings.h lib/standards.h lib/suppressions.h lib/templatesimplifier.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/vfvalue.h lib/xml.h test/fixture.h test/helpers.h $(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testlibrary.cpp test/testmathlib.o: test/testmathlib.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/testmathlib.cpp -test/testmemleak.o: test/testmemleak.cpp lib/addoninfo.h lib/check.h lib/checkmemoryleak.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 +test/testmemleak.o: test/testmemleak.cpp externals/simplecpp/simplecpp.h lib/addoninfo.h lib/check.h lib/checkmemoryleak.h lib/color.h lib/config.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/testmemleak.cpp -test/testnullpointer.o: test/testnullpointer.cpp lib/addoninfo.h lib/check.h lib/checknullpointer.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/settings.h lib/standards.h lib/suppressions.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 +test/testnullpointer.o: test/testnullpointer.cpp externals/simplecpp/simplecpp.h lib/addoninfo.h lib/check.h lib/checknullpointer.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/standards.h lib/suppressions.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/testnullpointer.cpp test/testoptions.o: test/testoptions.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 test/options.h @@ -792,7 +792,7 @@ test/testoptions.o: test/testoptions.cpp lib/addoninfo.h lib/check.h lib/color.h test/testother.o: test/testother.cpp externals/simplecpp/simplecpp.h lib/addoninfo.h lib/check.h lib/checkother.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/preprocessor.h lib/settings.h lib/standards.h lib/suppressions.h lib/tokenize.h lib/tokenlist.h lib/utils.h test/fixture.h test/helpers.h $(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testother.cpp -test/testpath.o: test/testpath.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/path.h lib/platform.h lib/settings.h lib/standards.h lib/suppressions.h lib/tokenize.h lib/tokenlist.h lib/utils.h test/fixture.h test/helpers.h +test/testpath.o: test/testpath.cpp externals/simplecpp/simplecpp.h 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/path.h lib/platform.h lib/preprocessor.h lib/settings.h lib/standards.h lib/suppressions.h lib/tokenize.h lib/tokenlist.h lib/utils.h test/fixture.h test/helpers.h $(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testpath.cpp test/testpathmatch.o: test/testpathmatch.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/pathmatch.h lib/platform.h lib/settings.h lib/standards.h lib/suppressions.h lib/utils.h test/fixture.h @@ -801,79 +801,79 @@ test/testpathmatch.o: test/testpathmatch.cpp lib/addoninfo.h lib/check.h lib/col test/testplatform.o: test/testplatform.cpp externals/tinyxml2/tinyxml2.h 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 lib/xml.h test/fixture.h $(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testplatform.cpp -test/testpostfixoperator.o: test/testpostfixoperator.cpp lib/addoninfo.h lib/check.h lib/checkpostfixoperator.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/tokenize.h lib/tokenlist.h lib/utils.h test/fixture.h +test/testpostfixoperator.o: test/testpostfixoperator.cpp externals/simplecpp/simplecpp.h lib/addoninfo.h lib/check.h lib/checkpostfixoperator.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/preprocessor.h lib/settings.h lib/standards.h lib/suppressions.h lib/tokenize.h lib/tokenlist.h lib/utils.h test/fixture.h test/helpers.h $(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testpostfixoperator.cpp test/testpreprocessor.o: test/testpreprocessor.cpp externals/simplecpp/simplecpp.h 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/path.h lib/platform.h lib/preprocessor.h lib/settings.h lib/standards.h lib/suppressions.h lib/tokenize.h lib/tokenlist.h lib/utils.h test/fixture.h test/helpers.h $(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testpreprocessor.cpp -test/testprocessexecutor.o: test/testprocessexecutor.cpp cli/executor.h cli/processexecutor.h lib/addoninfo.h lib/analyzerinfo.h lib/check.h lib/color.h lib/config.h lib/cppcheck.h lib/errorlogger.h lib/errortypes.h lib/filesettings.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/standards.h lib/suppressions.h lib/timer.h lib/tokenize.h lib/tokenlist.h lib/utils.h test/fixture.h test/helpers.h test/redirect.h +test/testprocessexecutor.o: test/testprocessexecutor.cpp cli/executor.h cli/processexecutor.h externals/simplecpp/simplecpp.h lib/addoninfo.h lib/analyzerinfo.h lib/check.h lib/color.h lib/config.h lib/cppcheck.h lib/errorlogger.h lib/errortypes.h lib/filesettings.h lib/library.h lib/mathlib.h lib/platform.h lib/preprocessor.h lib/settings.h lib/standards.h lib/suppressions.h lib/timer.h lib/tokenize.h lib/tokenlist.h lib/utils.h test/fixture.h test/helpers.h test/redirect.h $(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testprocessexecutor.cpp -test/testsettings.o: test/testsettings.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/tokenize.h lib/tokenlist.h lib/utils.h test/fixture.h test/helpers.h +test/testsettings.o: test/testsettings.cpp externals/simplecpp/simplecpp.h 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/preprocessor.h lib/settings.h lib/standards.h lib/suppressions.h lib/tokenize.h lib/tokenlist.h lib/utils.h test/fixture.h test/helpers.h $(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testsettings.cpp -test/testsimplifytemplate.o: test/testsimplifytemplate.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/templatesimplifier.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/vfvalue.h test/fixture.h +test/testsimplifytemplate.o: test/testsimplifytemplate.cpp externals/simplecpp/simplecpp.h 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/preprocessor.h lib/settings.h lib/standards.h lib/suppressions.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/testsimplifytemplate.cpp -test/testsimplifytokens.o: test/testsimplifytokens.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/templatesimplifier.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/vfvalue.h test/fixture.h test/helpers.h +test/testsimplifytokens.o: test/testsimplifytokens.cpp externals/simplecpp/simplecpp.h 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/preprocessor.h lib/settings.h lib/standards.h lib/suppressions.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/testsimplifytokens.cpp -test/testsimplifytypedef.o: test/testsimplifytypedef.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/templatesimplifier.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/vfvalue.h test/fixture.h test/helpers.h +test/testsimplifytypedef.o: test/testsimplifytypedef.cpp externals/simplecpp/simplecpp.h 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/preprocessor.h lib/settings.h lib/standards.h lib/suppressions.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/testsimplifytypedef.cpp -test/testsimplifyusing.o: test/testsimplifyusing.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/templatesimplifier.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/vfvalue.h test/fixture.h test/helpers.h +test/testsimplifyusing.o: test/testsimplifyusing.cpp externals/simplecpp/simplecpp.h 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/preprocessor.h lib/settings.h lib/standards.h lib/suppressions.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/testsimplifyusing.cpp -test/testsingleexecutor.o: test/testsingleexecutor.cpp cli/executor.h cli/singleexecutor.h lib/addoninfo.h lib/analyzerinfo.h lib/check.h lib/color.h lib/config.h lib/cppcheck.h lib/errorlogger.h lib/errortypes.h lib/filesettings.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/standards.h lib/suppressions.h lib/timer.h lib/tokenize.h lib/tokenlist.h lib/utils.h test/fixture.h test/helpers.h test/redirect.h +test/testsingleexecutor.o: test/testsingleexecutor.cpp cli/executor.h cli/singleexecutor.h externals/simplecpp/simplecpp.h lib/addoninfo.h lib/analyzerinfo.h lib/check.h lib/color.h lib/config.h lib/cppcheck.h lib/errorlogger.h lib/errortypes.h lib/filesettings.h lib/library.h lib/mathlib.h lib/platform.h lib/preprocessor.h lib/settings.h lib/standards.h lib/suppressions.h lib/timer.h lib/tokenize.h lib/tokenlist.h lib/utils.h test/fixture.h test/helpers.h test/redirect.h $(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testsingleexecutor.cpp -test/testsizeof.o: test/testsizeof.cpp lib/addoninfo.h lib/check.h lib/checksizeof.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/tokenize.h lib/tokenlist.h lib/utils.h test/fixture.h test/helpers.h +test/testsizeof.o: test/testsizeof.cpp externals/simplecpp/simplecpp.h lib/addoninfo.h lib/check.h lib/checksizeof.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/preprocessor.h lib/settings.h lib/standards.h lib/suppressions.h lib/tokenize.h lib/tokenlist.h lib/utils.h test/fixture.h test/helpers.h $(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testsizeof.cpp -test/teststl.o: test/teststl.cpp lib/addoninfo.h lib/check.h lib/checkstl.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/tokenize.h lib/tokenlist.h lib/utils.h lib/vfvalue.h test/fixture.h +test/teststl.o: test/teststl.cpp externals/simplecpp/simplecpp.h lib/addoninfo.h lib/check.h lib/checkstl.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/preprocessor.h lib/settings.h lib/standards.h lib/suppressions.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/teststl.cpp -test/teststring.o: test/teststring.cpp lib/addoninfo.h lib/check.h lib/checkstring.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/tokenize.h lib/tokenlist.h lib/utils.h test/fixture.h test/helpers.h +test/teststring.o: test/teststring.cpp externals/simplecpp/simplecpp.h lib/addoninfo.h lib/check.h lib/checkstring.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/preprocessor.h lib/settings.h lib/standards.h lib/suppressions.h lib/tokenize.h lib/tokenlist.h lib/utils.h test/fixture.h test/helpers.h $(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/teststring.cpp -test/testsummaries.o: test/testsummaries.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/summaries.h lib/suppressions.h lib/tokenize.h lib/tokenlist.h lib/utils.h test/fixture.h +test/testsummaries.o: test/testsummaries.cpp externals/simplecpp/simplecpp.h 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/preprocessor.h lib/settings.h lib/standards.h lib/summaries.h lib/suppressions.h lib/tokenize.h lib/tokenlist.h lib/utils.h test/fixture.h test/helpers.h $(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testsummaries.cpp -test/testsuppressions.o: test/testsuppressions.cpp cli/cppcheckexecutor.h cli/executor.h cli/processexecutor.h cli/singleexecutor.h cli/threadexecutor.h lib/addoninfo.h lib/analyzerinfo.h lib/check.h lib/color.h lib/config.h lib/cppcheck.h lib/errorlogger.h lib/errortypes.h lib/filesettings.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/standards.h lib/suppressions.h lib/tokenize.h lib/tokenlist.h lib/utils.h test/fixture.h test/helpers.h +test/testsuppressions.o: test/testsuppressions.cpp cli/cppcheckexecutor.h cli/executor.h cli/processexecutor.h cli/singleexecutor.h cli/threadexecutor.h externals/simplecpp/simplecpp.h lib/addoninfo.h lib/analyzerinfo.h lib/check.h lib/color.h lib/config.h lib/cppcheck.h lib/errorlogger.h lib/errortypes.h lib/filesettings.h lib/library.h lib/mathlib.h lib/platform.h lib/preprocessor.h lib/settings.h lib/standards.h lib/suppressions.h lib/tokenize.h lib/tokenlist.h lib/utils.h test/fixture.h test/helpers.h $(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testsuppressions.cpp -test/testsymboldatabase.o: test/testsymboldatabase.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/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 +test/testsymboldatabase.o: test/testsymboldatabase.cpp externals/simplecpp/simplecpp.h 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/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/testsymboldatabase.cpp -test/testthreadexecutor.o: test/testthreadexecutor.cpp cli/executor.h cli/threadexecutor.h lib/addoninfo.h lib/analyzerinfo.h lib/check.h lib/color.h lib/config.h lib/cppcheck.h lib/errorlogger.h lib/errortypes.h lib/filesettings.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/standards.h lib/suppressions.h lib/timer.h lib/tokenize.h lib/tokenlist.h lib/utils.h test/fixture.h test/helpers.h test/redirect.h +test/testthreadexecutor.o: test/testthreadexecutor.cpp cli/executor.h cli/threadexecutor.h externals/simplecpp/simplecpp.h lib/addoninfo.h lib/analyzerinfo.h lib/check.h lib/color.h lib/config.h lib/cppcheck.h lib/errorlogger.h lib/errortypes.h lib/filesettings.h lib/library.h lib/mathlib.h lib/platform.h lib/preprocessor.h lib/settings.h lib/standards.h lib/suppressions.h lib/timer.h lib/tokenize.h lib/tokenlist.h lib/utils.h test/fixture.h test/helpers.h test/redirect.h $(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testthreadexecutor.cpp test/testtimer.o: test/testtimer.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/timer.h lib/utils.h test/fixture.h $(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testtimer.cpp -test/testtoken.o: test/testtoken.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/templatesimplifier.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/vfvalue.h test/fixture.h test/helpers.h +test/testtoken.o: test/testtoken.cpp externals/simplecpp/simplecpp.h 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/preprocessor.h lib/settings.h lib/standards.h lib/suppressions.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/testtoken.cpp test/testtokenize.o: test/testtokenize.cpp externals/simplecpp/simplecpp.h 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/preprocessor.h lib/settings.h lib/standards.h lib/suppressions.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/testtokenize.cpp -test/testtokenlist.o: test/testtokenlist.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/templatesimplifier.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/vfvalue.h test/fixture.h test/helpers.h +test/testtokenlist.o: test/testtokenlist.cpp externals/simplecpp/simplecpp.h 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/preprocessor.h lib/settings.h lib/standards.h lib/suppressions.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/testtokenlist.cpp -test/testtokenrange.o: test/testtokenrange.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/sourcelocation.h lib/standards.h lib/suppressions.h lib/symboldatabase.h lib/templatesimplifier.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/tokenrange.h lib/utils.h lib/vfvalue.h test/fixture.h test/helpers.h +test/testtokenrange.o: test/testtokenrange.cpp externals/simplecpp/simplecpp.h 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/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/tokenrange.h lib/utils.h lib/vfvalue.h test/fixture.h test/helpers.h $(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testtokenrange.cpp test/testtype.o: test/testtype.cpp externals/simplecpp/simplecpp.h lib/addoninfo.h lib/check.h lib/checktype.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/preprocessor.h lib/settings.h lib/standards.h lib/suppressions.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/testtype.cpp -test/testuninitvar.o: test/testuninitvar.cpp lib/addoninfo.h lib/check.h lib/checkuninitvar.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/settings.h lib/standards.h lib/suppressions.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/vfvalue.h test/fixture.h +test/testuninitvar.o: test/testuninitvar.cpp externals/simplecpp/simplecpp.h lib/addoninfo.h lib/check.h lib/checkuninitvar.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/standards.h lib/suppressions.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/testuninitvar.cpp test/testunusedfunctions.o: test/testunusedfunctions.cpp externals/simplecpp/simplecpp.h lib/addoninfo.h lib/check.h lib/checkunusedfunctions.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/preprocessor.h lib/settings.h lib/standards.h lib/suppressions.h lib/tokenize.h lib/tokenlist.h lib/utils.h test/fixture.h test/helpers.h $(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testunusedfunctions.cpp -test/testunusedprivfunc.o: test/testunusedprivfunc.cpp lib/addoninfo.h lib/check.h lib/checkclass.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 test/helpers.h +test/testunusedprivfunc.o: test/testunusedprivfunc.cpp externals/simplecpp/simplecpp.h lib/addoninfo.h lib/check.h lib/checkclass.h lib/color.h lib/config.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/testunusedprivfunc.cpp test/testunusedvar.o: test/testunusedvar.cpp externals/simplecpp/simplecpp.h lib/addoninfo.h lib/check.h lib/checkunusedvar.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/preprocessor.h lib/settings.h lib/standards.h lib/suppressions.h lib/tokenize.h lib/tokenlist.h lib/utils.h test/fixture.h test/helpers.h @@ -882,13 +882,13 @@ test/testunusedvar.o: test/testunusedvar.cpp externals/simplecpp/simplecpp.h lib test/testutils.o: test/testutils.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/testutils.cpp -test/testvaarg.o: test/testvaarg.cpp lib/addoninfo.h lib/check.h lib/checkvaarg.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/tokenize.h lib/tokenlist.h lib/utils.h test/fixture.h +test/testvaarg.o: test/testvaarg.cpp externals/simplecpp/simplecpp.h lib/addoninfo.h lib/check.h lib/checkvaarg.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/preprocessor.h lib/settings.h lib/standards.h lib/suppressions.h lib/tokenize.h lib/tokenlist.h lib/utils.h test/fixture.h test/helpers.h $(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testvaarg.cpp -test/testvalueflow.o: test/testvalueflow.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/templatesimplifier.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/vfvalue.h test/fixture.h test/helpers.h +test/testvalueflow.o: test/testvalueflow.cpp externals/simplecpp/simplecpp.h 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/preprocessor.h lib/settings.h lib/standards.h lib/suppressions.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/testvalueflow.cpp -test/testvarid.o: test/testvarid.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/templatesimplifier.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/vfvalue.h test/fixture.h test/helpers.h +test/testvarid.o: test/testvarid.cpp externals/simplecpp/simplecpp.h 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/preprocessor.h lib/settings.h lib/standards.h lib/suppressions.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/testvarid.cpp externals/simplecpp/simplecpp.o: externals/simplecpp/simplecpp.cpp externals/simplecpp/simplecpp.h diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index c99d75114d51..56498b0d7869 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -3439,16 +3439,6 @@ bool Tokenizer::simplifyTokens1(const std::string &configuration) return true; } -// cppcheck-suppress unusedFunction - used in tests only -bool Tokenizer::tokenize(std::istream &code, - const char FileName[], - const std::string &configuration) -{ - if (!list.createTokens(code, FileName)) - return false; - - return simplifyTokens1(configuration); -} //--------------------------------------------------------------------------- void Tokenizer::findComplicatedSyntaxErrorsInTemplates() @@ -10659,6 +10649,7 @@ void Tokenizer::simplifyNamespaceAliases() } } +// TODO: how to move the Preprocessor dependency out of here? bool Tokenizer::hasIfdef(const Token *start, const Token *end) const { assert(mPreprocessor); diff --git a/lib/tokenize.h b/lib/tokenize.h index a82490242157..304f66f92eff 100644 --- a/lib/tokenize.h +++ b/lib/tokenize.h @@ -79,30 +79,6 @@ class CPPCHECKLIB Tokenizer { bool isScopeNoReturn(const Token *endScopeToken, bool *unknown = nullptr) const; bool simplifyTokens1(const std::string &configuration); - /** - * Tokenize code - * @param code input stream for code, e.g. - * \code - * #file "p.h" - * class Foo - * { - * private: - * void Bar(); - * }; - * - * #endfile - * void Foo::Bar() - * { - * } - * \endcode - * - * @param FileName The filename - * @param configuration E.g. "A" for code where "#ifdef A" is true - * @return false if source code contains syntax errors - */ - bool tokenize(std::istream &code, - const char FileName[], - const std::string &configuration = emptyString); private: /** Set variable id */ diff --git a/test/helpers.cpp b/test/helpers.cpp index 4f5014585cfd..43117a7a3a8b 100644 --- a/test/helpers.cpp +++ b/test/helpers.cpp @@ -44,6 +44,9 @@ class SuppressionList; +const Settings SimpleTokenizer::s_settings; +const Preprocessor SimpleTokenizer::s_preprocessor{s_settings, nullptr}; // TODO: provide ErrorLogger + // TODO: better path-only usage ScopedFile::ScopedFile(std::string name, const std::string &content, std::string path) : mName(std::move(name)) diff --git a/test/helpers.h b/test/helpers.h index b451b4a4597f..c6a202f7e342 100644 --- a/test/helpers.h +++ b/test/helpers.h @@ -19,6 +19,7 @@ #ifndef helpersH #define helpersH +#include "preprocessor.h" #include "settings.h" #include "standards.h" #include "tokenize.h" @@ -31,34 +32,60 @@ #include class Token; -class Preprocessor; class SuppressionList; class ErrorLogger; namespace simplecpp { struct DUI; } -class SimpleTokenizer { +// TODO: make Tokenizer private +class SimpleTokenizer : public Tokenizer { public: - SimpleTokenizer(ErrorLogger& errorlogger, const char sample[], bool cpp = true) - : tokenizer{settings, &errorlogger} + SimpleTokenizer(ErrorLogger& errorlogger, const char code[], bool cpp = true) + : Tokenizer{s_settings, &errorlogger, &s_preprocessor} { - std::istringstream iss(sample); - if (!tokenizer.tokenize(iss, cpp ? "test.cpp" : "test.c")) + if (!tokenize(code, cpp)) throw std::runtime_error("creating tokens failed"); } + SimpleTokenizer(const Settings& settings, ErrorLogger& errorlogger) + : Tokenizer{settings, &errorlogger, &s_preprocessor} + {} + + SimpleTokenizer(const Settings& settings, ErrorLogger& errorlogger, const Preprocessor* preprocessor) + : Tokenizer{settings, &errorlogger, preprocessor} + {} + Token* tokens() { - return tokenizer.tokens(); + return Tokenizer::tokens(); } const Token* tokens() const { - return tokenizer.tokens(); + return Tokenizer::tokens(); + } + + /** + * Tokenize code + * @param code The code + * @param cpp Indicates if the code is C++ + * @param configuration E.g. "A" for code where "#ifdef A" is true + * @return false if source code contains syntax errors + */ + bool tokenize(const char code[], + bool cpp = true, + const std::string &configuration = emptyString) + { + std::istringstream istr(code); + if (!list.createTokens(istr, cpp ? "test.cpp" : "test.c")) + return false; + + return simplifyTokens1(configuration); } private: - const Settings settings; - Tokenizer tokenizer; + // TODO. find a better solution + static const Settings s_settings; + static const Preprocessor s_preprocessor; }; class SimpleTokenList diff --git a/test/test64bit.cpp b/test/test64bit.cpp index 97ba363c01d5..58bef23b9c70 100644 --- a/test/test64bit.cpp +++ b/test/test64bit.cpp @@ -16,14 +16,11 @@ * along with this program. If not, see . */ - #include "check64bit.h" #include "errortypes.h" -#include "settings.h" #include "fixture.h" -#include "tokenize.h" - -#include +#include "helpers.h" +#include "settings.h" class Test64BitPortability : public TestFixture { public: @@ -45,9 +42,8 @@ class Test64BitPortability : public TestFixture { #define check(code) check_(code, __FILE__, __LINE__) void check_(const char code[], const char* file, int line) { // Tokenize.. - Tokenizer tokenizer(settings, this); - std::istringstream istr(code); - ASSERT_LOC(tokenizer.tokenize(istr, "test.cpp"), file, line); + SimpleTokenizer tokenizer(settings, *this); + ASSERT_LOC(tokenizer.tokenize(code), file, line); // Check char variable usage.. Check64BitPortability check64BitPortability(&tokenizer, &settings, this); diff --git a/test/testassert.cpp b/test/testassert.cpp index e6beeb33a053..50f0ca1a60b3 100644 --- a/test/testassert.cpp +++ b/test/testassert.cpp @@ -19,12 +19,9 @@ #include "checkassert.h" #include "errortypes.h" -#include "settings.h" #include "fixture.h" -#include "tokenize.h" - -#include - +#include "helpers.h" +#include "settings.h" class TestAssert : public TestFixture { public: @@ -34,11 +31,10 @@ class TestAssert : public TestFixture { const Settings settings = settingsBuilder().severity(Severity::warning).build(); #define check(...) check_(__FILE__, __LINE__, __VA_ARGS__) - void check_(const char* file, int line, const char code[], const char *filename = "test.cpp") { + void check_(const char* file, int line, const char code[]) { // Tokenize.. - Tokenizer tokenizer(settings, this); - std::istringstream istr(code); - ASSERT_LOC(tokenizer.tokenize(istr, filename), file, line); + SimpleTokenizer tokenizer(settings, *this); + ASSERT_LOC(tokenizer.tokenize(code), file, line); // Check.. runChecks(tokenizer, this); diff --git a/test/testastutils.cpp b/test/testastutils.cpp index 9140b16e5610..baa8357d09c9 100644 --- a/test/testastutils.cpp +++ b/test/testastutils.cpp @@ -16,18 +16,16 @@ * along with this program. If not, see . */ - #include "astutils.h" +#include "fixture.h" +#include "helpers.h" #include "library.h" #include "settings.h" -#include "fixture.h" #include "symboldatabase.h" #include "token.h" -#include "tokenize.h" #include "tokenlist.h" #include -#include class TestAstUtils : public TestFixture { public: @@ -54,9 +52,8 @@ class TestAstUtils : public TestFixture { #define findLambdaEndToken(...) findLambdaEndToken_(__FILE__, __LINE__, __VA_ARGS__) bool findLambdaEndToken_(const char* file, int line, const char code[], const char pattern[] = nullptr, bool checkNext = true) { const Settings settings; - Tokenizer tokenizer(settings, this); - std::istringstream istr(code); - ASSERT_LOC(tokenizer.tokenize(istr, "test.cpp"), file, line); + SimpleTokenizer tokenizer(settings, *this); + ASSERT_LOC(tokenizer.tokenize(code), file, line); const Token* const tokStart = pattern ? Token::findsimplematch(tokenizer.tokens(), pattern, strlen(pattern)) : tokenizer.tokens(); const Token * const tokEnd = (::findLambdaEndToken)(tokStart); return tokEnd && (!checkNext || tokEnd->next() == nullptr); @@ -92,9 +89,8 @@ class TestAstUtils : public TestFixture { #define findLambdaStartToken(code) findLambdaStartToken_(code, __FILE__, __LINE__) bool findLambdaStartToken_(const char code[], const char* file, int line) { - Tokenizer tokenizer(settingsDefault, this); - std::istringstream istr(code); - ASSERT_LOC(tokenizer.tokenize(istr, "test.cpp"), file, line); + SimpleTokenizer tokenizer(settingsDefault, *this); + ASSERT_LOC(tokenizer.tokenize(code), file, line); const Token * const tokStart = (::findLambdaStartToken)(tokenizer.list.back()); return tokStart && tokStart == tokenizer.list.front(); } @@ -124,9 +120,8 @@ class TestAstUtils : public TestFixture { #define isNullOperand(code) isNullOperand_(code, __FILE__, __LINE__) bool isNullOperand_(const char code[], const char* file, int line) { - Tokenizer tokenizer(settingsDefault, this); - std::istringstream istr(code); - ASSERT_LOC(tokenizer.tokenize(istr, "test.cpp"), file, line); + SimpleTokenizer tokenizer(settingsDefault, *this); + ASSERT_LOC(tokenizer.tokenize(code), file, line); return (::isNullOperand)(tokenizer.tokens()); } @@ -145,9 +140,8 @@ class TestAstUtils : public TestFixture { #define isReturnScope(code, offset) isReturnScope_(code, offset, __FILE__, __LINE__) bool isReturnScope_(const char code[], int offset, const char* file, int line) { - Tokenizer tokenizer(settingsDefault, this); - std::istringstream istr(code); - ASSERT_LOC(tokenizer.tokenize(istr, "test.cpp"), file, line); + SimpleTokenizer tokenizer(settingsDefault, *this); + ASSERT_LOC(tokenizer.tokenize(code), file, line); const Token * const tok = (offset < 0) ? tokenizer.list.back()->tokAt(1+offset) : tokenizer.tokens()->tokAt(offset); @@ -176,9 +170,8 @@ class TestAstUtils : public TestFixture { #define isSameExpression(...) isSameExpression_(__FILE__, __LINE__, __VA_ARGS__) bool isSameExpression_(const char* file, int line, const char code[], const char tokStr1[], const char tokStr2[], bool cpp) { Library library; - Tokenizer tokenizer(settingsDefault, this); - std::istringstream istr(code); - ASSERT_LOC(tokenizer.tokenize(istr, cpp ? "test.cpp" : "test.c"), file, line); + SimpleTokenizer tokenizer(settingsDefault, *this); + ASSERT_LOC(tokenizer.tokenize(code, cpp), file, line); const Token * const tok1 = Token::findsimplematch(tokenizer.tokens(), tokStr1, strlen(tokStr1)); const Token * const tok2 = Token::findsimplematch(tok1->next(), tokStr2, strlen(tokStr2)); return (isSameExpression)(false, tok1, tok2, library, false, true, nullptr); @@ -224,9 +217,8 @@ class TestAstUtils : public TestFixture { #define isVariableChanged(code, startPattern, endPattern) isVariableChanged_(code, startPattern, endPattern, __FILE__, __LINE__) bool isVariableChanged_(const char code[], const char startPattern[], const char endPattern[], const char* file, int line) { - Tokenizer tokenizer(settingsDefault, this); - std::istringstream istr(code); - ASSERT_LOC(tokenizer.tokenize(istr, "test.cpp"), file, line); + SimpleTokenizer tokenizer(settingsDefault, *this); + ASSERT_LOC(tokenizer.tokenize(code), file, line); const Token * const tok1 = Token::findsimplematch(tokenizer.tokens(), startPattern, strlen(startPattern)); const Token * const tok2 = Token::findsimplematch(tokenizer.tokens(), endPattern, strlen(endPattern)); return (isVariableChanged)(tok1, tok2, 1, false, &settingsDefault); @@ -258,9 +250,8 @@ class TestAstUtils : public TestFixture { #define isVariableChangedByFunctionCall(code, pattern, inconclusive) isVariableChangedByFunctionCall_(code, pattern, inconclusive, __FILE__, __LINE__) bool isVariableChangedByFunctionCall_(const char code[], const char pattern[], bool *inconclusive, const char* file, int line) { - Tokenizer tokenizer(settingsDefault, this); - std::istringstream istr(code); - ASSERT_LOC(tokenizer.tokenize(istr, "test.cpp"), file, line); + SimpleTokenizer tokenizer(settingsDefault, *this); + ASSERT_LOC(tokenizer.tokenize(code), file, line); const Token * const argtok = Token::findmatch(tokenizer.tokens(), pattern); ASSERT_LOC(argtok, file, line); int indirect = (argtok->variable() && argtok->variable()->isArray()); @@ -401,9 +392,8 @@ class TestAstUtils : public TestFixture { int line) { const Settings settings = settingsBuilder().library("std.cfg").build(); - Tokenizer tokenizer(settings, this); - std::istringstream istr(code); - ASSERT_LOC(tokenizer.tokenize(istr, "test.cpp"), file, line); + SimpleTokenizer tokenizer(settings, *this); + ASSERT_LOC(tokenizer.tokenize(code), file, line); const Token* const start = Token::findsimplematch(tokenizer.tokens(), startPattern, strlen(startPattern)); const Token* const end = Token::findsimplematch(start, endPattern, strlen(endPattern)); const Token* const expr = Token::findsimplematch(tokenizer.tokens(), var, strlen(var)); @@ -432,9 +422,8 @@ class TestAstUtils : public TestFixture { #define nextAfterAstRightmostLeaf(code, parentPattern, rightPattern) nextAfterAstRightmostLeaf_(code, parentPattern, rightPattern, __FILE__, __LINE__) bool nextAfterAstRightmostLeaf_(const char code[], const char parentPattern[], const char rightPattern[], const char* file, int line) { - Tokenizer tokenizer(settingsDefault, this); - std::istringstream istr(code); - ASSERT_LOC(tokenizer.tokenize(istr, "test.cpp"), file, line); + SimpleTokenizer tokenizer(settingsDefault, *this); + ASSERT_LOC(tokenizer.tokenize(code), file, line); const Token * tok = Token::findsimplematch(tokenizer.tokens(), parentPattern, strlen(parentPattern)); return Token::simpleMatch((::nextAfterAstRightmostLeaf)(tok), rightPattern, strlen(rightPattern)); } @@ -456,9 +445,8 @@ class TestAstUtils : public TestFixture { enum class Result {False, True, Fail}; Result isUsedAsBool(const char code[], const char pattern[]) { - Tokenizer tokenizer(settingsDefault, this); - std::istringstream istr(code); - if (!tokenizer.tokenize(istr, "test.cpp")) + SimpleTokenizer tokenizer(settingsDefault, *this); + if (!tokenizer.tokenize(code)) return Result::Fail; const Token * const argtok = Token::findmatch(tokenizer.tokens(), pattern); if (!argtok) diff --git a/test/testautovariables.cpp b/test/testautovariables.cpp index 198f6be8b578..b6d491b39745 100644 --- a/test/testautovariables.cpp +++ b/test/testautovariables.cpp @@ -16,14 +16,11 @@ * along with this program. If not, see . */ - #include "checkautovariables.h" #include "errortypes.h" -#include "settings.h" #include "fixture.h" -#include "tokenize.h" - -#include +#include "helpers.h" +#include "settings.h" class TestAutoVariables : public TestFixture { public: @@ -33,13 +30,12 @@ class TestAutoVariables : public TestFixture { const Settings settings = settingsBuilder().severity(Severity::warning).severity(Severity::style).library("std.cfg").library("qt.cfg").build(); #define check(...) check_(__FILE__, __LINE__, __VA_ARGS__) - void check_(const char* file, int line, const char code[], bool inconclusive = true, const char* filename = "test.cpp") { + void check_(const char* file, int line, const char code[], bool inconclusive = true, bool cpp = true) { const Settings settings1 = settingsBuilder(settings).certainty(Certainty::inconclusive, inconclusive).build(); // Tokenize.. - Tokenizer tokenizer(settings1, this); - std::istringstream istr(code); - ASSERT_LOC(tokenizer.tokenize(istr, filename), file, line); + SimpleTokenizer tokenizer(settings1, *this); + ASSERT_LOC(tokenizer.tokenize(code, cpp), file, line); runChecks(tokenizer, this); } @@ -916,7 +912,7 @@ class TestAutoVariables : public TestFixture { check("void svn_repos_dir_delta2() {\n" " struct context c;\n" " SVN_ERR(delete(&c, root_baton, src_entry, pool));\n" - "}\n", false, "test.c"); + "}\n", false, /* cpp= */false); ASSERT_EQUALS("", errout_str()); } diff --git a/test/testbool.cpp b/test/testbool.cpp index b8fb09558815..d6f79a3285e8 100644 --- a/test/testbool.cpp +++ b/test/testbool.cpp @@ -16,14 +16,11 @@ * along with this program. If not, see . */ - #include "checkbool.h" #include "errortypes.h" -#include "settings.h" #include "fixture.h" -#include "tokenize.h" - -#include +#include "helpers.h" +#include "settings.h" class TestBool : public TestFixture { public: @@ -77,11 +74,10 @@ class TestBool : public TestFixture { } #define check(...) check_(__FILE__, __LINE__, __VA_ARGS__) - void check_(const char* file, int line, const char code[], const char filename[] = "test.cpp") { + void check_(const char* file, int line, const char code[], bool cpp = true) { // Tokenize.. - Tokenizer tokenizer(settings, this); - std::istringstream istr(code); - ASSERT_LOC(tokenizer.tokenize(istr, filename), file, line); + SimpleTokenizer tokenizer(settings, *this); + ASSERT_LOC(tokenizer.tokenize(code, cpp), file, line); // Check... runChecks(tokenizer, this); @@ -147,7 +143,7 @@ class TestBool : public TestFixture { " const int *rmat = n < 4 ? " /* OK */ " ctx->q_intra_matrix :" " ctx->q_chroma_intra_matrix;\n" - "}", "test.c"); + "}", false); ASSERT_EQUALS("[test.c:3]: (error) Boolean value assigned to pointer.\n", errout_str()); // ticket #6588 (c++ mode) @@ -166,7 +162,7 @@ class TestBool : public TestFixture { " char* m1 = compare(a, b) < 0\n" " ? (compare(b, c) < 0 ? b : (compare(a, c) < 0 ? c : a))\n" " : (compare(a, c) < 0 ? a : (compare(b, c) < 0 ? c : b));\n" - "}", "test.c"); + "}", false); ASSERT_EQUALS("", errout_str()); // #7381 diff --git a/test/testboost.cpp b/test/testboost.cpp index af09069eb706..554c0e043991 100644 --- a/test/testboost.cpp +++ b/test/testboost.cpp @@ -16,14 +16,11 @@ * along with this program. If not, see . */ - #include "checkboost.h" #include "errortypes.h" -#include "settings.h" #include "fixture.h" -#include "tokenize.h" - -#include +#include "helpers.h" +#include "settings.h" class TestBoost : public TestFixture { public: @@ -39,9 +36,8 @@ class TestBoost : public TestFixture { #define check(code) check_(code, __FILE__, __LINE__) void check_(const char code[], const char* file, int line) { // Tokenize.. - Tokenizer tokenizer(settings, this); - std::istringstream istr(code); - ASSERT_LOC(tokenizer.tokenize(istr, "test.cpp"), file, line); + SimpleTokenizer tokenizer(settings, *this); + ASSERT_LOC(tokenizer.tokenize(code), file, line); // Check.. runChecks(tokenizer, this); diff --git a/test/testbufferoverrun.cpp b/test/testbufferoverrun.cpp index d462f44638dd..5a7a6e981772 100644 --- a/test/testbufferoverrun.cpp +++ b/test/testbufferoverrun.cpp @@ -29,7 +29,6 @@ #include "tokenize.h" #include -#include #include #include @@ -41,22 +40,20 @@ class TestBufferOverrun : public TestFixture { /*const*/ Settings settings0 = settingsBuilder().library("std.cfg").severity(Severity::warning).severity(Severity::style).severity(Severity::portability).build(); #define check(...) check_(__FILE__, __LINE__, __VA_ARGS__) - void check_(const char* file, int line, const char code[], const char filename[] = "test.cpp") { + void check_(const char* file, int line, const char code[], bool cpp = true) { const Settings settings = settingsBuilder(settings0).certainty(Certainty::inconclusive).build(); // Tokenize.. - Tokenizer tokenizer(settings, this); - std::istringstream istr(code); - ASSERT_LOC(tokenizer.tokenize(istr, filename), file, line); + SimpleTokenizer tokenizer(settings, *this); + ASSERT_LOC(tokenizer.tokenize(code, cpp), file, line); // Check for buffer overruns.. runChecks(tokenizer, this); } - void check_(const char* file, int line, const char code[], const Settings &settings, const char filename[] = "test.cpp") { - Tokenizer tokenizer(settings, this); - std::istringstream istr(code); - ASSERT_LOC(tokenizer.tokenize(istr, filename), file, line); + void check_(const char* file, int line, const char code[], const Settings &settings, bool cpp = true) { + SimpleTokenizer tokenizer(settings, *this); + ASSERT_LOC(tokenizer.tokenize(code, cpp), file, line); // Check for buffer overruns.. runChecks(tokenizer, this); @@ -2474,7 +2471,7 @@ class TestBufferOverrun : public TestFixture { " c++;\n" " }\n" " return c;\n" - "}", "test.c"); + "}", false); ASSERT_EQUALS("", errout_str()); } @@ -2680,7 +2677,7 @@ class TestBufferOverrun : public TestFixture { " char str[6] = \"\\0\";\n" " unsigned short port = 65535;\n" " snprintf(str, sizeof(str), \"%hu\", port);\n" - "}", settings0, "test.c"); + "}", settings0, false); ASSERT_EQUALS("", errout_str()); check("int f(int x) {\n" // #11020 @@ -2737,13 +2734,13 @@ class TestBufferOverrun : public TestFixture { check("void f() {\n" " char str[3];\n" " str[((unsigned char)3) - 1] = 0;\n" - "}", "test.cpp"); + "}"); ASSERT_EQUALS("", errout_str()); check("void f() {\n" // #5416 FP " char *str[3];\n" " do_something(&str[0][5]);\n" - "}", "test.cpp"); + "}"); ASSERT_EQUALS("", errout_str()); check("class X { static const int x[100]; };\n" // #6070 @@ -3698,7 +3695,7 @@ class TestBufferOverrun : public TestFixture { check("void f() {\n" // #6350 - fp when there is cast of buffer " wchar_t buf[64];\n" " p = (unsigned char *) buf + sizeof (buf);\n" - "}", "6350.c"); + "}", false); ASSERT_EQUALS("", errout_str()); check("int f() {\n" @@ -5163,9 +5160,8 @@ class TestBufferOverrun : public TestFixture { #define ctu(code) ctu_(code, __FILE__, __LINE__) void ctu_(const char code[], const char* file, int line) { // Tokenize.. - Tokenizer tokenizer(settings0, this); - std::istringstream istr(code); - ASSERT_LOC(tokenizer.tokenize(istr, "test.cpp"), file, line); + SimpleTokenizer tokenizer(settings0, *this); + ASSERT_LOC(tokenizer.tokenize(code), file, line); CTU::FileInfo *ctu = CTU::getFileInfo(&tokenizer); @@ -5522,7 +5518,7 @@ class TestBufferOverrun : public TestFixture { " (*str)[applen] = '\\0';\n" " }\n" " free(*str);\n" - "}\n", "test.c"); + "}\n", false); ASSERT_EQUALS("", errout_str()); check("template \n" diff --git a/test/testcharvar.cpp b/test/testcharvar.cpp index 15198feb2247..5e939051908c 100644 --- a/test/testcharvar.cpp +++ b/test/testcharvar.cpp @@ -16,15 +16,12 @@ * along with this program. If not, see . */ - #include "checkother.h" #include "errortypes.h" +#include "fixture.h" +#include "helpers.h" #include "platform.h" #include "settings.h" -#include "fixture.h" -#include "tokenize.h" - -#include class TestCharVar : public TestFixture { public: @@ -42,9 +39,8 @@ class TestCharVar : public TestFixture { #define check(code) check_(code, __FILE__, __LINE__) void check_(const char code[], const char* file, int line) { // Tokenize.. - Tokenizer tokenizer(settings, this); - std::istringstream istr(code); - ASSERT_LOC(tokenizer.tokenize(istr, "test.cpp"), file, line); + SimpleTokenizer tokenizer(settings, *this); + ASSERT_LOC(tokenizer.tokenize(code), file, line); // Check char variable usage.. CheckOther checkOther(&tokenizer, &settings, this); diff --git a/test/testclass.cpp b/test/testclass.cpp index 7b628149e634..875e1114909d 100644 --- a/test/testclass.cpp +++ b/test/testclass.cpp @@ -19,14 +19,13 @@ #include "check.h" #include "checkclass.h" #include "errortypes.h" +#include "fixture.h" #include "helpers.h" #include "preprocessor.h" #include "settings.h" -#include "fixture.h" #include "tokenize.h" #include -#include #include #include @@ -252,9 +251,8 @@ class TestClass : public TestFixture { Preprocessor preprocessor(settings); // Tokenize.. - Tokenizer tokenizer(settings, this, &preprocessor); - std::istringstream istr(code); - ASSERT_LOC(tokenizer.tokenize(istr, "test.cpp"), file, line); + SimpleTokenizer tokenizer(settings, *this, &preprocessor); + ASSERT_LOC(tokenizer.tokenize(code), file, line); // Check.. CheckClass checkClass(&tokenizer, &settings, this); @@ -355,9 +353,8 @@ class TestClass : public TestFixture { Preprocessor preprocessor(settings0); // Tokenize.. - Tokenizer tokenizer(settings0, this, &preprocessor); - std::istringstream istr(code); - ASSERT_LOC(tokenizer.tokenize(istr, "test.cpp"), file, line); + SimpleTokenizer tokenizer(settings0, *this, &preprocessor); + ASSERT_LOC(tokenizer.tokenize(code), file, line); // Check.. CheckClass checkClass(&tokenizer, &settings0, this); @@ -506,9 +503,8 @@ class TestClass : public TestFixture { Preprocessor preprocessor(settings1); // Tokenize.. - Tokenizer tokenizer(settings1, this, &preprocessor); - std::istringstream istr(code); - ASSERT_LOC(tokenizer.tokenize(istr, "test.cpp"), file, line); + SimpleTokenizer tokenizer(settings1, *this, &preprocessor); + ASSERT_LOC(tokenizer.tokenize(code), file, line); // Check.. CheckClass checkClass(&tokenizer, &settings1, this); @@ -725,9 +721,8 @@ class TestClass : public TestFixture { Preprocessor preprocessor(settings3); // Tokenize.. - Tokenizer tokenizer(settings3, this, &preprocessor); - std::istringstream istr(code); - ASSERT_LOC(tokenizer.tokenize(istr, "test.cpp"), file, line); + SimpleTokenizer tokenizer(settings3, *this, &preprocessor); + ASSERT_LOC(tokenizer.tokenize(code), file, line); // Check.. CheckClass checkClass(&tokenizer, &settings3, this); @@ -1171,9 +1166,8 @@ class TestClass : public TestFixture { Preprocessor preprocessor(settings0); // Tokenize.. - Tokenizer tokenizer(settings0, this, &preprocessor); - std::istringstream istr(code); - ASSERT_LOC(tokenizer.tokenize(istr, "test.cpp"), file, line); + SimpleTokenizer tokenizer(settings0, *this, &preprocessor); + ASSERT_LOC(tokenizer.tokenize(code), file, line); // Check.. CheckClass checkClass(&tokenizer, &settings0, this); @@ -1644,9 +1638,8 @@ class TestClass : public TestFixture { Preprocessor preprocessor(settings1); // Tokenize.. - Tokenizer tokenizer(settings1, this, &preprocessor); - std::istringstream istr(code); - ASSERT_LOC(tokenizer.tokenize(istr, "test.cpp"), file, line); + SimpleTokenizer tokenizer(settings1, *this, &preprocessor); + ASSERT_LOC(tokenizer.tokenize(code), file, line); // Check.. CheckClass checkClass(&tokenizer, &settings1, this); @@ -2604,9 +2597,8 @@ class TestClass : public TestFixture { Preprocessor preprocessor(s); // Tokenize.. - Tokenizer tokenizer(s, this, &preprocessor); - std::istringstream istr(code); - ASSERT_LOC(tokenizer.tokenize(istr, "test.cpp"), file, line); + SimpleTokenizer tokenizer(s, *this, &preprocessor); + ASSERT_LOC(tokenizer.tokenize(code), file, line); // Check.. CheckClass checkClass(&tokenizer, &s, this); @@ -2943,9 +2935,8 @@ class TestClass : public TestFixture { Preprocessor preprocessor(settings); // Tokenize.. - Tokenizer tokenizer(settings, this, &preprocessor); - std::istringstream istr(code); - ASSERT_LOC(tokenizer.tokenize(istr, "test.cpp"), file, line); + SimpleTokenizer tokenizer(settings, *this, &preprocessor); + ASSERT_LOC(tokenizer.tokenize(code), file, line); // Check.. CheckClass checkClass(&tokenizer, &settings, this); @@ -3591,9 +3582,8 @@ class TestClass : public TestFixture { Preprocessor preprocessor(settings1); // Tokenize.. - Tokenizer tokenizer(settings1, this, &preprocessor); - std::istringstream istr(code); - ASSERT_LOC(tokenizer.tokenize(istr, "test.cpp"), file, line); + SimpleTokenizer tokenizer(settings1, *this, &preprocessor); + ASSERT_LOC(tokenizer.tokenize(code), file, line); // Check.. CheckClass checkClass(&tokenizer, &settings1, this); @@ -3625,9 +3615,8 @@ class TestClass : public TestFixture { Preprocessor preprocessor(settings); // Tokenize.. - Tokenizer tokenizer(settings, this, &preprocessor); - std::istringstream istr(code); - ASSERT_LOC(tokenizer.tokenize(istr, "test.cpp"), file, line); + SimpleTokenizer tokenizer(settings, *this, &preprocessor); + ASSERT_LOC(tokenizer.tokenize(code), file, line); CheckClass checkClass(&tokenizer, &settings, this); (checkClass.checkConst)(); @@ -7547,9 +7536,8 @@ class TestClass : public TestFixture { Preprocessor preprocessor(settings2); // Tokenize.. - Tokenizer tokenizer(settings2, this, &preprocessor); - std::istringstream istr(code); - ASSERT_LOC(tokenizer.tokenize(istr, "test.cpp"), file, line); + SimpleTokenizer tokenizer(settings2, *this, &preprocessor); + ASSERT_LOC(tokenizer.tokenize(code), file, line); CheckClass checkClass(&tokenizer, &settings2, this); checkClass.initializerListOrder(); @@ -7678,9 +7666,8 @@ class TestClass : public TestFixture { Preprocessor preprocessor(settings); // Tokenize.. - Tokenizer tokenizer(settings, this, &preprocessor); - std::istringstream istr(code); - ASSERT_LOC(tokenizer.tokenize(istr, "test.cpp"), file, line); + SimpleTokenizer tokenizer(settings, *this, &preprocessor); + ASSERT_LOC(tokenizer.tokenize(code), file, line); CheckClass checkClass(&tokenizer, &settings, this); checkClass.initializationListUsage(); @@ -7889,9 +7876,8 @@ class TestClass : public TestFixture { Preprocessor preprocessor(settings0); // Tokenize.. - Tokenizer tokenizer(settings0, this, &preprocessor); - std::istringstream istr(code); - ASSERT_LOC(tokenizer.tokenize(istr, "test.cpp"), file, line); + SimpleTokenizer tokenizer(settings0, *this, &preprocessor); + ASSERT_LOC(tokenizer.tokenize(code), file, line); CheckClass checkClass(&tokenizer, &settings0, this); (checkClass.checkSelfInitialization)(); @@ -8002,9 +7988,8 @@ class TestClass : public TestFixture { Preprocessor preprocessor(settings); // Tokenize.. - Tokenizer tokenizer(settings, this, &preprocessor); - std::istringstream istr(code); - ASSERT_LOC(tokenizer.tokenize(istr, "test.cpp"), file, line); + SimpleTokenizer tokenizer(settings, *this, &preprocessor); + ASSERT_LOC(tokenizer.tokenize(code), file, line); CheckClass checkClass(&tokenizer, &settings, this); checkClass.checkVirtualFunctionCallInConstructor(); @@ -8348,9 +8333,8 @@ class TestClass : public TestFixture { Preprocessor preprocessor(settings); // Tokenize.. - Tokenizer tokenizer(settings, this, &preprocessor); - std::istringstream istr(code); - ASSERT_LOC(tokenizer.tokenize(istr, "test.cpp"), file, line); + SimpleTokenizer tokenizer(settings, *this, &preprocessor); + ASSERT_LOC(tokenizer.tokenize(code), file, line); // Check.. CheckClass checkClass(&tokenizer, &settings, this); @@ -8723,9 +8707,8 @@ class TestClass : public TestFixture { Preprocessor preprocessor(settings); // Tokenize.. - Tokenizer tokenizer(settings, this, &preprocessor); - std::istringstream istr(code); - ASSERT_LOC(tokenizer.tokenize(istr, "test.cpp"), file, line); + SimpleTokenizer tokenizer(settings, *this, &preprocessor); + ASSERT_LOC(tokenizer.tokenize(code), file, line); // Check.. CheckClass checkClass(&tokenizer, &settings, this); @@ -8743,9 +8726,8 @@ class TestClass : public TestFixture { Preprocessor preprocessor(settings1); // Tokenize.. - Tokenizer tokenizer(settings1, this, &preprocessor); - std::istringstream istr(code); - ASSERT_LOC(tokenizer.tokenize(istr, "test.cpp"), file, line); + SimpleTokenizer tokenizer(settings1, *this, &preprocessor); + ASSERT_LOC(tokenizer.tokenize(code), file, line); // Check.. CheckClass checkClass(&tokenizer, &settings1, this); @@ -8901,7 +8883,9 @@ class TestClass : public TestFixture { for (const std::string& c: code) { Tokenizer tokenizer(settingsDefault, this); std::istringstream istr(c); - ASSERT(tokenizer.tokenize(istr, (std::to_string(fileInfo.size()) + ".cpp").c_str())); + const std::string filename = std::to_string(fileInfo.size()) + ".cpp"; + ASSERT(tokenizer.list.createTokens(istr, filename.c_str())); + ASSERT(tokenizer.simplifyTokens1("")); fileInfo.push_back(check.getFileInfo(&tokenizer, &settingsDefault)); } @@ -8943,9 +8927,8 @@ class TestClass : public TestFixture { Preprocessor preprocessor(settings1); // Tokenize.. - Tokenizer tokenizer(settings1, this, &preprocessor); - std::istringstream istr(code); - ASSERT_LOC(tokenizer.tokenize(istr, "test.cpp"), file, line); + SimpleTokenizer tokenizer(settings1, *this, &preprocessor); + ASSERT_LOC(tokenizer.tokenize(code), file, line); // Check.. const Check& c = getCheck(); diff --git a/test/testcondition.cpp b/test/testcondition.cpp index 115fbe4b84c8..7ae5338448fe 100644 --- a/test/testcondition.cpp +++ b/test/testcondition.cpp @@ -18,15 +18,14 @@ #include "checkcondition.h" #include "errortypes.h" +#include "fixture.h" #include "helpers.h" #include "platform.h" #include "preprocessor.h" #include "settings.h" -#include "fixture.h" #include "tokenize.h" #include -#include #include #include @@ -543,9 +542,8 @@ class TestCondition : public TestFixture { void checkPureFunction_(const char code[], const char* file, int line) { // Tokenize.. - Tokenizer tokenizer(settings1, this); - std::istringstream istr(code); - ASSERT_LOC(tokenizer.tokenize(istr, "test.cpp"), file, line); + SimpleTokenizer tokenizer(settings1, *this); + ASSERT_LOC(tokenizer.tokenize(code), file, line); runChecks(tokenizer, this); } diff --git a/test/testconstructors.cpp b/test/testconstructors.cpp index 4b25cc52b0c0..2ab939c177d3 100644 --- a/test/testconstructors.cpp +++ b/test/testconstructors.cpp @@ -16,16 +16,12 @@ * along with this program. If not, see . */ - #include "checkclass.h" #include "errortypes.h" +#include "fixture.h" +#include "helpers.h" #include "standards.h" #include "settings.h" -#include "fixture.h" -#include "tokenize.h" - -#include - class TestConstructors : public TestFixture { public: @@ -39,9 +35,8 @@ class TestConstructors : public TestFixture { const Settings settings1 = settingsBuilder(settings).certainty(Certainty::inconclusive, inconclusive).build(); // Tokenize.. - Tokenizer tokenizer(settings1, this); - std::istringstream istr(code); - ASSERT_LOC(tokenizer.tokenize(istr, "test.cpp"), file, line); + SimpleTokenizer tokenizer(settings1, *this); + ASSERT_LOC(tokenizer.tokenize(code), file, line); // Check class constructors.. CheckClass checkClass(&tokenizer, &settings1, this); @@ -50,9 +45,8 @@ class TestConstructors : public TestFixture { void check_(const char* file, int line, const char code[], const Settings &s) { // Tokenize.. - Tokenizer tokenizer(s, this); - std::istringstream istr(code); - ASSERT_LOC(tokenizer.tokenize(istr, "test.cpp"), file, line); + SimpleTokenizer tokenizer(s, *this); + ASSERT_LOC(tokenizer.tokenize(code), file, line); // Check class constructors.. CheckClass checkClass(&tokenizer, &s, this); diff --git a/test/testexceptionsafety.cpp b/test/testexceptionsafety.cpp index 4c1f099d8972..eaf2108a098c 100644 --- a/test/testexceptionsafety.cpp +++ b/test/testexceptionsafety.cpp @@ -16,14 +16,11 @@ * along with this program. If not, see . */ - #include "checkexceptionsafety.h" #include "errortypes.h" -#include "settings.h" #include "fixture.h" -#include "tokenize.h" - -#include +#include "helpers.h" +#include "settings.h" class TestExceptionSafety : public TestFixture { public: @@ -63,9 +60,8 @@ class TestExceptionSafety : public TestFixture { const Settings settings1 = settingsBuilder(s ? *s : settings).certainty(Certainty::inconclusive, inconclusive).build(); // Tokenize.. - Tokenizer tokenizer(settings1, this); - std::istringstream istr(code); - ASSERT_LOC(tokenizer.tokenize(istr, "test.cpp"), file, line); + SimpleTokenizer tokenizer(settings1, *this); + ASSERT_LOC(tokenizer.tokenize(code), file, line); // Check char variable usage.. runChecks(tokenizer, this); diff --git a/test/testfunctions.cpp b/test/testfunctions.cpp index d907c9ae40ab..3e682a375c6f 100644 --- a/test/testfunctions.cpp +++ b/test/testfunctions.cpp @@ -18,11 +18,10 @@ #include "checkfunctions.h" #include "errortypes.h" +#include "fixture.h" #include "helpers.h" #include "settings.h" #include "standards.h" -#include "fixture.h" -#include "tokenize.h" #include #include @@ -106,14 +105,13 @@ class TestFunctions : public TestFixture { } #define check(...) check_(__FILE__, __LINE__, __VA_ARGS__) - void check_(const char* file, int line, const char code[], const char filename[] = "test.cpp", const Settings* settings_ = nullptr) { + void check_(const char* file, int line, const char code[], bool cpp = true, const Settings* settings_ = nullptr) { if (!settings_) settings_ = &settings; // Tokenize.. - Tokenizer tokenizer(*settings_, this); - std::istringstream istr(code); - ASSERT_LOC(tokenizer.tokenize(istr, filename), file, line); + SimpleTokenizer tokenizer(*settings_, *this); + ASSERT_LOC(tokenizer.tokenize(code, cpp), file, line); runChecks(tokenizer, this); } @@ -252,32 +250,32 @@ class TestFunctions : public TestFixture { check("void f()\n" "{\n" " char *x = alloca(10);\n" - "}", "test.cpp"); // #4382 - there are no VLAs in C++ + "}"); // #4382 - there are no VLAs in C++ ASSERT_EQUALS("[test.cpp:3]: (warning) Obsolete function 'alloca' called.\n", errout_str()); check("void f()\n" "{\n" " char *x = alloca(10);\n" - "}", "test.c"); + "}", false); ASSERT_EQUALS("[test.c:3]: (warning) Obsolete function 'alloca' called. In C99 and later it is recommended to use a variable length array instead.\n", errout_str()); const Settings s = settingsBuilder(settings).c(Standards::C89).cpp(Standards::CPP03).build(); check("void f()\n" "{\n" " char *x = alloca(10);\n" - "}", "test.cpp", &s); // #4382 - there are no VLAs in C++ + "}", true, &s); // #4382 - there are no VLAs in C++ ASSERT_EQUALS("", errout_str()); check("void f()\n" "{\n" " char *x = alloca(10);\n" - "}", "test.c", &s); // #7558 - no alternative to alloca in C89 + "}", false, &s); // #7558 - no alternative to alloca in C89 ASSERT_EQUALS("", errout_str()); check("void f()\n" "{\n" " char *x = alloca(10);\n" - "}", "test.c", &s); + "}", false, &s); ASSERT_EQUALS("", errout_str()); } @@ -445,7 +443,7 @@ class TestFunctions : public TestFixture { check("void record(char* buf, int n) {\n" " memset(buf, 0, n < 255);\n" /* KO */ " memset(buf, 0, n < 255 ? n : 255);\n" /* OK */ - "}", "test.c"); + "}", false); ASSERT_EQUALS("[test.c:2]: (error) Invalid memset() argument nr 3. A non-boolean value is required.\n", errout_str()); // Ticket #6588 (c++ mode) @@ -747,7 +745,7 @@ class TestFunctions : public TestFixture { check("size_t f() { wchar_t x = L'x'; return wcslen(&x); }"); ASSERT_EQUALS("[test.cpp:1]: (error) Invalid wcslen() argument nr 1. A nul-terminated string is required.\n", errout_str()); - check("void f() { char a[10] = \"1234567890\"; puts(a); }", "test.c"); // #1770 + check("void f() { char a[10] = \"1234567890\"; puts(a); }", false); // #1770 ASSERT_EQUALS("[test.c:1]: (error) Invalid puts() argument nr 1. A nul-terminated string is required.\n", errout_str()); } @@ -1299,67 +1297,67 @@ class TestFunctions : public TestFixture { check("void foo() {\n" " mystrcmp(a, b);\n" - "}", "test.cpp", &settings2); + "}", true, &settings2); ASSERT_EQUALS("[test.cpp:2]: (warning) Return value of function mystrcmp() is not used.\n", errout_str()); check("void foo() {\n" " foo::mystrcmp(a, b);\n" - "}", "test.cpp", &settings2); + "}", true, &settings2); ASSERT_EQUALS("[test.cpp:2]: (warning) Return value of function foo::mystrcmp() is not used.\n", errout_str()); check("void f() {\n" " foo x;\n" " x.mystrcmp(a, b);\n" - "}", "test.cpp", &settings2); + "}", true, &settings2); ASSERT_EQUALS("[test.cpp:3]: (warning) Return value of function x.mystrcmp() is not used.\n", errout_str()); check("bool mystrcmp(char* a, char* b);\n" // cppcheck sees a custom strcmp definition, but it returns a value. Assume it is the one specified in the library. "void foo() {\n" " mystrcmp(a, b);\n" - "}", "test.cpp", &settings2); + "}", true, &settings2); ASSERT_EQUALS("[test.cpp:3]: (warning) Return value of function mystrcmp() is not used.\n", errout_str()); check("void mystrcmp(char* a, char* b);\n" // cppcheck sees a custom strcmp definition which returns void! "void foo() {\n" " mystrcmp(a, b);\n" - "}", "test.cpp", &settings2); + "}", true, &settings2); ASSERT_EQUALS("", errout_str()); check("void foo() {\n" " class mystrcmp { mystrcmp() {} };\n" // strcmp is a constructor definition here - "}", "test.cpp", &settings2); + "}", true, &settings2); ASSERT_EQUALS("", errout_str()); check("void foo() {\n" " return mystrcmp(a, b);\n" - "}", "test.cpp", &settings2); + "}", true, &settings2); ASSERT_EQUALS("", errout_str()); check("void foo() {\n" " return foo::mystrcmp(a, b);\n" - "}", "test.cpp", &settings2); + "}", true, &settings2); ASSERT_EQUALS("", errout_str()); check("void foo() {\n" " if(mystrcmp(a, b));\n" - "}", "test.cpp", &settings2); + "}", true, &settings2); ASSERT_EQUALS("", errout_str()); check("void foo() {\n" " bool b = mystrcmp(a, b);\n" - "}", "test.cpp", &settings2); + "}", true, &settings2); ASSERT_EQUALS("", errout_str()); // #6194 check("void foo() {\n" " MyStrCmp mystrcmp(x, y);\n" - "}", "test.cpp", &settings2); + "}", true, &settings2); ASSERT_EQUALS("", errout_str()); // #6197 check("void foo() {\n" " abc::def.mystrcmp(a,b);\n" - "}", "test.cpp", &settings2); + "}", true, &settings2); ASSERT_EQUALS("", errout_str()); // #6233 @@ -1382,18 +1380,18 @@ class TestFunctions : public TestFixture { // #7447 check("void foo() {\n" " int x{mystrcmp(a,b)};\n" - "}", "test.cpp", &settings2); + "}", true, &settings2); ASSERT_EQUALS("", errout_str()); // #7905 check("void foo() {\n" " int x({mystrcmp(a,b)});\n" - "}", "test.cpp", &settings2); + "}", true, &settings2); ASSERT_EQUALS("", errout_str()); check("void foo() {\n" // don't crash " DEBUG(123)(mystrcmp(a,b))(fd);\n" - "}", "test.c", &settings2); + "}", false, &settings2); check("struct teststruct {\n" " int testfunc1() __attribute__ ((warn_unused_result)) { return 1; }\n" " [[nodiscard]] int testfunc2() { return 1; }\n" @@ -1404,7 +1402,7 @@ class TestFunctions : public TestFixture { " TestStruct1.testfunc1();\n" " TestStruct1.testfunc2();\n" " return 0;\n" - "}", "test.cpp", &settings2); + "}", true, &settings2); ASSERT_EQUALS("[test.cpp:4]: (warning) Return value of function testfunc1() is not used.\n" "[test.cpp:4]: (warning) Return value of function testfunc2() is not used.\n" "[test.cpp:8]: (warning) Return value of function TestStruct1.testfunc1() is not used.\n" @@ -1428,7 +1426,7 @@ class TestFunctions : public TestFixture { // #8412 - unused operator result check("void foo() {\n" " !mystrcmp(a, b);\n" - "}", "test.cpp", &settings2); + "}", true, &settings2); ASSERT_EQUALS("[test.cpp:2]: (warning) Return value of function mystrcmp() is not used.\n", errout_str()); check("void f(std::vector v) {\n" @@ -1450,7 +1448,7 @@ class TestFunctions : public TestFixture { check("void foo() {\n" " mystrcmp(a, b);\n" - "}", "test.cpp", &settings2); + "}", true, &settings2); ASSERT_EQUALS("[test.cpp:2]: (style) Error code from the return value of function mystrcmp() is not used.\n", errout_str()); } @@ -1556,16 +1554,16 @@ class TestFunctions : public TestFixture { { const Settings s = settingsBuilder().c(Standards::C89).build(); - check(code, "test.c", &s); // c code (c89) + check(code, false, &s); // c code (c89) ASSERT_EQUALS("[test.c:1]: (error) Found an exit path from function with non-void return type that has missing return statement\n", errout_str()); } { const Settings s = settingsBuilder().c(Standards::C99).build(); - check(code, "test.c", &s); // c code (c99) + check(code, false, &s); // c code (c99) ASSERT_EQUALS("", errout_str()); - check(code, "test.cpp", &s); // c++ code + check(code, true, &s); // c++ code ASSERT_EQUALS("", errout_str()); } } @@ -1830,12 +1828,12 @@ class TestFunctions : public TestFixture { check("void f() {\n" " lib_func();" - "}", "test.cpp", &s); + "}", true, &s); ASSERT_EQUALS("[test.cpp:2]: (information) --check-library: There is no matching configuration for function lib_func()\n", errout_str()); check("void f(void* v) {\n" " lib_func(v);" - "}", "test.cpp", &s); + "}", true, &s); ASSERT_EQUALS("[test.cpp:2]: (information) --check-library: There is no matching configuration for function lib_func()\n", errout_str()); // #10105 @@ -1851,7 +1849,7 @@ class TestFunctions : public TestFixture { "\n" " void testFunctionReturnType() {\n" " }\n" - "};", "test.cpp", &s); + "};", true, &s); ASSERT_EQUALS("", errout_str()); // #11183 @@ -1861,7 +1859,7 @@ class TestFunctions : public TestFixture { "\n" "void f() {\n" " cb(std::string(\"\"));\n" - "}", "test.cpp", &s); + "}", true, &s); TODO_ASSERT_EQUALS("", "[test.cpp:6]: (information) --check-library: There is no matching configuration for function cb()\n", errout_str()); // #7375 @@ -1869,38 +1867,38 @@ class TestFunctions : public TestFixture { " struct S { int i; char c; };\n" " size_t s = sizeof(S);\n" " static_assert(s == 9);\n" - "}\n", "test.cpp", &s); + "}\n", true, &s); ASSERT_EQUALS("", errout_str()); check("void f(char) {}\n" "void g() {\n" " f(int8_t(1));\n" - "}\n", "test.cpp", &s); + "}\n", true, &s); ASSERT_EQUALS("", errout_str()); check("void f(std::uint64_t& u) {\n" " u = std::uint32_t(u) * std::uint64_t(100);\n" - "}\n", "test.cpp", &s); + "}\n", true, &s); ASSERT_EQUALS("", errout_str()); - check("void f() { throw(1); }\n", "test.cpp", &s); // #8958 + check("void f() { throw(1); }\n", true, &s); // #8958 ASSERT_EQUALS("", errout_str()); check("using namespace std;\n" - "void f() { throw range_error(\"abc\"); }\n", "test.cpp", &s); + "void f() { throw range_error(\"abc\"); }\n", true, &s); ASSERT_EQUALS("", errout_str()); check("class C {\n" // #9002 "public:\n" " static int f() { return 1; }\n" "};\n" - "void g() { C::f(); }\n", "test.cpp", &s); + "void g() { C::f(); }\n", true, &s); ASSERT_EQUALS("", errout_str()); check("void f(const std::vector& v) {\n" // #11223 " for (const auto& s : v)\n" " s.find(\"\");\n" - "}\n", "test.cpp", &s); + "}\n", true, &s); ASSERT_EQUALS("[test.cpp:3]: (warning) Return value of function s.find() is not used.\n", errout_str()); check("void f() {\n" @@ -1910,19 +1908,19 @@ class TestFunctions : public TestFixture { " q->push_back(1);\n" " auto* r = new std::vector;\n" " r->push_back(1);\n" - "}\n", "test.cpp", &s); + "}\n", true, &s); ASSERT_EQUALS("", errout_str()); check("void f() {\n" " auto p = std::make_shared>();\n" " p->push_back(1);\n" - "}\n", "test.cpp", &s); + "}\n", true, &s); ASSERT_EQUALS("", errout_str()); check("void f(std::vector>& v) {\n" " auto it = v.begin();\n" " it->push_back(1);\n" - "}\n", "test.cpp", &s); + "}\n", true, &s); ASSERT_EQUALS("", errout_str()); check("void f() {\n" @@ -1932,7 +1930,7 @@ class TestFunctions : public TestFixture { " w.push_back(1);\n" " auto x = std::vector(1);\n" " x.push_back(1);\n" - "}\n", "test.cpp", &s); + "}\n", true, &s); ASSERT_EQUALS("", errout_str()); check("void f() {\n" @@ -1940,7 +1938,7 @@ class TestFunctions : public TestFixture { " p->push_back(1);\n" " auto q{ std::make_shared>{} };\n" " q->push_back(1);\n" - "}\n", "test.cpp", &s); + "}\n", true, &s); TODO_ASSERT_EQUALS("", "[test.cpp:2]: (debug) auto token with no type.\n" "[test.cpp:4]: (debug) auto token with no type.\n" @@ -1953,12 +1951,12 @@ class TestFunctions : public TestFixture { " std::list::iterator it;\n" " for (it = l.begin(); it != l.end(); ++it)\n" " it->g(0);\n" - "}\n", "test.cpp", &s); + "}\n", true, &s); ASSERT_EQUALS("", filter_valueflow(errout_str())); check("auto f() {\n" " return std::runtime_error(\"abc\");\n" - "}\n", "test.cpp", &s); + "}\n", true, &s); TODO_ASSERT_EQUALS("", "[test.cpp:1]: (debug) auto token with no type.\n", errout_str()); @@ -1971,7 +1969,7 @@ class TestFunctions : public TestFixture { "void S::f(int i) const {\n" " for (const std::shared_ptr& c : v)\n" " c->f(i);\n" - "}\n", "test.cpp", &s); + "}\n", true, &s); ASSERT_EQUALS("", errout_str()); check("namespace N {\n" @@ -1980,29 +1978,29 @@ class TestFunctions : public TestFixture { "void f() {\n" " const auto& t = N::S::s;\n" " if (t.find(\"abc\") != t.end()) {}\n" - "}\n", "test.cpp", &s); + "}\n", true, &s); ASSERT_EQUALS("", filter_valueflow(errout_str())); check("void f(std::vector>>& v, int i, int j) {\n" " auto& s = v[i][j];\n" " s.insert(0);\n" - "}\n", "test.cpp", &s); + "}\n", true, &s); ASSERT_EQUALS("", errout_str()); check("int f(const std::vector& v, int i, char c) {\n" " const auto& s = v[i];\n" " return s.find(c);\n" - "}\n", "test.cpp", &s); + "}\n", true, &s); ASSERT_EQUALS("", errout_str()); check("void f() {\n" // #11604 " int (*g)() = nullptr;\n" - "}\n", "test.cpp", &s); + "}\n", true, &s); ASSERT_EQUALS("", errout_str()); check("void f() {\n" " INT (*g)() = nullptr;\n" - "}\n", "test.cpp", &s); + "}\n", true, &s); ASSERT_EQUALS("", errout_str()); check("struct T;\n" @@ -2011,13 +2009,13 @@ class TestFunctions : public TestFixture { " auto p = get();\n" " p->h(i);\n" " p.reset(nullptr);\n" - "}\n", "test.cpp", &s); + "}\n", true, &s); ASSERT_EQUALS("[test.cpp:5]: (information) --check-library: There is no matching configuration for function T::h()\n", errout_str()); check("struct S : std::vector {\n" " void f(int i) { push_back(i); }\n" - "};\n", "test.cpp", &s); + "};\n", true, &s); ASSERT_EQUALS("", errout_str()); check("void f() {\n" @@ -2027,18 +2025,18 @@ class TestFunctions : public TestFixture { " auto h{ []() -> std::string { return \"xyz\"; } };\n" " auto t = h();\n" " if (t.at(0)) {}\n" - "};\n", "test.cpp", &s); + "};\n", true, &s); ASSERT_EQUALS("", filter_valueflow(errout_str())); check("::std::string f(const char* c) {\n" // #12365 " return ::std::string(c);\n" - "}\n", "test.cpp", &s); + "}\n", true, &s); ASSERT_EQUALS("", errout_str()); check("template \n" "struct S : public std::vector {\n" " void resize(size_t n) { std::vector::resize(n); }\n" - "};\n", "test.cpp", &s); + "};\n", true, &s); ASSERT_EQUALS("", errout_str()); } diff --git a/test/testgarbage.cpp b/test/testgarbage.cpp index 86757545194d..8972da28463f 100644 --- a/test/testgarbage.cpp +++ b/test/testgarbage.cpp @@ -18,17 +18,16 @@ #include "check.h" #include "errortypes.h" +#include "fixture.h" +#include "helpers.h" #include "preprocessor.h" #include "settings.h" -#include "fixture.h" #include "token.h" -#include "tokenize.h" #include #include #include - class TestGarbage : public TestFixture { public: TestGarbage() : TestFixture("TestGarbage") {} @@ -272,26 +271,23 @@ class TestGarbage : public TestFixture { } #define checkCodeInternal(code, filename) checkCodeInternal_(code, filename, __FILE__, __LINE__) - std::string checkCode(const std::string &code, bool cpp = true) { + std::string checkCode(const char code[], bool cpp = true) { // double the tests - run each example as C as well as C++ - const char* const filename = cpp ? "test.cpp" : "test.c"; - const char* const alternatefilename = cpp ? "test.c" : "test.cpp"; // run alternate check first. It should only ensure stability - so we catch exceptions here. try { - checkCodeInternal(code, alternatefilename); + checkCodeInternal(code, !cpp); } catch (const InternalError&) {} - return checkCodeInternal(code, filename); + return checkCodeInternal(code, cpp); } - std::string checkCodeInternal_(const std::string &code, const char* filename, const char* file, int line) { + std::string checkCodeInternal_(const char code[], bool cpp, const char* file, int line) { Preprocessor preprocessor(settings); // tokenize.. - Tokenizer tokenizer(settings, this, &preprocessor); - std::istringstream istr(code); - ASSERT_LOC(tokenizer.tokenize(istr, filename), file, line); + SimpleTokenizer tokenizer(settings, *this, &preprocessor); + ASSERT_LOC(tokenizer.tokenize(code, cpp), file, line); // call all "runChecks" in all registered Check classes for (std::list::const_iterator it = Check::instances().cbegin(); it != Check::instances().cend(); ++it) { @@ -303,10 +299,9 @@ class TestGarbage : public TestFixture { #define getSyntaxError(code) getSyntaxError_(code, __FILE__, __LINE__) std::string getSyntaxError_(const char code[], const char* file, int line) { - Tokenizer tokenizer(settings, this); - std::istringstream istr(code); + SimpleTokenizer tokenizer(settings, *this); try { - ASSERT_LOC(tokenizer.tokenize(istr, "test.cpp"), file, line); + ASSERT_LOC(tokenizer.tokenize(code), file, line); } catch (InternalError& e) { if (e.id != "syntaxError") return ""; @@ -319,12 +314,9 @@ class TestGarbage : public TestFixture { void final_class_x() { const char code[] = "class __declspec(dllexport) x final { };"; - { - Tokenizer tokenizer(settings, this); - std::istringstream istr(code); - ASSERT(tokenizer.tokenize(istr, "test.cpp")); - ASSERT_EQUALS("", errout_str()); - } + SimpleTokenizer tokenizer(settings, *this); + ASSERT(tokenizer.tokenize(code)); + ASSERT_EQUALS("", errout_str()); } void wrong_syntax1() { @@ -368,10 +360,9 @@ class TestGarbage : public TestFixture { " )\n" "}"; - Tokenizer tokenizer(settings, this); - std::istringstream istr(code); + SimpleTokenizer tokenizer(settings, *this); try { - ASSERT(tokenizer.tokenize(istr, "test.cpp")); + ASSERT(tokenizer.tokenize(code)); assertThrowFail(__FILE__, __LINE__); } catch (InternalError& e) { ASSERT_EQUALS("syntax error", e.errorMessage); @@ -402,15 +393,13 @@ class TestGarbage : public TestFixture { const char code[] = "class x y { };"; { - Tokenizer tokenizer(settings, this); - std::istringstream istr(code); - ASSERT(tokenizer.tokenize(istr, "test.c")); + SimpleTokenizer tokenizer(settings, *this); + ASSERT(tokenizer.tokenize(code, false)); ASSERT_EQUALS("", errout_str()); } { - Tokenizer tokenizer(settings, this); - std::istringstream istr(code); - ASSERT(tokenizer.tokenize(istr, "test.cpp")); + SimpleTokenizer tokenizer(settings, *this); + ASSERT(tokenizer.tokenize(code)); ASSERT_EQUALS("[test.cpp:1]: (information) The code 'class x y {' is not handled. You can use -I or --include to add handling of this code.\n", errout_str()); } } @@ -1536,7 +1525,7 @@ class TestGarbage : public TestFixture { } void garbageCode187() { // # 8152 - segfault in handling - const std::string inp("0|\0|0>;\n", 8); + const char inp[] = "0|\0|0>;\n"; ASSERT_THROW_INTERNAL(checkCode(inp), SYNTAX); checkCode("template struct S : A< B || C > {};"); // No syntax error: #8390 diff --git a/test/testinternal.cpp b/test/testinternal.cpp index 90369a6efed9..445044636b5a 100644 --- a/test/testinternal.cpp +++ b/test/testinternal.cpp @@ -18,13 +18,11 @@ #ifdef CHECK_INTERNAL -#include "tokenize.h" #include "checkinternal.h" #include "fixture.h" +#include "helpers.h" #include "settings.h" -#include - class TestInternal : public TestFixture { public: TestInternal() : TestFixture("TestInternal") {} @@ -51,9 +49,8 @@ class TestInternal : public TestFixture { #define check(code) check_(code, __FILE__, __LINE__) void check_(const char code[], const char* file, int line) { // Tokenize.. - Tokenizer tokenizer(settings, this); - std::istringstream istr(code); - ASSERT_LOC(tokenizer.tokenize(istr, "test.cpp"), file, line); + SimpleTokenizer tokenizer(settings, *this); + ASSERT_LOC(tokenizer.tokenize(code), file, line); // Check.. runChecks(tokenizer, this); diff --git a/test/testio.cpp b/test/testio.cpp index ad07c82f02c1..e815be969821 100644 --- a/test/testio.cpp +++ b/test/testio.cpp @@ -16,17 +16,14 @@ * along with this program. If not, see . */ - #include "checkio.h" #include "config.h" #include "errortypes.h" +#include "fixture.h" #include "helpers.h" #include "platform.h" #include "settings.h" -#include "fixture.h" -#include "tokenize.h" -#include #include class TestIO : public TestFixture { @@ -99,10 +96,8 @@ class TestIO : public TestFixture { PLATFORM(settings1.platform, options.platform); // Tokenize.. - Tokenizer tokenizer(settings1, this); - std::istringstream istr(code); - const std::string file_in = options.cpp ? "test.cpp" : "test.c"; - ASSERT_LOC(tokenizer.tokenize(istr, file_in.c_str()), file, line); + SimpleTokenizer tokenizer(settings1, *this); + ASSERT_LOC(tokenizer.tokenize(code, options.cpp), file, line); // Check.. if (options.onlyFormatStr) { diff --git a/test/testleakautovar.cpp b/test/testleakautovar.cpp index 2a7e6ed6d7ce..1c788ece2b94 100644 --- a/test/testleakautovar.cpp +++ b/test/testleakautovar.cpp @@ -16,15 +16,13 @@ * along with this program. If not, see . */ - #include "checkleakautovar.h" #include "errortypes.h" +#include "fixture.h" #include "helpers.h" #include "settings.h" -#include "fixture.h" #include "tokenize.h" -#include #include #include @@ -234,9 +232,8 @@ class TestLeakAutoVar : public TestFixture { const Settings settings1 = settingsBuilder(s ? *s : settings).checkLibrary().build(); // Tokenize.. - Tokenizer tokenizer(settings1, this); - std::istringstream istr(code); - ASSERT_LOC(tokenizer.tokenize(istr, cpp ? "test.cpp" : "test.c"), file, line); + SimpleTokenizer tokenizer(settings1, *this); + ASSERT_LOC(tokenizer.tokenize(code, cpp), file, line); // Check for leaks.. runChecks(tokenizer, this); @@ -246,9 +243,8 @@ class TestLeakAutoVar : public TestFixture { const Settings settings0 = settingsBuilder(s).checkLibrary().build(); // Tokenize.. - Tokenizer tokenizer(settings0, this); - std::istringstream istr(code); - ASSERT_LOC(tokenizer.tokenize(istr, "test.cpp"), file, line); + SimpleTokenizer tokenizer(settings0, *this); + ASSERT_LOC(tokenizer.tokenize(code), file, line); // Check for leaks.. runChecks(tokenizer, this); @@ -3123,9 +3119,8 @@ class TestLeakAutoVarStrcpy : public TestFixture { void check_(const char* file, int line, const char code[]) { // Tokenize.. - Tokenizer tokenizer(settings, this); - std::istringstream istr(code); - ASSERT_LOC(tokenizer.tokenize(istr, "test.cpp"), file, line); + SimpleTokenizer tokenizer(settings, *this); + ASSERT_LOC(tokenizer.tokenize(code), file, line); // Check for leaks.. runChecks(tokenizer, this); @@ -3227,9 +3222,8 @@ class TestLeakAutoVarWindows : public TestFixture { void check_(const char* file, int line, const char code[]) { // Tokenize.. - Tokenizer tokenizer(settings, this); - std::istringstream istr(code); - ASSERT_LOC(tokenizer.tokenize(istr, "test.c"), file, line); + SimpleTokenizer tokenizer(settings, *this); + ASSERT_LOC(tokenizer.tokenize(code, false), file, line); // Check for leaks.. runChecks(tokenizer, this); @@ -3299,9 +3293,8 @@ class TestLeakAutoVarPosix : public TestFixture { void check_(const char* file, int line, const char code[]) { // Tokenize.. - Tokenizer tokenizer(settings, this); - std::istringstream istr(code); - ASSERT_LOC(tokenizer.tokenize(istr, "test.cpp"), file, line); + SimpleTokenizer tokenizer(settings, *this); + ASSERT_LOC(tokenizer.tokenize(code), file, line); // Check for leaks.. runChecks(tokenizer, this); diff --git a/test/testlibrary.cpp b/test/testlibrary.cpp index c9e2a9b8c833..7739877d78d0 100644 --- a/test/testlibrary.cpp +++ b/test/testlibrary.cpp @@ -17,13 +17,12 @@ */ #include "errortypes.h" +#include "fixture.h" +#include "helpers.h" #include "library.h" #include "settings.h" #include "standards.h" -#include "fixture.h" -#include "helpers.h" #include "token.h" -#include "tokenize.h" #include "tokenlist.h" #include @@ -571,16 +570,16 @@ class TestLibrary : public TestFixture { ASSERT_EQUALS(library.functions.size(), 1U); { - Tokenizer tokenizer(settings, this); - std::istringstream istr("CString str; str.Format();"); - ASSERT(tokenizer.tokenize(istr, "test.cpp")); + SimpleTokenizer tokenizer(settings, *this); + const char code[] = "CString str; str.Format();"; + ASSERT(tokenizer.tokenize(code)); ASSERT(library.isnotnoreturn(Token::findsimplematch(tokenizer.tokens(), "Format"))); } { - Tokenizer tokenizer(settings, this); - std::istringstream istr("HardDrive hd; hd.Format();"); - ASSERT(tokenizer.tokenize(istr, "test.cpp")); + SimpleTokenizer tokenizer(settings, *this); + const char code[] = "HardDrive hd; hd.Format();"; + ASSERT(tokenizer.tokenize(code)); ASSERT(!library.isnotnoreturn(Token::findsimplematch(tokenizer.tokens(), "Format"))); } } @@ -597,16 +596,16 @@ class TestLibrary : public TestFixture { ASSERT(loadxmldata(library, xmldata, sizeof(xmldata))); { - Tokenizer tokenizer(settings, this); - std::istringstream istr("struct X : public Base { void dostuff() { f(0); } };"); - ASSERT(tokenizer.tokenize(istr, "test.cpp")); + SimpleTokenizer tokenizer(settings, *this); + const char code[] = "struct X : public Base { void dostuff() { f(0); } };"; + ASSERT(tokenizer.tokenize(code)); ASSERT(library.isnullargbad(Token::findsimplematch(tokenizer.tokens(), "f"),1)); } { - Tokenizer tokenizer(settings, this); - std::istringstream istr("struct X : public Base { void dostuff() { f(1,2); } };"); - ASSERT(tokenizer.tokenize(istr, "test.cpp")); + SimpleTokenizer tokenizer(settings, *this); + const char code[] = "struct X : public Base { void dostuff() { f(1,2); } };"; + ASSERT(tokenizer.tokenize(code)); ASSERT(!library.isnullargbad(Token::findsimplematch(tokenizer.tokens(), "f"),1)); } } diff --git a/test/testmemleak.cpp b/test/testmemleak.cpp index 8659865c82f3..db73d5ca665a 100644 --- a/test/testmemleak.cpp +++ b/test/testmemleak.cpp @@ -18,14 +18,13 @@ #include "checkmemoryleak.h" #include "errortypes.h" +#include "fixture.h" +#include "helpers.h" #include "settings.h" #include "symboldatabase.h" -#include "fixture.h" #include "token.h" -#include "tokenize.h" #include -#include class TestMemleak : private TestFixture { public: @@ -42,9 +41,8 @@ class TestMemleak : private TestFixture { #define functionReturnType(code) functionReturnType_(code, __FILE__, __LINE__) CheckMemoryLeak::AllocType functionReturnType_(const char code[], const char* file, int line) { // Tokenize.. - Tokenizer tokenizer(settings, this); - std::istringstream istr(code); - ASSERT_LOC(tokenizer.tokenize(istr, "test.cpp"), file, line); + SimpleTokenizer tokenizer(settings, *this); + ASSERT_LOC(tokenizer.tokenize(code), file, line); const CheckMemoryLeak c(&tokenizer, this, &settings); @@ -91,9 +89,8 @@ class TestMemleak : private TestFixture { " }\n" "};\n"; - Tokenizer tokenizer(settings, this); - std::istringstream istr(code); - ASSERT(tokenizer.tokenize(istr, "test.cpp")); + SimpleTokenizer tokenizer(settings, *this); + ASSERT(tokenizer.tokenize(code)); // there is no allocation const Token *tok = Token::findsimplematch(tokenizer.tokens(), "ret ="); @@ -118,9 +115,8 @@ class TestMemleakInFunction : public TestFixture { #define check(...) check_(__FILE__, __LINE__, __VA_ARGS__) void check_(const char* file, int line, const char code[]) { // Tokenize.. - Tokenizer tokenizer(settings, this); - std::istringstream istr(code); - ASSERT_LOC(tokenizer.tokenize(istr, "test.cpp"), file, line); + SimpleTokenizer tokenizer(settings, *this); + ASSERT_LOC(tokenizer.tokenize(code), file, line); // Check for memory leaks.. CheckMemoryLeakInFunction checkMemoryLeak(&tokenizer, &settings, this); @@ -444,9 +440,8 @@ class TestMemleakInClass : public TestFixture { */ void check_(const char* file, int line, const char code[]) { // Tokenize.. - Tokenizer tokenizer(settings, this); - std::istringstream istr(code); - ASSERT_LOC(tokenizer.tokenize(istr, "test.cpp"), file, line); + SimpleTokenizer tokenizer(settings, *this); + ASSERT_LOC(tokenizer.tokenize(code), file, line); // Check for memory leaks.. CheckMemoryLeakInClass checkMemoryLeak(&tokenizer, &settings, this); @@ -1646,11 +1641,10 @@ class TestMemleakStructMember : public TestFixture { private: const Settings settings = settingsBuilder().library("std.cfg").library("posix.cfg").build(); - void check_(const char* file, int line, const char code[], bool isCPP = true) { + void check_(const char* file, int line, const char code[], bool cpp = true) { // Tokenize.. - Tokenizer tokenizer(settings, this); - std::istringstream istr(code); - ASSERT_LOC(tokenizer.tokenize(istr, isCPP ? "test.cpp" : "test.c"), file, line); + SimpleTokenizer tokenizer(settings, *this); + ASSERT_LOC(tokenizer.tokenize(code, cpp), file, line); // Check for memory leaks.. CheckMemoryLeakStructMember checkMemoryLeakStructMember(&tokenizer, &settings, this); @@ -2258,9 +2252,8 @@ class TestMemleakNoVar : public TestFixture { void check_(const char* file, int line, const char code[]) { // Tokenize.. - Tokenizer tokenizer(settings, this); - std::istringstream istr(code); - ASSERT_LOC(tokenizer.tokenize(istr, "test.cpp"), file, line); + SimpleTokenizer tokenizer(settings, *this); + ASSERT_LOC(tokenizer.tokenize(code), file, line); // Check for memory leaks.. CheckMemoryLeakNoVar checkMemoryLeakNoVar(&tokenizer, &settings, this); diff --git a/test/testnullpointer.cpp b/test/testnullpointer.cpp index df309274172e..b950af682756 100644 --- a/test/testnullpointer.cpp +++ b/test/testnullpointer.cpp @@ -20,16 +20,15 @@ #include "checknullpointer.h" #include "ctu.h" #include "errortypes.h" +#include "fixture.h" #include "helpers.h" #include "library.h" #include "settings.h" -#include "fixture.h" #include "token.h" #include "tokenize.h" #include #include -#include #include #include #include @@ -177,13 +176,12 @@ class TestNullPointer : public TestFixture { } #define check(...) check_(__FILE__, __LINE__, __VA_ARGS__) - void check_(const char* file, int line, const char code[], bool inconclusive = false, const char filename[] = "test.cpp") { + void check_(const char* file, int line, const char code[], bool inconclusive = false, bool cpp = true) { const Settings settings1 = settingsBuilder(settings).certainty(Certainty::inconclusive, inconclusive).build(); // Tokenize.. - Tokenizer tokenizer(settings1, this); - std::istringstream istr(code); - ASSERT_LOC(tokenizer.tokenize(istr, filename), file, line); + SimpleTokenizer tokenizer(settings1, *this); + ASSERT_LOC(tokenizer.tokenize(code, cpp), file, line); // Check for null pointer dereferences.. runChecks(tokenizer, this); @@ -1320,10 +1318,10 @@ class TestNullPointer : public TestFixture { " return *i;\n" "}\n"; - check(code, false, "test.cpp"); // C++ file => nullptr means NULL + check(code, false, true); // C++ file => nullptr means NULL ASSERT_EQUALS("[test.cpp:4]: (error) Null pointer dereference: i\n", errout_str()); - check(code, false, "test.c"); // C file => nullptr does not mean NULL + check(code, false, false); // C file => nullptr does not mean NULL ASSERT_EQUALS("", errout_str()); } @@ -2634,7 +2632,7 @@ class TestNullPointer : public TestFixture { " s->ppc = NULL;\n" " if (alloc(s))\n" " s->ppc[0] = \"\";\n" - "}\n", /*inconclusive*/ false, "test.c"); + "}\n", /*inconclusive*/ false, false); ASSERT_EQUALS("", errout_str()); } @@ -4141,9 +4139,9 @@ class TestNullPointer : public TestFixture { } void functioncalllibrary() { - Tokenizer tokenizer(settingsDefault,this); - std::istringstream code("void f() { int a,b,c; x(a,b,c); }"); - ASSERT_EQUALS(true, tokenizer.tokenize(code, "test.c")); + SimpleTokenizer tokenizer(settingsDefault,*this); + const char code[] = "void f() { int a,b,c; x(a,b,c); }"; + ASSERT_EQUALS(true, tokenizer.tokenize(code, false)); const Token *xtok = Token::findsimplematch(tokenizer.tokens(), "x"); // nothing bad.. @@ -4376,7 +4374,7 @@ class TestNullPointer : public TestFixture { "}\n" "void bar() {\n" " foo(0);\n" - "}\n", true, "test.c"); + "}\n", true, false); ASSERT_EQUALS("", errout_str()); } @@ -4482,9 +4480,8 @@ class TestNullPointer : public TestFixture { #define ctu(code) ctu_(code, __FILE__, __LINE__) void ctu_(const char code[], const char* file, int line) { // Tokenize.. - Tokenizer tokenizer(settings, this); - std::istringstream istr(code); - ASSERT_LOC(tokenizer.tokenize(istr, "test.cpp"), file, line); + SimpleTokenizer tokenizer(settings, *this); + ASSERT_LOC(tokenizer.tokenize(code), file, line); CTU::FileInfo *ctu = CTU::getFileInfo(&tokenizer); diff --git a/test/testother.cpp b/test/testother.cpp index 94e7f66e4218..eaddae272c6b 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -18,15 +18,14 @@ #include "checkother.h" #include "errortypes.h" +#include "fixture.h" #include "helpers.h" #include "platform.h" #include "preprocessor.h" #include "settings.h" #include "standards.h" -#include "fixture.h" #include "tokenize.h" -#include #include #include @@ -294,7 +293,7 @@ class TestOther : public TestFixture { } #define check(...) check_(__FILE__, __LINE__, __VA_ARGS__) - void check_(const char* file, int line, const char code[], const char *filename = nullptr, bool inconclusive = true, bool runSimpleChecks=true, bool verbose=false, Settings* settings = nullptr) { + void check_(const char* file, int line, const char code[], bool cpp = true, bool inconclusive = true, bool runSimpleChecks=true, bool verbose=false, Settings* settings = nullptr) { if (!settings) { settings = &_settings; } @@ -310,9 +309,8 @@ class TestOther : public TestFixture { Preprocessor preprocessor(*settings); // Tokenize.. - Tokenizer tokenizer(*settings, this, &preprocessor); - std::istringstream istr(code); - ASSERT_LOC(tokenizer.tokenize(istr, filename ? filename : "test.cpp"), file, line); + SimpleTokenizer tokenizer(*settings, *this, &preprocessor); + ASSERT_LOC(tokenizer.tokenize(code, cpp), file, line); // Check.. runChecks(tokenizer, this); @@ -321,7 +319,7 @@ class TestOther : public TestFixture { } void check_(const char* file, int line, const char code[], Settings *s) { - check_(file, line, code, "test.cpp", true, true, false, s); + check_(file, line, code, true, true, true, false, s); } #define checkP(...) checkP_(__FILE__, __LINE__, __VA_ARGS__) @@ -350,7 +348,7 @@ class TestOther : public TestFixture { void checkInterlockedDecrement(const char code[]) { /*const*/ Settings settings = settingsBuilder().platform(Platform::Type::Win32A).build(); - check(code, nullptr, false, true, false, &settings); + check(code, true, false, true, false, &settings); } void emptyBrackets() { @@ -1146,7 +1144,7 @@ class TestOther : public TestFixture { " else if(b);\n" " else if(c);\n" " else;\n" - "}", nullptr, false); + "}", true, false); ASSERT_EQUALS("", errout_str()); } @@ -1358,7 +1356,7 @@ class TestOther : public TestFixture { " currtime = time(&dummy);\n" " if (currtime > t) {}\n" " }\n" - "}", "test.c"); + "}", false); ASSERT_EQUALS("[test.c:2]: (style) The scope of the variable 'currtime' can be reduced.\n", errout_str()); } @@ -1411,7 +1409,7 @@ class TestOther : public TestFixture { " s.i = 0;\n" " g(e, s);\n" " }\n" - "}\n", "test.c"); + "}\n", false); ASSERT_EQUALS("[test.c:4]: (style) The scope of the variable 'e' can be reduced.\n" "[test.c:5]: (style) The scope of the variable 's' can be reduced.\n", errout_str()); @@ -1670,7 +1668,7 @@ class TestOther : public TestFixture { " else{\n" " for( i = 0U; i < 5U; i++ ) {}\n" " }\n" - "}\n", nullptr, false); + "}\n", true, false); ASSERT_EQUALS("[test.cpp:2]: (style) The scope of the variable 'i' can be reduced.\n", errout_str()); } @@ -1685,7 +1683,7 @@ class TestOther : public TestFixture { " for( i = 0U; i < 5U; i++ ) {}\n" " }\n" " }\n" - "}\n", nullptr, false); + "}\n", true, false); ASSERT_EQUALS("[test.cpp:2]: (style) The scope of the variable 'i' can be reduced.\n", errout_str()); } @@ -1708,9 +1706,8 @@ class TestOther : public TestFixture { Preprocessor preprocessor(settings); // Tokenize.. - Tokenizer tokenizerCpp(settings, this, &preprocessor); - std::istringstream istr(code); - ASSERT_LOC(tokenizerCpp.tokenize(istr, "test.cpp"), file, line); + SimpleTokenizer tokenizerCpp(settings, *this, &preprocessor); + ASSERT_LOC(tokenizerCpp.tokenize(code), file, line); CheckOther checkOtherCpp(&tokenizerCpp, &settings, this); checkOtherCpp.warningOldStylePointerCast(); @@ -1930,9 +1927,8 @@ class TestOther : public TestFixture { Preprocessor preprocessor(settings); // Tokenize.. - Tokenizer tokenizer(settings, this, &preprocessor); - std::istringstream istr(code); - ASSERT_LOC(tokenizer.tokenize(istr, "test.cpp"), file, line); + SimpleTokenizer tokenizer(settings, *this, &preprocessor); + ASSERT_LOC(tokenizer.tokenize(code), file, line); CheckOther checkOtherCpp(&tokenizer, &settings, this); checkOtherCpp.invalidPointerCast(); @@ -2240,7 +2236,7 @@ class TestOther : public TestFixture { "};\n" "void f(S s) {\n" " if (s.x > s.y) {}\n" - "}\n", /*filename*/ nullptr, /*inconclusive*/ true, /*runSimpleChecks*/ true, /*verbose*/ false, &settings0); + "}\n", /*cpp*/ true, /*inconclusive*/ true, /*runSimpleChecks*/ true, /*verbose*/ false, &settings0); ASSERT_EQUALS("", errout_str()); check("struct S { std::list l; };\n" // #12147 @@ -2274,7 +2270,7 @@ class TestOther : public TestFixture { /*const*/ Settings settings1 = settingsBuilder().platform(Platform::Type::Win64).build(); check("using ui64 = unsigned __int64;\n" "ui64 Test(ui64 one, ui64 two) { return one + two; }\n", - /*filename*/ nullptr, /*inconclusive*/ true, /*runSimpleChecks*/ true, /*verbose*/ false, &settings1); + /*cpp*/ true, /*inconclusive*/ true, /*runSimpleChecks*/ true, /*verbose*/ false, &settings1); ASSERT_EQUALS("", errout_str()); } @@ -4312,7 +4308,7 @@ class TestOther : public TestFixture { " case 3:\n" " strcpy(str, \"b'\");\n" " }\n" - "}", nullptr, false, false); + "}", true, false, false); TODO_ASSERT_EQUALS("[test.cpp:6] -> [test.cpp:8]: (style) Buffer 'str' is being written before its old content has been used. 'break;' missing?\n", "", errout_str()); @@ -4343,7 +4339,7 @@ class TestOther : public TestFixture { " strcpy(str, \"b'\");\n" " z++;\n" " }\n" - "}", nullptr, false, false); + "}", true, false, false); TODO_ASSERT_EQUALS("[test.cpp:7] -> [test.cpp:10]: (style) Buffer 'str' is being written before its old content has been used. 'break;' missing?\n", "", errout_str()); @@ -4372,7 +4368,7 @@ class TestOther : public TestFixture { " case 3:\n" " strcpy(str, \"b'\");\n" " }\n" - "}", nullptr, false, false); + "}", true, false, false); ASSERT_EQUALS("", errout_str()); // Ticket #5158 "segmentation fault (valid code)" @@ -4386,7 +4382,7 @@ class TestOther : public TestFixture { "} deflate_state;\n" "void f(deflate_state *s) {\n" " s->dyn_ltree[0].fc.freq++;\n" - "}\n", nullptr, false, false); + "}\n", true, false, false); ASSERT_EQUALS("", errout_str()); // Ticket #6132 "crash: daca: kvirc CheckOther::checkRedundantAssignment()" @@ -4396,7 +4392,7 @@ class TestOther : public TestFixture { "} else {\n" "KviKvsScript :: run ( m_szCompletionCallback , out ? out : ( g_pApp . activeConsole ( ) ) , & vParams ) ;\n" "}\n" - "}\n", nullptr, false, true); + "}\n", true, false, true); ASSERT_EQUALS("", errout_str()); check("void f() {\n" @@ -4557,7 +4553,7 @@ class TestOther : public TestFixture { " y++;\n" " }\n" " bar(y);\n" - "}", nullptr, false, false); + "}", true, false, false); ASSERT_EQUALS("", errout_str()); check("void foo()\n" "{\n" @@ -4611,7 +4607,7 @@ class TestOther : public TestFixture { " y--;\n" " }\n" " bar(y);\n" - "}", nullptr, false, false); + "}", true, false, false); ASSERT_EQUALS("", errout_str()); check("void foo()\n" "{\n" @@ -4967,20 +4963,20 @@ class TestOther : public TestFixture { " continue;\n" " }\n" " }\n" - "}", nullptr, false, false); + "}", true, false, false); ASSERT_EQUALS("[test.cpp:5]: (style) Consecutive return, break, continue, goto or throw statements are unnecessary.\n", errout_str()); check("int foo(int a) {\n" " return 0;\n" " return(a-1);\n" - "}", nullptr, false, false); + "}", true, false, false); ASSERT_EQUALS("[test.cpp:3]: (style) Consecutive return, break, continue, goto or throw statements are unnecessary.\n", errout_str()); check("int foo(int a) {\n" " A:" " return(0);\n" " goto A;\n" - "}", nullptr, false, false); + "}", true, false, false); ASSERT_EQUALS("[test.cpp:3]: (style) Consecutive return, break, continue, goto or throw statements are unnecessary.\n", errout_str()); constexpr char xmldata[] = "\n" @@ -4995,7 +4991,7 @@ class TestOther : public TestFixture { check("void foo() {\n" " exit(0);\n" " break;\n" - "}", nullptr, false, false, false, &settings); + "}", true, false, false, false, &settings); ASSERT_EQUALS("[test.cpp:3]: (style) Consecutive return, break, continue, goto or throw statements are unnecessary.\n", errout_str()); check("class NeonSession {\n" @@ -5004,16 +5000,16 @@ class TestOther : public TestFixture { "void NeonSession::exit()\n" "{\n" " SAL_INFO(\"ucb.ucp.webdav\", \"neon commands cannot be aborted\");\n" - "}", nullptr, false, false, false, &settings); + "}", true, false, false, false, &settings); ASSERT_EQUALS("", errout_str()); check("void NeonSession::exit()\n" "{\n" " SAL_INFO(\"ucb.ucp.webdav\", \"neon commands cannot be aborted\");\n" - "}", nullptr, false, false, false, &settings); + "}", true, false, false, false, &settings); ASSERT_EQUALS("", errout_str()); - check("void foo() { xResAccess->exit(); }", nullptr, false, false, false, &settings); + check("void foo() { xResAccess->exit(); }", true, false, false, false, &settings); ASSERT_EQUALS("", errout_str()); check("void foo(int a)\n" @@ -5027,7 +5023,7 @@ class TestOther : public TestFixture { " c++;\n" " break;\n" " }\n" - "}", nullptr, false, false); + "}", true, false, false); ASSERT_EQUALS("[test.cpp:7]: (style) Consecutive return, break, continue, goto or throw statements are unnecessary.\n", errout_str()); check("void foo(int a)\n" @@ -5051,7 +5047,7 @@ class TestOther : public TestFixture { " break;\n" " }\n" " }\n" - "}", nullptr, false, false); + "}", true, false, false); ASSERT_EQUALS("[test.cpp:6]: (style) Consecutive return, break, continue, goto or throw statements are unnecessary.\n", errout_str()); check("void foo(int a)\n" @@ -5063,7 +5059,7 @@ class TestOther : public TestFixture { " }\n" " a+=2;\n" " }\n" - "}", nullptr, false, false); + "}", true, false, false); ASSERT_EQUALS("[test.cpp:6]: (style) Consecutive return, break, continue, goto or throw statements are unnecessary.\n", errout_str()); check("void foo(int a)\n" @@ -5080,44 +5076,44 @@ class TestOther : public TestFixture { check("int foo() {\n" " throw 0;\n" " return 1;\n" - "}", nullptr, false, false); + "}", true, false, false); ASSERT_EQUALS("[test.cpp:3]: (style) Consecutive return, break, continue, goto or throw statements are unnecessary.\n", errout_str()); check("void foo() {\n" " throw 0;\n" " return;\n" - "}", nullptr, false, false); + "}", true, false, false); ASSERT_EQUALS("[test.cpp:3]: (style) Consecutive return, break, continue, goto or throw statements are unnecessary.\n", errout_str()); check("int foo() {\n" " throw = 0;\n" " return 1;\n" - "}", "test.c", false, false); + "}", false, false, false); ASSERT_EQUALS("", errout_str()); check("int foo() {\n" " return 0;\n" " return 1;\n" - "}", nullptr, false, false, false); + "}", true, false, false, false); ASSERT_EQUALS("[test.cpp:3]: (style) Consecutive return, break, continue, goto or throw statements are unnecessary.\n", errout_str()); check("int foo() {\n" " return 0;\n" " foo();\n" - "}", nullptr, false, false); + "}", true, false, false); ASSERT_EQUALS("[test.cpp:3]: (style) Statements following 'return' will never be executed.\n", errout_str()); check("int foo(int unused) {\n" " return 0;\n" " (void)unused;\n" - "}", nullptr, false, false); + "}", true, false, false); ASSERT_EQUALS("", errout_str()); check("int foo(int unused1, int unused2) {\n" " return 0;\n" " (void)unused1;\n" " (void)unused2;\n" - "}", nullptr, false, false); + "}", true, false, false); ASSERT_EQUALS("", errout_str()); check("int foo(int unused1, int unused2) {\n" @@ -5125,7 +5121,7 @@ class TestOther : public TestFixture { " (void)unused1;\n" " (void)unused2;\n" " foo();\n" - "}", nullptr, false, false); + "}", true, false, false); ASSERT_EQUALS("[test.cpp:5]: (style) Statements following 'return' will never be executed.\n", errout_str()); check("int foo() {\n" @@ -5143,7 +5139,7 @@ class TestOther : public TestFixture { " return 0;\n" " }\n" " return 124;\n" - "}", nullptr, false, false); + "}", true, false, false); ASSERT_EQUALS("[test.cpp:4]: (style) Consecutive return, break, continue, goto or throw statements are unnecessary.\n", errout_str()); check("void foo() {\n" @@ -5151,7 +5147,7 @@ class TestOther : public TestFixture { " return;\n" " break;\n" " }\n" - "}", nullptr, false, false); + "}", true, false, false); ASSERT_EQUALS("[test.cpp:4]: (style) Consecutive return, break, continue, goto or throw statements are unnecessary.\n", errout_str()); // #5707 @@ -5162,14 +5158,14 @@ class TestOther : public TestFixture { " }\n" " return 0;\n" " j=2;\n" - "}", nullptr, false, false); + "}", true, false, false); ASSERT_EQUALS("[test.cpp:7]: (style) Statements following 'return' will never be executed.\n", errout_str()); check("int foo() {\n" " return 0;\n" " label:\n" " throw 0;\n" - "}", nullptr, false, false); + "}", true, false, false); ASSERT_EQUALS("[test.cpp:3]: (style) Label 'label' is not used.\n", errout_str()); check("struct A {\n" @@ -5211,21 +5207,21 @@ class TestOther : public TestFixture { " return 0;\n" "\n" // #endif " return 1;\n" - "}", nullptr, false, false); + "}", true, false, false); ASSERT_EQUALS("", errout_str()); check("int foo() {\n" "\n" // #ifdef A " return 0;\n" "\n" // #endif " return 1;\n" - "}", nullptr, true, false); + "}", true, true, false); ASSERT_EQUALS("[test.cpp:5]: (style, inconclusive) Consecutive return, break, continue, goto or throw statements are unnecessary.\n", errout_str()); // #4711 lambda functions check("int f() {\n" " return g([](int x){(void)x+1; return x;});\n" "}", - nullptr, + true, false, false); ASSERT_EQUALS("", errout_str()); @@ -5241,7 +5237,7 @@ class TestOther : public TestFixture { " __asm__ (\"rorw $8, %w0\" : \"=r\" (__v) : \"0\" (__x) : \"cc\");\n" " (void)__v;\n" " }));\n" - "}", nullptr, false, false); + "}", true, false, false); ASSERT_EQUALS("", errout_str()); // #6008 @@ -5250,7 +5246,7 @@ class TestOther : public TestFixture { " int sum = a_ + b_;\n" " return sum;\n" " };\n" - "}", nullptr, false, false); + "}", true, false, false); ASSERT_EQUALS("", errout_str()); // #5789 @@ -5258,20 +5254,20 @@ class TestOther : public TestFixture { " uint64_t enter, exit;\n" " uint64_t events;\n" " per_state_info() : enter(0), exit(0), events(0) {}\n" - "};", nullptr, false, false); + "};", true, false, false); ASSERT_EQUALS("", errout_str()); // #6664 check("void foo() {\n" " (beat < 100) ? (void)0 : exit(0);\n" " bar();\n" - "}", nullptr, false, false, false, &settings); + "}", true, false, false, false, &settings); ASSERT_EQUALS("", errout_str()); check("void foo() {\n" " (beat < 100) ? exit(0) : (void)0;\n" " bar();\n" - "}", nullptr, false, false, false, &settings); + "}", true, false, false, false, &settings); ASSERT_EQUALS("", errout_str()); // #8261 @@ -5279,7 +5275,7 @@ class TestOther : public TestFixture { TODO_ASSERT_THROW(check("void foo() {\n" " (beat < 100) ? (void)0 : throw(0);\n" " bar();\n" - "}", nullptr, false, false, false, &settings), InternalError); + "}", true, false, false, false, &settings), InternalError); //ASSERT_EQUALS("", errout_str()); check("int foo() {\n" @@ -5718,7 +5714,7 @@ class TestOther : public TestFixture { " b = 300\n" " };\n" "};\n" - "const int DFLT_TIMEOUT = A::b % 1000000 ;\n", nullptr, false, false); + "const int DFLT_TIMEOUT = A::b % 1000000 ;\n", true, false, false); ASSERT_EQUALS("", errout_str()); } @@ -5843,10 +5839,10 @@ class TestOther : public TestFixture { " do_something();\n" "}\n"; - check(code, "test.cpp"); + check(code, true); ASSERT_EQUALS("[test.cpp:7]: (style) Instance of 'cb_watch_bool' object is destroyed immediately.\n", errout_str()); - check(code, "test.c"); + check(code, false); ASSERT_EQUALS("", errout_str()); // Ticket #2639 @@ -5888,7 +5884,7 @@ class TestOther : public TestFixture { " do_something();\n" "}\n"; - check(code, "test.cpp"); + check(code, true); ASSERT_EQUALS("", errout_str()); } @@ -5901,7 +5897,7 @@ class TestOther : public TestFixture { " }\n" " Foo(char x, int y) { }\n" "};\n"; - check(code, "test.cpp"); + check(code, true); ASSERT_EQUALS("[test.cpp:4]: (style) Instance of 'Foo' object is destroyed immediately.\n", errout_str()); } @@ -5916,7 +5912,7 @@ class TestOther : public TestFixture { " int{ i };\n" " int{ g() };\n" // don't warn " g();\n" - "}\n", "test.cpp"); + "}\n", true); ASSERT_EQUALS("[test.cpp:3]: (style) Instance of 'int' object is destroyed immediately.\n" "[test.cpp:4]: (style) Instance of 'int' object is destroyed immediately.\n" "[test.cpp:6]: (style) Instance of 'int' object is destroyed immediately.\n" @@ -5926,19 +5922,19 @@ class TestOther : public TestFixture { check("void f(int j) {\n" " for (; bool(j); ) {}\n" - "}\n", "test.cpp"); + "}\n", true); ASSERT_EQUALS("", errout_str()); check("void g() {\n" " float (f);\n" " float (*p);\n" - "}\n", "test.cpp"); + "}\n", true); ASSERT_EQUALS("", errout_str()); check("int f(int i) {\n" " void();\n" " return i;\n" - "}\n", "test.cpp"); + "}\n", true); ASSERT_EQUALS("", errout_str()); } @@ -5951,7 +5947,7 @@ class TestOther : public TestFixture { "int f() {\n" " M::N::S();\n" " return 0;\n" - "}\n", "test.cpp"); + "}\n", true); ASSERT_EQUALS("[test.cpp:7]: (style) Instance of 'M::N::S' object is destroyed immediately.\n", errout_str()); check("void f() {\n" // #10057 @@ -5959,7 +5955,7 @@ class TestOther : public TestFixture { " std::string{ \"abc\" };\n" " std::pair(1, 2);\n" " (void)0;\n" - "}\n", "test.cpp"); + "}\n", true); ASSERT_EQUALS("[test.cpp:2]: (style) Instance of 'std::string' object is destroyed immediately.\n" "[test.cpp:3]: (style) Instance of 'std::string' object is destroyed immediately.\n" "[test.cpp:4]: (style) Instance of 'std::pair' object is destroyed immediately.\n", @@ -5976,7 +5972,7 @@ class TestOther : public TestFixture { " std::scoped_lock(m);\n" " }\n" " std::mutex m;\n" - "}\n", "test.cpp"); + "}\n", true); ASSERT_EQUALS("[test.cpp:3]: (style) Instance of 'std::lock_guard' object is destroyed immediately.\n" "[test.cpp:6]: (style) Instance of 'std::scoped_lock' object is destroyed immediately.\n" "[test.cpp:9]: (style) Instance of 'std::scoped_lock' object is destroyed immediately.\n", @@ -5985,7 +5981,7 @@ class TestOther : public TestFixture { check("struct S { int i; };\n" "namespace {\n" " S s() { return ::S{42}; }\n" - "}\n", "test.cpp"); + "}\n", true); ASSERT_EQUALS("", errout_str()); } @@ -5998,7 +5994,7 @@ class TestOther : public TestFixture { "void t0() { f() = {}; }\n" "void t1() { g() = {}; }\n" "void t2() { h() = {}; }\n" - "void t3() { *i() = {}; }\n", "test.cpp"); + "void t3() { *i() = {}; }\n", true); ASSERT_EQUALS("[test.cpp:6]: (style) Instance of 'S' object is destroyed immediately, assignment has no effect.\n", errout_str()); } @@ -6042,7 +6038,7 @@ class TestOther : public TestFixture { check("void f(char c) {\n" " printf(\"%i\", a + b ? 1 : 2);\n" - "}",nullptr,false,false); + "}",true,false,false); ASSERT_EQUALS("[test.cpp:2]: (style) Clarify calculation precedence for '+' and '?'.\n", errout_str()); check("void f() {\n" @@ -6236,7 +6232,7 @@ class TestOther : public TestFixture { " else\n" " ret = (unsigned char)value;\n" " return ret;\n" - "}", nullptr, false, false); + "}", true, false, false); ASSERT_EQUALS("", errout_str()); check("void f() {\n" @@ -6545,7 +6541,7 @@ class TestOther : public TestFixture { // make sure there are not "same expression" fp when there are different casts check("void f(long x) { if ((int32_t)x == (int64_t)x) {} }", - nullptr, // filename + true, // filename false, // inconclusive false, // runSimpleChecks false, // verbose @@ -6604,7 +6600,7 @@ class TestOther : public TestFixture { check("void f() {\n" " enum { Four = 4 };\n" " if (Four == 4) {}" - "}", nullptr, true, false); + "}", true, true, false); ASSERT_EQUALS("[test.cpp:3]: (style) The comparison 'Four == 4' is always true.\n", errout_str()); @@ -6624,7 +6620,7 @@ class TestOther : public TestFixture { " enum { FourInEnumOne = 4 };\n" " enum { FourInEnumTwo = 4 };\n" " if (FourInEnumOne == FourInEnumTwo) {}\n" - "}", nullptr, true, false); + "}", true, true, false); ASSERT_EQUALS("[test.cpp:4]: (style) The comparison 'FourInEnumOne == FourInEnumTwo' is always true because 'FourInEnumOne' and 'FourInEnumTwo' represent the same value.\n", errout_str()); @@ -6663,7 +6659,7 @@ class TestOther : public TestFixture { check("float f(float x) { return x-x; }"); // ticket #4485 (Inf) ASSERT_EQUALS("", errout_str()); - check("float f(float x) { return (X double)x == (X double)x; }", nullptr, false, false); + check("float f(float x) { return (X double)x == (X double)x; }", true, false, false); ASSERT_EQUALS("", errout_str()); check("struct X { float f; };\n" @@ -6737,7 +6733,7 @@ class TestOther : public TestFixture { check("void foo() {\n" " if ((mystrcmp(a, b) == 0) || (mystrcmp(a, b) == 0)) {}\n" - "}", "test.cpp", false, true, false, &settings); + "}", true, false, true, false, &settings); ASSERT_EQUALS("[test.cpp:2]: (style) Same expression on both sides of '||'.\n", errout_str()); check("void GetValue() { return rand(); }\n" @@ -6778,7 +6774,7 @@ class TestOther : public TestFixture { check("void f(A *src) {\n" " if (dynamic_cast(src) || dynamic_cast(src)) {}\n" - "}\n", "test.cpp", false, false); // don't run simplifications + "}\n", true, false, false); // don't run simplifications ASSERT_EQUALS("[test.cpp:2]: (style) Same expression on both sides of '||'.\n", errout_str()); // #5819 @@ -8083,9 +8079,9 @@ class TestOther : public TestFixture { const char code[] = "void foo(unsigned int x) {\n" " if (x < 0) {}\n" "}"; - check(code, nullptr, false, true, false); + check(code, true, false, true, false); ASSERT_EQUALS("[test.cpp:2]: (style) Checking if unsigned expression 'x' is less than zero.\n", errout_str()); - check(code, nullptr, false, true, true); + check(code, true, false, true, true); ASSERT_EQUALS("[test.cpp:2]: (style) Checking if unsigned expression 'x' is less than zero.\n", errout_str()); } @@ -8104,9 +8100,9 @@ class TestOther : public TestFixture { " int y = 0;\n" " if (x < y) {}\n" "}"; - check(code, nullptr, false, true, false); + check(code, true, false, true, false); ASSERT_EQUALS("[test.cpp:3]: (style) Checking if unsigned expression 'x' is less than zero.\n", errout_str()); - check(code, nullptr, false, true, true); + check(code, true, false, true, true); ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:3]: (style) Checking if unsigned expression 'x' is less than zero.\n", errout_str()); } check("void foo(unsigned x) {\n" @@ -8265,9 +8261,9 @@ class TestOther : public TestFixture { " if (x <= n);\n" "}\n" "foo<0>();"; - check(code, nullptr, false); + check(code, true, false); ASSERT_EQUALS("", errout_str()); - check(code, nullptr, true); + check(code, true, true); ASSERT_EQUALS("", errout_str()); } @@ -8329,9 +8325,9 @@ class TestOther : public TestFixture { " int y = 0;\n" " if (x >= y) {}\n" "}"; - check(code, nullptr, false, true, false); + check(code, true, false, true, false); ASSERT_EQUALS("[test.cpp:3]: (style) A pointer can not be negative so it is either pointless or an error to check if it is not.\n", errout_str()); - check(code, nullptr, false, true, true); + check(code, true, false, true, true); ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:3]: (style) A pointer can not be negative so it is either pointless or an error to check if it is not.\n", errout_str()); } check("void foo(const int* x) {\n" @@ -8350,9 +8346,9 @@ class TestOther : public TestFixture { " if (x < y) {}\n" "}"; - check(code, nullptr, false, true, false); + check(code, true, false, true, false); ASSERT_EQUALS("[test.cpp:3]: (style) A pointer can not be negative so it is either pointless or an error to check if it is.\n", errout_str()); - check(code, nullptr, false, true, true); + check(code, true, false, true, true); ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:3]: (style) A pointer can not be negative so it is either pointless or an error to check if it is.\n", errout_str()); } @@ -8826,9 +8822,9 @@ class TestOther : public TestFixture { " tok->str(tok->strAt(2));\n" " }\n" "}"; - check(code5618, nullptr, true); + check(code5618, true, true); ASSERT_EQUALS("", errout_str()); - check(code5618, nullptr, false); + check(code5618, true, false); ASSERT_EQUALS("", errout_str()); // #5890 - crash: wesnoth desktop_util.cpp / unicode.hpp @@ -8848,7 +8844,7 @@ class TestOther : public TestFixture { " \n" "void foo() {\n" " const CD cd(CD::getOne());\n" - "}", nullptr, true); + "}", true, true); ASSERT_EQUALS("", errout_str()); check("struct S {\n" // #10545 @@ -8861,7 +8857,7 @@ class TestOther : public TestFixture { " if (i != 0)\n" " return old;\n" " return {};\n" - "}", nullptr, /*inconclusive*/ true); + "}", true, /*inconclusive*/ true); ASSERT_EQUALS("", errout_str()); check("struct X { int x; };\n" // #10191 @@ -8879,7 +8875,7 @@ class TestOther : public TestFixture { " modify();\n" " return x.x;\n" " }\n" - "};\n", nullptr, /*inconclusive*/ true); + "};\n", true, /*inconclusive*/ true); ASSERT_EQUALS("", errout_str()); // #10704 @@ -9595,7 +9591,7 @@ class TestOther : public TestFixture { " }\n" " catch (const uno::Exception&) {\n" " }\n" - "}", "test.cpp", true); + "}", true, true); ASSERT_EQUALS("", errout_str()); check("void ConvertBitmapData(sal_uInt16 nDestBits) {\n" @@ -9604,7 +9600,7 @@ class TestOther : public TestFixture { " BitmapBuffer aDstBuf;\n" " aSrcBuf.mnBitCount = nDestBits;\n" " bConverted = ::ImplFastBitmapConversion( aDstBuf, aSrcBuf, aTwoRects );\n" - "}", "test.c"); + "}", false); ASSERT_EQUALS("[test.c:3] -> [test.c:5]: (style) Variable 'aSrcBuf.mnBitCount' is reassigned a value before the old one has been used.\n", errout_str()); check("void ConvertBitmapData(sal_uInt16 nDestBits) {\n" " BitmapBuffer aSrcBuf;\n" @@ -10165,32 +10161,32 @@ class TestOther : public TestFixture { " if (a < 0)\n" " return a++,\n" " do_something();\n" - "}", nullptr, false, false); + "}", true, false, false); TODO_ASSERT_EQUALS("[test.cpp:3]: (style) Comma is used in return statement. The comma can easily be misread as a ';'.\n", "", errout_str()); check("int fun(int a) {\n" " if (a < 0)\n" " return a++, do_something();\n" - "}", nullptr, false, false); + "}", true, false, false); ASSERT_EQUALS("", errout_str()); check("int fun(int a) {\n" " if (a < 0)\n" " return a+5,\n" " do_something();\n" - "}", nullptr, false, false); + "}", true, false, false); TODO_ASSERT_EQUALS("[test.cpp:3]: (style) Comma is used in return statement. The comma can easily be misread as a ';'.\n", "", errout_str()); check("int fun(int a) {\n" " if (a < 0)\n" " return a+5, do_something();\n" - "}", nullptr, false, false); + "}", true, false, false); ASSERT_EQUALS("", errout_str()); check("int fun(int a) {\n" " if (a < 0)\n" " return c::b;\n" - "}", nullptr, false, false); + "}", true, false, false); ASSERT_EQUALS("", errout_str()); // #4943 take care of C++11 initializer lists @@ -10201,7 +10197,7 @@ class TestOther : public TestFixture { " { \"2\" },\n" " { \"3\" }\n" " };\n" - "}", nullptr, false, false); + "}", true, false, false); ASSERT_EQUALS("", errout_str()); } @@ -10217,7 +10213,7 @@ class TestOther : public TestFixture { " explicit B(A a) : a(std::move(a)) {}\n" " void Init(A _a) { a = std::move(_a); }\n" " A a;" - "};", nullptr, false, true); + "};", true, false, true); ASSERT_EQUALS("", errout_str()); check("struct A\n" @@ -10230,7 +10226,7 @@ class TestOther : public TestFixture { " explicit B(A a) : a{std::move(a)} {}\n" " void Init(A _a) { a = std::move(_a); }\n" " A a;" - "};", nullptr, false, true); + "};", true, false, true); ASSERT_EQUALS("", errout_str()); check("struct A\n" @@ -10244,7 +10240,7 @@ class TestOther : public TestFixture { " void Init(A _a) { a = std::move(_a); }\n" " A a;" " A a2;" - "};", nullptr, false, true); + "};", true, false, true); ASSERT_EQUALS("", errout_str()); check("struct A\n" @@ -10258,7 +10254,7 @@ class TestOther : public TestFixture { " void Init(A _a) { a = std::move(_a); }\n" " A a;" " A a2;" - "};", nullptr, false, true); + "};", true, false, true); ASSERT_EQUALS("[test.cpp:8]: (performance) Function parameter 'a2' should be passed by const reference.\n", errout_str()); check("struct A\n" @@ -10272,7 +10268,7 @@ class TestOther : public TestFixture { " void Init(A _a) { a = std::move(_a); }\n" " A a;" " A a2;" - "};", nullptr, false, true); + "};", true, false, true); ASSERT_EQUALS("[test.cpp:8]: (performance) Function parameter 'a2' should be passed by const reference.\n", errout_str()); check("std::map m;\n" // #10817 @@ -10335,12 +10331,12 @@ class TestOther : public TestFixture { void redundantPointerOp() { check("int *f(int *x) {\n" " return &*x;\n" - "}\n", nullptr, true); + "}\n", true, true); ASSERT_EQUALS("[test.cpp:2]: (style) Redundant pointer operation on 'x' - it's already a pointer.\n", errout_str()); check("int *f(int *y) {\n" " return &(*y);\n" - "}\n", nullptr, true); + "}\n", true, true); ASSERT_EQUALS("[test.cpp:2]: (style) Redundant pointer operation on 'y' - it's already a pointer.\n", errout_str()); check("int f() {\n" // #10991 @@ -10348,18 +10344,18 @@ class TestOther : public TestFixture { " int result1 = *(&value);\n" " int result2 = *&value;\n" " return result1 + result2;\n" - "}\n", nullptr, true); + "}\n", true, true); ASSERT_EQUALS("[test.cpp:3]: (style) Redundant pointer operation on 'value' - it's already a variable.\n" "[test.cpp:4]: (style) Redundant pointer operation on 'value' - it's already a variable.\n", errout_str()); check("void f(int& a, int b) {\n" " *(&a) = b;\n" - "}\n", nullptr, true); + "}\n", true, true); ASSERT_EQUALS("[test.cpp:2]: (style) Redundant pointer operation on 'a' - it's already a variable.\n", errout_str()); - check("void f(int**& p) {}\n", nullptr, true); + check("void f(int**& p) {}\n", true, true); ASSERT_EQUALS("", errout_str()); checkP("#define RESTORE(ORIG, COPY) { *ORIG = *COPY; }\n" @@ -10371,38 +10367,38 @@ class TestOther : public TestFixture { // no warning for bitwise AND check("void f(const int *b) {\n" " int x = 0x20 & *b;\n" - "}\n", nullptr, true); + "}\n", true, true); ASSERT_EQUALS("", errout_str()); // No message for double pointers to structs check("void f(struct foo **my_struct) {\n" " char **pass_to_func = &(*my_struct)->buf;\n" - "}\n", nullptr, true); + "}\n", true, true); ASSERT_EQUALS("", errout_str()); // another double pointer to struct - with an array check("void f(struct foo **my_struct) {\n" " char **pass_to_func = &(*my_struct)->buf[10];\n" - "}\n", nullptr, true); + "}\n", true, true); ASSERT_EQUALS("", errout_str()); // double pointer to array check("void f(char **ptr) {\n" " int *x = &(*ptr)[10];\n" - "}\n", nullptr, true); + "}\n", true, true); ASSERT_EQUALS("[test.cpp:2]: (style) Variable 'x' can be declared as pointer to const\n", errout_str()); // function calls check("void f(Mutex *mut) {\n" " pthread_mutex_lock(&*mut);\n" - "}\n", nullptr, false); + "}\n", true, false); ASSERT_EQUALS("[test.cpp:2]: (style) Redundant pointer operation on 'mut' - it's already a pointer.\n", errout_str()); // make sure we got the AST match for "(" right check("void f(char *ptr) {\n" " if (&*ptr == NULL)\n" " return;\n" - "}\n", nullptr, true); + "}\n", true, true); ASSERT_EQUALS("[test.cpp:2]: (style) Redundant pointer operation on 'ptr' - it's already a pointer.\n", errout_str()); // no warning for macros @@ -10423,7 +10419,7 @@ class TestOther : public TestFixture { void test_isSameExpression() { // see #5738 check("bool isInUnoIncludeFile(StringRef name) {" " return name.startswith(SRCDIR \"/com/\") || name.startswith(SRCDIR \"/uno/\");\n" - "};", "test.cpp", false); + "};", true, false); ASSERT_EQUALS("", errout_str()); } @@ -10742,24 +10738,24 @@ class TestOther : public TestFixture { check("void f() {\n" " int x = dostuff();\n" " return x + x++;\n" - "}", "test.c"); + "}", false); ASSERT_EQUALS("[test.c:3]: (error) Expression 'x+x++' depends on order of evaluation of side effects\n", errout_str()); // #7226 check("long int f1(const char *exp) {\n" " return strtol(++exp, (char **)&exp, 10);\n" - "}", "test.c"); + "}", false); ASSERT_EQUALS("", errout_str()); check("long int f1(const char *exp) {\n" " return dostuff(++exp, exp, 10);\n" - "}", "test.c"); + "}", false); ASSERT_EQUALS("[test.c:2]: (error) Expression '++exp,exp' depends on order of evaluation of side effects\n", errout_str()); check("void f() {\n" " int a;\n" " while (a=x(), a==123) {}\n" - "}", "test.c"); + "}", false); ASSERT_EQUALS("", errout_str()); // # 8717 @@ -10767,19 +10763,19 @@ class TestOther : public TestFixture { " char **local_argv = safe_malloc(sizeof (*local_argv));\n" " int local_argc = 0;\n" " local_argv[local_argc++] = argv[0];\n" - "}\n", "test.c"); + "}\n", false); ASSERT_EQUALS("", errout_str()); check("void f() {\n" " int x = 0;\n" " return 0 + x++;\n" - "}\n", "test.c"); + "}\n", false); ASSERT_EQUALS("", errout_str()); check("void f(int x, int y) {\n" " int a[10];\n" " a[x+y] = a[y+x]++;;\n" - "}\n", "test.c"); + "}\n", false); ASSERT_EQUALS("[test.c:3]: (error) Expression 'a[x+y]=a[y+x]++' depends on order of evaluation of side effects\n", errout_str()); } @@ -10787,7 +10783,7 @@ class TestOther : public TestFixture { // self assignment check("void f() {\n" " int x = x = y + 1;\n" - "}", "test.c"); + "}", false); ASSERT_EQUALS( "[test.c:2]: (style) Redundant assignment of 'x' to itself.\n" "[test.c:2]: (style) Redundant assignment of 'x' to itself.\n", // duplicate @@ -10807,13 +10803,13 @@ class TestOther : public TestFixture { // FP check("void f(int id) {\n" " id = dostuff(id += 42);\n" - "}", "test.c"); + "}", false); ASSERT_EQUALS("", errout_str()); // FN check("void f(int id) {\n" " id = id + dostuff(id += 42);\n" - "}", "test.c"); + "}", false); TODO_ASSERT_EQUALS("error", "", errout_str()); } @@ -10821,19 +10817,19 @@ class TestOther : public TestFixture { check("int f(void) {\n" " int t;\n" " return (unsigned char)(t=1,t^c);\n" - "}", "test.c"); + "}", false); ASSERT_EQUALS("", errout_str()); check("void f(void) {\n" " int t;\n" " dostuff(t=1,t^c);\n" - "}", "test.c"); + "}", false); ASSERT_EQUALS("[test.c:3]: (error) Expression 't=1,t^c' depends on order of evaluation of side effects\n", errout_str()); check("void f(void) {\n" " int t;\n" " dostuff((t=1,t),2);\n" - "}", "test.c"); + "}", false); ASSERT_EQUALS("", errout_str()); // #8230 @@ -10841,28 +10837,28 @@ class TestOther : public TestFixture { " do\n" " ;\n" " while (++fp, (*fp) <= 0177);\n" - "}\n", "test.c"); + "}\n", false); ASSERT_EQUALS("", errout_str()); check("void hprf(const char* fp) {\n" " do\n" " ;\n" " while (i++, ++fp, (*fp) <= 0177);\n" - "}\n", "test.c"); + "}\n", false); ASSERT_EQUALS("", errout_str()); check("void f(const char* fp) {\n" " do\n" " ;\n" " while (f(++fp, (*fp) <= 7));\n" - "}\n", "test.c"); + "}\n", false); ASSERT_EQUALS("[test.c:4]: (error) Expression '++fp,(*fp)<=7' depends on order of evaluation of side effects\n", errout_str()); } void testEvaluationOrderSizeof() { check("void f(char *buf) {\n" " dostuff(buf++, sizeof(*buf));" - "}", "test.c"); + "}", false); ASSERT_EQUALS("", errout_str()); } @@ -10881,7 +10877,7 @@ class TestOther : public TestFixture { " if (0 > d.n) {\n" " return;\n" " }\n" - "}", "test.c"); + "}", false); ASSERT_EQUALS("[test.c:8]: (style) Checking if unsigned expression 'd.n' is less than zero.\n" "[test.c:12]: (style) Checking if unsigned expression 'd.n' is less than zero.\n", errout_str()); @@ -11278,7 +11274,7 @@ class TestOther : public TestFixture { "void Fred::func2(int c, int b, int a) { }\n" "void Fred::func3(int c, int b, int a) { }\n" "void Fred::func4(int c, int b, int a) { }\n", - nullptr, false); + true, false); ASSERT_EQUALS("[test.cpp:3] -> [test.cpp:4]: (warning) Function 'func2' argument order different: declaration 'a, b, c' definition 'c, b, a'\n" "[test.cpp:5] -> [test.cpp:6]: (warning) Function 'func3' argument order different: declaration ', b, c' definition 'c, b, a'\n" "[test.cpp:9] -> [test.cpp:14]: (warning) Function 'func2' argument order different: declaration 'a, b, c' definition 'c, b, a'\n" @@ -11382,7 +11378,7 @@ class TestOther : public TestFixture { "static int f(void) {\n" " int a;\n" " return 0;\n" - "}\n", "test.c"); + "}\n", false); ASSERT_EQUALS("[test.c:1] -> [test.c:4]: (style) Local variable 'a' shadows outer variable\n", errout_str()); check("int f() {\n" // #12591 diff --git a/test/testpostfixoperator.cpp b/test/testpostfixoperator.cpp index 31588a31f81b..56a2b479d6be 100644 --- a/test/testpostfixoperator.cpp +++ b/test/testpostfixoperator.cpp @@ -16,14 +16,11 @@ * along with this program. If not, see . */ - #include "checkpostfixoperator.h" #include "errortypes.h" -#include "settings.h" #include "fixture.h" -#include "tokenize.h" - -#include +#include "helpers.h" +#include "settings.h" class TestPostfixOperator : public TestFixture { public: @@ -35,9 +32,8 @@ class TestPostfixOperator : public TestFixture { #define check(code) check_(code, __FILE__, __LINE__) void check_(const char code[], const char* file, int line) { // Tokenize.. - Tokenizer tokenizer(settings, this); - std::istringstream istr(code); - ASSERT_LOC(tokenizer.tokenize(istr, "test.cpp"), file, line); + SimpleTokenizer tokenizer(settings, *this); + ASSERT_LOC(tokenizer.tokenize(code), file, line); // Check for postfix operators.. CheckPostfixOperator checkPostfixOperator(&tokenizer, &settings, this); diff --git a/test/testsimplifytemplate.cpp b/test/testsimplifytemplate.cpp index bc7ee1095fc3..1be4c3619509 100644 --- a/test/testsimplifytemplate.cpp +++ b/test/testsimplifytemplate.cpp @@ -16,12 +16,12 @@ * along with this program. If not, see . */ - #include "errortypes.h" +#include "fixture.h" +#include "helpers.h" #include "platform.h" #include "settings.h" #include "templatesimplifier.h" -#include "fixture.h" #include "token.h" #include "tokenize.h" #include "tokenlist.h" @@ -31,7 +31,6 @@ #include #include - class TestSimplifyTemplate : public TestFixture { public: TestSimplifyTemplate() : TestFixture("TestSimplifyTemplate") {} @@ -311,10 +310,9 @@ class TestSimplifyTemplate : public TestFixture { #define tok(...) tok_(__FILE__, __LINE__, __VA_ARGS__) std::string tok_(const char* file, int line, const char code[], bool debugwarnings = false, Platform::Type type = Platform::Type::Native) { const Settings settings1 = settingsBuilder(settings).library("std.cfg").debugwarnings(debugwarnings).platform(type).build(); - Tokenizer tokenizer(settings1, this); + SimpleTokenizer tokenizer(settings1, *this); - std::istringstream istr(code); - ASSERT_LOC(tokenizer.tokenize(istr, "test.cpp"), file, line); + ASSERT_LOC(tokenizer.tokenize(code), file, line); return tokenizer.tokens()->stringifyList(nullptr, true); } @@ -5777,10 +5775,9 @@ class TestSimplifyTemplate : public TestFixture { #define instantiateMatch(code, numberOfArguments, patternAfter) instantiateMatch_(code, numberOfArguments, patternAfter, __FILE__, __LINE__) bool instantiateMatch_(const char code[], const std::size_t numberOfArguments, const char patternAfter[], const char* file, int line) { - Tokenizer tokenizer(settings, this); + SimpleTokenizer tokenizer(settings, *this); - std::istringstream istr(code); - ASSERT_LOC(tokenizer.tokenize(istr, "test.cpp", ""), file, line); + ASSERT_LOC(tokenizer.tokenize(code), file, line); return (TemplateSimplifier::instantiateMatch)(tokenizer.tokens(), numberOfArguments, false, patternAfter); } diff --git a/test/testsimplifytokens.cpp b/test/testsimplifytokens.cpp index a4fc279427ff..3f4aff098859 100644 --- a/test/testsimplifytokens.cpp +++ b/test/testsimplifytokens.cpp @@ -166,33 +166,22 @@ class TestSimplifyTokens : public TestFixture { } #define tok(...) tok_(__FILE__, __LINE__, __VA_ARGS__) - std::string tok_(const char* file, int line, const char code[], Platform::Type type = Platform::Type::Native) { + std::string tok_(const char* file, int line, const char code[], bool cpp = true, Platform::Type type = Platform::Type::Native) { const Settings settings = settingsBuilder(settings0).platform(type).build(); - Tokenizer tokenizer(settings, this); + SimpleTokenizer tokenizer(settings, *this); - std::istringstream istr(code); - ASSERT_LOC(tokenizer.tokenize(istr, "test.cpp"), file, line); - - return tokenizer.tokens()->stringifyList(nullptr, false); - } - - std::string tok_(const char* file, int line, const char code[], const char filename[]) { - Tokenizer tokenizer(settings0, this); - - std::istringstream istr(code); - ASSERT_LOC(tokenizer.tokenize(istr, filename), file, line); + ASSERT_LOC(tokenizer.tokenize(code, cpp), file, line); return tokenizer.tokens()->stringifyList(nullptr, false); } #define tokenizeAndStringify(...) tokenizeAndStringify_(__FILE__, __LINE__, __VA_ARGS__) - std::string tokenizeAndStringify_(const char* file, int linenr, const char code[], bool expand = true, Platform::Type platform = Platform::Type::Native, const char* filename = "test.cpp", bool cpp11 = true) { + std::string tokenizeAndStringify_(const char* file, int linenr, const char code[], bool expand = true, Platform::Type platform = Platform::Type::Native, bool cpp = true, bool cpp11 = true) { const Settings settings = settingsBuilder(settings1).debugwarnings().platform(platform).cpp(cpp11 ? Standards::CPP11 : Standards::CPP03).build(); // tokenize.. - Tokenizer tokenizer(settings, this); - std::istringstream istr(code); - ASSERT_LOC(tokenizer.tokenize(istr, filename), file, linenr); + SimpleTokenizer tokenizer(settings, *this); + ASSERT_LOC(tokenizer.tokenize(code, cpp), file, linenr); if (tokenizer.tokens()) return tokenizer.tokens()->stringifyList(false, expand, false, true, false, nullptr, nullptr); @@ -200,10 +189,9 @@ class TestSimplifyTokens : public TestFixture { } #define tokenizeDebugListing(...) tokenizeDebugListing_(__FILE__, __LINE__, __VA_ARGS__) - std::string tokenizeDebugListing_(const char* file, int line, const char code[], const char filename[] = "test.cpp") { - Tokenizer tokenizer(settings0, this); - std::istringstream istr(code); - ASSERT_LOC(tokenizer.tokenize(istr, filename), file, line); + std::string tokenizeDebugListing_(const char* file, int line, const char code[], bool cpp = true) { + SimpleTokenizer tokenizer(settings0, *this); + ASSERT_LOC(tokenizer.tokenize(code, cpp), file, line); // result.. return tokenizer.tokens()->stringifyList(true); @@ -231,10 +219,10 @@ class TestSimplifyTokens : public TestFixture { ASSERT_EQUALS(tok(code2), tok(code1)); const char code3[] = "x = L\"1\" TEXT(\"2\") L\"3\";"; - ASSERT_EQUALS("x = L\"123\" ;", tok(code3, Platform::Type::Win64)); + ASSERT_EQUALS("x = L\"123\" ;", tok(code3, true, Platform::Type::Win64)); const char code4[] = "x = TEXT(\"1\") L\"2\";"; - ASSERT_EQUALS("x = L\"1\" L\"2\" ;", tok(code4, Platform::Type::Win64)); + ASSERT_EQUALS("x = L\"1\" L\"2\" ;", tok(code4, true, Platform::Type::Win64)); } void combine_wstrings() { @@ -242,9 +230,8 @@ class TestSimplifyTokens : public TestFixture { const char expected[] = "a = L\"hello world\" ;"; - Tokenizer tokenizer(settings0, this); - std::istringstream istr(code); - ASSERT(tokenizer.tokenize(istr, "test.cpp")); + SimpleTokenizer tokenizer(settings0, *this); + ASSERT(tokenizer.tokenize(code)); ASSERT_EQUALS(expected, tokenizer.tokens()->stringifyList(nullptr, false)); } @@ -254,9 +241,8 @@ class TestSimplifyTokens : public TestFixture { const char expected[] = "abcd = u\"abcd\" ;"; - Tokenizer tokenizer(settings0, this); - std::istringstream istr(code); - ASSERT(tokenizer.tokenize(istr, "test.cpp")); + SimpleTokenizer tokenizer(settings0, *this); + ASSERT(tokenizer.tokenize(code)); ASSERT_EQUALS(expected, tokenizer.tokens()->stringifyList(nullptr, false)); } @@ -266,9 +252,8 @@ class TestSimplifyTokens : public TestFixture { const char expected[] = "abcd = U\"abcd\" ;"; - Tokenizer tokenizer(settings0, this); - std::istringstream istr(code); - ASSERT(tokenizer.tokenize(istr, "test.cpp")); + SimpleTokenizer tokenizer(settings0, *this); + ASSERT(tokenizer.tokenize(code)); ASSERT_EQUALS(expected, tokenizer.tokens()->stringifyList(nullptr, false)); } @@ -278,9 +263,8 @@ class TestSimplifyTokens : public TestFixture { const char expected[] = "abcd = u8\"abcd\" ;"; - Tokenizer tokenizer(settings0, this); - std::istringstream istr(code); - ASSERT(tokenizer.tokenize(istr, "test.cpp")); + SimpleTokenizer tokenizer(settings0, *this); + ASSERT(tokenizer.tokenize(code)); ASSERT_EQUALS(expected, tokenizer.tokens()->stringifyList(nullptr, false)); } @@ -290,9 +274,8 @@ class TestSimplifyTokens : public TestFixture { const char expected[] = "abcdef = L\"abcdef\" ;"; - Tokenizer tokenizer(settings0, this); - std::istringstream istr(code); - ASSERT(tokenizer.tokenize(istr, "test.cpp")); + SimpleTokenizer tokenizer(settings0, *this); + ASSERT(tokenizer.tokenize(code)); ASSERT_EQUALS(expected, tokenizer.tokens()->stringifyList(nullptr, false)); } @@ -609,71 +592,71 @@ class TestSimplifyTokens : public TestFixture { } void not1() { - ASSERT_EQUALS("void f ( ) { if ( ! p ) { ; } }", tok("void f() { if (not p); }", "test.c")); - ASSERT_EQUALS("void f ( ) { if ( p && ! q ) { ; } }", tok("void f() { if (p && not q); }", "test.c")); - ASSERT_EQUALS("void f ( ) { a = ! ( p && q ) ; }", tok("void f() { a = not(p && q); }", "test.c")); + ASSERT_EQUALS("void f ( ) { if ( ! p ) { ; } }", tok("void f() { if (not p); }", false)); + ASSERT_EQUALS("void f ( ) { if ( p && ! q ) { ; } }", tok("void f() { if (p && not q); }", false)); + ASSERT_EQUALS("void f ( ) { a = ! ( p && q ) ; }", tok("void f() { a = not(p && q); }", false)); // Don't simplify 'not' or 'compl' if they are defined as a type; // in variable declaration and in function declaration/definition - ASSERT_EQUALS("struct not { int x ; } ;", tok("struct not { int x; };", "test.c")); - ASSERT_EQUALS("void f ( ) { not p ; compl c ; }", tok(" void f() { not p; compl c; }", "test.c")); - ASSERT_EQUALS("void foo ( not i ) ;", tok("void foo(not i);", "test.c")); - ASSERT_EQUALS("int foo ( not i ) { return g ( i ) ; }", tok("int foo(not i) { return g(i); }", "test.c")); + ASSERT_EQUALS("struct not { int x ; } ;", tok("struct not { int x; };", false)); + ASSERT_EQUALS("void f ( ) { not p ; compl c ; }", tok(" void f() { not p; compl c; }", false)); + ASSERT_EQUALS("void foo ( not i ) ;", tok("void foo(not i);", false)); + ASSERT_EQUALS("int foo ( not i ) { return g ( i ) ; }", tok("int foo(not i) { return g(i); }", false)); } void and1() { ASSERT_EQUALS("void f ( ) { if ( p && q ) { ; } }", - tok("void f() { if (p and q) ; }", "test.c")); + tok("void f() { if (p and q) ; }", false)); ASSERT_EQUALS("void f ( ) { if ( foo ( ) && q ) { ; } }", - tok("void f() { if (foo() and q) ; }", "test.c")); + tok("void f() { if (foo() and q) ; }", false)); ASSERT_EQUALS("void f ( ) { if ( foo ( ) && bar ( ) ) { ; } }", - tok("void f() { if (foo() and bar()) ; }", "test.c")); + tok("void f() { if (foo() and bar()) ; }", false)); ASSERT_EQUALS("void f ( ) { if ( p && bar ( ) ) { ; } }", - tok("void f() { if (p and bar()) ; }", "test.c")); + tok("void f() { if (p and bar()) ; }", false)); ASSERT_EQUALS("void f ( ) { if ( p && ! q ) { ; } }", - tok("void f() { if (p and not q) ; }", "test.c")); + tok("void f() { if (p and not q) ; }", false)); ASSERT_EQUALS("void f ( ) { r = a && b ; }", - tok("void f() { r = a and b; }", "test.c")); + tok("void f() { r = a and b; }", false)); ASSERT_EQUALS("void f ( ) { r = ( a || b ) && ( c || d ) ; }", - tok("void f() { r = (a || b) and (c || d); }", "test.c")); + tok("void f() { r = (a || b) and (c || d); }", false)); ASSERT_EQUALS("void f ( ) { if ( test1 [ i ] == 'A' && test2 [ i ] == 'C' ) { } }", - tok("void f() { if (test1[i] == 'A' and test2[i] == 'C') {} }", "test.c")); + tok("void f() { if (test1[i] == 'A' and test2[i] == 'C') {} }", false)); } void or1() { ASSERT_EQUALS("void f ( ) { if ( p || q ) { ; } }", - tok("void f() { if (p or q) ; }", "test.c")); + tok("void f() { if (p or q) ; }", false)); ASSERT_EQUALS("void f ( ) { if ( foo ( ) || q ) { ; } }", - tok("void f() { if (foo() or q) ; }", "test.c")); + tok("void f() { if (foo() or q) ; }", false)); ASSERT_EQUALS("void f ( ) { if ( foo ( ) || bar ( ) ) { ; } }", - tok("void f() { if (foo() or bar()) ; }", "test.c")); + tok("void f() { if (foo() or bar()) ; }", false)); ASSERT_EQUALS("void f ( ) { if ( p || bar ( ) ) { ; } }", - tok("void f() { if (p or bar()) ; }", "test.c")); + tok("void f() { if (p or bar()) ; }", false)); ASSERT_EQUALS("void f ( ) { if ( p || ! q ) { ; } }", - tok("void f() { if (p or not q) ; }", "test.c")); + tok("void f() { if (p or not q) ; }", false)); ASSERT_EQUALS("void f ( ) { r = a || b ; }", - tok("void f() { r = a or b; }", "test.c")); + tok("void f() { r = a or b; }", false)); ASSERT_EQUALS("void f ( ) { r = ( a && b ) || ( c && d ) ; }", - tok("void f() { r = (a && b) or (c && d); }", "test.c")); + tok("void f() { r = (a && b) or (c && d); }", false)); } void cAlternativeTokens() { ASSERT_EQUALS("void f ( ) { err |= ( ( r & s ) && ! t ) ; }", - tok("void f() { err or_eq ((r bitand s) and not t); }", "test.c")); + tok("void f() { err or_eq ((r bitand s) and not t); }", false)); ASSERT_EQUALS("void f ( ) const { r = f ( a [ 4 ] | 0x0F , ~ c , ! d ) ; }", - tok("void f() const { r = f(a[4] bitor 0x0F, compl c, not d) ; }", "test.c")); + tok("void f() const { r = f(a[4] bitor 0x0F, compl c, not d) ; }", false)); } @@ -1297,20 +1280,20 @@ class TestSimplifyTokens : public TestFixture { ASSERT_EQUALS("constexpr int foo ( ) { }", tok("consteval int foo() { }")); ASSERT_EQUALS("int x ; x = 0 ;", tok("constinit int x = 0;")); ASSERT_EQUALS("void f ( ) { int final [ 10 ] ; }", tok("void f() { int final[10]; }")); - ASSERT_EQUALS("int * p ;", tok("int * __restrict p;", "test.c")); - ASSERT_EQUALS("int * * p ;", tok("int * __restrict__ * p;", "test.c")); - ASSERT_EQUALS("void foo ( float * a , float * b ) ;", tok("void foo(float * __restrict__ a, float * __restrict__ b);", "test.c")); - ASSERT_EQUALS("int * p ;", tok("int * restrict p;", "test.c")); - ASSERT_EQUALS("int * * p ;", tok("int * restrict * p;", "test.c")); - ASSERT_EQUALS("void foo ( float * a , float * b ) ;", tok("void foo(float * restrict a, float * restrict b);", "test.c")); + ASSERT_EQUALS("int * p ;", tok("int * __restrict p;", false)); + ASSERT_EQUALS("int * * p ;", tok("int * __restrict__ * p;", false)); + ASSERT_EQUALS("void foo ( float * a , float * b ) ;", tok("void foo(float * __restrict__ a, float * __restrict__ b);", false)); + ASSERT_EQUALS("int * p ;", tok("int * restrict p;", false)); + ASSERT_EQUALS("int * * p ;", tok("int * restrict * p;", false)); + ASSERT_EQUALS("void foo ( float * a , float * b ) ;", tok("void foo(float * restrict a, float * restrict b);", false)); ASSERT_EQUALS("void foo ( int restrict ) ;", tok("void foo(int restrict);")); - ASSERT_EQUALS("int * p ;", tok("typedef int * __restrict__ rint; rint p;", "test.c")); + ASSERT_EQUALS("int * p ;", tok("typedef int * __restrict__ rint; rint p;", false)); // don't remove struct members: ASSERT_EQUALS("a = b . _inline ;", tok("a = b._inline;")); - ASSERT_EQUALS("int i ; i = 0 ;", tok("auto int i = 0;", "test.c")); - ASSERT_EQUALS("auto i ; i = 0 ;", tok("auto i = 0;", "test.cpp")); + ASSERT_EQUALS("int i ; i = 0 ;", tok("auto int i = 0;", false)); + ASSERT_EQUALS("auto i ; i = 0 ;", tok("auto i = 0;", true)); } void simplifyCallingConvention() { @@ -1330,12 +1313,12 @@ class TestSimplifyTokens : public TestFixture { ASSERT_EQUALS("int f ( ) ;", tok("int __far __syscall f();")); ASSERT_EQUALS("int f ( ) ;", tok("int __far __pascal f();")); ASSERT_EQUALS("int f ( ) ;", tok("int __far __fortran f();")); - ASSERT_EQUALS("int f ( ) ;", tok("int WINAPI f();", Platform::Type::Win32A)); - ASSERT_EQUALS("int f ( ) ;", tok("int APIENTRY f();", Platform::Type::Win32A)); - ASSERT_EQUALS("int f ( ) ;", tok("int CALLBACK f();", Platform::Type::Win32A)); + ASSERT_EQUALS("int f ( ) ;", tok("int WINAPI f();", true, Platform::Type::Win32A)); + ASSERT_EQUALS("int f ( ) ;", tok("int APIENTRY f();", true, Platform::Type::Win32A)); + ASSERT_EQUALS("int f ( ) ;", tok("int CALLBACK f();", true, Platform::Type::Win32A)); // don't simplify Microsoft defines in unix code (#7554) - ASSERT_EQUALS("enum E { CALLBACK } ;", tok("enum E { CALLBACK } ;", Platform::Type::Unix32)); + ASSERT_EQUALS("enum E { CALLBACK } ;", tok("enum E { CALLBACK } ;", true, Platform::Type::Unix32)); } void simplifyAttribute() { @@ -1531,9 +1514,8 @@ class TestSimplifyTokens : public TestFixture { #define simplifyKnownVariables(code) simplifyKnownVariables_(code, __FILE__, __LINE__) std::string simplifyKnownVariables_(const char code[], const char* file, int line) { - Tokenizer tokenizer(settings0, this); - std::istringstream istr(code); - ASSERT_LOC(tokenizer.tokenize(istr, "test.cpp"), file, line); + SimpleTokenizer tokenizer(settings0, *this); + ASSERT_LOC(tokenizer.tokenize(code), file, line); return tokenizer.tokens()->stringifyList(nullptr, false); } @@ -2074,7 +2056,7 @@ class TestSimplifyTokens : public TestFixture { "strcpy ( a , \"hello\" ) ;\n" "strcat ( a , \"!\" ) ;\n" "}"; - ASSERT_EQUALS(expected, tokenizeAndStringify(code, true, Platform::Type::Native, "test.c")); + ASSERT_EQUALS(expected, tokenizeAndStringify(code, true, Platform::Type::Native, false)); } { @@ -2171,7 +2153,7 @@ class TestSimplifyTokens : public TestFixture { "cin >> x ;\n" "return x ;\n" "}"; - ASSERT_EQUALS(expected, tokenizeAndStringify(code, true, Platform::Type::Native, "test.cpp")); + ASSERT_EQUALS(expected, tokenizeAndStringify(code, true, Platform::Type::Native, true)); } } @@ -2185,7 +2167,7 @@ class TestSimplifyTokens : public TestFixture { "int x ; x = 0 ;\n" "cin >> std :: hex >> x ;\n" "}"; - ASSERT_EQUALS(expected, tokenizeAndStringify(code, true, Platform::Type::Native, "test.cpp")); + ASSERT_EQUALS(expected, tokenizeAndStringify(code, true, Platform::Type::Native, true)); } void simplifyKnownVariables48() { @@ -2198,7 +2180,7 @@ class TestSimplifyTokens : public TestFixture { "int i ;\n" "for ( i = 0 ; ( i < sz ) && ( sz > 3 ) ; ++ i ) { }\n" "}"; - ASSERT_EQUALS(expected, tokenizeAndStringify(code, true, Platform::Type::Native, "test.c")); + ASSERT_EQUALS(expected, tokenizeAndStringify(code, true, Platform::Type::Native, false)); } void simplifyKnownVariables49() { // #3691 @@ -2214,7 +2196,7 @@ class TestSimplifyTokens : public TestFixture { "case 2 : ; x = sz ; break ;\n" "}\n" "}"; - ASSERT_EQUALS(expected, tokenizeAndStringify(code, true, Platform::Type::Native, "test.c")); + ASSERT_EQUALS(expected, tokenizeAndStringify(code, true, Platform::Type::Native, false)); } void simplifyKnownVariables50() { // #4066 diff --git a/test/testsimplifytypedef.cpp b/test/testsimplifytypedef.cpp index aa2ceb669379..4f3fc5e47d30 100644 --- a/test/testsimplifytypedef.cpp +++ b/test/testsimplifytypedef.cpp @@ -16,12 +16,11 @@ * along with this program. If not, see . */ - #include "errortypes.h" +#include "fixture.h" #include "helpers.h" #include "platform.h" #include "settings.h" -#include "fixture.h" #include "standards.h" #include "token.h" #include "tokenize.h" @@ -240,10 +239,9 @@ class TestSimplifyTypedef : public TestFixture { std::string tok_(const char* file, int line, const char code[], bool simplify = true, Platform::Type type = Platform::Type::Native, bool debugwarnings = true) { // show warnings about unhandled typedef const Settings settings = settingsBuilder(settings0).exhaustive().certainty(Certainty::inconclusive).debugwarnings(debugwarnings).platform(type).build(); - Tokenizer tokenizer(settings, this); + SimpleTokenizer tokenizer(settings, *this); - std::istringstream istr(code); - ASSERT_LOC(tokenizer.tokenize(istr, "test.cpp"), file, line); + ASSERT_LOC(tokenizer.tokenize(code), file, line); return tokenizer.tokens()->stringifyList(nullptr, !simplify); } @@ -278,9 +276,8 @@ class TestSimplifyTypedef : public TestFixture { // Tokenize.. // show warnings about unhandled typedef const Settings settings = settingsBuilder(settings0).certainty(Certainty::inconclusive).debugwarnings().build(); - Tokenizer tokenizer(settings, this); - std::istringstream istr(code); - ASSERT_LOC(tokenizer.tokenize(istr, "test.cpp"), file, line); + SimpleTokenizer tokenizer(settings, *this); + ASSERT_LOC(tokenizer.tokenize(code), file, line); } diff --git a/test/testsimplifyusing.cpp b/test/testsimplifyusing.cpp index a5714103a71f..fbeb0c8de15e 100644 --- a/test/testsimplifyusing.cpp +++ b/test/testsimplifyusing.cpp @@ -16,12 +16,11 @@ * along with this program. If not, see . */ - #include "errortypes.h" +#include "fixture.h" #include "helpers.h" #include "platform.h" #include "settings.h" -#include "fixture.h" #include "token.h" #include "tokenize.h" #include "utils.h" @@ -98,15 +97,18 @@ class TestSimplifyUsing : public TestFixture { std::string tok_(const char* file, int line, const char code[], Platform::Type type = Platform::Type::Native, bool debugwarnings = true, bool preprocess = false) { const Settings settings = settingsBuilder(settings0).certainty(Certainty::inconclusive).debugwarnings(debugwarnings).platform(type).build(); - Tokenizer tokenizer(settings, this); - if (preprocess) { + Tokenizer tokenizer(settings, this); std::vector files(1, "test.cpp"); PreprocessorHelper::preprocess(code, files, tokenizer); + std::istringstream istr(code); + ASSERT_LOC(tokenizer.list.createTokens(istr, "test.cpp"), file, line); // TODO: this creates the tokens a second time + ASSERT_LOC(tokenizer.simplifyTokens1(""), file, line); + return tokenizer.tokens()->stringifyList(nullptr); } - std::istringstream istr(code); - ASSERT_LOC(tokenizer.tokenize(istr, "test.cpp"), file, line); + SimpleTokenizer tokenizer(settings, *this); + ASSERT_LOC(tokenizer.tokenize(code), file, line); return tokenizer.tokens()->stringifyList(nullptr); } diff --git a/test/testsizeof.cpp b/test/testsizeof.cpp index 9a2d4366269c..9a576629c50b 100644 --- a/test/testsizeof.cpp +++ b/test/testsizeof.cpp @@ -18,12 +18,11 @@ #include "checksizeof.h" #include "errortypes.h" +#include "fixture.h" #include "helpers.h" #include "settings.h" -#include "fixture.h" #include "tokenize.h" -#include #include #include @@ -51,9 +50,8 @@ class TestSizeof : public TestFixture { #define check(code) check_(code, __FILE__, __LINE__) void check_(const char code[], const char* file, int line) { // Tokenize.. - Tokenizer tokenizer(settings, this); - std::istringstream istr(code); - ASSERT_LOC(tokenizer.tokenize(istr, "test.cpp"), file, line); + SimpleTokenizer tokenizer(settings, *this); + ASSERT_LOC(tokenizer.tokenize(code), file, line); // Check... runChecks(tokenizer, this); diff --git a/test/teststl.cpp b/test/teststl.cpp index 4a39b9a1fa21..2cd9adc43f79 100644 --- a/test/teststl.cpp +++ b/test/teststl.cpp @@ -18,17 +18,16 @@ #include "checkstl.h" #include "errortypes.h" +#include "fixture.h" +#include "helpers.h" #include "settings.h" #include "standards.h" -#include "fixture.h" #include "tokenize.h" #include "utils.h" #include -#include #include - class TestStl : public TestFixture { public: TestStl() : TestFixture("TestStl") {} @@ -182,10 +181,9 @@ class TestStl : public TestFixture { const Settings settings1 = settingsBuilder(settings).certainty(Certainty::inconclusive, inconclusive).cpp(cppstandard).build(); // Tokenize.. - Tokenizer tokenizer(settings1, this); - std::istringstream istr(code); + SimpleTokenizer tokenizer(settings1, *this); - ASSERT_LOC(tokenizer.tokenize(istr, "test.cpp"), file, line); + ASSERT_LOC(tokenizer.tokenize(code), file, line); runChecks(tokenizer, this); } @@ -197,9 +195,8 @@ class TestStl : public TestFixture { #define checkNormal(code) checkNormal_(code, __FILE__, __LINE__) void checkNormal_(const char code[], const char* file, int line) { // Tokenize.. - Tokenizer tokenizer(settings, this); - std::istringstream istr(code); - ASSERT_LOC(tokenizer.tokenize(istr, "test.cpp"), file, line); + SimpleTokenizer tokenizer(settings, *this); + ASSERT_LOC(tokenizer.tokenize(code), file, line); // Check.. runChecks(tokenizer, this); diff --git a/test/testsummaries.cpp b/test/testsummaries.cpp index 454131c38c5d..26b9782825ea 100644 --- a/test/testsummaries.cpp +++ b/test/testsummaries.cpp @@ -16,16 +16,14 @@ * along with this program. If not, see . */ - +#include "fixture.h" +#include "helpers.h" #include "settings.h" #include "summaries.h" -#include "fixture.h" #include "tokenize.h" -#include #include - class TestSummaries : public TestFixture { public: TestSummaries() : TestFixture("TestSummaries") {} @@ -39,11 +37,10 @@ class TestSummaries : public TestFixture { } #define createSummaries(...) createSummaries_(__FILE__, __LINE__, __VA_ARGS__) - std::string createSummaries_(const char* file, int line, const char code[], const char filename[] = "test.cpp") { + std::string createSummaries_(const char* file, int line, const char code[], bool cpp = true) { // tokenize.. - Tokenizer tokenizer(settingsDefault, this); - std::istringstream istr(code); - ASSERT_LOC(tokenizer.tokenize(istr, filename), file, line); + SimpleTokenizer tokenizer(settingsDefault, *this); + ASSERT_LOC(tokenizer.tokenize(code, cpp), file, line); return Summaries::create(&tokenizer, ""); } diff --git a/test/testsymboldatabase.cpp b/test/testsymboldatabase.cpp index ebe28bdb9f97..3b66387caffd 100644 --- a/test/testsymboldatabase.cpp +++ b/test/testsymboldatabase.cpp @@ -42,19 +42,19 @@ class TestSymbolDatabase; #define GET_SYMBOL_DB(code) \ - Tokenizer tokenizer(settings1, this); \ - const SymbolDatabase *db = getSymbolDB_inner(tokenizer, code, "test.cpp"); \ + SimpleTokenizer tokenizer(settings1, *this); \ + const SymbolDatabase *db = getSymbolDB_inner(tokenizer, code, true); \ ASSERT(db); \ do {} while (false) #define GET_SYMBOL_DB_C(code) \ - Tokenizer tokenizer(settings1, this); \ - const SymbolDatabase *db = getSymbolDB_inner(tokenizer, code, "test.c"); \ + SimpleTokenizer tokenizer(settings1, *this); \ + const SymbolDatabase *db = getSymbolDB_inner(tokenizer, code, false); \ do {} while (false) #define GET_SYMBOL_DB_DBG(code) \ - Tokenizer tokenizer(settingsDbg, this); \ - const SymbolDatabase *db = getSymbolDB_inner(tokenizer, code, "test.cpp"); \ + SimpleTokenizer tokenizer(settingsDbg, *this); \ + const SymbolDatabase *db = getSymbolDB_inner(tokenizer, code, true); \ ASSERT(db); \ do {} while (false) @@ -74,9 +74,8 @@ class TestSymbolDatabase : public TestFixture { typetok = nullptr; } - static const SymbolDatabase* getSymbolDB_inner(Tokenizer& tokenizer, const char* code, const char* filename) { - std::istringstream istr(code); - return tokenizer.tokenize(istr, filename) ? tokenizer.getSymbolDatabase() : nullptr; + static const SymbolDatabase* getSymbolDB_inner(SimpleTokenizer& tokenizer, const char* code, bool cpp) { + return tokenizer.tokenize(code, cpp) ? tokenizer.getSymbolDatabase() : nullptr; } static const Token* findToken(Tokenizer& tokenizer, const std::string& expr, unsigned int exprline) @@ -101,9 +100,8 @@ class TestSymbolDatabase : public TestFixture { unsigned int exprline2, SourceLocation loc = SourceLocation::current()) { - Tokenizer tokenizer(settings1, this); - std::istringstream istr(code); - ASSERT_LOC(tokenizer.tokenize(istr, "test.cpp"), loc.file_name(), loc.line()); + SimpleTokenizer tokenizer(settings1, *this); + ASSERT_LOC(tokenizer.tokenize(code), loc.file_name(), loc.line()); const Token* tok1 = findToken(tokenizer, expr1, exprline1); const Token* tok2 = findToken(tokenizer, expr2, exprline2); @@ -2580,14 +2578,13 @@ class TestSymbolDatabase : public TestFixture { } #define check(...) check_(__FILE__, __LINE__, __VA_ARGS__) - void check_(const char* file, int line, const char code[], bool debug = true, const char filename[] = "test.cpp", const Settings* pSettings = nullptr) { + void check_(const char* file, int line, const char code[], bool debug = true, bool cpp = true, const Settings* pSettings = nullptr) { // Check.. const Settings settings = settingsBuilder(pSettings ? *pSettings : settings1).debugwarnings(debug).exhaustive().build(); // Tokenize.. - Tokenizer tokenizer(settings, this); - std::istringstream istr(code); - ASSERT_LOC(tokenizer.tokenize(istr, filename), file, line); + SimpleTokenizer tokenizer(settings, *this); + ASSERT_LOC(tokenizer.tokenize(code, cpp), file, line); // force symbol database creation tokenizer.createSymbolDatabase(); @@ -3222,11 +3219,11 @@ class TestSymbolDatabase : public TestFixture { "static void function_declaration_after(void) __attribute__((__used__));"); ASSERT_EQUALS("", errout_str()); - check("main(int argc, char *argv[]) { }", true, "test.c"); + check("main(int argc, char *argv[]) { }", true, false); ASSERT_EQUALS("", errout_str()); const Settings s = settingsBuilder(settings1).severity(Severity::portability).build(); - check("main(int argc, char *argv[]) { }", false, "test.c", &s); + check("main(int argc, char *argv[]) { }", false, false, &s); ASSERT_EQUALS("[test.c:1]: (portability) Omitted return type of function 'main' defaults to int, this is not supported by ISO C99 and later standards.\n", errout_str()); @@ -8721,10 +8718,9 @@ class TestSymbolDatabase : public TestFixture { } } #define typeOf(...) typeOf_(__FILE__, __LINE__, __VA_ARGS__) - std::string typeOf_(const char* file, int line, const char code[], const char pattern[], const char filename[] = "test.cpp", const Settings *settings = nullptr) { - Tokenizer tokenizer(settings ? *settings : settings2, this); - std::istringstream istr(code); - ASSERT_LOC(tokenizer.tokenize(istr, filename), file, line); + std::string typeOf_(const char* file, int line, const char code[], const char pattern[], bool cpp = true, const Settings *settings = nullptr) { + SimpleTokenizer tokenizer(settings ? *settings : settings2, *this); + ASSERT_LOC(tokenizer.tokenize(code, cpp), file, line); const Token* tok; for (tok = tokenizer.list.back(); tok; tok = tok->previous()) if (Token::simpleMatch(tok, pattern, strlen(pattern))) @@ -8747,30 +8743,30 @@ class TestSymbolDatabase : public TestFixture { sSameSize.platform.long_long_bit = 64; // numbers - ASSERT_EQUALS("signed int", typeOf("1;", "1", "test.c", &s)); - ASSERT_EQUALS("signed int", typeOf("(-1);", "-1", "test.c", &s)); - ASSERT_EQUALS("signed int", typeOf("32767;", "32767", "test.c", &s)); - ASSERT_EQUALS("signed int", typeOf("(-32767);", "-32767", "test.c", &s)); - ASSERT_EQUALS("signed long", typeOf("32768;", "32768", "test.c", &s)); - ASSERT_EQUALS("signed long", typeOf("(-32768);", "-32768", "test.c", &s)); - ASSERT_EQUALS("signed long", typeOf("32768l;", "32768l", "test.c", &s)); - ASSERT_EQUALS("unsigned int", typeOf("32768U;", "32768U", "test.c", &s)); - ASSERT_EQUALS("signed long long", typeOf("2147483648;", "2147483648", "test.c", &s)); - ASSERT_EQUALS("unsigned long", typeOf("2147483648u;", "2147483648u", "test.c", &s)); - ASSERT_EQUALS("signed long long", typeOf("2147483648L;", "2147483648L", "test.c", &s)); - ASSERT_EQUALS("unsigned long long", typeOf("18446744069414584320;", "18446744069414584320", "test.c", &s)); - ASSERT_EQUALS("signed int", typeOf("0xFF;", "0xFF", "test.c", &s)); - ASSERT_EQUALS("unsigned int", typeOf("0xFFU;", "0xFFU", "test.c", &s)); - ASSERT_EQUALS("unsigned int", typeOf("0xFFFF;", "0xFFFF", "test.c", &s)); - ASSERT_EQUALS("signed long", typeOf("0xFFFFFF;", "0xFFFFFF", "test.c", &s)); - ASSERT_EQUALS("unsigned long", typeOf("0xFFFFFFU;", "0xFFFFFFU", "test.c", &s)); - ASSERT_EQUALS("unsigned long", typeOf("0xFFFFFFFF;", "0xFFFFFFFF", "test.c", &s)); - ASSERT_EQUALS("signed long long", typeOf("0xFFFFFFFFFFFF;", "0xFFFFFFFFFFFF", "test.c", &s)); - ASSERT_EQUALS("unsigned long long", typeOf("0xFFFFFFFFFFFFU;", "0xFFFFFFFFFFFFU", "test.c", &s)); - ASSERT_EQUALS("unsigned long long", typeOf("0xFFFFFFFF00000000;", "0xFFFFFFFF00000000", "test.c", &s)); - - ASSERT_EQUALS("signed long", typeOf("2147483648;", "2147483648", "test.c", &sSameSize)); - ASSERT_EQUALS("unsigned long", typeOf("0xc000000000000000;", "0xc000000000000000", "test.c", &sSameSize)); + ASSERT_EQUALS("signed int", typeOf("1;", "1", false, &s)); + ASSERT_EQUALS("signed int", typeOf("(-1);", "-1", false, &s)); + ASSERT_EQUALS("signed int", typeOf("32767;", "32767", false, &s)); + ASSERT_EQUALS("signed int", typeOf("(-32767);", "-32767", false, &s)); + ASSERT_EQUALS("signed long", typeOf("32768;", "32768", false, &s)); + ASSERT_EQUALS("signed long", typeOf("(-32768);", "-32768", false, &s)); + ASSERT_EQUALS("signed long", typeOf("32768l;", "32768l", false, &s)); + ASSERT_EQUALS("unsigned int", typeOf("32768U;", "32768U", false, &s)); + ASSERT_EQUALS("signed long long", typeOf("2147483648;", "2147483648", false, &s)); + ASSERT_EQUALS("unsigned long", typeOf("2147483648u;", "2147483648u", false, &s)); + ASSERT_EQUALS("signed long long", typeOf("2147483648L;", "2147483648L", false, &s)); + ASSERT_EQUALS("unsigned long long", typeOf("18446744069414584320;", "18446744069414584320", false, &s)); + ASSERT_EQUALS("signed int", typeOf("0xFF;", "0xFF", false, &s)); + ASSERT_EQUALS("unsigned int", typeOf("0xFFU;", "0xFFU", false, &s)); + ASSERT_EQUALS("unsigned int", typeOf("0xFFFF;", "0xFFFF", false, &s)); + ASSERT_EQUALS("signed long", typeOf("0xFFFFFF;", "0xFFFFFF", false, &s)); + ASSERT_EQUALS("unsigned long", typeOf("0xFFFFFFU;", "0xFFFFFFU", false, &s)); + ASSERT_EQUALS("unsigned long", typeOf("0xFFFFFFFF;", "0xFFFFFFFF", false, &s)); + ASSERT_EQUALS("signed long long", typeOf("0xFFFFFFFFFFFF;", "0xFFFFFFFFFFFF", false, &s)); + ASSERT_EQUALS("unsigned long long", typeOf("0xFFFFFFFFFFFFU;", "0xFFFFFFFFFFFFU", false, &s)); + ASSERT_EQUALS("unsigned long long", typeOf("0xFFFFFFFF00000000;", "0xFFFFFFFF00000000", false, &s)); + + ASSERT_EQUALS("signed long", typeOf("2147483648;", "2147483648", false, &sSameSize)); + ASSERT_EQUALS("unsigned long", typeOf("0xc000000000000000;", "0xc000000000000000", false, &sSameSize)); ASSERT_EQUALS("unsigned int", typeOf("1U;", "1U")); ASSERT_EQUALS("signed long", typeOf("1L;", "1L")); @@ -8827,12 +8823,12 @@ class TestSymbolDatabase : public TestFixture { ASSERT_EQUALS("unsigned long", typeOf("(unsigned long)1 + (signed int)2;", "+")); // char - ASSERT_EQUALS("char", typeOf("'a';", "'a'", "test.cpp")); - ASSERT_EQUALS("signed int", typeOf("'a';", "'a'", "test.c")); - ASSERT_EQUALS("wchar_t", typeOf("L'a';", "L'a'", "test.cpp")); - ASSERT_EQUALS("wchar_t", typeOf("L'a';", "L'a'", "test.c")); - ASSERT_EQUALS("signed int", typeOf("'aaa';", "'aaa'", "test.cpp")); - ASSERT_EQUALS("signed int", typeOf("'aaa';", "'aaa'", "test.c")); + ASSERT_EQUALS("char", typeOf("'a';", "'a'", true)); + ASSERT_EQUALS("signed int", typeOf("'a';", "'a'", false)); + ASSERT_EQUALS("wchar_t", typeOf("L'a';", "L'a'", true)); + ASSERT_EQUALS("wchar_t", typeOf("L'a';", "L'a'", false)); + ASSERT_EQUALS("signed int", typeOf("'aaa';", "'aaa'", true)); + ASSERT_EQUALS("signed int", typeOf("'aaa';", "'aaa'", false)); // char * ASSERT_EQUALS("const char *", typeOf("\"hello\" + 1;", "+")); @@ -8893,10 +8889,10 @@ class TestSymbolDatabase : public TestFixture { // shift => result has same type as lhs ASSERT_EQUALS("signed int", typeOf("int x; a = x << 1U;", "<<")); ASSERT_EQUALS("signed int", typeOf("int x; a = x >> 1U;", ">>")); - ASSERT_EQUALS("", typeOf("a = 12 >> x;", ">>", "test.cpp")); // >> might be overloaded - ASSERT_EQUALS("signed int", typeOf("a = 12 >> x;", ">>", "test.c")); - ASSERT_EQUALS("", typeOf("a = 12 << x;", "<<", "test.cpp")); // << might be overloaded - ASSERT_EQUALS("signed int", typeOf("a = 12 << x;", "<<", "test.c")); + ASSERT_EQUALS("", typeOf("a = 12 >> x;", ">>", true)); // >> might be overloaded + ASSERT_EQUALS("signed int", typeOf("a = 12 >> x;", ">>", false)); + ASSERT_EQUALS("", typeOf("a = 12 << x;", "<<", true)); // << might be overloaded + ASSERT_EQUALS("signed int", typeOf("a = 12 << x;", "<<", false)); ASSERT_EQUALS("signed int", typeOf("a = true << 1U;", "<<")); // assignment => result has same type as lhs @@ -8906,8 +8902,8 @@ class TestSymbolDatabase : public TestFixture { ASSERT_EQUALS("void * *", typeOf("void * x[10]; a = x + 0;", "+")); ASSERT_EQUALS("signed int *", typeOf("int x[10]; a = x + 1;", "+")); ASSERT_EQUALS("signed int", typeOf("int x[10]; a = x[0] + 1;", "+")); - ASSERT_EQUALS("", typeOf("a = x[\"hello\"];", "[", "test.cpp")); - ASSERT_EQUALS("const char", typeOf("a = x[\"hello\"];", "[", "test.c")); + ASSERT_EQUALS("", typeOf("a = x[\"hello\"];", "[", true)); + ASSERT_EQUALS("const char", typeOf("a = x[\"hello\"];", "[", false)); ASSERT_EQUALS("signed int *", typeOf("int x[10]; a = &x;", "&")); ASSERT_EQUALS("signed int *", typeOf("int x[10]; a = &x[1];", "&")); @@ -8977,7 +8973,7 @@ class TestSymbolDatabase : public TestFixture { "\n" \ ""; \ const Settings sF = settingsBuilder().libraryxml(xmldata, sizeof(xmldata)).build(); \ - ASSERT_EQUALS(#type, typeOf("void f() { auto x = g(); }", "x", "test.cpp", &sF)); \ + ASSERT_EQUALS(#type, typeOf("void f() { auto x = g(); }", "x", true, &sF)); \ } while (false) // *INDENT-OFF* CHECK_LIBRARY_FUNCTION_RETURN_TYPE(bool); @@ -9010,12 +9006,12 @@ class TestSymbolDatabase : public TestFixture { settings.platform.sizeof_short = 2; settings.platform.sizeof_int = 4; - ASSERT_EQUALS("unsigned char", typeOf("u8'a';", "u8'a'", "test.cpp", &settings)); - ASSERT_EQUALS("unsigned short", typeOf("u'a';", "u'a'", "test.cpp", &settings)); - ASSERT_EQUALS("unsigned int", typeOf("U'a';", "U'a'", "test.cpp", &settings)); - ASSERT_EQUALS("const unsigned char *", typeOf("u8\"a\";", "u8\"a\"", "test.cpp", &settings)); - ASSERT_EQUALS("const unsigned short *", typeOf("u\"a\";", "u\"a\"", "test.cpp", &settings)); - ASSERT_EQUALS("const unsigned int *", typeOf("U\"a\";", "U\"a\"", "test.cpp", &settings)); + ASSERT_EQUALS("unsigned char", typeOf("u8'a';", "u8'a'", true, &settings)); + ASSERT_EQUALS("unsigned short", typeOf("u'a';", "u'a'", true, &settings)); + ASSERT_EQUALS("unsigned int", typeOf("U'a';", "U'a'", true, &settings)); + ASSERT_EQUALS("const unsigned char *", typeOf("u8\"a\";", "u8\"a\"", true, &settings)); + ASSERT_EQUALS("const unsigned short *", typeOf("u\"a\";", "u\"a\"", true, &settings)); + ASSERT_EQUALS("const unsigned int *", typeOf("U\"a\";", "U\"a\"", true, &settings)); } { // PodType @@ -9033,11 +9029,11 @@ class TestSymbolDatabase : public TestFixture { ValueType vt2; ASSERT_EQUALS(true, vt2.fromLibraryType("podtype2", settingsWin64)); ASSERT_EQUALS(ValueType::Type::INT, vt2.type); - ASSERT_EQUALS("unsigned int *", typeOf(";void *data = new u32[10];", "new", "test.cpp", &settingsWin64)); - ASSERT_EQUALS("unsigned int *", typeOf(";void *data = new xyz::x[10];", "new", "test.cpp", &settingsWin64)); - ASSERT_EQUALS("unsigned int", typeOf("; x = (xyz::x)12;", "(", "test.cpp", &settingsWin64)); - ASSERT_EQUALS("unsigned int", typeOf(";u32(12);", "(", "test.cpp", &settingsWin64)); - ASSERT_EQUALS("unsigned int", typeOf("x = u32(y[i]);", "(", "test.cpp", &settingsWin64)); + ASSERT_EQUALS("unsigned int *", typeOf(";void *data = new u32[10];", "new", true, &settingsWin64)); + ASSERT_EQUALS("unsigned int *", typeOf(";void *data = new xyz::x[10];", "new", true, &settingsWin64)); + ASSERT_EQUALS("unsigned int", typeOf("; x = (xyz::x)12;", "(", true, &settingsWin64)); + ASSERT_EQUALS("unsigned int", typeOf(";u32(12);", "(", true, &settingsWin64)); + ASSERT_EQUALS("unsigned int", typeOf("x = u32(y[i]);", "(", true, &settingsWin64)); } { // PlatformType @@ -9072,9 +9068,9 @@ class TestSymbolDatabase : public TestFixture { " \n" ""; const Settings sC = settingsBuilder().libraryxml(xmldata, sizeof(xmldata)).build(); - ASSERT_EQUALS("container(C) *", typeOf("C*c=new C;","new","test.cpp",&sC)); - ASSERT_EQUALS("container(C) *", typeOf("x=(C*)c;","(","test.cpp",&sC)); - ASSERT_EQUALS("container(C)", typeOf("C c = C();","(","test.cpp",&sC)); + ASSERT_EQUALS("container(C) *", typeOf("C*c=new C;","new",true,&sC)); + ASSERT_EQUALS("container(C) *", typeOf("x=(C*)c;","(",true,&sC)); + ASSERT_EQUALS("container(C)", typeOf("C c = C();","(",true,&sC)); } { // Container (vector) @@ -9094,31 +9090,31 @@ class TestSymbolDatabase : public TestFixture { " \n" ""; const Settings set = settingsBuilder().libraryxml(xmldata, sizeof(xmldata)).build(); - ASSERT_EQUALS("signed int", typeOf("Vector v; v[0]=3;", "[", "test.cpp", &set)); - ASSERT_EQUALS("container(test :: string)", typeOf("{return test::string();}", "(", "test.cpp", &set)); + ASSERT_EQUALS("signed int", typeOf("Vector v; v[0]=3;", "[", true, &set)); + ASSERT_EQUALS("container(test :: string)", typeOf("{return test::string();}", "(", true, &set)); ASSERT_EQUALS( "container(test :: string)", - typeOf("void foo(Vector v) { for (auto s: v) { x=s+s; } }", "s", "test.cpp", &set)); + typeOf("void foo(Vector v) { for (auto s: v) { x=s+s; } }", "s", true, &set)); ASSERT_EQUALS( "container(test :: string)", - typeOf("void foo(Vector v) { for (auto s: v) { x=s+s; } }", "+", "test.cpp", &set)); + typeOf("void foo(Vector v) { for (auto s: v) { x=s+s; } }", "+", true, &set)); ASSERT_EQUALS("container(test :: string) &", - typeOf("Vector v; x = v.front();", "(", "test.cpp", &set)); + typeOf("Vector v; x = v.front();", "(", true, &set)); ASSERT_EQUALS("container(test :: string) *", - typeOf("Vector v; x = v.data();", "(", "test.cpp", &set)); - ASSERT_EQUALS("signed int &", typeOf("Vector v; x = v.front();", "(", "test.cpp", &set)); - ASSERT_EQUALS("signed int *", typeOf("Vector v; x = v.data();", "(", "test.cpp", &set)); - ASSERT_EQUALS("signed int * *", typeOf("Vector v; x = v.data();", "(", "test.cpp", &set)); - ASSERT_EQUALS("iterator(Vector <)", typeOf("Vector v; x = v.begin();", "(", "test.cpp", &set)); - ASSERT_EQUALS("signed int &", typeOf("Vector v; x = *v.begin();", "*", "test.cpp", &set)); + typeOf("Vector v; x = v.data();", "(", true, &set)); + ASSERT_EQUALS("signed int &", typeOf("Vector v; x = v.front();", "(", true, &set)); + ASSERT_EQUALS("signed int *", typeOf("Vector v; x = v.data();", "(", true, &set)); + ASSERT_EQUALS("signed int * *", typeOf("Vector v; x = v.data();", "(", true, &set)); + ASSERT_EQUALS("iterator(Vector <)", typeOf("Vector v; x = v.begin();", "(", true, &set)); + ASSERT_EQUALS("signed int &", typeOf("Vector v; x = *v.begin();", "*", true, &set)); ASSERT_EQUALS("container(test :: string)", - typeOf("void foo(){test::string s; return \"x\"+s;}", "+", "test.cpp", &set)); + typeOf("void foo(){test::string s; return \"x\"+s;}", "+", true, &set)); ASSERT_EQUALS("container(test :: string)", - typeOf("void foo(){test::string s; return s+\"x\";}", "+", "test.cpp", &set)); + typeOf("void foo(){test::string s; return s+\"x\";}", "+", true, &set)); ASSERT_EQUALS("container(test :: string)", - typeOf("void foo(){test::string s; return 'x'+s;}", "+", "test.cpp", &set)); + typeOf("void foo(){test::string s; return 'x'+s;}", "+", true, &set)); ASSERT_EQUALS("container(test :: string)", - typeOf("void foo(){test::string s; return s+'x';}", "+", "test.cpp", &set)); + typeOf("void foo(){test::string s; return s+'x';}", "+", true, &set)); } // new @@ -9161,7 +9157,7 @@ class TestSymbolDatabase : public TestFixture { ""; const Settings set = settingsBuilder().libraryxml(xmldata, sizeof(xmldata)).build(); ASSERT_EQUALS("smart-pointer(std::shared_ptr)", - typeOf("class C {}; x = std::make_shared();", "(", "test.cpp", &set)); + typeOf("class C {}; x = std::make_shared();", "(", true, &set)); } // return @@ -9172,7 +9168,7 @@ class TestSymbolDatabase : public TestFixture { " \n" ""; const Settings sC = settingsBuilder().libraryxml(xmldata, sizeof(xmldata)).build(); - ASSERT_EQUALS("container(C)", typeOf("C f(char *p) { char data[10]; return data; }", "return", "test.cpp", &sC)); + ASSERT_EQUALS("container(C)", typeOf("C f(char *p) { char data[10]; return data; }", "return", true, &sC)); } // Smart pointer { @@ -9182,9 +9178,9 @@ class TestSymbolDatabase : public TestFixture { ""; const Settings set = settingsBuilder().libraryxml(xmldata, sizeof(xmldata)).build(); ASSERT_EQUALS("smart-pointer(MyPtr)", - typeOf("void f() { MyPtr p; return p; }", "p ;", "test.cpp", &set)); - ASSERT_EQUALS("signed int", typeOf("void f() { MyPtr p; return *p; }", "* p ;", "test.cpp", &set)); - ASSERT_EQUALS("smart-pointer(MyPtr)", typeOf("void f() {return MyPtr();}", "(", "test.cpp", &set)); + typeOf("void f() { MyPtr p; return p; }", "p ;", true, &set)); + ASSERT_EQUALS("signed int", typeOf("void f() { MyPtr p; return *p; }", "* p ;", true, &set)); + ASSERT_EQUALS("smart-pointer(MyPtr)", typeOf("void f() {return MyPtr();}", "(", true, &set)); } } diff --git a/test/testtoken.cpp b/test/testtoken.cpp index 273d04984f60..cba7f7c7367e 100644 --- a/test/testtoken.cpp +++ b/test/testtoken.cpp @@ -16,18 +16,16 @@ * along with this program. If not, see . */ -#include "settings.h" #include "errortypes.h" #include "fixture.h" #include "helpers.h" +#include "settings.h" #include "standards.h" #include "token.h" -#include "tokenize.h" #include "tokenlist.h" #include "vfvalue.h" #include -#include #include #include @@ -142,10 +140,10 @@ class TestToken : public TestFixture { #define MatchCheck(...) MatchCheck_(__FILE__, __LINE__, __VA_ARGS__) bool MatchCheck_(const char* file, int line, const std::string& code, const std::string& pattern, unsigned int varid = 0) { - Tokenizer tokenizer(settingsDefault, this); - std::istringstream istr(";" + code + ";"); + SimpleTokenizer tokenizer(settingsDefault, *this); + const std::string code2 = ";" + code + ";"; try { - ASSERT_LOC(tokenizer.tokenize(istr, "test.cpp"), file, line); + ASSERT_LOC(tokenizer.tokenize(code2.c_str()), file, line); } catch (...) {} return Token::Match(tokenizer.tokens()->next(), pattern.c_str(), varid); } diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index 559ab5779397..3331ccc31998 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -18,12 +18,12 @@ #include "config.h" #include "errortypes.h" +#include "fixture.h" #include "helpers.h" #include "platform.h" #include "preprocessor.h" // usually tests here should not use preprocessor... #include "settings.h" #include "standards.h" -#include "fixture.h" #include "token.h" #include "tokenize.h" #include "tokenlist.h" @@ -452,13 +452,12 @@ class TestTokenizer : public TestFixture { } #define tokenizeAndStringify(...) tokenizeAndStringify_(__FILE__, __LINE__, __VA_ARGS__) - std::string tokenizeAndStringify_(const char* file, int linenr, const char code[], bool expand = true, Platform::Type platform = Platform::Type::Native, const char* filename = "test.cpp", Standards::cppstd_t std = Standards::CPP11) { + std::string tokenizeAndStringify_(const char* file, int linenr, const char code[], bool expand = true, Platform::Type platform = Platform::Type::Native, bool cpp = true, Standards::cppstd_t std = Standards::CPP11) { const Settings settings = settingsBuilder(settings1).debugwarnings().cpp(std).platform(platform).build(); // tokenize.. - Tokenizer tokenizer(settings, this); - std::istringstream istr(code); - ASSERT_LOC(tokenizer.tokenize(istr, filename), file, linenr); + SimpleTokenizer tokenizer(settings, *this); + ASSERT_LOC(tokenizer.tokenize(code, cpp), file, linenr); if (tokenizer.tokens()) return tokenizer.tokens()->stringifyList(false, expand, false, true, false, nullptr, nullptr); @@ -466,36 +465,33 @@ class TestTokenizer : public TestFixture { } #define tokenizeAndStringifyWindows(...) tokenizeAndStringifyWindows_(__FILE__, __LINE__, __VA_ARGS__) - std::string tokenizeAndStringifyWindows_(const char* file, int linenr, const char code[], bool expand = true, Platform::Type platform = Platform::Type::Native, const char* filename = "test.cpp", bool cpp11 = true) { + std::string tokenizeAndStringifyWindows_(const char* file, int linenr, const char code[], bool expand = true, Platform::Type platform = Platform::Type::Native, bool cpp = true, bool cpp11 = true) { const Settings settings = settingsBuilder(settings_windows).debugwarnings().cpp(cpp11 ? Standards::CPP11 : Standards::CPP03).platform(platform).build(); // tokenize.. - Tokenizer tokenizer(settings, this); - std::istringstream istr(code); - ASSERT_LOC(tokenizer.tokenize(istr, filename), file, linenr); + SimpleTokenizer tokenizer(settings, *this); + ASSERT_LOC(tokenizer.tokenize(code, cpp), file, linenr); if (tokenizer.tokens()) return tokenizer.tokens()->stringifyList(false, expand, false, true, false, nullptr, nullptr); return ""; } - std::string tokenizeAndStringify_(const char* file, int line, const char code[], const Settings &settings, const char filename[] = "test.cpp") { + std::string tokenizeAndStringify_(const char* file, int line, const char code[], const Settings &settings, bool cpp = true) { // tokenize.. - Tokenizer tokenizer(settings, this); - std::istringstream istr(code); - ASSERT_LOC(tokenizer.tokenize(istr, filename), file, line); + SimpleTokenizer tokenizer(settings, *this); + ASSERT_LOC(tokenizer.tokenize(code, cpp), file, line); if (!tokenizer.tokens()) return ""; return tokenizer.tokens()->stringifyList(false, true, false, true, false, nullptr, nullptr); } #define tokenizeDebugListing(...) tokenizeDebugListing_(__FILE__, __LINE__, __VA_ARGS__) - std::string tokenizeDebugListing_(const char* file, int line, const char code[], const char filename[] = "test.cpp") { + std::string tokenizeDebugListing_(const char* file, int line, const char code[], bool cpp = true) { const Settings settings = settingsBuilder(settings0).c(Standards::C89).cpp(Standards::CPP03).build(); - Tokenizer tokenizer(settings, this); - std::istringstream istr(code); - ASSERT_LOC(tokenizer.tokenize(istr, filename), file, line); + SimpleTokenizer tokenizer(settings, *this); + ASSERT_LOC(tokenizer.tokenize(code, cpp), file, line); // result.. return tokenizer.tokens()->stringifyList(true,true,true,true,false); @@ -783,11 +779,17 @@ class TestTokenizer : public TestFixture { void validate() { // C++ code in C file - ASSERT_THROW_INTERNAL(tokenizeAndStringify(";using namespace std;",false,Platform::Type::Native,"test.c"), SYNTAX); - ASSERT_THROW_INTERNAL(tokenizeAndStringify(";std::map m;",false,Platform::Type::Native,"test.c"), SYNTAX); - ASSERT_THROW_INTERNAL(tokenizeAndStringify(";template class X { };",false,Platform::Type::Native,"test.c"), SYNTAX); - ASSERT_THROW_INTERNAL(tokenizeAndStringify("int X() {};",false,Platform::Type::Native,"test.c"), SYNTAX); - ASSERT_THROW_INTERNAL(tokenizeAndStringify("void foo(int i) { reinterpret_cast(i) };",false,Platform::Type::Native,"test.h"), SYNTAX); + ASSERT_THROW_INTERNAL(tokenizeAndStringify(";using namespace std;",false,Platform::Type::Native,false), SYNTAX); + ASSERT_THROW_INTERNAL(tokenizeAndStringify(";std::map m;",false,Platform::Type::Native,false), SYNTAX); + ASSERT_THROW_INTERNAL(tokenizeAndStringify(";template class X { };",false,Platform::Type::Native,false), SYNTAX); + ASSERT_THROW_INTERNAL(tokenizeAndStringify("int X() {};",false,Platform::Type::Native,false), SYNTAX); + { + Tokenizer tokenizer(settings1, this); + const char code[] = "void foo(int i) { reinterpret_cast(i) };"; + std::istringstream istr(code); + ASSERT(tokenizer.list.createTokens(istr, "test.h")); + ASSERT_THROW_INTERNAL(tokenizer.simplifyTokens1(""), SYNTAX); + } } void objectiveC() { @@ -838,14 +840,14 @@ class TestTokenizer : public TestFixture { void removePragma() { const char code[] = "_Pragma(\"abc\") int x;"; const Settings s_c89 = settingsBuilder().c(Standards::C89).build(); - ASSERT_EQUALS("_Pragma ( \"abc\" ) int x ;", tokenizeAndStringify(code, s_c89, "test.c")); + ASSERT_EQUALS("_Pragma ( \"abc\" ) int x ;", tokenizeAndStringify(code, s_c89, false)); const Settings s_clatest = settingsBuilder().c(Standards::CLatest).build(); - ASSERT_EQUALS("int x ;", tokenizeAndStringify(code, s_clatest, "test.c")); + ASSERT_EQUALS("int x ;", tokenizeAndStringify(code, s_clatest, false)); const Settings s_cpp03 = settingsBuilder().cpp(Standards::CPP03).build(); - ASSERT_EQUALS("_Pragma ( \"abc\" ) int x ;", tokenizeAndStringify(code, s_cpp03, "test.cpp")); + ASSERT_EQUALS("_Pragma ( \"abc\" ) int x ;", tokenizeAndStringify(code, s_cpp03, true)); const Settings s_cpplatest = settingsBuilder().cpp(Standards::CPPLatest).build(); - ASSERT_EQUALS("int x ;", tokenizeAndStringify(code, s_cpplatest, "test.cpp")); + ASSERT_EQUALS("int x ;", tokenizeAndStringify(code, s_cpplatest, true)); } void foreach () { @@ -1530,9 +1532,8 @@ class TestTokenizer : public TestFixture { { const char code[] = "extern \"C\" int foo();"; // tokenize.. - Tokenizer tokenizer(settings0, this); - std::istringstream istr(code); - ASSERT(tokenizer.tokenize(istr, "test.cpp")); + SimpleTokenizer tokenizer(settings0, *this); + ASSERT(tokenizer.tokenize(code)); // Expected result.. ASSERT_EQUALS(expected, tokenizer.tokens()->stringifyList(nullptr, false)); ASSERT(tokenizer.tokens()->next()->isExternC()); @@ -1540,9 +1541,8 @@ class TestTokenizer : public TestFixture { { const char code[] = "extern \"C\" { int foo(); }"; // tokenize.. - Tokenizer tokenizer(settings0, this); - std::istringstream istr(code); - ASSERT(tokenizer.tokenize(istr, "test.cpp")); + SimpleTokenizer tokenizer(settings0, *this); + ASSERT(tokenizer.tokenize(code)); // Expected result.. ASSERT_EQUALS(expected, tokenizer.tokens()->stringifyList(nullptr, false)); ASSERT(tokenizer.tokens()->next()->isExternC()); @@ -1550,9 +1550,8 @@ class TestTokenizer : public TestFixture { { const char code[] = "extern \"C++\" int foo();"; // tokenize.. - Tokenizer tokenizer(settings0, this); - std::istringstream istr(code); - ASSERT(tokenizer.tokenize(istr, "test.cpp")); + SimpleTokenizer tokenizer(settings0, *this); + ASSERT(tokenizer.tokenize(code)); // Expected result.. ASSERT_EQUALS(expected, tokenizer.tokens()->stringifyList(nullptr, false)); ASSERT(!tokenizer.tokens()->next()->isExternC()); @@ -1560,9 +1559,8 @@ class TestTokenizer : public TestFixture { { const char code[] = "extern \"C++\" { int foo(); }"; // tokenize.. - Tokenizer tokenizer(settings0, this); - std::istringstream istr(code); - ASSERT(tokenizer.tokenize(istr, "test.cpp")); + SimpleTokenizer tokenizer(settings0, *this); + ASSERT(tokenizer.tokenize(code)); // Expected result.. ASSERT_EQUALS(expected, tokenizer.tokens()->stringifyList(nullptr, false)); ASSERT(!tokenizer.tokens()->next()->isExternC()); @@ -2303,7 +2301,7 @@ class TestTokenizer : public TestFixture { void vardecl14() { const char code[] = "::std::tr1::shared_ptr pNum1, pNum2;\n"; - ASSERT_EQUALS(":: std :: tr1 :: shared_ptr < int > pNum1 ; :: std :: tr1 :: shared_ptr < int > pNum2 ;", tokenizeAndStringify(code, false, Platform::Type::Native, "test.cpp", Standards::CPP03)); + ASSERT_EQUALS(":: std :: tr1 :: shared_ptr < int > pNum1 ; :: std :: tr1 :: shared_ptr < int > pNum2 ;", tokenizeAndStringify(code, false, Platform::Type::Native, true, Standards::CPP03)); } void vardecl15() { @@ -2510,7 +2508,7 @@ class TestTokenizer : public TestFixture { void vardecl26() { // #5907 const char code[] = "extern int *new, obj, player;"; const char expected[] = "extern int * new ; extern int obj ; extern int player ;"; - ASSERT_EQUALS(expected, tokenizeAndStringify(code, true, Platform::Type::Native, "test.c")); + ASSERT_EQUALS(expected, tokenizeAndStringify(code, true, Platform::Type::Native, false)); ASSERT_EQUALS(expected, tokenizeAndStringify(code)); ASSERT_EQUALS("[test.cpp:1]: (debug) Scope::checkVariable found variable 'new' with varid 0.\n", errout_str()); } @@ -2522,7 +2520,7 @@ class TestTokenizer : public TestFixture { " return 0;\n" " return 0;\n" "}"; - tokenizeAndStringify(code, /*expand=*/ true, Platform::Type::Native, "test.c"); + tokenizeAndStringify(code, /*expand=*/ true, Platform::Type::Native, false); } void vardecl28() { @@ -2534,7 +2532,7 @@ class TestTokenizer : public TestFixture { "const unsigned short x ; x = 1 ;\n" "return x ;\n" "}", - tokenizeAndStringify(code, /*expand=*/ true, Platform::Type::Native, "test.c")); + tokenizeAndStringify(code, /*expand=*/ true, Platform::Type::Native, false)); } void vardecl29() { // #9282 @@ -2554,9 +2552,9 @@ class TestTokenizer : public TestFixture { void vardecl30() { const char code[] = "struct D {} const d;"; ASSERT_EQUALS("struct D { } ; struct D const d ;", - tokenizeAndStringify(code, true, Platform::Type::Native, "test.cpp")); + tokenizeAndStringify(code, true, Platform::Type::Native, true)); ASSERT_EQUALS("struct D { } ; struct D const d ;", - tokenizeAndStringify(code, true, Platform::Type::Native, "test.c")); + tokenizeAndStringify(code, true, Platform::Type::Native, false)); } void vardecl31() { @@ -2627,15 +2625,15 @@ class TestTokenizer : public TestFixture { } void implicitIntConst() { - ASSERT_EQUALS("const int x ;", tokenizeAndStringify("const x;", true, Platform::Type::Native, "test.c")); - ASSERT_EQUALS("const int * x ;", tokenizeAndStringify("const *x;", true, Platform::Type::Native, "test.c")); - ASSERT_EQUALS("const int * f ( ) ;", tokenizeAndStringify("const *f();", true, Platform::Type::Native, "test.c")); + ASSERT_EQUALS("const int x ;", tokenizeAndStringify("const x;", true, Platform::Type::Native, false)); + ASSERT_EQUALS("const int * x ;", tokenizeAndStringify("const *x;", true, Platform::Type::Native, false)); + ASSERT_EQUALS("const int * f ( ) ;", tokenizeAndStringify("const *f();", true, Platform::Type::Native, false)); } void implicitIntExtern() { - ASSERT_EQUALS("extern int x ;", tokenizeAndStringify("extern x;", true, Platform::Type::Native, "test.c")); - ASSERT_EQUALS("extern int * x ;", tokenizeAndStringify("extern *x;", true, Platform::Type::Native, "test.c")); - ASSERT_EQUALS("const int * f ( ) ;", tokenizeAndStringify("const *f();", true, Platform::Type::Native, "test.c")); + ASSERT_EQUALS("extern int x ;", tokenizeAndStringify("extern x;", true, Platform::Type::Native, false)); + ASSERT_EQUALS("extern int * x ;", tokenizeAndStringify("extern *x;", true, Platform::Type::Native, false)); + ASSERT_EQUALS("const int * f ( ) ;", tokenizeAndStringify("const *f();", true, Platform::Type::Native, false)); } /** @@ -2869,27 +2867,27 @@ class TestTokenizer : public TestFixture { { const char code[] = "float complex x;"; const char expected[] = "_Complex float x ;"; - ASSERT_EQUALS(expected, tokenizeAndStringify(code, true, Platform::Native, "test.c")); + ASSERT_EQUALS(expected, tokenizeAndStringify(code, true, Platform::Native, false)); } { const char code[] = "complex float x;"; const char expected[] = "_Complex float x ;"; - ASSERT_EQUALS(expected, tokenizeAndStringify(code, true, Platform::Native, "test.c")); + ASSERT_EQUALS(expected, tokenizeAndStringify(code, true, Platform::Native, false)); } { const char code[] = "complex long double x;"; const char expected[] = "_Complex long double x ;"; - ASSERT_EQUALS(expected, tokenizeAndStringify(code, true, Platform::Native, "test.c")); + ASSERT_EQUALS(expected, tokenizeAndStringify(code, true, Platform::Native, false)); } { const char code[] = "long double complex x;"; const char expected[] = "_Complex long double x ;"; - ASSERT_EQUALS(expected, tokenizeAndStringify(code, true, Platform::Native, "test.c")); + ASSERT_EQUALS(expected, tokenizeAndStringify(code, true, Platform::Native, false)); } { const char code[] = "double complex;"; const char expected[] = "double complex ;"; - ASSERT_EQUALS(expected, tokenizeAndStringify(code, true, Platform::Native, "test.c")); + ASSERT_EQUALS(expected, tokenizeAndStringify(code, true, Platform::Native, false)); } } @@ -2898,9 +2896,8 @@ class TestTokenizer : public TestFixture { const char code[] = "class A{\n" " void f() {}\n" "};"; - Tokenizer tokenizer(settings0, this); - std::istringstream istr(code); - ASSERT(tokenizer.tokenize(istr, "test.cpp")); + SimpleTokenizer tokenizer(settings0, *this); + ASSERT(tokenizer.tokenize(code)); const Token *tok = tokenizer.tokens(); // A body {} ASSERT_EQUALS(true, tok->linkAt(2) == tok->tokAt(9)); @@ -2922,9 +2919,8 @@ class TestTokenizer : public TestFixture { " char a[10];\n" " char *b ; b = new char[a[0]];\n" "};"; - Tokenizer tokenizer(settings0, this); - std::istringstream istr(code); - ASSERT(tokenizer.tokenize(istr, "test.cpp")); + SimpleTokenizer tokenizer(settings0, *this); + ASSERT(tokenizer.tokenize(code)); const Token *tok = tokenizer.tokens(); // a[10] ASSERT_EQUALS(true, tok->linkAt(7) == tok->tokAt(9)); @@ -2945,9 +2941,8 @@ class TestTokenizer : public TestFixture { const char code[] = "void f(){\n" " foo(g());\n" "};"; - Tokenizer tokenizer(settings0, this); - std::istringstream istr(code); - ASSERT(tokenizer.tokenize(istr, "test.cpp")); + SimpleTokenizer tokenizer(settings0, *this); + ASSERT(tokenizer.tokenize(code)); const Token *tok = tokenizer.tokens(); // foo( ASSERT_EQUALS(true, tok->linkAt(6) == tok->tokAt(10)); @@ -2964,9 +2959,8 @@ class TestTokenizer : public TestFixture { const char code[] = "bool foo(C a, bar>& f, int b) {\n" " return(af);\n" "}"; - Tokenizer tokenizer(settings0, this); - std::istringstream istr(code); - ASSERT(tokenizer.tokenize(istr, "test.cpp")); + SimpleTokenizer tokenizer(settings0, *this); + ASSERT(tokenizer.tokenize(code)); const Token *tok = tokenizer.tokens(); // template< ASSERT_EQUALS(true, tok->tokAt(6) == tok->linkAt(4)); @@ -2991,9 +2985,8 @@ class TestTokenizer : public TestFixture { const char code[] = "void foo() {\n" " return static_cast(a);\n" "}"; - Tokenizer tokenizer(settings0, this); - std::istringstream istr(code); - ASSERT(tokenizer.tokenize(istr, "test.cpp")); + SimpleTokenizer tokenizer(settings0, *this); + ASSERT(tokenizer.tokenize(code)); const Token *tok = tokenizer.tokens(); // static_cast< @@ -3007,9 +3000,8 @@ class TestTokenizer : public TestFixture { const char code[] = "void foo() {\n" " nvwa<(x > y)> ERROR_nnn;\n" "}"; - Tokenizer tokenizer(settings0, this); - std::istringstream istr(code); - ASSERT(tokenizer.tokenize(istr, "test.cpp")); + SimpleTokenizer tokenizer(settings0, *this); + ASSERT(tokenizer.tokenize(code)); const Token *tok = tokenizer.tokens(); // nvwa<(x > y)> @@ -3022,9 +3014,8 @@ class TestTokenizer : public TestFixture { { // #4860 const char code[] = "class A : public B {};"; - Tokenizer tokenizer(settings0, this); - std::istringstream istr(code); - ASSERT(tokenizer.tokenize(istr, "test.cpp")); + SimpleTokenizer tokenizer(settings0, *this); + ASSERT(tokenizer.tokenize(code)); const Token *tok = tokenizer.tokens(); // B<..> @@ -3037,9 +3028,8 @@ class TestTokenizer : public TestFixture { { // #4860 const char code[] = "Bar>>>::set(1, 2, 3);"; - Tokenizer tokenizer(settings0, this); - std::istringstream istr(code); - ASSERT(tokenizer.tokenize(istr, "test.cpp")); + SimpleTokenizer tokenizer(settings0, *this); + ASSERT(tokenizer.tokenize(code)); const Token *tok = tokenizer.tokens(); ASSERT_EQUALS(true, tok->tokAt(1) == tok->linkAt(18)); @@ -3053,9 +3043,8 @@ class TestTokenizer : public TestFixture { { // #5627 const char code[] = "new Foo[10];"; - Tokenizer tokenizer(settings0, this); - std::istringstream istr(code); - ASSERT(tokenizer.tokenize(istr, "test.cpp")); + SimpleTokenizer tokenizer(settings0, *this); + ASSERT(tokenizer.tokenize(code)); const Token *tok = tokenizer.tokens(); ASSERT_EQUALS(true, tok->tokAt(2) == tok->linkAt(4)); @@ -3068,9 +3057,8 @@ class TestTokenizer : public TestFixture { { // #6242 const char code[] = "func = integral_;"; - Tokenizer tokenizer(settings0, this); - std::istringstream istr(code); - ASSERT(tokenizer.tokenize(istr, "test.cpp")); + SimpleTokenizer tokenizer(settings0, *this); + ASSERT(tokenizer.tokenize(code)); const Token *tok = tokenizer.tokens(); ASSERT_EQUALS(true, tok->tokAt(3) == tok->linkAt(9)); @@ -3082,9 +3070,8 @@ class TestTokenizer : public TestFixture { { // if (a < b || c > d) { } const char code[] = "{ if (a < b || c > d); }"; - Tokenizer tokenizer(settings0, this); - std::istringstream istr(code); - ASSERT(tokenizer.tokenize(istr, "test.cpp")); + SimpleTokenizer tokenizer(settings0, *this); + ASSERT(tokenizer.tokenize(code)); const Token *tok = tokenizer.tokens(); ASSERT_EQUALS(true, tok->linkAt(3) == nullptr); @@ -3093,9 +3080,8 @@ class TestTokenizer : public TestFixture { { // bool f = a < b || c > d const char code[] = "bool f = a < b || c > d;"; - Tokenizer tokenizer(settings0, this); - std::istringstream istr(code); - ASSERT(tokenizer.tokenize(istr, "test.cpp")); + SimpleTokenizer tokenizer(settings0, *this); + ASSERT(tokenizer.tokenize(code)); const Token *tok = tokenizer.tokens(); ASSERT_EQUALS(true, tok->linkAt(4) == nullptr); @@ -3104,9 +3090,8 @@ class TestTokenizer : public TestFixture { { // template const char code[] = "a < b || c > d;"; - Tokenizer tokenizer(settings0, this); - std::istringstream istr(code); - ASSERT(tokenizer.tokenize(istr, "test.cpp")); + SimpleTokenizer tokenizer(settings0, *this); + ASSERT(tokenizer.tokenize(code)); const Token *tok = tokenizer.tokens(); ASSERT_EQUALS(true, tok->linkAt(1) == tok->tokAt(5)); @@ -3115,9 +3100,8 @@ class TestTokenizer : public TestFixture { { // if (a < ... > d) { } const char code[] = "{ if (a < b || c == 3 || d > e); }"; - Tokenizer tokenizer(settings0, this); - std::istringstream istr(code); - ASSERT(tokenizer.tokenize(istr, "test.cpp")); + SimpleTokenizer tokenizer(settings0, *this); + ASSERT(tokenizer.tokenize(code)); const Token *tok = tokenizer.tokens(); ASSERT_EQUALS(true, tok->linkAt(3) == nullptr); @@ -3126,9 +3110,8 @@ class TestTokenizer : public TestFixture { { // template const char code[] = "a d;"; - Tokenizer tokenizer(settings0, this); - std::istringstream istr(code); - ASSERT(tokenizer.tokenize(istr, "test.cpp")); + SimpleTokenizer tokenizer(settings0, *this); + ASSERT(tokenizer.tokenize(code)); const Token *tok = tokenizer.tokens(); ASSERT_EQUALS(true, tok->linkAt(1) == tok->tokAt(7)); } @@ -3136,18 +3119,16 @@ class TestTokenizer : public TestFixture { { // template const char code[] = "a d;"; - Tokenizer tokenizer(settings0, this); - std::istringstream istr(code); - ASSERT(tokenizer.tokenize(istr, "test.cpp")); + SimpleTokenizer tokenizer(settings0, *this); + ASSERT(tokenizer.tokenize(code)); const Token *tok = tokenizer.tokens(); ASSERT_EQUALS(true, tok->linkAt(1) == tok->tokAt(7)); } { const char code[] = "template < f = b || c > struct S;"; - Tokenizer tokenizer(settings0, this); - std::istringstream istr(code); - ASSERT(tokenizer.tokenize(istr, "test.cpp")); + SimpleTokenizer tokenizer(settings0, *this); + ASSERT(tokenizer.tokenize(code)); const Token *tok = tokenizer.tokens(); ASSERT_EQUALS(true, tok->linkAt(1) == tok->tokAt(7)); ASSERT_EQUALS(true, tok->tokAt(1) == tok->linkAt(7)); @@ -3155,9 +3136,8 @@ class TestTokenizer : public TestFixture { { const char code[] = "struct A : B {};"; - Tokenizer tokenizer(settings0, this); - std::istringstream istr(code); - ASSERT(tokenizer.tokenize(istr, "test.cpp")); + SimpleTokenizer tokenizer(settings0, *this); + ASSERT(tokenizer.tokenize(code)); const Token *tok = tokenizer.tokens(); ASSERT_EQUALS(true, tok->linkAt(4) == tok->tokAt(8)); ASSERT_EQUALS(true, tok->tokAt(4) == tok->linkAt(8)); @@ -3165,9 +3145,8 @@ class TestTokenizer : public TestFixture { { const char code[] = "Data;"; - Tokenizer tokenizer(settings0, this); - std::istringstream istr(code); - ASSERT(tokenizer.tokenize(istr, "test.cpp")); + SimpleTokenizer tokenizer(settings0, *this); + ASSERT(tokenizer.tokenize(code)); const Token *tok = tokenizer.tokens(); ASSERT_EQUALS(true, tok->linkAt(1) == tok->tokAt(4)); ASSERT_EQUALS(true, tok->tokAt(1) == tok->linkAt(4)); @@ -3176,9 +3155,8 @@ class TestTokenizer : public TestFixture { { // #6601 const char code[] = "template struct FuncType : FuncType { };"; - Tokenizer tokenizer(settings0, this); - std::istringstream istr(code); - ASSERT(tokenizer.tokenize(istr, "test.cpp")); + SimpleTokenizer tokenizer(settings0, *this); + ASSERT(tokenizer.tokenize(code)); const Token *tok = tokenizer.tokens(); ASSERT_EQUALS(true, tok->linkAt(1) == tok->tokAt(4)); // @@ -3195,9 +3173,8 @@ class TestTokenizer : public TestFixture { { // #7158 const char code[] = "enum { value = boost::mpl::at_c };"; - Tokenizer tokenizer(settings0, this); - std::istringstream istr(code); - ASSERT(tokenizer.tokenize(istr, "test.cpp")); + SimpleTokenizer tokenizer(settings0, *this); + ASSERT(tokenizer.tokenize(code)); const Token *tok = Token::findsimplematch(tokenizer.tokens(), "<"); ASSERT_EQUALS(true, tok->link() == tok->tokAt(4)); ASSERT_EQUALS(true, tok->linkAt(4) == tok); @@ -3208,9 +3185,8 @@ class TestTokenizer : public TestFixture { const char code[] = "template \n" "struct CheckedDivOp< T, U, typename std::enable_if::value || std::is_floating_point::value>::type> {\n" "};\n"; - Tokenizer tokenizer(settings0, this); - std::istringstream istr(code); - ASSERT(tokenizer.tokenize(istr, "test.cpp")); + SimpleTokenizer tokenizer(settings0, *this); + ASSERT(tokenizer.tokenize(code)); const Token *tok1 = Token::findsimplematch(tokenizer.tokens(), "struct")->tokAt(2); const Token *tok2 = Token::findsimplematch(tokenizer.tokens(), "{")->previous(); ASSERT_EQUALS(true, tok1->link() == tok2); @@ -3220,9 +3196,8 @@ class TestTokenizer : public TestFixture { { // #7975 const char code[] = "template X copy() {};\n"; - Tokenizer tokenizer(settings0, this); - std::istringstream istr(code); - ASSERT(tokenizer.tokenize(istr, "test.cpp")); + SimpleTokenizer tokenizer(settings0, *this); + ASSERT(tokenizer.tokenize(code)); const Token *tok1 = Token::findsimplematch(tokenizer.tokens(), "< Y"); const Token *tok2 = Token::findsimplematch(tok1, "> copy"); ASSERT_EQUALS(true, tok1->link() == tok2); @@ -3232,9 +3207,8 @@ class TestTokenizer : public TestFixture { { // #8006 const char code[] = "C && a = b;"; - Tokenizer tokenizer(settings0, this); - std::istringstream istr(code); - ASSERT(tokenizer.tokenize(istr, "test.cpp")); + SimpleTokenizer tokenizer(settings0, *this); + ASSERT(tokenizer.tokenize(code)); const Token *tok1 = tokenizer.tokens()->next(); const Token *tok2 = tok1->tokAt(2); ASSERT_EQUALS(true, tok1->link() == tok2); @@ -3244,9 +3218,8 @@ class TestTokenizer : public TestFixture { { // #8115 const char code[] = "void Test(C && c);"; - Tokenizer tokenizer(settings0, this); - std::istringstream istr(code); - ASSERT(tokenizer.tokenize(istr, "test.cpp")); + SimpleTokenizer tokenizer(settings0, *this); + ASSERT(tokenizer.tokenize(code)); const Token *tok1 = Token::findsimplematch(tokenizer.tokens(), "<"); const Token *tok2 = tok1->tokAt(2); ASSERT_EQUALS(true, tok1->link() == tok2); @@ -3256,9 +3229,8 @@ class TestTokenizer : public TestFixture { // #8654 const char code[] = "template struct A {}; " "template struct foo : A... {};"; - Tokenizer tokenizer(settings0, this); - std::istringstream istr(code); - ASSERT(tokenizer.tokenize(istr, "test.cpp")); + SimpleTokenizer tokenizer(settings0, *this); + ASSERT(tokenizer.tokenize(code)); const Token *A = Token::findsimplematch(tokenizer.tokens(), "A <"); ASSERT_EQUALS(true, A->next()->link() == A->tokAt(3)); } @@ -3266,18 +3238,16 @@ class TestTokenizer : public TestFixture { // #8851 const char code[] = "template::type>" "void basic_json() {}"; - Tokenizer tokenizer(settings0, this); - std::istringstream istr(code); - ASSERT(tokenizer.tokenize(istr, "test.cpp")); + SimpleTokenizer tokenizer(settings0, *this); + ASSERT(tokenizer.tokenize(code)); ASSERT_EQUALS(true, Token::simpleMatch(tokenizer.tokens()->next()->link(), "> void")); } { // #9094 - template usage or comparison? const char code[] = "a = f(x%x<--a==x>x);"; - Tokenizer tokenizer(settings0, this); - std::istringstream istr(code); - ASSERT(tokenizer.tokenize(istr, "test.cpp")); + SimpleTokenizer tokenizer(settings0, *this); + ASSERT(tokenizer.tokenize(code)); ASSERT(nullptr == Token::findsimplematch(tokenizer.tokens(), "<")->link()); } @@ -3286,9 +3256,8 @@ class TestTokenizer : public TestFixture { const char code[] = "using std::same_as;\n" "template T>\n" "void f();"; - Tokenizer tokenizer(settings0, this); - std::istringstream istr(code); - ASSERT(tokenizer.tokenize(istr, "test.cpp")); + SimpleTokenizer tokenizer(settings0, *this); + ASSERT(tokenizer.tokenize(code)); const Token *tok1 = Token::findsimplematch(tokenizer.tokens(), "template <"); const Token *tok2 = Token ::findsimplematch(tokenizer.tokens(), "same_as <"); ASSERT(tok1->next()->link() == tok1->tokAt(7)); @@ -3298,9 +3267,8 @@ class TestTokenizer : public TestFixture { { // #9131 - template usage or comparison? const char code[] = "using std::list; list l;"; - Tokenizer tokenizer(settings0, this); - std::istringstream istr(code); - ASSERT(tokenizer.tokenize(istr, "test.cpp")); + SimpleTokenizer tokenizer(settings0, *this); + ASSERT(tokenizer.tokenize(code)); ASSERT(nullptr != Token::findsimplematch(tokenizer.tokens(), "<")->link()); } @@ -3310,9 +3278,8 @@ class TestTokenizer : public TestFixture { "{\n" " for (set::iterator i = sources.begin(); i != sources.end(); ++i) {}\n" "}"; - Tokenizer tokenizer(settings0, this); - std::istringstream istr(code); - ASSERT(tokenizer.tokenize(istr, "test.cpp")); + SimpleTokenizer tokenizer(settings0, *this); + ASSERT(tokenizer.tokenize(code)); ASSERT(nullptr != Token::findsimplematch(tokenizer.tokens(), "<")->link()); } @@ -3322,9 +3289,8 @@ class TestTokenizer : public TestFixture { " a<> b;\n" " b.a<>::c();\n" "}\n"; - Tokenizer tokenizer(settings0, this); - std::istringstream istr(code); - ASSERT(tokenizer.tokenize(istr, "test.cpp")); + SimpleTokenizer tokenizer(settings0, *this); + ASSERT(tokenizer.tokenize(code)); ASSERT(nullptr != Token::findsimplematch(tokenizer.tokens(), "> ::")->link()); } @@ -3334,9 +3300,8 @@ class TestTokenizer : public TestFixture { "template struct c {\n" " void d() { a[0]; }\n" "};\n"; - Tokenizer tokenizer(settings0, this); - std::istringstream istr(code); - ASSERT(tokenizer.tokenize(istr, "test.cpp")); + SimpleTokenizer tokenizer(settings0, *this); + ASSERT(tokenizer.tokenize(code)); ASSERT(nullptr != Token::findsimplematch(tokenizer.tokens(), "> [")->link()); } @@ -3347,9 +3312,8 @@ class TestTokenizer : public TestFixture { "template using f = c;\n" "template > struct g {};\n" "template using baz = g;\n"; - Tokenizer tokenizer(settings0, this); - std::istringstream istr(code); - ASSERT(tokenizer.tokenize(istr, "test.cpp")); + SimpleTokenizer tokenizer(settings0, *this); + ASSERT(tokenizer.tokenize(code)); ASSERT(nullptr != Token::findsimplematch(tokenizer.tokens(), "> ;")->link()); } @@ -3362,9 +3326,8 @@ class TestTokenizer : public TestFixture { "template using c = a;\n" "template c e;\n" "auto f = -e<1> == 0;\n"; - Tokenizer tokenizer(settings0, this); - std::istringstream istr(code); - ASSERT(tokenizer.tokenize(istr, "test.cpp")); + SimpleTokenizer tokenizer(settings0, *this); + ASSERT(tokenizer.tokenize(code)); ASSERT(nullptr != Token::findsimplematch(tokenizer.tokens(), "> ==")->link()); } @@ -3381,18 +3344,16 @@ class TestTokenizer : public TestFixture { "constexpr void b::operator()(c &&) const {\n" " i<3>.f([] {});\n" "}\n"; - Tokenizer tokenizer(settings0, this); - std::istringstream istr(code); - ASSERT(tokenizer.tokenize(istr, "test.cpp")); + SimpleTokenizer tokenizer(settings0, *this); + ASSERT(tokenizer.tokenize(code)); ASSERT(nullptr != Token::findsimplematch(tokenizer.tokens(), "> . f (")->link()); } { // #10491 const char code[] = "template