Home | History | Annotate | Download | only in Basic
      1 //===--- OperatorKinds.def - C++ Overloaded Operator Database ---*- 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 // This file defines the OverloadedOperator database, which includes
     11 // all of the overloadable C++ operators.
     12 //
     13 //===----------------------------------------------------------------------===//
     14 //
     15 /// @file OperatorKinds.def
     16 ///
     17 /// In this file, each of the overloadable C++ operators is enumerated
     18 /// with either the OVERLOADED_OPERATOR or OVERLOADED_OPERATOR_MULTI
     19 /// macro, each of which can be specified by the code including this
     20 /// file. OVERLOADED_OPERATOR is used for single-token operators
     21 /// (e.g., "+"), and has six arguments:
     22 ///
     23 /// Name: The name of the token. OO_Name will be the name of the
     24 /// corresponding enumerator in OverloadedOperatorKind in
     25 /// OperatorKinds.h.
     26 ///
     27 /// Spelling: A string that provides a canonical spelling for the
     28 /// operator, e.g., "operator+".
     29 ///
     30 /// Token: The name of the token that specifies the operator, e.g.,
     31 /// "plus" for operator+ or "greatergreaterequal" for
     32 /// "operator>>=". With a "kw_" prefix, the token name can be used as
     33 /// an enumerator into the TokenKind enumeration.
     34 ///
     35 /// Unary: True if the operator can be declared as a unary operator.
     36 ///
     37 /// Binary: True if the operator can be declared as a binary
     38 /// operator. Note that some operators (e.g., "operator+" and
     39 /// "operator*") can be both unary and binary.
     40 ///
     41 /// MemberOnly: True if this operator can only be declared as a
     42 /// non-static member function. False if the operator can be both a
     43 /// non-member function and a non-static member function.
     44 ///
     45 /// OVERLOADED_OPERATOR_MULTI is used to enumerate the multi-token
     46 /// overloaded operator names, e.g., "operator delete []". The macro
     47 /// has all of the parameters of OVERLOADED_OPERATOR except Token,
     48 /// which is omitted.
     49 
     50 #ifndef OVERLOADED_OPERATOR
     51 #  define OVERLOADED_OPERATOR(Name,Spelling,Token,Unary,Binary,MemberOnly)
     52 #endif
     53 
     54 #ifndef OVERLOADED_OPERATOR_MULTI
     55 #  define OVERLOADED_OPERATOR_MULTI(Name,Spelling,Unary,Binary,MemberOnly) \
     56     OVERLOADED_OPERATOR(Name,Spelling,unknown,Unary,Binary,MemberOnly)
     57 #endif
     58 
     59 OVERLOADED_OPERATOR_MULTI(New            , "new"                      , true , true , false)
     60 OVERLOADED_OPERATOR_MULTI(Delete         , "delete"                   , true , true , false)
     61 OVERLOADED_OPERATOR_MULTI(Array_New      , "new[]"                    , true , true , false)
     62 OVERLOADED_OPERATOR_MULTI(Array_Delete   , "delete[]"                 , true , true , false)
     63 OVERLOADED_OPERATOR(Plus                 , "+"   , plus               , true , true , false)
     64 OVERLOADED_OPERATOR(Minus                , "-"   , minus              , true , true , false)
     65 OVERLOADED_OPERATOR(Star                 , "*"   , star               , true , true , false)
     66 OVERLOADED_OPERATOR(Slash                , "/"   , slash              , false, true , false)
     67 OVERLOADED_OPERATOR(Percent              , "%"   , percent            , false, true , false)
     68 OVERLOADED_OPERATOR(Caret                , "^"   , caret              , false, true , false)
     69 OVERLOADED_OPERATOR(Amp                  , "&"   , amp                , true , true , false)
     70 OVERLOADED_OPERATOR(Pipe                 , "|"   , pipe               , false, true , false)
     71 OVERLOADED_OPERATOR(Tilde                , "~"   , tilde              , true , false, false)
     72 OVERLOADED_OPERATOR(Exclaim              , "!"   , exclaim            , true , false, false)
     73 OVERLOADED_OPERATOR(Equal                , "="   , equal              , false, true , true)
     74 OVERLOADED_OPERATOR(Less                 , "<"   , less               , false, true , false)
     75 OVERLOADED_OPERATOR(Greater              , ">"   , greater            , false, true , false)
     76 OVERLOADED_OPERATOR(PlusEqual            , "+="  , plusequal          , false, true , false)
     77 OVERLOADED_OPERATOR(MinusEqual           , "-="  , minusequal         , false, true , false)
     78 OVERLOADED_OPERATOR(StarEqual            , "*="  , starequal          , false, true , false)
     79 OVERLOADED_OPERATOR(SlashEqual           , "/="  , slashequal         , false, true , false)
     80 OVERLOADED_OPERATOR(PercentEqual         , "%="  , percentequal       , false, true , false)
     81 OVERLOADED_OPERATOR(CaretEqual           , "^="  , caretequal         , false, true , false)
     82 OVERLOADED_OPERATOR(AmpEqual             , "&="  , ampequal           , false, true , false)
     83 OVERLOADED_OPERATOR(PipeEqual            , "|="  , pipeequal          , false, true , false)
     84 OVERLOADED_OPERATOR(LessLess             , "<<"  , lessless           , false, true , false)
     85 OVERLOADED_OPERATOR(GreaterGreater       , ">>"  , greatergreater     , false, true , false)
     86 OVERLOADED_OPERATOR(LessLessEqual        , "<<=" , lesslessequal      , false, true , false)
     87 OVERLOADED_OPERATOR(GreaterGreaterEqual  , ">>=" , greatergreaterequal, false, true , false)
     88 OVERLOADED_OPERATOR(EqualEqual           , "=="  , equalequal         , false, true , false)
     89 OVERLOADED_OPERATOR(ExclaimEqual         , "!="  , exclaimequal       , false, true , false)
     90 OVERLOADED_OPERATOR(LessEqual            , "<="  , lessequal          , false, true , false)
     91 OVERLOADED_OPERATOR(GreaterEqual         , ">="  , greaterequal       , false, true , false)
     92 OVERLOADED_OPERATOR(AmpAmp               , "&&"  , ampamp             , false, true , false)
     93 OVERLOADED_OPERATOR(PipePipe             , "||"  , pipepipe           , false, true , false)
     94 OVERLOADED_OPERATOR(PlusPlus             , "++"  , plusplus           , true , true , false)
     95 OVERLOADED_OPERATOR(MinusMinus           , "--"  , minusminus         , true , true , false)
     96 OVERLOADED_OPERATOR(Comma                , ","   , comma              , false, true , false)
     97 OVERLOADED_OPERATOR(ArrowStar            , "->*" , arrowstar          , false, true , false)
     98 OVERLOADED_OPERATOR(Arrow                , "->"  , arrow              , true , false, true)
     99 OVERLOADED_OPERATOR_MULTI(Call           , "()"                       , true , true , true)
    100 OVERLOADED_OPERATOR_MULTI(Subscript      , "[]"                       , false, true , true)
    101 // ?: can *not* be overloaded, but we need the overload
    102 // resolution machinery for it.
    103 OVERLOADED_OPERATOR_MULTI(Conditional    , "?"                        , false, true , false)
    104 OVERLOADED_OPERATOR(Coawait              , "co_await", kw_co_await    , true , false, false)
    105 
    106 #undef OVERLOADED_OPERATOR_MULTI
    107 #undef OVERLOADED_OPERATOR
    108