1//===--- CleanupInfo.cpp - Cleanup Control in Sema ------------------------===//
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//
9//  This file implements a set of operations on whether generating an
10//  ExprWithCleanups in a full expression.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_CLANG_SEMA_CLEANUP_INFO_H
15#define LLVM_CLANG_SEMA_CLEANUP_INFO_H
16
17namespace clang {
18
19class CleanupInfo {
20  bool ExprNeedsCleanups = false;
21  bool CleanupsHaveSideEffects = false;
22
23public:
24  bool exprNeedsCleanups() const { return ExprNeedsCleanups; }
25
26  bool cleanupsHaveSideEffects() const { return CleanupsHaveSideEffects; }
27
28  void setExprNeedsCleanups(bool SideEffects) {
29    ExprNeedsCleanups = true;
30    CleanupsHaveSideEffects |= SideEffects;
31  }
32
33  void reset() {
34    ExprNeedsCleanups = false;
35    CleanupsHaveSideEffects = false;
36  }
37
38  void mergeFrom(CleanupInfo Rhs) {
39    ExprNeedsCleanups |= Rhs.ExprNeedsCleanups;
40    CleanupsHaveSideEffects |= Rhs.CleanupsHaveSideEffects;
41  }
42};
43
44} // end namespace clang
45
46#endif
47