Skip to content

Commit deb707f

Browse files
authored
Merge branch 'main' into main
2 parents 74999d5 + f68ba93 commit deb707f

31 files changed

Lines changed: 928 additions & 246 deletions

.github/workflows/CI-unixish.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,39 @@ jobs:
243243
run: |
244244
ls lib/*.cpp | xargs -n 1 -P $(nproc) g++ -fsyntax-only -std=c++0x -Ilib -Iexternals -Iexternals/picojson -Iexternals/simplecpp -Iexternals/tinyxml2 -DNONNEG
245245
246+
build_cmake_boost:
247+
248+
strategy:
249+
matrix:
250+
os: [macos-13, macos-15] # non-macos platforms are already built with Boost in other contexts
251+
fail-fast: false # Prefer quick result
252+
253+
runs-on: ${{ matrix.os }}
254+
255+
env:
256+
# TODO: figure out why there are cache misses with PCH enabled
257+
CCACHE_SLOPPINESS: pch_defines,time_macros
258+
259+
steps:
260+
- uses: actions/checkout@v4
261+
with:
262+
persist-credentials: false
263+
264+
- name: ccache
265+
uses: hendrikmuhs/ccache-action@v1.2
266+
with:
267+
key: ${{ github.workflow }}-${{ github.job }}-${{ matrix.os }}
268+
269+
# coreutils contains "nproc"
270+
- name: Install missing software on macos
271+
run: |
272+
brew install coreutils boost
273+
274+
- name: CMake build on macOS (with Boost)
275+
run: |
276+
cmake -S . -B cmake.output.boost -G "Unix Makefiles" -DBUILD_TESTS=On -DCMAKE_DISABLE_PRECOMPILE_HEADERS=On -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
277+
cmake --build cmake.output.boost -- -j$(nproc)
278+
246279
build:
247280

248281
strategy:

Makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,7 @@ $(libcppdir)/forwardanalyzer.o: lib/forwardanalyzer.cpp lib/addoninfo.h lib/anal
586586
$(libcppdir)/fwdanalysis.o: lib/fwdanalysis.cpp lib/addoninfo.h lib/astutils.h lib/checkers.h lib/config.h lib/errortypes.h lib/fwdanalysis.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/smallvector.h lib/sourcelocation.h lib/standards.h lib/symboldatabase.h lib/templatesimplifier.h lib/token.h lib/utils.h lib/vfvalue.h
587587
$(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/fwdanalysis.cpp
588588

589-
$(libcppdir)/importproject.o: lib/importproject.cpp externals/picojson/picojson.h externals/tinyxml2/tinyxml2.h lib/addoninfo.h lib/checkers.h lib/config.h lib/errortypes.h lib/filesettings.h lib/importproject.h lib/json.h lib/library.h lib/mathlib.h lib/path.h lib/platform.h lib/settings.h lib/standards.h lib/suppressions.h lib/templatesimplifier.h lib/token.h lib/tokenlist.h lib/utils.h lib/vfvalue.h lib/xml.h
589+
$(libcppdir)/importproject.o: lib/importproject.cpp externals/picojson/picojson.h externals/tinyxml2/tinyxml2.h lib/addoninfo.h lib/checkers.h lib/config.h lib/errortypes.h lib/filesettings.h lib/importproject.h lib/json.h lib/library.h lib/mathlib.h lib/path.h lib/pathmatch.h lib/platform.h lib/settings.h lib/standards.h lib/suppressions.h lib/templatesimplifier.h lib/token.h lib/tokenlist.h lib/utils.h lib/vfvalue.h lib/xml.h
590590
$(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/importproject.cpp
591591

592592
$(libcppdir)/infer.o: lib/infer.cpp lib/calculate.h lib/config.h lib/errortypes.h lib/infer.h lib/mathlib.h lib/templatesimplifier.h lib/token.h lib/utils.h lib/valueptr.h lib/vfvalue.h
@@ -607,7 +607,7 @@ $(libcppdir)/path.o: lib/path.cpp externals/simplecpp/simplecpp.h lib/config.h l
607607
$(libcppdir)/pathanalysis.o: lib/pathanalysis.cpp lib/astutils.h lib/config.h lib/errortypes.h lib/library.h lib/mathlib.h lib/pathanalysis.h lib/smallvector.h lib/sourcelocation.h lib/standards.h lib/symboldatabase.h lib/templatesimplifier.h lib/token.h lib/utils.h lib/vfvalue.h
608608
$(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/pathanalysis.cpp
609609

610-
$(libcppdir)/pathmatch.o: lib/pathmatch.cpp lib/config.h lib/path.h lib/pathmatch.h lib/standards.h lib/utils.h
610+
$(libcppdir)/pathmatch.o: lib/pathmatch.cpp lib/config.h lib/path.h lib/pathmatch.h lib/standards.h
611611
$(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/pathmatch.cpp
612612

613613
$(libcppdir)/platform.o: lib/platform.cpp externals/tinyxml2/tinyxml2.h lib/config.h lib/mathlib.h lib/path.h lib/platform.h lib/standards.h lib/xml.h
@@ -631,7 +631,7 @@ $(libcppdir)/standards.o: lib/standards.cpp externals/simplecpp/simplecpp.h lib/
631631
$(libcppdir)/summaries.o: lib/summaries.cpp lib/addoninfo.h lib/analyzerinfo.h lib/checkers.h lib/config.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/sourcelocation.h lib/standards.h lib/summaries.h lib/symboldatabase.h lib/templatesimplifier.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/vfvalue.h
632632
$(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/summaries.cpp
633633

634-
$(libcppdir)/suppressions.o: lib/suppressions.cpp externals/tinyxml2/tinyxml2.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/filesettings.h lib/mathlib.h lib/path.h lib/platform.h lib/standards.h lib/suppressions.h lib/templatesimplifier.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/vfvalue.h lib/xml.h
634+
$(libcppdir)/suppressions.o: lib/suppressions.cpp externals/tinyxml2/tinyxml2.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/filesettings.h lib/mathlib.h lib/path.h lib/pathmatch.h lib/platform.h lib/standards.h lib/suppressions.h lib/templatesimplifier.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/vfvalue.h lib/xml.h
635635
$(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/suppressions.cpp
636636

637637
$(libcppdir)/templatesimplifier.o: lib/templatesimplifier.cpp lib/addoninfo.h lib/checkers.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/standards.h lib/templatesimplifier.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/vfvalue.h
@@ -817,7 +817,7 @@ test/testother.o: test/testother.cpp lib/addoninfo.h lib/check.h lib/checkers.h
817817
test/testpath.o: test/testpath.cpp lib/addoninfo.h lib/check.h lib/checkers.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/path.h lib/platform.h lib/settings.h lib/standards.h lib/tokenize.h lib/tokenlist.h lib/utils.h test/fixture.h test/helpers.h
818818
$(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testpath.cpp
819819

820-
test/testpathmatch.o: test/testpathmatch.cpp lib/addoninfo.h lib/check.h lib/checkers.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/pathmatch.h lib/platform.h lib/settings.h lib/standards.h lib/utils.h test/fixture.h
820+
test/testpathmatch.o: test/testpathmatch.cpp lib/addoninfo.h lib/check.h lib/checkers.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/path.h lib/pathmatch.h lib/platform.h lib/settings.h lib/standards.h lib/utils.h test/fixture.h
821821
$(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testpathmatch.cpp
822822

823823
test/testplatform.o: test/testplatform.cpp externals/tinyxml2/tinyxml2.h lib/addoninfo.h lib/check.h lib/checkers.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/path.h lib/platform.h lib/settings.h lib/standards.h lib/utils.h lib/xml.h test/fixture.h

addons/misra.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2074,7 +2074,9 @@ def misra_7_2(self, data):
20742074
self.reportError(token, 7, 2)
20752075

20762076
def misra_7_3(self, rawTokens):
2077-
compiled = re.compile(r'^[0-9.]+[Uu]*l+[Uu]*$')
2077+
# Match decimal digits, hex digits, decimal point, and e/E p/P floating
2078+
# point constant exponent separators.
2079+
compiled = re.compile(r'^(0[xX])?[0-9a-fA-FpP.]+[Uu]*l+[Uu]*$')
20782080
for tok in rawTokens:
20792081
if compiled.match(tok.str):
20802082
self.reportError(tok, 7, 3)

addons/test/misra/misra-test.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,20 @@ struct misra_7_3_s
302302
{
303303
uint32_t ul_clka;
304304
uint32_t test123l;
305+
float t = 6.02E23l; // 7.3
306+
float t1 = 6.02E23L;
307+
float u = 0xa1B2.p12l; // 7.3
308+
float u1 = 0xa1B2.p12L;
309+
float v = 0xa1B2.P12l; // 7.3
310+
float v1 = 0xa1B2.P12L;
311+
float w = 6.02e23l; // 7.3
312+
float w1 = 6.02e23L;
313+
unsigned long x = 0xabcul; // 7.3
314+
unsigned long x1 = 0xabcuL;
315+
unsigned long y = 0xABCUl; // 7.3
316+
unsigned long y1 = 0xABCUL;
317+
unsigned long z = 0XdeadBeEfUl; // 7.3
318+
unsigned long z1 = 0XdeadBeEfUL;
305319
};
306320

307321
static void misra_7_3(void) {

cli/cmdlineparser.cpp

Lines changed: 14 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -209,11 +209,13 @@ bool CmdLineParser::fillSettingsFromArgs(int argc, const char* const argv[])
209209
std::list<FileSettings> fileSettings;
210210
if (!mSettings.fileFilters.empty()) {
211211
// filter only for the selected filenames from all project files
212+
PathMatch filtermatcher(mSettings.fileFilters, Path::getCurrentPath());
212213
std::copy_if(fileSettingsRef.cbegin(), fileSettingsRef.cend(), std::back_inserter(fileSettings), [&](const FileSettings &fs) {
213-
return matchglobs(mSettings.fileFilters, fs.filename());
214+
return filtermatcher.match(fs.filename());
214215
});
215216
if (fileSettings.empty()) {
216-
mLogger.printError("could not find any files matching the filter.");
217+
for (const std::string& f: mSettings.fileFilters)
218+
mLogger.printError("could not find any files matching the filter:" + f);
217219
return false;
218220
}
219221
}
@@ -242,16 +244,9 @@ bool CmdLineParser::fillSettingsFromArgs(int argc, const char* const argv[])
242244

243245
if (!pathnamesRef.empty()) {
244246
std::list<FileWithDetails> filesResolved;
245-
// TODO: this needs to be inlined into PathMatch as it depends on the underlying filesystem
246-
#if defined(_WIN32)
247-
// For Windows we want case-insensitive path matching
248-
const bool caseSensitive = false;
249-
#else
250-
const bool caseSensitive = true;
251-
#endif
252247
// Execute recursiveAddFiles() to each given file parameter
253248
// TODO: verbose log which files were ignored?
254-
const PathMatch matcher(ignored, caseSensitive);
249+
const PathMatch matcher(ignored, Path::getCurrentPath());
255250
for (const std::string &pathname : pathnamesRef) {
256251
const std::string err = FileLister::recursiveAddFiles(filesResolved, Path::toNativeSeparators(pathname), mSettings.library.markupExtensions(), matcher, mSettings.debugignore);
257252
if (!err.empty()) {
@@ -285,7 +280,8 @@ bool CmdLineParser::fillSettingsFromArgs(int argc, const char* const argv[])
285280
if (!mSettings.fileFilters.empty()) {
286281
files = filterFiles(mSettings.fileFilters, filesResolved);
287282
if (files.empty()) {
288-
mLogger.printError("could not find any files matching the filter.");
283+
for (const std::string& f: mSettings.fileFilters)
284+
mLogger.printError("could not find any files matching the filter:" + f);
289285
return false;
290286
}
291287
}
@@ -1130,7 +1126,7 @@ CmdLineParser::Result CmdLineParser::parseFromArgs(int argc, const char* const a
11301126

11311127
mSettings.checkAllConfigurations = false; // Can be overridden with --max-configs or --force
11321128
std::string projectFile = argv[i]+10;
1133-
projectType = project.import(projectFile, &mSettings, &mSuppressions);
1129+
projectType = project.import(projectFile, &mSettings, &mSuppressions, isCppcheckPremium());
11341130
if (projectType == ImportProject::Type::CPPCHECK_GUI) {
11351131
for (const std::string &lib : project.guiProject.libraries)
11361132
mSettings.libraries.emplace_back(lib);
@@ -1622,19 +1618,7 @@ CmdLineParser::Result CmdLineParser::parseFromArgs(int argc, const char* const a
16221618
for (auto& path : mIgnoredPaths)
16231619
{
16241620
path = Path::removeQuotationMarks(std::move(path));
1625-
path = Path::simplifyPath(std::move(path));
1626-
1627-
bool isdir = false;
1628-
if (!Path::exists(path, &isdir) && mSettings.debugignore) {
1629-
// FIXME: this is misleading because we match from the end of the path so it does not require to exist
1630-
//std::cout << "path to ignore does not exist: " << path << std::endl;
1631-
}
1632-
// TODO: this only works when it exists
1633-
if (isdir) {
1634-
// If directory name doesn't end with / or \, add it
1635-
if (!endsWith(path, '/'))
1636-
path += '/';
1637-
}
1621+
path = Path::fromNativeSeparators(std::move(path));
16381622
}
16391623

16401624
if (!project.guiProject.pathNames.empty())
@@ -1792,10 +1776,9 @@ void CmdLineParser::printHelp() const
17921776
" this is not needed.\n"
17931777
" --include=<file>\n"
17941778
" Force inclusion of a file before the checked file.\n"
1795-
" -i <dir or file> Give a source file or source file directory to exclude\n"
1796-
" from the check. This applies only to source files so\n"
1797-
" header files included by source files are not matched.\n"
1798-
" Directory name is matched to all parts of the path.\n"
1779+
" -i <str> Exclude source files or directories matching str from\n"
1780+
" the check. This applies only to source files so header\n"
1781+
" files included by source files are not matched.\n"
17991782
" --inconclusive Allow that Cppcheck reports even though the analysis is\n"
18001783
" inconclusive.\n"
18011784
" There are false positives with this option. Each result\n"
@@ -2160,13 +2143,9 @@ bool CmdLineParser::loadCppcheckCfg()
21602143
std::list<FileWithDetails> CmdLineParser::filterFiles(const std::vector<std::string>& fileFilters,
21612144
const std::list<FileWithDetails>& filesResolved) {
21622145
std::list<FileWithDetails> files;
2163-
#ifdef _WIN32
2164-
constexpr bool caseInsensitive = true;
2165-
#else
2166-
constexpr bool caseInsensitive = false;
2167-
#endif
2146+
PathMatch filtermatcher(fileFilters, Path::getCurrentPath());
21682147
std::copy_if(filesResolved.cbegin(), filesResolved.cend(), std::inserter(files, files.end()), [&](const FileWithDetails& entry) {
2169-
return matchglobs(fileFilters, entry.path(), caseInsensitive) || matchglobs(fileFilters, entry.spath(), caseInsensitive);
2148+
return filtermatcher.match(entry.path());
21702149
});
21712150
return files;
21722151
}

cli/filelister.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,7 @@ static std::string addFiles2(std::list<FileWithDetails>&files, const std::string
129129
} else {
130130
// Directory
131131
if (recursive) {
132-
// append a slash if it is a directory since that is what we are doing for mIgnoredPaths directory entries.
133-
// otherwise we would ignore all its contents individually instead as a whole.
134-
if (!ignored.match(fname + '/')) {
132+
if (!ignored.match(fname)) {
135133
std::list<FileWithDetails> filesSorted;
136134

137135
std::string err = addFiles2(filesSorted, fname, extra, recursive, ignored);
@@ -243,9 +241,7 @@ static std::string addFiles2(std::list<FileWithDetails> &files,
243241
#endif
244242
if (path_is_directory) {
245243
if (recursive) {
246-
// append a slash if it is a directory since that is what we are doing for mIgnoredPaths directory entries.
247-
// otherwise we would ignore all its contents individually instead as a whole.
248-
if (!ignored.match(new_path + '/')) {
244+
if (!ignored.match(new_path)) {
249245
std::string err = addFiles2(files, new_path, extra, recursive, ignored, debug);
250246
if (!err.empty()) {
251247
return err;

gui/filelist.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -119,11 +119,7 @@ static std::vector<std::string> toStdStringList(const QStringList &stringList)
119119

120120
QStringList FileList::applyExcludeList() const
121121
{
122-
#ifdef _WIN32
123-
const PathMatch pathMatch(toStdStringList(mExcludedPaths), true);
124-
#else
125-
const PathMatch pathMatch(toStdStringList(mExcludedPaths), false);
126-
#endif
122+
const PathMatch pathMatch(toStdStringList(mExcludedPaths), QDir::currentPath().toStdString());
127123

128124
QStringList paths;
129125
for (const QFileInfo& item : mFileList) {

0 commit comments

Comments
 (0)