Coverage Report

Created: 2021-01-19 06:58

/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
43.4M
                               bool CPlusPlus11) {
19
43.4M
  switch (Kind) {
20
550k
  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
550k
    if (GreaterThanIsOperator)
26
109k
      return prec::Relational;
27
441k
    return prec::Unknown;
28
29
47.4k
  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
47.4k
    if (GreaterThanIsOperator || 
!CPlusPlus112.08k
)
37
45.4k
      return prec::Shift;
38
2.07k
    return prec::Unknown;
39
40
27.9M
  default:                        return prec::Unknown;
41
10.8M
  case tok::comma:                return prec::Comma;
42
1.14M
  case tok::equal:
43
1.15M
  case tok::starequal:
44
1.15M
  case tok::slashequal:
45
1.15M
  case tok::percentequal:
46
1.21M
  case tok::plusequal:
47
1.24M
  case tok::minusequal:
48
1.24M
  case tok::lesslessequal:
49
1.24M
  case tok::greatergreaterequal:
50
1.25M
  case tok::ampequal:
51
1.26M
  case tok::caretequal:
52
1.28M
  case tok::pipeequal:            return prec::Assignment;
53
69.9k
  case tok::question:             return prec::Conditional;
54
61.7k
  case tok::pipepipe:             return prec::LogicalOr;
55
1
  case tok::caretcaret:
56
158k
  case tok::ampamp:               return prec::LogicalAnd;
57
118k
  case tok::pipe:                 return prec::InclusiveOr;
58
23.1k
  case tok::caret:                return prec::ExclusiveOr;
59
128k
  case tok::amp:                  return prec::And;
60
145k
  case tok::exclaimequal:
61
401k
  case tok::equalequal:           return prec::Equality;
62
41.5k
  case tok::lessequal:
63
304k
  case tok::less:
64
343k
  case tok::greaterequal:         return prec::Relational;
65
709
  case tok::spaceship:            return prec::Spaceship;
66
338k
  case tok::lessless:             return prec::Shift;
67
523k
  case tok::plus:
68
784k
  case tok::minus:                return prec::Additive;
69
18.6k
  case tok::percent:
70
92.2k
  case tok::slash:
71
234k
  case tok::star:                 return prec::Multiplicative;
72
18.3k
  case tok::periodstar:
73
20.5k
  case tok::arrowstar:            return prec::PointerToMember;
74
43.4M
  }
75
43.4M
}
76
77
}  // namespace clang