Skip to content

Commit 3ac9416

Browse files
committed
fixed -Wlifetime-safety-intra-tu-constructor-suggestions Clang warnings
1 parent 463bf75 commit 3ac9416

3 files changed

Lines changed: 8 additions & 8 deletions

File tree

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
8181
# the warnings were introduced with Clang 23
8282
if(CMAKE_CXX_STANDARD LESS 20)
8383
add_compile_options_safe(-Wno-lifetime-safety-intra-tu-suggestions)
84+
add_compile_options_safe(-Wno-lifetime-safety-intra-tu-constructor-suggestions)
8485
endif()
85-
add_compile_options_safe(-Wno-lifetime-safety-intra-tu-constructor-suggestions)
8686
add_compile_options_safe(-Wno-lifetime-safety-cross-tu-constructor-suggestions)
8787

8888
# TODO: fix these?

simplecpp.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ namespace {
368368
class StdIStream : public simplecpp::TokenList::Stream {
369369
public:
370370
// cppcheck-suppress uninitDerivedMemberVar - we call Stream::init() to initialize the private members
371-
explicit StdIStream(std::istream &istr)
371+
explicit StdIStream(std::istream &istr SIMPLECPP_LIFETIMEBOUND)
372372
: istr(istr) {
373373
assert(istr.good());
374374
init();
@@ -394,7 +394,7 @@ namespace {
394394
class StdCharBufStream : public simplecpp::TokenList::Stream {
395395
public:
396396
// cppcheck-suppress uninitDerivedMemberVar - we call Stream::init() to initialize the private members
397-
StdCharBufStream(const unsigned char* str, std::size_t size)
397+
StdCharBufStream(const unsigned char* str SIMPLECPP_LIFETIMEBOUND, std::size_t size)
398398
: str(str)
399399
, size(size)
400400
{
@@ -1508,12 +1508,12 @@ namespace simplecpp {
15081508

15091509
class Macro {
15101510
public:
1511-
explicit Macro(std::vector<std::string> &f) : nameTokDef(nullptr), valueToken(nullptr), endToken(nullptr), files(f), tokenListDefine(f), variadic(false), variadicOpt(false), valueDefinedInCode_(false) {}
1511+
explicit Macro(std::vector<std::string> &f SIMPLECPP_LIFETIMEBOUND) : nameTokDef(nullptr), valueToken(nullptr), endToken(nullptr), files(f), tokenListDefine(f), variadic(false), variadicOpt(false), valueDefinedInCode_(false) {}
15121512

15131513
/**
15141514
* @throws std::runtime_error thrown on bad macro syntax
15151515
*/
1516-
Macro(const Token *tok, std::vector<std::string> &f) : nameTokDef(nullptr), files(f), tokenListDefine(f), valueDefinedInCode_(true) {
1516+
Macro(const Token *tok, std::vector<std::string> &f SIMPLECPP_LIFETIMEBOUND) : nameTokDef(nullptr), files(f), tokenListDefine(f), valueDefinedInCode_(true) {
15171517
if (sameline(tok->previousSkipComments(), tok))
15181518
throw std::runtime_error("bad macro syntax");
15191519
if (tok->op != '#')
@@ -1532,7 +1532,7 @@ namespace simplecpp {
15321532
/**
15331533
* @throws std::runtime_error thrown on bad macro syntax
15341534
*/
1535-
Macro(const std::string &name, const std::string &value, std::vector<std::string> &f) : nameTokDef(nullptr), files(f), tokenListDefine(f), valueDefinedInCode_(false) {
1535+
Macro(const std::string &name, const std::string &value, std::vector<std::string> &f SIMPLECPP_LIFETIMEBOUND) : nameTokDef(nullptr), files(f), tokenListDefine(f), valueDefinedInCode_(false) {
15361536
const std::string def(name + ' ' + value);
15371537
StdCharBufStream stream(reinterpret_cast<const unsigned char*>(def.data()), def.size());
15381538
tokenListDefine.readfile(stream);

simplecpp.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ namespace simplecpp {
8686
{
8787
// cppcheck-suppress noExplicitConstructor
8888
// NOLINTNEXTLINE(misc-explicit-constructor)
89-
View(const char* data)
89+
View(const char* data SIMPLECPP_LIFETIMEBOUND)
9090
: mData(data)
9191
, mSize(strlen(data))
9292
{}
@@ -100,7 +100,7 @@ namespace simplecpp {
100100

101101
// cppcheck-suppress noExplicitConstructor
102102
// NOLINTNEXTLINE(misc-explicit-constructor)
103-
View(const std::string& str)
103+
View(const std::string& str )
104104
: mData(str.data())
105105
, mSize(str.size())
106106
{}

0 commit comments

Comments
 (0)