Skip to content

Commit

Permalink
Partial fix
Browse files Browse the repository at this point in the history
  • Loading branch information
danmar committed Aug 12, 2024
1 parent c3fc22a commit a8c2c5d
Show file tree
Hide file tree
Showing 16 changed files with 104 additions and 28 deletions.
2 changes: 1 addition & 1 deletion lib/analyzer.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ struct Analyzer {
return get(Match);
}

Action& operator|=(Action a) {
Action& operator|=(Action a) & {
set(a.mFlag);
return *this;
}
Expand Down
5 changes: 4 additions & 1 deletion lib/check.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,10 @@ class CPPCHECKLIB Check {
virtual void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const = 0;

/** class name, used to generate documentation */
const std::string& name() const {
const std::string& name() const & {
return mName;
}
const std::string& name() && {
return mName;
}

Expand Down
5 changes: 4 additions & 1 deletion lib/checkunusedvar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,10 @@ class Variables {
void clear() {
mVarUsage.clear();
}
const std::map<nonneg int, VariableUsage> &varUsage() const {
const std::map<nonneg int, VariableUsage> &varUsage() const & {
return mVarUsage;
}
const std::map<nonneg int, VariableUsage> &varUsage() && {
return mVarUsage;
}
void addVar(const Variable *var, VariableType type, bool write_);
Expand Down
2 changes: 1 addition & 1 deletion lib/cppcheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1511,7 +1511,7 @@ void CppCheck::executeAddonsWholeProgram(const std::list<FileWithDetails> &files
}
}

Settings &CppCheck::settings()
Settings &CppCheck::settings()&
{
return mSettings;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/cppcheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ class CPPCHECKLIB CppCheck : ErrorLogger {
* @brief Get reference to current settings.
* @return a reference to current settings
*/
Settings &settings();
Settings &settings()&;

/**
* @brief Returns current version number as a string.
Expand Down
24 changes: 20 additions & 4 deletions lib/errorlogger.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,11 @@ class CPPCHECKLIB ErrorMessage {
int line; // negative value means "no line"
unsigned int column;

const std::string& getinfo() const {
const std::string& getinfo() const & {
return mInfo;
}

const std::string& getinfo() && {
return mInfo;
}

Expand Down Expand Up @@ -181,18 +185,30 @@ class CPPCHECKLIB ErrorMessage {
void setmsg(const std::string &msg);

/** Short message (single line short message) */
const std::string &shortMessage() const {
const std::string &shortMessage() const & {
return mShortMessage;
}

const std::string &shortMessage() && {
return mShortMessage;
}

/** Verbose message (may be the same as the short message) */
// cppcheck-suppress unusedFunction - used by GUI only
const std::string &verboseMessage() const {
const std::string &verboseMessage() const & {
return mVerboseMessage;
}

const std::string &verboseMessage() && {
return mVerboseMessage;
}

/** Symbol names */
const std::string &symbolNames() const {
const std::string &symbolNames() const & {
return mSymbolNames;
}

const std::string &symbolNames() && {
return mSymbolNames;
}

Expand Down
13 changes: 11 additions & 2 deletions lib/filesettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,21 @@ class FileWithDetails
throw std::runtime_error("empty path specified");
}

const std::string& path() const
const std::string& path() const &
{
return mPath;
}

const std::string& spath() const
const std::string& path() &&
{
return mPath;
}

const std::string& spath() const &
{
return mPathSimplified;
}
const std::string& spath() &&
{
return mPathSimplified;
}
Expand Down
10 changes: 8 additions & 2 deletions lib/library.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,16 @@ struct Library::LibraryData
void addBlock(const char* blockName) {
mBlocks.insert(blockName);
}
const std::string& start() const {
const std::string& start() const & {
return mStart;
}
const std::string& end() const {
const std::string& start() && {
return mStart;
}
const std::string& end() const & {
return mEnd;
}
const std::string& end() && {
return mEnd;
}
int offset() const {
Expand Down
7 changes: 6 additions & 1 deletion lib/suppressions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,12 @@ std::list<SuppressionList::Suppression> SuppressionList::getUnmatchedGlobalSuppr
return result;
}

const std::list<SuppressionList::Suppression> &SuppressionList::getSuppressions() const
const std::list<SuppressionList::Suppression> &SuppressionList::getSuppressions() const &
{
return mSuppressions;
}

const std::list<SuppressionList::Suppression> &SuppressionList::getSuppressions() &&
{
return mSuppressions;
}
Expand Down
8 changes: 6 additions & 2 deletions lib/suppressions.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,10 @@ class CPPCHECKLIB SuppressionList {
std::size_t hash;
std::string errorId;
void setFileName(std::string s);
const std::string &getFileName() const {
const std::string &getFileName() const& {
return mFileName;
}
const std::string &getFileName() && {
return mFileName;
}
int lineNumber;
Expand Down Expand Up @@ -241,7 +244,8 @@ class CPPCHECKLIB SuppressionList {
* @brief Returns list of all suppressions.
* @return list of suppressions
*/
const std::list<Suppression> &getSuppressions() const;
const std::list<Suppression> &getSuppressions() const&;
const std::list<Suppression> &getSuppressions() &&;

/**
* @brief Marks Inline Suppressions as checked if source line is in the token stream
Expand Down
10 changes: 8 additions & 2 deletions lib/symboldatabase.h
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,10 @@ class CPPCHECKLIB Variable {
* Get array dimensions.
* @return array dimensions vector
*/
const std::vector<Dimension> &dimensions() const {
const std::vector<Dimension> &dimensions() const& {
return mDimensions;
}
const std::vector<Dimension> &dimensions() && {
return mDimensions;
}

Expand Down Expand Up @@ -1373,7 +1376,10 @@ class CPPCHECKLIB SymbolDatabase {
return mVariableList.at(varId);
}

const std::vector<const Variable *> & variableList() const {
const std::vector<const Variable *> & variableList() const& {
return mVariableList;
}
const std::vector<const Variable *> & variableList() && {
return mVariableList;
}

Expand Down
20 changes: 16 additions & 4 deletions lib/templatesimplifier.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@ class CPPCHECKLIB TemplateSimplifier {
public:
explicit TemplateSimplifier(Tokenizer &tokenizer);

const std::string& dump() const {
const std::string& dump() const & {
return mDump;
}
const std::string& dump() && {
return mDump;
}

Expand Down Expand Up @@ -169,13 +172,22 @@ class CPPCHECKLIB TemplateSimplifier {
void token(Token * token) {
mToken = token;
}
const std::string & scope() const {
const std::string & scope() const & {
return mScope;
}
const std::string & scope() && {
return mScope;
}
const std::string & name() const {
const std::string & name() const & {
return mName;
}
const std::string & fullName() const {
const std::string & name() && {
return mName;
}
const std::string & fullName() const & {
return mFullName;
}
const std::string & fullName() && {
return mFullName;
}
const Token * nameToken() const {
Expand Down
5 changes: 4 additions & 1 deletion lib/token.h
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,10 @@ class CPPCHECKLIB Token {
*/
void concatStr(std::string const& b);

const std::string &str() const {
const std::string &str() const & {
return mStr;
}
const std::string &str() && {
return mStr;
}

Expand Down
5 changes: 4 additions & 1 deletion lib/tokenlist.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,10 @@ class CPPCHECKLIB TokenList {
* The first filename is the filename for the sourcefile
* @return vector with filenames
*/
const std::vector<std::string>& getFiles() const {
const std::vector<std::string>& getFiles() const & {
return mFiles;
}
const std::vector<std::string>& getFiles() && {
return mFiles;
}

Expand Down
2 changes: 1 addition & 1 deletion lib/tokenrange.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class TokenRangeBase {
T* mt;
TokenIterator() : mt(nullptr) {}
explicit TokenIterator(T* t) : mt(t) {}
TokenIterator& operator++() {
TokenIterator& operator++() & {
mt = mt->next();
return *this;
}
Expand Down
12 changes: 9 additions & 3 deletions lib/valueflow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -759,7 +759,7 @@ class SelectValueFromVarIdMapRange {
return &mIt->second;
}

Iterator &operator++() {
Iterator &operator++() & {
// cppcheck-suppress postfixOperator - forward iterator needs to perform post-increment
mIt++;
return *this;
Expand Down Expand Up @@ -1529,11 +1529,17 @@ struct SingleValueFlowAnalyzer : ValueFlowAnalyzer {

SingleValueFlowAnalyzer(ValueFlow::Value v, const Settings& s) : ValueFlowAnalyzer(s), value(std::move(v)) {}

const std::unordered_map<nonneg int, const Variable*>& getVars() const {
const std::unordered_map<nonneg int, const Variable*>& getVars() const & {
return varids;
}
const std::unordered_map<nonneg int, const Variable*>& getVars() && {
return varids;
}

const std::unordered_map<nonneg int, const Variable*>& getAliasedVars() const {
const std::unordered_map<nonneg int, const Variable*>& getAliasedVars() const & {
return aliases;
}
const std::unordered_map<nonneg int, const Variable*>& getAliasedVars() && {
return aliases;
}

Expand Down

0 comments on commit a8c2c5d

Please sign in to comment.