Refactoring: missing include added, (potential) multi-threading issue fixed, expose static method to allow unit testing
This commit is contained in:
parent
189a652c2e
commit
60f5bd97df
|
@ -24,6 +24,8 @@
|
||||||
#include "checkother.h"
|
#include "checkother.h"
|
||||||
#include "symboldatabase.h"
|
#include "symboldatabase.h"
|
||||||
|
|
||||||
|
#include <limits>
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
// Register this check class (by creating a static instance of it)
|
// Register this check class (by creating a static instance of it)
|
||||||
|
|
|
@ -29,8 +29,6 @@
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
static std::string fixInvalidChars(const std::string& raw);
|
|
||||||
|
|
||||||
InternalError::InternalError(const Token *tok, const std::string &errorMsg, Type type) :
|
InternalError::InternalError(const Token *tok, const std::string &errorMsg, Type type) :
|
||||||
token(tok), errorMessage(errorMsg)
|
token(tok), errorMessage(errorMsg)
|
||||||
{
|
{
|
||||||
|
@ -225,8 +223,8 @@ std::string ErrorLogger::ErrorMessage::getXMLFooter(int xml_version)
|
||||||
}
|
}
|
||||||
|
|
||||||
// There is no utf-8 support around but the strings should at least be safe for to tinyxml2.
|
// There is no utf-8 support around but the strings should at least be safe for to tinyxml2.
|
||||||
// See #5300 "Invalid encoding in XML output"
|
// See #5300 "Invalid encoding in XML output" and #6431 "Invalid XML created - Invalid encoding of string literal "
|
||||||
static std::string fixInvalidChars(const std::string& raw)
|
std::string ErrorLogger::ErrorMessage::fixInvalidChars(const std::string& raw)
|
||||||
{
|
{
|
||||||
std::string result;
|
std::string result;
|
||||||
result.reserve(raw.length());
|
result.reserve(raw.length());
|
||||||
|
|
|
@ -256,6 +256,8 @@ public:
|
||||||
*/
|
*/
|
||||||
static void findAndReplace(std::string &source, const std::string &searchFor, const std::string &replaceWith);
|
static void findAndReplace(std::string &source, const std::string &searchFor, const std::string &replaceWith);
|
||||||
|
|
||||||
|
static std::string fixInvalidChars(const std::string& raw);
|
||||||
|
|
||||||
/** Short message */
|
/** Short message */
|
||||||
std::string _shortMessage;
|
std::string _shortMessage;
|
||||||
|
|
||||||
|
|
|
@ -3602,15 +3602,14 @@ Function * SymbolDatabase::findFunctionInScope(const Token *func, const Scope *n
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
bool SymbolDatabase::isReservedName(const std::string& iName) const
|
namespace {
|
||||||
{
|
const std::set<std::string> c_keywords = make_container<std::set<std::string>>() <<
|
||||||
static const std::set<std::string> c_keywords = make_container<std::set<std::string>>() <<
|
|
||||||
"auto" << "break" << "case" << "char" << "const" << "continue" << "default" << "do" <<
|
"auto" << "break" << "case" << "char" << "const" << "continue" << "default" << "do" <<
|
||||||
"double" << "else" << "enum" << "extern" << "float" << "for" << "goto" << "if" << "inline" <<
|
"double" << "else" << "enum" << "extern" << "float" << "for" << "goto" << "if" << "inline" <<
|
||||||
"int" << "long" << "register" << "restrict" << "return" << "short" << "signed" << "sizeof" <<
|
"int" << "long" << "register" << "restrict" << "return" << "short" << "signed" << "sizeof" <<
|
||||||
"static" << "struct" << "switch" << "typedef" << "union" << "unsigned" << "void" << "volatile" <<
|
"static" << "struct" << "switch" << "typedef" << "union" << "unsigned" << "void" << "volatile" <<
|
||||||
"while";
|
"while";
|
||||||
static const std::set<std::string> cpp_keywords = make_container<std::set<std::string>>() <<
|
const std::set<std::string> cpp_keywords = make_container<std::set<std::string>>() <<
|
||||||
"alignas" << "alignof" << "and" << "and_eq" << "asm" << "auto" << "bitand" << "bitor" << "bool" <<
|
"alignas" << "alignof" << "and" << "and_eq" << "asm" << "auto" << "bitand" << "bitor" << "bool" <<
|
||||||
"break" << "case" << "catch" << "char" << "char16_t" << "char32_t" << "class" << "compl" <<
|
"break" << "case" << "catch" << "char" << "char16_t" << "char32_t" << "class" << "compl" <<
|
||||||
"concept" << "const" << "constexpr" << "const_cast" << "continue" << "decltype" << "default" <<
|
"concept" << "const" << "constexpr" << "const_cast" << "continue" << "decltype" << "default" <<
|
||||||
|
@ -3622,5 +3621,8 @@ bool SymbolDatabase::isReservedName(const std::string& iName) const
|
||||||
"static_cast" << "struct" << "switch" << "template" << "this" << "thread_local" << "throw" <<
|
"static_cast" << "struct" << "switch" << "template" << "this" << "thread_local" << "throw" <<
|
||||||
"true" << "try" << "typedef" << "typeid" << "typename" << "union" << "unsigned" << "using" <<
|
"true" << "try" << "typedef" << "typeid" << "typename" << "union" << "unsigned" << "using" <<
|
||||||
"virtual" << "void" << "volatile" << "wchar_t" << "while" << "xor" << "xor_eq";
|
"virtual" << "void" << "volatile" << "wchar_t" << "while" << "xor" << "xor_eq";
|
||||||
|
}
|
||||||
|
bool SymbolDatabase::isReservedName(const std::string& iName) const
|
||||||
|
{
|
||||||
return (c_keywords.find(iName) != c_keywords.cend()) || (isCPP() && (cpp_keywords.find(iName) != cpp_keywords.cend()));
|
return (c_keywords.find(iName) != c_keywords.cend()) || (isCPP() && (cpp_keywords.find(iName) != cpp_keywords.cend()));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue