Skip to content

Commit 6e5d338

Browse files
committed
made some function names more descriptive
1 parent 8ea056d commit 6e5d338

19 files changed

+57
-53
lines changed

democlient/democlient.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ class CppcheckExecutor : public ErrorLogger {
6868

6969
template<std::size_t size>
7070
void run(const char (&code)[size]) {
71-
cppcheck.check(FileWithDetails("test.cpp", Standards::Language::CPP, 0), reinterpret_cast<const uint8_t*>(code), size-1);
71+
cppcheck.checkBuffer(FileWithDetails("test.cpp", Standards::Language::CPP, 0), reinterpret_cast<const uint8_t*>(code), size-1);
7272
}
7373

7474
void reportOut(const std::string & /*outmsg*/, Color /*c*/) override {}

gui/mainwindow.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -732,7 +732,7 @@ void MainWindow::analyzeCode(const QString& code, const QString& filename)
732732
{
733733
const std::string code_s = code.toStdString();
734734
// TODO: apply enforcedLanguage?
735-
cppcheck.check(FileWithDetails(filename.toStdString(), Path::identify(filename.toStdString(), false), 0), reinterpret_cast<const std::uint8_t*>(code_s.data()), code_s.size());
735+
cppcheck.checkBuffer(FileWithDetails(filename.toStdString(), Path::identify(filename.toStdString(), false), 0), reinterpret_cast<const std::uint8_t*>(code_s.data()), code_s.size());
736736
}
737737
analysisDone();
738738

lib/cppcheck.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -799,7 +799,7 @@ unsigned int CppCheck::check(const FileWithDetails &file)
799799
return returnValue;
800800
}
801801

802-
unsigned int CppCheck::check(const FileWithDetails &file, const uint8_t* data, std::size_t size)
802+
unsigned int CppCheck::checkBuffer(const FileWithDetails &file, const uint8_t* data, std::size_t size)
803803
{
804804
return checkBuffer(file, "", 0, data, size);
805805
}
@@ -1077,7 +1077,7 @@ unsigned int CppCheck::checkInternal(const FileWithDetails& file, const std::str
10771077
code += "#line " + std::to_string(dir.linenr) + " \"" + dir.file + "\"\n" + dir.str + '\n';
10781078
}
10791079
TokenList tokenlist(mSettings, file.lang());
1080-
tokenlist.createTokens(code.data(), code.size()); // TODO: check result?
1080+
tokenlist.createTokensFromBuffer(code.data(), code.size()); // TODO: check result?
10811081
executeRules("define", tokenlist);
10821082
}
10831083
#endif

lib/cppcheck.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,11 @@ class CPPCHECKLIB CppCheck {
109109
* @note You must set settings before calling this function (by calling
110110
* settings()).
111111
*/
112-
unsigned int check(const FileWithDetails &file, const uint8_t* data, std::size_t size);
112+
unsigned int checkBuffer(const FileWithDetails &file, const uint8_t* data, std::size_t size);
113+
114+
unsigned int checkString(const FileWithDetails &file, const std::string& data) {
115+
return checkBuffer(file, reinterpret_cast<const uint8_t*>(data.data()), data.size());
116+
}
113117

114118
/**
115119
* @brief Returns current version number as a string.

lib/importproject.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,7 @@ namespace {
533533
// TODO: improve evaluation
534534
const Settings s;
535535
TokenList tokenlist(s, Standards::Language::C);
536-
tokenlist.createTokens(c.data(), c.size()); // TODO: check result
536+
tokenlist.createTokensFromBuffer(c.data(), c.size()); // TODO: check result
537537
// TODO: put in a helper
538538
// generate links
539539
{

lib/library.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ static std::vector<std::string> getnames(const char *names)
178178
static void gettokenlistfromvalid(const std::string& valid, TokenList& tokenList)
179179
{
180180
const std::string str(valid + ',');
181-
tokenList.createTokens(str.data(), str.size()); // TODO: check result?
181+
tokenList.createTokensFromBuffer(str.data(), str.size()); // TODO: check result?
182182
for (Token *tok = tokenList.front(); tok; tok = tok->next()) {
183183
if (Token::Match(tok,"- %num%")) {
184184
tok->str("-" + tok->strAt(1));

lib/programmemory.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1822,7 +1822,7 @@ static std::shared_ptr<Token> createTokenFromExpression(const std::string& retur
18221822
std::shared_ptr<TokenList> tokenList = std::make_shared<TokenList>(settings, cpp ? Standards::Language::CPP : Standards::Language::C);
18231823
{
18241824
const std::string code = "return " + returnValue + ";";
1825-
if (!tokenList->createTokens(code.data(), code.size()))
1825+
if (!tokenList->createTokensFromBuffer(code.data(), code.size()))
18261826
return nullptr;
18271827
}
18281828

lib/symboldatabase.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7757,7 +7757,7 @@ void SymbolDatabase::setValueTypeInTokenList(bool reportDebugWarnings, Token *to
77577757
ValueType valuetype;
77587758
TokenList tokenList(mSettings, tok->isCpp() ? Standards::Language::CPP : Standards::Language::C);
77597759
const std::string str(typestr+";");
7760-
tokenList.createTokens(str.data(), str.size()); // TODO: check result?
7760+
tokenList.createTokensFromBuffer(str.data(), str.size()); // TODO: check result?
77617761
tokenList.simplifyStdType();
77627762
if (parsedecl(tokenList.front(), &valuetype, mDefaultSignedness, mSettings)) {
77637763
valuetype.originalTypeName = typestr;
@@ -7847,7 +7847,7 @@ void SymbolDatabase::setValueTypeInTokenList(bool reportDebugWarnings, Token *to
78477847
}
78487848
TokenList tokenList(mSettings, tok->isCpp() ? Standards::Language::CPP : Standards::Language::C);
78497849
const std::string str(typestr+";");
7850-
if (tokenList.createTokens(str.data(), str.size())) {
7850+
if (tokenList.createTokensFromBuffer(str.data(), str.size())) {
78517851
ValueType vt;
78527852
tokenList.simplifyPlatformTypes();
78537853
tokenList.simplifyStdType();

lib/tokenlist.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -321,14 +321,14 @@ void TokenList::insertTokens(Token *dest, const Token *src, nonneg int n)
321321

322322
//---------------------------------------------------------------------------
323323

324-
bool TokenList::createTokens(const uint8_t* data, size_t size)
324+
bool TokenList::createTokensFromBuffer(const uint8_t* data, size_t size)
325325
{
326-
return createTokensInternal(data, size, mFiles.empty() ? "" : *mFiles.cbegin());
326+
return createTokensFromBufferInternal(data, size, mFiles.empty() ? "" : *mFiles.cbegin());
327327
}
328328

329329
//---------------------------------------------------------------------------
330330

331-
bool TokenList::createTokensInternal(const std::string& file0)
331+
bool TokenList::createTokensFromFileInternal(const std::string& file0)
332332
{
333333
simplecpp::OutputList outputList;
334334
simplecpp::TokenList tokens(file0, mFiles, &outputList);
@@ -340,7 +340,7 @@ bool TokenList::createTokensInternal(const std::string& file0)
340340

341341
//---------------------------------------------------------------------------
342342

343-
bool TokenList::createTokensInternal(const uint8_t* data, size_t size, const std::string& file0)
343+
bool TokenList::createTokensFromBufferInternal(const uint8_t* data, size_t size, const std::string& file0)
344344
{
345345
simplecpp::OutputList outputList;
346346
simplecpp::TokenList tokens(data, size, mFiles, file0, &outputList);

lib/tokenlist.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -99,13 +99,13 @@ class CPPCHECKLIB TokenList {
9999
* - UTF in the code are not handled.
100100
* - comments are not handled.
101101
*/
102-
bool createTokens(const uint8_t* data, size_t size);
103-
bool createTokens(const char* data, size_t size) {
104-
return createTokens(reinterpret_cast<const uint8_t*>(data), size);
102+
bool createTokensFromBuffer(const uint8_t* data, size_t size);
103+
bool createTokensFromBuffer(const char* data, size_t size) {
104+
return createTokensFromBuffer(reinterpret_cast<const uint8_t*>(data), size);
105105
}
106106
template<size_t size>
107-
bool createTokens(const char (&data)[size]) {
108-
return createTokens(reinterpret_cast<const uint8_t*>(data), size-1);
107+
bool createTokensFromString(const char (&data)[size]) {
108+
return createTokensFromBuffer(reinterpret_cast<const uint8_t*>(data), size-1);
109109
}
110110

111111
void createTokens(simplecpp::TokenList&& tokenList);
@@ -214,8 +214,8 @@ class CPPCHECKLIB TokenList {
214214
}
215215

216216
private:
217-
bool createTokensInternal(const std::string& file0);
218-
bool createTokensInternal(const uint8_t* data, std::size_t size, const std::string& file0);
217+
bool createTokensFromFileInternal(const std::string& file0);
218+
bool createTokensFromBufferInternal(const uint8_t* data, std::size_t size, const std::string& file0);
219219

220220
/** Token list */
221221
std::shared_ptr<TokensFrontBack> mTokensFrontBack;

0 commit comments

Comments
 (0)