xref: /freebsd/contrib/llvm-project/clang/lib/Sema/CheckExprLifetime.h (revision 0fca6ea1d4eea4c934cfff25ac9ee8ad6fe95583)
1*0fca6ea1SDimitry Andric //===- CheckExprLifetime.h -----------------------------------  -*- C++ -*-===//
2*0fca6ea1SDimitry Andric //
3*0fca6ea1SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4*0fca6ea1SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
5*0fca6ea1SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6*0fca6ea1SDimitry Andric //===----------------------------------------------------------------------===//
7*0fca6ea1SDimitry Andric //
8*0fca6ea1SDimitry Andric //  This files implements a statement-local lifetime analysis.
9*0fca6ea1SDimitry Andric //
10*0fca6ea1SDimitry Andric //===----------------------------------------------------------------------===//
11*0fca6ea1SDimitry Andric 
12*0fca6ea1SDimitry Andric #ifndef LLVM_CLANG_SEMA_CHECK_EXPR_LIFETIME_H
13*0fca6ea1SDimitry Andric #define LLVM_CLANG_SEMA_CHECK_EXPR_LIFETIME_H
14*0fca6ea1SDimitry Andric 
15*0fca6ea1SDimitry Andric #include "clang/AST/Expr.h"
16*0fca6ea1SDimitry Andric #include "clang/Sema/Initialization.h"
17*0fca6ea1SDimitry Andric #include "clang/Sema/Sema.h"
18*0fca6ea1SDimitry Andric 
19*0fca6ea1SDimitry Andric namespace clang::sema {
20*0fca6ea1SDimitry Andric 
21*0fca6ea1SDimitry Andric /// Describes an entity that is being assigned.
22*0fca6ea1SDimitry Andric struct AssignedEntity {
23*0fca6ea1SDimitry Andric   // The left-hand side expression of the assignment.
24*0fca6ea1SDimitry Andric   Expr *LHS = nullptr;
25*0fca6ea1SDimitry Andric };
26*0fca6ea1SDimitry Andric 
27*0fca6ea1SDimitry Andric /// Check that the lifetime of the given expr (and its subobjects) is
28*0fca6ea1SDimitry Andric /// sufficient for initializing the entity, and perform lifetime extension
29*0fca6ea1SDimitry Andric /// (when permitted) if not.
30*0fca6ea1SDimitry Andric void checkExprLifetime(Sema &SemaRef, const InitializedEntity &Entity,
31*0fca6ea1SDimitry Andric                        Expr *Init);
32*0fca6ea1SDimitry Andric 
33*0fca6ea1SDimitry Andric /// Check that the lifetime of the given expr (and its subobjects) is
34*0fca6ea1SDimitry Andric /// sufficient for assigning to the entity.
35*0fca6ea1SDimitry Andric void checkExprLifetime(Sema &SemaRef, const AssignedEntity &Entity, Expr *Init);
36*0fca6ea1SDimitry Andric 
37*0fca6ea1SDimitry Andric } // namespace clang::sema
38*0fca6ea1SDimitry Andric 
39*0fca6ea1SDimitry Andric #endif // LLVM_CLANG_SEMA_CHECK_EXPR_LIFETIME_H
40