|
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 60 of file LifetimeSafety.h.
| bool clang::lifetimes::destructsFirstArg | ( | const FunctionDecl & | FD | ) |
Definition at line 564 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 65 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 130 of file LifetimeAnnotations.cpp.
References getImplicitObjectParamAttr().
| const CXXMethodDecl * clang::lifetimes::getDeclWithMergedLifetimeBoundAttrs | ( | const CXXMethodDecl * | CMD | ) |
Definition at line 31 of file LifetimeAnnotations.cpp.
References getDeclWithMergedLifetimeBoundAttrs().
| const FunctionDecl * clang::lifetimes::getDeclWithMergedLifetimeBoundAttrs | ( | const FunctionDecl * | FD | ) |
Definition at line 26 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 103 of file LifetimeAnnotations.cpp.
References getAttrFromFunctionType().
Referenced by clang::lifetimes::LifetimeSafetySemaHelperImpl::reportMisplacedLifetimebound().
|
static |
Definition at line 82 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 108 of file LifetimeAnnotations.cpp.
References getImplicitObjectParamAttr().
Referenced by implicitObjectParamIsLifetimeBound(), and clang::lifetimes::LifetimeSafetySemaHelperImpl::reportLifetimeboundViolation().
|
inline |
Definition at line 146 of file SemaLifetimeSafety.h.
References clang::lifetimes::LifetimeSafetyOpts::CheckCaptureByViolations, 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, ShouldCheckCaptureByViolations(), 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 431 of file LifetimeAnnotations.cpp.
References clang::NamedDecl::getIdentifier(), and clang::NamedDecl::getName().
Referenced by destructsFirstArg(), isInvalidationMethod(), isStdCallableWrapperType(), and isStdUniquePtr().
|
static |
Definition at line 439 of file LifetimeAnnotations.cpp.
References clang::NamedDecl::getIdentifier(), and clang::NamedDecl::getName().
| const ParmVarDecl * clang::lifetimes::getParamForArg | ( | const FunctionDecl & | FD, |
| unsigned | I ) |
Definition at line 156 of file LifetimeAnnotations.cpp.
References clang::FunctionDecl::getNumParams(), clang::FunctionDecl::getParamDecl(), and hasImplicitObjectArg().
Referenced by getTrackedArgInfo().
| std::optional< LifetimeBoundParamInfo > clang::lifetimes::getTrackedArgInfo | ( | const FunctionDecl * | FD, |
| llvm::ArrayRef< const Expr * > | Args, | ||
| unsigned | I ) |
Definition at line 166 of file LifetimeAnnotations.cpp.
References clang::cast(), getDeclWithMergedLifetimeBoundAttrs(), clang::FunctionDecl::getParamDecl(), getParamForArg(), hasImplicitObjectArg(), hasObjectArg(), implicitObjectParamIsLifetimeBound(), clang::Method, paramIsLifetimeBound(), shouldTrackFirstArgument(), shouldTrackImplicitObjectArg(), and shouldTrackSecondArgument().
Referenced by getTrackingInfoForCallArg().
| std::optional< LifetimeBoundParamInfo > clang::lifetimes::getTrackingInfoForCallArg | ( | const Expr * | Call, |
| const Expr * | Source ) |
Definition at line 200 of file LifetimeAnnotations.cpp.
References clang::Call, getTrackedArgInfo(), and ignoreParensAndImpCasts().
| bool clang::lifetimes::hasImplicitObjectArg | ( | const FunctionDecl & | FD | ) |
Definition at line 151 of file LifetimeAnnotations.cpp.
References clang::cast(), and hasObjectArg().
Referenced by getParamForArg(), and getTrackedArgInfo().
| bool clang::lifetimes::hasObjectArg | ( | const FunctionDecl & | FD | ) |
Definition at line 146 of file LifetimeAnnotations.cpp.
References clang::isa().
Referenced by getTrackedArgInfo(), and hasImplicitObjectArg().
Definition at line 626 of file LifetimeAnnotations.cpp.
References clang::IgnoreExprNodes(), clang::IgnoreImplicitCastsSingleStep(), and clang::IgnoreParensSingleStep().
Referenced by clang::lifetimes::internal::findPredBlockForExpr(), clang ::lifetimes::FunctionCallInfo::FunctionCallInfo(), getTrackingInfoForCallArg(), clang::lifetimes::internal::isSubobjectOfThis(), and clang::lifetimes::internal::FactsGenerator::VisitLambdaExpr().
| bool clang::lifetimes::implicitObjectParamIsLifetimeBound | ( | const FunctionDecl * | FD | ) |
Definition at line 112 of file LifetimeAnnotations.cpp.
References getImplicitObjectParamLifetimeBoundAttr(), and isNormalAssignmentOperator().
Referenced by clang::Sema::addLifetimeBoundToImplicitThis(), getTrackedArgInfo(), ProcessAPINotes(), and clang::sema::visitFunctionCallArguments().
| bool clang::lifetimes::isAllocatingFunction | ( | const FunctionDecl & | FD | ) |
Definition at line 570 of file LifetimeAnnotations.cpp.
References clang::FunctionDecl::getBuiltinID(), and clang::Decl::specific_attrs().
| bool clang::lifetimes::isAssignmentOperatorLifetimeBound | ( | const CXXMethodDecl * | CMD | ) |
Definition at line 55 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::isFreeingFunction | ( | const FunctionDecl & | FD | ) |
Definition at line 588 of file LifetimeAnnotations.cpp.
References clang::FunctionDecl::getBuiltinID(), and clang::Decl::specific_attrs().
| bool clang::lifetimes::isGslOwnerType | ( | const CXXRecordDecl * | RD | ) |
Definition at line 422 of file LifetimeAnnotations.cpp.
References isRecordWithAttr().
Definition at line 421 of file LifetimeAnnotations.cpp.
References isRecordWithAttr().
Referenced by isOwnerPtrCtor(), shouldTrackImplicitObjectArg(), and clang::lifetimes::internal::FactsGenerator::VisitCXXMemberCallExpr().
Definition at line 420 of file LifetimeAnnotations.cpp.
References isRecordWithAttr().
Referenced by clang::lifetimes::internal::OriginManager::hasOrigins(), clang::Sema::inferLifetimeCaptureByAttribute(), isPointerLikeType(), shouldTrackFirstArgument(), shouldTrackImplicitObjectArg(), clang::lifetimes::internal::FactsGenerator::VisitCXXConstructExpr(), and clang::lifetimes::internal::FactsGenerator::VisitCXXMemberCallExpr().
Definition at line 217 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 454 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 113 of file SemaLifetimeSafety.h.
References clang::Sema::getLangOpts(), clang::isa(), ShouldCheckCaptureByViolations(), 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 37 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 426 of file LifetimeAnnotations.cpp.
References clang::CXXMethodDecl::getParent(), clang::ValueDecl::getType(), isGslOwnerType(), and clang::Type::isPointerType().
Definition at line 232 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 390 of file LifetimeAnnotations.cpp.
References clang::Decl::hasAttr(), clang::Result, and clang::T.
Referenced by isGslOwnerType(), isGslOwnerType(), isGslPointerType(), and isRecordWithAttr().
Definition at line 416 of file LifetimeAnnotations.cpp.
References clang::Type::getAsCXXRecordDecl(), and isRecordWithAttr().
Definition at line 236 of file LifetimeAnnotations.cpp.
References isPointerLikeType(), and clang::Type::isReferenceType().
Referenced by shouldTrackImplicitObjectArg().
| bool clang::lifetimes::isStdCallableWrapperType | ( | const CXXRecordDecl * | RD | ) |
Definition at line 604 of file LifetimeAnnotations.cpp.
References getName(), and isInStlNamespace().
Referenced by clang::lifetimes::internal::OriginManager::hasOrigins(), and clang::lifetimes::internal::FactsGenerator::VisitCXXConstructExpr().
| bool clang::lifetimes::isStdReferenceCast | ( | const FunctionDecl * | FD | ) |
Definition at line 611 of file LifetimeAnnotations.cpp.
References clang::FunctionDecl::getBuiltinID().
|
static |
Definition at line 445 of file LifetimeAnnotations.cpp.
References getName(), and clang::Decl::isInStdNamespace().
Referenced by isUniquePtrRelease().
| bool clang::lifetimes::isUniquePtrRelease | ( | const CXXMethodDecl & | MD | ) |
Definition at line 449 of file LifetimeAnnotations.cpp.
References clang::NamedDecl::getIdentifier(), clang::NamedDecl::getName(), clang::FunctionDecl::getNumParams(), clang::CXXMethodDecl::getParent(), and isStdUniquePtr().
| bool clang::lifetimes::paramIsLifetimeBound | ( | const ParmVarDecl & | PVD | ) |
Definition at line 118 of file LifetimeAnnotations.cpp.
References clang::Decl::getDeclContext(), clang::Decl::hasAttr(), clang::isa(), and clang::Decl::specific_attrs().
Referenced by getTrackedArgInfo().
| 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 61 of file SemaLifetimeSafety.h.
References clang::Decl::getBeginLoc(), clang::Sema::getDiagnostics(), and clang::DiagnosticsEngine::isIgnored().
Referenced by GetLifetimeSafetyOpts(), and IsLifetimeSafetyEnabled().
Definition at line 87 of file SemaLifetimeSafety.h.
References clang::Decl::getBeginLoc(), clang::Sema::getDiagnostics(), and clang::DiagnosticsEngine::isIgnored().
Referenced by GetLifetimeSafetyOpts(), and IsLifetimeSafetyEnabled().
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 56 of file SemaLifetimeSafety.h.
References clang::Decl::getBeginLoc(), clang::Sema::getDiagnostics(), and clang::DiagnosticsEngine::isIgnored().
Referenced by GetLifetimeSafetyOpts(), and IsLifetimeSafetyEnabled().
Definition at line 66 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 98 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 322 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 240 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 374 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().