Activated checking of .java and .cs files

This commit is contained in:
Daniel Marjamäki 2010-10-19 21:54:15 +02:00
parent 20674e08d0
commit f8c02718a5
5 changed files with 46 additions and 1 deletions

View File

@ -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();
}

View File

@ -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())

View File

@ -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;
}

View File

@ -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())
{

View File

@ -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)