[PATCH] D78290: Move [[gsl::Pointer]] into llvm/include/llvm/Support/Compiler.h

Matthias Gehre via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 16 03:56:55 PDT 2020


mgehre updated this revision to Diff 258007.
mgehre added a comment.

Fix typo


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D78290/new/

https://reviews.llvm.org/D78290

Files:
  llvm/include/llvm/ADT/StringRef.h
  llvm/include/llvm/Support/Compiler.h


Index: llvm/include/llvm/Support/Compiler.h
===================================================================
--- llvm/include/llvm/Support/Compiler.h
+++ llvm/include/llvm/Support/Compiler.h
@@ -289,6 +289,14 @@
 #define LLVM_REQUIRE_CONSTANT_INITIALIZATION
 #endif
 
+/// LLVM_GSL_POINTER - Apply this to non-owning classes like
+/// StringRef to enable lifetime warnings.
+#if LLVM_HAS_CPP_ATTRIBUTE(gsl::Pointer)
+#define LLVM_GSL_POINTER [[gsl::Pointer]]
+#else
+#define LLVM_GSL_POINTER
+#endif
+
 /// LLVM_EXTENSION - Support compilers where we have a keyword to suppress
 /// pedantic diagnostics.
 #ifdef __GNUC__
Index: llvm/include/llvm/ADT/StringRef.h
===================================================================
--- llvm/include/llvm/ADT/StringRef.h
+++ llvm/include/llvm/ADT/StringRef.h
@@ -54,7 +54,7 @@
   /// situations where the character data resides in some other buffer, whose
   /// lifetime extends past that of the StringRef. For this reason, it is not in
   /// general safe to store a StringRef.
-  class [[gsl::Pointer]] StringRef {
+  class LLVM_GSL_POINTER StringRef {
   public:
     static const size_t npos = ~size_t(0);
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D78290.258007.patch
Type: text/x-patch
Size: 1164 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200416/85758e88/attachment.bin>


More information about the llvm-commits mailing list