clang API Documentation

Classes | Namespaces | Defines | 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 "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

Namespaces

namespace  clang

Defines

#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 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.
static void AddKeyword (StringRef Keyword, tok::TokenKind TokenCode, unsigned Flags, const LangOptions &LangOpts, IdentifierTable &Table)
static void AddCXXOperatorKeyword (StringRef Keyword, tok::TokenKind TokenCode, IdentifierTable &Table)
static void AddObjCKeyword (StringRef Name, tok::ObjCKeywordKind ObjCID, IdentifierTable &Table)
static bool startsWithWord (StringRef name, StringRef word)
static SelectorTableImpl & getSelectorTableImpl (void *P)

Define Documentation

#define ALIAS (   NAME,
  TOK,
  FLAGS 
)
Value:
AddKeyword(StringRef(NAME), tok::kw_ ## TOK,  \
             FLAGS, LangOpts, *this);
#define CASE (   LEN,
  FIRST,
  THIRD,
  NAME 
)
Value:
case HASH(LEN, FIRST, THIRD): \
    return memcmp(Name, #NAME, LEN) ? tok::pp_not_keyword : tok::pp_ ## NAME

Referenced by clang::IdentifierInfo::getPPKeywordID(), and getStableLevel().

#define CXX_KEYWORD_OPERATOR (   NAME,
  ALIAS 
)
Value:
if (LangOpts.CXXOperatorNames)          \
    AddCXXOperatorKeyword(StringRef(#NAME), tok::ALIAS, *this);
#define HASH (   LEN,
  FIRST,
  THIRD 
)    (LEN << 5) + (((FIRST-'a') + (THIRD-'a')) & 31)
#define KEYWORD (   NAME,
  FLAGS 
)
Value:
AddKeyword(StringRef(#NAME), tok::kw_ ## NAME,  \
             FLAGS, LangOpts, *this);
#define OBJC1_AT_KEYWORD (   NAME)
Value:
if (LangOpts.ObjC1)          \
    AddObjCKeyword(StringRef(#NAME), tok::objc_##NAME, *this);
#define OBJC2_AT_KEYWORD (   NAME)
Value:
if (LangOpts.ObjC2)          \
    AddObjCKeyword(StringRef(#NAME), tok::objc_##NAME, *this);
#define OVERLOADED_OPERATOR (   Name,
  Spelling,
  Token,
  Unary,
  Binary,
  MemberOnly 
)    case OO_##Name: return Spelling;
#define TESTING_KEYWORD (   NAME,
  FLAGS 
)

Enumeration Type Documentation

anonymous enum

Definition at line 95 of file IdentifierTable.cpp.

How a keyword is treated in the selected standard.

Definition at line 115 of file IdentifierTable.cpp.


Function Documentation

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

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

Definition at line 170 of file IdentifierTable.cpp.

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

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 151 of file IdentifierTable.cpp.

References clang::IdentifierTable::get(), GetKeywordStatus(), clang::IdentifierInfo::setIsCXX11CompatKeyword(), and clang::IdentifierInfo::setIsExtensionToken().

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

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 179 of file IdentifierTable.cpp.

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

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 125 of file IdentifierTable.cpp.

Referenced by AddKeyword().

static SelectorTableImpl& getSelectorTableImpl ( void *  P) [static]
static bool startsWithWord ( StringRef  name,
StringRef  word 
) [static]

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.

Definition at line 422 of file IdentifierTable.cpp.

References clang::isLowercase().

Referenced by clang::Selector::getInstTypeMethodFamily().