Skip to content

Commit 203a349

Browse files
committed
move to CheckExprLifetime.h
1 parent 241a35c commit 203a349

File tree

4 files changed

+12
-15
lines changed

4 files changed

+12
-15
lines changed

clang/include/clang/Sema/Sema.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1763,10 +1763,6 @@ class Sema final : public SemaBase {
17631763
/// Add [[gsl::Pointer]] attributes for std:: types.
17641764
void inferGslPointerAttribute(TypedefNameDecl *TD);
17651765

1766-
// Tells whether the type is annotated with [[gsl::Pointer]] or is a pointer
1767-
// type.
1768-
static bool isPointerLikeType(QualType QT);
1769-
17701766
LifetimeCaptureByAttr *ParseLifetimeCaptureByAttr(const ParsedAttr &AL,
17711767
StringRef ParamName);
17721768
// Processes the argument 'X' in [[clang::lifetime_capture_by(X)]]. Since 'X'

clang/lib/Sema/CheckExprLifetime.cpp

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -261,16 +261,12 @@ template <typename T> static bool isRecordWithAttr(QualType Type) {
261261
RD = CTSD->getSpecializedTemplate()->getTemplatedDecl();
262262
return RD->hasAttr<T>();
263263
}
264-
} // namespace clang::sema
265264

266-
namespace clang {
267-
bool Sema::isPointerLikeType(QualType QT) {
268-
return sema::isRecordWithAttr<PointerAttr>(QT) || QT->isPointerType() ||
265+
bool isPointerLikeType(QualType QT) {
266+
return isRecordWithAttr<PointerAttr>(QT) || QT->isPointerType() ||
269267
QT->isNullPtrType();
270268
}
271-
} // namespace clang
272269

273-
namespace clang::sema {
274270
// Decl::isInStdNamespace will return false for iterators in some STL
275271
// implementations due to them being defined in a namespace outside of the std
276272
// namespace.
@@ -298,7 +294,7 @@ static bool isContainerOfPointer(const RecordDecl *Container) {
298294
return false;
299295
const auto &TAs = CTSD->getTemplateArgs();
300296
return TAs.size() > 0 && TAs[0].getKind() == TemplateArgument::Type &&
301-
Sema::isPointerLikeType(TAs[0].getAsType());
297+
isPointerLikeType(TAs[0].getAsType());
302298
}
303299
return false;
304300
}
@@ -322,7 +318,7 @@ static bool isStdInitializerListOfPointer(const RecordDecl *RD) {
322318
return isInStlNamespace(RD) && RD->getIdentifier() &&
323319
RD->getName() == "initializer_list" && TAs.size() > 0 &&
324320
TAs[0].getKind() == TemplateArgument::Type &&
325-
Sema::isPointerLikeType(TAs[0].getAsType());
321+
isPointerLikeType(TAs[0].getAsType());
326322
}
327323
return false;
328324
}
@@ -338,7 +334,7 @@ static bool shouldTrackImplicitObjectArg(const CXXMethodDecl *Callee) {
338334
Callee->getFunctionObjectParameterType()) &&
339335
!isRecordWithAttr<OwnerAttr>(Callee->getFunctionObjectParameterType()))
340336
return false;
341-
if (Sema::isPointerLikeType(Callee->getReturnType())) {
337+
if (isPointerLikeType(Callee->getReturnType())) {
342338
if (!Callee->getIdentifier())
343339
return false;
344340
return llvm::StringSwitch<bool>(Callee->getName())
@@ -1446,7 +1442,7 @@ checkExprLifetimeImpl(Sema &SemaRef, const InitializedEntity *InitEntity,
14461442
break;
14471443
}
14481444
case LK_LifetimeCapture: {
1449-
if (Sema::isPointerLikeType(Init->getType()))
1445+
if (isPointerLikeType(Init->getType()))
14501446
Path.push_back({IndirectLocalPathEntry::GslPointerInit, Init});
14511447
break;
14521448
}

clang/lib/Sema/CheckExprLifetime.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@
1818

1919
namespace clang::sema {
2020

21+
// Tells whether the type is annotated with [[gsl::Pointer]] or is a pointer
22+
// type.
23+
bool isPointerLikeType(QualType QT);
24+
2125
/// Describes an entity that is being assigned.
2226
struct AssignedEntity {
2327
// The left-hand side expression of the assignment.

clang/lib/Sema/SemaAttr.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
//
1212
//===----------------------------------------------------------------------===//
1313

14+
#include "CheckExprLifetime.h"
1415
#include "clang/AST/ASTConsumer.h"
1516
#include "clang/AST/Attr.h"
1617
#include "clang/AST/Expr.h"
@@ -286,7 +287,7 @@ void Sema::inferLifetimeCaptureByAttribute(FunctionDecl *FD) {
286287
if (PVD->hasAttr<LifetimeCaptureByAttr>())
287288
return;
288289
for (ParmVarDecl *PVD : MD->parameters()) {
289-
if (isPointerLikeType(PVD->getType().getNonReferenceType())) {
290+
if (sema::isPointerLikeType(PVD->getType().getNonReferenceType())) {
290291
int CaptureByThis[] = {LifetimeCaptureByAttr::THIS};
291292
PVD->addAttr(
292293
LifetimeCaptureByAttr::CreateImplicit(Context, CaptureByThis, 1));

0 commit comments

Comments
 (0)