Coverage Report

Created: 2020-02-15 09:57

/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
38.7M
                               bool CPlusPlus11) {
19
38.7M
  switch (Kind) {
20
531k
  case tok::greater:
21
531k
    // C++ [temp.names]p3:
22
531k
    //   [...] When parsing a template-argument-list, the first
23
531k
    //   non-nested > is taken as the ending delimiter rather than a
24
531k
    //   greater-than operator. [...]
25
531k
    if (GreaterThanIsOperator)
26
93.4k
      return prec::Relational;
27
438k
    return prec::Unknown;
28
438k
29
438k
  case tok::greatergreater:
30
47.4k
    // C++11 [temp.names]p3:
31
47.4k
    //
32
47.4k
    //   [...] Similarly, the first non-nested >> is treated as two
33
47.4k
    //   consecutive but distinct > tokens, the first of which is
34
47.4k
    //   taken as the end of the template-argument-list and completes
35
47.4k
    //   the template-id. [...]
36
47.4k
    if (GreaterThanIsOperator || 
!CPlusPlus111.90k
)
37
45.5k
      return prec::Shift;
38
1.90k
    return prec::Unknown;
39
1.90k
40
24.3M
  default:                        return prec::Unknown;
41
10.1M
  case tok::comma:                return prec::Comma;
42
1.10M
  case tok::equal:
43
1.10M
  case tok::starequal:
44
1.10M
  case tok::slashequal:
45
1.10M
  case tok::percentequal:
46
1.10M
  case tok::plusequal:
47
1.10M
  case tok::minusequal:
48
1.10M
  case tok::lesslessequal:
49
1.10M
  case tok::greatergreaterequal:
50
1.10M
  case tok::ampequal:
51
1.10M
  case tok::caretequal:
52
1.10M
  case tok::pipeequal:            return prec::Assignment;
53
1.10M
  
case tok::question: return prec::Conditional62.4k
;
54
1.10M
  
case tok::pipepipe: return prec::LogicalOr65.1k
;
55
1.10M
  case tok::caretcaret:
56
172k
  case tok::ampamp:               return prec::LogicalAnd;
57
172k
  
case tok::pipe: return prec::InclusiveOr115k
;
58
172k
  
case tok::caret: return prec::ExclusiveOr19.9k
;
59
172k
  
case tok::amp: return prec::And120k
;
60
393k
  case tok::exclaimequal:
61
393k
  case tok::equalequal:           return prec::Equality;
62
393k
  case tok::lessequal:
63
304k
  case tok::less:
64
304k
  case tok::greaterequal:         return prec::Relational;
65
304k
  
case tok::spaceship: return prec::Spaceship703
;
66
325k
  case tok::lessless:             return prec::Shift;
67
728k
  case tok::plus:
68
728k
  case tok::minus:                return prec::Additive;
69
728k
  case tok::percent:
70
209k
  case tok::slash:
71
209k
  case tok::star:                 return prec::Multiplicative;
72
209k
  case tok::periodstar:
73
24.8k
  case tok::arrowstar:            return prec::PointerToMember;
74
38.7M
  }
75
38.7M
}
76
77
}  // namespace clang