clang  6.0.0svn
Classes | Namespaces | Macros | Enumerations | Functions
IdentifierTable.cpp File Reference
#include "clang/Basic/CharInfo.h"
#include "clang/Basic/IdentifierTable.h"
#include "clang/Basic/LangOptions.h"
#include "clang/Basic/OperatorKinds.h"
#include "clang/Basic/Specifiers.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/FoldingSet.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/raw_ostream.h"
#include <cstdio>
#include "clang/Basic/TokenKinds.def"
#include "clang/Basic/OperatorKinds.def"
Include dependency graph for IdentifierTable.cpp:

Go to the source code of this file.

Classes

class  clang::MultiKeywordSelector
 MultiKeywordSelector - One of these variable length records is kept for each selector containing more than one keyword. More...
 

Namespaces

 clang
 Dataflow Directional Tag Classes.
 

Macros

#define KEYWORD(NAME, FLAGS)
 
#define ALIAS(NAME, TOK, FLAGS)
 
#define CXX_KEYWORD_OPERATOR(NAME, ALIAS)
 
#define OBJC1_AT_KEYWORD(NAME)
 
#define OBJC2_AT_KEYWORD(NAME)
 
#define TESTING_KEYWORD(NAME, FLAGS)
 
#define KEYWORD(NAME, FLAGS)   case tok::kw_##NAME: return getKeywordStatus(LangOpts, FLAGS);
 
#define HASH(LEN, FIRST, THIRD)   (LEN << 5) + (((FIRST-'a') + (THIRD-'a')) & 31)
 
#define CASE(LEN, FIRST, THIRD, NAME)
 
#define OVERLOADED_OPERATOR(Name, Spelling, Token, Unary, Binary, MemberOnly)   case OO_##Name: return Spelling;
 

Enumerations

enum  
 
enum  KeywordStatus
 How a keyword is treated in the selected standard. More...
 

Functions

static KeywordStatus getKeywordStatus (const LangOptions &LangOpts, unsigned Flags)
 Translates flags as specified in TokenKinds.def into keyword status in the given language standard. More...
 
static void AddKeyword (StringRef Keyword, tok::TokenKind TokenCode, unsigned Flags, const LangOptions &LangOpts, IdentifierTable &Table)
 AddKeyword - This method is used to associate a token ID with specific identifiers because they are language keywords. More...
 
static void AddCXXOperatorKeyword (StringRef Keyword, tok::TokenKind TokenCode, IdentifierTable &Table)
 AddCXXOperatorKeyword - Register a C++ operator keyword alternative representations. More...
 
static void AddObjCKeyword (StringRef Name, tok::ObjCKeywordKind ObjCID, IdentifierTable &Table)
 AddObjCKeyword - Register an Objective-C @keyword like "class" "selector" or "property". More...
 
static KeywordStatus getTokenKwStatus (const LangOptions &LangOpts, tok::TokenKind K)
 Checks if the specified token kind represents a keyword in the specified language. More...
 
static bool startsWithWord (StringRef name, StringRef word)
 Interpreting the given string using the normal CamelCase conventions, determine whether the given string starts with the given "word", which is assumed to end in a lowercase letter. More...
 
static SelectorTableImpl & getSelectorTableImpl (void *P)
 

Macro Definition Documentation

◆ ALIAS

#define ALIAS (   NAME,
  TOK,
  FLAGS 
)
Value:
AddKeyword(StringRef(NAME), tok::kw_ ## TOK, \
FLAGS, LangOpts, *this);
static void AddKeyword(StringRef Keyword, tok::TokenKind TokenCode, unsigned Flags, const LangOptions &LangOpts, IdentifierTable &Table)
AddKeyword - This method is used to associate a token ID with specific identifiers because they are l...
#define TOK(X)
Definition: TokenKinds.h:26

◆ CASE

#define CASE (   LEN,
  FIRST,
  THIRD,
  NAME 
)
Value:
case HASH(LEN, FIRST, THIRD): \
return memcmp(Name, #NAME, LEN) ? tok::pp_not_keyword : tok::pp_ ## NAME
return(__x >> __y)|(__x<<(32 - __y))
#define HASH(LEN, FIRST, THIRD)

◆ CXX_KEYWORD_OPERATOR

#define CXX_KEYWORD_OPERATOR (   NAME,
  ALIAS 
)
Value:
if (LangOpts.CXXOperatorNames) \
AddCXXOperatorKeyword(StringRef(#NAME), tok::ALIAS, *this);
#define ALIAS(NAME, TOK, FLAGS)

◆ HASH

#define HASH (   LEN,
  FIRST,
  THIRD 
)    (LEN << 5) + (((FIRST-'a') + (THIRD-'a')) & 31)

◆ KEYWORD [1/2]

#define KEYWORD (   NAME,
  FLAGS 
)
Value:
AddKeyword(StringRef(#NAME), tok::kw_ ## NAME, \
FLAGS, LangOpts, *this);
static void AddKeyword(StringRef Keyword, tok::TokenKind TokenCode, unsigned Flags, const LangOptions &LangOpts, IdentifierTable &Table)
AddKeyword - This method is used to associate a token ID with specific identifiers because they are l...

◆ KEYWORD [2/2]

#define KEYWORD (   NAME,
  FLAGS 
)    case tok::kw_##NAME: return getKeywordStatus(LangOpts, FLAGS);

◆ OBJC1_AT_KEYWORD

#define OBJC1_AT_KEYWORD (   NAME)
Value:
if (LangOpts.ObjC1) \
AddObjCKeyword(StringRef(#NAME), tok::objc_##NAME, *this);

◆ OBJC2_AT_KEYWORD

#define OBJC2_AT_KEYWORD (   NAME)
Value:
if (LangOpts.ObjC2) \
AddObjCKeyword(StringRef(#NAME), tok::objc_##NAME, *this);

◆ OVERLOADED_OPERATOR

#define OVERLOADED_OPERATOR (   Name,
  Spelling,
  Token,
  Unary,
  Binary,
  MemberOnly 
)    case OO_##Name: return Spelling;

◆ TESTING_KEYWORD

#define TESTING_KEYWORD (   NAME,
  FLAGS 
)

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

Definition at line 95 of file IdentifierTable.cpp.

◆ KeywordStatus

How a keyword is treated in the selected standard.

Definition at line 124 of file IdentifierTable.cpp.

Function Documentation

◆ AddCXXOperatorKeyword()

static void AddCXXOperatorKeyword ( StringRef  Keyword,
tok::TokenKind  TokenCode,
IdentifierTable Table 
)
static

AddCXXOperatorKeyword - Register a C++ operator keyword alternative representations.

Definition at line 190 of file IdentifierTable.cpp.

References clang::IdentifierTable::get(), and clang::IdentifierInfo::setIsCPlusPlusOperatorKeyword().

◆ AddKeyword()

static void AddKeyword ( StringRef  Keyword,
tok::TokenKind  TokenCode,
unsigned  Flags,
const LangOptions LangOpts,
IdentifierTable Table 
)
static

AddKeyword - This method is used to associate a token ID with specific identifiers because they are language keywords.

This causes the lexer to automatically map matching identifiers to specialized token codes.

Definition at line 165 of file IdentifierTable.cpp.

References clang::IdentifierTable::get(), getKeywordStatus(), clang::LangOptions::isCompatibleWithMSVC(), clang::LangOptions::MSVC2015, clang::IdentifierInfo::setIsExtensionToken(), and clang::IdentifierInfo::setIsFutureCompatKeyword().

Referenced by clang::IdentifierTable::AddKeywords().

◆ AddObjCKeyword()

static void AddObjCKeyword ( StringRef  Name,
tok::ObjCKeywordKind  ObjCID,
IdentifierTable Table 
)
static

AddObjCKeyword - Register an Objective-C @keyword like "class" "selector" or "property".

Definition at line 199 of file IdentifierTable.cpp.

◆ getKeywordStatus()

static KeywordStatus getKeywordStatus ( const LangOptions LangOpts,
unsigned  Flags 
)
static

Translates flags as specified in TokenKinds.def into keyword status in the given language standard.

Definition at line 134 of file IdentifierTable.cpp.

Referenced by AddKeyword().

◆ getSelectorTableImpl()

static SelectorTableImpl& getSelectorTableImpl ( void *  P)
static

◆ getTokenKwStatus()

static KeywordStatus getTokenKwStatus ( const LangOptions LangOpts,
tok::TokenKind  K 
)
static

Checks if the specified token kind represents a keyword in the specified language.

Returns
Status of the keyword in the language.

Definition at line 238 of file IdentifierTable.cpp.

Referenced by clang::IdentifierInfo::isKeyword().

◆ startsWithWord()

static bool startsWithWord ( StringRef  name,
StringRef  word 
)
static