Skip to content

Commit 6d2f73f

Browse files
committed
Revert "Revert "[LifetimeAnalysis] Add [[gsl::Pointer]] to llvm::StringRef""
This reverts commit bac85ab.
1 parent 38ca7b1 commit 6d2f73f

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

llvm/include/llvm/ADT/StringRef.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ namespace llvm {
5454
/// situations where the character data resides in some other buffer, whose
5555
/// lifetime extends past that of the StringRef. For this reason, it is not in
5656
/// general safe to store a StringRef.
57-
class StringRef {
57+
class LLVM_GSL_POINTER StringRef {
5858
public:
5959
static const size_t npos = ~size_t(0);
6060

llvm/include/llvm/Support/Compiler.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,14 @@
289289
#define LLVM_REQUIRE_CONSTANT_INITIALIZATION
290290
#endif
291291

292+
/// LLVM_GSL_POINTER - Apply this to non-owning classes like
293+
/// StringRef to enable lifetime warnings.
294+
#if LLVM_HAS_CPP_ATTRIBUTE(gsl::Pointer)
295+
#define LLVM_GSL_POINTER [[gsl::Pointer]]
296+
#else
297+
#define LLVM_GSL_POINTER
298+
#endif
299+
292300
/// LLVM_EXTENSION - Support compilers where we have a keyword to suppress
293301
/// pedantic diagnostics.
294302
#ifdef __GNUC__

0 commit comments

Comments
 (0)