|
26 | 26 | #include "tokenize.h" |
27 | 27 | #include "vfvalue.h" |
28 | 28 |
|
29 | | -#include <algorithm> |
30 | 29 | #include <cctype> |
31 | 30 | #include <iostream> |
32 | | -#include <stdexcept> |
33 | 31 | #include <utility> |
34 | 32 |
|
35 | 33 | //--------------------------------------------------------------------------- |
36 | 34 |
|
37 | | -Check::Check(const std::string &aname) |
38 | | - : mName(aname) |
39 | | -{ |
40 | | - { |
41 | | - const auto it = std::find_if(instances().begin(), instances().end(), [&](const Check *i) { |
42 | | - return i->name() == aname; |
43 | | - }); |
44 | | - if (it != instances().end()) |
45 | | - throw std::runtime_error("'" + aname + "' instance already exists"); |
46 | | - } |
47 | | - |
48 | | - // make sure the instances are sorted |
49 | | - const auto it = std::find_if(instances().begin(), instances().end(), [&](const Check* i) { |
50 | | - return i->name() > aname; |
51 | | - }); |
52 | | - if (it == instances().end()) |
53 | | - instances().push_back(this); |
54 | | - else |
55 | | - instances().insert(it, this); |
56 | | -} |
| 35 | +Check::Check(std::string aname) |
| 36 | + : mName(std::move(aname)) |
| 37 | +{} |
57 | 38 |
|
58 | 39 | void Check::writeToErrorList(const ErrorMessage &errmsg) |
59 | 40 | { |
@@ -88,19 +69,6 @@ bool Check::wrongData(const Token *tok, const char *str) |
88 | 69 | return true; |
89 | 70 | } |
90 | 71 |
|
91 | | -std::list<Check *> &Check::instances() |
92 | | -{ |
93 | | -#ifdef __SVR4 |
94 | | - // Under Solaris, destructors are called in wrong order which causes a segmentation fault. |
95 | | - // This fix ensures pointer remains valid and reachable until program terminates. |
96 | | - static std::list<Check *> *_instances= new std::list<Check *>; |
97 | | - return *_instances; |
98 | | -#else |
99 | | - static std::list<Check *> _instances; |
100 | | - return _instances; |
101 | | -#endif |
102 | | -} |
103 | | - |
104 | 72 | std::string Check::getMessageId(const ValueFlow::Value &value, const char id[]) |
105 | 73 | { |
106 | 74 | if (value.condition != nullptr) |
|
0 commit comments