├── addons ├── __init__.py ├── test │ ├── __init__.py │ ├── misra │ │ ├── crash11.c │ │ ├── crash9.c │ │ ├── misra2012_rules_dummy_ascii.txt │ │ ├── crash1.c │ │ ├── misra2012_rules_dummy_windows1250.txt │ │ ├── misra2012_rules_dummy_utf8.txt │ │ ├── crash7.c │ │ ├── config1.c │ │ ├── crash8.c │ │ ├── crash10.c │ │ ├── crash4.c │ │ ├── crash2.c │ │ ├── crash_misra9_parseInitializer.c │ │ ├── crash6.c │ │ ├── suppressions.txt │ │ ├── misra_rules_empty_lines.txt │ │ ├── misra-test.h │ │ ├── misra_rules_structure.txt │ │ ├── misra_rules_multiple_lines.txt │ │ ├── misra_rules_dummy.txt │ │ ├── misra-test.cpp │ │ ├── crash12.c │ │ ├── crash5.c │ │ ├── misra-ctu-test.h │ │ ├── crash3.c │ │ ├── misra-suppressions2-test.c │ │ ├── misra-test-avr8.c │ │ ├── misra-test-c11.c │ │ └── misra-suppressions1-test.c │ ├── threadsafety │ │ ├── local_static.cpp │ │ └── local_static_const.cpp │ ├── naming_test.c │ ├── y2038 │ │ ├── y2038-test-5-good-no-time-used.c │ │ ├── y2038-test-4-good.c │ │ ├── y2038-test-2-no-time-bits.c │ │ ├── y2038-test-3-no-use-time-bits.c │ │ ├── y2038-test-1-bad-time-bits.c │ │ ├── y2038-inc.h │ │ └── y2038-test-compiler-flags.c │ ├── naming_test.cpp │ ├── path1 │ │ ├── misra-suppressions2-test.c │ │ └── misra-suppressions1-test.c │ └── misc-test.cpp ├── doc │ └── img │ │ └── cppcheck-gui-addons.png ├── namingng.json ├── runaddon.py ├── namingng.config.json ├── findcasts.py ├── ROS_naming.json └── cppcheck.py ├── lsan-suppr.txt ├── htmlreport ├── cppcheck_htmlreport │ └── __init__.py ├── requirements.txt ├── README.txt └── setup.py ├── test ├── cli │ ├── proj2 │ │ ├── b │ │ │ └── b.c │ │ ├── a │ │ │ └── a.c │ │ └── proj2.cppcheck │ ├── reanalysis │ │ ├── b.cpp │ │ ├── c.cpp │ │ ├── d.cpp │ │ └── a.cpp │ ├── proj-inline-suppress │ │ ├── 1.c │ │ ├── 1.h │ │ ├── 4.c │ │ ├── 2.c │ │ ├── misraUnmatched.c │ │ ├── duplicate.cpp │ │ ├── premiumUnmatched.cpp │ │ ├── cfg.c │ │ ├── unusedFunctionUnmatched.cpp │ │ ├── 3.cpp │ │ └── template.cpp │ ├── proj-suppress-syntaxError │ │ ├── 2.c │ │ ├── 3.c │ │ └── 1.c │ ├── fuzz-crash │ │ ├── crash-039028704ca27187fc3228e9fa01ca30a8434e7a │ │ ├── crash-1b9524a7fa25529c34c06b04372efd44e72ccfdc │ │ ├── crash-26edfe9761d3b681c841dfe80398847dee332f83 │ │ ├── crash-2cf8ffd04628a7c025bb07074462a51c1284dff0 │ │ ├── crash-78bcf47420424bf607f6697cf84ddd84b4dfbeb9 │ │ ├── crash-8a24e81ac1d7627233a227e6cc156dd20d57b058 │ │ ├── crash-9e4f80a23bc966f25e874df655f600478dca3b87 │ │ ├── crash-cb1d71440b24712fdf0bdcee43b9b3f1bc35c0d0 │ │ ├── crash-e000709d155e9c993795748ba31fddacbd5a86ac │ │ ├── crash-ee5250480d7bc4bed7520d96a50d8501632a8997 │ │ ├── leak-9543188fae87abc4409106e1918d6424efe0d68a │ │ ├── crash-0f0efd6e66bd115fc0aabbfe6503230b31de5f24 │ │ ├── crash-19219d7e7dfe8202248cd22229cdd9a2fd87a78a │ │ ├── crash-1bcbece2593792b0d34fb8f5dbacbae22decd082 │ │ ├── crash-20efd8856e04ca1fced9daa93837ae3384bb5e62 │ │ ├── crash-28733cc31fd7f5d636beeaa3fa2bc30779fc6487 │ │ ├── crash-3997cb1cad0af26035d36ca1a01ece07ca3fd114 │ │ ├── crash-43fe82a87d6a7f34f000cbbc90b63ad1a58e3dcd │ │ ├── crash-44b5d1f53328660cbcb6e90793eae2ff8ffc4893 │ │ ├── crash-522f048722bf5f33fa10a32a4c5253d1dc8b01d5 │ │ ├── crash-58e1517a74e314553e8eef249268cec29493235b │ │ ├── crash-5db88ae1610f5a9782ea78af206f9cd87b6708dd │ │ ├── crash-66bd8440a699d270b323367978dab020dd1da3ff │ │ ├── crash-772965250be2580c7c52f024c15fd5c8a9bb13c7 │ │ ├── crash-77a4e4ffd476997f06f67e4a18b5d4eedfa71900 │ │ ├── crash-82986578453ec2056069c70846571775b10dfbcb │ │ ├── crash-889549c7af3edaaf3e6e6f0783a42f4bcab7167e │ │ ├── crash-9a91d3da4e19336af500b94b2405831ed0fc1585 │ │ ├── crash-d6609399a4398aed92f5ac9e53aa0554d9f8bbd6 │ │ ├── crash-f158d32510f6eba5e1aa06ed8ef689b88da33a95 │ │ ├── crash-34c8d34fd4607de810d8d5bec881b40d37533181 │ │ ├── crash-68f8e0ba3d73255e879027ffd2dd39bf8cc34120 │ │ ├── crash-69570c88fc79e9a66ce2f2c729b455eaa237f3d2 │ │ ├── crash-7ead2ccf9be8b03b2d9c8c82891f58081390a560 │ │ ├── crash-81a29a4459dee76d10e452690f3e52fa0172852f │ │ ├── crash-8b9b108955146efbdae71f7167251da89d1e18c4 │ │ ├── crash-e4a26f2d7d0a73836bf086f54e48204d8914b95a │ │ ├── crash-0fc87af032255dddcea3248798a6e19ab49b231a │ │ ├── crash-15d71125ba17344f02417a9d46443cdaa30aa17f │ │ ├── crash-2490dbc1880f2d7883c1b634deee8da3805186f8 │ │ ├── crash-3275671bf6888060270f902458ff36c711718e22 │ │ ├── crash-3ea64296c8518edb538e0047c3eba0792d5deeba │ │ ├── crash-6eadb507c9ee93d9500028a9be2d183d1518f26b │ │ ├── crash-7bac85061edab7fdce2889f02ea3a044242a3920 │ │ ├── crash-8e34edab2458422d12e1b796686205a80760dbcb │ │ ├── crash-a431ec7f7379fc460eaa6284627091ded6c0d696 │ │ ├── crash-adb20a108c3686d79bc9bd0e4025445e3a35fa49 │ │ ├── crash-e6c12e56d9711d24fc9a4355e7d35fc23fbf0ff4 │ │ ├── crash-19269c327fd82c6db8f9f2b0c47c645a721ff55a │ │ ├── crash-2adde1da09b2db453c18898785b78024adb02c78 │ │ ├── crash-49338578888313fd087eb219d248c9aaf4ea9d0b │ │ ├── crash-4d4e80f09d4733a9f724282d60ee4e3c3a143b61 │ │ ├── crash-a76710eb5c80761456679c5be64482f1ef332556 │ │ ├── crash-c021b973c9f8692ff1ea73710209a4129dc7a834 │ │ ├── crash-faa56134676fb5d021ad69c8ac526d65debcfdb1 │ │ ├── crash-f4ec019b9a1f357d036a9bc3c2cb6fb10a0c3ded │ │ ├── crash-9ef938bba7d752386e24f2438c73cec66f6b972b │ │ └── crash-a3cfaec435c6df0f6c3cfc83f052abd42c75ba4d │ ├── unusedFunction │ │ ├── 3.h │ │ ├── 3.c │ │ ├── 1.c │ │ ├── 2.c │ │ ├── 4.c │ │ └── unusedFunction.cppcheck │ ├── whole-program │ │ ├── nullpointer1.cpp │ │ ├── odr_cfg2.cpp │ │ ├── odr_cfg1.cpp │ │ ├── whole2.c │ │ ├── nullpointer1_1.h │ │ ├── odr3.cpp │ │ ├── whole1.c │ │ ├── odr.h │ │ ├── nullpointer1.h │ │ ├── odr2.cpp │ │ └── odr1.cpp │ ├── fuzz-crash_c │ │ ├── crash-77c74a5f04704110ab5f71b753a623f2d28440bc │ │ ├── crash-85219ec46607233cec457b54a209ded59c333f46 │ │ ├── crash-dbd2b8fcc4fecd0b7bdde1f5938711075a35d242 │ │ ├── crash-7af21bec1d9be105742fdcb336514aae26ab4425 │ │ ├── crash-bbf4e88b43fa24873e63d39ab04ef8d3fd00e344 │ │ ├── crash-dd1289f81f5aaf90167595c5402e6cda2be505be │ │ └── crash-c43160a021f72643e229bb61306240d0dbf2c9bd │ ├── fuzz-timeout │ │ ├── timeout-0ee5eed9abd34e9d23640a5b82dd724affd05b79 │ │ ├── oom-0c8e70d5adb08986635b786737dbb5e6ac098f22 │ │ ├── oom-756ab636471bffa2430290f58776f1f6d8754ab1 │ │ ├── minimized-from-179e5b42a7b0ba41a088e7972bdb13dde18ef4d1 │ │ ├── timeout-98121de84d1c09fdfd3697cdedcdd69bf6abc15d │ │ ├── oom-e19261c78d73cf172308f6c33df68642dfd7b679 │ │ ├── timeout-a0b9848dd6e98677a0a96c5fc50ad571ed5a7092 │ │ ├── timeout-faa72062ab3f26df7305d72eed55a69f7f0dfbf0 │ │ ├── timeout-9598595ae3c480b58773e85cd4e4d52b1dc37038 │ │ ├── timeout-7795aa299fc0c2bafe3a152785d55b039d4f339c │ │ ├── timeout-90ec15c5629f957bf2d497bc9f60c57f252bd2ae │ │ └── timeout-8229bbbfcf6f3ab98a6c23bfb1421ffd611c3657 │ ├── QML-Samples-TableView │ │ ├── README │ │ ├── qml.qrc │ │ ├── TableColumn.qml │ │ ├── main.cpp │ │ ├── samplemodel.h │ │ ├── TableView.qml │ │ ├── TableRow.qml │ │ ├── TableView.pro │ │ └── main.qml │ ├── proj-inline-suppress-unusedFunction │ │ ├── A.cpp │ │ ├── B.hpp │ │ └── B.cpp │ ├── shared-items-project │ │ ├── Main │ │ │ └── MainFile.cpp │ │ └── Shared │ │ │ ├── TestClass.cpp │ │ │ ├── TestClass.h │ │ │ └── Shared.vcxitems │ ├── helloworld │ │ ├── main.c │ │ └── helloworld.cppcheck │ ├── trac5704 │ │ ├── trac5704b.c │ │ └── trac5704a.c │ └── readme.txt ├── tools │ ├── htmlreport │ │ ├── example-checkers.txt │ │ ├── example.cc │ │ ├── test_suppressions.txt │ │ └── example.xml │ └── donate_cpu_server_test.py ├── scripts │ ├── testrunnerify_code.sh │ ├── extract_and_run_more_tests.sh │ ├── testrunner-single.sh │ └── generate_and_run_more_tests.sh ├── seh │ └── CMakeLists.txt ├── .clang-tidy ├── cfg │ ├── mfc.cpp │ ├── cairo.c │ ├── lua.c │ ├── openmp.c │ └── libsigc++.cpp ├── precompiled.h └── testcolor.cpp ├── gui ├── test │ ├── data │ │ ├── files │ │ │ ├── bar1 │ │ │ ├── foo3.cc │ │ │ ├── foo4.c │ │ │ ├── bar1.foo │ │ │ ├── foo1.cpp │ │ │ ├── foo2.cxx │ │ │ ├── foo5.c++ │ │ │ ├── foo6.txx │ │ │ ├── foo7.tpp │ │ │ ├── foo8.ipp │ │ │ ├── foo9.ixx │ │ │ ├── dir1 │ │ │ │ ├── foo1.cpp │ │ │ │ └── dir11 │ │ │ │ │ └── foo11.cpp │ │ │ └── dir2 │ │ │ │ └── foo1.cpp │ │ └── projectfiles │ │ │ ├── simple_noroot.cppcheck │ │ │ ├── simple.cppcheck │ │ │ └── simple_ignore.cppcheck │ ├── cppchecklibrarydata │ │ ├── files │ │ │ ├── undefine_valid.cfg │ │ │ ├── define_valid.cfg │ │ │ ├── mandatory_attribute_missing.cfg │ │ │ ├── podtype_valid.cfg │ │ │ ├── reflection_mandatory_attribute_missing.cfg │ │ │ ├── xml_reader_error.cfg │ │ │ ├── unhandled_element.cfg │ │ │ ├── reflection_unhandled_element.cfg │ │ │ ├── reflection_valid.cfg │ │ │ ├── markup_mandatory_attribute_missing.cfg │ │ │ ├── platform_type_unhandled_element.cfg │ │ │ ├── smartptr_valid.cfg │ │ │ ├── container_valid.cfg │ │ │ ├── typechecks_valid.cfg │ │ │ ├── container_unhandled_element.cfg │ │ │ ├── platform_type_valid.cfg │ │ │ ├── memory_resource_unhandled_element.cfg │ │ │ ├── memory_resource_valid.cfg │ │ │ ├── markup_valid.cfg │ │ │ └── markup_unhandled_element.cfg │ │ └── resources.qrc │ ├── CMakeLists.txt │ ├── xmlreportv2 │ │ ├── testxmlreportv2.h │ │ └── CMakeLists.txt │ ├── translationhandler │ │ ├── testtranslationhandler.h │ │ └── CMakeLists.txt │ ├── filelist │ │ ├── CMakeLists.txt │ │ └── testfilelist.h │ ├── projectfile │ │ └── CMakeLists.txt │ └── resultstree │ │ └── testresultstree.h ├── cppcheck.ico ├── cppcheck-gui.png ├── images │ ├── go-down.png │ ├── go-home.png │ ├── go-next.png │ ├── edit-clear.png │ ├── go-previous.png │ ├── llvm-dragon.png │ ├── openproject.png │ ├── scratchpad.png │ ├── showerrors.png │ ├── dialog-error.png │ ├── help-browser.png │ ├── media-floppy.png │ ├── process-stop.png │ ├── showwarnings.png │ ├── view-recheck.png │ ├── view-refresh.png │ ├── dialog-warning.png │ ├── showperformance.png │ ├── text-x-generic.png │ ├── dialog-information.png │ ├── preferences-system.png │ ├── showstylewarnings.png │ ├── applications-system.png │ ├── applications-development.png │ └── utilities-system-monitor.png ├── help │ ├── images │ │ ├── index-mainwindow.png │ │ ├── severities-error.png │ │ ├── severities-style.png │ │ ├── severities-warning.png │ │ ├── walkthrough-analysis.png │ │ ├── walkthrough-library.png │ │ ├── severities-information.png │ │ ├── severities-performance.png │ │ ├── severities-portability.png │ │ ├── walkthrough-new-project.png │ │ ├── walkthrough-import-project.png │ │ ├── walkthrough-warning-menu.png │ │ └── walkthrough-toolbar-severities.png │ ├── index.html │ ├── online-help.qhcp │ ├── standalone-analysis.html │ ├── tagging.html │ └── investigating-warnings.html ├── .clang-tidy ├── cppcheck-gui.rc ├── cppcheck-gui.desktop ├── gui.cppcheck ├── manualtest │ └── mainwindow.md ├── precompiled_qmake.h ├── resultitem.cpp ├── application.cpp └── precompiled.h ├── tools ├── donate-cpu-requirements.txt ├── CMakeLists.txt ├── triage │ ├── .clang-tidy │ ├── triage.pro │ ├── main.cpp │ └── readme.txt ├── test │ ├── start_donate_cpu_client_test_local.sh │ ├── start_donate_cpu_client_productive.sh │ └── start_donate_cpu_server_test_local.sh ├── defines │ ├── run_cppcheck.sh │ ├── defines.sh │ ├── limits.c │ ├── readme.md │ ├── stdint.c │ └── float.c ├── dmake │ └── CMakeLists.txt ├── run-coverity.sh ├── listErrorsWithoutCWE.py ├── check-errorids.sh └── trac-keywords.py ├── codecov.yml ├── samples ├── syntaxError │ ├── bad.c │ ├── good.c │ └── out.txt ├── memleak │ ├── out.txt │ ├── bad.c │ └── good.c ├── incorrectLogicOperator │ ├── bad.c │ ├── good.c │ └── out.txt ├── resourceLeak │ ├── out.txt │ ├── bad.c │ └── good.c ├── arrayIndexOutOfBounds_1 │ ├── bad.c │ ├── good.c │ └── out.txt ├── bufferAccessOutOfBounds │ ├── bad.c │ ├── good.c │ └── out.txt ├── arrayIndexOutOfBounds_2 │ ├── bad.c │ ├── good.c │ └── out.txt ├── multiCondition │ ├── good.c │ ├── bad.c │ └── out.txt ├── autoVariables │ ├── out.txt │ ├── bad.c │ └── good.c ├── passedByValue_2 │ ├── bad.cpp │ ├── good.cpp │ └── out.txt ├── accessMoved │ ├── good.cpp │ ├── bad.cpp │ └── out.txt ├── unreadVariable │ ├── bad.cpp │ ├── good.cpp │ └── out.txt ├── AssignmentAddressToInteger │ ├── good.c │ ├── bad.c │ └── out.txt ├── passedByValue_1 │ ├── bad.cpp │ ├── good.cpp │ └── out.txt └── invalidContainer │ ├── bad.cpp │ └── good.cpp ├── man ├── images │ ├── gui-results.png │ ├── gui-newproject.png │ ├── gui-newproject-addons.png │ ├── gui-newproject-project.png │ └── gui-newproject-pathsanddefines.png ├── build-html.sh ├── CMakeLists.txt ├── buildman.sh ├── manual-style.tex ├── build-pdf.sh └── checkers │ └── dangerousTypeCast.md ├── snap └── gui │ ├── cppcheck-gui.png │ └── cppcheck-gui.desktop ├── win_installer ├── images │ ├── banner.jpg │ └── dialog.jpg ├── config.wxi ├── cppcheck.sln └── productInfo.wxi ├── requirements.txt ├── cfg ├── vcl.cfg ├── embedded_sql.cfg ├── dpdk.cfg ├── protobuf.cfg ├── microsoft_unittest.cfg └── tinyxml2.cfg ├── externals ├── picojson │ └── CMakeLists.txt ├── .clang-tidy ├── simplecpp │ ├── CMakeLists.txt │ └── LICENSE ├── pcre.patch └── tinyxml2 │ ├── LICENSE │ └── CMakeLists.txt ├── .codacy.yml ├── frontend └── CMakeLists.txt ├── naming.json ├── cmake ├── buildFiles.cmake ├── cxx11.cmake ├── versions.cmake ├── qtCompat.cmake ├── compilerCheck.cmake └── cmake_uninstall.cmake.in ├── releasenotes.txt ├── rules ├── empty-catch-block.xml ├── show-all-defines.rule ├── unused-deref.xml ├── strlen-empty-str.xml ├── stl.xml └── suggest_nullptr.xml ├── .selfcheck_unused_suppressions ├── valgrind └── testrunner.supp ├── platforms ├── avr8.xml ├── mips32.xml ├── pic16.xml ├── pic8.xml ├── aix_ppc64.xml ├── cray_sv1.xml ├── arm32-wchar_t2.xml ├── arm32-wchar_t4.xml ├── arm64-wchar_t2.xml ├── arm64-wchar_t4.xml ├── elbrus-e1cp.xml ├── pic8-enhanced.xml ├── msp430_eabi_large_datamodel.xml └── cppcheck-platforms.rng ├── .gitattributes ├── webreport.sh ├── generate_coverage_report ├── cppcheck.cppcheck ├── democlient └── build.sh ├── oss-fuzz └── type2.h ├── cli ├── precompiled.h ├── version.rc ├── signalhandler.h └── cmdlinelogger.h ├── lib ├── version.rc ├── version.h ├── precompiled.h ├── reverseanalyzer.h ├── vf_settokenvalue.h ├── clangimport.h └── keywords.h └── .github └── workflows └── cifuzz.yml /addons/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /addons/test/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /lsan-suppr.txt: -------------------------------------------------------------------------------- 1 | leak:libpcre.so -------------------------------------------------------------------------------- /htmlreport/cppcheck_htmlreport/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /htmlreport/requirements.txt: -------------------------------------------------------------------------------- 1 | Pygments 2 | -------------------------------------------------------------------------------- /test/cli/proj2/b/b.c: -------------------------------------------------------------------------------- 1 | x = 3 / 0; 2 | 3 | -------------------------------------------------------------------------------- /gui/test/data/files/bar1: -------------------------------------------------------------------------------- 1 | Dummy test file. 2 | -------------------------------------------------------------------------------- /gui/test/data/files/foo3.cc: -------------------------------------------------------------------------------- 1 | Dummy test file. 2 | -------------------------------------------------------------------------------- /gui/test/data/files/foo4.c: -------------------------------------------------------------------------------- 1 | Dummy test file . 2 | -------------------------------------------------------------------------------- /test/cli/reanalysis/b.cpp: -------------------------------------------------------------------------------- 1 | int main() {} 2 | 3 | -------------------------------------------------------------------------------- /test/cli/reanalysis/c.cpp: -------------------------------------------------------------------------------- 1 | int main() {} 2 | 3 | -------------------------------------------------------------------------------- /test/cli/reanalysis/d.cpp: -------------------------------------------------------------------------------- 1 | int main() {} 2 | 3 | -------------------------------------------------------------------------------- /addons/test/misra/crash11.c: -------------------------------------------------------------------------------- 1 | // #12651 2 | __arm__ 3 | -------------------------------------------------------------------------------- /gui/test/data/files/bar1.foo: -------------------------------------------------------------------------------- 1 | Dummy test file. 2 | -------------------------------------------------------------------------------- /gui/test/data/files/foo1.cpp: -------------------------------------------------------------------------------- 1 | Dummy test file . 2 | -------------------------------------------------------------------------------- /gui/test/data/files/foo2.cxx: -------------------------------------------------------------------------------- 1 | Dummy test file. 2 | -------------------------------------------------------------------------------- /gui/test/data/files/foo5.c++: -------------------------------------------------------------------------------- 1 | Dummy test file. 2 | -------------------------------------------------------------------------------- /gui/test/data/files/foo6.txx: -------------------------------------------------------------------------------- 1 | Dummy test file. 2 | -------------------------------------------------------------------------------- /gui/test/data/files/foo7.tpp: -------------------------------------------------------------------------------- 1 | Dummy test file. 2 | -------------------------------------------------------------------------------- /gui/test/data/files/foo8.ipp: -------------------------------------------------------------------------------- 1 | Dummy test file. 2 | -------------------------------------------------------------------------------- /gui/test/data/files/foo9.ixx: -------------------------------------------------------------------------------- 1 | Dummy test file. 2 | -------------------------------------------------------------------------------- /test/cli/proj-inline-suppress/1.c: -------------------------------------------------------------------------------- 1 | #include <1.h> 2 | -------------------------------------------------------------------------------- /test/cli/proj-suppress-syntaxError/2.c: -------------------------------------------------------------------------------- 1 | void f1(); 2 | -------------------------------------------------------------------------------- /gui/test/data/files/dir1/foo1.cpp: -------------------------------------------------------------------------------- 1 | Dummy test file . 2 | -------------------------------------------------------------------------------- /gui/test/data/files/dir2/foo1.cpp: -------------------------------------------------------------------------------- 1 | Dummy test file . 2 | -------------------------------------------------------------------------------- /test/cli/proj-suppress-syntaxError/3.c: -------------------------------------------------------------------------------- 1 | 2 | void f2(); 3 | -------------------------------------------------------------------------------- /tools/donate-cpu-requirements.txt: -------------------------------------------------------------------------------- 1 | psutil 2 | packaging 3 | -------------------------------------------------------------------------------- /gui/test/data/files/dir1/dir11/foo11.cpp: -------------------------------------------------------------------------------- 1 | Dummy test file . 2 | -------------------------------------------------------------------------------- /test/cli/fuzz-crash/crash-039028704ca27187fc3228e9fa01ca30a8434e7a: -------------------------------------------------------------------------------- 1 | _ 1p; -------------------------------------------------------------------------------- /test/cli/fuzz-crash/crash-1b9524a7fa25529c34c06b04372efd44e72ccfdc: -------------------------------------------------------------------------------- 1 | (h l).h -------------------------------------------------------------------------------- /test/cli/fuzz-crash/crash-26edfe9761d3b681c841dfe80398847dee332f83: -------------------------------------------------------------------------------- 1 | []e -------------------------------------------------------------------------------- /test/cli/fuzz-crash/crash-cb1d71440b24712fdf0bdcee43b9b3f1bc35c0d0: -------------------------------------------------------------------------------- 1 | (n@()###); -------------------------------------------------------------------------------- /test/cli/fuzz-crash/crash-e000709d155e9c993795748ba31fddacbd5a86ac: -------------------------------------------------------------------------------- 1 | {for(()s)} -------------------------------------------------------------------------------- /test/cli/fuzz-crash/crash-ee5250480d7bc4bed7520d96a50d8501632a8997: -------------------------------------------------------------------------------- 1 | $(){using} -------------------------------------------------------------------------------- /test/cli/fuzz-crash/leak-9543188fae87abc4409106e1918d6424efe0d68a: -------------------------------------------------------------------------------- 1 | v f(*){e=t&&} -------------------------------------------------------------------------------- /test/cli/fuzz-crash_c/crash-77c74a5f04704110ab5f71b753a623f2d28440bc: -------------------------------------------------------------------------------- 1 | class r::_ -------------------------------------------------------------------------------- /test/cli/fuzz-timeout/timeout-0ee5eed9abd34e9d23640a5b82dd724affd05b79: -------------------------------------------------------------------------------- 1 | ;new t() -------------------------------------------------------------------------------- /test/cli/whole-program/odr_cfg1.cpp: -------------------------------------------------------------------------------- 1 | #ifdef X 2 | struct S {}; 3 | #endif 4 | -------------------------------------------------------------------------------- /gui/cppcheck.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danmar/cppcheck/HEAD/gui/cppcheck.ico -------------------------------------------------------------------------------- /test/cli/fuzz-crash/crash-0f0efd6e66bd115fc0aabbfe6503230b31de5f24: -------------------------------------------------------------------------------- 1 | d f(t*a){a[a[3]]} -------------------------------------------------------------------------------- /test/cli/fuzz-crash/crash-19219d7e7dfe8202248cd22229cdd9a2fd87a78a: -------------------------------------------------------------------------------- 1 | n::template u -------------------------------------------------------------------------------- /test/cli/fuzz-crash/crash-1bcbece2593792b0d34fb8f5dbacbae22decd082: -------------------------------------------------------------------------------- 1 | enum{A=0()7=F}; -------------------------------------------------------------------------------- /test/cli/fuzz-crash/crash-20efd8856e04ca1fced9daa93837ae3384bb5e62: -------------------------------------------------------------------------------- 1 | assert({:=;}) -------------------------------------------------------------------------------- /test/cli/fuzz-crash/crash-28733cc31fd7f5d636beeaa3fa2bc30779fc6487: -------------------------------------------------------------------------------- 1 | assert({:=4;}) -------------------------------------------------------------------------------- /test/cli/fuzz-crash/crash-3997cb1cad0af26035d36ca1a01ece07ca3fd114: -------------------------------------------------------------------------------- 1 | b=1;t o(){& &&&} -------------------------------------------------------------------------------- /test/cli/fuzz-crash/crash-43fe82a87d6a7f34f000cbbc90b63ad1a58e3dcd: -------------------------------------------------------------------------------- 1 | d o(){t&a=*&a} -------------------------------------------------------------------------------- /test/cli/fuzz-crash/crash-44b5d1f53328660cbcb6e90793eae2ff8ffc4893: -------------------------------------------------------------------------------- 1 | typedef q r[];r A -------------------------------------------------------------------------------- /test/cli/fuzz-crash/crash-522f048722bf5f33fa10a32a4c5253d1dc8b01d5: -------------------------------------------------------------------------------- 1 | C(){o y=>::*} -------------------------------------------------------------------------------- /test/cli/fuzz-crash/crash-58e1517a74e314553e8eef249268cec29493235b: -------------------------------------------------------------------------------- 1 | n a(){!!=!!?:b} -------------------------------------------------------------------------------- /test/cli/fuzz-crash/crash-5db88ae1610f5a9782ea78af206f9cd87b6708dd: -------------------------------------------------------------------------------- 1 | {for(typedef;);} -------------------------------------------------------------------------------- /test/cli/fuzz-crash/crash-66bd8440a699d270b323367978dab020dd1da3ff: -------------------------------------------------------------------------------- 1 | enum{C={;}=e}; -------------------------------------------------------------------------------- /test/cli/fuzz-crash/crash-772965250be2580c7c52f024c15fd5c8a9bb13c7: -------------------------------------------------------------------------------- 1 | enum{C=e;=U}; -------------------------------------------------------------------------------- /test/cli/fuzz-crash/crash-77a4e4ffd476997f06f67e4a18b5d4eedfa71900: -------------------------------------------------------------------------------- 1 | n i(){t i=0-::-t} -------------------------------------------------------------------------------- /test/cli/fuzz-crash/crash-82986578453ec2056069c70846571775b10dfbcb: -------------------------------------------------------------------------------- 1 | namespace d=S -------------------------------------------------------------------------------- /test/cli/fuzz-crash/crash-889549c7af3edaaf3e6e6f0783a42f4bcab7167e: -------------------------------------------------------------------------------- 1 | {enum{A=s()0=s};} -------------------------------------------------------------------------------- /test/cli/fuzz-crash/crash-9a91d3da4e19336af500b94b2405831ed0fc1585: -------------------------------------------------------------------------------- 1 | template<>>a{} -------------------------------------------------------------------------------- /test/cli/fuzz-crash/crash-d6609399a4398aed92f5ac9e53aa0554d9f8bbd6: -------------------------------------------------------------------------------- 1 | _(){w((char)=e)} -------------------------------------------------------------------------------- /test/cli/fuzz-crash/crash-f158d32510f6eba5e1aa06ed8ef689b88da33a95: -------------------------------------------------------------------------------- 1 | enum{a=1{}=d}; -------------------------------------------------------------------------------- /test/cli/fuzz-crash_c/crash-85219ec46607233cec457b54a209ded59c333f46: -------------------------------------------------------------------------------- 1 | n(){o?5:t++m} -------------------------------------------------------------------------------- /test/cli/fuzz-crash_c/crash-dbd2b8fcc4fecd0b7bdde1f5938711075a35d242: -------------------------------------------------------------------------------- 1 | {assert({f=a})} -------------------------------------------------------------------------------- /test/cli/proj2/a/a.c: -------------------------------------------------------------------------------- 1 | x = 3 / 0; 2 | #ifdef AAA 3 | void aa; 4 | #endif 5 | 6 | -------------------------------------------------------------------------------- /test/cli/unusedFunction/3.c: -------------------------------------------------------------------------------- 1 | void f3_1() {} 2 | void f3_2() {} 3 | void f3_3() {} -------------------------------------------------------------------------------- /addons/test/misra/crash9.c: -------------------------------------------------------------------------------- 1 | 2 | #line 3 "" 3 | typedef int8_t flex_int8_t; 4 | -------------------------------------------------------------------------------- /test/cli/fuzz-crash/crash-34c8d34fd4607de810d8d5bec881b40d37533181: -------------------------------------------------------------------------------- 1 | te=c>n -------------------------------------------------------------------------------- /test/cli/fuzz-crash/crash-68f8e0ba3d73255e879027ffd2dd39bf8cc34120: -------------------------------------------------------------------------------- 1 | v f(){B?1::s:t} 2 | -------------------------------------------------------------------------------- /test/cli/fuzz-crash/crash-69570c88fc79e9a66ce2f2c729b455eaa237f3d2: -------------------------------------------------------------------------------- 1 | o oo(){extern oo();} -------------------------------------------------------------------------------- /test/cli/fuzz-crash/crash-7ead2ccf9be8b03b2d9c8c82891f58081390a560: -------------------------------------------------------------------------------- 1 | n m(){int a[];a=[]} -------------------------------------------------------------------------------- /test/cli/fuzz-crash/crash-81a29a4459dee76d10e452690f3e52fa0172852f: -------------------------------------------------------------------------------- 1 | {s for(typedef:;){}} -------------------------------------------------------------------------------- /test/cli/fuzz-crash/crash-8b9b108955146efbdae71f7167251da89d1e18c4: -------------------------------------------------------------------------------- 1 | {enum{A=s(u)0=s};} -------------------------------------------------------------------------------- /test/cli/fuzz-crash/crash-e4a26f2d7d0a73836bf086f54e48204d8914b95a: -------------------------------------------------------------------------------- 1 | t i(){for(;;f&++)} -------------------------------------------------------------------------------- /test/cli/fuzz-crash_c/crash-7af21bec1d9be105742fdcb336514aae26ab4425: -------------------------------------------------------------------------------- 1 | i 2 | class q::_ -------------------------------------------------------------------------------- /test/cli/fuzz-timeout/oom-0c8e70d5adb08986635b786737dbb5e6ac098f22: -------------------------------------------------------------------------------- 1 | template<8<>e=e<>>f -------------------------------------------------------------------------------- /test/cli/fuzz-timeout/oom-756ab636471bffa2430290f58776f1f6d8754ab1: -------------------------------------------------------------------------------- 1 | template< <>t=t<>>d -------------------------------------------------------------------------------- /codecov.yml: -------------------------------------------------------------------------------- 1 | comment: false 2 | coverage: 3 | status: 4 | project: off 5 | patch: off -------------------------------------------------------------------------------- /gui/cppcheck-gui.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danmar/cppcheck/HEAD/gui/cppcheck-gui.png -------------------------------------------------------------------------------- /test/cli/fuzz-crash/crash-0fc87af032255dddcea3248798a6e19ab49b231a: -------------------------------------------------------------------------------- 1 | {template<~>tu<0>}tu=ctu< <>tu=e -------------------------------------------------------------------------------- /test/cli/fuzz-crash/crash-e6c12e56d9711d24fc9a4355e7d35fc23fbf0ff4: -------------------------------------------------------------------------------- 1 | struct B{o a;B<>{0,{}}} -------------------------------------------------------------------------------- /test/cli/fuzz-crash_c/crash-bbf4e88b43fa24873e63d39ab04ef8d3fd00e344: -------------------------------------------------------------------------------- 1 | f(){int a[5];memset(a,5)} -------------------------------------------------------------------------------- /test/cli/fuzz-crash_c/crash-dd1289f81f5aaf90167595c5402e6cda2be505be: -------------------------------------------------------------------------------- 1 | d(){A a;n=do{}while(N)t} -------------------------------------------------------------------------------- /test/cli/fuzz-timeout/minimized-from-179e5b42a7b0ba41a088e7972bdb13dde18ef4d1: -------------------------------------------------------------------------------- 1 | d f(*){*:b&&} -------------------------------------------------------------------------------- /test/cli/fuzz-timeout/timeout-98121de84d1c09fdfd3697cdedcdd69bf6abc15d: -------------------------------------------------------------------------------- 1 | typedef static i i,n.i -------------------------------------------------------------------------------- /gui/images/go-down.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danmar/cppcheck/HEAD/gui/images/go-down.png -------------------------------------------------------------------------------- /gui/images/go-home.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danmar/cppcheck/HEAD/gui/images/go-home.png -------------------------------------------------------------------------------- /gui/images/go-next.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danmar/cppcheck/HEAD/gui/images/go-next.png -------------------------------------------------------------------------------- /samples/syntaxError/bad.c: -------------------------------------------------------------------------------- 1 | int main() 2 | { 3 | return 0; 4 | #ifdef A 5 | } 6 | #endif 7 | -------------------------------------------------------------------------------- /samples/syntaxError/good.c: -------------------------------------------------------------------------------- 1 | int main() 2 | { 3 | #ifndef A 4 | #endif 5 | return 0; 6 | } 7 | -------------------------------------------------------------------------------- /test/cli/fuzz-crash/crash-19269c327fd82c6db8f9f2b0c47c645a721ff55a: -------------------------------------------------------------------------------- 1 | n eu<#F A<>;template<#m<>eu=i -------------------------------------------------------------------------------- /test/cli/fuzz-crash/crash-2adde1da09b2db453c18898785b78024adb02c78: -------------------------------------------------------------------------------- 1 | S namespace d=S;e namespace d=a -------------------------------------------------------------------------------- /test/cli/fuzz-crash/crash-49338578888313fd087eb219d248c9aaf4ea9d0b: -------------------------------------------------------------------------------- 1 | ;namespace d=S;r namespace d=X -------------------------------------------------------------------------------- /test/cli/fuzz-crash/crash-4d4e80f09d4733a9f724282d60ee4e3c3a143b61: -------------------------------------------------------------------------------- 1 | d o(i*a){n b;*a=&b;if(a)r{}} -------------------------------------------------------------------------------- /test/cli/fuzz-crash/crash-a76710eb5c80761456679c5be64482f1ef332556: -------------------------------------------------------------------------------- 1 | i n(){$ i;f a;for(i:++)a=[]i;} -------------------------------------------------------------------------------- /test/cli/fuzz-crash/crash-c021b973c9f8692ff1ea73710209a4129dc7a834: -------------------------------------------------------------------------------- 1 | typedef const C;C(public Ctu<2>tu= 2 | void g(T* p) { 3 | *p = 0; 4 | }; 5 | -------------------------------------------------------------------------------- /gui/images/dialog-warning.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danmar/cppcheck/HEAD/gui/images/dialog-warning.png -------------------------------------------------------------------------------- /gui/images/showperformance.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danmar/cppcheck/HEAD/gui/images/showperformance.png -------------------------------------------------------------------------------- /gui/images/text-x-generic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danmar/cppcheck/HEAD/gui/images/text-x-generic.png -------------------------------------------------------------------------------- /man/images/gui-newproject.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danmar/cppcheck/HEAD/man/images/gui-newproject.png -------------------------------------------------------------------------------- /test/cli/QML-Samples-TableView/README: -------------------------------------------------------------------------------- 1 | Downloaded from here: 2 | https://github.com/HamedMasafi/QML-Samples 3 | -------------------------------------------------------------------------------- /test/cli/fuzz-crash/crash-9ef938bba7d752386e24f2438c73cec66f6b972b: -------------------------------------------------------------------------------- 1 | o n(){r<>items;t iter;for(&&){iter=items.g}} -------------------------------------------------------------------------------- /test/cli/fuzz-timeout/timeout-faa72062ab3f26df7305d72eed55a69f7f0dfbf0: -------------------------------------------------------------------------------- 1 | typedef q k k k q,q k,q,k,q,k,q k,q,k,q,k,; -------------------------------------------------------------------------------- /test/cli/proj-inline-suppress/1.h: -------------------------------------------------------------------------------- 1 | 2 | // cppcheck-suppress zerodiv 3 | const int x = 10000 / 0; 4 | 5 | 6 | -------------------------------------------------------------------------------- /win_installer/images/banner.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danmar/cppcheck/HEAD/win_installer/images/banner.jpg -------------------------------------------------------------------------------- /win_installer/images/dialog.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danmar/cppcheck/HEAD/win_installer/images/dialog.jpg -------------------------------------------------------------------------------- /gui/images/dialog-information.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danmar/cppcheck/HEAD/gui/images/dialog-information.png -------------------------------------------------------------------------------- /gui/images/preferences-system.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danmar/cppcheck/HEAD/gui/images/preferences-system.png -------------------------------------------------------------------------------- /gui/images/showstylewarnings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danmar/cppcheck/HEAD/gui/images/showstylewarnings.png -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | pcre,pfultz2/pcre@8.45 -H sha256:d6f7182602a775a7d500a0cedca6449af0400c6493951513046d17615ed0bf11 2 | -------------------------------------------------------------------------------- /test/cli/fuzz-crash/crash-a3cfaec435c6df0f6c3cfc83f052abd42c75ba4d: -------------------------------------------------------------------------------- 1 | typedef C();typedef const C*(*func2)();d(func2()) -------------------------------------------------------------------------------- /test/cli/fuzz-timeout/timeout-9598595ae3c480b58773e85cd4e4d52b1dc37038: -------------------------------------------------------------------------------- 1 | i f(n*a){n b=0;*a=b;%*a=b;--------------------b} -------------------------------------------------------------------------------- /test/tools/htmlreport/example.cc: -------------------------------------------------------------------------------- 1 | #include "missing.h" 2 | 3 | int main() 4 | { 5 | int x; 6 | x++; 7 | } 8 | -------------------------------------------------------------------------------- /cfg/vcl.cfg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /gui/help/images/index-mainwindow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danmar/cppcheck/HEAD/gui/help/images/index-mainwindow.png -------------------------------------------------------------------------------- /gui/help/images/severities-error.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danmar/cppcheck/HEAD/gui/help/images/severities-error.png -------------------------------------------------------------------------------- /gui/help/images/severities-style.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danmar/cppcheck/HEAD/gui/help/images/severities-style.png -------------------------------------------------------------------------------- /gui/images/applications-system.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danmar/cppcheck/HEAD/gui/images/applications-system.png -------------------------------------------------------------------------------- /man/images/gui-newproject-addons.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danmar/cppcheck/HEAD/man/images/gui-newproject-addons.png -------------------------------------------------------------------------------- /samples/memleak/out.txt: -------------------------------------------------------------------------------- 1 | samples\memleak\bad.c:10:5: error: Memory leak: a [memleak] 2 | return result; 3 | ^ 4 | -------------------------------------------------------------------------------- /test/cli/whole-program/odr3.cpp: -------------------------------------------------------------------------------- 1 | // #10431 2 | #ifdef X 3 | struct S { S() {} }; 4 | #else 5 | struct S {}; 6 | #endif 7 | -------------------------------------------------------------------------------- /addons/doc/img/cppcheck-gui-addons.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danmar/cppcheck/HEAD/addons/doc/img/cppcheck-gui-addons.png -------------------------------------------------------------------------------- /gui/help/images/severities-warning.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danmar/cppcheck/HEAD/gui/help/images/severities-warning.png -------------------------------------------------------------------------------- /man/images/gui-newproject-project.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danmar/cppcheck/HEAD/man/images/gui-newproject-project.png -------------------------------------------------------------------------------- /test/cli/fuzz-timeout/timeout-7795aa299fc0c2bafe3a152785d55b039d4f339c: -------------------------------------------------------------------------------- 1 | e<>(){F+0+0+++++++++++++++++++++++++++++++++++++++++5;} -------------------------------------------------------------------------------- /test/cli/unusedFunction/1.c: -------------------------------------------------------------------------------- 1 | #include "3.h" 2 | 3 | // cppcheck-suppress unusedFunction 4 | void f1() 5 | { 6 | f3_1(); 7 | } -------------------------------------------------------------------------------- /test/cli/unusedFunction/2.c: -------------------------------------------------------------------------------- 1 | #include "3.h" 2 | 3 | // cppcheck-suppress unusedFunction 4 | void f2() 5 | { 6 | f3_2(); 7 | } -------------------------------------------------------------------------------- /gui/help/images/walkthrough-analysis.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danmar/cppcheck/HEAD/gui/help/images/walkthrough-analysis.png -------------------------------------------------------------------------------- /gui/help/images/walkthrough-library.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danmar/cppcheck/HEAD/gui/help/images/walkthrough-library.png -------------------------------------------------------------------------------- /gui/images/applications-development.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danmar/cppcheck/HEAD/gui/images/applications-development.png -------------------------------------------------------------------------------- /gui/images/utilities-system-monitor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danmar/cppcheck/HEAD/gui/images/utilities-system-monitor.png -------------------------------------------------------------------------------- /man/build-html.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | echo Building $1.html 3 | pandoc $1.md -o $1.html -s --number-sections --toc --css manual.css 4 | -------------------------------------------------------------------------------- /samples/incorrectLogicOperator/bad.c: -------------------------------------------------------------------------------- 1 | 2 | static void foo(int x) { 3 | if (x >= 0 || x <= 10) {} 4 | } 5 | 6 | dummy=foo(); 7 | -------------------------------------------------------------------------------- /samples/incorrectLogicOperator/good.c: -------------------------------------------------------------------------------- 1 | 2 | static void foo(int x) { 3 | if (x >= 0 && x <= 10) {} 4 | } 5 | 6 | dummy=foo(); 7 | -------------------------------------------------------------------------------- /samples/resourceLeak/out.txt: -------------------------------------------------------------------------------- 1 | samples\resourceLeak\bad.c:8:5: error: Resource leak: a [resourceLeak] 2 | return 0; 3 | ^ 4 | -------------------------------------------------------------------------------- /samples/syntaxError/out.txt: -------------------------------------------------------------------------------- 1 | samples\syntaxError\bad.c:2:1: error: Unmatched '{'. Configuration: ''. [syntaxError] 2 | { 3 | ^ 4 | -------------------------------------------------------------------------------- /gui/help/images/severities-information.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danmar/cppcheck/HEAD/gui/help/images/severities-information.png -------------------------------------------------------------------------------- /gui/help/images/severities-performance.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danmar/cppcheck/HEAD/gui/help/images/severities-performance.png -------------------------------------------------------------------------------- /gui/help/images/severities-portability.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danmar/cppcheck/HEAD/gui/help/images/severities-portability.png -------------------------------------------------------------------------------- /gui/help/images/walkthrough-new-project.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danmar/cppcheck/HEAD/gui/help/images/walkthrough-new-project.png -------------------------------------------------------------------------------- /test/cli/proj-inline-suppress-unusedFunction/A.cpp: -------------------------------------------------------------------------------- 1 | #include "B.hpp" 2 | 3 | int main() 4 | { 5 | B b(); 6 | return 0; 7 | } 8 | -------------------------------------------------------------------------------- /test/cli/unusedFunction/4.c: -------------------------------------------------------------------------------- 1 | static void f4_0() {} 2 | 3 | // cppcheck-suppress unusedFunction 4 | void f4_1() 5 | { 6 | f4_0(); 7 | } -------------------------------------------------------------------------------- /test/cli/whole-program/whole1.c: -------------------------------------------------------------------------------- 1 | // cppcheck-suppress misra-c2012-8.4 2 | // cppcheck-suppress misra-c2012-5.8 3 | int misra_5_8_var1; 4 | -------------------------------------------------------------------------------- /test/scripts/testrunnerify_code.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | sed s@\"@\\\\\"@g | sed s@^@\"@ $1 | sed s@\$@\\\\n\"@ | sed 's@\t@ @g' 4 | -------------------------------------------------------------------------------- /addons/namingng.json: -------------------------------------------------------------------------------- 1 | { 2 | "script":"namingng.py", 3 | "args":[ 4 | "--configfile=namingng.config.json" 5 | ] 6 | } 7 | -------------------------------------------------------------------------------- /externals/picojson/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | add_library(picojson INTERFACE) 3 | target_externals_include_directories(picojson INTERFACE .) 4 | 5 | -------------------------------------------------------------------------------- /gui/help/images/walkthrough-import-project.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danmar/cppcheck/HEAD/gui/help/images/walkthrough-import-project.png -------------------------------------------------------------------------------- /gui/help/images/walkthrough-warning-menu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danmar/cppcheck/HEAD/gui/help/images/walkthrough-warning-menu.png -------------------------------------------------------------------------------- /man/images/gui-newproject-pathsanddefines.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danmar/cppcheck/HEAD/man/images/gui-newproject-pathsanddefines.png -------------------------------------------------------------------------------- /test/cli/proj-inline-suppress-unusedFunction/B.hpp: -------------------------------------------------------------------------------- 1 | class B { 2 | public: 3 | B(); 4 | 5 | static void unusedFunctionTest(); 6 | }; 7 | -------------------------------------------------------------------------------- /test/cli/proj-inline-suppress/4.c: -------------------------------------------------------------------------------- 1 | int main() { 2 | // cppcheck-suppress unreadVariable 3 | int i = 0; 4 | return 0; 5 | } 6 | 7 | -------------------------------------------------------------------------------- /cfg/embedded_sql.cfg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /test/cli/fuzz-timeout/timeout-90ec15c5629f957bf2d497bc9f60c57f252bd2ae: -------------------------------------------------------------------------------- 1 | ama typedef f m ef ef dz e dz e e ef ef m ef dz e,,,,m ef dz e,,,,,K -------------------------------------------------------------------------------- /test/cli/proj-inline-suppress/2.c: -------------------------------------------------------------------------------- 1 | // cppcheck-suppress some_warning_id ; there should be a unmatchedSuppression warning about this 2 | x; 3 | 4 | -------------------------------------------------------------------------------- /gui/help/images/walkthrough-toolbar-severities.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danmar/cppcheck/HEAD/gui/help/images/walkthrough-toolbar-severities.png -------------------------------------------------------------------------------- /test/cli/proj-inline-suppress/misraUnmatched.c: -------------------------------------------------------------------------------- 1 | void f() 2 | { 3 | // cppcheck-suppress misra-c2012-20.5 4 | // cppcheck-suppress uninitvar 5 | } -------------------------------------------------------------------------------- /test/tools/htmlreport/test_suppressions.txt: -------------------------------------------------------------------------------- 1 | variableScope:*/samples/memleak/good.c 2 | *:*/samples/resourceLeak/notexisting.c* 3 | uninitstring:* 4 | -------------------------------------------------------------------------------- /addons/test/misra/misra2012_rules_dummy_ascii.txt: -------------------------------------------------------------------------------- 1 | Appendix A Summary of guidelines 2 | Rule 1.1 3 | Text of rule 1.1 4 | Rule 1.2 5 | Text of rule 1.2 6 | -------------------------------------------------------------------------------- /gui/test/cppchecklibrarydata/files/undefine_valid.cfg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /test/cli/shared-items-project/Main/MainFile.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(void) 4 | { 5 | Shared::TestClass test{}; 6 | return 0; 7 | } -------------------------------------------------------------------------------- /test/cli/whole-program/odr.h: -------------------------------------------------------------------------------- 1 | class Base { 2 | public: 3 | virtual void f() = 0; 4 | }; 5 | 6 | extern Base *c1_create(); 7 | extern Base *c2_create(); -------------------------------------------------------------------------------- /addons/test/misra/crash1.c: -------------------------------------------------------------------------------- 1 | 2 | struct expression { 3 | int nargs; 4 | struct expression *args[3]; 5 | }; 6 | 7 | struct expression plvar = {0}; 8 | 9 | -------------------------------------------------------------------------------- /addons/test/misra/misra2012_rules_dummy_windows1250.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danmar/cppcheck/HEAD/addons/test/misra/misra2012_rules_dummy_windows1250.txt -------------------------------------------------------------------------------- /addons/test/misra/misra2012_rules_dummy_utf8.txt: -------------------------------------------------------------------------------- 1 | Appendix A Summary of guidelines 2 | Rule 1.1 3 | Text of rule 1.1, utf8 test: ∑ 4 | Rule 1.2 5 | Text of rule 1.2 6 | -------------------------------------------------------------------------------- /gui/test/cppchecklibrarydata/files/define_valid.cfg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /samples/arrayIndexOutOfBounds_1/bad.c: -------------------------------------------------------------------------------- 1 | int a[2]; 2 | 3 | int main() 4 | { 5 | a[0] = 0; 6 | a[1] = 0; 7 | a[2] = 0; 8 | return a[0]; 9 | } 10 | -------------------------------------------------------------------------------- /samples/arrayIndexOutOfBounds_1/good.c: -------------------------------------------------------------------------------- 1 | int a[3]; 2 | 3 | int main() 4 | { 5 | a[0] = 0; 6 | a[1] = 0; 7 | a[2] = 0; 8 | return 0; 9 | } 10 | -------------------------------------------------------------------------------- /samples/bufferAccessOutOfBounds/bad.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | char str[5]; 5 | strcpy(str, "0123456789abcdef"); 6 | return 0; 7 | } 8 | -------------------------------------------------------------------------------- /samples/bufferAccessOutOfBounds/good.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | char str[10]; 5 | snprintf(str, 10, "%s", "abc"); 6 | return 0; 7 | } 8 | -------------------------------------------------------------------------------- /test/cli/proj-inline-suppress/duplicate.cpp: -------------------------------------------------------------------------------- 1 | int main() { 2 | // cppcheck-suppress [unreadVariable,unreadVariable] 3 | int i = 0; 4 | return 0; 5 | } 6 | -------------------------------------------------------------------------------- /test/cli/proj-inline-suppress/premiumUnmatched.cpp: -------------------------------------------------------------------------------- 1 | void f() 2 | { 3 | // cppcheck-suppress premium-misra-cpp-2023-12.2.1 4 | // cppcheck-suppress uninitvar 5 | } -------------------------------------------------------------------------------- /gui/test/cppchecklibrarydata/files/mandatory_attribute_missing.cfg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /samples/arrayIndexOutOfBounds_2/bad.c: -------------------------------------------------------------------------------- 1 | int main() 2 | { 3 | int a[2]; 4 | int i; 5 | for (i = 0; i < 3; i++) 6 | a[i] = 0; 7 | return a[0]; 8 | } 9 | -------------------------------------------------------------------------------- /samples/arrayIndexOutOfBounds_2/good.c: -------------------------------------------------------------------------------- 1 | int main() 2 | { 3 | int a[3]; 4 | int i; 5 | for (i = 0; i < 3; i++) 6 | a[i] = 0; 7 | return a[0]; 8 | } 9 | -------------------------------------------------------------------------------- /test/cli/proj-inline-suppress-unusedFunction/B.cpp: -------------------------------------------------------------------------------- 1 | #include "B.hpp" 2 | 3 | B::B() {} 4 | 5 | // cppcheck-suppress unusedFunction 6 | void B::unusedFunctionTest() {} 7 | -------------------------------------------------------------------------------- /addons/test/misra/crash7.c: -------------------------------------------------------------------------------- 1 | 2 | 3 | static const struct id3_frametype wordlist[] = 4 | { 5 | {0, "Encryption method registration"}, 6 | {1, "Popularimeter"}, 7 | }; 8 | 9 | -------------------------------------------------------------------------------- /samples/multiCondition/good.c: -------------------------------------------------------------------------------- 1 | static void f(bool b) 2 | { 3 | if (b) {} 4 | else {} 5 | } 6 | 7 | int main() 8 | { 9 | f(true); 10 | return 0; 11 | } -------------------------------------------------------------------------------- /addons/test/misra/config1.c: -------------------------------------------------------------------------------- 1 | 2 | struct S { 3 | uint32_t some[100]; 4 | }; 5 | 6 | void foo( void ) 7 | { 8 | if (((S *)0x8000)->some[0] != 0U) { } 9 | } 10 | 11 | -------------------------------------------------------------------------------- /gui/.clang-tidy: -------------------------------------------------------------------------------- 1 | --- 2 | Checks: > 3 | -readability-convert-member-functions-to-static, 4 | -readability-redundant-access-specifiers 5 | InheritParentConfig: true 6 | -------------------------------------------------------------------------------- /samples/autoVariables/out.txt: -------------------------------------------------------------------------------- 1 | samples\autoVariables\bad.c:4:5: error: Address of local auto-variable assigned to a function parameter. [autoVariables] 2 | *a = &b; 3 | ^ 4 | -------------------------------------------------------------------------------- /samples/passedByValue_2/bad.cpp: -------------------------------------------------------------------------------- 1 | bool foo(std::string s) 2 | { 3 | return s.empty(); 4 | } 5 | 6 | int main() 7 | { 8 | std::string s; 9 | foo(s); 10 | } 11 | -------------------------------------------------------------------------------- /addons/test/threadsafety/local_static.cpp: -------------------------------------------------------------------------------- 1 | struct Dummy { 2 | int x; 3 | }; 4 | void func() { 5 | // cppcheck-suppress threadsafety-threadsafety 6 | static Dummy dummy; 7 | } 8 | -------------------------------------------------------------------------------- /externals/.clang-tidy: -------------------------------------------------------------------------------- 1 | --- 2 | Checks: '-*,misc-definitions-in-headers' 3 | WarningsAsErrors: '*' 4 | CheckOptions: 5 | - { key: HeaderFileExtensions, value: "x" } 6 | -------------------------------------------------------------------------------- /samples/accessMoved/good.cpp: -------------------------------------------------------------------------------- 1 | void foo(std::string); 2 | 3 | int main() 4 | { 5 | std::string s = "test"; 6 | foo(s); 7 | 8 | std::cout << s << std::endl; 9 | } 10 | -------------------------------------------------------------------------------- /samples/multiCondition/bad.c: -------------------------------------------------------------------------------- 1 | static void f(bool b) 2 | { 3 | if (b) {} 4 | else if (!b) {} 5 | } 6 | 7 | int main() 8 | { 9 | f(true); 10 | return 0; 11 | } 12 | -------------------------------------------------------------------------------- /samples/passedByValue_2/good.cpp: -------------------------------------------------------------------------------- 1 | bool foo(const std::string& s) 2 | { 3 | return s.empty(); 4 | } 5 | 6 | int main() 7 | { 8 | std::string s; 9 | foo(s); 10 | } 11 | -------------------------------------------------------------------------------- /samples/unreadVariable/bad.cpp: -------------------------------------------------------------------------------- 1 | void foo(const std::string&, const std::string&); 2 | 3 | int main() 4 | { 5 | std::string s1 = "test1", s2 = "test2"; 6 | foo(s1, s1); 7 | } 8 | -------------------------------------------------------------------------------- /samples/unreadVariable/good.cpp: -------------------------------------------------------------------------------- 1 | void foo(const std::string&, const std::string&); 2 | 3 | int main() 4 | { 5 | std::string s1 = "test1", s2 = "test2"; 6 | foo(s1, s2); 7 | } 8 | -------------------------------------------------------------------------------- /samples/resourceLeak/bad.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | const FILE *a = fopen("good.c", "r"); 5 | if (!a) 6 | return 0; 7 | 8 | return 0; 9 | } 10 | -------------------------------------------------------------------------------- /test/cli/whole-program/nullpointer1.h: -------------------------------------------------------------------------------- 1 | #include "nullpointer1_1.h" 2 | 3 | template 4 | void f(T* p) { 5 | if (sizeof(T) == 4) 6 | p = nullptr; 7 | g(p); 8 | } 9 | -------------------------------------------------------------------------------- /tools/triage/.clang-tidy: -------------------------------------------------------------------------------- 1 | --- 2 | Checks: > 3 | -readability-convert-member-functions-to-static, 4 | -readability-redundant-access-specifiers 5 | InheritParentConfig: true 6 | -------------------------------------------------------------------------------- /samples/accessMoved/bad.cpp: -------------------------------------------------------------------------------- 1 | void foo(std::string); 2 | 3 | int main() 4 | { 5 | std::string s = "test"; 6 | foo(std::move(s)); 7 | 8 | std::cout << s << std::endl; 9 | } 10 | -------------------------------------------------------------------------------- /addons/test/threadsafety/local_static_const.cpp: -------------------------------------------------------------------------------- 1 | struct Dummy { 2 | int x; 3 | }; 4 | void func() { 5 | // cppcheck-suppress threadsafety-threadsafety-const 6 | static const Dummy dummy; 7 | } 8 | -------------------------------------------------------------------------------- /gui/test/cppchecklibrarydata/files/podtype_valid.cfg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /gui/test/cppchecklibrarydata/files/reflection_mandatory_attribute_missing.cfg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | invokeMethod 5 | 6 | -------------------------------------------------------------------------------- /samples/AssignmentAddressToInteger/good.c: -------------------------------------------------------------------------------- 1 | static int* foo(int *p) 2 | { 3 | return p + 4; 4 | } 5 | 6 | int main() 7 | { 8 | int i[10]; 9 | foo(i); 10 | return 0; 11 | } 12 | -------------------------------------------------------------------------------- /samples/autoVariables/bad.c: -------------------------------------------------------------------------------- 1 | static void foo(int **a) 2 | { 3 | int b = 1; 4 | *a = &b; 5 | } 6 | 7 | int main() 8 | { 9 | int *c; 10 | foo(&c); 11 | return 0; 12 | } 13 | -------------------------------------------------------------------------------- /samples/passedByValue_1/bad.cpp: -------------------------------------------------------------------------------- 1 | class C 2 | { 3 | public: 4 | explicit C(std::string s) 5 | : _s(s) 6 | { 7 | } 8 | void foo(); 9 | private: 10 | std::string _s; 11 | }; -------------------------------------------------------------------------------- /samples/resourceLeak/good.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | FILE *a = fopen("good.c", "r"); 5 | if (!a) 6 | return 0; 7 | fclose(a); 8 | return 0; 9 | } 10 | -------------------------------------------------------------------------------- /test/cli/proj-inline-suppress/cfg.c: -------------------------------------------------------------------------------- 1 | void f() 2 | { 3 | #if DEF_1 4 | // cppcheck-suppress id 5 | (void)0; 6 | #endif 7 | 8 | // cppcheck-suppress id 9 | (void)0; 10 | } 11 | -------------------------------------------------------------------------------- /test/cli/proj-inline-suppress/unusedFunctionUnmatched.cpp: -------------------------------------------------------------------------------- 1 | // cppcheck-suppress unusedFunction 2 | void f() { 3 | // cppcheck-suppress unusedFunction 4 | // cppcheck-suppress uninitvar 5 | } 6 | -------------------------------------------------------------------------------- /test/cli/shared-items-project/Shared/TestClass.cpp: -------------------------------------------------------------------------------- 1 | #include "TestClass.h" 2 | 3 | using namespace Shared; 4 | 5 | TestClass::TestClass() 6 | {} 7 | 8 | TestClass::~TestClass() 9 | {} 10 | -------------------------------------------------------------------------------- /samples/arrayIndexOutOfBounds_1/out.txt: -------------------------------------------------------------------------------- 1 | samples\arrayIndexOutOfBounds_1\bad.c:7:6: error: Array 'a[2]' accessed at index 2, which is out of bounds. [arrayIndexOutOfBounds] 2 | a[2] = 0; 3 | ^ 4 | -------------------------------------------------------------------------------- /test/cli/proj2/proj2.cppcheck: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | compile_commands.json 5 | 6 | 7 | -------------------------------------------------------------------------------- /.codacy.yml: -------------------------------------------------------------------------------- 1 | exclude_paths: 2 | - addons/test/** 3 | - addons/y2038/test/*.c 4 | - htmlreport/example.cc 5 | - samples/**/bad.c 6 | - samples/**/bad.cpp 7 | - test/cfg/*.c 8 | - test/cfg/*.cpp 9 | -------------------------------------------------------------------------------- /samples/passedByValue_1/good.cpp: -------------------------------------------------------------------------------- 1 | class C 2 | { 3 | public: 4 | explicit C(std::string s) 5 | : _s(std::move(s)) 6 | { 7 | } 8 | void foo(); 9 | private: 10 | std::string _s; 11 | }; -------------------------------------------------------------------------------- /gui/cppcheck-gui.rc: -------------------------------------------------------------------------------- 1 | // Include command line program's resource file containing version info 2 | #include "../cli/version.rc" 3 | 4 | // GUI Icon 5 | IDI_ICON1 ICON DISCARDABLE "cppcheck.ico" 6 | -------------------------------------------------------------------------------- /samples/AssignmentAddressToInteger/bad.c: -------------------------------------------------------------------------------- 1 | static int foo(int *p) 2 | { 3 | int a = p; 4 | return a + 4; 5 | } 6 | 7 | int main() 8 | { 9 | int i[10]; 10 | foo(i); 11 | return 0; 12 | } 13 | -------------------------------------------------------------------------------- /samples/bufferAccessOutOfBounds/out.txt: -------------------------------------------------------------------------------- 1 | samples\bufferAccessOutOfBounds\bad.c:5:12: error: Buffer is accessed out of bounds: str [bufferAccessOutOfBounds] 2 | strcpy(str, "0123456789abcdef"); 3 | ^ 4 | -------------------------------------------------------------------------------- /samples/passedByValue_2/out.txt: -------------------------------------------------------------------------------- 1 | samples\passedByValue_2\bad.cpp:1:22: performance: Function parameter 's' should be passed by const reference. [passedByValue] 2 | bool foo(std::string s) 3 | ^ 4 | -------------------------------------------------------------------------------- /test/cli/proj-inline-suppress/3.cpp: -------------------------------------------------------------------------------- 1 | // From forum: https://sourceforge.net/p/cppcheck/discussion/general/thread/e67653efdb/ 2 | void foo() 3 | { // cppcheck-suppress zerodiv 4 | int x = 10000 / 0; 5 | } 6 | 7 | -------------------------------------------------------------------------------- /gui/test/cppchecklibrarydata/files/xml_reader_error.cfg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /samples/AssignmentAddressToInteger/out.txt: -------------------------------------------------------------------------------- 1 | samples\AssignmentAddressToInteger\bad.c:3:11: portability: Assigning a pointer to an integer is not portable. [AssignmentAddressToInteger] 2 | int a = p; 3 | ^ 4 | -------------------------------------------------------------------------------- /samples/autoVariables/good.c: -------------------------------------------------------------------------------- 1 | static void foo(int **a) 2 | { 3 | int b = 1; 4 | **a = b; 5 | } 6 | 7 | int main() 8 | { 9 | int b; 10 | int *c = &b; 11 | foo(&c); 12 | return 0; 13 | } 14 | -------------------------------------------------------------------------------- /tools/test/start_donate_cpu_client_test_local.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | cppcheck_tools_path=.. 4 | 5 | while : 6 | do 7 | "${cppcheck_tools_path}/donate-cpu.py" --test --bandwidth-limit=2m 8 | sleep 2 9 | done 10 | -------------------------------------------------------------------------------- /frontend/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB hdrs "*.h") 2 | file(GLOB srcs "*.cpp") 3 | 4 | add_library(frontend ${hdrs} ${srcs}) 5 | target_include_directories(frontend PUBLIC .) 6 | target_link_libraries(frontend PRIVATE cppcheck-core) 7 | -------------------------------------------------------------------------------- /gui/cppcheck-gui.desktop: -------------------------------------------------------------------------------- 1 | [Desktop Entry] 2 | Version=1.0 3 | Type=Application 4 | Name=Cppcheck 5 | Comment=A tool for static C/C++ code analysis 6 | Exec=cppcheck-gui 7 | Icon=cppcheck-gui 8 | Categories=Development;Debugger;Qt; 9 | -------------------------------------------------------------------------------- /samples/passedByValue_1/out.txt: -------------------------------------------------------------------------------- 1 | samples\passedByValue_1\bad.cpp:4:28: performance: Function parameter 's' should be passed by const reference. [passedByValue] 2 | explicit C(std::string s) 3 | ^ 4 | -------------------------------------------------------------------------------- /gui/test/cppchecklibrarydata/files/unhandled_element.cfg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /samples/memleak/bad.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | int result = 0; 5 | char *a = malloc(10); 6 | if (a) { 7 | a[0] = 0; 8 | result = a[0]; 9 | } 10 | return result; 11 | } 12 | -------------------------------------------------------------------------------- /samples/incorrectLogicOperator/out.txt: -------------------------------------------------------------------------------- 1 | samples\incorrectLogicOperator\bad.c:3:16: warning: Logical disjunction always evaluates to true: x >= 0 || x <= 10. [incorrectLogicOperator] 2 | if (x >= 0 || x <= 10) {} 3 | ^ 4 | -------------------------------------------------------------------------------- /test/cli/proj-suppress-syntaxError/1.c: -------------------------------------------------------------------------------- 1 | 2 | 3 | void validCode(int argInt) 4 | { 5 | // if G_UNLIKELY is not defined this results in a syntax error 6 | if G_UNLIKELY(argInt == 1) {} else if (G_UNLIKELY(argInt == 2)) {} 7 | } 8 | 9 | -------------------------------------------------------------------------------- /test/seh/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_executable(test-sehwrapper 2 | test-sehwrapper.cpp 3 | ${PROJECT_SOURCE_DIR}/cli/sehwrapper.cpp) 4 | target_include_directories(test-sehwrapper PRIVATE ${PROJECT_SOURCE_DIR}/cli ${PROJECT_SOURCE_DIR}/lib) -------------------------------------------------------------------------------- /addons/test/misra/crash8.c: -------------------------------------------------------------------------------- 1 | 2 | struct three_d_filter_t { 3 | char name[16]; 4 | double elem[2]; 5 | }; 6 | 7 | static three_d_filter_t base_filters[] = { 8 | {"Identity", { 1.0, 0.0 } }, 9 | {"Echo", { 0.4, 0.0 } } 10 | }; 11 | -------------------------------------------------------------------------------- /test/cli/helloworld/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(void) { 4 | (void)printf("Hello world!\n"); 5 | int x = 3 / 0; (void)x; // ERROR 6 | return 0; 7 | } 8 | 9 | #ifdef SOME_CONFIG 10 | void foo(); 11 | #endif 12 | -------------------------------------------------------------------------------- /addons/test/naming_test.c: -------------------------------------------------------------------------------- 1 | // To test: 2 | // ~/cppcheck/cppcheck --dump naming_test.c && python ../naming.py --var='[a-z].*' --function='[a-z].*' naming_test.c.dump 3 | 4 | // Should not crash when there is no name 5 | void func(int number, int); 6 | -------------------------------------------------------------------------------- /gui/test/cppchecklibrarydata/files/reflection_unhandled_element.cfg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | invokeMethod 6 | 7 | 8 | -------------------------------------------------------------------------------- /naming.json: -------------------------------------------------------------------------------- 1 | { 2 | "script": "addons/naming.py", 3 | "args": [ 4 | "--private-member-variable=m[A-Z].*", 5 | "--var=[_a-z].*", 6 | "--const=[_a-zA-Z].*", 7 | "--function=[a-zA-Z].*" 8 | ] 9 | } 10 | -------------------------------------------------------------------------------- /test/cli/trac5704/trac5704b.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(int argc, char *argv[]) 4 | { 5 | #ifdef 0 6 | // cppcheck-suppress zerodiv 7 | int i = 1/0; 8 | printf("i = %d\n", i); 9 | #endif 10 | return 0; 11 | } 12 | -------------------------------------------------------------------------------- /gui/test/cppchecklibrarydata/files/reflection_valid.cfg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | invokeMethod 5 | callFunction 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /tools/defines/run_cppcheck.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # TODO: use temporary filename 4 | ./create_platform_cfg.sh > platform.cfg 5 | 6 | # TODO: add option to pass define to cppcheck 7 | ./defines.sh > defines.txt 8 | 9 | ./cppcheck --platform=platform.cfg "$@" -------------------------------------------------------------------------------- /addons/test/misra/crash10.c: -------------------------------------------------------------------------------- 1 | //#12267 2 | 3 | extern uint32_t end; 4 | 5 | //#define KEEP // if uncomment this then wont crash 6 | 7 | KEEP static const int32_t ptr_to_end = &end; 8 | 9 | void foo(void) 10 | { 11 | (void)ptr_to_end; 12 | } 13 | -------------------------------------------------------------------------------- /addons/test/misra/crash4.c: -------------------------------------------------------------------------------- 1 | 2 | struct ConDesDesc { 3 | unsigned Order; 4 | unsigned Import; 5 | }; 6 | 7 | // cppcheck-suppress misra-config 8 | static ConDesDesc ConDes[CD_TYPE_COUNT] = { 9 | { 0, 0 }, 10 | { 0, 0 }, 11 | }; 12 | -------------------------------------------------------------------------------- /cmake/buildFiles.cmake: -------------------------------------------------------------------------------- 1 | CONFIGURE_FILE("${PROJECT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in" "${PROJECT_BINARY_DIR}/cmake_uninstall.cmake" IMMEDIATE @ONLY) 2 | ADD_CUSTOM_TARGET(uninstall "${CMAKE_COMMAND}" -P "${PROJECT_BINARY_DIR}/cmake_uninstall.cmake") 3 | -------------------------------------------------------------------------------- /gui/test/cppchecklibrarydata/files/markup_mandatory_attribute_missing.cfg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /samples/memleak/good.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | int result = 0; 5 | char *a = malloc(10); 6 | if (a) { 7 | a[0] = 0; 8 | result = a[0]; 9 | free(a); 10 | } 11 | return result; 12 | } 13 | -------------------------------------------------------------------------------- /test/cli/QML-Samples-TableView/qml.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | main.qml 4 | TableView.qml 5 | TableRow.qml 6 | TableColumn.qml 7 | 8 | 9 | -------------------------------------------------------------------------------- /test/cli/helloworld/helloworld.cppcheck: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | helloworld.sln 5 | false 6 | 7 | -------------------------------------------------------------------------------- /test/cli/shared-items-project/Shared/TestClass.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace Shared 4 | { 5 | class TestClass 6 | { 7 | public: 8 | explicit TestClass(); 9 | virtual ~TestClass(); 10 | }; 11 | } // namespace Shared 12 | -------------------------------------------------------------------------------- /test/cli/trac5704/trac5704a.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(int argc, char *argv[]) 4 | { 5 | #ifdef INCLUDE_ZERO_DIV 6 | // cppcheck-suppress zerodiv 7 | int i = 1/0; 8 | printf("i = %d\n", i); 9 | #endif 10 | return 0; 11 | } 12 | -------------------------------------------------------------------------------- /test/scripts/extract_and_run_more_tests.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cd ~/cppcheck || exit 1 4 | rm -rf test1 5 | python tools/extracttests.py --code=test1 test/testleakautovar.cpp 6 | cd ~/cppcheck/test1 || exit 1 7 | ~/cppcheck/test/scripts/run_more_tests.sh 8 | 9 | -------------------------------------------------------------------------------- /addons/test/misra/crash2.c: -------------------------------------------------------------------------------- 1 | 2 | // #11793 3 | 4 | typedef struct pfmlib_pmu { 5 | int flags ; 6 | int (*get_event_encoding[10])(void* this, pfmlib_event_desc_t* e); 7 | } pfmlib_pmu_t ; 8 | 9 | pfmlib_pmu_t sparc_ultra3_support = { .flags = 0 }; 10 | -------------------------------------------------------------------------------- /gui/test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_custom_target(gui-tests) 2 | 3 | add_subdirectory(cppchecklibrarydata) 4 | add_subdirectory(filelist) 5 | add_subdirectory(projectfile) 6 | add_subdirectory(resultstree) 7 | add_subdirectory(translationhandler) 8 | add_subdirectory(xmlreportv2) -------------------------------------------------------------------------------- /releasenotes.txt: -------------------------------------------------------------------------------- 1 | 2 | Release Notes for Cppcheck 2.20 3 | 4 | Major bug fixes & crashes: 5 | - 6 | 7 | New checks: 8 | - 9 | 10 | C/C++ support: 11 | - 12 | 13 | GUI: 14 | - 15 | 16 | Changed interface: 17 | - 18 | 19 | Infrastructure & dependencies: 20 | - 21 | -------------------------------------------------------------------------------- /test/.clang-tidy: -------------------------------------------------------------------------------- 1 | --- 2 | InheritParentConfig: true 3 | CheckOptions: 4 | #- key: bugprone-unused-return-value.CheckedFunctions 5 | # value: '::.*' 6 | - key: bugprone-unused-return-value.AllowCastToVoid 7 | value: 'true' -------------------------------------------------------------------------------- /test/cli/unusedFunction/unusedFunction.cppcheck: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /cfg/dpdk.cfg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | true 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /test/cli/whole-program/odr2.cpp: -------------------------------------------------------------------------------- 1 | #include "odr.h" 2 | 3 | #include 4 | 5 | class C : public Base 6 | { 7 | public: 8 | void f() override { 9 | std::cout << "2"; 10 | } 11 | }; 12 | 13 | Base *c2_create() 14 | { 15 | return new C(); 16 | } 17 | -------------------------------------------------------------------------------- /addons/test/misra/crash_misra9_parseInitializer.c: -------------------------------------------------------------------------------- 1 | union { 2 | struct { 3 | uint8_t a; 4 | uint8_t b; 5 | } a; 6 | } bar; 7 | 8 | struct foo { 9 | uint8_t a; 10 | union bar w; 11 | uint8_t b; 12 | }; 13 | 14 | struct foo asdf = { 15 | 0, 16 | {{0,0}}, 17 | 1 18 | }; 19 | -------------------------------------------------------------------------------- /gui/test/cppchecklibrarydata/files/platform_type_unhandled_element.cfg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /cmake/cxx11.cmake: -------------------------------------------------------------------------------- 1 | macro(use_cxx11) 2 | if(USE_BOOST AND USE_BOOST_INT128) 3 | # Boost.Math requires C++14 4 | set(CMAKE_CXX_STANDARD 14 CACHE STRING "C++ standard to use") 5 | else() 6 | set(CMAKE_CXX_STANDARD 11 CACHE STRING "C++ standard to use") 7 | endif() 8 | endmacro() 9 | -------------------------------------------------------------------------------- /gui/test/cppchecklibrarydata/files/smartptr_valid.cfg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /snap/gui/cppcheck-gui.desktop: -------------------------------------------------------------------------------- 1 | [Desktop Entry] 2 | Type=Application 3 | Name=Cppcheck 4 | Comment=A tool for static C/C++ code analysis 5 | Exec=cppcheck-gui 6 | Icon=${SNAP}/meta/gui/cppcheck-gui.png 7 | Terminal=true 8 | StartupNotify=true 9 | Categories=Development;Debugger;Qt; 10 | -------------------------------------------------------------------------------- /addons/test/misra/crash6.c: -------------------------------------------------------------------------------- 1 | 2 | 3 | typedef struct _tGames 4 | { 5 | char magicdirname[10]; 6 | unsigned int expectedmask; 7 | unsigned char pictureorder[3]; 8 | } tGames; 9 | 10 | static const tGames games[1]={ 11 | {"Pawn", 1, {0,1,2}} 12 | }; 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /addons/test/misra/suppressions.txt: -------------------------------------------------------------------------------- 1 | misra-c2012-21.6:*/misra-suppressions1-test.c:7 2 | misra-c2012-17.3 3 | misra-c2012-8.4:*/misra-suppressions1-test.c 4 | misra-c2012-4.1:*/misra-suppressions2-test.c 5 | misra-c2012-8.4:*/misra-suppressions2-test.c 6 | misra-c2012-19.2:*/misra-suppressions2-test.c 7 | -------------------------------------------------------------------------------- /rules/empty-catch-block.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | normal 4 | 5 | 6 | style 7 | Empty catch block found. 8 | 9 | 10 | -------------------------------------------------------------------------------- /rules/show-all-defines.rule: -------------------------------------------------------------------------------- 1 | 2 | 3 | define 4 | .* 5 | 6 | showalldefines 7 | information 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /tools/defines/defines.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | gcc -Wall -Wextra limits.c 4 | ./a.out 5 | gcc -Wall -Wextra float.c 6 | ./a.out 7 | gcc -Wall -Wextra stdint.c 8 | ./a.out 9 | 10 | clang -Weverything limits.c 11 | ./a.out 12 | clang -Weverything float.c 13 | ./a.out 14 | clang -Weverything stdint.c 15 | ./a.out -------------------------------------------------------------------------------- /.selfcheck_unused_suppressions: -------------------------------------------------------------------------------- 1 | # should not be reported - see #13387 2 | checkersReport 3 | 4 | # we are not using all methods of their interfaces 5 | unusedFunction:externals/*/* 6 | 7 | # Q_OBJECT functions which are not called in our code 8 | unusedFunction:cmake.output.notest/gui/cppcheck-gui_autogen/*/moc_aboutdialog.cpp 9 | -------------------------------------------------------------------------------- /test/cli/QML-Samples-TableView/TableColumn.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.0 2 | import QtQuick.Layouts 1.12 3 | import QtQuick.Controls 2.12 4 | import QtQml.Models 2.12 5 | 6 | QtObject { 7 | property string title 8 | property string role 9 | property bool fillWidth: false 10 | property int size: -1 11 | } 12 | -------------------------------------------------------------------------------- /addons/test/y2038/y2038-test-5-good-no-time-used.c: -------------------------------------------------------------------------------- 1 | /* 2 | * C file that does not use any time functionality -> no errors should 3 | * be reported. 4 | */ 5 | 6 | #include 7 | 8 | int main(int argc, char **argv) 9 | { 10 | if (argc > 1) { 11 | printf("Hello"); 12 | } 13 | return 0; 14 | } 15 | -------------------------------------------------------------------------------- /rules/unused-deref.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | [;{}] [*] \w+? (\+\+|\-\-) ; 4 | 5 | UnusedDeref 6 | style 7 | Redundant * found, "*p++" is the same as "*(p++)". 8 | 9 | 10 | -------------------------------------------------------------------------------- /test/cli/whole-program/odr1.cpp: -------------------------------------------------------------------------------- 1 | #include "odr.h" 2 | 3 | #include 4 | 5 | // cppcheck-suppress ctuOneDefinitionRuleViolation 6 | class C : public Base 7 | { 8 | public: 9 | void f() override { 10 | std::cout << "1"; 11 | } 12 | }; 13 | 14 | Base *c1_create() 15 | { 16 | return new C(); 17 | } 18 | -------------------------------------------------------------------------------- /cmake/versions.cmake: -------------------------------------------------------------------------------- 1 | # Version for libraries CPP 2 | # Version string must have 3 "parts". https://sourceforge.net/p/cppcheck/discussion/development/thread/e57efb2b62/ 3 | SET(SOVERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}") 4 | 5 | # Postfix of so's: 6 | SET(DLLVERSION "") 7 | SET(DEBUG_POSTFIX "") 8 | -------------------------------------------------------------------------------- /gui/test/cppchecklibrarydata/files/container_valid.cfg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /test/cli/proj-inline-suppress/template.cpp: -------------------------------------------------------------------------------- 1 | namespace { 2 | template 3 | T f() { 4 | return T(); 5 | } 6 | } 7 | 8 | // cppcheck-suppress unusedFunction 9 | int g(int i) { 10 | if (i == 0) 11 | return f(); 12 | if (i == 1) 13 | return f(); 14 | return f(); 15 | } -------------------------------------------------------------------------------- /addons/test/misra/misra_rules_empty_lines.txt: -------------------------------------------------------------------------------- 1 | Appendix A Summary of guidelines 2 | 3 | 4 | Rule 1.1 5 | Add this rule and parse to next, skipping empty lines. 6 | 7 | 8 | 9 | 10 | Rule 1.2 11 | Rule text. 12 | 13 | Rule 1.3 14 | There is 3 rules. 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /test/cli/readme.txt: -------------------------------------------------------------------------------- 1 | 2 | Systemtesting of Cppcheck CLI on some projects 3 | 4 | addons 5 | base path 6 | exclude folders 7 | importing projects 8 | * visual studio 9 | * compile database 10 | - different generators bear/cmake/.. 11 | - different platforms 12 | suppressions 13 | 14 | Different paths: 15 | * relative 16 | * absolute 17 | 18 | -------------------------------------------------------------------------------- /cmake/qtCompat.cmake: -------------------------------------------------------------------------------- 1 | # use "versionless" targets - no need for wrapper functions 2 | 3 | set(QT_CORE_LIB Qt::Core) 4 | set(QT_TEST_LIB Qt::Test) 5 | set(QT_WIDGETS_LIB Qt::Widgets) 6 | set(QT_GUI_LIB Qt::Gui) 7 | set(QT_HELP_LIB Qt::Help) 8 | set(QT_PRINTSUPPORT_LIB Qt::PrintSupport) 9 | set(QT_CHARTS_LIB Qt::Charts) 10 | set(QT_NETWORK_LIB Qt::Network) 11 | -------------------------------------------------------------------------------- /gui/gui.cppcheck: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /test/cli/fuzz-timeout/timeout-8229bbbfcf6f3ab98a6c23bfb1421ffd611c3657: -------------------------------------------------------------------------------- 1 | int bhar() 2 | { 3 | int a[2]; 4 | ift i; 5 | for (i = 0; i < 3; ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^~^^^^^^^^^^^^^^^^^^&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&size_t^^^^^^^^^^^^^^^^^^i++) 6 | a[i] = 1; 7 | rewurn a[0]; 8 | } 9 | -------------------------------------------------------------------------------- /rules/strlen-empty-str.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | if \( ([!] )*?(strlen) \( \w+? \) ([>] [0] )*?\) { 4 | 5 | StrlenEmptyString 6 | performance 7 | Using strlen() to check if a string is empty is not efficient. 8 | 9 | 10 | -------------------------------------------------------------------------------- /addons/test/y2038/y2038-test-4-good.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Define _TIME_BITS equal to 64 so that glibc knows we want Y2038 support. 3 | */ 4 | 5 | #define _TIME_BITS 64 6 | 7 | #include "y2038-inc.h" 8 | 9 | int main(int argc, char **argv) 10 | { 11 | clockid_t my_clk_id = CLOCK_REALTIME; 12 | struct timespec *my_tp; 13 | 14 | return clock_gettime(my_clk_id, &my_tp); 15 | } 16 | -------------------------------------------------------------------------------- /man/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | if (BUILD_MANPAGE) 2 | find_program(XSLTPROC NAMES xsltproc REQUIRED) 3 | set(DB2MAN "/usr/share/sgml/docbook/stylesheet/xsl/nwalsh/manpages/docbook.xsl") 4 | set(MAN_SOURCE "${CMAKE_CURRENT_SOURCE_DIR}/cppcheck.1.xml") 5 | add_custom_target(man ${XSLTPROC} --nonet --param man.charmap.use.subset "0" ${DB2MAN} ${MAN_SOURCE} 6 | DEPENDS ${MAN_SOURCE}) 7 | endif() -------------------------------------------------------------------------------- /man/buildman.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # To install required tools in debian: 3 | # sudo apt-get install pandoc texlive-latex-base texlive-fonts-recommended texlive-latex-extra 4 | # For Windows you can use the MiKTeX installer https://miktex.org/download 5 | 6 | ./build-pdf.sh manual 7 | ./build-html.sh manual 8 | 9 | ./build-pdf.sh reference-cfg-format 10 | ./build-html.sh reference-cfg-format 11 | -------------------------------------------------------------------------------- /samples/invalidContainer/bad.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | std::vector items; 5 | items.push_back(1); 6 | items.push_back(2); 7 | items.push_back(3); 8 | std::vector::iterator iter; 9 | for (iter = items.begin(); iter != items.end(); ++iter) { 10 | if (*iter == 2) { 11 | items.erase(iter); 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /addons/test/misra/misra-test.h: -------------------------------------------------------------------------------- 1 | #ifndef MISRA_TEST_H 2 | #define MISRA_TEST_H 3 | struct misra_h_s { int foo; }; 4 | bool test(char *a); // OK 5 | int misra_8_2_no_fp(int a); 6 | void misra_8_4_bar(void); 7 | // #12978 8 | typedef struct m8_4_stErrorDef 9 | { 10 | uint8_t ubReturnVal; 11 | } m8_4_stErrorDef; 12 | extern const m8_4_stErrorDef * m8_4_pubTestPointer; 13 | #endif // MISRA_TEST_H 14 | -------------------------------------------------------------------------------- /addons/test/misra/misra_rules_structure.txt: -------------------------------------------------------------------------------- 1 | Here can be any text. 2 | 3 | Incorrect definitions: 4 | Appendix A 5 | Appendix A Summary: 6 | 7 | Rule 1.1 8 | Error! 9 | 10 | Here we go: 11 | Appendix A Summary of guidelines 12 | 13 | Rule 1.2 14 | Rule text. 15 | 16 | Rule 2.1 17 | Rule text for 2.1. 18 | 19 | Stop parsing after this line: 20 | Appendix B 21 | 22 | Rule 1.3 23 | Error! 24 | -------------------------------------------------------------------------------- /addons/test/y2038/y2038-test-2-no-time-bits.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | /* 5 | * Do not define _TIME_BITS but have _USE_TIME_BITS64 defined 6 | */ 7 | 8 | #include "y2038-inc.h" 9 | 10 | int main(int argc, char **argv) 11 | { 12 | clockid_t my_clk_id = CLOCK_REALTIME; 13 | struct timespec *my_tp; 14 | 15 | return clock_gettime(my_clk_id, &my_tp); 16 | } 17 | -------------------------------------------------------------------------------- /addons/test/y2038/y2038-test-3-no-use-time-bits.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | /* 5 | * Include bad _USE_TIME_BITS64 definition to trigger error 6 | */ 7 | 8 | #define _TIME_BITS 64 9 | 10 | int main(int argc, char **argv) 11 | { 12 | clockid_t my_clk_id = CLOCK_REALTIME; 13 | struct timespec *my_tp; 14 | 15 | return clock_gettime(my_clk_id, &my_tp); 16 | } 17 | -------------------------------------------------------------------------------- /samples/accessMoved/out.txt: -------------------------------------------------------------------------------- 1 | samples\accessMoved\bad.cpp:8:18: warning: Access of moved variable 's'. [accessMoved] 2 | std::cout << s << std::endl; 3 | ^ 4 | samples\accessMoved\bad.cpp:6:9: note: Calling std::move(s) 5 | foo(std::move(s)); 6 | ^ 7 | samples\accessMoved\bad.cpp:8:18: note: Access of moved variable 's'. 8 | std::cout << s << std::endl; 9 | ^ 10 | -------------------------------------------------------------------------------- /addons/test/misra/misra_rules_multiple_lines.txt: -------------------------------------------------------------------------------- 1 | Appendix A Summary of guidelines 2 | 3 | Rule 1.1 4 | Multiple 5 | lines 6 | text. 7 | Rule 1.2 8 | Multiple lines 9 | text. 10 | Rule 1.3 Required 11 | Multiple 12 | lines 13 | text. 14 | Rule 1.4 15 | Should 16 | Starts from lowercase letter. 17 | Rule 1.5 18 | Should 19 | starts from lowercase letter. 20 | Rule 1.6 21 | Can 22 | 23 | contain empty lines. 24 | 25 | -------------------------------------------------------------------------------- /rules/stl.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | \. find \( "[^"]+?" \) == \d+ 5 | 6 | UselessSTDStringFind 7 | performance 8 | When looking for a string at a fixed position compare 9 | is faster. 10 | 11 | 12 | -------------------------------------------------------------------------------- /valgrind/testrunner.supp: -------------------------------------------------------------------------------- 1 | { 2 | 3 | Memcheck:Leak 4 | match-leak-kinds: reachable 5 | fun:_Znwm 6 | fun:__static_initialization_and_destruction_0 7 | fun:_GLOBAL__sub_I_memory_manager.cpp 8 | fun:call_init.part.0 9 | fun:call_init 10 | fun:_dl_init 11 | obj:/usr/lib/x86_64-linux-gnu/ld-2.31.so 12 | obj:* 13 | obj:* 14 | obj:* 15 | obj:* 16 | } 17 | -------------------------------------------------------------------------------- /addons/test/y2038/y2038-test-1-bad-time-bits.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | /* 5 | * Define _TIME_BITS unequal to 64 to trigger error 6 | */ 7 | 8 | #define _TIME_BITS 62 9 | 10 | #include "y2038-inc.h" 11 | 12 | int main(int argc, char **argv) 13 | { 14 | clockid_t my_clk_id = CLOCK_REALTIME; 15 | struct timespec *my_tp; 16 | 17 | return clock_gettime(my_clk_id, &my_tp); 18 | } 19 | -------------------------------------------------------------------------------- /gui/test/cppchecklibrarydata/files/typechecks_valid.cfg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | std::insert_iterator 6 | std::pair 7 | 8 | 9 | 10 | 11 | 12 | std::tuple 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /samples/unreadVariable/out.txt: -------------------------------------------------------------------------------- 1 | samples\unreadVariable\bad.cpp:5:34: style: Variable 's2' is assigned a value that is never used. [unreadVariable] 2 | std::string s1 = "test1", s2 = "test2"; 3 | ^ 4 | samples\unreadVariable\bad.cpp:5:31: style: Variable 's2' is assigned a value that is never used. [unreadVariable] 5 | std::string s1 = "test1", s2 = "test2"; 6 | ^ 7 | -------------------------------------------------------------------------------- /addons/runaddon.py: -------------------------------------------------------------------------------- 1 | import cppcheckdata 2 | import cppcheck 3 | import runpy 4 | import sys 5 | import os 6 | 7 | if __name__ == '__main__': 8 | addon = sys.argv[1] 9 | __addon_name__ = os.path.splitext(os.path.basename(addon))[0] 10 | sys.argv.pop(0) 11 | 12 | runpy.run_path(addon, run_name='__main__') 13 | 14 | # Run registered checkers 15 | cppcheck.runcheckers() 16 | sys.exit(cppcheckdata.EXIT_CODE) -------------------------------------------------------------------------------- /addons/test/naming_test.cpp: -------------------------------------------------------------------------------- 1 | // To test: 2 | // ~/cppcheck/cppcheck --dump naming_test.cpp && python ../naming.py --var='[a-z].*' --function='[a-z].*' naming_test.cpp.dump 3 | 4 | // No error for mismatching Constructor/Destructor names should be issued, they can not be changed. 5 | class TestClass1 6 | { 7 | TestClass1() {} 8 | ~TestClass1() {} 9 | TestClass1(const TestClass1 &) {} 10 | TestClass1(TestClass1 &&) {} 11 | }; 12 | -------------------------------------------------------------------------------- /externals/simplecpp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB hdrs "*.h") 2 | file(GLOB srcs "*.cpp") 3 | 4 | add_library(simplecpp ${srcs} ${hdrs}) 5 | target_dll_compile_definitions(simplecpp EXPORT SIMPLECPP_EXPORT IMPORT SIMPLECPP_IMPORT) 6 | 7 | if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") 8 | target_compile_options_safe(simplecpp -Wno-zero-as-null-pointer-constant) 9 | endif() 10 | 11 | target_externals_include_directories(simplecpp PUBLIC .) 12 | -------------------------------------------------------------------------------- /samples/invalidContainer/good.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | std::vector items; 5 | items.push_back(1); 6 | items.push_back(2); 7 | items.push_back(3); 8 | std::vector::iterator iter; 9 | for (iter = items.begin(); iter != items.end();) { 10 | if (*iter == 2) { 11 | iter = items.erase(iter); 12 | } else { 13 | ++iter; 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /gui/test/cppchecklibrarydata/files/container_unhandled_element.cfg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /rules/suggest_nullptr.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | raw 4 | 5 | 6 | modernizeUseNullPtr 7 | style 8 | Prefer to use a 'nullptr' instead of initializing a pointer with 0. 9 | 10 | 11 | -------------------------------------------------------------------------------- /gui/help/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Cppcheck GUI 4 | 5 | 6 | 7 |

Cppcheck GUI

8 | 9 |

With the Cppcheck GUI you can analyze your code.

10 | 11 |

Contents

12 | 13 |

If you want to get started, look at the walk through.

14 | 15 |

Example

16 | 17 |
18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /samples/multiCondition/out.txt: -------------------------------------------------------------------------------- 1 | samples\multiCondition\bad.c:4:14: style: Expression is always true because 'else if' condition is opposite to previous condition at line 3. [multiCondition] 2 | else if (!b) {} 3 | ^ 4 | samples\multiCondition\bad.c:3:9: note: first condition 5 | if (b) {} 6 | ^ 7 | samples\multiCondition\bad.c:4:14: note: else if condition is opposite to first condition 8 | else if (!b) {} 9 | ^ 10 | -------------------------------------------------------------------------------- /addons/test/misra/misra_rules_dummy.txt: -------------------------------------------------------------------------------- 1 | Appendix A Summary of guidelines 2 | Rule 3.1 Required 3 | R3.1 text. 4 | Rule 4.1 Required 5 | R4.1 text. 6 | Rule 10.4 Mandatory 7 | R10.4 text. 8 | Rule 11.5 Advisory 9 | R11.5 text. 10 | Rule 15.5 Advisory 11 | R15.5 text. 12 | Rule 15.6 Required 13 | R15.6 text. 14 | Rule 17.7 Required 15 | R17.7 text. 16 | Rule 20.1 Advisory 17 | R20.1 text. 18 | Rule 21.3 Required 19 | R21.3 text. 20 | Rule 21.4 21 | R21.4 text. 22 | 23 | -------------------------------------------------------------------------------- /gui/help/online-help.qhcp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | online-help.qhp 7 | online-help.qch 8 | 9 | 10 | 11 | online-help.qch 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /addons/test/misra/misra-test.cpp: -------------------------------------------------------------------------------- 1 | // #8441 2 | class C { 3 | int a; 4 | int b; 5 | C(void) : a(1), b(1) { c; } 6 | }; 7 | 8 | class misra_21_1_C { 9 | public: 10 | misra_21_1_C operator=(const misra_21_1_C &); 11 | }; 12 | 13 | class C2 { 14 | public: 15 | C2(void); 16 | private: 17 | void* f; 18 | }; 19 | C2::C2(void) : f(NULL) {} 20 | 21 | static void test_misra_21_1_crash(void) 22 | { 23 | auto misra_21_1_C a, b; // 12.3 24 | a = b; 25 | } 26 | -------------------------------------------------------------------------------- /gui/help/standalone-analysis.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Standalone analysis 5 | 6 | 7 | 8 |

Standalone analysis

9 | 10 |

It is possible to quickly analyze files. Open the Analyze menu and click on 11 | either Files... or Directory....

12 | 13 |

It is recommended that you create a project for analysis. A properly configured 14 | project will give you better analysis.

15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /gui/test/data/projectfiles/simple_noroot.cppcheck: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /platforms/avr8.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 4 | unsigned 5 | 6 | 1 7 | 2 8 | 2 9 | 4 10 | 8 11 | 4 12 | 4 13 | 4 14 | 2 15 | 2 16 | 2 17 | 18 | 19 | -------------------------------------------------------------------------------- /platforms/mips32.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 4 | signed 5 | 6 | 1 7 | 2 8 | 4 9 | 4 10 | 8 11 | 4 12 | 8 13 | 8 14 | 4 15 | 4 16 | 4 17 | 18 | 19 | -------------------------------------------------------------------------------- /platforms/pic16.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 4 | unsigned 5 | 6 | 1 7 | 2 8 | 2 9 | 4 10 | 8 11 | 4 12 | 4 13 | 8 14 | 2 15 | 2 16 | 2 17 | 18 | 19 | -------------------------------------------------------------------------------- /platforms/pic8.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 4 | unsigned 5 | 6 | 1 7 | 2 8 | 2 9 | 4 10 | 4 11 | 4 12 | 4 13 | 4 14 | 2 15 | 2 16 | 2 17 | 18 | 19 | -------------------------------------------------------------------------------- /samples/arrayIndexOutOfBounds_2/out.txt: -------------------------------------------------------------------------------- 1 | samples\arrayIndexOutOfBounds_2\bad.c:6:10: error: Array 'a[2]' accessed at index 2, which is out of bounds. [arrayIndexOutOfBounds] 2 | a[i] = 0; 3 | ^ 4 | samples\arrayIndexOutOfBounds_2\bad.c:5:19: note: Assuming that condition 'i<3' is not redundant 5 | for (i = 0; i < 3; i++) 6 | ^ 7 | samples\arrayIndexOutOfBounds_2\bad.c:6:10: note: Array index out of bounds 8 | a[i] = 0; 9 | ^ 10 | -------------------------------------------------------------------------------- /platforms/aix_ppc64.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 4 | unsigned 5 | 6 | 1 7 | 2 8 | 4 9 | 8 10 | 8 11 | 4 12 | 8 13 | 8 14 | 8 15 | 8 16 | 2 17 | 18 | 19 | -------------------------------------------------------------------------------- /platforms/cray_sv1.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 4 | unsigned 5 | 6 | 1 7 | 2 8 | 8 9 | 8 10 | 8 11 | 8 12 | 8 13 | 16 14 | 8 15 | 8 16 | 8 17 | 18 | 19 | -------------------------------------------------------------------------------- /htmlreport/README.txt: -------------------------------------------------------------------------------- 1 | cppcheck-htmlreport 2 | 3 | This is a little utility to generate a html report of a XML file produced by 4 | cppcheck. 5 | 6 | The utility is implemented in Python and requires the pygments module 7 | to generate syntax highlighted source code. 8 | If you are using a Debian based Linux system, the pygments package can be 9 | installed by following command: 10 | $ sudo apt-get install python-pygments 11 | 12 | For more information run './cppcheck-htmlreport --help' 13 | -------------------------------------------------------------------------------- /platforms/arm32-wchar_t2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 4 | unsigned 5 | 6 | 1 7 | 2 8 | 4 9 | 4 10 | 8 11 | 4 12 | 8 13 | 8 14 | 4 15 | 4 16 | 2 17 | 18 | 19 | -------------------------------------------------------------------------------- /platforms/arm32-wchar_t4.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 4 | unsigned 5 | 6 | 1 7 | 2 8 | 4 9 | 4 10 | 8 11 | 4 12 | 8 13 | 8 14 | 4 15 | 4 16 | 4 17 | 18 | 19 | -------------------------------------------------------------------------------- /platforms/arm64-wchar_t2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 4 | unsigned 5 | 6 | 1 7 | 2 8 | 4 9 | 4 10 | 8 11 | 4 12 | 8 13 | 8 14 | 8 15 | 4 16 | 2 17 | 18 | 19 | -------------------------------------------------------------------------------- /platforms/arm64-wchar_t4.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 4 | unsigned 5 | 6 | 1 7 | 2 8 | 4 9 | 4 10 | 8 11 | 4 12 | 8 13 | 8 14 | 8 15 | 4 16 | 4 17 | 18 | 19 | -------------------------------------------------------------------------------- /platforms/elbrus-e1cp.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 4 | unsigned 5 | 6 | 1 7 | 2 8 | 4 9 | 8 10 | 8 11 | 4 12 | 8 13 | 16 14 | 8 15 | 8 16 | 4 17 | 18 | 19 | -------------------------------------------------------------------------------- /platforms/pic8-enhanced.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 4 | unsigned 5 | 6 | 1 7 | 2 8 | 2 9 | 4 10 | 8 11 | 4 12 | 4 13 | 4 14 | 2 15 | 2 16 | 2 17 | 18 | 19 | -------------------------------------------------------------------------------- /addons/test/misra/crash12.c: -------------------------------------------------------------------------------- 1 | // 13140 2 | #line 78 "tmp.h" 3 | typedef struct 4 | { 5 | int vara [30] ; 6 | int varb [5] ; 7 | } S0 ; 8 | 9 | 10 | 11 | typedef struct 12 | { 13 | bool var1 ; 14 | S2 var2 ; 15 | S2 var3 ; 16 | S2 var4 ; 17 | short var5 ; 18 | short var6 ; 19 | S1 var7 ; 20 | S1 var8 ; 21 | S1 var9 ; 22 | S1 var10 ; 23 | S1 var11 ; 24 | float var12 ; 25 | short var13 [ 3 ] ; 26 | } S3 ; 27 | 28 | #line 33 "tmp.c" 29 | static const S3 s3 = 30 | { 31 | 0 , 32 | { 0, 0 } , 33 | } ; -------------------------------------------------------------------------------- /cfg/protobuf.cfg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /tools/dmake/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | add_executable(dmake EXCLUDE_FROM_ALL 3 | dmake.cpp 4 | ) 5 | target_link_libraries(dmake cppcheck-core cli simplecpp) 6 | if (WIN32 AND NOT BORLAND) 7 | if(NOT MINGW) 8 | target_link_libraries(dmake Shlwapi.lib) 9 | else() 10 | target_link_libraries(dmake shlwapi) 11 | endif() 12 | endif() 13 | 14 | add_custom_target(run-dmake $ 15 | WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} 16 | DEPENDS dmake) 17 | -------------------------------------------------------------------------------- /platforms/msp430_eabi_large_datamodel.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 4 | signed 5 | 6 | 1 7 | 2 8 | 2 9 | 4 10 | 8 11 | 4 12 | 8 13 | 8 14 | 4 15 | 4 16 | 2 17 | 18 | 19 | -------------------------------------------------------------------------------- /gui/test/data/projectfiles/simple.cppcheck: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /gui/test/data/projectfiles/simple_ignore.cppcheck: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /test/scripts/testrunner-single.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 4 | 5 | if [ -n "$1" ]; then 6 | testrunner_bin=$1 7 | else 8 | make -s -C "$SCRIPT_DIR/../.." -j"$(nproc)" testrunner # CXXOPTS="-g -O2 -w" CPPOPTS="-DHAVE_BOOST" 9 | testrunner_bin=$SCRIPT_DIR/../../testrunner 10 | fi 11 | 12 | ec=0 13 | 14 | tests=$($testrunner_bin -d | cut -d'(' -f2 | cut -d')' -f1) 15 | for test in $tests; do 16 | $testrunner_bin -n "$test" || ec=1 17 | done 18 | 19 | exit $ec 20 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | ## standard default enconding 2 | * text=auto 3 | 4 | ## UNIX specific files 5 | *.sh text eol=lf 6 | 7 | ## Windows specific files 8 | *.bat text eol=crlf 9 | *.cmd text eol=crlf 10 | *.ps1 text eol=crlf 11 | *.vcxproj text eol=crlf 12 | *.vcxproj.filters text eol=crlf 13 | *.sln text eol=crlf 14 | *.wixproj text eol=crlf 15 | *.wxi text eol=crlf 16 | *.wxs text eol=crlf 17 | 18 | ## Binary resources 19 | *.pdf binary -------------------------------------------------------------------------------- /test/tools/htmlreport/example.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Checking example.cc... 4 | 5 | 6 | Checking usage of global functions.. 7 | 8 | 9 | -------------------------------------------------------------------------------- /gui/manualtest/mainwindow.md: -------------------------------------------------------------------------------- 1 | 2 | # Main window 3 | 4 | Some manual testing in the main window interface 5 | 6 | 7 | ## Test: Recheck file 8 | 9 | 1. Load a project with results. 10 | 1. Restart the GUI. 11 | 1. Right click on a file and click on "Recheck". 12 | 13 | EXPECTED: Results for that file should be refreshed. 14 | 15 | 16 | ## Test: Switch project 17 | 18 | 1. Open project #1 19 | 1. Open project #2 that has different results 20 | 21 | EXPECTED: Results for project #1 should go away, results for project #2 should be shown 22 | -------------------------------------------------------------------------------- /externals/pcre.patch: -------------------------------------------------------------------------------- 1 | diff -urN pcre/CMakeLists.txt pcre-8.45/CMakeLists.txt 2 | --- pcre/CMakeLists.txt 2021-11-05 13:28:16.000000000 +0100 3 | +++ pcre-8.45/CMakeLists.txt 2025-04-02 10:18:49.636009900 +0200 4 | @@ -77,7 +77,7 @@ 5 | # CMP0026 to avoid warnings for the use of LOCATION in GET_TARGET_PROPERTY. 6 | 7 | CMAKE_MINIMUM_REQUIRED(VERSION 2.8.5) 8 | -CMAKE_POLICY(SET CMP0026 OLD) 9 | +#CMAKE_POLICY(SET CMP0026 OLD) 10 | 11 | # For FindReadline.cmake. This was changed to allow setting CMAKE_MODULE_PATH 12 | # on the command line. 13 | -------------------------------------------------------------------------------- /addons/test/misra/crash5.c: -------------------------------------------------------------------------------- 1 | 2 | struct _boardcnf_ch { 3 | // cppcheck-suppress misra-config 4 | uint8_t ddr_density[CS_CNT]; 5 | uint64_t ca_swap; 6 | }; 7 | 8 | struct _boardcnf { 9 | 10 | uint16_t dqdm_dly_r; 11 | // cppcheck-suppress misra-config 12 | struct _boardcnf_ch ch[DRAM_CH_CNT]; 13 | }; 14 | 15 | static const struct _boardcnf boardcnfs[1] = { 16 | { 17 | 0x0a0, 18 | { 19 | { {0x02, 0x02}, 0x00345201 }, 20 | { {0x02, 0x02}, 0x00302154 } 21 | } 22 | }, 23 | }; 24 | -------------------------------------------------------------------------------- /gui/help/tagging.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Tagging warnings 4 | 5 | 6 | 7 |

Tagging warnings

8 | 9 |

You can manually categorize warnings.

10 | 11 |

You choose the names of the categories yourself in the project file 12 | dialog.

13 | 14 |

If tag names are configured, then you can tag the warnings by 15 | right-clicking on them and selecting the proper tag in the 16 | context menu.

17 | 18 |

Tags are saved in the project file and will be permanent.

19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /test/scripts/generate_and_run_more_tests.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Run like: 3 | # cd ~/cppcheck 4 | # tools/generate_and_run_more_tests.sh 5 | 6 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 7 | 8 | set -e 9 | 10 | echo testleakautovar 11 | $DIR/run_more_tests.sh $DIR/../testleakautovar.cpp 12 | 13 | echo testmemleak 14 | $DIR/run_more_tests.sh $DIR/../testmemleak.cpp 15 | 16 | echo testnullpointer 17 | $DIR/run_more_tests.sh $DIR/../testnullpointer.cpp 18 | 19 | echo testuninitvar 20 | $DIR/run_more_tests.sh $DIR/../testuninitvar.cpp 21 | 22 | -------------------------------------------------------------------------------- /gui/test/cppchecklibrarydata/files/platform_type_valid.cfg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /tools/triage/triage.pro: -------------------------------------------------------------------------------- 1 | lessThan(QT_MAJOR_VERSION, 5): error(requires >= Qt 5 (You used: $$QT_VERSION)) 2 | QT += core gui widgets 3 | TARGET = triage 4 | TEMPLATE = app 5 | QMAKE_CXXFLAGS += -std=c++11 6 | INCLUDEPATH += ../../gui 7 | MOC_DIR = temp 8 | OBJECTS_DIR = temp 9 | UI_DIR = temp 10 | SOURCES += main.cpp\ 11 | mainwindow.cpp \ 12 | ../../gui/codeeditorstyle.cpp \ 13 | ../../gui/codeeditor.cpp 14 | HEADERS += mainwindow.h \ 15 | ../../gui/codeeditorstyle.h \ 16 | ../../gui/codeeditor.h 17 | FORMS += mainwindow.ui 18 | -------------------------------------------------------------------------------- /webreport.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ./generate_coverage_report 4 | 5 | rm -rf devinfo 6 | mkdir devinfo 7 | 8 | mv coverage_report devinfo/ 9 | 10 | doxygen 2> devinfo/doxygen-errors.txt 11 | mv doxyoutput/html devinfo/doxyoutput 12 | 13 | cd addons || exit 1 14 | doxygen cppcheckdata.doxyfile 15 | mv html ../devinfo/cppcheckdata 16 | cd .. 17 | 18 | # Detect duplicate code.. 19 | ~/pmd-4.2.6/bin/cpd.sh lib/ > devinfo/cpd.txt 20 | #java -jar ~/simian-2.4.0/bin/simian-2.4.0.jar -language=c++ -reportDuplicateText -threshold=10 lib/*.cpp lib/*.h > devinfo/simian.txt 21 | 22 | -------------------------------------------------------------------------------- /gui/test/cppchecklibrarydata/files/memory_resource_unhandled_element.cfg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | malloc 5 | 6 | calloc 7 | aligned_alloc 8 | realloc 9 | reallocarray 10 | free 11 | 12 | 13 | -------------------------------------------------------------------------------- /test/cfg/mfc.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Test library configuration for mfc.cfg 3 | 4 | #include 5 | 6 | 7 | class MyClass1 : public CObject { 8 | DECLARE_DYNAMIC(MyClass1) 9 | public: 10 | MyClass1() {} 11 | }; 12 | IMPLEMENT_DYNAMIC(MyClass1, CObject) 13 | 14 | class MyClass2 : public CObject { 15 | DECLARE_DYNCREATE(MyClass2) 16 | public: 17 | MyClass2() {} 18 | }; 19 | IMPLEMENT_DYNCREATE(MyClass2, CObject) 20 | 21 | class MyClass3 : public CObject { 22 | DECLARE_SERIAL(MyClass3) 23 | public: 24 | MyClass3() {} 25 | }; 26 | IMPLEMENT_SERIAL(MyClass3, CObject, 42) 27 | -------------------------------------------------------------------------------- /tools/test/start_donate_cpu_client_productive.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Runs the daca@home client against the real server and thus produces real results. 4 | # 5 | # The donate-cpu.py script is stopped regularly to pull updates and then starts again after a 6 | # short pause with the latest "Donate CPU" client script. 7 | # 8 | # Should any error occur then the script also pulls updates and restarts donate-cpu.py. 9 | 10 | cppcheck_tools_path=.. 11 | 12 | while : 13 | do 14 | git pull 15 | "${cppcheck_tools_path}/donate-cpu.py" --bandwidth-limit=1m --max-packages=100 16 | sleep 10 17 | done 18 | -------------------------------------------------------------------------------- /addons/test/misra/misra-ctu-test.h: -------------------------------------------------------------------------------- 1 | 2 | 3 | typedef int MISRA_2_3_A; 4 | typedef int MISRA_2_3_B; 5 | typedef int MISRA_2_3_VIOLATION; // cppcheck-suppress misra-c2012-2.3 6 | 7 | // cppcheck-suppress misra-c2012-2.4 8 | struct misra_2_4_violation_t { 9 | int x; 10 | }; 11 | 12 | static inline void misra_5_9_exception(void) {} 13 | 14 | void misra_8_7_external(void); 15 | 16 | #define MISRA_2_5_OK_1 1 17 | #define MISRA_2_5_OK_2 2 18 | // cppcheck-suppress misra-c2012-2.5 19 | #define MISRA_2_5_VIOLATION 0 20 | 21 | // #12362 22 | extern void misra_8_7_compliant( void ); 23 | 24 | #define MISRA_2_5_OK_3 This -------------------------------------------------------------------------------- /addons/test/path1/misra-suppressions2-test.c: -------------------------------------------------------------------------------- 1 | // To test: 2 | // ../../cppcheck --suppressions-list=suppressions.txt --dump misra-suppressions*-test.c && python ../misra.py misra-suppressions*-test.c.dump 3 | // There should be no violations reported 4 | 5 | union misra_5_2_field_hides_field__63x { //19.2 6 | int misra_5_2_field_hides_field__31x; 7 | int misra_5_2_field_hides_field__31y;//5.2 8 | }; 9 | struct misra_5_2_field_hides_field__63y { //5.2 10 | int misra_5_2_field_hides_field1_31x; 11 | int misra_5_2_field_hides_field1_31y;//5.2 12 | }; 13 | const char *s41_1 = "\x41g"; // 4.1 14 | const char *s41_2 = "\x41\x42"; 15 | -------------------------------------------------------------------------------- /gui/test/cppchecklibrarydata/files/memory_resource_valid.cfg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | malloc 5 | calloc 6 | realloc 7 | UuidToString 8 | HeapFree 9 | g_malloc 10 | 11 | 12 | 13 | fclose 14 | _wfopen_s 15 | 16 | 17 | -------------------------------------------------------------------------------- /addons/test/misra/crash3.c: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | /* This is the representation of the expressions to determine the 6 | plural form. */ 7 | struct expression 8 | { 9 | int nargs; /* Number of arguments. */ 10 | union 11 | { 12 | unsigned long int num; /* Number value for `num'. */ 13 | struct expression *args[3]; /* Up to three arguments. */ 14 | } val; 15 | }; 16 | 17 | 18 | struct expression GERMANIC_PLURAL = 19 | { 20 | .nargs = 2, 21 | .val = 22 | { 23 | .args = 24 | { 25 | [0] = (struct expression *) &plvar, 26 | [1] = (struct expression *) &plone 27 | } 28 | } 29 | }; 30 | 31 | -------------------------------------------------------------------------------- /generate_coverage_report: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | make clean 4 | rm -rf coverage_report 5 | make test CXXOPTS="-g -fprofile-arcs -ftest-coverage" 6 | test/cfg/runtests.sh 7 | gcov lib/*.cpp -o lib/ 8 | lcov --directory ./ --capture --output-file lcov_tmp.info -b ./ 9 | lcov --extract lcov_tmp.info "$(pwd)/*" --output-file lcov.info 10 | genhtml lcov.info -o coverage_report --frame --legend --demangle-cpp 11 | rm cli/*.gcda 12 | rm cli/*.gcno 13 | rm lib/*.gcda 14 | rm lib/*.gcno 15 | rm test/*.gcda 16 | rm test/*.gcno 17 | rm externals/tinyxml2/*.gcda 18 | rm externals/tinyxml2/*.gcno 19 | rm lcov.info lcov_tmp.info 20 | make clean 21 | -------------------------------------------------------------------------------- /win_installer/config.wxi: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /addons/namingng.config.json: -------------------------------------------------------------------------------- 1 | { 2 | "RE_VARNAME": ["[a-z]*[a-zA-Z0-9_]*\\Z"], 3 | "RE_PRIVATE_MEMBER_VARIABLE": null, 4 | "RE_FUNCTIONNAME": ["[a-z0-9A-Z]*\\Z"], 5 | "include_guard": { 6 | "input": "path", 7 | "prefix": "", 8 | "suffix": "", 9 | "case": "upper", 10 | "max_linenr": 5, 11 | "RE_HEADERFILE": "[^/].*\\.h\\Z", 12 | "required": true 13 | }, 14 | "var_prefixes": {"uint32_t": "ui32", 15 | "int*": "intp"}, 16 | "function_prefixes": {"uint16_t": "ui16", 17 | "uint32_t": "ui32"}, 18 | "skip_one_char_variables": false 19 | } 20 | -------------------------------------------------------------------------------- /cmake/compilerCheck.cmake: -------------------------------------------------------------------------------- 1 | if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") 2 | if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.1) 3 | message(ERROR "GCC >= 5.1 required - detected ${CMAKE_CXX_COMPILER_VERSION} not supported") 4 | endif() 5 | elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang") 6 | if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.5) 7 | message(ERROR "Clang >= 3.5 required - detected ${CMAKE_CXX_COMPILER_VERSION} not supported") 8 | endif() 9 | elseif(MSVC) 10 | if(MSVC_VERSION VERSION_LESS 1900) 11 | message(ERROR "Visual Studio >= 2015 (19.0) required - detected ${MSVC_VERSION} not supported") 12 | endif() 13 | endif() 14 | -------------------------------------------------------------------------------- /cppcheck.cppcheck: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | out1 5 | true 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /addons/test/y2038/y2038-inc.h: -------------------------------------------------------------------------------- 1 | #ifndef __INC2038 2 | #define _INC2038 3 | 4 | /* 5 | * This file defines _USE_TIME_BITS64. 6 | * It plays the role of a Y2038-proof glibc. 7 | */ 8 | 9 | #define _USE_TIME_BITS64 10 | 11 | /* 12 | * Declare just enough for clock_gettime 13 | */ 14 | 15 | typedef int clockid_t; 16 | 17 | typedef int __time_t; 18 | 19 | typedef long int __syscall_slong_t; 20 | 21 | struct timespec 22 | { 23 | __time_t tv_sec; /* Seconds. */ 24 | __syscall_slong_t tv_nsec; /* Nanoseconds. */ 25 | }; 26 | 27 | extern int clock_gettime(clockid_t clk_id, struct timespec *tp); 28 | 29 | #define CLOCK_REALTIME 0 30 | 31 | #endif /* INC2038 */ 32 | -------------------------------------------------------------------------------- /tools/run-coverity.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | PATH=$PATH:/home/danielmarjamaki/cov-analysis-linux64-2021.12.1/bin 3 | cd /home/danielmarjamaki/cppcheck-devinfo || exit 1 4 | git pull 5 | 6 | echo Analyze 7 | make clean 8 | nice cov-build --dir cov-int make 9 | 10 | echo Compressing 11 | tar czvf cppcheck.tgz cov-int 12 | 13 | echo Upload 14 | curl --insecure \ 15 | --form token=e74RRnWR6BVsn5LKdclfcA \ 16 | --form email=daniel.marjamaki@gmail.com \ 17 | --form file=@cppcheck.tgz \ 18 | --form version=$(git log -1 --format=oneline | sed -r 's/([a-f0-9]{7}).*/\1/') \ 19 | --form description="Development" \ 20 | https://scan.coverity.com/builds?project=cppcheck 21 | 22 | echo Done 23 | rm -rf cov-int 24 | 25 | -------------------------------------------------------------------------------- /gui/help/investigating-warnings.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Investigating warnings 4 | 5 | 6 | 7 |

Investigating warnings

8 | 9 |

When you have run the analysis it is time to look at the results.

10 | 11 |

If you click on a warning then the corresponding code will be shown in the 12 | "Warning details" at the bottom.

13 | 14 |

You can right click warnings to get options. The difference of 15 | "hiding" a warning and "suppressing" a warning is that 16 | the suppression is permanent and hiding the warning is only temporary. When 17 | suppressing warning(s), that is saved in the project file. 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /test/cli/QML-Samples-TableView/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "samplemodel.h" 4 | 5 | int main(int argc, char *argv[]) 6 | { 7 | QGuiApplication app(argc, argv); 8 | 9 | QQmlApplicationEngine engine; 10 | qmlRegisterType("Test", 1, 0, "SampleModel"); 11 | 12 | const QUrl url(QStringLiteral("qrc:/main.qml")); 13 | QObject::connect(&engine, &QQmlApplicationEngine::objectCreated, 14 | &app, [url](QObject *obj, const QUrl &objUrl) { 15 | if (!obj && url == objUrl) 16 | QCoreApplication::exit(-1); 17 | }, Qt::QueuedConnection); 18 | engine.load(url); 19 | 20 | return app.exec(); 21 | } 22 | -------------------------------------------------------------------------------- /externals/simplecpp/LICENSE: -------------------------------------------------------------------------------- 1 | BSD Zero Clause License 2 | 3 | Copyright (c) 2023 simplecpp team 4 | 5 | Permission to use, copy, modify, and/or distribute this software for any 6 | purpose with or without fee is hereby granted. 7 | 8 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH 9 | REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 10 | AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, 11 | INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 12 | LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR 13 | OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 14 | PERFORMANCE OF THIS SOFTWARE. 15 | -------------------------------------------------------------------------------- /test/cli/QML-Samples-TableView/samplemodel.h: -------------------------------------------------------------------------------- 1 | #ifndef SAMPLEMODEL_H 2 | #define SAMPLEMODEL_H 3 | 4 | #include 5 | 6 | class SampleModel : public QAbstractListModel 7 | { 8 | Q_OBJECT 9 | 10 | typedef QPair Row; 11 | QList _data; 12 | 13 | public: 14 | enum Role { 15 | IdRole = Qt::UserRole + 1, 16 | NameRole, 17 | GradeRole 18 | }; 19 | 20 | SampleModel(QObject *parent = nullptr); 21 | 22 | int rowCount(const QModelIndex &parent) const; 23 | QVariant data(const QModelIndex &index, int role) const; 24 | QHash roleNames() const; 25 | 26 | public slots: 27 | void fillSampleData(int size); 28 | }; 29 | 30 | #endif // SAMPLEMODEL_H 31 | -------------------------------------------------------------------------------- /test/cli/QML-Samples-TableView/TableView.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.0 2 | import QtQuick.Layouts 1.12 3 | import QtQuick.Controls 2.12 4 | import QtQml.Models 2.12 5 | 6 | Item { 7 | id: root 8 | 9 | property alias model: tableView.model 10 | default property list columns 11 | 12 | TableRow { 13 | id: header 14 | anchors.left: parent.left 15 | anchors.right: parent.right 16 | anchors.top: parent.top 17 | background: null 18 | isHeader: true 19 | height: 60 20 | } 21 | 22 | ListView { 23 | id: tableView 24 | clip: true 25 | 26 | anchors.fill: parent 27 | anchors.topMargin: header.height 28 | delegate: TableRow {} 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /cmake/cmake_uninstall.cmake.in: -------------------------------------------------------------------------------- 1 | # ----------------------------------------------- 2 | # File that provides "make uninstall" target 3 | # We use the file 'install_manifest.txt' 4 | # ----------------------------------------------- 5 | if(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") 6 | message(FATAL_ERROR "Cannot find install manifest: \"@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt\"") 7 | endif(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") 8 | 9 | file(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files) 10 | string(REGEX REPLACE "\n" ";" files "${files}") 11 | foreach(file ${files}) 12 | message(STATUS "Uninstalling \"$ENV{DESTDIR}${file}\"") 13 | execute_process(COMMAND rm $ENV{DESTDIR}${file}) 14 | endforeach(file) 15 | 16 | 17 | -------------------------------------------------------------------------------- /addons/test/misra/misra-suppressions2-test.c: -------------------------------------------------------------------------------- 1 | // To test: 2 | // ../../cppcheck --suppressions-list=suppressions.txt --dump misra-suppressions*-test.c && python ../misra.py misra-suppressions*-test.c.dump 3 | // There should be no violations reported 4 | 5 | // cppcheck-suppress-file misra-c2012-5.2 6 | union misra_5_2_field_hides_field__63x { //19.2 7 | int misra_5_2_field_hides_field__31x; 8 | int misra_5_2_field_hides_field__31y;//5.2 9 | }; 10 | struct misra_5_2_field_hides_field__63y { //5.2 11 | int misra_5_2_field_hides_field1_31x; 12 | int misra_5_2_field_hides_field1_31y;//5.2 13 | }; 14 | const char *s41_1 = "\x41g"; // 4.1 8.4 15 | const char *s41_2 = "\x41\x42"; // 8.4 16 | 17 | // cppcheck-suppress misra-c2012-5.7 18 | struct misra_5_7_violation_t { 19 | int x; 20 | }; 21 | -------------------------------------------------------------------------------- /test/cli/QML-Samples-TableView/TableRow.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.0 2 | import QtQuick.Layouts 1.12 3 | import QtQuick.Controls 2.12 4 | import QtQml.Models 2.12 5 | 6 | ItemDelegate { 7 | height: 40 8 | width: parent.width 9 | property bool isHeader: false 10 | RowLayout { 11 | property var _d: model 12 | anchors.fill: parent 13 | anchors.leftMargin: 9 14 | 15 | Repeater { 16 | model: root.columns 17 | Label { 18 | text: parent.parent.isHeader ? modelData.title : parent._d[modelData.role] 19 | Layout.fillWidth: modelData.fillWidth 20 | Layout.preferredWidth: modelData.size !== '*' 21 | ? modelData.size : 20 22 | } 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /tools/listErrorsWithoutCWE.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | from __future__ import print_function 3 | import argparse 4 | import xml.etree.ElementTree as ET 5 | 6 | 7 | def main(): 8 | parser = argparse.ArgumentParser(description="List all error without a CWE assigned in CSV format") 9 | parser.add_argument("-F", metavar="filename", required=True, 10 | help="XML file containing output from: ./cppcheck --errorlist --xml-version=2") 11 | parsed = parser.parse_args() 12 | 13 | tree = ET.parse(vars(parsed)["F"]) 14 | root = tree.getroot() 15 | for child in root.iter("error"): 16 | if "cwe" not in child.attrib: 17 | print(child.attrib["id"], child.attrib["severity"], child.attrib["verbose"], sep=", ") 18 | 19 | if __name__ == "__main__": 20 | main() 21 | -------------------------------------------------------------------------------- /addons/test/misra/misra-test-avr8.c: -------------------------------------------------------------------------------- 1 | // To test: 2 | // ~/cppcheck/cppcheck--dump -DDUMMY --suppress=uninitvar misra/misra-test-avr8.c --std=c89 --platform=avr8 && python3 ../misra.py -verify misra/misra-test-avr8.c.dump 3 | 4 | static void misra_10_4(void) 5 | { 6 | // #10480 7 | const char buf1[1] = {a}; 8 | const char c = '0'; 9 | x = buf1[0] - c; 10 | 11 | const char buf2[2] = {x,y}; 12 | x = 'a' == buf2[0]; // no-warning 13 | 14 | typedef struct { 15 | int t; 16 | char buf[2]; 17 | } foo_t; 18 | const foo_t cmd = {0}; 19 | x = 'b' == cmd.buf[0]; // no-warning 20 | 21 | const foo_t * pcmd = &cmd; 22 | x='c' == pcmd->buf[0]; // no-warning 23 | (void)cmd.t; 24 | } 25 | 26 | static void misra_12_2(void) { 27 | a = (((uint64_t)0xFF) << 32); 28 | } 29 | 30 | -------------------------------------------------------------------------------- /addons/test/y2038/y2038-test-compiler-flags.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Shared test case for Y2038 addon compiler flag testing 3 | * 4 | * This file tests various compiler flag scenarios: 5 | * - Proper Y2038 configuration: -D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64 -D_USE_TIME_BITS64 6 | * - Incorrect _TIME_BITS value: -D_TIME_BITS=32 7 | * - Incomplete configuration: -D_USE_TIME_BITS64 (without _TIME_BITS) 8 | * 9 | * The same source code is used for all scenarios - differentiation happens 10 | * through the compiler flags passed to cppcheck during dump creation. 11 | */ 12 | 13 | #include 14 | 15 | int main(int argc, char **argv) 16 | { 17 | time_t current_time; 18 | struct timespec ts; 19 | 20 | current_time = time(NULL); 21 | clock_gettime(CLOCK_REALTIME, &ts); 22 | 23 | return 0; 24 | } 25 | 26 | -------------------------------------------------------------------------------- /democlient/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # this script downloads and builds the democlient 4 | # syntax: 5 | # ./build 1.60.1 6 | 7 | # cppcheck lib folder 8 | cppchecklib=cppcheck-$1/lib 9 | 10 | echo Downloading... 11 | wget http://downloads.sourceforge.net/project/cppcheck/cppcheck/$1/cppcheck-$1.tar.bz2 12 | 13 | echo Unpacking... 14 | tar xjvf cppcheck-$1.tar.bz2 15 | rm cppcheck-$1.tar.bz2 16 | rm cppcheck-$1/Changelog 17 | 18 | echo Building... 19 | g++ -O2 -o democlient-$1.cgi -I$cppchecklib -Icppcheck-$1/externals/tinyxml2 cppcheck-$1/democlient/democlient.cpp $cppchecklib/*.cpp cppcheck-$1/externals/tinyxml2/tinyxml2.cpp 20 | 21 | echo Copy cgi to webspace... 22 | cp democlient-$1.cgi /home/project-web/cppcheck/cgi-bin/democlient.cgi 23 | chmod +rx /home/project-web/cppcheck/cgi-bin/democlient.cgi 24 | 25 | echo Done! 26 | -------------------------------------------------------------------------------- /test/cfg/cairo.c: -------------------------------------------------------------------------------- 1 | 2 | // Test library configuration for cairo.cfg 3 | // 4 | // Usage: 5 | // $ cppcheck --check-library --library=cairo --enable=style,information --inconclusive --error-exitcode=1 --inline-suppr test/cfg/cairo.c 6 | // => 7 | // No warnings about bad library configuration, unmatched suppressions, etc. exitcode=0 8 | // 9 | 10 | #include 11 | 12 | void validCode(cairo_surface_t *target) 13 | { 14 | cairo_t * cairo1 = cairo_create(target); 15 | cairo_move_to(cairo1, 1.0, 2.0); 16 | cairo_line_to(cairo1, 5.0, 6.0); 17 | cairo_destroy(cairo1); 18 | } 19 | 20 | void ignoredReturnValue(cairo_surface_t *target) 21 | { 22 | // cppcheck-suppress ignoredReturnValue 23 | cairo_create(target); 24 | // cppcheck-suppress ignoredReturnValue 25 | cairo_status_to_string(CAIRO_STATUS_READ_ERROR); 26 | } 27 | -------------------------------------------------------------------------------- /man/manual-style.tex: -------------------------------------------------------------------------------- 1 | \usepackage{titlesec} 2 | \usepackage{fancyvrb,newverbs,xcolor} 3 | \usepackage{xcolor} 4 | 5 | \titleformat{\chapter}[display] 6 | {\normalfont\huge\bfseries}{\chaptertitlename\ \thechapter}{20pt}{\Huge} 7 | \titlespacing*{\chapter}{0pt}{-20pt}{20pt} 8 | 9 | 10 | \definecolor{Light}{HTML}{EEEEEE} 11 | \let\oldtexttt\texttt 12 | \renewcommand{\texttt}[1]{ 13 | \colorbox{Light}{\oldtexttt{#1}} 14 | } 15 | 16 | \lstset{ 17 | basicstyle=\ttfamily, 18 | backgroundcolor=\color{Light}, 19 | xleftmargin=10pt, 20 | frame=lrtb, 21 | framesep=10pt, 22 | framerule=0pt, 23 | showspaces=false, 24 | showstringspaces=false, 25 | showtabs=false, 26 | tabsize=2, 27 | captionpos=b, 28 | breaklines=true, 29 | breakatwhitespace=true, 30 | breakautoindent=true, 31 | linewidth=\textwidth 32 | } 33 | -------------------------------------------------------------------------------- /test/cli/QML-Samples-TableView/TableView.pro: -------------------------------------------------------------------------------- 1 | QT += quick 2 | 3 | CONFIG += c++11 4 | 5 | # You can make your code fail to compile if it uses deprecated APIs. 6 | # In order to do so, uncomment the following line. 7 | #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 8 | 9 | SOURCES += \ 10 | main.cpp \ 11 | samplemodel.cpp 12 | 13 | RESOURCES += qml.qrc 14 | 15 | # Additional import path used to resolve QML modules in Qt Creator's code model 16 | QML_IMPORT_PATH = 17 | 18 | # Additional import path used to resolve QML modules just for Qt Quick Designer 19 | QML_DESIGNER_IMPORT_PATH = 20 | 21 | # Default rules for deployment. 22 | qnx: target.path = /tmp/$${TARGET}/bin 23 | else: unix:!android: target.path = /opt/$${TARGET}/bin 24 | !isEmpty(target.path): INSTALLS += target 25 | 26 | HEADERS += \ 27 | samplemodel.h 28 | -------------------------------------------------------------------------------- /externals/tinyxml2/LICENSE: -------------------------------------------------------------------------------- 1 | This software is provided 'as-is', without any express or implied 2 | warranty. In no event will the authors be held liable for any 3 | damages arising from the use of this software. 4 | 5 | Permission is granted to anyone to use this software for any 6 | purpose, including commercial applications, and to alter it and 7 | redistribute it freely, subject to the following restrictions: 8 | 9 | 1. The origin of this software must not be misrepresented; you must 10 | not claim that you wrote the original software. If you use this 11 | software in a product, an acknowledgment in the product documentation 12 | would be appreciated but is not required. 13 | 14 | 2. Altered source versions must be plainly marked as such, and 15 | must not be misrepresented as being the original software. 16 | 17 | 3. This notice may not be removed or altered from any source 18 | distribution. 19 | -------------------------------------------------------------------------------- /test/cli/QML-Samples-TableView/main.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.12 2 | import QtQuick.Window 2.12 3 | import Test 1.0 4 | import '.' as Here 5 | 6 | Window { 7 | width: 640 8 | height: 480 9 | visible: true 10 | title: qsTr("Hello World") 11 | 12 | Component.onCompleted: sampleModel.fillSampleData(50) 13 | SampleModel { 14 | id: sampleModel 15 | } 16 | 17 | Here.TableView { 18 | anchors.fill: parent 19 | model: sampleModel 20 | 21 | TableColumn { 22 | title: qsTr("Id") 23 | role: 'id' 24 | size: 30 25 | } 26 | TableColumn { 27 | title: qsTr("Name") 28 | role: 'name' 29 | fillWidth: true 30 | } 31 | TableColumn { 32 | title: qsTr("Grade") 33 | role: 'grade' 34 | size: 50 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /test/cfg/lua.c: -------------------------------------------------------------------------------- 1 | 2 | // Test library configuration for lua.cfg 3 | // 4 | // Usage: 5 | // $ cppcheck --check-library --library=lua --enable=style,information --inconclusive --error-exitcode=1 --inline-suppr test/cfg/lua.c 6 | // => 7 | // No warnings about bad library configuration, unmatched suppressions, etc. exitcode=0 8 | // 9 | 10 | #include 11 | #include 12 | 13 | void validCode(lua_State *L) 14 | { 15 | int a = lua_gettop(L); 16 | printf("%d", a); 17 | lua_pushnil(L); 18 | lua_pop(L, 1); 19 | } 20 | 21 | void ignoredReturnValue(lua_State *L) 22 | { 23 | // cppcheck-suppress ignoredReturnValue 24 | lua_tonumber(L, 1); 25 | // cppcheck-suppress ignoredReturnValue 26 | lua_tostring(L, 1); 27 | // cppcheck-suppress ignoredReturnValue 28 | lua_isboolean(L, 1); 29 | // cppcheck-suppress ignoredReturnValue 30 | lua_isnil(L, 1); 31 | } 32 | -------------------------------------------------------------------------------- /man/build-pdf.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # This uses installed fonts, which vary between systems 3 | # Segoe UI and Consolas are standard in Windows 10, DejaVu is more common on Linux 4 | echo Building $1.pdf 5 | 6 | MainFont="Segoe UI" 7 | MonoFont="Consolas" 8 | 9 | is_font_installed() { 10 | fontname=$1 11 | fc-list | grep -i "$fontname" >/dev/null 12 | } 13 | 14 | if ! is_font_installed "$MainFont"; then 15 | MainFont="DejaVu Sans" 16 | fi 17 | if ! is_font_installed "$MonoFont"; then 18 | MonoFont="DejaVu Sans Mono" 19 | fi 20 | 21 | # echo Using $MainFont / $MonoFont 22 | 23 | pandoc $1.md -o $1.pdf -s --number-sections --toc \ 24 | --pdf-engine=xelatex \ 25 | --listings \ 26 | -f markdown \ 27 | -V mainfont="$MainFont" \ 28 | -V monofont="$MonoFont" \ 29 | -V geometry:a4paper \ 30 | -V geometry:margin=2.4cm \ 31 | -V subparagraph \ 32 | -H manual-style.tex 33 | -------------------------------------------------------------------------------- /tools/defines/limits.c: -------------------------------------------------------------------------------- 1 | #include "limits.h" 2 | #include "stdio.h" 3 | 4 | #define PRINT_DEF(d, f) \ 5 | fprintf(stdout, ";"#d "=%"#f, d) 6 | 7 | int main(void) 8 | { 9 | PRINT_DEF(CHAR_BIT, d); 10 | PRINT_DEF(SCHAR_MIN, d); 11 | PRINT_DEF(SCHAR_MAX, d); 12 | PRINT_DEF(UCHAR_MAX, d); 13 | PRINT_DEF(CHAR_MIN, d); 14 | PRINT_DEF(CHAR_MAX, d); 15 | PRINT_DEF(MB_LEN_MAX, d); 16 | PRINT_DEF(SHRT_MIN, d); 17 | PRINT_DEF(SHRT_MAX, d); 18 | PRINT_DEF(USHRT_MAX, d); 19 | PRINT_DEF(INT_MIN, d); 20 | PRINT_DEF(INT_MAX, d); 21 | PRINT_DEF(UINT_MAX, u); 22 | PRINT_DEF(LONG_MIN, ld); 23 | PRINT_DEF(LONG_MAX, ld); 24 | PRINT_DEF(ULONG_MAX, ld); 25 | #if (__STDC_VERSION__ >= 199901L) || (__cplusplus >= 201103L) 26 | PRINT_DEF(LLONG_MIN, lld); 27 | PRINT_DEF(LLONG_MAX, lld); 28 | PRINT_DEF(ULLONG_MAX, llu); 29 | #endif 30 | 31 | return 0; 32 | } 33 | -------------------------------------------------------------------------------- /addons/test/misc-test.cpp: -------------------------------------------------------------------------------- 1 | // To test: 2 | // ~/cppcheck/cppcheck --dump misc-test.cpp && python ../misc.py -verify misc-test.cpp.dump 3 | 4 | #include 5 | #include 6 | 7 | // Warn about string concatenation in array initializers.. 8 | const char *a[] = {"a" "b"}; // stringConcatInArrayInit 9 | const char *b[] = {"a","b" "c"}; // stringConcatInArrayInit 10 | #define MACRO "MACRO" 11 | const char *c[] = { MACRO "text" }; // stringConcatInArrayInit 12 | 13 | 14 | // Function is implicitly virtual 15 | class base { 16 | virtual void dostuff(int); 17 | }; 18 | 19 | class derived : base { 20 | void dostuff(int); // implicitlyVirtual 21 | }; 22 | 23 | 24 | // Pass struct to ellipsis function 25 | struct {int x;int y;} s; 26 | void ellipsis(int x, ...); 27 | void foo(std::vector v) { 28 | ellipsis(321, s); // ellipsisStructArg 29 | ellipsis(321, v[0]); // ellipsisStructArg 30 | } 31 | -------------------------------------------------------------------------------- /tools/check-errorids.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | #set -x 4 | 5 | SCRIPT_DIR="$(dirname "$(realpath "$0")")" 6 | 7 | # TODO: exclude testinternal.cpp 8 | echo 'no --errorlist entry:' 9 | grep -h -o -P '\[[a-zA-Z0-9_]+\]\\n\"' $SCRIPT_DIR/../test/*.cpp | tr -d '[]\"' | sed 's/\\n$//' | sort -u | \ 10 | while read -r id; do 11 | if [ ${#id} -lt 4 ]; then 12 | continue 13 | fi 14 | $SCRIPT_DIR/../cppcheck --errorlist | grep "id=\"$id\"" > /dev/null 15 | # shellcheck disable=SC2181 16 | if [ $? -ne 0 ]; then 17 | echo $id 18 | fi 19 | done 20 | 21 | echo '' 22 | 23 | echo 'no test coverage:' 24 | $SCRIPT_DIR/../cppcheck --errorlist | grep -h -o -P 'id=\"[a-zA-Z0-9_]*\"' | sed 's/\id=//' | tr -d '\"' | sort -u | \ 25 | while read -r id; do 26 | grep -h -o -P "\[$id\]\\\\n\"" $SCRIPT_DIR/../test/*.cpp > /dev/null 27 | # shellcheck disable=SC2181 28 | if [ $? -ne 0 ]; then 29 | echo $id 30 | fi 31 | done -------------------------------------------------------------------------------- /test/cfg/openmp.c: -------------------------------------------------------------------------------- 1 | 2 | // Test library configuration for openmp.cfg 3 | // 4 | // Usage: 5 | // $ cppcheck --check-library --library=openmp --enable=style,information --inconclusive --error-exitcode=1 --inline-suppr test/cfg/openmp.c 6 | // => 7 | // No warnings about bad library configuration, unmatched suppressions, etc. exitcode=0 8 | // 9 | 10 | #include 11 | #include 12 | 13 | void validCode() 14 | { 15 | int arr[20] = { 0 }; 16 | #pragma omp parallel for 17 | for (int i = 0; i < 20; ++i) { 18 | // cppcheck-suppress unreadVariable 19 | arr[i] = i * i; 20 | } 21 | 22 | char * pChars = (char *) omp_target_alloc(4, 1); 23 | printf("pChars: %p", pChars); 24 | omp_target_free(pChars, 1); 25 | } 26 | 27 | void memleak_omp_target_alloc() 28 | { 29 | const char * pChars = (char *) omp_target_alloc(2, 0); 30 | printf("pChars: %p", pChars); 31 | // cppcheck-suppress memleak 32 | } 33 | -------------------------------------------------------------------------------- /gui/precompiled_qmake.h: -------------------------------------------------------------------------------- 1 | /* -*- C++ -*- 2 | * Cppcheck - A tool for static C/C++ code analysis 3 | * Copyright (C) 2007-2024 Cppcheck team. 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #pragma once 20 | #include "precompiled.h" 21 | #include 22 | #include 23 | #include 24 | -------------------------------------------------------------------------------- /test/cfg/libsigc++.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Test library configuration for libsigc++.cfg 3 | // 4 | // Usage: 5 | // $ cppcheck --check-library --library=libsigc++ --enable=style,information --inconclusive --error-exitcode=1 --inline-suppr test/cfg/libsigc++.cpp 6 | // => 7 | // No warnings about bad library configuration, unmatched suppressions, etc. exitcode=0 8 | // 9 | 10 | #include // IWYU pragma: keep 11 | #include 12 | #include 13 | #include 14 | 15 | struct struct1 : public sigc::trackable { 16 | void func1(int) const {} 17 | }; 18 | 19 | void valid_code() 20 | { 21 | const struct1 my_sruct1; 22 | sigc::slot sl = sigc::mem_fun(my_sruct1, &struct1::func1); 23 | if (sl) {} 24 | } 25 | 26 | void ignoredReturnValue() 27 | { 28 | const struct1 my_sruct1; 29 | // cppcheck-suppress ignoredReturnValue 30 | sigc::mem_fun(my_sruct1, &struct1::func1); 31 | } 32 | -------------------------------------------------------------------------------- /addons/findcasts.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # 3 | # Locate casts in the code 4 | # 5 | 6 | import cppcheck 7 | 8 | @cppcheck.checker 9 | def cast(cfg, data): 10 | for token in cfg.tokenlist: 11 | if token.str != '(' or not token.astOperand1 or token.astOperand2: 12 | continue 13 | 14 | # Is it a lambda? 15 | if token.astOperand1.str == '{': 16 | continue 17 | 18 | # we probably have a cast.. if there is something inside the parentheses 19 | # there is a cast. Otherwise this is a function call. 20 | typetok = token.next 21 | if not typetok.isName: 22 | continue 23 | 24 | # cast number => skip output 25 | if token.astOperand1.isNumber: 26 | continue 27 | 28 | # void cast => often used to suppress compiler warnings 29 | if typetok.str == 'void': 30 | continue 31 | 32 | cppcheck.reportError(token, 'information', 'found a cast') 33 | -------------------------------------------------------------------------------- /oss-fuzz/type2.h: -------------------------------------------------------------------------------- 1 | /* -*- C++ -*- 2 | * Cppcheck - A tool for static C/C++ code analysis 3 | * Copyright (C) 2007-2024 Cppcheck team. 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #pragma once 20 | 21 | #include 22 | #include 23 | 24 | std::string generateCode2(const uint8_t *data, size_t dataSize); 25 | 26 | -------------------------------------------------------------------------------- /tools/defines/readme.md: -------------------------------------------------------------------------------- 1 | # Compiler defines 2 | 3 | NOTE: this is preliminary. 4 | 5 | This folder contains scripts to extract compiler-specific defines and definitions for use with a Cppcheck scan. 6 | 7 | Specifying these will get rid of `` warnings (which are reported when `--debug-warnings` is specified) which allows for increased coverage of the ValueFlow. 8 | 9 | ## Files 10 | 11 | - `define.sh` 12 | Invokes the compilation and execution of the various programs which output the compiler-specific defines. 13 | - `float.c` 14 | Outputs the defines provided by `float.h`/`cfloat`. 15 | - `limits.c` 16 | Outputs the defines provided by `limits.h`/`climits`. 17 | - `stdint.c` 18 | Outputs the defines provided by `stdint.h`/`cstdint`. 19 | - `create_platform_cfg.sh` 20 | Generates a platform file from the given compiler which can be given to Cppcheck via `--platform`. 21 | - `run_cppcheck.sh` 22 | Generates the compiler-specific configurations for the given compiler and runs Cppcheck with them. -------------------------------------------------------------------------------- /tools/test/start_donate_cpu_server_test_local.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Script for setting up everything that is needed and then running donate-cpu-server.py as 3 | # a local server for testing. 4 | # To start a real server instead of a local one simply remove the "--test" parameter. 5 | 6 | # You can move this script to another location but then you have to set this path accordingly. 7 | cppcheck_tools_path=.. 8 | 9 | # Paths that should not be changed: 10 | dacaathome_path=~/daca@home 11 | donatedresults_path=${dacaathome_path}/donated-results 12 | 13 | if [ ! -d "${dacaathome_path}" ] 14 | then 15 | mkdir "${dacaathome_path}" 16 | fi 17 | 18 | if [ ! -d "${donatedresults_path}" ] 19 | then 20 | mkdir "${donatedresults_path}" 21 | fi 22 | 23 | if [ ! -f "${dacaathome_path}/packages.txt" ] 24 | then 25 | "${cppcheck_tools_path}/daca2-getpackages.py" > "${dacaathome_path}/packages.txt" 26 | fi 27 | 28 | while : 29 | do 30 | "${cppcheck_tools_path}/donate-cpu-server.py" --test 31 | done 32 | -------------------------------------------------------------------------------- /cli/precompiled.h: -------------------------------------------------------------------------------- 1 | /* -*- C++ -*- 2 | * Cppcheck - A tool for static C/C++ code analysis 3 | * Copyright (C) 2007-2024 Cppcheck team. 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #pragma once 20 | 21 | // IWYU pragma: begin_keep 22 | #include "config.h" 23 | #include "cppcheck.h" 24 | #include "settings.h" 25 | // IWYU pragma: end_keep 26 | -------------------------------------------------------------------------------- /gui/test/xmlreportv2/testxmlreportv2.h: -------------------------------------------------------------------------------- 1 | /* -*- C++ -*- 2 | * Cppcheck - A tool for static C/C++ code analysis 3 | * Copyright (C) 2007-2021 Cppcheck team. 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #include 20 | 21 | class TestXmlReportV2 : public QObject { 22 | Q_OBJECT 23 | 24 | private slots: 25 | void readXml() const; 26 | }; 27 | -------------------------------------------------------------------------------- /addons/test/misra/misra-test-c11.c: -------------------------------------------------------------------------------- 1 | // To test: 2 | // ~/cppcheck/cppcheck --dump misra/misra-test-c11.c --std=c11 3 | // ~/cppcheck/cppcheck --dump -DDUMMY --suppress=uninitvar --inline-suppr misra/misra-test-c11.c --std=c11 --platform=unix64 && python3 ../misra.py -verify misra/misra-test-c11.c.dump 4 | 5 | #include 6 | 7 | typedef unsigned int UINT_TYPEDEF; 8 | struct struct_with_bitfields 9 | { 10 | unsigned int a:2; // Compliant 11 | signed int b:2; // Compliant 12 | UINT_TYPEDEF c:2; // Compliant 13 | int d:2; // 6.1 - plain int not compliant 14 | signed long f:2; // Compliant in c99 or later - explicitly signed integer type 15 | unsigned int g:1; // Compliant 16 | signed int h:1; // 6.2 - signed int with size 1 is not compliant 17 | uint16_t i:1; // Compliant 18 | bool j:1; // Compliant in C99 or later 19 | }; 20 | 21 | static void misra6_1_fn(void) { 22 | // "Use" occurrence should not generate warnings 23 | struct_with_bitfields s; 24 | s.h = 61; 25 | } 26 | -------------------------------------------------------------------------------- /gui/test/translationhandler/testtranslationhandler.h: -------------------------------------------------------------------------------- 1 | /* -*- C++ -*- 2 | * Cppcheck - A tool for static C/C++ code analysis 3 | * Copyright (C) 2007-2021 Cppcheck team. 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #include 20 | 21 | class TestTranslationHandler : public QObject { 22 | Q_OBJECT 23 | 24 | private slots: 25 | void construct() const; 26 | }; 27 | -------------------------------------------------------------------------------- /lib/version.rc: -------------------------------------------------------------------------------- 1 | #include "version.h" 2 | #include "winresrc.h" 3 | 4 | VS_VERSION_INFO VERSIONINFO 5 | FILEVERSION CPPCHECK_VERSION 6 | PRODUCTVERSION CPPCHECK_VERSION 7 | FILEFLAGSMASK 0x17L 8 | #ifdef _DEBUG 9 | FILEFLAGS (0x1L|VS_FF_PRERELEASE) 10 | #else 11 | FILEFLAGS (0x0L|VS_FF_PRERELEASE) 12 | #endif 13 | FILEOS VOS__WINDOWS32 14 | FILETYPE VFT_DLL 15 | FILESUBTYPE VFT2_UNKNOWN 16 | BEGIN 17 | BLOCK "StringFileInfo" 18 | BEGIN 19 | BLOCK "040904b0" 20 | BEGIN 21 | VALUE "FileDescription", "cppcheck core library" 22 | VALUE "FileVersion", CPPCHECK_VERSION_STRING 23 | VALUE "InternalName", "cppcheck" 24 | VALUE "LegalCopyright", LEGALCOPYRIGHT 25 | VALUE "OriginalFilename", "cppcheck.exe" 26 | VALUE "ProductName", "cppcheck core library" 27 | VALUE "ProductVersion", CPPCHECK_VERSION_STRING 28 | END 29 | END 30 | BLOCK "VarFileInfo" 31 | BEGIN 32 | VALUE "Translation", 0x409, 1200 33 | END 34 | END 35 | -------------------------------------------------------------------------------- /cli/version.rc: -------------------------------------------------------------------------------- 1 | #include "../lib/version.h" 2 | #include "winresrc.h" 3 | 4 | VS_VERSION_INFO VERSIONINFO 5 | FILEVERSION CPPCHECK_VERSION 6 | PRODUCTVERSION CPPCHECK_VERSION 7 | FILEFLAGSMASK 0x17L 8 | #ifdef _DEBUG 9 | FILEFLAGS (0x1L|VS_FF_PRERELEASE) 10 | #else 11 | FILEFLAGS (0x0L|VS_FF_PRERELEASE) 12 | #endif 13 | FILEOS VOS__WINDOWS32 14 | FILETYPE VFT_APP 15 | FILESUBTYPE VFT2_UNKNOWN 16 | BEGIN 17 | BLOCK "StringFileInfo" 18 | BEGIN 19 | BLOCK "040904b0" 20 | BEGIN 21 | VALUE "FileDescription", "cppcheck Application" 22 | VALUE "FileVersion", CPPCHECK_VERSION_STRING 23 | VALUE "InternalName", "cppcheck" 24 | VALUE "LegalCopyright", LEGALCOPYRIGHT 25 | VALUE "OriginalFilename", "cppcheck.exe" 26 | VALUE "ProductName", "cppcheck Application" 27 | VALUE "ProductVersion", CPPCHECK_VERSION_STRING 28 | END 29 | END 30 | BLOCK "VarFileInfo" 31 | BEGIN 32 | VALUE "Translation", 0x409, 1200 33 | END 34 | END 35 | -------------------------------------------------------------------------------- /gui/resultitem.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Cppcheck - A tool for static C/C++ code analysis 3 | * Copyright (C) 2007-2025 Cppcheck team. 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #include "resultitem.h" 20 | 21 | ResultItem::ResultItem(QSharedPointer errorItem, Type type, int errorPathIndex) 22 | : errorItem(std::move(errorItem)), mType(type), mErrorPathIndex(errorPathIndex) 23 | {} 24 | -------------------------------------------------------------------------------- /win_installer/cppcheck.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.29020.237 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{930C7802-8A8C-48F9-8165-68863BCCD9DD}") = "cppcheck", "cppcheck.wixproj", "{3B772885-4980-4A76-8407-4DABF8F7757C}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Release|x64 = Release|x64 11 | Release|x86 = Release|x86 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {3B772885-4980-4A76-8407-4DABF8F7757C}.Release|x64.ActiveCfg = Release|x64 15 | {3B772885-4980-4A76-8407-4DABF8F7757C}.Release|x64.Build.0 = Release|x64 16 | {3B772885-4980-4A76-8407-4DABF8F7757C}.Release|x86.ActiveCfg = Release|x86 17 | {3B772885-4980-4A76-8407-4DABF8F7757C}.Release|x86.Build.0 = Release|x86 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = TRUE 21 | EndGlobalSection 22 | EndGlobal 23 | -------------------------------------------------------------------------------- /htmlreport/setup.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | import shutil 3 | from setuptools import find_packages, setup 4 | 5 | with open("README.txt") as f: 6 | readme = f.read() 7 | 8 | shutil.copy("cppcheck-htmlreport", "cppcheck_htmlreport/run.py") 9 | 10 | setup( 11 | name="cppcheck-htmlreport", 12 | description=( 13 | "Python script to parse the XML (version 2) output of " 14 | "cppcheck and generate an HTML report using Pygments for syntax " 15 | "highlighting." 16 | ), 17 | long_description=readme, 18 | author="Cppcheck Team", 19 | url="https://github.com/danmar/cppcheck", 20 | license="GPL", 21 | packages=find_packages(exclude=("tests", "docs")), 22 | use_scm_version={"root": ".."}, 23 | entry_points={ 24 | "console_scripts": [ 25 | "cppcheck-htmlreport = cppcheck_htmlreport:run.main", 26 | ] 27 | }, 28 | install_requires=["Pygments"], 29 | # Required by setuptools-scm 7.0 for Python 3.7+ 30 | setup_requires=["setuptools>=60", "setuptools-scm>=7.0"], 31 | ) 32 | -------------------------------------------------------------------------------- /lib/version.h: -------------------------------------------------------------------------------- 1 | /* -*- C++ -*- 2 | * Cppcheck - A tool for static C/C++ code analysis 3 | * Copyright (C) 2007-2025 Cppcheck team. 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | 20 | #ifndef versionH 21 | #define versionH 22 | 23 | #define CPPCHECK_VERSION_STRING "2.19 dev" 24 | #define CPPCHECK_VERSION 2,18,99,0 25 | 26 | #define LEGALCOPYRIGHT L"Copyright (C) 2007-2025 Cppcheck team." 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /test/tools/donate_cpu_server_test.py: -------------------------------------------------------------------------------- 1 | from importlib import import_module 2 | 3 | donate_cpu_server = import_module('donate-cpu-server') 4 | 5 | def _test_parse_req(req_str, url_exp, queryParams_exp): 6 | url, queryParams = donate_cpu_server.HttpClientThread.parse_req(req_str) 7 | assert url == url_exp and queryParams == queryParams_exp 8 | 9 | def test_parse_req(): 10 | _test_parse_req("", None, None) 11 | _test_parse_req("GET / HTTP/1.1", '/', {}) 12 | _test_parse_req("GET /crash.html HTTP/1.1", '/crash.html', {}) 13 | _test_parse_req("GET /head-uninitvar HTTP/1.1", '/head-uninitvar', {}) 14 | _test_parse_req("GET /check_library-std%3A%3Aunordered_set%3A%3Ainsert%28%29 HTTP/1.1", '/check_library-std%3A%3Aunordered_set%3A%3Ainsert%28%29', {}) 15 | _test_parse_req("GET /head-uninitvar?pkgs=1 HTTP/1.1", '/head-uninitvar', {'pkgs': '1'}) 16 | _test_parse_req("GET /crash.html?pkgs=1 HTTP/1.1", '/crash.html', {'pkgs': '1'}) 17 | _test_parse_req("GET /head-uninitvar?pkgs=1&pkgs2=2 HTTP/1.1", '/head-uninitvar', {'pkgs': '1', 'pkgs2': '2'}) 18 | -------------------------------------------------------------------------------- /tools/triage/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Cppcheck - A tool for static C/C++ code analysis 3 | * Copyright (C) 2007-2021 Cppcheck team. 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #include "mainwindow.h" 20 | 21 | #include 22 | 23 | int main(int argc, char *argv[]) 24 | { 25 | QApplication a(argc, argv); 26 | MainWindow w; 27 | w.show(); 28 | 29 | return QApplication::exec(); 30 | } 31 | -------------------------------------------------------------------------------- /test/cli/shared-items-project/Shared/Shared.vcxitems: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | $(MSBuildAllProjects);$(MSBuildThisFileFullPath) 5 | true 6 | {3633ee6f-e5e8-46fc-87c9-f13a18db966a} 7 | 8 | 9 | 10 | %(AdditionalIncludeDirectories);$(MSBuildThisFileDirectory) 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /tools/trac-keywords.py: -------------------------------------------------------------------------------- 1 | 2 | import subprocess 3 | import sys 4 | 5 | TRACDB = 'trac.db' 6 | 7 | 8 | def readdb(): 9 | cmds = ['sqlite3', TRACDB, 'SELECT id,keywords FROM ticket WHERE status<>"closed";'] 10 | with subprocess.Popen(cmds, stdout=subprocess.PIPE, stderr=subprocess.PIPE) as p: 11 | # TODO: handle p.returncode? 12 | stdout, _ = p.communicate() 13 | data = stdout 14 | ret = {} 15 | for line in data.splitlines(): 16 | pos1 = line.find('|') 17 | if pos1 <= 0: 18 | continue 19 | nr = line[:pos1] 20 | for kw in line[pos1 + 1:].split(' '): 21 | if kw == '': 22 | continue 23 | if kw not in ret: 24 | ret[kw] = [] 25 | ret[kw].append(nr) 26 | return ret 27 | 28 | 29 | for arg in sys.argv[1:]: 30 | if arg.endswith('/trac.db'): 31 | TRACDB = arg 32 | 33 | data = readdb() 34 | for kw in sorted(data.keys()): 35 | out = kw + ':' 36 | for ticket in data[kw]: 37 | out = out + ' ' + ticket 38 | print(out) 39 | -------------------------------------------------------------------------------- /addons/test/path1/misra-suppressions1-test.c: -------------------------------------------------------------------------------- 1 | // To test: 2 | // ../../cppcheck --suppressions-list=suppressions.txt --dump misra-suppressions*-test.c && python ../misra.py misra-suppressions*-test.c.dump 3 | // There should be no violations reported 4 | 5 | // This needs to stay at line number 7 to make the test pass 6 | // If it is changed update suppressions.txt with the new line number 7 | #include //21.6 8 | 9 | extern int misra_5_2_var_hides_var______31x; 10 | static int misra_5_2_var_hides_var______31y;//5.2 11 | static int misra_5_2_function_hides_var_31x; 12 | void misra_5_2_function_hides_var_31y(void) {}//5.2 13 | void foo(void) 14 | { 15 | int i; 16 | switch(misra_5_2_func1()) //16.4 16.6 17 | { 18 | case 1: 19 | { 20 | do 21 | { 22 | for(i = 0; i < 10; i++) 23 | { 24 | if(misra_5_2_func3()) //14.4 25 | { 26 | int misra_5_2_var_hides_var_1____31x; 27 | int misra_5_2_var_hides_var_1____31y;//5.2 28 | } 29 | } 30 | } while(misra_5_2_func2()); //14.4 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /externals/tinyxml2/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB hdrs "*.h") 2 | file(GLOB srcs "*.cpp") 3 | 4 | add_library(tinyxml2 ${srcs} ${hdrs}) 5 | target_dll_compile_definitions(tinyxml2 EXPORT TINYXML2_EXPORT IMPORT TINYXML2_IMPORT) 6 | 7 | # TODO: needs to be fixed upstream 8 | if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") 9 | target_compile_options(tinyxml2 PRIVATE -Wno-suggest-attribute=format) 10 | target_compile_options(tinyxml2 PRIVATE -Wno-useless-cast) 11 | endif() 12 | if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") 13 | target_compile_options_safe(tinyxml2 -Wno-implicit-fallthrough) 14 | target_compile_options_safe(tinyxml2 -Wno-suggest-destructor-override) 15 | target_compile_options_safe(tinyxml2 -Wno-zero-as-null-pointer-constant) 16 | target_compile_options_safe(tinyxml2 -Wno-format-nonliteral) 17 | target_compile_options_safe(tinyxml2 -Wno-inconsistent-missing-destructor-override) 18 | endif() 19 | if(CYGWIN) 20 | target_compile_definitions(-D_LARGEFILE_SOURCE) # required for fseeko() and ftello() 21 | endif() 22 | 23 | target_externals_include_directories(tinyxml2 PUBLIC .) 24 | 25 | -------------------------------------------------------------------------------- /gui/application.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Cppcheck - A tool for static C/C++ code analysis 3 | * Copyright (C) 2007-2023 Cppcheck team. 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #include "application.h" 20 | 21 | #include 22 | 23 | Application::Application(QString name, QString path, 24 | QString params) 25 | : mName(std::move(name)) 26 | , mPath(std::move(path)) 27 | , mParameters(std::move(params)) 28 | {} 29 | -------------------------------------------------------------------------------- /gui/test/cppchecklibrarydata/files/markup_valid.cfg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | READ 26 | READ 27 | WRITE 28 | NOTIFY 29 | 30 | 31 | 32 | connect 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /man/checkers/dangerousTypeCast.md: -------------------------------------------------------------------------------- 1 | 2 | # dangerousTypeCast 3 | 4 | **Message**: Potentially invalid type conversion in old-style C cast, clarify/fix with C++ cast
5 | **Category**: Type Safety
6 | **Severity**: Warning
7 | **Language**: C++, not applicable for C code 8 | 9 | ## Motivation 10 | 11 | C style casts can be dangerous in many ways: 12 | * loss of precision 13 | * loss of sign 14 | * loss of constness 15 | * invalid type conversion 16 | 17 | ## Philosophy 18 | 19 | This checker warns about old style C casts that perform type conversions that can be invalid. 20 | 21 | This checker is not about readability. It is about safety. 22 | 23 | ## How to fix 24 | 25 | You can use `dynamic_cast` or `static_cast` to fix these warnings. 26 | 27 | Before: 28 | ```cpp 29 | struct Base{}; 30 | struct Derived: public Base {}; 31 | void foo(Base* base) { 32 | Derived *p = (Derived*)base; // <- can be invalid 33 | } 34 | ``` 35 | 36 | After: 37 | ```cpp 38 | struct Base{}; 39 | struct Derived: public Base {}; 40 | void foo(Base* base) { 41 | Derived *p = dynamic_cast(base); 42 | } 43 | ``` 44 | -------------------------------------------------------------------------------- /gui/test/filelist/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | qt_wrap_cpp(test-filelist_SRC testfilelist.h) 2 | add_custom_target(build-testfilelist-deps SOURCES ${test-filelist_SRC}) 3 | add_dependencies(gui-build-deps build-testfilelist-deps) 4 | add_executable(test-filelist 5 | ${test-filelist_SRC} 6 | testfilelist.cpp 7 | ${CMAKE_SOURCE_DIR}/gui/filelist.cpp 8 | ) 9 | target_include_directories(test-filelist PRIVATE ${CMAKE_SOURCE_DIR}/gui) 10 | target_compile_definitions(test-filelist PRIVATE SRCDIR="${CMAKE_CURRENT_SOURCE_DIR}") 11 | target_link_libraries(test-filelist ${QT_CORE_LIB} ${QT_TEST_LIB} cppcheck-core simplecpp) 12 | 13 | if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") 14 | if(QT_VERSION VERSION_GREATER_EQUAL "6.9.0") 15 | # caused by Qt generated moc code starting with 6.9.0 - see https://bugreports.qt.io/browse/QTBUG-135638 16 | target_compile_options_safe(test-filelist -Wno-ctad-maybe-unsupported) 17 | endif() 18 | endif() 19 | 20 | if (REGISTER_GUI_TESTS) 21 | add_test(NAME test-filelist COMMAND $) 22 | endif() 23 | 24 | add_dependencies(gui-tests test-filelist) 25 | -------------------------------------------------------------------------------- /cli/signalhandler.h: -------------------------------------------------------------------------------- 1 | /* -*- C++ -*- 2 | * Cppcheck - A tool for static C/C++ code analysis 3 | * Copyright (C) 2007-2024 Cppcheck team. 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef SIGNALHANDLER_H 20 | #define SIGNALHANDLER_H 21 | 22 | #include "config.h" 23 | 24 | #if defined(USE_UNIX_SIGNAL_HANDLING) 25 | 26 | #include 27 | 28 | void register_signal_handler(FILE* output); 29 | 30 | #endif // USE_UNIX_SIGNAL_HANDLING 31 | 32 | #endif // SIGNALHANDLER_H 33 | -------------------------------------------------------------------------------- /.github/workflows/cifuzz.yml: -------------------------------------------------------------------------------- 1 | # Syntax reference https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions 2 | # Environment reference https://help.github.com/en/actions/reference/virtual-environments-for-github-hosted-runners 3 | name: CIFuzz 4 | 5 | on: [pull_request] 6 | 7 | permissions: 8 | contents: read 9 | 10 | jobs: 11 | Fuzzing: 12 | runs-on: ubuntu-latest 13 | if: ${{ github.repository_owner == 'danmar' }} 14 | steps: 15 | - name: Build Fuzzers 16 | id: build 17 | uses: google/oss-fuzz/infra/cifuzz/actions/build_fuzzers@master 18 | with: 19 | oss-fuzz-project-name: 'cppcheck' 20 | dry-run: false 21 | language: c++ 22 | - name: Run Fuzzers 23 | uses: google/oss-fuzz/infra/cifuzz/actions/run_fuzzers@master 24 | with: 25 | oss-fuzz-project-name: 'cppcheck' 26 | fuzz-seconds: 300 27 | dry-run: false 28 | language: c++ 29 | - name: Upload Crash 30 | uses: actions/upload-artifact@v4 31 | if: failure() && steps.build.outcome == 'success' 32 | with: 33 | name: artifacts 34 | path: ./out/artifacts 35 | -------------------------------------------------------------------------------- /gui/test/cppchecklibrarydata/files/markup_unhandled_element.cfg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | READ 27 | READ 28 | WRITE 29 | NOTIFY 30 | 31 | 32 | 33 | connect 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /test/precompiled.h: -------------------------------------------------------------------------------- 1 | /* -*- C++ -*- 2 | * Cppcheck - A tool for static C/C++ code analysis 3 | * Copyright (C) 2007-2024 Cppcheck team. 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #pragma once 20 | 21 | // IWYU pragma: begin_keep 22 | #include "check.h" 23 | #include "config.h" 24 | #include "importproject.h" 25 | #include "library.h" 26 | #include "mathlib.h" 27 | #include "settings.h" 28 | #include "timer.h" 29 | #include "token.h" 30 | #include "tokenlist.h" 31 | #include "tokenize.h" 32 | // IWYU pragma: end_keep 33 | -------------------------------------------------------------------------------- /lib/precompiled.h: -------------------------------------------------------------------------------- 1 | /* -*- C++ -*- 2 | * Cppcheck - A tool for static C/C++ code analysis 3 | * Copyright (C) 2007-2024 Cppcheck team. 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #pragma once 20 | 21 | // IWYU pragma: begin_keep 22 | #include "astutils.h" 23 | #include "errorlogger.h" 24 | #include "library.h" 25 | //#include "matchcompiler.h" 26 | #include "mathlib.h" 27 | #include "token.h" 28 | #include "settings.h" 29 | #include "suppressions.h" 30 | #include "utils.h" 31 | #include "valueflow.h" 32 | // IWYU pragma: end_keep 33 | -------------------------------------------------------------------------------- /gui/precompiled.h: -------------------------------------------------------------------------------- 1 | /* -*- C++ -*- 2 | * Cppcheck - A tool for static C/C++ code analysis 3 | * Copyright (C) 2007-2024 Cppcheck team. 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #pragma once 20 | 21 | // IWYU pragma: begin_keep 22 | #include "checkthread.h" 23 | #include "codeeditor.h" 24 | #include "codeeditorstyle.h" 25 | #include "config.h" 26 | #include "cppcheck.h" 27 | #include "cppchecklibrarydata.h" 28 | #include "report.h" 29 | #include "showtypes.h" 30 | 31 | #include 32 | #include 33 | // IWYU pragma: end_keep 34 | -------------------------------------------------------------------------------- /gui/test/projectfile/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | qt_wrap_cpp(test-projectfile_SRC testprojectfile.h ${CMAKE_SOURCE_DIR}/gui/projectfile.h) 2 | add_custom_target(build-projectfile-deps SOURCES ${test-projectfile_SRC}) 3 | add_dependencies(gui-build-deps build-projectfile-deps) 4 | add_executable(test-projectfile 5 | ${test-projectfile_SRC} 6 | testprojectfile.cpp 7 | ${CMAKE_SOURCE_DIR}/gui/projectfile.cpp 8 | ) 9 | target_include_directories(test-projectfile PRIVATE ${CMAKE_SOURCE_DIR}/gui ${CMAKE_SOURCE_DIR}/lib) 10 | target_compile_definitions(test-projectfile PRIVATE SRCDIR="${CMAKE_CURRENT_SOURCE_DIR}") 11 | target_link_libraries(test-projectfile ${QT_CORE_LIB} ${QT_TEST_LIB}) 12 | 13 | if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") 14 | if(QT_VERSION VERSION_GREATER_EQUAL "6.9.0") 15 | # caused by Qt generated moc code starting with 6.9.0 - see https://bugreports.qt.io/browse/QTBUG-135638 16 | target_compile_options_safe(test-projectfile -Wno-ctad-maybe-unsupported) 17 | endif() 18 | endif() 19 | 20 | if (REGISTER_GUI_TESTS) 21 | add_test(NAME test-projectfile COMMAND $) 22 | endif() 23 | 24 | add_dependencies(gui-tests test-projectfile) -------------------------------------------------------------------------------- /addons/ROS_naming.json: -------------------------------------------------------------------------------- 1 | { 2 | "RE_FILE": [".*[A-Z]"], 3 | "RE_NAMESPACE": {".*[A-Z]": [true, "under_scored"], 4 | ".*\\_$": [true, "under_scored"]}, 5 | "RE_FUNCTIONNAME": {".*\\_": [true, "camelCase"], 6 | ".*^[a-z]": [false, "camelCase"]}, 7 | "RE_CLASS_NAME": {".*^[A-Z]": [false, "CamelCase"], 8 | ".*\\_": [true, "CamelCase"]}, 9 | "RE_GLOBAL_VARNAME": {".*^([g]\\_)": [false, "g_under_scored"], 10 | ".*[A-Z]": [true, "g_under_scored"], 11 | ".*\\_$": [true, "g_under_scored"]}, 12 | "RE_VARNAME": {".*^([g]\\_)": [true, "under_scored"], 13 | ".*[A-Z]": [true, "under_scored"], 14 | ".*\\_$": [true, "under_scored"]}, 15 | "RE_PRIVATE_MEMBER_VARIABLE": {".*\\_$": [false, "under_scored_"], 16 | ".*[A-Z]": [true, "under_scored_"]}, 17 | "RE_PUBLIC_MEMBER_VARIABLE": {".*\\_$": [false, "under_scored_"], 18 | ".*[A-Z]": [true, "under_scored_"]}, 19 | "var_prefixes": {"uint32_t": "ui32", 20 | "int*": "intp"}, 21 | "function_prefixes": {"uint16_t": "ui16", 22 | "uint32_t": "ui32"}, 23 | "skip_one_char_variables": false 24 | } -------------------------------------------------------------------------------- /gui/test/resultstree/testresultstree.h: -------------------------------------------------------------------------------- 1 | /* -*- C++ -*- 2 | * Cppcheck - A tool for static C/C++ code analysis 3 | * Copyright (C) 2007-2021 Cppcheck team. 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #include 20 | 21 | class TestResultsTree : public QObject { 22 | Q_OBJECT 23 | 24 | private slots: 25 | void test1() const; 26 | void multiLineResult() const; 27 | void resultsInSameFile() const; 28 | void testReportType() const; 29 | void testGetGuidelineError() const; 30 | void misraCReportShowClassifications() const; 31 | }; 32 | -------------------------------------------------------------------------------- /addons/cppcheck.py: -------------------------------------------------------------------------------- 1 | 2 | import cppcheckdata 3 | import sys 4 | import os 5 | 6 | __checkers__ = [] 7 | 8 | def checker(f): 9 | __checkers__.append(f) 10 | return f 11 | 12 | 13 | __errorid__ = '' 14 | __addon_name__ = '' 15 | def reportError(location, severity, message, errorId=None): 16 | cppcheckdata.reportError(location, severity, message, __addon_name__, errorId or __errorid__) 17 | 18 | def runcheckers(): 19 | # If there are no checkers then don't run 20 | if len(__checkers__) == 0: 21 | return 22 | global __addon_name__ 23 | global __errorid__ 24 | addon = sys.argv[0] 25 | parser = cppcheckdata.ArgumentParser() 26 | args = parser.parse_args() 27 | 28 | __addon_name__ = os.path.splitext(os.path.basename(addon))[0] 29 | 30 | for dumpfile in args.dumpfile: 31 | if not args.quiet: 32 | print('Checking %s...' % dumpfile) 33 | 34 | data = cppcheckdata.CppcheckData(dumpfile) 35 | 36 | for cfg in data.iterconfigurations(): 37 | if not args.quiet: 38 | print('Checking %s, config %s...' % (dumpfile, cfg.name)) 39 | for c in __checkers__: 40 | __errorid__ = c.__name__ 41 | c(cfg, data) 42 | -------------------------------------------------------------------------------- /gui/test/cppchecklibrarydata/resources.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | files/xml_reader_error.cfg 4 | files/mandatory_attribute_missing.cfg 5 | files/unhandled_element.cfg 6 | files/typechecks_valid.cfg 7 | files/podtype_valid.cfg 8 | files/smartptr_valid.cfg 9 | files/platform_type_valid.cfg 10 | files/platform_type_unhandled_element.cfg 11 | files/memory_resource_unhandled_element.cfg 12 | files/memory_resource_valid.cfg 13 | files/define_valid.cfg 14 | files/undefine_valid.cfg 15 | files/container_unhandled_element.cfg 16 | files/reflection_unhandled_element.cfg 17 | files/reflection_valid.cfg 18 | files/reflection_mandatory_attribute_missing.cfg 19 | files/markup_mandatory_attribute_missing.cfg 20 | files/markup_valid.cfg 21 | files/markup_unhandled_element.cfg 22 | files/container_valid.cfg 23 | 24 | 25 | -------------------------------------------------------------------------------- /lib/reverseanalyzer.h: -------------------------------------------------------------------------------- 1 | /* -*- C++ -*- 2 | * Cppcheck - A tool for static C/C++ code analysis 3 | * Copyright (C) 2007-2024 Cppcheck team. 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef reverseanalyzerH 20 | #define reverseanalyzerH 21 | 22 | struct Analyzer; 23 | class ErrorLogger; 24 | class Settings; 25 | class Token; 26 | class TokenList; 27 | template 28 | class ValuePtr; 29 | 30 | void valueFlowGenericReverse(Token* start, const Token* end, const ValuePtr& a, const TokenList& tokenlist, ErrorLogger& errorLogger, const Settings& settings); 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /tools/triage/readme.txt: -------------------------------------------------------------------------------- 1 | triage tool 2 | This tool lets you comfortably look at Cppcheck analysis results for daca packages. It automatically 3 | downloads the package, extracts it and jumps to the corresponding source code for a Cppcheck 4 | message. 5 | 6 | triage uses "wget" and "tar" 7 | On Linux the tool can be directly run since the programs should be installed. 8 | On Windows something like Cygwin is necessary and the directory containing the executables must be 9 | in the PATH environment variable (for example "C:\cygwin\bin"). 10 | 11 | Usage: 12 | After triage has been started you have to load daca results from a file via the "Load from file" 13 | button or from the clipboard via the "Load from clipboard" button. 14 | The file or clipboard text must contain the package URL line beginning with "ftp://" and the 15 | Cppcheck messages. 16 | When the results data has been parsed successfully you can see a list of Cppcheck messages directly 17 | beneath the "Load ..." buttons. Double-click any entry to let the tool show the source code and jump 18 | to and mark the corresponding line. If the package is not found it is downloaded and extracted 19 | automatically. So after the first double-click it is normal that it takes some time until the 20 | source code is shown. 21 | -------------------------------------------------------------------------------- /addons/test/misra/misra-suppressions1-test.c: -------------------------------------------------------------------------------- 1 | // To test: 2 | // ../../cppcheck --suppressions-list=suppressions.txt --dump misra-suppressions*-test.c && python ../misra.py misra-suppressions*-test.c.dump 3 | // There should be no violations reported 4 | 5 | // This needs to stay at line number 7 to make the test pass 6 | // If it is changed update suppressions.txt with the new line number 7 | // cppcheck-suppress-file misra-c2012-5.2 8 | #include //21.6 9 | 10 | extern int misra_5_2_var_hides_var______31x;//8.4 11 | static int misra_5_2_var_hides_var______31y;//5.2 12 | static int misra_5_2_function_hides_var_31x; 13 | static void misra_5_2_function_hides_var_31y(void) {}//5.2 14 | static void foo(void) 15 | { 16 | int i; 17 | // cppcheck-suppress-begin misra-c2012-16.4 18 | // cppcheck-suppress misra-c2012-16.6 19 | switch(misra_5_2_func1()) //16.4 16.6 20 | { 21 | case 1: 22 | { 23 | do 24 | { 25 | for(i = 0; i < 10; i++) 26 | { 27 | if(misra_5_2_func3()) //17.3 28 | { 29 | int misra_5_2_var_hides_var_1____31x; 30 | int misra_5_2_var_hides_var_1____31y;//5.2 31 | } 32 | } 33 | } while(misra_5_2_func2()); //17.3 34 | } 35 | } 36 | // cppcheck-suppress-end misra-c2012-16.4 37 | } 38 | -------------------------------------------------------------------------------- /gui/test/xmlreportv2/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | qt_wrap_cpp(test-xmlreportv2_SRC testxmlreportv2.h) 2 | add_custom_target(build-xmlreportv2-deps SOURCES ${test-xmlreportv2_SRC}) 3 | add_dependencies(gui-build-deps build-xmlreportv2-deps) 4 | add_executable(test-xmlreportv2 5 | ${test-xmlreportv2_SRC} 6 | testxmlreportv2.cpp 7 | ${CMAKE_SOURCE_DIR}/gui/erroritem.cpp 8 | ${CMAKE_SOURCE_DIR}/gui/report.cpp 9 | ${CMAKE_SOURCE_DIR}/gui/xmlreport.cpp 10 | ${CMAKE_SOURCE_DIR}/gui/xmlreportv2.cpp 11 | ) 12 | target_include_directories(test-xmlreportv2 PRIVATE ${CMAKE_SOURCE_DIR}/gui) 13 | target_compile_definitions(test-xmlreportv2 PRIVATE SRCDIR="${CMAKE_CURRENT_SOURCE_DIR}") 14 | target_link_libraries(test-xmlreportv2 ${QT_CORE_LIB} ${QT_TEST_LIB} cppcheck-core) 15 | if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") 16 | if(QT_VERSION VERSION_GREATER_EQUAL "6.9.0") 17 | # caused by Qt generated moc code starting with 6.9.0 - see https://bugreports.qt.io/browse/QTBUG-135638 18 | target_compile_options_safe(test-xmlreportv2 -Wno-ctad-maybe-unsupported) 19 | endif() 20 | endif() 21 | 22 | if (REGISTER_GUI_TESTS) 23 | add_test(NAME test-xmlreportv2 COMMAND $) 24 | endif() 25 | 26 | add_dependencies(gui-tests test-xmlreportv2) 27 | -------------------------------------------------------------------------------- /lib/vf_settokenvalue.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Cppcheck - A tool for static C/C++ code analysis 3 | * Copyright (C) 2007-2024 Cppcheck team. 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef vfSetTokenValueH 20 | #define vfSetTokenValueH 21 | 22 | #include "sourcelocation.h" 23 | 24 | class Token; 25 | class Settings; 26 | namespace ValueFlow { class Value; } 27 | 28 | namespace ValueFlow 29 | { 30 | void setTokenValue(Token* tok, 31 | Value value, 32 | const Settings& settings, 33 | SourceLocation loc = SourceLocation::current()); 34 | } 35 | 36 | #endif // vfSetTokenValueH 37 | -------------------------------------------------------------------------------- /gui/test/translationhandler/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | qt_wrap_cpp(test-translationhandler_SRC testtranslationhandler.h ${CMAKE_SOURCE_DIR}/gui/translationhandler.h) 2 | add_custom_target(build-translationhandler-deps SOURCES ${test-translationhandler_SRC}) 3 | add_dependencies(gui-build-deps build-translationhandler-deps) 4 | add_executable(test-translationhandler 5 | ${test-translationhandler_SRC} 6 | testtranslationhandler.cpp 7 | ${CMAKE_SOURCE_DIR}/gui/common.cpp 8 | ${CMAKE_SOURCE_DIR}/gui/translationhandler.cpp 9 | ) 10 | target_include_directories(test-translationhandler PRIVATE ${CMAKE_SOURCE_DIR}/gui ${CMAKE_SOURCE_DIR}/lib) 11 | target_link_libraries(test-translationhandler ${QT_CORE_LIB} ${QT_WIDGETS_LIB} ${QT_TEST_LIB}) 12 | 13 | if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") 14 | if(QT_VERSION VERSION_GREATER_EQUAL "6.9.0") 15 | # caused by Qt generated moc code starting with 6.9.0 - see https://bugreports.qt.io/browse/QTBUG-135638 16 | target_compile_options_safe(test-translationhandler -Wno-ctad-maybe-unsupported) 17 | endif() 18 | endif() 19 | 20 | if (REGISTER_GUI_TESTS) 21 | add_test(NAME test-translationhandler COMMAND $ -platform offscreen) 22 | endif() 23 | 24 | add_dependencies(gui-tests test-translationhandler) -------------------------------------------------------------------------------- /test/testcolor.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Cppcheck - A tool for static C/C++ code analysis 3 | * Copyright (C) 2007-2023 Cppcheck team. 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #include "color.h" 20 | #include "fixture.h" 21 | 22 | class TestColor : public TestFixture { 23 | public: 24 | TestColor() : TestFixture("TestColor") {} 25 | 26 | private: 27 | 28 | void run() override { 29 | TEST_CASE(toString); 30 | } 31 | 32 | void toString() const { 33 | // TODO: color conversion is dependent on stdout/stderr being a TTY 34 | ASSERT_EQUALS("", ::toString(Color::FgRed)); 35 | } 36 | }; 37 | 38 | REGISTER_TEST(TestColor) 39 | -------------------------------------------------------------------------------- /gui/test/filelist/testfilelist.h: -------------------------------------------------------------------------------- 1 | /* -*- C++ -*- 2 | * Cppcheck - A tool for static C/C++ code analysis 3 | * Copyright (C) 2007-2021 Cppcheck team. 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #include 20 | 21 | class TestFileList : public QObject { 22 | Q_OBJECT 23 | 24 | private slots: 25 | void addFile() const; 26 | void addPathList() const; 27 | void addFile_notexist() const; 28 | void addFile_unknown() const; 29 | void addDirectory() const; 30 | void addDirectory_recursive() const; 31 | void filterFiles() const; 32 | void filterFiles2() const; 33 | void filterFiles3() const; 34 | void filterFiles4() const; 35 | void filterFiles5() const; 36 | }; 37 | -------------------------------------------------------------------------------- /tools/defines/stdint.c: -------------------------------------------------------------------------------- 1 | #include "stdint.h" 2 | #include "stdio.h" 3 | 4 | #define PRINT_DEF(d, f) \ 5 | fprintf(stdout, ";"#d "=%"#f, d) 6 | 7 | #define PRINT_DEF_N(d1, d2, f) \ 8 | do { \ 9 | PRINT_DEF(d1 ## 8 ## d2, f); \ 10 | PRINT_DEF(d1 ## 16 ## d2, f); \ 11 | PRINT_DEF(d1 ## 32 ## d2, f); \ 12 | PRINT_DEF(d1 ## 64 ## d2, l ## f); \ 13 | } while (0) 14 | 15 | // TODO: fix all format specifiers 16 | int main(void) 17 | { 18 | PRINT_DEF(INTMAX_MIN, ld); 19 | PRINT_DEF(INTMAX_MAX, ld); 20 | PRINT_DEF(UINTMAX_MAX, lu); 21 | PRINT_DEF_N(INT, _MIN, d); 22 | PRINT_DEF_N(INT, _MAX, d); 23 | PRINT_DEF_N(UINT, _MAX, u); 24 | PRINT_DEF_N(INT_LEAST, _MIN, d); 25 | PRINT_DEF_N(INT_LEAST, _MAX, d); 26 | PRINT_DEF_N(UINT_LEAST, _MAX, u); 27 | PRINT_DEF_N(INT_FAST, _MIN, d); 28 | PRINT_DEF_N(INT_FAST, _MAX, d); 29 | PRINT_DEF_N(UINT_FAST, _MAX, u); 30 | PRINT_DEF(INTPTR_MIN, ld); 31 | PRINT_DEF(INTPTR_MAX, ld); 32 | PRINT_DEF(UINTPTR_MAX, lu); 33 | PRINT_DEF(SIZE_MAX, lu); 34 | PRINT_DEF(PTRDIFF_MIN, ld); 35 | PRINT_DEF(PTRDIFF_MAX, ld); 36 | PRINT_DEF(SIG_ATOMIC_MIN, d); 37 | PRINT_DEF(SIG_ATOMIC_MAX, d); 38 | PRINT_DEF(WCHAR_MIN, d); 39 | PRINT_DEF(WCHAR_MAX, d); 40 | PRINT_DEF(WINT_MIN, d); 41 | PRINT_DEF(WINT_MAX, d); 42 | 43 | return 0; 44 | } 45 | -------------------------------------------------------------------------------- /cli/cmdlinelogger.h: -------------------------------------------------------------------------------- 1 | /* -*- C++ -*- 2 | * Cppcheck - A tool for static C/C++ code analysis 3 | * Copyright (C) 2007-2024 Cppcheck team. 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef CMD_LINE_LOGGER_H 20 | #define CMD_LINE_LOGGER_H 21 | 22 | #include 23 | 24 | class CmdLineLogger 25 | { 26 | public: 27 | virtual ~CmdLineLogger() = default; 28 | 29 | /** print a regular message */ 30 | virtual void printMessage(const std::string &message) = 0; 31 | /** print an error message */ 32 | virtual void printError(const std::string &message) = 0; 33 | /** print to the output */ 34 | virtual void printRaw(const std::string &message) = 0; 35 | }; 36 | 37 | #endif // CMD_LINE_LOGGER_H 38 | -------------------------------------------------------------------------------- /lib/clangimport.h: -------------------------------------------------------------------------------- 1 | /* -*- C++ -*- 2 | * Cppcheck - A tool for static C/C++ code analysis 3 | * Copyright (C) 2007-2025 Cppcheck team. 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | 20 | //--------------------------------------------------------------------------- 21 | #ifndef clangimportH 22 | #define clangimportH 23 | //--------------------------------------------------------------------------- 24 | 25 | #include "config.h" 26 | 27 | #include 28 | 29 | class Tokenizer; 30 | 31 | namespace clangimport { 32 | /** 33 | * @throws InternalError thrown on incorrectly linked tokens 34 | */ 35 | void CPPCHECKLIB parseClangAstDump(Tokenizer &tokenizer, std::istream &f); 36 | } 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /lib/keywords.h: -------------------------------------------------------------------------------- 1 | /* -*- C++ -*- 2 | * Cppcheck - A tool for static C/C++ code analysis 3 | * Copyright (C) 2007-2024 Cppcheck team. 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef keywordsH 20 | #define keywordsH 21 | 22 | #include "standards.h" 23 | 24 | #include 25 | #include 26 | 27 | class Keywords 28 | { 29 | public: 30 | static const std::unordered_set& getAll(Standards::cstd_t cStd); 31 | static const std::unordered_set& getAll(Standards::cppstd_t cppStd); 32 | 33 | static const std::unordered_set& getOnly(Standards::cstd_t cStd); 34 | static const std::unordered_set& getOnly(Standards::cppstd_t cppStd); 35 | }; 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /win_installer/productInfo.wxi: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /tools/defines/float.c: -------------------------------------------------------------------------------- 1 | #include "float.h" 2 | #include "stdio.h" 3 | 4 | #define PRINT_DEF(d, f) \ 5 | fprintf(stdout, ";"#d "=%"#f, d) 6 | 7 | int main(void) 8 | { 9 | PRINT_DEF(FLT_RADIX, d); 10 | PRINT_DEF(FLT_MANT_DIG, d); 11 | PRINT_DEF(DBL_MANT_DIG, d); 12 | PRINT_DEF(LDBL_MANT_DIG, d); 13 | PRINT_DEF(FLT_DIG, d); 14 | PRINT_DEF(DBL_DIG, d); 15 | PRINT_DEF(LDBL_DIG, d); 16 | PRINT_DEF(FLT_MIN_EXP, d); 17 | PRINT_DEF(DBL_MIN_EXP, d); 18 | PRINT_DEF(LDBL_MIN_EXP, d); 19 | PRINT_DEF(FLT_MIN_10_EXP, d); 20 | PRINT_DEF(DBL_MIN_10_EXP, d); 21 | PRINT_DEF(LDBL_MIN_10_EXP, d); 22 | PRINT_DEF(FLT_MAX_EXP, d); 23 | PRINT_DEF(DBL_MAX_EXP, d); 24 | PRINT_DEF(LDBL_MAX_EXP, d); 25 | PRINT_DEF(FLT_MAX_10_EXP, d); 26 | PRINT_DEF(DBL_MAX_10_EXP, d); 27 | PRINT_DEF(LDBL_MAX_10_EXP, d); 28 | PRINT_DEF(FLT_MAX, f); // TODO: float-to-double 29 | PRINT_DEF(DBL_MAX, f); 30 | PRINT_DEF(LDBL_MAX, Lf); 31 | PRINT_DEF(FLT_EPSILON, f); // TODO: float-to-double 32 | PRINT_DEF(DBL_EPSILON, f); 33 | PRINT_DEF(LDBL_EPSILON, Lf); 34 | PRINT_DEF(FLT_MIN, f); // TODO: float-to-double 35 | PRINT_DEF(DBL_MIN, f); 36 | PRINT_DEF(LDBL_MIN, Lf); 37 | #if (__STDC_VERSION__ >= 199901L) || (__cplusplus >= 201103L) 38 | PRINT_DEF(FLT_EVAL_METHOD, d); 39 | PRINT_DEF(DECIMAL_DIG, d); 40 | #endif 41 | 42 | return 0; 43 | } 44 | -------------------------------------------------------------------------------- /cfg/microsoft_unittest.cfg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /platforms/cppcheck-platforms.rng: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /cfg/tinyxml2.cfg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | false 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | false 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | false 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | --------------------------------------------------------------------------------