Refactoring: missing include added, (potential) multi-threading issue fixed, expose static method to allow unit testing

This commit is contained in:
Alexander Mai 2015-06-18 19:07:51 +02:00
parent 189a652c2e
commit 60f5bd97df
4 changed files with 12 additions and 8 deletions

View File

@ -24,6 +24,8 @@
#include "checkother.h"
#include "symboldatabase.h"
#include <limits>
//---------------------------------------------------------------------------
// Register this check class (by creating a static instance of it)

View File

@ -29,8 +29,6 @@
#include <sstream>
#include <vector>
static std::string fixInvalidChars(const std::string& raw);
InternalError::InternalError(const Token *tok, const std::string &errorMsg, Type type) :
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.
// See #5300 "Invalid encoding in XML output"
static std::string fixInvalidChars(const std::string& raw)
// See #5300 "Invalid encoding in XML output" and #6431 "Invalid XML created - Invalid encoding of string literal "
std::string ErrorLogger::ErrorMessage::fixInvalidChars(const std::string& raw)
{
std::string result;
result.reserve(raw.length());

View File

@ -256,6 +256,8 @@ public:
*/
static void findAndReplace(std::string &source, const std::string &searchFor, const std::string &replaceWith);
static std::string fixInvalidChars(const std::string& raw);
/** Short message */
std::string _shortMessage;

View File

@ -3602,15 +3602,14 @@ Function * SymbolDatabase::findFunctionInScope(const Token *func, const Scope *n
//---------------------------------------------------------------------------
bool SymbolDatabase::isReservedName(const std::string& iName) const
{
static const std::set<std::string> c_keywords = make_container<std::set<std::string>>() <<
namespace {
const std::set<std::string> c_keywords = make_container<std::set<std::string>>() <<
"auto" << "break" << "case" << "char" << "const" << "continue" << "default" << "do" <<
"double" << "else" << "enum" << "extern" << "float" << "for" << "goto" << "if" << "inline" <<
"int" << "long" << "register" << "restrict" << "return" << "short" << "signed" << "sizeof" <<
"static" << "struct" << "switch" << "typedef" << "union" << "unsigned" << "void" << "volatile" <<
"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" <<
"break" << "case" << "catch" << "char" << "char16_t" << "char32_t" << "class" << "compl" <<
"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" <<
"true" << "try" << "typedef" << "typeid" << "typename" << "union" << "unsigned" << "using" <<
"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()));
}