Coverage Report

Created: 2023-11-11 10:31

/Users/buildslave/jenkins/workspace/coverage/llvm-project/clang/lib/Basic/OperatorPrecedence.cpp
Line
Count
Source (jump to first uncovered line)
1
//===--- OperatorPrecedence.cpp ---------------------------------*- 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 and computes precedence levels for binary/ternary operators.
11
///
12
//===----------------------------------------------------------------------===//
13
#include "clang/Basic/OperatorPrecedence.h"
14
15
namespace clang {
16
17
prec::Level getBinOpPrecedence(tok::TokenKind Kind, bool GreaterThanIsOperator,
18
63.8M
                               bool CPlusPlus11) {
19
63.8M
  switch (Kind) {
20
884k
  case tok::greater:
21
    // C++ [temp.names]p3:
22
    //   [...] When parsing a template-argument-list, the first
23
    //   non-nested > is taken as the ending delimiter rather than a
24
    //   greater-than operator. [...]
25
884k
    if (GreaterThanIsOperator)
26
186k
      return prec::Relational;
27
698k
    return prec::Unknown;
28
29
61.6k
  case tok::greatergreater:
30
    // C++11 [temp.names]p3:
31
    //
32
    //   [...] Similarly, the first non-nested >> is treated as two
33
    //   consecutive but distinct > tokens, the first of which is
34
    //   taken as the end of the template-argument-list and completes
35
    //   the template-id. [...]
36
61.6k
    if (GreaterThanIsOperator || 
!CPlusPlus114.20k
)
37
57.4k
      return prec::Shift;
38
4.20k
    return prec::Unknown;
39
40
43.3M
  default:                        return prec::Unknown;
41
13.5M
  case tok::comma:                return prec::Comma;
42
1.96M
  case tok::equal:
43
1.97M
  case tok::starequal:
44
1.98M
  case tok::slashequal:
45
1.98M
  case tok::percentequal:
46
2.06M
  case tok::plusequal:
47
2.09M
  case tok::minusequal:
48
2.09M
  case tok::lesslessequal:
49
2.10M
  case tok::greatergreaterequal:
50
2.12M
  case tok::ampequal:
51
2.13M
  case tok::caretequal:
52
2.18M
  case tok::pipeequal:            return prec::Assignment;
53
94.9k
  case tok::question:             return prec::Conditional;
54
106k
  case tok::pipepipe:             return prec::LogicalOr;
55
2
  case tok::caretcaret:
56
339k
  case tok::ampamp:               return prec::LogicalAnd;
57
118k
  case tok::pipe:                 return prec::InclusiveOr;
58
26.3k
  case tok::caret:                return prec::ExclusiveOr;
59
149k
  case tok::amp:                  return prec::And;
60
264k
  case tok::exclaimequal:
61
701k
  case tok::equalequal:           return prec::Equality;
62
64.2k
  case tok::lessequal:
63
495k
  case tok::less:
64
560k
  case tok::greaterequal:         return prec::Relational;
65
1.40k
  case tok::spaceship:            return prec::Spaceship;
66
302k
  case tok::lessless:             return prec::Shift;
67
670k
  case tok::plus:
68
1.06M
  case tok::minus:                return prec::Additive;
69
25.9k
  case tok::percent:
70
135k
  case tok::slash:
71
317k
  case tok::star:                 return prec::Multiplicative;
72
11.8k
  case tok::periodstar:
73
13.8k
  case tok::arrowstar:            return prec::PointerToMember;
74
63.8M
  }
75
63.8M
}
76
77
}  // namespace clang