Skip to content

Commit 363ca5a

Browse files
committed
Add lifetime annotations to more places using StringRef
1 parent cb6d713 commit 363ca5a

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/catch2/internal/catch_string_manip.hpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#ifndef CATCH_STRING_MANIP_HPP_INCLUDED
99
#define CATCH_STRING_MANIP_HPP_INCLUDED
1010

11+
#include <catch2/internal/catch_lifetimebound.hpp>
1112
#include <catch2/internal/catch_stringref.hpp>
1213

1314
#include <cstdint>
@@ -28,10 +29,10 @@ namespace Catch {
2829
//! Returns a new string without whitespace at the start/end
2930
std::string trim( std::string const& str );
3031
//! Returns a substring of the original ref without whitespace. Beware lifetimes!
31-
StringRef trim(StringRef ref);
32+
StringRef trim( StringRef ref CATCH_ATTR_LIFETIMEBOUND );
3233

3334
// !!! Be aware, returns refs into original string - make sure original string outlives them
34-
std::vector<StringRef> splitStringRef( StringRef str, char delimiter );
35+
std::vector<StringRef> splitStringRef( StringRef str CATCH_ATTR_LIFETIMEBOUND, char delimiter );
3536
bool replaceInPlace( std::string& str, std::string const& replaceThis, std::string const& withThis );
3637

3738
/**
@@ -49,7 +50,7 @@ namespace Catch {
4950
StringRef m_label;
5051

5152
public:
52-
constexpr pluralise(std::uint64_t count, StringRef label):
53+
constexpr pluralise(std::uint64_t count, StringRef label CATCH_ATTR_LIFETIMEBOUND):
5354
m_count(count),
5455
m_label(label)
5556
{}

src/catch2/internal/catch_test_case_tracker.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#ifndef CATCH_TEST_CASE_TRACKER_HPP_INCLUDED
99
#define CATCH_TEST_CASE_TRACKER_HPP_INCLUDED
1010

11+
#include <catch2/internal/catch_lifetimebound.hpp>
1112
#include <catch2/internal/catch_source_line_info.hpp>
1213
#include <catch2/internal/catch_unique_ptr.hpp>
1314
#include <catch2/internal/catch_stringref.hpp>
@@ -48,7 +49,7 @@ namespace TestCaseTracking {
4849
StringRef name;
4950
SourceLineInfo location;
5051

51-
constexpr NameAndLocationRef( StringRef name_,
52+
constexpr NameAndLocationRef( StringRef name_ CATCH_ATTR_LIFETIMEBOUND,
5253
SourceLineInfo location_ ):
5354
name( name_ ), location( location_ ) {}
5455

0 commit comments

Comments
 (0)