• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===--- ExceptionSpecificationType.h ---------------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 ///
10 /// \file
11 /// \brief Defines the ExceptionSpecificationType enumeration and various
12 /// utility functions.
13 ///
14 //===----------------------------------------------------------------------===//
15 #ifndef LLVM_CLANG_BASIC_EXCEPTIONSPECIFICATIONTYPE_H
16 #define LLVM_CLANG_BASIC_EXCEPTIONSPECIFICATIONTYPE_H
17 
18 namespace clang {
19 
20 /// \brief The various types of exception specifications that exist in C++11.
21 enum ExceptionSpecificationType {
22   EST_None,             ///< no exception specification
23   EST_DynamicNone,      ///< throw()
24   EST_Dynamic,          ///< throw(T1, T2)
25   EST_MSAny,            ///< Microsoft throw(...) extension
26   EST_BasicNoexcept,    ///< noexcept
27   EST_ComputedNoexcept, ///< noexcept(expression)
28   EST_Unevaluated,      ///< not evaluated yet, for special member function
29   EST_Uninstantiated    ///< not instantiated yet
30 };
31 
isDynamicExceptionSpec(ExceptionSpecificationType ESpecType)32 inline bool isDynamicExceptionSpec(ExceptionSpecificationType ESpecType) {
33   return ESpecType >= EST_DynamicNone && ESpecType <= EST_MSAny;
34 }
35 
isNoexceptExceptionSpec(ExceptionSpecificationType ESpecType)36 inline bool isNoexceptExceptionSpec(ExceptionSpecificationType ESpecType) {
37   return ESpecType == EST_BasicNoexcept || ESpecType == EST_ComputedNoexcept;
38 }
39 
isUnresolvedExceptionSpec(ExceptionSpecificationType ESpecType)40 inline bool isUnresolvedExceptionSpec(ExceptionSpecificationType ESpecType) {
41   return ESpecType == EST_Unevaluated || ESpecType == EST_Uninstantiated;
42 }
43 
44 /// \brief Possible results from evaluation of a noexcept expression.
45 enum CanThrowResult {
46   CT_Cannot,
47   CT_Dependent,
48   CT_Can
49 };
50 
mergeCanThrow(CanThrowResult CT1,CanThrowResult CT2)51 inline CanThrowResult mergeCanThrow(CanThrowResult CT1, CanThrowResult CT2) {
52   // CanThrowResult constants are ordered so that the maximum is the correct
53   // merge result.
54   return CT1 > CT2 ? CT1 : CT2;
55 }
56 
57 } // end namespace clang
58 
59 #endif // LLVM_CLANG_BASIC_EXCEPTIONSPECIFICATIONTYPE_H
60