Coverage Report

Created: 2018-09-25 23:22

/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
//                     The LLVM Compiler Infrastructure
4
//
5
// This file is distributed under the University of Illinois Open Source
6
// License. See LICENSE.TXT for details.
7
//
8
//===----------------------------------------------------------------------===//
9
///
10
/// \file
11
/// Defines the clang::TokenKind enum and support functions.
12
///
13
//===----------------------------------------------------------------------===//
14
15
#ifndef LLVM_CLANG_BASIC_TOKENKINDS_H
16
#define LLVM_CLANG_BASIC_TOKENKINDS_H
17
18
#include "llvm/Support/Compiler.h"
19
20
namespace clang {
21
22
namespace tok {
23
24
/// Provides a simple uniform namespace for tokens from all C languages.
25
enum TokenKind : unsigned short {
26
#define TOK(X) X,
27
#include "clang/Basic/TokenKinds.def"
28
  NUM_TOKENS
29
};
30
31
/// Provides a namespace for preprocessor keywords which start with a
32
/// '#' at the beginning of the line.
33
enum PPKeywordKind {
34
#define PPKEYWORD(X) pp_##X,
35
#include "clang/Basic/TokenKinds.def"
36
  NUM_PP_KEYWORDS
37
};
38
39
/// Provides a namespace for Objective-C keywords which start with
40
/// an '@'.
41
enum ObjCKeywordKind {
42
#define OBJC1_AT_KEYWORD(X) objc_##X,
43
#define OBJC2_AT_KEYWORD(X) objc_##X,
44
#include "clang/Basic/TokenKinds.def"
45
  NUM_OBJC_KEYWORDS
46
};
47
48
/// Defines the possible values of an on-off-switch (C99 6.10.6p2).
49
enum OnOffSwitch {
50
  OOS_ON, OOS_OFF, OOS_DEFAULT
51
};
52
53
/// Determines the name of a token as used within the front end.
54
///
55
/// The name of a token will be an internal name (such as "l_square")
56
/// and should not be used as part of diagnostic messages.
57
const char *getTokenName(TokenKind Kind) LLVM_READNONE;
58
59
/// Determines the spelling of simple punctuation tokens like
60
/// '!' or '%', and returns NULL for literal and annotation tokens.
61
///
62
/// This routine only retrieves the "simple" spelling of the token,
63
/// and will not produce any alternative spellings (e.g., a
64
/// digraph). For the actual spelling of a given Token, use
65
/// Preprocessor::getSpelling().
66
const char *getPunctuatorSpelling(TokenKind Kind) LLVM_READNONE;
67
68
/// Determines the spelling of simple keyword and contextual keyword
69
/// tokens like 'int' and 'dynamic_cast'. Returns NULL for other token kinds.
70
const char *getKeywordSpelling(TokenKind Kind) LLVM_READNONE;
71
72
/// Return true if this is a raw identifier or an identifier kind.
73
1.96M
inline bool isAnyIdentifier(TokenKind K) {
74
1.96M
  return (K == tok::identifier) || 
(K == tok::raw_identifier)499k
;
75
1.96M
}
76
77
/// Return true if this is a C or C++ string-literal (or
78
/// C++11 user-defined-string-literal) token.
79
614M
inline bool isStringLiteral(TokenKind K) {
80
614M
  return K == tok::string_literal || 
K == tok::wide_string_literal596M
||
81
614M
         
K == tok::utf8_string_literal596M
||
K == tok::utf16_string_literal596M
||
82
614M
         
K == tok::utf32_string_literal596M
;
83
614M
}
84
85
/// Return true if this is a "literal" kind, like a numeric
86
/// constant, string, etc.
87
597M
inline bool isLiteral(TokenKind K) {
88
597M
  return K == tok::numeric_constant || 
K == tok::char_constant557M
||
89
597M
         
K == tok::wide_char_constant557M
||
K == tok::utf8_char_constant557M
||
90
597M
         
K == tok::utf16_char_constant557M
||
K == tok::utf32_char_constant557M
||
91
597M
         
isStringLiteral(K)557M
||
K == tok::angle_string_literal541M
;
92
597M
}
93
94
/// Return true if this is any of tok::annot_* kinds.
95
201M
inline bool isAnnotation(TokenKind K) {
96
201M
#define ANNOTATION(NAME) \
97
6.02G
  if (K == tok::annot_##NAME) \
98
6.02G
    
return true633k
;
99
5.82G
#include 
"clang/Basic/TokenKinds.def"201M
100
5.82G
  
return false200M
;
101
5.82G
}
102
103
}  // end namespace tok
104
}  // end namespace clang
105
106
#endif