Skip to content

Commit ecd4e18

Browse files
committed
ValueFlow: introduced cf/analyze.h to group all analyze headers / prefix extracted function with analyze / use ValueFlow namespace in split implementation
1 parent 50e13b7 commit ecd4e18

8 files changed

Lines changed: 36 additions & 7 deletions

File tree

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -621,7 +621,7 @@ $(libcppdir)/tokenlist.o: lib/tokenlist.cpp externals/simplecpp/simplecpp.h lib/
621621
$(libcppdir)/utils.o: lib/utils.cpp lib/config.h lib/utils.h
622622
$(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/utils.cpp
623623

624-
$(libcppdir)/valueflow.o: lib/valueflow.cpp lib/analyzer.h lib/astutils.h lib/calculate.h lib/check.h lib/checkuninitvar.h lib/color.h lib/config.h lib/ctu.h lib/errorlogger.h lib/errortypes.h lib/forwardanalyzer.h lib/importproject.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/tokenlist.h lib/utils.h lib/valueflow.h lib/valueptr.h lib/vf/enumvalue.h lib/vfvalue.h
624+
$(libcppdir)/valueflow.o: lib/valueflow.cpp lib/analyzer.h lib/astutils.h lib/calculate.h lib/check.h lib/checkuninitvar.h lib/color.h lib/config.h lib/ctu.h lib/errorlogger.h lib/errortypes.h lib/forwardanalyzer.h lib/importproject.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/tokenlist.h lib/utils.h lib/valueflow.h lib/valueptr.h lib/vf/analyze.h lib/vf/enumvalue.h lib/vfvalue.h
625625
$(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/valueflow.cpp
626626

627627
$(libcppdir)/vf/enumvalue.o: lib/vf/enumvalue.cpp lib/vf/enumvalue.h

lib/cppcheck.vcxproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@
176176
<ClInclude Include="valueflow.h" />
177177
<ClInclude Include="valueptr.h" />
178178
<ClInclude Include="version.h" />
179+
<ClInclude Include="vf/analyze.h" />
179180
<ClInclude Include="vf/enumvalue.h" />
180181
<ClInclude Include="vfvalue.h" />
181182
</ItemGroup>

lib/lib.pri

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ HEADERS += $${PWD}/analyzer.h \
7070
$${PWD}/valueflow.h \
7171
$${PWD}/valueptr.h \
7272
$${PWD}/version.h \
73+
$${PWD}/vf/analyze.h \
7374
$${PWD}/vf/enumvalue.h \
7475
$${PWD}/vfvalue.h
7576

lib/valueflow.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@
102102
#include "valueptr.h"
103103
#include "vfvalue.h"
104104

105-
#include "vf/enumvalue.h"
105+
#include "vf/analyze.h"
106106

107107
#include <algorithm>
108108
#include <array>
@@ -8809,13 +8809,13 @@ void ValueFlow::setValues(TokenList *tokenlist, SymbolDatabase* symboldatabase,
88098809
for (Token *tok = tokenlist->front(); tok; tok = tok->next())
88108810
tok->clearValueFlow();
88118811

8812-
ValueFlow::enumValue(symboldatabase, settings);
8812+
ValueFlow::analyzeEnumValue(symboldatabase, settings);
88138813
valueFlowNumber(tokenlist);
88148814
valueFlowString(tokenlist);
88158815
valueFlowArray(tokenlist);
88168816
valueFlowUnknownFunctionReturn(tokenlist, settings);
88178817
valueFlowGlobalConstVar(tokenlist, settings);
8818-
ValueFlow::enumValue(symboldatabase, settings);
8818+
ValueFlow::analyzeEnumValue(symboldatabase, settings);
88198819
valueFlowNumber(tokenlist);
88208820
valueFlowGlobalStaticVar(tokenlist, settings);
88218821
valueFlowPointerAlias(tokenlist);

lib/vf/analyze.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
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 <http://www.gnu.org/licenses/>.
17+
*/
18+
19+
#ifndef vfAnalyzeeH
20+
#define vfAnalyzeeH
21+
22+
#include "enumvalue.h"
23+
24+
#endif // vfAnalyzeeH

lib/vf/enumvalue.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@
2323
#include "token.h"
2424
#include "valueflow.h"
2525

26-
void ValueFlow::enumValue(SymbolDatabase * symboldatabase, const Settings * settings)
26+
using namespace ValueFlow;
27+
28+
void ValueFlow::analyzeEnumValue(SymbolDatabase * symboldatabase, const Settings * settings)
2729
{
2830
for (Scope & scope : symboldatabase->scopeList) {
2931
if (scope.type != Scope::eEnum)
@@ -34,7 +36,7 @@ void ValueFlow::enumValue(SymbolDatabase * symboldatabase, const Settings * sett
3436
for (Enumerator & enumerator : scope.enumeratorList) {
3537
if (enumerator.start) {
3638
Token *rhs = enumerator.start->previous()->astOperand2();
37-
ValueFlow::valueFlowConstantFoldAST(rhs, settings);
39+
valueFlowConstantFoldAST(rhs, settings);
3840
if (rhs && rhs->hasKnownIntValue()) {
3941
enumerator.value = rhs->values().front().intvalue;
4042
enumerator.value_known = true;

lib/vf/enumvalue.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class Settings;
2424

2525
namespace ValueFlow
2626
{
27-
void enumValue(SymbolDatabase * symboldatabase, const Settings * settings);
27+
void analyzeEnumValue(SymbolDatabase * symboldatabase, const Settings * settings);
2828
}
2929

3030
#endif // vfEnumValueH

tools/dmake.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,7 @@ int main(int argc, char **argv)
318318
libfiles_h.emplace_back("tokenrange.h");
319319
libfiles_h.emplace_back("valueptr.h");
320320
libfiles_h.emplace_back("version.h");
321+
libfiles_h.emplace_back("vf/analyze.h");
321322
std::sort(libfiles_h.begin(), libfiles_h.end());
322323

323324
std::vector<std::string> clifiles_h;

0 commit comments

Comments
 (0)