clang 22.0.0git
LifetimeAnnotations.h
Go to the documentation of this file.
1//===- LifetimeAnnotations.h - -*--------------- C++--------------------*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8// Helper functions to inspect and infer lifetime annotations.
9//===----------------------------------------------------------------------===//
10#ifndef LLVM_CLANG_ANALYSIS_ANALYSES_LIFETIMEANNOTATIONS_H
11#define LLVM_CLANG_ANALYSIS_ANALYSES_LIFETIMEANNOTATIONS_H
12
13#include "clang/AST/DeclCXX.h"
14
15namespace clang ::lifetimes {
16
17/// Returns the most recent declaration of the method to ensure all
18/// lifetime-bound attributes from redeclarations are considered.
19const FunctionDecl *getDeclWithMergedLifetimeBoundAttrs(const FunctionDecl *FD);
20
21/// Returns the most recent declaration of the method to ensure all
22/// lifetime-bound attributes from redeclarations are considered.
23const CXXMethodDecl *
24getDeclWithMergedLifetimeBoundAttrs(const CXXMethodDecl *CMD);
25
26// Return true if this is an "normal" assignment operator.
27// We assume that a normal assignment operator always returns *this, that is,
28// an lvalue reference that is the same type as the implicit object parameter
29// (or the LHS for a non-member operator==).
30bool isNormalAssignmentOperator(const FunctionDecl *FD);
31
32/// Returns true if this is an assignment operator where the parameter
33/// has the lifetimebound attribute.
34bool isAssignmentOperatorLifetimeBound(const CXXMethodDecl *CMD);
35
36/// Returns true if the implicit object parameter (this) should be considered
37/// lifetimebound, either due to an explicit lifetimebound attribute on the
38/// method or because it's a normal assignment operator.
39bool implicitObjectParamIsLifetimeBound(const FunctionDecl *FD);
40
41} // namespace clang::lifetimes
42
43#endif // LLVM_CLANG_ANALYSIS_ANALYSES_LIFETIMEANNOTATIONS_H
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
bool isAssignmentOperatorLifetimeBound(const CXXMethodDecl *CMD)
Returns true if this is an assignment operator where the parameter has the lifetimebound attribute.
bool implicitObjectParamIsLifetimeBound(const FunctionDecl *FD)
Returns true if the implicit object parameter (this) should be considered lifetimebound,...
const FunctionDecl * getDeclWithMergedLifetimeBoundAttrs(const FunctionDecl *FD)
Returns the most recent declaration of the method to ensure all lifetime-bound attributes from redecl...
bool isNormalAssignmentOperator(const FunctionDecl *FD)
The JSON file list parser is used to communicate input to InstallAPI.