Coverage Report

Created: 2020-11-24 06:42

/Users/buildslave/jenkins/workspace/coverage/llvm-project/clang/lib/Basic/TokenKinds.cpp
Line
Count
Source (jump to first uncovered line)
1
//===--- TokenKinds.cpp - Token Kinds Support -----------------------------===//
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
//  This file implements the TokenKind enum and support functions.
10
//
11
//===----------------------------------------------------------------------===//
12
13
#include "clang/Basic/TokenKinds.h"
14
#include "llvm/Support/ErrorHandling.h"
15
using namespace clang;
16
17
static const char * const TokNames[] = {
18
#define TOK(X) #X,
19
#define KEYWORD(X,Y) #X,
20
#include "clang/Basic/TokenKinds.def"
21
  nullptr
22
};
23
24
7.11k
const char *tok::getTokenName(TokenKind Kind) {
25
7.11k
  if (Kind < tok::NUM_TOKENS)
26
7.11k
    return TokNames[Kind];
27
0
  llvm_unreachable("unknown TokenKind");
28
0
  return nullptr;
29
0
}
30
31
15.2M
const char *tok::getPunctuatorSpelling(TokenKind Kind) {
32
15.2M
  switch (Kind) {
33
10.1M
#define PUNCTUATOR(X,Y) case X: return Y;
34
0
#include "clang/Basic/TokenKinds.def"
35
5.11M
  default: break;
36
5.11M
  }
37
5.11M
  return nullptr;
38
5.11M
}
39
40
5.11M
const char *tok::getKeywordSpelling(TokenKind Kind) {
41
5.11M
  switch (Kind) {
42
639k
#define KEYWORD(X,Y) case kw_ ## X: return #X;
43
0
#include "clang/Basic/TokenKinds.def"
44
4.47M
    default: break;
45
4.47M
  }
46
4.47M
  return nullptr;
47
4.47M
}
48
49
8.50G
bool tok::isAnnotation(TokenKind Kind) {
50
8.50G
  switch (Kind) {
51
230M
#define ANNOTATION(X) case annot_ ## X: return true;
52
0
#include "clang/Basic/TokenKinds.def"
53
8.27G
  default:
54
8.27G
    break;
55
8.27G
  }
56
8.27G
  return false;
57
8.27G
}
58
59
4.87M
bool tok::isPragmaAnnotation(TokenKind Kind) {
60
4.87M
  switch (Kind) {
61
6
#define PRAGMA_ANNOTATION(X) case annot_ ## X: return true;
62
0
#include "clang/Basic/TokenKinds.def"
63
4.87M
  default:
64
4.87M
    break;
65
4.87M
  }
66
4.87M
  return false;
67
4.87M
}