Back to home page

EIC code displayed by LXR

 
 

    


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

0001 //===--- OperatorKinds.h - C++ Overloaded Operators -------------*- 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 an enumeration for C++ overloaded operators.
0011 ///
0012 //===----------------------------------------------------------------------===//
0013 
0014 #ifndef LLVM_CLANG_BASIC_OPERATORKINDS_H
0015 #define LLVM_CLANG_BASIC_OPERATORKINDS_H
0016 
0017 namespace clang {
0018 
0019 /// Enumeration specifying the different kinds of C++ overloaded
0020 /// operators.
0021 enum OverloadedOperatorKind : int {
0022   OO_None,                ///< Not an overloaded operator
0023 #define OVERLOADED_OPERATOR(Name,Spelling,Token,Unary,Binary,MemberOnly) \
0024   OO_##Name,
0025 #include "clang/Basic/OperatorKinds.def"
0026   NUM_OVERLOADED_OPERATORS
0027 };
0028 
0029 /// Retrieve the spelling of the given overloaded operator, without
0030 /// the preceding "operator" keyword.
0031 const char *getOperatorSpelling(OverloadedOperatorKind Operator);
0032 
0033 /// Get the other overloaded operator that the given operator can be rewritten
0034 /// into, if any such operator exists.
0035 inline OverloadedOperatorKind
0036 getRewrittenOverloadedOperator(OverloadedOperatorKind Kind) {
0037   switch (Kind) {
0038   case OO_Less:
0039   case OO_LessEqual:
0040   case OO_Greater:
0041   case OO_GreaterEqual:
0042     return OO_Spaceship;
0043 
0044   case OO_ExclaimEqual:
0045     return OO_EqualEqual;
0046 
0047   default:
0048     return OO_None;
0049   }
0050 }
0051 
0052 /// Determine if this is a compound assignment operator.
0053 inline bool isCompoundAssignmentOperator(OverloadedOperatorKind Kind) {
0054   return Kind >= OO_PlusEqual && Kind <= OO_PipeEqual;
0055 }
0056 
0057 } // end namespace clang
0058 
0059 #endif