Coverage Report

Created: 2019-07-24 05:18

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/tools/clang/lib/Basic/OperatorPrecedence.cpp
Line
Count
Source
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
53.1M
                               bool CPlusPlus11) {
19
53.1M
  switch (Kind) {
20
53.1M
  case tok::greater:
21
680k
    // C++ [temp.names]p3:
22
680k
    //   [...] When parsing a template-argument-list, the first
23
680k
    //   non-nested > is taken as the ending delimiter rather than a
24
680k
    //   greater-than operator. [...]
25
680k
    if (GreaterThanIsOperator)
26
195k
      return prec::Relational;
27
484k
    return prec::Unknown;
28
484k
29
484k
  case tok::greatergreater:
30
114k
    // C++11 [temp.names]p3:
31
114k
    //
32
114k
    //   [...] Similarly, the first non-nested >> is treated as two
33
114k
    //   consecutive but distinct > tokens, the first of which is
34
114k
    //   taken as the end of the template-argument-list and completes
35
114k
    //   the template-id. [...]
36
114k
    if (GreaterThanIsOperator || 
!CPlusPlus111.84k
)
37
113k
      return prec::Shift;
38
1.83k
    return prec::Unknown;
39
1.83k
40
37.2M
  default:                        return prec::Unknown;
41
8.80M
  case tok::comma:                return prec::Comma;
42
2.17M
  case tok::equal:
43
2.17M
  case tok::starequal:
44
2.17M
  case tok::slashequal:
45
2.17M
  case tok::percentequal:
46
2.17M
  case tok::plusequal:
47
2.17M
  case tok::minusequal:
48
2.17M
  case tok::lesslessequal:
49
2.17M
  case tok::greatergreaterequal:
50
2.17M
  case tok::ampequal:
51
2.17M
  case tok::caretequal:
52
2.17M
  case tok::pipeequal:            return prec::Assignment;
53
2.17M
  
case tok::question: return prec::Conditional139k
;
54
2.17M
  
case tok::pipepipe: return prec::LogicalOr133k
;
55
2.17M
  case tok::caretcaret:
56
292k
  case tok::ampamp:               return prec::LogicalAnd;
57
292k
  
case tok::pipe: return prec::InclusiveOr91.8k
;
58
292k
  
case tok::caret: return prec::ExclusiveOr29.1k
;
59
292k
  
case tok::amp: return prec::And189k
;
60
808k
  case tok::exclaimequal:
61
808k
  case tok::equalequal:           return prec::Equality;
62
808k
  case tok::lessequal:
63
546k
  case tok::less:
64
546k
  case tok::greaterequal:         return prec::Relational;
65
546k
  
case tok::spaceship: return prec::Spaceship446
;
66
546k
  
case tok::lessless: return prec::Shift218k
;
67
1.09M
  case tok::plus:
68
1.09M
  case tok::minus:                return prec::Additive;
69
1.09M
  case tok::percent:
70
557k
  case tok::slash:
71
557k
  case tok::star:                 return prec::Multiplicative;
72
557k
  case tok::periodstar:
73
27.0k
  case tok::arrowstar:            return prec::PointerToMember;
74
53.1M
  }
75
53.1M
}
76
77
}  // namespace clang