Skip to content

Commit 03d32d8

Browse files
committed
fast valueflow
1 parent 646f869 commit 03d32d8

19 files changed

Lines changed: 10505 additions & 21 deletions

Makefile

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@ LIBOBJ = $(libcppdir)/valueflow.o \
243243
$(libcppdir)/platform.o \
244244
$(libcppdir)/preprocessor.o \
245245
$(libcppdir)/programmemory.o \
246+
$(libcppdir)/programmemoryfast.o \
246247
$(libcppdir)/reverseanalyzer.o \
247248
$(libcppdir)/settings.o \
248249
$(libcppdir)/summaries.o \
@@ -252,6 +253,7 @@ LIBOBJ = $(libcppdir)/valueflow.o \
252253
$(libcppdir)/token.o \
253254
$(libcppdir)/tokenlist.o \
254255
$(libcppdir)/utils.o \
256+
$(libcppdir)/valueflowfast.o \
255257
$(libcppdir)/vfvalue.o
256258

257259
EXTOBJ = externals/simplecpp/simplecpp.o \
@@ -338,6 +340,7 @@ TESTOBJ = test/fixture.o \
338340
test/testutils.o \
339341
test/testvaarg.o \
340342
test/testvalueflow.o \
343+
test/testvalueflowfast.o \
341344
test/testvarid.o
342345

343346
.PHONY: run-dmake tags
@@ -459,7 +462,7 @@ validateRules:
459462

460463
###### Build
461464

462-
$(libcppdir)/valueflow.o: lib/valueflow.cpp lib/addoninfo.h lib/analyzer.h lib/astutils.h lib/calculate.h lib/check.h lib/checkuninitvar.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/findtoken.h lib/forwardanalyzer.h lib/infer.h lib/library.h lib/mathlib.h lib/path.h lib/platform.h lib/programmemory.h lib/reverseanalyzer.h lib/settings.h lib/smallvector.h lib/sourcelocation.h lib/standards.h lib/suppressions.h lib/symboldatabase.h lib/templatesimplifier.h lib/timer.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/valueflow.h lib/valueptr.h lib/vfvalue.h
465+
$(libcppdir)/valueflow.o: lib/valueflow.cpp lib/addoninfo.h lib/analyzer.h lib/astutils.h lib/calculate.h lib/check.h lib/checkuninitvar.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/findtoken.h lib/forwardanalyzer.h lib/infer.h lib/library.h lib/mathlib.h lib/path.h lib/platform.h lib/programmemory.h lib/reverseanalyzer.h lib/settings.h lib/smallvector.h lib/sourcelocation.h lib/standards.h lib/suppressions.h lib/symboldatabase.h lib/templatesimplifier.h lib/timer.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/valueflow.h lib/valueflowfast.h lib/valueptr.h lib/vfvalue.h
463466
$(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/valueflow.cpp
464467

465468
$(libcppdir)/tokenize.o: lib/tokenize.cpp externals/simplecpp/simplecpp.h lib/addoninfo.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/path.h lib/platform.h lib/preprocessor.h lib/settings.h lib/sourcelocation.h lib/standards.h lib/summaries.h lib/suppressions.h lib/symboldatabase.h lib/templatesimplifier.h lib/timer.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/valueflow.h lib/vfvalue.h
@@ -618,6 +621,9 @@ $(libcppdir)/preprocessor.o: lib/preprocessor.cpp externals/simplecpp/simplecpp.
618621
$(libcppdir)/programmemory.o: lib/programmemory.cpp lib/addoninfo.h lib/astutils.h lib/calculate.h lib/config.h lib/errortypes.h lib/infer.h lib/library.h lib/mathlib.h lib/platform.h lib/programmemory.h lib/settings.h lib/smallvector.h lib/sourcelocation.h lib/standards.h lib/suppressions.h lib/symboldatabase.h lib/templatesimplifier.h lib/token.h lib/utils.h lib/valueflow.h lib/valueptr.h lib/vfvalue.h
619622
$(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/programmemory.cpp
620623

624+
$(libcppdir)/programmemoryfast.o: lib/programmemoryfast.cpp lib/astutils.h lib/config.h lib/errortypes.h lib/library.h lib/mathlib.h lib/programmemoryfast.h lib/smallvector.h lib/sourcelocation.h lib/standards.h lib/symboldatabase.h lib/templatesimplifier.h lib/token.h lib/utils.h lib/valueflow.h lib/vfvalue.h
625+
$(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/programmemoryfast.cpp
626+
621627
$(libcppdir)/reverseanalyzer.o: lib/reverseanalyzer.cpp lib/addoninfo.h lib/analyzer.h lib/astutils.h lib/config.h lib/errortypes.h lib/forwardanalyzer.h lib/library.h lib/mathlib.h lib/platform.h lib/reverseanalyzer.h lib/settings.h lib/smallvector.h lib/sourcelocation.h lib/standards.h lib/suppressions.h lib/symboldatabase.h lib/templatesimplifier.h lib/token.h lib/utils.h lib/valueptr.h lib/vfvalue.h
622628
$(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/reverseanalyzer.cpp
623629

@@ -645,6 +651,9 @@ $(libcppdir)/tokenlist.o: lib/tokenlist.cpp externals/simplecpp/simplecpp.h lib/
645651
$(libcppdir)/utils.o: lib/utils.cpp lib/config.h lib/utils.h
646652
$(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/utils.cpp
647653

654+
$(libcppdir)/valueflowfast.o: lib/valueflowfast.cpp lib/addoninfo.h lib/astutils.h lib/calculate.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/fwdanalysis.h lib/library.h lib/mathlib.h lib/path.h lib/platform.h lib/programmemoryfast.h lib/settings.h lib/smallvector.h lib/sourcelocation.h lib/standards.h lib/suppressions.h lib/symboldatabase.h lib/templatesimplifier.h lib/token.h lib/tokenlist.h lib/utils.h lib/valueflow.h lib/valueflowfast.h lib/vfvalue.h
655+
$(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/valueflowfast.cpp
656+
648657
$(libcppdir)/vfvalue.o: lib/vfvalue.cpp lib/config.h lib/errortypes.h lib/mathlib.h lib/templatesimplifier.h lib/token.h lib/utils.h lib/vfvalue.h
649658
$(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/vfvalue.cpp
650659

@@ -888,6 +897,9 @@ test/testvaarg.o: test/testvaarg.cpp lib/addoninfo.h lib/check.h lib/checkvaarg.
888897
test/testvalueflow.o: test/testvalueflow.cpp lib/addoninfo.h lib/check.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/standards.h lib/suppressions.h lib/templatesimplifier.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/vfvalue.h test/fixture.h test/helpers.h
889898
$(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testvalueflow.cpp
890899

900+
test/testvalueflowfast.o: test/testvalueflowfast.cpp externals/simplecpp/simplecpp.h lib/addoninfo.h lib/check.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/standards.h lib/suppressions.h lib/templatesimplifier.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/valueflow.h lib/vfvalue.h test/fixture.h test/helpers.h
901+
$(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testvalueflowfast.cpp
902+
891903
test/testvarid.o: test/testvarid.cpp lib/addoninfo.h lib/check.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/standards.h lib/suppressions.h lib/templatesimplifier.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/vfvalue.h test/fixture.h test/helpers.h
892904
$(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testvarid.cpp
893905

cli/cmdlineparser.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,9 @@ CmdLineParser::Result CmdLineParser::parseFromArgs(int argc, const char* const a
475475
else if (std::strncmp(argv[i], "--check-level=", 14) == 0) {
476476
Settings::CheckLevel level = Settings::CheckLevel::normal;
477477
const std::string level_s(argv[i] + 14);
478-
if (level_s == "normal")
478+
if (level_s == "fast")
479+
level = Settings::CheckLevel::fast;
480+
else if (level_s == "normal")
479481
level = Settings::CheckLevel::normal;
480482
else if (level_s == "exhaustive")
481483
level = Settings::CheckLevel::exhaustive;

lib/checkother.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3585,7 +3585,7 @@ void CheckOther::checkShadowVariables()
35853585
continue;
35863586
if (scope.type == Scope::eFunction && scope.className == var.name())
35873587
continue;
3588-
if (functionScope->functionOf && functionScope->functionOf->isClassOrStructOrUnion() && functionScope->function && functionScope->function->isStatic() &&
3588+
if (functionScope && functionScope->functionOf && functionScope->functionOf->isClassOrStructOrUnion() && functionScope->function && functionScope->function->isStatic() &&
35893589
shadowed->variable() && !shadowed->variable()->isLocal())
35903590
continue;
35913591
shadowError(var.nameToken(), shadowed, (shadowed->varId() != 0) ? "variable" : "function");

lib/cppcheck.vcxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@
7878
<ClCompile Include="platform.cpp" />
7979
<ClCompile Include="preprocessor.cpp" />
8080
<ClCompile Include="programmemory.cpp" />
81+
<ClCompile Include="programmemoryfast.cpp" />
8182
<ClCompile Include="reverseanalyzer.cpp" />
8283
<ClCompile Include="settings.cpp" />
8384
<ClCompile Include="summaries.cpp" />
@@ -87,6 +88,7 @@
8788
<ClCompile Include="token.cpp" />
8889
<ClCompile Include="tokenlist.cpp" />
8990
<ClCompile Include="utils.cpp" />
91+
<ClCompile Include="valueflowfast.cpp" />
9092
<ClCompile Include="vfvalue.cpp" />
9193
</ItemGroup>
9294
<ItemGroup Label="HeaderFiles">
@@ -149,6 +151,7 @@
149151
<ClInclude Include="precompiled.h" />
150152
<ClInclude Include="preprocessor.h" />
151153
<ClInclude Include="programmemory.h" />
154+
<ClInclude Include="programmemoryfast.h" />
152155
<ClInclude Include="reverseanalyzer.h" />
153156
<ClInclude Include="settings.h" />
154157
<ClInclude Include="smallvector.h" />
@@ -164,6 +167,7 @@
164167
<ClInclude Include="tokenrange.h" />
165168
<ClInclude Include="utils.h" />
166169
<ClInclude Include="valueflow.h" />
170+
<ClInclude Include="valueflowfast.h" />
167171
<ClInclude Include="valueptr.h" />
168172
<ClInclude Include="version.h" />
169173
<ClInclude Include="vfvalue.h" />

lib/lib.pri

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ HEADERS += $${PWD}/addoninfo.h \
6060
$${PWD}/precompiled.h \
6161
$${PWD}/preprocessor.h \
6262
$${PWD}/programmemory.h \
63+
$${PWD}/programmemoryfast.h \
6364
$${PWD}/reverseanalyzer.h \
6465
$${PWD}/settings.h \
6566
$${PWD}/smallvector.h \
@@ -75,6 +76,7 @@ HEADERS += $${PWD}/addoninfo.h \
7576
$${PWD}/tokenrange.h \
7677
$${PWD}/utils.h \
7778
$${PWD}/valueflow.h \
79+
$${PWD}/valueflowfast.h \
7880
$${PWD}/valueptr.h \
7981
$${PWD}/version.h \
8082
$${PWD}/vfvalue.h \
@@ -133,6 +135,7 @@ SOURCES += $${PWD}/valueflow.cpp \
133135
$${PWD}/platform.cpp \
134136
$${PWD}/preprocessor.cpp \
135137
$${PWD}/programmemory.cpp \
138+
$${PWD}/programmemoryfast.cpp \
136139
$${PWD}/reverseanalyzer.cpp \
137140
$${PWD}/settings.cpp \
138141
$${PWD}/summaries.cpp \
@@ -142,4 +145,5 @@ SOURCES += $${PWD}/valueflow.cpp \
142145
$${PWD}/token.cpp \
143146
$${PWD}/tokenlist.cpp \
144147
$${PWD}/utils.cpp \
148+
$${PWD}/valueflowfast.cpp \
145149
$${PWD}/vfvalue.cpp

0 commit comments

Comments
 (0)