avoid more cases of returning non-const pointers from `const` objects (#4821)
This commit is contained in:
parent
d65cc696b0
commit
8583fcf96e
|
@ -335,13 +335,13 @@ void MainWindow::loadSettings()
|
||||||
mSettings->value(SETTINGS_WINDOW_HEIGHT, 600).toInt());
|
mSettings->value(SETTINGS_WINDOW_HEIGHT, 600).toInt());
|
||||||
}
|
}
|
||||||
|
|
||||||
ShowTypes *types = mUI->mResults->getShowTypes();
|
const ShowTypes &types = mUI->mResults->getShowTypes();
|
||||||
mUI->mActionShowStyle->setChecked(types->isShown(ShowTypes::ShowStyle));
|
mUI->mActionShowStyle->setChecked(types.isShown(ShowTypes::ShowStyle));
|
||||||
mUI->mActionShowErrors->setChecked(types->isShown(ShowTypes::ShowErrors));
|
mUI->mActionShowErrors->setChecked(types.isShown(ShowTypes::ShowErrors));
|
||||||
mUI->mActionShowWarnings->setChecked(types->isShown(ShowTypes::ShowWarnings));
|
mUI->mActionShowWarnings->setChecked(types.isShown(ShowTypes::ShowWarnings));
|
||||||
mUI->mActionShowPortability->setChecked(types->isShown(ShowTypes::ShowPortability));
|
mUI->mActionShowPortability->setChecked(types.isShown(ShowTypes::ShowPortability));
|
||||||
mUI->mActionShowPerformance->setChecked(types->isShown(ShowTypes::ShowPerformance));
|
mUI->mActionShowPerformance->setChecked(types.isShown(ShowTypes::ShowPerformance));
|
||||||
mUI->mActionShowInformation->setChecked(types->isShown(ShowTypes::ShowInformation));
|
mUI->mActionShowInformation->setChecked(types.isShown(ShowTypes::ShowInformation));
|
||||||
mUI->mActionShowCppcheck->setChecked(true);
|
mUI->mActionShowCppcheck->setChecked(true);
|
||||||
mUI->mActionShowClang->setChecked(true);
|
mUI->mActionShowClang->setChecked(true);
|
||||||
|
|
||||||
|
|
|
@ -113,9 +113,9 @@ void ResultsView::clearRecheckFile(const QString &filename)
|
||||||
mUI->mTree->clearRecheckFile(filename);
|
mUI->mTree->clearRecheckFile(filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
ShowTypes * ResultsView::getShowTypes() const
|
const ShowTypes & ResultsView::getShowTypes() const
|
||||||
{
|
{
|
||||||
return &mUI->mTree->mShowSeverities;
|
return mUI->mTree->mShowSeverities;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ResultsView::progress(int value, const QString& description)
|
void ResultsView::progress(int value, const QString& description)
|
||||||
|
|
|
@ -189,7 +189,7 @@ public:
|
||||||
* @brief Return checking statistics.
|
* @brief Return checking statistics.
|
||||||
* @return Pointer to checking statistics.
|
* @return Pointer to checking statistics.
|
||||||
*/
|
*/
|
||||||
CheckStatistics *getStatistics() const {
|
const CheckStatistics *getStatistics() const {
|
||||||
return mStatistics;
|
return mStatistics;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -197,7 +197,7 @@ public:
|
||||||
* @brief Return Showtypes.
|
* @brief Return Showtypes.
|
||||||
* @return Pointer to Showtypes.
|
* @return Pointer to Showtypes.
|
||||||
*/
|
*/
|
||||||
ShowTypes * getShowTypes() const;
|
const ShowTypes & getShowTypes() const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
|
|
|
@ -1399,12 +1399,12 @@ public:
|
||||||
const Scope *findScopeByName(const std::string& name) const;
|
const Scope *findScopeByName(const std::string& name) const;
|
||||||
|
|
||||||
const Type* findType(const Token *startTok, const Scope *startScope, bool lookOutside = false) const;
|
const Type* findType(const Token *startTok, const Scope *startScope, bool lookOutside = false) const;
|
||||||
Type* findType(const Token *startTok, Scope *startScope, bool lookOutside = false) const {
|
Type* findType(const Token *startTok, Scope *startScope, bool lookOutside = false) {
|
||||||
return const_cast<Type*>(this->findType(startTok, const_cast<const Scope *>(startScope), lookOutside));
|
return const_cast<Type*>(this->findType(startTok, const_cast<const Scope *>(startScope), lookOutside));
|
||||||
}
|
}
|
||||||
|
|
||||||
const Scope *findScope(const Token *tok, const Scope *startScope) const;
|
const Scope *findScope(const Token *tok, const Scope *startScope) const;
|
||||||
Scope *findScope(const Token *tok, Scope *startScope) const {
|
Scope *findScope(const Token *tok, Scope *startScope) {
|
||||||
return const_cast<Scope *>(this->findScope(tok, const_cast<const Scope *>(startScope)));
|
return const_cast<Scope *>(this->findScope(tok, const_cast<const Scope *>(startScope)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -156,6 +156,7 @@ public:
|
||||||
mNameToken == rhs.mNameToken && mParamEnd == rhs.mParamEnd && mFlags == rhs.mFlags;
|
mNameToken == rhs.mNameToken && mParamEnd == rhs.mParamEnd && mFlags == rhs.mFlags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: do not return non-const pointer from const object
|
||||||
Token * token() const {
|
Token * token() const {
|
||||||
return mToken;
|
return mToken;
|
||||||
}
|
}
|
||||||
|
|
|
@ -510,7 +510,7 @@ static Token *splitDefinitionFromTypedef(Token *tok, nonneg int *unnamedCount)
|
||||||
* code that generated it deals in some way with functions, then this
|
* code that generated it deals in some way with functions, then this
|
||||||
* function will probably need to be extended to handle a new function
|
* function will probably need to be extended to handle a new function
|
||||||
* related pattern */
|
* related pattern */
|
||||||
Token *Tokenizer::processFunc(Token *tok2, bool inOperator) const
|
const Token *Tokenizer::processFunc(const Token *tok2, bool inOperator) const
|
||||||
{
|
{
|
||||||
if (tok2->next() && tok2->next()->str() != ")" &&
|
if (tok2->next() && tok2->next()->str() != ")" &&
|
||||||
tok2->next()->str() != ",") {
|
tok2->next()->str() != ",") {
|
||||||
|
@ -570,6 +570,11 @@ Token *Tokenizer::processFunc(Token *tok2, bool inOperator) const
|
||||||
return tok2;
|
return tok2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Token *Tokenizer::processFunc(Token *tok2, bool inOperator)
|
||||||
|
{
|
||||||
|
return const_cast<Token*>(processFunc(const_cast<const Token*>(tok2), inOperator));
|
||||||
|
}
|
||||||
|
|
||||||
void Tokenizer::simplifyUsingToTypedef()
|
void Tokenizer::simplifyUsingToTypedef()
|
||||||
{
|
{
|
||||||
if (!isCPP() || mSettings->standards.cpp < Standards::CPP11)
|
if (!isCPP() || mSettings->standards.cpp < Standards::CPP11)
|
||||||
|
|
|
@ -693,7 +693,8 @@ public:
|
||||||
Tokenizer &operator=(const Tokenizer &) = delete;
|
Tokenizer &operator=(const Tokenizer &) = delete;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Token *processFunc(Token *tok2, bool inOperator) const;
|
const Token *processFunc(const Token *tok2, bool inOperator) const;
|
||||||
|
Token *processFunc(Token *tok2, bool inOperator);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get new variable id.
|
* Get new variable id.
|
||||||
|
|
Loading…
Reference in New Issue