#include "CheckExprLifetime.h"
#include "clang/AST/Decl.h"
#include "clang/AST/Expr.h"
#include "clang/Basic/DiagnosticSema.h"
#include "clang/Sema/Initialization.h"
#include "clang/Sema/Sema.h"
#include "llvm/ADT/PointerIntPair.h"
namespace clang::sema {
namespace {
enum LifetimeKind { … };
LifetimeResult;
}
static LifetimeResult
getEntityLifetime(const InitializedEntity *Entity,
const InitializedEntity *InitField = nullptr) { … }
namespace {
enum ReferenceKind { … };
Local;
struct IndirectLocalPathEntry { … };
IndirectLocalPath;
struct RevertToOldSizeRAII { … };
LocalVisitor;
}
static bool isVarOnPath(IndirectLocalPath &Path, VarDecl *VD) { … }
static bool pathContainsInit(IndirectLocalPath &Path) { … }
static void visitLocalsRetainedByInitializer(IndirectLocalPath &Path,
Expr *Init, LocalVisitor Visit,
bool RevisitSubinits);
static void visitLocalsRetainedByReferenceBinding(IndirectLocalPath &Path,
Expr *Init, ReferenceKind RK,
LocalVisitor Visit);
template <typename T> static bool isRecordWithAttr(QualType Type) { … }
static bool isInStlNamespace(const Decl *D) { … }
static bool isPointerLikeType(QualType Type) { … }
static bool isContainerOfPointer(const RecordDecl *Container) { … }
static bool isContainerOfOwner(const RecordDecl *Container) { … }
static bool isStdInitializerListOfPointer(const RecordDecl *RD) { … }
static bool shouldTrackImplicitObjectArg(const CXXMethodDecl *Callee) { … }
static bool shouldTrackFirstArgument(const FunctionDecl *FD) { … }
static bool isCopyLikeConstructor(const CXXConstructorDecl *Ctor) { … }
static bool
shouldTrackFirstArgumentForConstructor(const CXXConstructExpr *Ctor) { … }
static bool isNormalAssignmentOperator(const FunctionDecl *FD) { … }
static bool implicitObjectParamIsLifetimeBound(const FunctionDecl *FD) { … }
static void visitFunctionCallArguments(IndirectLocalPath &Path, Expr *Call,
LocalVisitor Visit) { … }
static void visitLocalsRetainedByReferenceBinding(IndirectLocalPath &Path,
Expr *Init, ReferenceKind RK,
LocalVisitor Visit) { … }
static void visitLocalsRetainedByInitializer(IndirectLocalPath &Path,
Expr *Init, LocalVisitor Visit,
bool RevisitSubinits) { … }
enum PathLifetimeKind { … };
static PathLifetimeKind
shouldLifetimeExtendThroughPath(const IndirectLocalPath &Path) { … }
static SourceRange nextPathEntryRange(const IndirectLocalPath &Path, unsigned I,
Expr *E) { … }
static bool pathOnlyHandlesGslPointer(IndirectLocalPath &Path) { … }
static bool isAssignmentOperatorLifetimeBound(CXXMethodDecl *CMD) { … }
static bool shouldRunGSLAssignmentAnalysis(const Sema &SemaRef,
const AssignedEntity &Entity) { … }
static void checkExprLifetimeImpl(Sema &SemaRef,
const InitializedEntity *InitEntity,
const InitializedEntity *ExtendingEntity,
LifetimeKind LK,
const AssignedEntity *AEntity, Expr *Init) { … }
void checkExprLifetime(Sema &SemaRef, const InitializedEntity &Entity,
Expr *Init) { … }
void checkExprLifetimeMustTailArg(Sema &SemaRef,
const InitializedEntity &Entity, Expr *Init) { … }
void checkExprLifetime(Sema &SemaRef, const AssignedEntity &Entity,
Expr *Init) { … }
}