#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,
bool EnableLifetimeWarnings);
static void visitLocalsRetainedByReferenceBinding(IndirectLocalPath &Path,
Expr *Init, ReferenceKind RK,
LocalVisitor Visit,
bool EnableLifetimeWarnings);
template <typename T> static bool isRecordWithAttr(QualType Type) { … }
static bool isInStlNamespace(const Decl *D) { … }
static bool shouldTrackImplicitObjectArg(const CXXMethodDecl *Callee) { … }
static bool shouldTrackFirstArgument(const FunctionDecl *FD) { … }
static bool implicitObjectParamIsLifetimeBound(const FunctionDecl *FD) { … }
static void visitFunctionCallArguments(IndirectLocalPath &Path, Expr *Call,
LocalVisitor Visit,
bool EnableLifetimeWarnings) { … }
static void visitLocalsRetainedByReferenceBinding(IndirectLocalPath &Path,
Expr *Init, ReferenceKind RK,
LocalVisitor Visit,
bool EnableLifetimeWarnings) { … }
static void visitLocalsRetainedByInitializer(IndirectLocalPath &Path,
Expr *Init, LocalVisitor Visit,
bool RevisitSubinits,
bool EnableLifetimeWarnings) { … }
enum PathLifetimeKind { … };
static PathLifetimeKind
shouldLifetimeExtendThroughPath(const IndirectLocalPath &Path) { … }
static SourceRange nextPathEntryRange(const IndirectLocalPath &Path, unsigned I,
Expr *E) { … }
static bool pathOnlyHandlesGslPointer(IndirectLocalPath &Path) { … }
static void checkExprLifetimeImpl(Sema &SemaRef,
const InitializedEntity *InitEntity,
const InitializedEntity *ExtendingEntity,
LifetimeKind LK,
const AssignedEntity *AEntity, Expr *Init,
bool EnableLifetimeWarnings) { … }
void checkExprLifetime(Sema &SemaRef, const InitializedEntity &Entity,
Expr *Init) { … }
void checkExprLifetime(Sema &SemaRef, const AssignedEntity &Entity,
Expr *Init) { … }
}