diff --git a/lib/config.h b/lib/config.h index 4ba06229d0d..f0e5cb8193c 100644 --- a/lib/config.h +++ b/lib/config.h @@ -131,6 +131,13 @@ # define RET_NONNULL #endif +// lifetimebound +#if __has_cpp_attribute (clang::lifetimebound) +# define LIFETIMEBOUND [[clang::lifetimebound]] +#else +# define LIFETIMEBOUND +#endif + #define REQUIRES(msg, ...) class=typename std::enable_if<__VA_ARGS__::value>::type // Use the nonneg macro when you want to assert that a variable/argument is not negative diff --git a/lib/cppcheck.cpp b/lib/cppcheck.cpp index 9aa7ec9d6b0..8ff819297dd 100644 --- a/lib/cppcheck.cpp +++ b/lib/cppcheck.cpp @@ -87,7 +87,7 @@ static const CWE CWE398(398U); // Indicator of Poor Code Quality class CppCheck::CppCheckLogger : public ErrorLogger { public: - CppCheckLogger(ErrorLogger& errorLogger, const Settings& settings, Suppressions& suppressions, bool useGlobalSuppressions) + CppCheckLogger(ErrorLogger& errorLogger LIFETIMEBOUND, const Settings& settings LIFETIMEBOUND, Suppressions& suppressions LIFETIMEBOUND, bool useGlobalSuppressions) : mErrorLogger(errorLogger) , mSettings(settings) , mSuppressions(suppressions) diff --git a/lib/cppcheck.h b/lib/cppcheck.h index ad1ca8cbeb3..1fddcec4a75 100644 --- a/lib/cppcheck.h +++ b/lib/cppcheck.h @@ -68,9 +68,9 @@ class CPPCHECKLIB CppCheck { /** * @brief Constructor. */ - CppCheck(const Settings& settings, - Suppressions& supprs, - ErrorLogger &errorLogger, + CppCheck(const Settings& settings LIFETIMEBOUND, + Suppressions& supprs LIFETIMEBOUND, + ErrorLogger &errorLogger LIFETIMEBOUND, bool useGlobalSuppressions, ExecuteCmdFn executeCommand); diff --git a/lib/fwdanalysis.h b/lib/fwdanalysis.h index 389ea195da2..46f344219f2 100644 --- a/lib/fwdanalysis.h +++ b/lib/fwdanalysis.h @@ -38,7 +38,7 @@ class Settings; */ class FwdAnalysis { public: - explicit FwdAnalysis(const Settings &settings) : mSettings(settings) {} + explicit FwdAnalysis(const Settings &settings LIFETIMEBOUND) : mSettings(settings) {} bool hasOperand(const Token *tok, const Token *lhs) const; diff --git a/lib/preprocessor.h b/lib/preprocessor.h index 282084ad239..c02adda0fce 100644 --- a/lib/preprocessor.h +++ b/lib/preprocessor.h @@ -102,7 +102,7 @@ class CPPCHECKLIB WARN_UNUSED Preprocessor { /** character that is inserted in expanded macros */ static char macroChar; - Preprocessor(simplecpp::TokenList& tokens, const Settings& settings, ErrorLogger &errorLogger, Standards::Language lang); + Preprocessor(simplecpp::TokenList& tokens LIFETIMEBOUND, const Settings& settings LIFETIMEBOUND, ErrorLogger &errorLogger LIFETIMEBOUND, Standards::Language lang); void inlineSuppressions(SuppressionList &suppressions); diff --git a/lib/symboldatabase.h b/lib/symboldatabase.h index 50f37fc1ebf..d2160bd077e 100644 --- a/lib/symboldatabase.h +++ b/lib/symboldatabase.h @@ -1038,8 +1038,8 @@ class CPPCHECKLIB Scope { const Scope *scope; }; - Scope(const SymbolDatabase &symdb_, const Token *classDef_, const Scope *nestedIn_); - Scope(const SymbolDatabase &symdb_, const Token *classDef_, const Scope *nestedIn_, ScopeType type_, const Token *start_); + Scope(const SymbolDatabase &symdb_ LIFETIMEBOUND, const Token *classDef_, const Scope *nestedIn_); + Scope(const SymbolDatabase &symdb_ LIFETIMEBOUND, const Token *classDef_, const Scope *nestedIn_, ScopeType type_, const Token *start_); const SymbolDatabase& symdb; std::string className; @@ -1327,7 +1327,7 @@ class CPPCHECKLIB ValueType { class CPPCHECKLIB SymbolDatabase { friend class TestSymbolDatabase; public: - explicit SymbolDatabase(Tokenizer& tokenizer); + explicit SymbolDatabase(Tokenizer& tokenizer LIFETIMEBOUND); ~SymbolDatabase(); /** @brief Information about all namespaces/classes/structures */ diff --git a/lib/templatesimplifier.h b/lib/templatesimplifier.h index 35b8ab04e3a..ec4bff83d06 100644 --- a/lib/templatesimplifier.h +++ b/lib/templatesimplifier.h @@ -48,7 +48,7 @@ class CPPCHECKLIB TemplateSimplifier { friend class TestSimplifyTemplate; public: - explicit TemplateSimplifier(Tokenizer &tokenizer); + explicit TemplateSimplifier(Tokenizer &tokenizer LIFETIMEBOUND); const std::string& dump() const { return mDump; diff --git a/lib/token.h b/lib/token.h index 034e2d36912..9fcdb8fb872 100644 --- a/lib/token.h +++ b/lib/token.h @@ -202,7 +202,7 @@ class CPPCHECKLIB Token { eNone }; - Token(const TokenList& tokenlist, std::shared_ptr tokensFrontBack); + Token(const TokenList& tokenlist LIFETIMEBOUND, std::shared_ptr tokensFrontBack); // for usage in CheckIO::ArgumentInfo only explicit Token(const Token *tok); ~Token(); diff --git a/lib/tokenize.h b/lib/tokenize.h index f9feebb43f0..48063001023 100644 --- a/lib/tokenize.h +++ b/lib/tokenize.h @@ -50,7 +50,7 @@ class CPPCHECKLIB Tokenizer { friend class SymbolDatabase; public: - Tokenizer(TokenList tokenList, ErrorLogger &errorLogger); + Tokenizer(TokenList tokenList, ErrorLogger &errorLogger LIFETIMEBOUND); ~Tokenizer(); void setTimerResults(TimerResults *tr) { diff --git a/lib/tokenlist.h b/lib/tokenlist.h index b528ebc7889..3d832a3034d 100644 --- a/lib/tokenlist.h +++ b/lib/tokenlist.h @@ -50,7 +50,7 @@ struct TokensFrontBack { class CPPCHECKLIB TokenList { public: - explicit TokenList(const Settings& settings, Standards::Language lang); + explicit TokenList(const Settings& settings LIFETIMEBOUND, Standards::Language lang); ~TokenList(); TokenList(const TokenList &) = delete;