ValueFlow: throw TerminateException in valueFlowGenericForward in case analysis is terminated
This commit is contained in:
parent
4e75c08f58
commit
15d3e510e1
|
@ -534,6 +534,9 @@ unsigned int CppCheck::check(const std::string &path)
|
||||||
} catch (const InternalError &e) {
|
} catch (const InternalError &e) {
|
||||||
internalError(path, e.errorMessage);
|
internalError(path, e.errorMessage);
|
||||||
mExitCode = 1; // e.g. reflect a syntax error
|
mExitCode = 1; // e.g. reflect a syntax error
|
||||||
|
} catch (const TerminateException &) {
|
||||||
|
// Analysis is terminated
|
||||||
|
return mExitCode;
|
||||||
} catch (const std::exception &e) {
|
} catch (const std::exception &e) {
|
||||||
internalError(path, e.what());
|
internalError(path, e.what());
|
||||||
}
|
}
|
||||||
|
@ -911,6 +914,10 @@ unsigned int CppCheck::checkFile(const std::string& filename, const std::string
|
||||||
--checkCount; // don't count invalid configurations
|
--checkCount; // don't count invalid configurations
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
} catch (const TerminateException &) {
|
||||||
|
// Analysis is terminated
|
||||||
|
return mExitCode;
|
||||||
|
|
||||||
} catch (const InternalError &e) {
|
} catch (const InternalError &e) {
|
||||||
std::list<ErrorMessage::FileLocation> locationList;
|
std::list<ErrorMessage::FileLocation> locationList;
|
||||||
if (e.token) {
|
if (e.token) {
|
||||||
|
@ -962,6 +969,9 @@ unsigned int CppCheck::checkFile(const std::string& filename, const std::string
|
||||||
|
|
||||||
executeAddons(dumpFile);
|
executeAddons(dumpFile);
|
||||||
|
|
||||||
|
} catch (const TerminateException &) {
|
||||||
|
// Analysis is terminated
|
||||||
|
return mExitCode;
|
||||||
} catch (const std::runtime_error &e) {
|
} catch (const std::runtime_error &e) {
|
||||||
internalError(filename, e.what());
|
internalError(filename, e.what());
|
||||||
} catch (const std::bad_alloc &e) {
|
} catch (const std::bad_alloc &e) {
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
|
#include <stdexcept>
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
@ -41,6 +42,11 @@ struct InternalError {
|
||||||
std::string id;
|
std::string id;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class TerminateException: public std::runtime_error {
|
||||||
|
public:
|
||||||
|
TerminateException(): std::runtime_error("terminate") {}
|
||||||
|
};
|
||||||
|
|
||||||
class CPPCHECKLIB Certainty {
|
class CPPCHECKLIB Certainty {
|
||||||
public:
|
public:
|
||||||
enum CertaintyLevel {
|
enum CertaintyLevel {
|
||||||
|
|
|
@ -889,6 +889,8 @@ Analyzer::Result valueFlowGenericForward(Token* start, const Token* end, const V
|
||||||
|
|
||||||
Analyzer::Result valueFlowGenericForward(Token* start, const ValuePtr<Analyzer>& a, const Settings* settings)
|
Analyzer::Result valueFlowGenericForward(Token* start, const ValuePtr<Analyzer>& a, const Settings* settings)
|
||||||
{
|
{
|
||||||
|
if (Settings::terminated())
|
||||||
|
throw TerminateException();
|
||||||
ForwardTraversal ft{a, settings};
|
ForwardTraversal ft{a, settings};
|
||||||
ft.updateRecursive(start);
|
ft.updateRecursive(start);
|
||||||
return Analyzer::Result{ ft.actions, ft.terminate };
|
return Analyzer::Result{ ft.actions, ft.terminate };
|
||||||
|
|
Loading…
Reference in New Issue