[clang-tools-extra] [clang-tidy][NFC] Fix gsl::not_null template parameter (PR #99472)
Rafael Stahl via cfe-commits
cfe-commits at lists.llvm.org
Thu Jul 18 04:36:20 PDT 2024
https://github.com/rafzi created https://github.com/llvm/llvm-project/pull/99472
`T` is expected to be a pointer type.
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Rf-nullptr
>From 48e452b9032d26889dfceb7668159275015a5290 Mon Sep 17 00:00:00 2001
From: Rafael Stahl <dummdoof-doof at web.de>
Date: Thu, 18 Jul 2024 13:35:28 +0200
Subject: [PATCH] [clang-tidy][NFC] Fix gsl::not_null template parameter
---
.../cppcoreguidelines/avoid-const-or-ref-data-members.rst | 2 +-
.../cppcoreguidelines/avoid-const-or-ref-data-members.cpp | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/avoid-const-or-ref-data-members.rst b/clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/avoid-const-or-ref-data-members.rst
index 5783280478dc1..57c4829431e76 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/avoid-const-or-ref-data-members.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/avoid-const-or-ref-data-members.rst
@@ -35,7 +35,7 @@ Examples:
int* x;
std::unique_ptr<int> x;
std::shared_ptr<int> x;
- gsl::not_null<int> x;
+ gsl::not_null<int*> x;
};
// Bad, rvalue reference member
diff --git a/clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/avoid-const-or-ref-data-members.cpp b/clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/avoid-const-or-ref-data-members.cpp
index 5a5d05bb4e94e..e3864be134da3 100644
--- a/clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/avoid-const-or-ref-data-members.cpp
+++ b/clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/avoid-const-or-ref-data-members.cpp
@@ -18,7 +18,7 @@ struct Ok {
const int *pc;
std::unique_ptr<int> up;
std::shared_ptr<int> sp;
- gsl::not_null<int> n;
+ gsl::not_null<int*> n;
};
struct ConstMember {
@@ -60,7 +60,7 @@ struct Ok2 {
const Foo *pc;
std::unique_ptr<Foo> up;
std::shared_ptr<Foo> sp;
- gsl::not_null<Foo> n;
+ gsl::not_null<Foo*> n;
};
struct ConstMember2 {
More information about the cfe-commits
mailing list