Coverage Report

Created: 2024-01-17 10:31

/src/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
0
const char *tok::getTokenName(TokenKind Kind) {
25
0
  if (Kind < tok::NUM_TOKENS)
26
0
    return TokNames[Kind];
27
0
  llvm_unreachable("unknown TokenKind");
28
0
  return nullptr;
29
0
}
30
31
4.67k
const char *tok::getPunctuatorSpelling(TokenKind Kind) {
32
4.67k
  switch (Kind) {
33
4.67k
#define PUNCTUATOR(X,Y) case X: return Y;
34
0
#include "clang/Basic/TokenKinds.def"
35
0
  default: break;
36
4.67k
  }
37
0
  return nullptr;
38
4.67k
}
39
40
0
const char *tok::getKeywordSpelling(TokenKind Kind) {
41
0
  switch (Kind) {
42
0
#define KEYWORD(X,Y) case kw_ ## X: return #X;
43
0
#include "clang/Basic/TokenKinds.def"
44
0
    default: break;
45
0
  }
46
0
  return nullptr;
47
0
}
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
608M
bool tok::isAnnotation(TokenKind Kind) {
59
608M
  switch (Kind) {
60
553
#define ANNOTATION(X) case annot_ ## X: return true;
61
0
#include "clang/Basic/TokenKinds.def"
62
608M
  default:
63
608M
    break;
64
608M
  }
65
608M
  return false;
66
608M
}
67
68
0
bool tok::isPragmaAnnotation(TokenKind Kind) {
69
0
  switch (Kind) {
70
0
#define PRAGMA_ANNOTATION(X) case annot_ ## X: return true;
71
0
#include "clang/Basic/TokenKinds.def"
72
0
  default:
73
0
    break;
74
0
  }
75
0
  return false;
76
0
}