|
| 1 | +//===--- RegionIsolation.h ------------------------------------------------===// |
| 2 | +// |
| 3 | +// This source file is part of the Swift.org open source project |
| 4 | +// |
| 5 | +// Copyright (c) 2014 - 2024 Apple Inc. and the Swift project authors |
| 6 | +// Licensed under Apache License v2.0 with Runtime Library Exception |
| 7 | +// |
| 8 | +// See https://swift.org/LICENSE.txt for license information |
| 9 | +// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors |
| 10 | +// |
| 11 | +//===----------------------------------------------------------------------===// |
| 12 | +/// |
| 13 | +/// \file This file just declares some command line options that are used for |
| 14 | +/// the various parts of region analysis based diagnostics. |
| 15 | +/// |
| 16 | +//===----------------------------------------------------------------------===// |
| 17 | + |
| 18 | +#ifndef SWIFT_SILOPTIMIZER_UTILS_REGIONANALYSIS_H |
| 19 | +#define SWIFT_SILOPTIMIZER_UTILS_REGIONANALYSIS_H |
| 20 | + |
| 21 | +namespace swift { |
| 22 | + |
| 23 | +namespace regionisolation { |
| 24 | + |
| 25 | +enum class LoggingFlag { |
| 26 | + Off = 0, |
| 27 | + Normal = 0x1, |
| 28 | + Verbose = 0x3, |
| 29 | +}; |
| 30 | + |
| 31 | +extern LoggingFlag ENABLE_LOGGING; |
| 32 | + |
| 33 | +#ifdef REGIONBASEDISOLATION_LOG |
| 34 | +#error "REGIONBASEDISOLATION_LOG already defined?!" |
| 35 | +#endif |
| 36 | + |
| 37 | +#ifdef REGIONBASEDISOLATION_VERBOSE_LOG |
| 38 | +#error "REGIONBASEDISOLATION_VERBOSE_LOG already defined?!" |
| 39 | +#endif |
| 40 | + |
| 41 | +#define REGIONBASEDISOLATION_LOG(...) \ |
| 42 | + do { \ |
| 43 | + if (swift::regionisolation::ENABLE_LOGGING != \ |
| 44 | + swift::regionisolation::LoggingFlag::Off) { \ |
| 45 | + __VA_ARGS__; \ |
| 46 | + } \ |
| 47 | + } while (0); |
| 48 | + |
| 49 | +#define REGIONBASEDISOLATION_VERBOSE_LOG(...) \ |
| 50 | + do { \ |
| 51 | + if (swift::regionisolation::ENABLE_LOGGING == \ |
| 52 | + swift::regionisolation::LoggingFlag::Verbose) { \ |
| 53 | + __VA_ARGS__; \ |
| 54 | + } \ |
| 55 | + } while (0); |
| 56 | + |
| 57 | +} // namespace regionisolation |
| 58 | + |
| 59 | +} // namespace swift |
| 60 | + |
| 61 | +#endif |
0 commit comments