Activated checking of .java and .cs files
This commit is contained in:
parent
20674e08d0
commit
f8c02718a5
|
@ -182,6 +182,13 @@ public:
|
|||
/** @brief run all simplified checks */
|
||||
void runSimplifiedChecks(const Tokenizer *tokenizr, const Settings *settings, ErrorLogger *errLog)
|
||||
{
|
||||
// Don't use these check for Java and C# programs..
|
||||
if (tokenizr->getFiles()->at(0).find(".java") != std::string::npos ||
|
||||
tokenizr->getFiles()->at(0).find(".cs") != std::string::npos)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
CheckMemoryLeakInFunction checkMemoryLeak(tokenizr, settings, errLog);
|
||||
checkMemoryLeak.checkReallocUsage();
|
||||
checkMemoryLeak.check();
|
||||
|
@ -355,6 +362,13 @@ public:
|
|||
|
||||
void runSimplifiedChecks(const Tokenizer *tokenizr, const Settings *settings, ErrorLogger *errLog)
|
||||
{
|
||||
// Don't use these check for Java and C# programs..
|
||||
if (tokenizr->getFiles()->at(0).find(".java") != std::string::npos ||
|
||||
tokenizr->getFiles()->at(0).find(".cs") != std::string::npos)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
CheckMemoryLeakInClass checkMemoryLeak(tokenizr, settings, errLog);
|
||||
checkMemoryLeak.check();
|
||||
}
|
||||
|
|
|
@ -2162,6 +2162,13 @@ void CheckOther::checkIncompleteStatement()
|
|||
|
||||
void CheckOther::strPlusChar()
|
||||
{
|
||||
// Don't use this check for Java and C# programs..
|
||||
if (_tokenizer->getFiles()->at(0).find(".java") != std::string::npos ||
|
||||
_tokenizer->getFiles()->at(0).find(".cs") != std::string::npos)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
bool charVars[10000] = {0};
|
||||
|
||||
for (const Token *tok = _tokenizer->tokens(); tok; tok = tok->next())
|
||||
|
|
|
@ -124,7 +124,9 @@ bool FileLister::acceptFile(const std::string &filename)
|
|||
extension == ".c" ||
|
||||
extension == ".c++" ||
|
||||
extension == ".tpp" ||
|
||||
extension == ".txx")
|
||||
extension == ".txx" ||
|
||||
extension == ".java" || // Java source file
|
||||
extension == ".cs") // C# source file
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -1722,6 +1722,20 @@ bool Tokenizer::tokenize(std::istream &code,
|
|||
|
||||
createTokens(code);
|
||||
|
||||
// Convert C# code
|
||||
if (_files[0].find(".cs"))
|
||||
{
|
||||
for (Token *tok = _tokens; tok; tok = tok->next())
|
||||
{
|
||||
if (Token::Match(tok, "[;{}] %type% [ ] %var% [=;]"))
|
||||
{
|
||||
tok = tok->next()->next();
|
||||
tok->str("*");
|
||||
tok->deleteNext();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// remove inline SQL (Oracle PRO*C). Ticket: #1959
|
||||
for (Token *tok = _tokens; tok; tok = tok->next())
|
||||
{
|
||||
|
|
|
@ -264,6 +264,9 @@ private:
|
|||
|
||||
// foo(p = new char[10]); => p = new char[10]; foo(p);
|
||||
TEST_CASE(simplifyAssignmentInFunctionCall);
|
||||
|
||||
// Tokenize C#
|
||||
TEST_CASE(cs);
|
||||
}
|
||||
|
||||
|
||||
|
@ -4563,6 +4566,11 @@ private:
|
|||
{
|
||||
ASSERT_EQUALS("; x = g ( ) ; f ( x ) ;", tokenizeAndStringify(";f(x=g());"));
|
||||
}
|
||||
|
||||
void cs()
|
||||
{
|
||||
ASSERT_EQUALS("; int * i ;", tokenizeAndStringify("; int [] i;"));
|
||||
}
|
||||
};
|
||||
|
||||
REGISTER_TEST(TestTokenizer)
|
||||
|
|
Loading…
Reference in New Issue