/Users/buildslave/jenkins/workspace/coverage/llvm-project/clang/include/clang/Basic/OperatorKinds.h
Line | Count | Source (jump to first uncovered line) |
1 | | //===--- OperatorKinds.h - C++ Overloaded Operators -------------*- 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 an enumeration for C++ overloaded operators. |
11 | | /// |
12 | | //===----------------------------------------------------------------------===// |
13 | | |
14 | | #ifndef LLVM_CLANG_BASIC_OPERATORKINDS_H |
15 | | #define LLVM_CLANG_BASIC_OPERATORKINDS_H |
16 | | |
17 | | namespace clang { |
18 | | |
19 | | /// Enumeration specifying the different kinds of C++ overloaded |
20 | | /// operators. |
21 | | enum OverloadedOperatorKind : int { |
22 | | OO_None, ///< Not an overloaded operator |
23 | | #define OVERLOADED_OPERATOR(Name,Spelling,Token,Unary,Binary,MemberOnly) \ |
24 | | OO_##Name, |
25 | | #include "clang/Basic/OperatorKinds.def" |
26 | | NUM_OVERLOADED_OPERATORS |
27 | | }; |
28 | | |
29 | | /// Retrieve the spelling of the given overloaded operator, without |
30 | | /// the preceding "operator" keyword. |
31 | | const char *getOperatorSpelling(OverloadedOperatorKind Operator); |
32 | | |
33 | | /// Get the other overloaded operator that the given operator can be rewritten |
34 | | /// into, if any such operator exists. |
35 | | inline OverloadedOperatorKind |
36 | 50.5k | getRewrittenOverloadedOperator(OverloadedOperatorKind Kind) { |
37 | 50.5k | switch (Kind) { |
38 | 3.66k | case OO_Less: |
39 | 4.61k | case OO_LessEqual: |
40 | 6.65k | case OO_Greater: |
41 | 7.53k | case OO_GreaterEqual: |
42 | 7.53k | return OO_Spaceship; |
43 | | |
44 | 6.08k | case OO_ExclaimEqual: |
45 | 6.08k | return OO_EqualEqual; |
46 | | |
47 | 36.9k | default: |
48 | 36.9k | return OO_None; |
49 | 50.5k | } |
50 | 50.5k | } |
51 | | |
52 | | /// Determine if this is a compound assignment operator. |
53 | 60.8k | inline bool isCompoundAssignmentOperator(OverloadedOperatorKind Kind) { |
54 | 60.8k | return Kind >= OO_PlusEqual && Kind <= OO_PipeEqual9.55k ; |
55 | 60.8k | } |
56 | | |
57 | | } // end namespace clang |
58 | | |
59 | | #endif |