Coverage Report

Created: 2021-06-15 06:44

/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.12k
const char *tok::getTokenName(TokenKind Kind) {
25
7.12k
  if (Kind < tok::NUM_TOKENS)
26
7.12k
    return TokNames[Kind];
27
7.12k
  
llvm_unreachable0
("unknown TokenKind");
28
0
  return nullptr;
29
7.12k
}
30
31
14.7M
const char *tok::getPunctuatorSpelling(TokenKind Kind) {
32
14.7M
  switch (Kind) {
33
9.77M
#define PUNCTUATOR(X,Y) case X: return Y;
34
0
#include "clang/Basic/TokenKinds.def"
35
4.95M
  default: break;
36
14.7M
  }
37
4.95M
  return nullptr;
38
14.7M
}
39
40
4.95M
const char *tok::getKeywordSpelling(TokenKind Kind) {
41
4.95M
  switch (Kind) {
42
620k
#define KEYWORD(X,Y) case kw_ ## X: return #X;
43
0
#include "clang/Basic/TokenKinds.def"
44
4.33M
    default: break;
45
4.95M
  }
46
4.33M
  return nullptr;
47
4.95M
}
48
49
8.07G
bool tok::isAnnotation(TokenKind Kind) {
50
8.07G
  switch (Kind) {
51
380M
#define ANNOTATION(X) case annot_ ## X: return true;
52
0
#include "clang/Basic/TokenKinds.def"
53
7.69G
  default:
54
7.69G
    break;
55
8.07G
  }
56
7.69G
  return false;
57
8.07G
}
58
59
4.39M
bool tok::isPragmaAnnotation(TokenKind Kind) {
60
4.39M
  switch (Kind) {
61
6
#define PRAGMA_ANNOTATION(X) case annot_ ## X: return true;
62
0
#include "clang/Basic/TokenKinds.def"
63
4.39M
  default:
64
4.39M
    break;
65
4.39M
  }
66
4.39M
  return false;
67
4.39M
}