Coverage Report

Created: 2022-05-14 11:35

/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.43k
const char *tok::getTokenName(TokenKind Kind) {
25
7.43k
  if (Kind < tok::NUM_TOKENS)
26
7.43k
    return TokNames[Kind];
27
0
  llvm_unreachable("unknown TokenKind");
28
0
  return nullptr;
29
7.43k
}
30
31
14.6M
const char *tok::getPunctuatorSpelling(TokenKind Kind) {
32
14.6M
  switch (Kind) {
33
9.72M
#define PUNCTUATOR(X,Y) case X: return Y;
34
0
#include "clang/Basic/TokenKinds.def"
35
4.91M
  default: break;
36
14.6M
  }
37
4.91M
  return nullptr;
38
14.6M
}
39
40
4.91M
const char *tok::getKeywordSpelling(TokenKind Kind) {
41
4.91M
  switch (Kind) {
42
613k
#define KEYWORD(X,Y) case kw_ ## X: return #X;
43
0
#include "clang/Basic/TokenKinds.def"
44
4.30M
    default: break;
45
4.91M
  }
46
4.30M
  return nullptr;
47
4.91M
}
48
49
0
const char *tok::getPPKeywordSpelling(tok::PPKeywordKind Kind) {
50
0
  switch (Kind) {
51
0
#define PPKEYWORD(x) case tok::pp_##x: return #x;
52
0
#include "clang/Basic/TokenKinds.def"
53
0
  default: break;
54
0
  }
55
0
  return nullptr;
56
0
}
57
58
7.03G
bool tok::isAnnotation(TokenKind Kind) {
59
7.03G
  switch (Kind) {
60
330M
#define ANNOTATION(X) case annot_ ## X: return true;
61
0
#include "clang/Basic/TokenKinds.def"
62
6.70G
  default:
63
6.70G
    break;
64
7.03G
  }
65
6.70G
  return false;
66
7.03G
}
67
68
4.51M
bool tok::isPragmaAnnotation(TokenKind Kind) {
69
4.51M
  switch (Kind) {
70
6
#define PRAGMA_ANNOTATION(X) case annot_ ## X: return true;
71
0
#include "clang/Basic/TokenKinds.def"
72
4.51M
  default:
73
4.51M
    break;
74
4.51M
  }
75
4.51M
  return false;
76
4.51M
}