CleanupInfo.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===--- CleanupInfo.cpp - Cleanup Control in Sema ------------------------===//
  7. //
  8. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  9. // See https://llvm.org/LICENSE.txt for license information.
  10. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  11. //
  12. //===----------------------------------------------------------------------===//
  13. //
  14. // This file implements a set of operations on whether generating an
  15. // ExprWithCleanups in a full expression.
  16. //
  17. //===----------------------------------------------------------------------===//
  18. #ifndef LLVM_CLANG_SEMA_CLEANUPINFO_H
  19. #define LLVM_CLANG_SEMA_CLEANUPINFO_H
  20. namespace clang {
  21. class CleanupInfo {
  22. bool ExprNeedsCleanups = false;
  23. bool CleanupsHaveSideEffects = false;
  24. public:
  25. bool exprNeedsCleanups() const { return ExprNeedsCleanups; }
  26. bool cleanupsHaveSideEffects() const { return CleanupsHaveSideEffects; }
  27. void setExprNeedsCleanups(bool SideEffects) {
  28. ExprNeedsCleanups = true;
  29. CleanupsHaveSideEffects |= SideEffects;
  30. }
  31. void reset() {
  32. ExprNeedsCleanups = false;
  33. CleanupsHaveSideEffects = false;
  34. }
  35. void mergeFrom(CleanupInfo Rhs) {
  36. ExprNeedsCleanups |= Rhs.ExprNeedsCleanups;
  37. CleanupsHaveSideEffects |= Rhs.CleanupsHaveSideEffects;
  38. }
  39. };
  40. } // end namespace clang
  41. #endif
  42. #ifdef __GNUC__
  43. #pragma GCC diagnostic pop
  44. #endif