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