Refactoring; Sort options alphabetically. Removed unused --check-diff functionality.
This commit is contained in:
parent
47c998e52d
commit
6d7dd7400d
File diff suppressed because it is too large
Load Diff
|
@ -1756,23 +1756,6 @@ void ExprEngine::executeFunction(const Scope *functionScope, const Tokenizer *to
|
||||||
// TODO.. what about functions in headers?
|
// TODO.. what about functions in headers?
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!settings->checkDiff.empty()) {
|
|
||||||
const std::string filename = tokenizer->list.getFiles().at(functionScope->bodyStart->fileIndex());
|
|
||||||
bool check = false;
|
|
||||||
for (const auto &diff: settings->checkDiff) {
|
|
||||||
if (diff.filename != filename)
|
|
||||||
continue;
|
|
||||||
if (diff.fromLine > functionScope->bodyEnd->linenr())
|
|
||||||
continue;
|
|
||||||
if (diff.toLine < functionScope->bodyStart->linenr())
|
|
||||||
continue;
|
|
||||||
check = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (!check)
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
int symbolValueIndex = 0;
|
int symbolValueIndex = 0;
|
||||||
TrackExecution trackExecution;
|
TrackExecution trackExecution;
|
||||||
Data data(&symbolValueIndex, tokenizer, settings, callbacks, &trackExecution);
|
Data data(&symbolValueIndex, tokenizer, settings, callbacks, &trackExecution);
|
||||||
|
|
|
@ -31,17 +31,20 @@ const char Settings::SafeChecks::XmlExternalVariables[] = "external-variables";
|
||||||
Settings::Settings()
|
Settings::Settings()
|
||||||
: mEnabled(0),
|
: mEnabled(0),
|
||||||
addonPython("python"),
|
addonPython("python"),
|
||||||
|
bugHunting(false),
|
||||||
|
checkAllConfigurations(true),
|
||||||
checkConfiguration(false),
|
checkConfiguration(false),
|
||||||
checkLibrary(false),
|
|
||||||
checkHeaders(true),
|
checkHeaders(true),
|
||||||
|
checkLibrary(false),
|
||||||
checkUnusedTemplates(false),
|
checkUnusedTemplates(false),
|
||||||
clang(false),
|
clang(false),
|
||||||
clangTidy(false),
|
clangTidy(false),
|
||||||
daca(false),
|
daca(false),
|
||||||
debugSimplified(false),
|
debugBugHunting(false),
|
||||||
debugnormal(false),
|
debugnormal(false),
|
||||||
debugwarnings(false),
|
debugSimplified(false),
|
||||||
debugtemplate(false),
|
debugtemplate(false),
|
||||||
|
debugwarnings(false),
|
||||||
dump(false),
|
dump(false),
|
||||||
enforcedLang(None),
|
enforcedLang(None),
|
||||||
exceptionHandling(false),
|
exceptionHandling(false),
|
||||||
|
@ -49,14 +52,11 @@ Settings::Settings()
|
||||||
experimental(false),
|
experimental(false),
|
||||||
force(false),
|
force(false),
|
||||||
inconclusive(false),
|
inconclusive(false),
|
||||||
bugHunting(false),
|
|
||||||
debugBugHunting(false),
|
|
||||||
inlineSuppressions(false),
|
inlineSuppressions(false),
|
||||||
jobs(1),
|
jobs(1),
|
||||||
jointSuppressionReport(false),
|
jointSuppressionReport(false),
|
||||||
loadAverage(0),
|
loadAverage(0),
|
||||||
maxConfigs(12),
|
maxConfigs(12),
|
||||||
checkAllConfigurations(true),
|
|
||||||
maxCtuDepth(2),
|
maxCtuDepth(2),
|
||||||
preprocessOnly(false),
|
preprocessOnly(false),
|
||||||
quiet(false),
|
quiet(false),
|
||||||
|
@ -153,39 +153,3 @@ bool Settings::isEnabled(const ValueFlow::Value *value, bool inconclusiveCheck)
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<Settings::Diff> Settings::loadDiffFile(std::istream &istr)
|
|
||||||
{
|
|
||||||
std::vector<Settings::Diff> ret;
|
|
||||||
std::string line;
|
|
||||||
std::string filename;
|
|
||||||
while (std::getline(istr, line)) {
|
|
||||||
if (line.compare(0, 11, "diff --git ") == 0) {
|
|
||||||
std::string::size_type pos = line.rfind(" b/");
|
|
||||||
if (pos == std::string::npos)
|
|
||||||
continue;
|
|
||||||
filename = line.substr(pos+3);
|
|
||||||
}
|
|
||||||
if (line.compare(0,4,"@@ -") == 0) {
|
|
||||||
std::string::size_type pos1 = line.find(" ",4);
|
|
||||||
if (pos1 == std::string::npos)
|
|
||||||
continue;
|
|
||||||
std::string::size_type pos2 = line.find(" ",pos1 + 1);
|
|
||||||
if (pos2 == std::string::npos || pos2 < pos1+3)
|
|
||||||
continue;
|
|
||||||
if (line[pos1+1] != '+')
|
|
||||||
continue;
|
|
||||||
std::string::size_type posComma = line.find(",", pos1);
|
|
||||||
if (posComma > pos2)
|
|
||||||
continue;
|
|
||||||
std::string line1 = line.substr(pos1 + 2, posComma - pos1 - 2);
|
|
||||||
std::string line2 = line.substr(posComma+1, pos2 - posComma - 1);
|
|
||||||
Diff diff;
|
|
||||||
diff.filename = filename;
|
|
||||||
diff.fromLine = std::atoi(line1.c_str());
|
|
||||||
diff.toLine = std::atoi(line1.c_str()) + std::atoi(line2.c_str());
|
|
||||||
ret.push_back(diff);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
148
lib/settings.h
148
lib/settings.h
|
@ -79,11 +79,17 @@ public:
|
||||||
/** @brief Paths used as base for conversion to relative paths. */
|
/** @brief Paths used as base for conversion to relative paths. */
|
||||||
std::vector<std::string> basePaths;
|
std::vector<std::string> basePaths;
|
||||||
|
|
||||||
|
/** @brief Bug hunting */
|
||||||
|
bool bugHunting;
|
||||||
|
|
||||||
|
/** Filename for bug hunting report */
|
||||||
|
std::string bugHuntingReport;
|
||||||
|
|
||||||
/** @brief --cppcheck-build-dir */
|
/** @brief --cppcheck-build-dir */
|
||||||
std::string buildDir;
|
std::string buildDir;
|
||||||
|
|
||||||
/** @brief --file-filter for analyzing special files */
|
/** @brief check all configurations (false if -D or --max-configs is used */
|
||||||
std::string fileFilter;
|
bool checkAllConfigurations;
|
||||||
|
|
||||||
/** Is the 'configuration checking' wanted? */
|
/** Is the 'configuration checking' wanted? */
|
||||||
bool checkConfiguration;
|
bool checkConfiguration;
|
||||||
|
@ -91,11 +97,17 @@ public:
|
||||||
/** Check for incomplete info in library files? */
|
/** Check for incomplete info in library files? */
|
||||||
bool checkLibrary;
|
bool checkLibrary;
|
||||||
|
|
||||||
|
/** @brief List of selected Visual Studio configurations that should be checks */
|
||||||
|
std::list<std::string> checkVsConfigs;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check code in the headers, this is on by default but can
|
* Check code in the headers, this is on by default but can
|
||||||
* be turned off to save CPU */
|
* be turned off to save CPU */
|
||||||
bool checkHeaders;
|
bool checkHeaders;
|
||||||
|
|
||||||
|
/** @brief check unknown function return values */
|
||||||
|
std::set<std::string> checkUnknownFunctionReturn;
|
||||||
|
|
||||||
/** Check unused/uninstantiated templates */
|
/** Check unused/uninstantiated templates */
|
||||||
bool checkUnusedTemplates;
|
bool checkUnusedTemplates;
|
||||||
|
|
||||||
|
@ -111,18 +123,21 @@ public:
|
||||||
/** @brief Are we running from DACA script? */
|
/** @brief Are we running from DACA script? */
|
||||||
bool daca;
|
bool daca;
|
||||||
|
|
||||||
/** @brief Is --debug-simplified given? */
|
/** @brief Debug bug hunting */
|
||||||
bool debugSimplified;
|
bool debugBugHunting;
|
||||||
|
|
||||||
/** @brief Is --debug-normal given? */
|
/** @brief Is --debug-normal given? */
|
||||||
bool debugnormal;
|
bool debugnormal;
|
||||||
|
|
||||||
/** @brief Is --debug-warnings given? */
|
/** @brief Is --debug-simplified given? */
|
||||||
bool debugwarnings;
|
bool debugSimplified;
|
||||||
|
|
||||||
/** @brief Is --debug-template given? */
|
/** @brief Is --debug-template given? */
|
||||||
bool debugtemplate;
|
bool debugtemplate;
|
||||||
|
|
||||||
|
/** @brief Is --debug-warnings given? */
|
||||||
|
bool debugwarnings;
|
||||||
|
|
||||||
/** @brief Is --dump given? */
|
/** @brief Is --dump given? */
|
||||||
bool dump;
|
bool dump;
|
||||||
std::string dumpFile;
|
std::string dumpFile;
|
||||||
|
@ -152,6 +167,9 @@ public:
|
||||||
*/
|
*/
|
||||||
bool experimental;
|
bool experimental;
|
||||||
|
|
||||||
|
/** @brief --file-filter for analyzing special files */
|
||||||
|
std::string fileFilter;
|
||||||
|
|
||||||
/** @brief Force checking the files with "too many" configurations (--force). */
|
/** @brief Force checking the files with "too many" configurations (--force). */
|
||||||
bool force;
|
bool force;
|
||||||
|
|
||||||
|
@ -159,77 +177,9 @@ public:
|
||||||
for finding include files inside source files. (-I) */
|
for finding include files inside source files. (-I) */
|
||||||
std::list<std::string> includePaths;
|
std::list<std::string> includePaths;
|
||||||
|
|
||||||
/** @brief List of selected Visual Studio configurations that should be checks */
|
|
||||||
std::list<std::string> checkVsConfigs;
|
|
||||||
|
|
||||||
/** @brief Inconclusive checks */
|
/** @brief Inconclusive checks */
|
||||||
bool inconclusive;
|
bool inconclusive;
|
||||||
|
|
||||||
/** Do not only check how interface is used. Also check that interface is safe. */
|
|
||||||
class CPPCHECKLIB SafeChecks {
|
|
||||||
public:
|
|
||||||
SafeChecks() : classes(false), externalFunctions(false), internalFunctions(false), externalVariables(false) {}
|
|
||||||
|
|
||||||
static const char XmlRootName[];
|
|
||||||
static const char XmlClasses[];
|
|
||||||
static const char XmlExternalFunctions[];
|
|
||||||
static const char XmlInternalFunctions[];
|
|
||||||
static const char XmlExternalVariables[];
|
|
||||||
|
|
||||||
void clear() {
|
|
||||||
classes = externalFunctions = internalFunctions = externalVariables = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Public interface of classes
|
|
||||||
* - public function parameters can have any value
|
|
||||||
* - public functions can be called in any order
|
|
||||||
* - public variables can have any value
|
|
||||||
*/
|
|
||||||
bool classes;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* External functions
|
|
||||||
* - external functions can be called in any order
|
|
||||||
* - function parameters can have any values
|
|
||||||
*/
|
|
||||||
bool externalFunctions;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Experimental: assume that internal functions can be used in any way
|
|
||||||
* This is only available in the GUI.
|
|
||||||
*/
|
|
||||||
bool internalFunctions;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Global variables that can be modified outside the TU.
|
|
||||||
* - Such variable can have "any" value
|
|
||||||
*/
|
|
||||||
bool externalVariables;
|
|
||||||
};
|
|
||||||
|
|
||||||
SafeChecks safeChecks;
|
|
||||||
|
|
||||||
/** @brief Bug hunting */
|
|
||||||
bool bugHunting;
|
|
||||||
|
|
||||||
/** @brief Debug bug hunting */
|
|
||||||
bool debugBugHunting;
|
|
||||||
|
|
||||||
/** Filename for bug hunting report */
|
|
||||||
std::string bugHuntingReport;
|
|
||||||
|
|
||||||
/** @brief Check diff */
|
|
||||||
struct Diff {
|
|
||||||
std::string filename;
|
|
||||||
int fromLine;
|
|
||||||
int toLine;
|
|
||||||
};
|
|
||||||
std::vector<Diff> checkDiff;
|
|
||||||
|
|
||||||
/** @brief check unknown function return values */
|
|
||||||
std::set<std::string> checkUnknownFunctionReturn;
|
|
||||||
|
|
||||||
/** @brief Is --inline-suppr given? */
|
/** @brief Is --inline-suppr given? */
|
||||||
bool inlineSuppressions;
|
bool inlineSuppressions;
|
||||||
|
|
||||||
|
@ -255,9 +205,6 @@ public:
|
||||||
Default is 12. (--max-configs=N) */
|
Default is 12. (--max-configs=N) */
|
||||||
unsigned int maxConfigs;
|
unsigned int maxConfigs;
|
||||||
|
|
||||||
/** @brief --check all configurations */
|
|
||||||
bool checkAllConfigurations;
|
|
||||||
|
|
||||||
/** @brief --max-ctu-depth */
|
/** @brief --max-ctu-depth */
|
||||||
int maxCtuDepth;
|
int maxCtuDepth;
|
||||||
|
|
||||||
|
@ -308,6 +255,51 @@ public:
|
||||||
*/
|
*/
|
||||||
std::list<Rule> rules;
|
std::list<Rule> rules;
|
||||||
|
|
||||||
|
/** Do not only check how interface is used. Also check that interface is safe. */
|
||||||
|
class CPPCHECKLIB SafeChecks {
|
||||||
|
public:
|
||||||
|
SafeChecks() : classes(false), externalFunctions(false), internalFunctions(false), externalVariables(false) {}
|
||||||
|
|
||||||
|
static const char XmlRootName[];
|
||||||
|
static const char XmlClasses[];
|
||||||
|
static const char XmlExternalFunctions[];
|
||||||
|
static const char XmlInternalFunctions[];
|
||||||
|
static const char XmlExternalVariables[];
|
||||||
|
|
||||||
|
void clear() {
|
||||||
|
classes = externalFunctions = internalFunctions = externalVariables = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Public interface of classes
|
||||||
|
* - public function parameters can have any value
|
||||||
|
* - public functions can be called in any order
|
||||||
|
* - public variables can have any value
|
||||||
|
*/
|
||||||
|
bool classes;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* External functions
|
||||||
|
* - external functions can be called in any order
|
||||||
|
* - function parameters can have any values
|
||||||
|
*/
|
||||||
|
bool externalFunctions;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Experimental: assume that internal functions can be used in any way
|
||||||
|
* This is only available in the GUI.
|
||||||
|
*/
|
||||||
|
bool internalFunctions;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Global variables that can be modified outside the TU.
|
||||||
|
* - Such variable can have "any" value
|
||||||
|
*/
|
||||||
|
bool externalVariables;
|
||||||
|
};
|
||||||
|
|
||||||
|
SafeChecks safeChecks;
|
||||||
|
|
||||||
/** @brief show timing information (--showtime=file|summary|top5) */
|
/** @brief show timing information (--showtime=file|summary|top5) */
|
||||||
SHOWTIME_MODES showtime;
|
SHOWTIME_MODES showtime;
|
||||||
|
|
||||||
|
@ -390,8 +382,6 @@ public:
|
||||||
*/
|
*/
|
||||||
bool isEnabled(const ValueFlow::Value *value, bool inconclusiveCheck=false) const;
|
bool isEnabled(const ValueFlow::Value *value, bool inconclusiveCheck=false) const;
|
||||||
|
|
||||||
static std::vector<Diff> loadDiffFile(std::istream &istr);
|
|
||||||
|
|
||||||
/** Is posix library specified? */
|
/** Is posix library specified? */
|
||||||
bool posix() const {
|
bool posix() const {
|
||||||
return std::find(libraries.begin(), libraries.end(), "posix") != libraries.end();
|
return std::find(libraries.begin(), libraries.end(), "posix") != libraries.end();
|
||||||
|
|
Loading…
Reference in New Issue