Coverage Report

Created: 2019-07-24 05:18

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/tools/clang/include/clang/Basic/TokenKinds.h
Line
Count
Source
1
//===--- TokenKinds.h - Enum values for C Token Kinds -----------*- C++ -*-===//
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
/// \file
10
/// Defines the clang::TokenKind enum and support functions.
11
///
12
//===----------------------------------------------------------------------===//
13
14
#ifndef LLVM_CLANG_BASIC_TOKENKINDS_H
15
#define LLVM_CLANG_BASIC_TOKENKINDS_H
16
17
#include "llvm/Support/Compiler.h"
18
19
namespace clang {
20
21
namespace tok {
22
23
/// Provides a simple uniform namespace for tokens from all C languages.
24
enum TokenKind : unsigned short {
25
#define TOK(X) X,
26
#include "clang/Basic/TokenKinds.def"
27
  NUM_TOKENS
28
};
29
30
/// Provides a namespace for preprocessor keywords which start with a
31
/// '#' at the beginning of the line.
32
enum PPKeywordKind {
33
#define PPKEYWORD(X) pp_##X,
34
#include "clang/Basic/TokenKinds.def"
35
  NUM_PP_KEYWORDS
36
};
37
38
/// Provides a namespace for Objective-C keywords which start with
39
/// an '@'.
40
enum ObjCKeywordKind {
41
#define OBJC_AT_KEYWORD(X) objc_##X,
42
#include "clang/Basic/TokenKinds.def"
43
  NUM_OBJC_KEYWORDS
44
};
45
46
/// Defines the possible values of an on-off-switch (C99 6.10.6p2).
47
enum OnOffSwitch {
48
  OOS_ON, OOS_OFF, OOS_DEFAULT
49
};
50
51
/// Determines the name of a token as used within the front end.
52
///
53
/// The name of a token will be an internal name (such as "l_square")
54
/// and should not be used as part of diagnostic messages.
55
const char *getTokenName(TokenKind Kind) LLVM_READNONE;
56
57
/// Determines the spelling of simple punctuation tokens like
58
/// '!' or '%', and returns NULL for literal and annotation tokens.
59
///
60
/// This routine only retrieves the "simple" spelling of the token,
61
/// and will not produce any alternative spellings (e.g., a
62
/// digraph). For the actual spelling of a given Token, use
63
/// Preprocessor::getSpelling().
64
const char *getPunctuatorSpelling(TokenKind Kind) LLVM_READNONE;
65
66
/// Determines the spelling of simple keyword and contextual keyword
67
/// tokens like 'int' and 'dynamic_cast'. Returns NULL for other token kinds.
68
const char *getKeywordSpelling(TokenKind Kind) LLVM_READNONE;
69
70
/// Return true if this is a raw identifier or an identifier kind.
71
2.07M
inline bool isAnyIdentifier(TokenKind K) {
72
2.07M
  return (K == tok::identifier) || 
(K == tok::raw_identifier)497k
;
73
2.07M
}
74
75
/// Return true if this is a C or C++ string-literal (or
76
/// C++11 user-defined-string-literal) token.
77
667M
inline bool isStringLiteral(TokenKind K) {
78
667M
  return K == tok::string_literal || 
K == tok::wide_string_literal649M
||
79
667M
         
K == tok::utf8_string_literal649M
||
K == tok::utf16_string_literal649M
||
80
667M
         
K == tok::utf32_string_literal649M
;
81
667M
}
82
83
/// Return true if this is a "literal" kind, like a numeric
84
/// constant, string, etc.
85
649M
inline bool isLiteral(TokenKind K) {
86
649M
  return K == tok::numeric_constant || 
K == tok::char_constant606M
||
87
649M
         
K == tok::wide_char_constant605M
||
K == tok::utf8_char_constant605M
||
88
649M
         
K == tok::utf16_char_constant605M
||
K == tok::utf32_char_constant605M
||
89
649M
         
isStringLiteral(K)605M
||
K == tok::header_name589M
;
90
649M
}
91
92
/// Return true if this is any of tok::annot_* kinds.
93
220M
inline bool isAnnotation(TokenKind K) {
94
220M
#define ANNOTATION(NAME) \
95
6.81G
  if (K == tok::annot_##NAME) \
96
6.81G
    
return true654k
;
97
6.59G
#include 
"clang/Basic/TokenKinds.def"220M
98
6.59G
  
return false219M
;
99
6.59G
}
100
101
}  // end namespace tok
102
}  // end namespace clang
103
104
#endif