/Users/buildslave/jenkins/workspace/coverage/llvm-project/clang/include/clang/Basic/ExceptionSpecificationType.h
Line | Count | Source (jump to first uncovered line) |
1 | | //===--- ExceptionSpecificationType.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 | | /// |
9 | | /// \file |
10 | | /// Defines the ExceptionSpecificationType enumeration and various |
11 | | /// utility functions. |
12 | | /// |
13 | | //===----------------------------------------------------------------------===// |
14 | | #ifndef LLVM_CLANG_BASIC_EXCEPTIONSPECIFICATIONTYPE_H |
15 | | #define LLVM_CLANG_BASIC_EXCEPTIONSPECIFICATIONTYPE_H |
16 | | |
17 | | namespace clang { |
18 | | |
19 | | /// The various types of exception specifications that exist in C++11. |
20 | | enum ExceptionSpecificationType { |
21 | | EST_None, ///< no exception specification |
22 | | EST_DynamicNone, ///< throw() |
23 | | EST_Dynamic, ///< throw(T1, T2) |
24 | | EST_MSAny, ///< Microsoft throw(...) extension |
25 | | EST_NoThrow, ///< Microsoft __declspec(nothrow) extension |
26 | | EST_BasicNoexcept, ///< noexcept |
27 | | EST_DependentNoexcept,///< noexcept(expression), value-dependent |
28 | | EST_NoexceptFalse, ///< noexcept(expression), evals to 'false' |
29 | | EST_NoexceptTrue, ///< noexcept(expression), evals to 'true' |
30 | | EST_Unevaluated, ///< not evaluated yet, for special member function |
31 | | EST_Uninstantiated, ///< not instantiated yet |
32 | | EST_Unparsed ///< not parsed yet |
33 | | }; |
34 | | |
35 | 55.0k | inline bool isDynamicExceptionSpec(ExceptionSpecificationType ESpecType) { |
36 | 55.0k | return ESpecType >= EST_DynamicNone && ESpecType <= EST_MSAny4.14k ; |
37 | 55.0k | } |
38 | | |
39 | 320M | inline bool isComputedNoexcept(ExceptionSpecificationType ESpecType) { |
40 | 320M | return ESpecType >= EST_DependentNoexcept && |
41 | 320M | ESpecType <= EST_NoexceptTrue9.66M ; |
42 | 320M | } |
43 | | |
44 | 58.5k | inline bool isNoexceptExceptionSpec(ExceptionSpecificationType ESpecType) { |
45 | 58.5k | return ESpecType == EST_BasicNoexcept || ESpecType == EST_NoThrow56.2k || |
46 | 58.5k | isComputedNoexcept(ESpecType)56.2k ; |
47 | 58.5k | } |
48 | | |
49 | 21.6M | inline bool isUnresolvedExceptionSpec(ExceptionSpecificationType ESpecType) { |
50 | 21.6M | return ESpecType == EST_Unevaluated || ESpecType == EST_Uninstantiated20.9M ; |
51 | 21.6M | } |
52 | | |
53 | 0 | inline bool isExplicitThrowExceptionSpec(ExceptionSpecificationType ESpecType) { |
54 | 0 | return ESpecType == EST_Dynamic || ESpecType == EST_MSAny || |
55 | 0 | ESpecType == EST_NoexceptFalse; |
56 | 0 | } |
57 | | |
58 | | /// Possible results from evaluation of a noexcept expression. |
59 | | enum CanThrowResult { |
60 | | CT_Cannot, |
61 | | CT_Dependent, |
62 | | CT_Can |
63 | | }; |
64 | | |
65 | 121k | inline CanThrowResult mergeCanThrow(CanThrowResult CT1, CanThrowResult CT2) { |
66 | | // CanThrowResult constants are ordered so that the maximum is the correct |
67 | | // merge result. |
68 | 121k | return CT1 > CT2 ? CT120.1k : CT2101k ; |
69 | 121k | } |
70 | | |
71 | | } // end namespace clang |
72 | | |
73 | | #endif // LLVM_CLANG_BASIC_EXCEPTIONSPECIFICATIONTYPE_H |