|
clang 24.0.0git
|
Namespaces | |
| namespace | internal |
Classes | |
| struct | LifetimeSafetyOpts |
| class | LifetimeSafetySemaHelper |
| Abstract interface for operations requiring Sema access. More... | |
| class | LifetimeSafetySemaHelperImpl |
| struct | LifetimeSafetyStats |
| A structure to hold the statistics related to LifetimeAnalysis. More... | |
| class | UseSite |
| Where and how an origin is used, for diagnostics. More... | |
Enumerations | |
| enum class | UseKind { Explicit , Destructor , Cleanup } |
| How an origin is used: by an expression, or implicitly at scope exit by a destructor or a cleanup callback that may read the borrows it holds. More... | |
| enum class | WarningScope { CrossTU , IntraTU } |
| Enum to track functions visible across or within TU. More... | |
|
strong |
|
strong |
Enum to track functions visible across or within TU.
| Enumerator | |
|---|---|
| CrossTU | |
| IntraTU | |
Definition at line 55 of file LifetimeSafety.h.
| bool clang::lifetimes::destructsFirstArg | ( | const FunctionDecl & | FD | ) |
Definition at line 536 of file LifetimeAnnotations.cpp.
References getName(), clang::isa(), and isInStlNamespace().
|
static |
Check if a function has an attribute on its function type (which represents the implicit 'this' parameter for methods).
Returns the attribute if found, nullptr otherwise.
Definition at line 64 of file LifetimeAnnotations.cpp.
References clang::TypeLoc::getAsAdjusted(), clang::TypeSourceInfo::getTypeLoc(), and clang::DeclaratorDecl::getTypeSourceInfo().
Referenced by getDirectImplicitObjectLifetimeBoundAttr(), and getImplicitObjectParamAttr().
| const LifetimeCaptureByAttr * clang::lifetimes::getCaptureByAttrFromFunctionType | ( | const FunctionDecl * | FD | ) |
Definition at line 118 of file LifetimeAnnotations.cpp.
References getImplicitObjectParamAttr().
| const CXXMethodDecl * clang::lifetimes::getDeclWithMergedLifetimeBoundAttrs | ( | const CXXMethodDecl * | CMD | ) |
Definition at line 30 of file LifetimeAnnotations.cpp.
References getDeclWithMergedLifetimeBoundAttrs().
| const FunctionDecl * clang::lifetimes::getDeclWithMergedLifetimeBoundAttrs | ( | const FunctionDecl * | FD | ) |
Definition at line 25 of file LifetimeAnnotations.cpp.
References clang::FunctionDecl::getMostRecentDecl().
Referenced by getDeclWithMergedLifetimeBoundAttrs(), getImplicitObjectParamAttr(), getTrackedArgInfo(), isAssignmentOperatorLifetimeBound(), and clang::sema::visitFunctionCallArguments().
| const LifetimeBoundAttr * clang::lifetimes::getDirectImplicitObjectLifetimeBoundAttr | ( | const FunctionDecl * | FD | ) |
Definition at line 102 of file LifetimeAnnotations.cpp.
References getAttrFromFunctionType().
Referenced by clang::lifetimes::LifetimeSafetySemaHelperImpl::reportMisplacedLifetimebound().
|
static |
Definition at line 81 of file LifetimeAnnotations.cpp.
References getAttrFromFunctionType(), getDeclWithMergedLifetimeBoundAttrs(), clang::FunctionDecl::getTemplateInstantiationPattern(), and clang::FunctionDecl::redecls().
Referenced by getCaptureByAttrFromFunctionType(), and getImplicitObjectParamLifetimeBoundAttr().
| const LifetimeBoundAttr * clang::lifetimes::getImplicitObjectParamLifetimeBoundAttr | ( | const FunctionDecl * | FD | ) |
Definition at line 107 of file LifetimeAnnotations.cpp.
References getImplicitObjectParamAttr().
Referenced by implicitObjectParamIsLifetimeBound(), and clang::lifetimes::LifetimeSafetySemaHelperImpl::reportLifetimeboundViolation().
|
inline |
Definition at line 140 of file SemaLifetimeSafety.h.
References clang::lifetimes::LifetimeSafetyOpts::CheckDestructorUses, clang::lifetimes::LifetimeSafetyOpts::CheckFieldOriginEscape, clang::lifetimes::LifetimeSafetyOpts::CheckInapplicableLifetimebound, clang::lifetimes::LifetimeSafetyOpts::CheckLifetimeboundViolations, clang::lifetimes::LifetimeSafetyOpts::CheckMisplacedLifetimebound, clang::lifetimes::LifetimeSafetyOpts::CheckNoescapeViolations, clang::Sema::getLangOpts(), clang::lifetimes::LifetimeSafetyOpts::MaxCFGBlocks, ShouldCheckDestructorUses(), ShouldCheckFieldOriginEscape(), ShouldCheckInapplicableLifetimebound(), ShouldCheckLifetimeboundViolations(), ShouldCheckMisplacedLifetimebound(), ShouldCheckNoescapeViolations(), ShouldSuggestLifetimeAnnotations(), and clang::lifetimes::LifetimeSafetyOpts::SuggestAnnotations.
Referenced by clang::sema::AnalysisBasedWarnings::IssueWarnings(), clang::sema::AnalysisBasedWarnings::IssueWarningsForImplicitFunction(), and LifetimeSafetyTUAnalysis().
|
static |
Definition at line 403 of file LifetimeAnnotations.cpp.
References clang::NamedDecl::getIdentifier(), and clang::NamedDecl::getName().
Referenced by destructsFirstArg(), isInvalidationMethod(), isStdCallableWrapperType(), and isStdUniquePtr().
|
static |
Definition at line 411 of file LifetimeAnnotations.cpp.
References clang::NamedDecl::getIdentifier(), and clang::NamedDecl::getName().
| std::optional< LifetimeBoundParamInfo > clang::lifetimes::getTrackedArgInfo | ( | const FunctionDecl * | FD, |
| llvm::ArrayRef< const Expr * > | Args, | ||
| unsigned | I ) |
Definition at line 135 of file LifetimeAnnotations.cpp.
References getDeclWithMergedLifetimeBoundAttrs(), clang::FunctionDecl::getParamDecl(), clang::Decl::hasAttr(), implicitObjectParamIsLifetimeBound(), clang::isa(), clang::Method, shouldTrackFirstArgument(), shouldTrackImplicitObjectArg(), and shouldTrackSecondArgument().
Referenced by getTrackingInfoForCallArg().
| std::optional< LifetimeBoundParamInfo > clang::lifetimes::getTrackingInfoForCallArg | ( | const Expr * | Call, |
| const Expr * | Source ) |
Definition at line 172 of file LifetimeAnnotations.cpp.
References clang::Call, and getTrackedArgInfo().
| bool clang::lifetimes::implicitObjectParamIsLifetimeBound | ( | const FunctionDecl * | FD | ) |
Definition at line 111 of file LifetimeAnnotations.cpp.
References getImplicitObjectParamLifetimeBoundAttr(), and isNormalAssignmentOperator().
Referenced by clang::Sema::addLifetimeBoundToImplicitThis(), getTrackedArgInfo(), ProcessAPINotes(), and clang::sema::visitFunctionCallArguments().
| bool clang::lifetimes::isAssignmentOperatorLifetimeBound | ( | const CXXMethodDecl * | CMD | ) |
Definition at line 54 of file LifetimeAnnotations.cpp.
References getDeclWithMergedLifetimeBoundAttrs(), clang::FunctionDecl::getParamDecl(), clang::Decl::hasAttr(), isNormalAssignmentOperator(), and clang::FunctionDecl::param_size().
Referenced by clang::sema::checkExprLifetimeImpl(), and clang::sema::shouldRunGSLAssignmentAnalysis().
| bool clang::lifetimes::isGslOwnerType | ( | const CXXRecordDecl * | RD | ) |
Definition at line 394 of file LifetimeAnnotations.cpp.
References isRecordWithAttr().
Definition at line 393 of file LifetimeAnnotations.cpp.
References isRecordWithAttr().
Referenced by isOwnerPtrCtor(), shouldTrackImplicitObjectArg(), clang::lifetimes::internal::FactsGenerator::VisitCXXMemberCallExpr(), and clang::lifetimes::internal::FactsGenerator::VisitCXXOperatorCallExpr().
Definition at line 392 of file LifetimeAnnotations.cpp.
References isRecordWithAttr().
Referenced by clang::lifetimes::internal::OriginManager::hasOrigins(), clang::Sema::inferLifetimeCaptureByAttribute(), isPointerLikeType(), shouldTrackFirstArgument(), shouldTrackImplicitObjectArg(), clang::lifetimes::internal::FactsGenerator::VisitCXXConstructExpr(), clang::lifetimes::internal::FactsGenerator::VisitCXXMemberCallExpr(), and clang::lifetimes::internal::FactsGenerator::VisitCXXOperatorCallExpr().
Definition at line 189 of file LifetimeAnnotations.cpp.
References clang::Decl::getDeclContext(), clang::DeclContext::getParent(), and clang::isUppercase().
Referenced by destructsFirstArg(), isInvalidationMethod(), isStdCallableWrapperType(), clang::sema::isStdInitializerListOfPointer(), and shouldTrackImplicitObjectArg().
| bool clang::lifetimes::isInvalidationMethod | ( | const CXXMethodDecl & | MD | ) |
Definition at line 426 of file LifetimeAnnotations.cpp.
References clang::NamedDecl::getIdentifier(), getName(), clang::NamedDecl::getName(), clang::FunctionDecl::getOverloadedOperator(), clang::CXXMethodDecl::getParent(), isInStlNamespace(), clang::OO_None, and clang::Vector.
Definition at line 108 of file SemaLifetimeSafety.h.
References clang::Sema::getLangOpts(), clang::isa(), ShouldCheckDestructorUses(), ShouldCheckFieldOriginEscape(), ShouldCheckInapplicableLifetimebound(), ShouldCheckLifetimeboundViolations(), ShouldCheckMisplacedLifetimebound(), ShouldCheckNoescapeViolations(), ShouldCheckSafety(), and ShouldSuggestLifetimeAnnotations().
Referenced by clang::sema::AnalysisBasedWarnings::IssueWarnings(), clang::sema::AnalysisBasedWarnings::IssueWarnings(), and clang::sema::AnalysisBasedWarnings::IssueWarningsForImplicitFunction().
| bool clang::lifetimes::isNormalAssignmentOperator | ( | const FunctionDecl * | FD | ) |
Definition at line 36 of file LifetimeAnnotations.cpp.
References clang::Decl::getASTContext(), clang::DeclarationName::getCXXOverloadedOperator(), clang::NamedDecl::getDeclName(), clang::ASTContext::getLValueReferenceType(), clang::FunctionDecl::getParamDecl(), clang::FunctionDecl::getReturnType(), clang::ValueDecl::getType(), clang::ASTContext::hasSameType(), clang::isCompoundAssignmentOperator(), and clang::Type::isLValueReferenceType().
Referenced by implicitObjectParamIsLifetimeBound(), and isAssignmentOperatorLifetimeBound().
| bool clang::lifetimes::isOwnerPtrCtor | ( | const CXXConstructorDecl * | Ctor, |
| const ParmVarDecl * | PVD ) |
Definition at line 398 of file LifetimeAnnotations.cpp.
References clang::CXXMethodDecl::getParent(), clang::ValueDecl::getType(), isGslOwnerType(), and clang::Type::isPointerType().
Definition at line 204 of file LifetimeAnnotations.cpp.
References isGslPointerType(), clang::Type::isNullPtrType(), and clang::Type::isPointerType().
Referenced by clang::sema::checkExprLifetimeImpl(), clang::sema::isContainerOfPointer(), isReferenceOrPointerLikeType(), clang::sema::isStdInitializerListOfPointer(), clang::isView(), and shouldTrackImplicitObjectArg().
|
static |
Definition at line 362 of file LifetimeAnnotations.cpp.
References clang::Decl::hasAttr(), clang::Result, and clang::T.
Referenced by isGslOwnerType(), isGslOwnerType(), isGslPointerType(), and isRecordWithAttr().
Definition at line 388 of file LifetimeAnnotations.cpp.
References clang::Type::getAsCXXRecordDecl(), and isRecordWithAttr().
Definition at line 208 of file LifetimeAnnotations.cpp.
References isPointerLikeType(), and clang::Type::isReferenceType().
Referenced by shouldTrackImplicitObjectArg().
| bool clang::lifetimes::isStdCallableWrapperType | ( | const CXXRecordDecl * | RD | ) |
Definition at line 542 of file LifetimeAnnotations.cpp.
References getName(), and isInStlNamespace().
Referenced by clang::lifetimes::internal::OriginManager::hasOrigins(), clang::lifetimes::internal::FactsGenerator::VisitCXXConstructExpr(), and clang::lifetimes::internal::FactsGenerator::VisitCXXOperatorCallExpr().
| bool clang::lifetimes::isStdReferenceCast | ( | const FunctionDecl * | FD | ) |
Definition at line 549 of file LifetimeAnnotations.cpp.
References clang::FunctionDecl::getBuiltinID().
|
static |
Definition at line 417 of file LifetimeAnnotations.cpp.
References getName(), and clang::Decl::isInStdNamespace().
Referenced by isUniquePtrRelease().
| bool clang::lifetimes::isUniquePtrRelease | ( | const CXXMethodDecl & | MD | ) |
Definition at line 421 of file LifetimeAnnotations.cpp.
References clang::NamedDecl::getIdentifier(), clang::NamedDecl::getName(), clang::FunctionDecl::getNumParams(), clang::CXXMethodDecl::getParent(), and isStdUniquePtr().
| void clang::lifetimes::printStats | ( | const LifetimeSafetyStats & | Stats | ) |
Utility function to print missing origin stats.
Definition at line 19 of file LifetimeStats.cpp.
References clang::lifetimes::LifetimeSafetyStats::ExprStmtClassToMissingOriginCount, clang::lifetimes::LifetimeSafetyStats::ExprTypeToMissingOriginCount, and clang::QualType::getAsString().
Referenced by clang::sema::AnalysisBasedWarnings::PrintStats().
| void clang::lifetimes::runLifetimeSafetyAnalysis | ( | AnalysisDeclContext & | AC, |
| LifetimeSafetySemaHelper * | SemaHelper, | ||
| const LifetimeSafetyOpts & | Opts, | ||
| LifetimeSafetyStats & | Stats, | ||
| bool | CollectStats ) |
The main entry point for the analysis.
Definition at line 124 of file LifetimeSafety.cpp.
References clang::lifetimes::internal::LifetimeSafetyAnalysis::getFactManager(), clang::lifetimes::internal::FactManager::getOriginMgr(), and clang::lifetimes::internal::LifetimeSafetyAnalysis::run().
Referenced by clang::sema::AnalysisBasedWarnings::IssueWarnings(), and clang::sema::AnalysisBasedWarnings::IssueWarningsForImplicitFunction().
Definition at line 82 of file SemaLifetimeSafety.h.
References clang::Decl::getBeginLoc(), clang::Sema::getDiagnostics(), and clang::DiagnosticsEngine::isIgnored().
Referenced by GetLifetimeSafetyOpts(), and IsLifetimeSafetyEnabled().
Definition at line 77 of file SemaLifetimeSafety.h.
References clang::Decl::getBeginLoc(), clang::Sema::getDiagnostics(), and clang::DiagnosticsEngine::isIgnored().
Referenced by GetLifetimeSafetyOpts(), and IsLifetimeSafetyEnabled().
Definition at line 72 of file SemaLifetimeSafety.h.
References clang::Decl::getBeginLoc(), clang::Sema::getDiagnostics(), and clang::DiagnosticsEngine::isIgnored().
Referenced by GetLifetimeSafetyOpts(), and IsLifetimeSafetyEnabled().
Definition at line 56 of file SemaLifetimeSafety.h.
References clang::Decl::getBeginLoc(), clang::Sema::getDiagnostics(), and clang::DiagnosticsEngine::isIgnored().
Referenced by GetLifetimeSafetyOpts(), and IsLifetimeSafetyEnabled().
Definition at line 61 of file SemaLifetimeSafety.h.
References clang::Decl::getBeginLoc(), clang::Sema::getDiagnostics(), and clang::DiagnosticsEngine::isIgnored().
Referenced by GetLifetimeSafetyOpts(), and IsLifetimeSafetyEnabled().
Definition at line 51 of file SemaLifetimeSafety.h.
References clang::Decl::getBeginLoc(), clang::Sema::getDiagnostics(), and clang::DiagnosticsEngine::isIgnored().
Referenced by GetLifetimeSafetyOpts(), and IsLifetimeSafetyEnabled().
Definition at line 28 of file SemaLifetimeSafety.h.
References clang::Decl::getBeginLoc(), clang::Sema::getDiagnostics(), and clang::DiagnosticsEngine::isIgnored().
Referenced by IsLifetimeSafetyEnabled().
Definition at line 93 of file SemaLifetimeSafety.h.
References clang::Decl::getBeginLoc(), clang::Sema::getDiagnostics(), and clang::DiagnosticsEngine::isIgnored().
Referenced by GetLifetimeSafetyOpts(), and IsLifetimeSafetyEnabled().
| bool clang::lifetimes::shouldTrackFirstArgument | ( | const FunctionDecl * | FD | ) |
Definition at line 294 of file LifetimeAnnotations.cpp.
References clang::Default, clang::NamedDecl::getIdentifier(), clang::NamedDecl::getName(), clang::FunctionDecl::getNumParams(), clang::FunctionDecl::getParamDecl(), clang::Type::getPointeeCXXRecordDecl(), clang::FunctionDecl::getReturnType(), clang::ValueDecl::getType(), isGslPointerType(), clang::Decl::isInStdNamespace(), clang::Type::isPointerType(), and clang::Type::isReferenceType().
Referenced by getTrackedArgInfo(), and clang::sema::visitFunctionCallArguments().
| bool clang::lifetimes::shouldTrackImplicitObjectArg | ( | const Expr & | ImplicitObjectArgument, |
| const CXXMethodDecl * | Callee, | ||
| bool | RunningUnderLifetimeSafety ) |
Definition at line 212 of file LifetimeAnnotations.cpp.
References clang::Default, clang::Expr::getBestDynamicClassType(), isGslOwnerType(), isGslPointerType(), isInStlNamespace(), isPointerLikeType(), and isReferenceOrPointerLikeType().
Referenced by getTrackedArgInfo(), and clang::sema::visitFunctionCallArguments().
| bool clang::lifetimes::shouldTrackSecondArgument | ( | const FunctionDecl * | FD | ) |
Definition at line 346 of file LifetimeAnnotations.cpp.
References clang::Type::getAsCXXRecordDecl(), clang::FunctionDecl::getNumParams(), clang::FunctionDecl::getOverloadedOperator(), clang::FunctionDecl::getParamDecl(), clang::FunctionDecl::getReturnType(), clang::ValueDecl::getType(), clang::Decl::hasAttr(), clang::ASTContext::hasSameUnqualifiedType(), and clang::isa().
Referenced by getTrackedArgInfo().