Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:36:49

0001 //===--- ExceptionSpecificationType.h ---------------------------*- C++ -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 ///
0009 /// \file
0010 /// Defines the ExceptionSpecificationType enumeration and various
0011 /// utility functions.
0012 ///
0013 //===----------------------------------------------------------------------===//
0014 #ifndef LLVM_CLANG_BASIC_EXCEPTIONSPECIFICATIONTYPE_H
0015 #define LLVM_CLANG_BASIC_EXCEPTIONSPECIFICATIONTYPE_H
0016 
0017 namespace clang {
0018 
0019 /// The various types of exception specifications that exist in C++11.
0020 enum ExceptionSpecificationType {
0021   EST_None,             ///< no exception specification
0022   EST_DynamicNone,      ///< throw()
0023   EST_Dynamic,          ///< throw(T1, T2)
0024   EST_MSAny,            ///< Microsoft throw(...) extension
0025   EST_NoThrow,          ///< Microsoft __declspec(nothrow) extension
0026   EST_BasicNoexcept,    ///< noexcept
0027   EST_DependentNoexcept,///< noexcept(expression), value-dependent
0028   EST_NoexceptFalse,    ///< noexcept(expression), evals to 'false'
0029   EST_NoexceptTrue,     ///< noexcept(expression), evals to 'true'
0030   EST_Unevaluated,      ///< not evaluated yet, for special member function
0031   EST_Uninstantiated,   ///< not instantiated yet
0032   EST_Unparsed          ///< not parsed yet
0033 };
0034 
0035 inline bool isDynamicExceptionSpec(ExceptionSpecificationType ESpecType) {
0036   return ESpecType >= EST_DynamicNone && ESpecType <= EST_MSAny;
0037 }
0038 
0039 inline bool isComputedNoexcept(ExceptionSpecificationType ESpecType) {
0040   return ESpecType >= EST_DependentNoexcept &&
0041          ESpecType <= EST_NoexceptTrue;
0042 }
0043 
0044 inline bool isNoexceptExceptionSpec(ExceptionSpecificationType ESpecType) {
0045   return ESpecType == EST_BasicNoexcept || ESpecType == EST_NoThrow ||
0046          isComputedNoexcept(ESpecType);
0047 }
0048 
0049 inline bool isUnresolvedExceptionSpec(ExceptionSpecificationType ESpecType) {
0050   return ESpecType == EST_Unevaluated || ESpecType == EST_Uninstantiated;
0051 }
0052 
0053 inline bool isExplicitThrowExceptionSpec(ExceptionSpecificationType ESpecType) {
0054   return ESpecType == EST_Dynamic || ESpecType == EST_MSAny ||
0055          ESpecType == EST_NoexceptFalse;
0056 }
0057 
0058 /// Possible results from evaluation of a noexcept expression.
0059 enum CanThrowResult {
0060   CT_Cannot,
0061   CT_Dependent,
0062   CT_Can
0063 };
0064 
0065 inline CanThrowResult mergeCanThrow(CanThrowResult CT1, CanThrowResult CT2) {
0066   // CanThrowResult constants are ordered so that the maximum is the correct
0067   // merge result.
0068   return CT1 > CT2 ? CT1 : CT2;
0069 }
0070 
0071 } // end namespace clang
0072 
0073 #endif // LLVM_CLANG_BASIC_EXCEPTIONSPECIFICATIONTYPE_H