Skip to content

Commit 738d81b

Browse files
committed
added LIFETIMEBOUND to utils.h and annotated some parameters with it [skip ci]
1 parent 843ce7c commit 738d81b

File tree

10 files changed

+20
-13
lines changed

10 files changed

+20
-13
lines changed

lib/config.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,13 @@
131131
# define RET_NONNULL
132132
#endif
133133

134+
// lifetimebound
135+
#if __has_cpp_attribute (clang::lifetimebound)
136+
# define LIFETIMEBOUND [[clang::lifetimebound]]
137+
#else
138+
# define LIFETIMEBOUND
139+
#endif
140+
134141
#define REQUIRES(msg, ...) class=typename std::enable_if<__VA_ARGS__::value>::type
135142

136143
// Use the nonneg macro when you want to assert that a variable/argument is not negative

lib/cppcheck.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ static const CWE CWE398(398U); // Indicator of Poor Code Quality
8787
class CppCheck::CppCheckLogger : public ErrorLogger
8888
{
8989
public:
90-
CppCheckLogger(ErrorLogger& errorLogger, const Settings& settings, Suppressions& suppressions, bool useGlobalSuppressions)
90+
CppCheckLogger(LIFETIMEBOUND ErrorLogger& errorLogger, LIFETIMEBOUND const Settings& settings, LIFETIMEBOUND Suppressions& suppressions, bool useGlobalSuppressions)
9191
: mErrorLogger(errorLogger)
9292
, mSettings(settings)
9393
, mSuppressions(suppressions)

lib/cppcheck.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ class CPPCHECKLIB CppCheck {
6868
/**
6969
* @brief Constructor.
7070
*/
71-
CppCheck(const Settings& settings,
72-
Suppressions& supprs,
73-
ErrorLogger &errorLogger,
71+
CppCheck(LIFETIMEBOUND const Settings& settings,
72+
LIFETIMEBOUND Suppressions& supprs,
73+
LIFETIMEBOUND ErrorLogger &errorLogger,
7474
bool useGlobalSuppressions,
7575
ExecuteCmdFn executeCommand);
7676

lib/fwdanalysis.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class Settings;
3838
*/
3939
class FwdAnalysis {
4040
public:
41-
explicit FwdAnalysis(const Settings &settings) : mSettings(settings) {}
41+
explicit FwdAnalysis(LIFETIMEBOUND const Settings &settings) : mSettings(settings) {}
4242

4343
bool hasOperand(const Token *tok, const Token *lhs) const;
4444

lib/preprocessor.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ class CPPCHECKLIB WARN_UNUSED Preprocessor {
102102
/** character that is inserted in expanded macros */
103103
static char macroChar;
104104

105-
Preprocessor(simplecpp::TokenList& tokens, const Settings& settings, ErrorLogger &errorLogger, Standards::Language lang);
105+
Preprocessor(LIFETIMEBOUND simplecpp::TokenList& tokens, LIFETIMEBOUND const Settings& settings, LIFETIMEBOUND ErrorLogger &errorLogger, Standards::Language lang);
106106

107107
void inlineSuppressions(SuppressionList &suppressions);
108108

lib/symboldatabase.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1038,8 +1038,8 @@ class CPPCHECKLIB Scope {
10381038
const Scope *scope;
10391039
};
10401040

1041-
Scope(const SymbolDatabase &symdb_, const Token *classDef_, const Scope *nestedIn_);
1042-
Scope(const SymbolDatabase &symdb_, const Token *classDef_, const Scope *nestedIn_, ScopeType type_, const Token *start_);
1041+
Scope(LIFETIMEBOUND const SymbolDatabase &symdb_, const Token *classDef_, const Scope *nestedIn_);
1042+
Scope(LIFETIMEBOUND const SymbolDatabase &symdb_, const Token *classDef_, const Scope *nestedIn_, ScopeType type_, const Token *start_);
10431043

10441044
const SymbolDatabase& symdb;
10451045
std::string className;
@@ -1327,7 +1327,7 @@ class CPPCHECKLIB ValueType {
13271327
class CPPCHECKLIB SymbolDatabase {
13281328
friend class TestSymbolDatabase;
13291329
public:
1330-
explicit SymbolDatabase(Tokenizer& tokenizer);
1330+
explicit SymbolDatabase(LIFETIMEBOUND Tokenizer& tokenizer);
13311331
~SymbolDatabase();
13321332

13331333
/** @brief Information about all namespaces/classes/structures */

lib/templatesimplifier.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class CPPCHECKLIB TemplateSimplifier {
4848
friend class TestSimplifyTemplate;
4949

5050
public:
51-
explicit TemplateSimplifier(Tokenizer &tokenizer);
51+
explicit TemplateSimplifier(LIFETIMEBOUND Tokenizer &tokenizer);
5252

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

lib/token.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ class CPPCHECKLIB Token {
202202
eNone
203203
};
204204

205-
Token(const TokenList& tokenlist, std::shared_ptr<TokensFrontBack> tokensFrontBack);
205+
Token(LIFETIMEBOUND const TokenList& tokenlist, std::shared_ptr<TokensFrontBack> tokensFrontBack);
206206
// for usage in CheckIO::ArgumentInfo only
207207
explicit Token(const Token *tok);
208208
~Token();

lib/tokenize.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class CPPCHECKLIB Tokenizer {
5050
friend class SymbolDatabase;
5151

5252
public:
53-
Tokenizer(TokenList tokenList, ErrorLogger &errorLogger);
53+
Tokenizer(TokenList tokenList, LIFETIMEBOUND ErrorLogger &errorLogger);
5454
~Tokenizer();
5555

5656
void setTimerResults(TimerResults *tr) {

lib/tokenlist.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ struct TokensFrontBack {
5050

5151
class CPPCHECKLIB TokenList {
5252
public:
53-
explicit TokenList(const Settings& settings, Standards::Language lang);
53+
explicit TokenList(LIFETIMEBOUND const Settings& settings, Standards::Language lang);
5454
~TokenList();
5555

5656
TokenList(const TokenList &) = delete;

0 commit comments

Comments
 (0)