[cfe-commits] r42730 - in /cfe/trunk: AST/ Analysis/ Basic/ CodeGen/ Driver/ Lex/ Parse/ Sema/ clang.xcodeproj/ include/clang/AST/ include/clang/Basic/ include/clang/Lex/ include/clang/Parse/
Chris Lattner
sabre at nondot.org
Sun Oct 7 01:58:53 PDT 2007
Author: lattner
Date: Sun Oct 7 03:58:51 2007
New Revision: 42730
URL: http://llvm.org/viewvc/llvm-project?rev=42730&view=rev
Log:
move IdentifierTable.h from liblex to libbasic.
Added:
cfe/trunk/Basic/IdentifierTable.cpp
- copied, changed from r42728, cfe/trunk/Lex/IdentifierTable.cpp
cfe/trunk/include/clang/Basic/IdentifierTable.h
- copied, changed from r42727, cfe/trunk/include/clang/Lex/IdentifierTable.h
Removed:
cfe/trunk/Lex/IdentifierTable.cpp
cfe/trunk/include/clang/Lex/IdentifierTable.h
Modified:
cfe/trunk/AST/ASTContext.cpp
cfe/trunk/AST/Builtins.cpp
cfe/trunk/AST/Decl.cpp
cfe/trunk/AST/Expr.cpp
cfe/trunk/AST/Stmt.cpp
cfe/trunk/AST/StmtDumper.cpp
cfe/trunk/AST/StmtPrinter.cpp
cfe/trunk/AST/Type.cpp
cfe/trunk/Analysis/LiveVariables.cpp
cfe/trunk/CodeGen/CGExpr.cpp
cfe/trunk/Driver/PrintParserCallbacks.cpp
cfe/trunk/Lex/HeaderSearch.cpp
cfe/trunk/Parse/AttributeList.cpp
cfe/trunk/Sema/SemaDecl.cpp
cfe/trunk/Sema/SemaStmt.cpp
cfe/trunk/Sema/SemaType.cpp
cfe/trunk/clang.xcodeproj/project.pbxproj
cfe/trunk/include/clang/AST/ASTContext.h
cfe/trunk/include/clang/AST/Decl.h
cfe/trunk/include/clang/AST/DeclObjC.h
cfe/trunk/include/clang/AST/Expr.h
cfe/trunk/include/clang/Lex/Preprocessor.h
cfe/trunk/include/clang/Parse/Action.h
Modified: cfe/trunk/AST/ASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/AST/ASTContext.cpp?rev=42730&r1=42729&r2=42730&view=diff
==============================================================================
--- cfe/trunk/AST/ASTContext.cpp (original)
+++ cfe/trunk/AST/ASTContext.cpp Sun Oct 7 03:58:51 2007
@@ -17,7 +17,6 @@
#include "clang/Lex/Preprocessor.h"
#include "clang/Basic/TargetInfo.h"
#include "llvm/ADT/SmallVector.h"
-#include "clang/Lex/IdentifierTable.h"
using namespace clang;
enum FloatingRank {
Modified: cfe/trunk/AST/Builtins.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/AST/Builtins.cpp?rev=42730&r1=42729&r2=42730&view=diff
==============================================================================
--- cfe/trunk/AST/Builtins.cpp (original)
+++ cfe/trunk/AST/Builtins.cpp Sun Oct 7 03:58:51 2007
@@ -13,7 +13,7 @@
#include "clang/AST/Builtins.h"
#include "clang/AST/ASTContext.h"
-#include "clang/Lex/IdentifierTable.h"
+#include "clang/Basic/IdentifierTable.h"
#include "clang/Basic/TargetInfo.h"
using namespace clang;
Modified: cfe/trunk/AST/Decl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/AST/Decl.cpp?rev=42730&r1=42729&r2=42730&view=diff
==============================================================================
--- cfe/trunk/AST/Decl.cpp (original)
+++ cfe/trunk/AST/Decl.cpp Sun Oct 7 03:58:51 2007
@@ -13,7 +13,7 @@
#include "clang/AST/Decl.h"
#include "clang/AST/DeclObjC.h"
-#include "clang/Lex/IdentifierTable.h"
+#include "clang/Basic/IdentifierTable.h"
using namespace clang;
// temporary statistics gathering
Modified: cfe/trunk/AST/Expr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/AST/Expr.cpp?rev=42730&r1=42729&r2=42730&view=diff
==============================================================================
--- cfe/trunk/AST/Expr.cpp (original)
+++ cfe/trunk/AST/Expr.cpp Sun Oct 7 03:58:51 2007
@@ -14,7 +14,7 @@
#include "clang/AST/Expr.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/StmtVisitor.h"
-#include "clang/Lex/IdentifierTable.h"
+#include "clang/Basic/IdentifierTable.h"
using namespace clang;
//===----------------------------------------------------------------------===//
Modified: cfe/trunk/AST/Stmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/AST/Stmt.cpp?rev=42730&r1=42729&r2=42730&view=diff
==============================================================================
--- cfe/trunk/AST/Stmt.cpp (original)
+++ cfe/trunk/AST/Stmt.cpp Sun Oct 7 03:58:51 2007
@@ -14,7 +14,7 @@
#include "clang/AST/Stmt.h"
#include "clang/AST/ExprCXX.h"
#include "clang/AST/StmtVisitor.h"
-#include "clang/Lex/IdentifierTable.h"
+#include "clang/Basic/IdentifierTable.h"
using namespace clang;
static struct StmtClassNameTable {
Modified: cfe/trunk/AST/StmtDumper.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/AST/StmtDumper.cpp?rev=42730&r1=42729&r2=42730&view=diff
==============================================================================
--- cfe/trunk/AST/StmtDumper.cpp (original)
+++ cfe/trunk/AST/StmtDumper.cpp Sun Oct 7 03:58:51 2007
@@ -15,7 +15,7 @@
#include "clang/AST/StmtVisitor.h"
#include "clang/AST/Decl.h"
#include "clang/AST/ExprCXX.h"
-#include "clang/Lex/IdentifierTable.h"
+#include "clang/Basic/IdentifierTable.h"
#include "clang/Basic/SourceManager.h"
#include "llvm/Support/Compiler.h"
#include <cstdio>
Modified: cfe/trunk/AST/StmtPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/AST/StmtPrinter.cpp?rev=42730&r1=42729&r2=42730&view=diff
==============================================================================
--- cfe/trunk/AST/StmtPrinter.cpp (original)
+++ cfe/trunk/AST/StmtPrinter.cpp Sun Oct 7 03:58:51 2007
@@ -16,7 +16,7 @@
#include "clang/AST/Decl.h"
#include "clang/AST/ExprCXX.h"
#include "clang/AST/PrettyPrinter.h"
-#include "clang/Lex/IdentifierTable.h"
+#include "clang/Basic/IdentifierTable.h"
#include "llvm/Support/Compiler.h"
#include <iostream>
#include <iomanip>
Modified: cfe/trunk/AST/Type.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/AST/Type.cpp?rev=42730&r1=42729&r2=42730&view=diff
==============================================================================
--- cfe/trunk/AST/Type.cpp (original)
+++ cfe/trunk/AST/Type.cpp Sun Oct 7 03:58:51 2007
@@ -11,11 +11,11 @@
//
//===----------------------------------------------------------------------===//
-#include "clang/Lex/IdentifierTable.h"
#include "clang/AST/Type.h"
#include "clang/AST/Decl.h"
#include "clang/AST/DeclObjC.h"
#include "clang/AST/Expr.h"
+#include "clang/Basic/IdentifierTable.h"
#include "clang/Basic/TargetInfo.h"
#include "llvm/Support/Streams.h"
#include "llvm/ADT/StringExtras.h"
Modified: cfe/trunk/Analysis/LiveVariables.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Analysis/LiveVariables.cpp?rev=42730&r1=42729&r2=42730&view=diff
==============================================================================
--- cfe/trunk/Analysis/LiveVariables.cpp (original)
+++ cfe/trunk/Analysis/LiveVariables.cpp Sun Oct 7 03:58:51 2007
@@ -18,7 +18,6 @@
#include "clang/AST/CFG.h"
#include "clang/Analysis/Visitors/CFGRecStmtDeclVisitor.h"
#include "clang/Analysis/FlowSensitive/DataflowSolver.h"
-#include "clang/Lex/IdentifierTable.h"
#include "llvm/ADT/SmallPtrSet.h"
#include <string.h>
Copied: cfe/trunk/Basic/IdentifierTable.cpp (from r42728, cfe/trunk/Lex/IdentifierTable.cpp)
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Basic/IdentifierTable.cpp?p2=cfe/trunk/Basic/IdentifierTable.cpp&p1=cfe/trunk/Lex/IdentifierTable.cpp&r1=42728&r2=42730&rev=42730&view=diff
==============================================================================
--- cfe/trunk/Lex/IdentifierTable.cpp (original)
+++ cfe/trunk/Basic/IdentifierTable.cpp Sun Oct 7 03:58:51 2007
@@ -12,7 +12,7 @@
//
//===----------------------------------------------------------------------===//
-#include "clang/Lex/IdentifierTable.h"
+#include "clang/Basic/IdentifierTable.h"
#include "clang/Basic/LangOptions.h"
#include "llvm/ADT/FoldingSet.h"
#include "llvm/ADT/DenseMap.h"
Modified: cfe/trunk/CodeGen/CGExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/CodeGen/CGExpr.cpp?rev=42730&r1=42729&r2=42730&view=diff
==============================================================================
--- cfe/trunk/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/CodeGen/CGExpr.cpp Sun Oct 7 03:58:51 2007
@@ -14,7 +14,6 @@
#include "CodeGenFunction.h"
#include "CodeGenModule.h"
#include "clang/AST/AST.h"
-#include "clang/Lex/IdentifierTable.h"
#include "llvm/Constants.h"
#include "llvm/DerivedTypes.h"
#include "llvm/Function.h"
Modified: cfe/trunk/Driver/PrintParserCallbacks.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/PrintParserCallbacks.cpp?rev=42730&r1=42729&r2=42730&view=diff
==============================================================================
--- cfe/trunk/Driver/PrintParserCallbacks.cpp (original)
+++ cfe/trunk/Driver/PrintParserCallbacks.cpp Sun Oct 7 03:58:51 2007
@@ -13,7 +13,6 @@
//===----------------------------------------------------------------------===//
#include "clang.h"
-#include "clang/Lex/IdentifierTable.h"
#include "clang/Parse/Action.h"
#include "clang/Parse/DeclSpec.h"
#include <iostream>
Modified: cfe/trunk/Lex/HeaderSearch.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Lex/HeaderSearch.cpp?rev=42730&r1=42729&r2=42730&view=diff
==============================================================================
--- cfe/trunk/Lex/HeaderSearch.cpp (original)
+++ cfe/trunk/Lex/HeaderSearch.cpp Sun Oct 7 03:58:51 2007
@@ -11,9 +11,9 @@
//
//===----------------------------------------------------------------------===//
-#include "clang/Basic/FileManager.h"
#include "clang/Lex/HeaderSearch.h"
-#include "clang/Lex/IdentifierTable.h"
+#include "clang/Basic/FileManager.h"
+#include "clang/Basic/IdentifierTable.h"
#include "llvm/System/Path.h"
#include "llvm/ADT/SmallString.h"
using namespace clang;
Removed: cfe/trunk/Lex/IdentifierTable.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Lex/IdentifierTable.cpp?rev=42729&view=auto
==============================================================================
--- cfe/trunk/Lex/IdentifierTable.cpp (original)
+++ cfe/trunk/Lex/IdentifierTable.cpp (removed)
@@ -1,374 +0,0 @@
-//===--- IdentifierTable.cpp - Hash table for identifier lookup -----------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file was developed by Chris Lattner and is distributed under
-// the University of Illinois Open Source License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This file implements the IdentifierInfo, IdentifierVisitor, and
-// IdentifierTable interfaces.
-//
-//===----------------------------------------------------------------------===//
-
-#include "clang/Lex/IdentifierTable.h"
-#include "clang/Basic/LangOptions.h"
-#include "llvm/ADT/FoldingSet.h"
-#include "llvm/ADT/DenseMap.h"
-using namespace clang;
-
-//===----------------------------------------------------------------------===//
-// IdentifierInfo Implementation
-//===----------------------------------------------------------------------===//
-
-IdentifierInfo::IdentifierInfo() {
- TokenID = tok::identifier;
- ObjCID = tok::objc_not_keyword;
- BuiltinID = 0;
- HasMacro = false;
- IsExtension = false;
- IsPoisoned = false;
- IsOtherTargetMacro = false;
- IsCPPOperatorKeyword = false;
- IsNonPortableBuiltin = false;
- FETokenInfo = 0;
-}
-
-//===----------------------------------------------------------------------===//
-// IdentifierTable Implementation
-//===----------------------------------------------------------------------===//
-
-IdentifierTable::IdentifierTable(const LangOptions &LangOpts)
- // Start with space for 8K identifiers.
- : HashTable(8192) {
-
- // Populate the identifier table with info about keywords for the current
- // language.
- AddKeywords(LangOpts);
-}
-
-//===----------------------------------------------------------------------===//
-// Language Keyword Implementation
-//===----------------------------------------------------------------------===//
-
-/// 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.
-///
-/// The C90/C99/CPP/CPP0x flags are set to 0 if the token should be
-/// enabled in the specified langauge, set to 1 if it is an extension
-/// in the specified language, and set to 2 if disabled in the
-/// specified language.
-static void AddKeyword(const char *Keyword, unsigned KWLen,
- tok::TokenKind TokenCode,
- int C90, int C99, int CXX, int CXX0x,
- const LangOptions &LangOpts, IdentifierTable &Table) {
- int Flags = LangOpts.CPlusPlus ? (LangOpts.CPlusPlus0x? CXX0x : CXX)
- : (LangOpts.C99 ? C99 : C90);
-
- // Don't add this keyword if disabled in this language or if an extension
- // and extensions are disabled.
- if (Flags + LangOpts.NoExtensions >= 2) return;
-
- IdentifierInfo &Info = Table.get(Keyword, Keyword+KWLen);
- Info.setTokenID(TokenCode);
- Info.setIsExtensionToken(Flags == 1);
-}
-
-static void AddAlias(const char *Keyword, unsigned KWLen,
- const char *AliaseeKeyword, unsigned AliaseeKWLen,
- const LangOptions &LangOpts, IdentifierTable &Table) {
- IdentifierInfo &AliasInfo = Table.get(Keyword, Keyword+KWLen);
- IdentifierInfo &AliaseeInfo = Table.get(AliaseeKeyword,
- AliaseeKeyword+AliaseeKWLen);
- AliasInfo.setTokenID(AliaseeInfo.getTokenID());
- AliasInfo.setIsExtensionToken(AliaseeInfo.isExtensionToken());
-}
-
-/// AddCXXOperatorKeyword - Register a C++ operator keyword alternative
-/// representations.
-static void AddCXXOperatorKeyword(const char *Keyword, unsigned KWLen,
- tok::TokenKind TokenCode,
- IdentifierTable &Table) {
- IdentifierInfo &Info = Table.get(Keyword, Keyword + KWLen);
- Info.setTokenID(TokenCode);
- Info.setIsCPlusplusOperatorKeyword();
-}
-
-/// AddObjCKeyword - Register an Objective-C @keyword like "class" "selector" or
-/// "property".
-static void AddObjCKeyword(tok::ObjCKeywordKind ObjCID,
- const char *Name, unsigned NameLen,
- IdentifierTable &Table) {
- Table.get(Name, Name+NameLen).setObjCKeywordID(ObjCID);
-}
-
-/// AddKeywords - Add all keywords to the symbol table.
-///
-void IdentifierTable::AddKeywords(const LangOptions &LangOpts) {
- enum {
- C90Shift = 0,
- EXTC90 = 1 << C90Shift,
- NOTC90 = 2 << C90Shift,
- C99Shift = 2,
- EXTC99 = 1 << C99Shift,
- NOTC99 = 2 << C99Shift,
- CPPShift = 4,
- EXTCPP = 1 << CPPShift,
- NOTCPP = 2 << CPPShift,
- CPP0xShift = 6,
- EXTCPP0x = 1 << CPP0xShift,
- NOTCPP0x = 2 << CPP0xShift,
- Mask = 3
- };
-
- // Add keywords and tokens for the current language.
-#define KEYWORD(NAME, FLAGS) \
- AddKeyword(#NAME, strlen(#NAME), tok::kw_ ## NAME, \
- ((FLAGS) >> C90Shift) & Mask, \
- ((FLAGS) >> C99Shift) & Mask, \
- ((FLAGS) >> CPPShift) & Mask, \
- ((FLAGS) >> CPP0xShift) & Mask, LangOpts, *this);
-#define ALIAS(NAME, TOK) \
- AddAlias(NAME, strlen(NAME), #TOK, strlen(#TOK), LangOpts, *this);
-#define CXX_KEYWORD_OPERATOR(NAME, ALIAS) \
- if (LangOpts.CXXOperatorNames) \
- AddCXXOperatorKeyword(#NAME, strlen(#NAME), tok::ALIAS, *this);
-#define OBJC1_AT_KEYWORD(NAME) \
- if (LangOpts.ObjC1) \
- AddObjCKeyword(tok::objc_##NAME, #NAME, strlen(#NAME), *this);
-#define OBJC2_AT_KEYWORD(NAME) \
- if (LangOpts.ObjC2) \
- AddObjCKeyword(tok::objc_##NAME, #NAME, strlen(#NAME), *this);
-#include "clang/Basic/TokenKinds.def"
-}
-
-tok::PPKeywordKind IdentifierInfo::getPPKeywordID() const {
- // We use a perfect hash function here involving the length of the keyword,
- // the first and third character. For preprocessor ID's there are no
- // collisions (if there were, the switch below would complain about duplicate
- // case values). Note that this depends on 'if' being null terminated.
-
-#define HASH(LEN, FIRST, THIRD) \
- (LEN << 5) + (((FIRST-'a') + (THIRD-'a')) & 31)
-#define CASE(LEN, FIRST, THIRD, NAME) \
- case HASH(LEN, FIRST, THIRD): \
- return memcmp(Name, #NAME, LEN) ? tok::pp_not_keyword : tok::pp_ ## NAME
-
- unsigned Len = getLength();
- const char *Name = getName();
- switch (HASH(Len, Name[0], Name[2])) {
- default: return tok::pp_not_keyword;
- CASE( 2, 'i', '\0', if);
- CASE( 4, 'e', 'i', elif);
- CASE( 4, 'e', 's', else);
- CASE( 4, 'l', 'n', line);
- CASE( 4, 's', 'c', sccs);
- CASE( 5, 'e', 'd', endif);
- CASE( 5, 'e', 'r', error);
- CASE( 5, 'i', 'e', ident);
- CASE( 5, 'i', 'd', ifdef);
- CASE( 5, 'u', 'd', undef);
-
- CASE( 6, 'a', 's', assert);
- CASE( 6, 'd', 'f', define);
- CASE( 6, 'i', 'n', ifndef);
- CASE( 6, 'i', 'p', import);
- CASE( 6, 'p', 'a', pragma);
-
- CASE( 7, 'd', 'f', defined);
- CASE( 7, 'i', 'c', include);
- CASE( 7, 'w', 'r', warning);
-
- CASE( 8, 'u', 'a', unassert);
- CASE(12, 'i', 'c', include_next);
- CASE(13, 'd', 'f', define_target);
- CASE(19, 'd', 'f', define_other_target);
-#undef CASE
-#undef HASH
- }
-}
-
-//===----------------------------------------------------------------------===//
-// Stats Implementation
-//===----------------------------------------------------------------------===//
-
-/// PrintStats - Print statistics about how well the identifier table is doing
-/// at hashing identifiers.
-void IdentifierTable::PrintStats() const {
- unsigned NumBuckets = HashTable.getNumBuckets();
- unsigned NumIdentifiers = HashTable.getNumItems();
- unsigned NumEmptyBuckets = NumBuckets-NumIdentifiers;
- unsigned AverageIdentifierSize = 0;
- unsigned MaxIdentifierLength = 0;
-
- // TODO: Figure out maximum times an identifier had to probe for -stats.
- for (llvm::StringMap<IdentifierInfo, llvm::BumpPtrAllocator>::const_iterator
- I = HashTable.begin(), E = HashTable.end(); I != E; ++I) {
- unsigned IdLen = I->getKeyLength();
- AverageIdentifierSize += IdLen;
- if (MaxIdentifierLength < IdLen)
- MaxIdentifierLength = IdLen;
- }
-
- fprintf(stderr, "\n*** Identifier Table Stats:\n");
- fprintf(stderr, "# Identifiers: %d\n", NumIdentifiers);
- fprintf(stderr, "# Empty Buckets: %d\n", NumEmptyBuckets);
- fprintf(stderr, "Hash density (#identifiers per bucket): %f\n",
- NumIdentifiers/(double)NumBuckets);
- fprintf(stderr, "Ave identifier length: %f\n",
- (AverageIdentifierSize/(double)NumIdentifiers));
- fprintf(stderr, "Max identifier length: %d\n", MaxIdentifierLength);
-
- // Compute statistics about the memory allocated for identifiers.
- HashTable.getAllocator().PrintStats();
-}
-
-//===----------------------------------------------------------------------===//
-// SelectorTable Implementation
-//===----------------------------------------------------------------------===//
-
-unsigned llvm::DenseMapInfo<clang::Selector>::getHashValue(clang::Selector S) {
- return DenseMapInfo<void*>::getHashValue(S.getAsOpaquePtr());
-}
-
-
-/// MultiKeywordSelector - One of these variable length records is kept for each
-/// selector containing more than one keyword. We use a folding set
-/// to unique aggregate names (keyword selectors in ObjC parlance). Access to
-/// this class is provided strictly through Selector.
-namespace clang {
-class MultiKeywordSelector : public llvm::FoldingSetNode {
-public:
- unsigned NumArgs;
-
- // Constructor for keyword selectors.
- MultiKeywordSelector(unsigned nKeys, IdentifierInfo **IIV) {
- assert((nKeys > 1) && "not a multi-keyword selector");
- NumArgs = nKeys;
- // Fill in the trailing keyword array.
- IdentifierInfo **KeyInfo = reinterpret_cast<IdentifierInfo **>(this+1);
- for (unsigned i = 0; i != nKeys; ++i)
- KeyInfo[i] = IIV[i];
- }
- // getName - Derive the full selector name and return it.
- std::string getName() const;
-
- unsigned getNumArgs() const { return NumArgs; }
-
- typedef IdentifierInfo *const *keyword_iterator;
- keyword_iterator keyword_begin() const {
- return reinterpret_cast<keyword_iterator>(this+1);
- }
- keyword_iterator keyword_end() const {
- return keyword_begin()+NumArgs;
- }
- IdentifierInfo *getIdentifierInfoForSlot(unsigned i) const {
- assert(i < NumArgs && "getIdentifierInfoForSlot(): illegal index");
- return keyword_begin()[i];
- }
- static void Profile(llvm::FoldingSetNodeID &ID,
- keyword_iterator ArgTys, unsigned NumArgs) {
- ID.AddInteger(NumArgs);
- for (unsigned i = 0; i != NumArgs; ++i)
- ID.AddPointer(ArgTys[i]);
- }
- void Profile(llvm::FoldingSetNodeID &ID) {
- Profile(ID, keyword_begin(), NumArgs);
- }
-};
-} // end namespace clang.
-
-unsigned Selector::getNumArgs() const {
- unsigned IIF = getIdentifierInfoFlag();
- if (IIF == ZeroArg)
- return 0;
- if (IIF == OneArg)
- return 1;
- // We point to a MultiKeywordSelector (pointer doesn't contain any flags).
- MultiKeywordSelector *SI = reinterpret_cast<MultiKeywordSelector *>(InfoPtr);
- return SI->getNumArgs();
-}
-
-IdentifierInfo *Selector::getIdentifierInfoForSlot(unsigned argIndex) const {
- if (IdentifierInfo *II = getAsIdentifierInfo()) {
- assert(argIndex == 0 && "illegal keyword index");
- return II;
- }
- // We point to a MultiKeywordSelector (pointer doesn't contain any flags).
- MultiKeywordSelector *SI = reinterpret_cast<MultiKeywordSelector *>(InfoPtr);
- return SI->getIdentifierInfoForSlot(argIndex);
-}
-
-std::string MultiKeywordSelector::getName() const {
- std::string Result;
- unsigned Length = 0;
- for (keyword_iterator I = keyword_begin(), E = keyword_end(); I != E; ++I) {
- if (*I)
- Length += (*I)->getLength();
- ++Length; // :
- }
-
- Result.reserve(Length);
-
- for (keyword_iterator I = keyword_begin(), E = keyword_end(); I != E; ++I) {
- if (*I)
- Result.insert(Result.end(), (*I)->getName(),
- (*I)->getName()+(*I)->getLength());
- Result.push_back(':');
- }
-
- return Result;
-}
-
-std::string Selector::getName() const {
- if (IdentifierInfo *II = getAsIdentifierInfo()) {
- if (getNumArgs() == 0)
- return II->getName();
-
- std::string Res = II->getName();
- Res += ":";
- return Res;
- }
-
- // We have a multiple keyword selector (no embedded flags).
- return reinterpret_cast<MultiKeywordSelector *>(InfoPtr)->getName();
-}
-
-
-Selector SelectorTable::getSelector(unsigned nKeys, IdentifierInfo **IIV) {
- if (nKeys < 2)
- return Selector(IIV[0], nKeys);
-
- llvm::FoldingSet<MultiKeywordSelector> *SelTab;
-
- SelTab = static_cast<llvm::FoldingSet<MultiKeywordSelector> *>(Impl);
-
- // Unique selector, to guarantee there is one per name.
- llvm::FoldingSetNodeID ID;
- MultiKeywordSelector::Profile(ID, IIV, nKeys);
-
- void *InsertPos = 0;
- if (MultiKeywordSelector *SI = SelTab->FindNodeOrInsertPos(ID, InsertPos))
- return Selector(SI);
-
- // MultiKeywordSelector objects are not allocated with new because they have a
- // variable size array (for parameter types) at the end of them.
- MultiKeywordSelector *SI =
- (MultiKeywordSelector*)malloc(sizeof(MultiKeywordSelector) +
- nKeys*sizeof(IdentifierInfo *));
- new (SI) MultiKeywordSelector(nKeys, IIV);
- SelTab->InsertNode(SI, InsertPos);
- return Selector(SI);
-}
-
-SelectorTable::SelectorTable() {
- Impl = new llvm::FoldingSet<MultiKeywordSelector>;
-}
-
-SelectorTable::~SelectorTable() {
- delete static_cast<llvm::FoldingSet<MultiKeywordSelector> *>(Impl);
-}
-
-
Modified: cfe/trunk/Parse/AttributeList.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Parse/AttributeList.cpp?rev=42730&r1=42729&r2=42730&view=diff
==============================================================================
--- cfe/trunk/Parse/AttributeList.cpp (original)
+++ cfe/trunk/Parse/AttributeList.cpp Sun Oct 7 03:58:51 2007
@@ -12,7 +12,6 @@
//===----------------------------------------------------------------------===//
#include "clang/Parse/AttributeList.h"
-#include "clang/Lex/IdentifierTable.h"
using namespace clang;
AttributeList::AttributeList(IdentifierInfo *aName, SourceLocation aLoc,
Modified: cfe/trunk/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Sema/SemaDecl.cpp?rev=42730&r1=42729&r2=42730&view=diff
==============================================================================
--- cfe/trunk/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/Sema/SemaDecl.cpp Sun Oct 7 03:58:51 2007
@@ -20,7 +20,6 @@
#include "clang/AST/Type.h"
#include "clang/Parse/DeclSpec.h"
#include "clang/Parse/Scope.h"
-#include "clang/Lex/IdentifierTable.h"
#include "clang/Basic/LangOptions.h"
#include "clang/Basic/TargetInfo.h"
#include "llvm/ADT/SmallString.h"
Modified: cfe/trunk/Sema/SemaStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Sema/SemaStmt.cpp?rev=42730&r1=42729&r2=42730&view=diff
==============================================================================
--- cfe/trunk/Sema/SemaStmt.cpp (original)
+++ cfe/trunk/Sema/SemaStmt.cpp Sun Oct 7 03:58:51 2007
@@ -18,7 +18,6 @@
#include "clang/Parse/Scope.h"
#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/LangOptions.h"
-#include "clang/Lex/IdentifierTable.h"
using namespace clang;
Sema::StmtResult Sema::ActOnExprStmt(ExprTy *expr) {
Modified: cfe/trunk/Sema/SemaType.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Sema/SemaType.cpp?rev=42730&r1=42729&r2=42730&view=diff
==============================================================================
--- cfe/trunk/Sema/SemaType.cpp (original)
+++ cfe/trunk/Sema/SemaType.cpp Sun Oct 7 03:58:51 2007
@@ -16,7 +16,6 @@
#include "clang/AST/Decl.h"
#include "clang/AST/DeclObjC.h"
#include "clang/Parse/DeclSpec.h"
-#include "clang/Lex/IdentifierTable.h"
#include "clang/Basic/LangOptions.h"
using namespace clang;
Modified: cfe/trunk/clang.xcodeproj/project.pbxproj
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/clang.xcodeproj/project.pbxproj?rev=42730&r1=42729&r2=42730&view=diff
==============================================================================
--- cfe/trunk/clang.xcodeproj/project.pbxproj (original)
+++ cfe/trunk/clang.xcodeproj/project.pbxproj Sun Oct 7 03:58:51 2007
@@ -53,6 +53,8 @@
DE3464220B03040900DBC861 /* Type.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = DE3464210B03040900DBC861 /* Type.h */; };
DE3985790CB8ADC800223765 /* ASTConsumers.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = DE3985780CB8ADC800223765 /* ASTConsumers.h */; };
DE39857B0CB8ADCB00223765 /* ASTConsumers.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DE39857A0CB8ADCB00223765 /* ASTConsumers.cpp */; };
+ DE3986F00CB8D4B300223765 /* IdentifierTable.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = DE3986EF0CB8D4B300223765 /* IdentifierTable.h */; };
+ DE3986F40CB8D50C00223765 /* IdentifierTable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DE3986F30CB8D50C00223765 /* IdentifierTable.cpp */; };
DE4264FC0C113592005A861D /* CGDecl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DE4264FB0C113592005A861D /* CGDecl.cpp */; };
DE46BF280AE0A82D00CC047C /* TargetInfo.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = DE46BF270AE0A82D00CC047C /* TargetInfo.h */; };
DE4772FA0C10EAE5002239E8 /* CGStmt.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DE4772F90C10EAE5002239E8 /* CGStmt.cpp */; };
@@ -104,7 +106,6 @@
DED7D7460A524295003AD0FB /* SourceManager.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = DED7D7360A524295003AD0FB /* SourceManager.h */; };
DED7D7470A524295003AD0FB /* TokenKinds.def in CopyFiles */ = {isa = PBXBuildFile; fileRef = DED7D7370A524295003AD0FB /* TokenKinds.def */; };
DED7D7480A524295003AD0FB /* TokenKinds.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = DED7D7380A524295003AD0FB /* TokenKinds.h */; };
- DED7D7490A524295003AD0FB /* IdentifierTable.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = DED7D73A0A524295003AD0FB /* IdentifierTable.h */; };
DED7D74A0A524295003AD0FB /* Lexer.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = DED7D73B0A524295003AD0FB /* Lexer.h */; };
DED7D74C0A524295003AD0FB /* MacroExpander.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = DED7D73D0A524295003AD0FB /* MacroExpander.h */; };
DED7D74D0A524295003AD0FB /* MacroInfo.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = DED7D73E0A524295003AD0FB /* MacroInfo.h */; };
@@ -114,7 +115,6 @@
DED7D77B0A5242C7003AD0FB /* FileManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DED7D75E0A5242C7003AD0FB /* FileManager.cpp */; };
DED7D7890A5242C7003AD0FB /* SourceManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DED7D76D0A5242C7003AD0FB /* SourceManager.cpp */; };
DED7D78A0A5242C7003AD0FB /* TokenKinds.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DED7D76E0A5242C7003AD0FB /* TokenKinds.cpp */; };
- DED7D7C20A5242E6003AD0FB /* IdentifierTable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DED7D79D0A5242E6003AD0FB /* IdentifierTable.cpp */; };
DED7D7C30A5242E6003AD0FB /* Lexer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DED7D79E0A5242E6003AD0FB /* Lexer.cpp */; };
DED7D7C50A5242E6003AD0FB /* MacroInfo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DED7D7A00A5242E6003AD0FB /* MacroInfo.cpp */; };
DED7D7C70A5242E6003AD0FB /* PPExpressions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DED7D7A20A5242E6003AD0FB /* PPExpressions.cpp */; };
@@ -152,7 +152,6 @@
DED7D7460A524295003AD0FB /* SourceManager.h in CopyFiles */,
DED7D7470A524295003AD0FB /* TokenKinds.def in CopyFiles */,
DED7D7480A524295003AD0FB /* TokenKinds.h in CopyFiles */,
- DED7D7490A524295003AD0FB /* IdentifierTable.h in CopyFiles */,
DED7D74A0A524295003AD0FB /* Lexer.h in CopyFiles */,
DED7D74C0A524295003AD0FB /* MacroExpander.h in CopyFiles */,
DED7D74D0A524295003AD0FB /* MacroInfo.h in CopyFiles */,
@@ -204,6 +203,7 @@
DEF7D9F70C9C8B1A0001F598 /* Rewriter.h in CopyFiles */,
84AF36A10CB17A3B00C820A5 /* DeclObjC.h in CopyFiles */,
DE3985790CB8ADC800223765 /* ASTConsumers.h in CopyFiles */,
+ DE3986F00CB8D4B300223765 /* IdentifierTable.h in CopyFiles */,
);
runOnlyForDeploymentPostprocessing = 1;
};
@@ -271,6 +271,8 @@
DE3464210B03040900DBC861 /* Type.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = Type.h; path = clang/AST/Type.h; sourceTree = "<group>"; };
DE3985780CB8ADC800223765 /* ASTConsumers.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = ASTConsumers.h; path = Driver/ASTConsumers.h; sourceTree = "<group>"; };
DE39857A0CB8ADCB00223765 /* ASTConsumers.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = ASTConsumers.cpp; path = Driver/ASTConsumers.cpp; sourceTree = "<group>"; };
+ DE3986EF0CB8D4B300223765 /* IdentifierTable.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = IdentifierTable.h; path = include/clang/Basic/IdentifierTable.h; sourceTree = SOURCE_ROOT; };
+ DE3986F30CB8D50C00223765 /* IdentifierTable.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = IdentifierTable.cpp; sourceTree = "<group>"; };
DE4264FB0C113592005A861D /* CGDecl.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = CGDecl.cpp; path = CodeGen/CGDecl.cpp; sourceTree = "<group>"; };
DE46BF270AE0A82D00CC047C /* TargetInfo.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = TargetInfo.h; sourceTree = "<group>"; };
DE4772F90C10EAE5002239E8 /* CGStmt.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = CGStmt.cpp; path = CodeGen/CGStmt.cpp; sourceTree = "<group>"; };
@@ -322,7 +324,6 @@
DED7D7360A524295003AD0FB /* SourceManager.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = SourceManager.h; sourceTree = "<group>"; };
DED7D7370A524295003AD0FB /* TokenKinds.def */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = TokenKinds.def; sourceTree = "<group>"; };
DED7D7380A524295003AD0FB /* TokenKinds.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = TokenKinds.h; sourceTree = "<group>"; };
- DED7D73A0A524295003AD0FB /* IdentifierTable.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = IdentifierTable.h; sourceTree = "<group>"; };
DED7D73B0A524295003AD0FB /* Lexer.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = Lexer.h; sourceTree = "<group>"; };
DED7D73D0A524295003AD0FB /* MacroExpander.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = MacroExpander.h; sourceTree = "<group>"; };
DED7D73E0A524295003AD0FB /* MacroInfo.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = MacroInfo.h; sourceTree = "<group>"; };
@@ -332,7 +333,6 @@
DED7D75E0A5242C7003AD0FB /* FileManager.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = FileManager.cpp; sourceTree = "<group>"; };
DED7D76D0A5242C7003AD0FB /* SourceManager.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = SourceManager.cpp; sourceTree = "<group>"; };
DED7D76E0A5242C7003AD0FB /* TokenKinds.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = TokenKinds.cpp; sourceTree = "<group>"; };
- DED7D79D0A5242E6003AD0FB /* IdentifierTable.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = IdentifierTable.cpp; sourceTree = "<group>"; };
DED7D79E0A5242E6003AD0FB /* Lexer.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = Lexer.cpp; sourceTree = "<group>"; };
DED7D7A00A5242E6003AD0FB /* MacroInfo.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = MacroInfo.cpp; sourceTree = "<group>"; };
DED7D7A20A5242E6003AD0FB /* PPExpressions.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = PPExpressions.cpp; sourceTree = "<group>"; };
@@ -651,7 +651,7 @@
children = (
DE3450D60AEB543100DBC861 /* DirectoryLookup.h */,
DE344AB70AE5DF6D00DBC861 /* HeaderSearch.h */,
- DED7D73A0A524295003AD0FB /* IdentifierTable.h */,
+ DE3986EF0CB8D4B300223765 /* IdentifierTable.h */,
DED7D73B0A524295003AD0FB /* Lexer.h */,
1A869A6E0BA2164C008DA07A /* LiteralSupport.h */,
DED7D73D0A524295003AD0FB /* MacroExpander.h */,
@@ -672,6 +672,7 @@
children = (
DED7D75D0A5242C7003AD0FB /* Diagnostic.cpp */,
DED7D75E0A5242C7003AD0FB /* FileManager.cpp */,
+ DE3986F30CB8D50C00223765 /* IdentifierTable.cpp */,
DED7D76D0A5242C7003AD0FB /* SourceManager.cpp */,
DED7D76E0A5242C7003AD0FB /* TokenKinds.cpp */,
DED626C80AE0C065001E80A4 /* TargetInfo.cpp */,
@@ -683,7 +684,6 @@
isa = PBXGroup;
children = (
DE344B530AE5E46C00DBC861 /* HeaderSearch.cpp */,
- DED7D79D0A5242E6003AD0FB /* IdentifierTable.cpp */,
DED7D79E0A5242E6003AD0FB /* Lexer.cpp */,
1A869AA70BA21ABA008DA07A /* LiteralSupport.cpp */,
DE3451570AEC176100DBC861 /* MacroExpander.cpp */,
@@ -758,7 +758,6 @@
DED7D77B0A5242C7003AD0FB /* FileManager.cpp in Sources */,
DED7D7890A5242C7003AD0FB /* SourceManager.cpp in Sources */,
DED7D78A0A5242C7003AD0FB /* TokenKinds.cpp in Sources */,
- DED7D7C20A5242E6003AD0FB /* IdentifierTable.cpp in Sources */,
DED7D7C30A5242E6003AD0FB /* Lexer.cpp in Sources */,
DED7D7C50A5242E6003AD0FB /* MacroInfo.cpp in Sources */,
DED7D7C70A5242E6003AD0FB /* PPExpressions.cpp in Sources */,
@@ -824,6 +823,7 @@
3513BD550C9F207900FA56C6 /* UninitializedValues.cpp in Sources */,
35CFFE000CA1CBCB00E6F2BE /* StmtViz.cpp in Sources */,
DE39857B0CB8ADCB00223765 /* ASTConsumers.cpp in Sources */,
+ DE3986F40CB8D50C00223765 /* IdentifierTable.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Modified: cfe/trunk/include/clang/AST/ASTContext.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=42730&r1=42729&r2=42730&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/ASTContext.h (original)
+++ cfe/trunk/include/clang/AST/ASTContext.h Sun Oct 7 03:58:51 2007
@@ -14,7 +14,6 @@
#ifndef LLVM_CLANG_AST_ASTCONTEXT_H
#define LLVM_CLANG_AST_ASTCONTEXT_H
-#include "clang/Lex/IdentifierTable.h" // FIXME: Move IdentifierTable to Basic
#include "clang/AST/Builtins.h"
#include "clang/AST/Expr.h"
#include "clang/AST/RecordLayout.h"
@@ -26,6 +25,7 @@
namespace clang {
class TargetInfo;
+ class IdentifierTable;
/// ASTContext - This class holds long-lived AST nodes (such as types and
/// decls) that can be referred to throughout the semantic analysis of a file.
Modified: cfe/trunk/include/clang/AST/Decl.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=42730&r1=42729&r2=42730&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Sun Oct 7 03:58:51 2007
@@ -17,13 +17,13 @@
#include "clang/Basic/SourceLocation.h"
#include "clang/AST/Type.h"
#include "llvm/ADT/APSInt.h"
-#include "clang/Lex/IdentifierTable.h" // FIXME: should be in Basic, not Lex.
namespace clang {
class Expr;
class Stmt;
class FunctionDecl;
class AttributeList;
+class IdentifierInfo;
/// Decl - This represents one declaration (or definition), e.g. a variable,
/// typedef, function, struct, etc.
Modified: cfe/trunk/include/clang/AST/DeclObjC.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclObjC.h?rev=42730&r1=42729&r2=42730&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/DeclObjC.h (original)
+++ cfe/trunk/include/clang/AST/DeclObjC.h Sun Oct 7 03:58:51 2007
@@ -15,6 +15,7 @@
#define LLVM_CLANG_AST_DECLOBJC_H
#include "clang/AST/Decl.h"
+#include "clang/Basic/IdentifierTable.h"
namespace clang {
class Expr;
Modified: cfe/trunk/include/clang/AST/Expr.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=42730&r1=42729&r2=42730&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Expr.h (original)
+++ cfe/trunk/include/clang/AST/Expr.h Sun Oct 7 03:58:51 2007
@@ -17,9 +17,9 @@
#include "clang/AST/Stmt.h"
#include "clang/AST/Type.h"
#include "clang/AST/Decl.h"
+#include "clang/Basic/IdentifierTable.h"
#include "llvm/ADT/APSInt.h"
#include "llvm/ADT/APFloat.h"
-#include "clang/Lex/IdentifierTable.h" // FIXME: should be in Basic, not Lex.
namespace clang {
class IdentifierInfo;
Copied: cfe/trunk/include/clang/Basic/IdentifierTable.h (from r42727, cfe/trunk/include/clang/Lex/IdentifierTable.h)
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/IdentifierTable.h?p2=cfe/trunk/include/clang/Basic/IdentifierTable.h&p1=cfe/trunk/include/clang/Lex/IdentifierTable.h&r1=42727&r2=42730&rev=42730&view=diff
==============================================================================
--- cfe/trunk/include/clang/Lex/IdentifierTable.h (original)
+++ cfe/trunk/include/clang/Basic/IdentifierTable.h Sun Oct 7 03:58:51 2007
@@ -7,15 +7,14 @@
//
//===----------------------------------------------------------------------===//
//
-// This file defines the IdentifierInfo and IdentifierTable interfaces.
+// This file defines the IdentifierInfo, IdentifierTable, and Selector
+// interfaces.
//
//===----------------------------------------------------------------------===//
-#ifndef LLVM_CLANG_LEX_IDENTIFIERTABLE_H
-#define LLVM_CLANG_LEX_IDENTIFIERTABLE_H
+#ifndef LLVM_CLANG_BASIC_IDENTIFIERTABLE_H
+#define LLVM_CLANG_BASIC_IDENTIFIERTABLE_H
-// FIXME: Move this header header/module to the "Basic" library. Unlike Lex,
-// this data is long-lived.
#include "clang/Basic/TokenKinds.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/ADT/SmallString.h"
Removed: cfe/trunk/include/clang/Lex/IdentifierTable.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/IdentifierTable.h?rev=42729&view=auto
==============================================================================
--- cfe/trunk/include/clang/Lex/IdentifierTable.h (original)
+++ cfe/trunk/include/clang/Lex/IdentifierTable.h (removed)
@@ -1,300 +0,0 @@
-//===--- IdentifierTable.h - Hash table for identifier lookup ---*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file was developed by Chris Lattner and is distributed under
-// the University of Illinois Open Source License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This file defines the IdentifierInfo and IdentifierTable interfaces.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_CLANG_LEX_IDENTIFIERTABLE_H
-#define LLVM_CLANG_LEX_IDENTIFIERTABLE_H
-
-// FIXME: Move this header header/module to the "Basic" library. Unlike Lex,
-// this data is long-lived.
-#include "clang/Basic/TokenKinds.h"
-#include "llvm/ADT/StringMap.h"
-#include "llvm/ADT/SmallString.h"
-#include <string>
-#include <cassert>
-
-namespace llvm {
- template <typename T> struct DenseMapInfo;
-}
-
-namespace clang {
- struct LangOptions;
- class MultiKeywordSelector; // a private class used by Selector.
-
-/// IdentifierInfo - One of these records is kept for each identifier that
-/// is lexed. This contains information about whether the token was #define'd,
-/// is a language keyword, or if it is a front-end token of some sort (e.g. a
-/// variable or function name). The preprocessor keeps this information in a
-/// set, and all tok::identifier tokens have a pointer to one of these.
-class IdentifierInfo {
- tok::TokenKind TokenID : 8; // Front-end token ID or tok::identifier.
- unsigned BuiltinID : 9; // ID if this is a builtin (__builtin_inf).
- tok::ObjCKeywordKind ObjCID : 5; // ID for objc @ keyword like @'protocol'.
- bool HasMacro : 1; // True if there is a #define for this.
- bool IsExtension : 1; // True if identifier is a lang extension.
- bool IsPoisoned : 1; // True if identifier is poisoned.
- bool IsOtherTargetMacro : 1; // True if ident is macro on another target.
- bool IsCPPOperatorKeyword : 1; // True if ident is a C++ operator keyword.
- bool IsNonPortableBuiltin : 1; // True if builtin varies across targets.
- void *FETokenInfo; // Managed by the language front-end.
- IdentifierInfo(const IdentifierInfo&); // NONCOPYABLE.
- void operator=(const IdentifierInfo&); // NONASSIGNABLE.
-public:
- IdentifierInfo();
-
- /// getName - Return the actual string for this identifier. The returned
- /// string is properly null terminated.
- ///
- const char *getName() const {
- // We know that this is embedded into a StringMapEntry, and it knows how to
- // efficiently find the string.
- return llvm::StringMapEntry<IdentifierInfo>::
- GetStringMapEntryFromValue(*this).getKeyData();
- }
-
- /// getLength - Efficiently return the length of this identifier info.
- ///
- unsigned getLength() const {
- return llvm::StringMapEntry<IdentifierInfo>::
- GetStringMapEntryFromValue(*this).getKeyLength();
- }
-
- /// hasMacroDefinition - Return true if this identifier is #defined to some
- /// other value.
- bool hasMacroDefinition() const {
- return HasMacro;
- }
- void setHasMacroDefinition(bool Val) { HasMacro = Val; }
-
- /// get/setTokenID - If this is a source-language token (e.g. 'for'), this API
- /// can be used to cause the lexer to map identifiers to source-language
- /// tokens.
- tok::TokenKind getTokenID() const { return TokenID; }
- void setTokenID(tok::TokenKind ID) { TokenID = ID; }
-
- /// getPPKeywordID - Return the preprocessor keyword ID for this identifier.
- /// For example, "define" will return tok::pp_define.
- tok::PPKeywordKind getPPKeywordID() const;
-
- /// getObjCKeywordID - Return the Objective-C keyword ID for the this
- /// identifier. For example, 'class' will return tok::objc_class if ObjC is
- /// enabled.
- tok::ObjCKeywordKind getObjCKeywordID() const { return ObjCID; }
- void setObjCKeywordID(tok::ObjCKeywordKind ID) { ObjCID = ID; }
-
- /// getBuiltinID - Return a value indicating whether this is a builtin
- /// function. 0 is not-built-in. 1 is builtin-for-some-nonprimary-target.
- /// 2+ are specific builtin functions.
- unsigned getBuiltinID() const { return BuiltinID; }
- void setBuiltinID(unsigned ID) {
- BuiltinID = ID;
- assert(BuiltinID == ID && "ID too large for field!");
- }
-
- /// isNonPortableBuiltin - Return true if this identifier corresponds to a
- /// builtin on some other target, but isn't one on this target, or if it is on
- /// the target but not on another, or if it is on both but it differs somehow
- /// in behavior.
- bool isNonPortableBuiltin() const { return IsNonPortableBuiltin; }
- void setNonPortableBuiltin(bool Val) { IsNonPortableBuiltin = Val; }
-
- /// get/setExtension - Initialize information about whether or not this
- /// language token is an extension. This controls extension warnings, and is
- /// only valid if a custom token ID is set.
- bool isExtensionToken() const { return IsExtension; }
- void setIsExtensionToken(bool Val) { IsExtension = Val; }
-
- /// setIsPoisoned - Mark this identifier as poisoned. After poisoning, the
- /// Preprocessor will emit an error every time this token is used.
- void setIsPoisoned(bool Value = true) { IsPoisoned = Value; }
-
- /// isPoisoned - Return true if this token has been poisoned.
- bool isPoisoned() const { return IsPoisoned; }
-
- /// setIsOtherTargetMacro/isOtherTargetMacro control whether this identifier
- /// is seen as being a macro on some other target.
- void setIsOtherTargetMacro(bool Val = true) { IsOtherTargetMacro = Val; }
- bool isOtherTargetMacro() const { return IsOtherTargetMacro; }
-
- /// isCPlusPlusOperatorKeyword/setIsCPlusPlusOperatorKeyword controls whether
- /// this identifier is a C++ alternate representation of an operator.
- void setIsCPlusplusOperatorKeyword(bool Val = true)
- { IsCPPOperatorKeyword = Val; }
- bool isCPlusPlusOperatorKeyword() const { return IsCPPOperatorKeyword; }
-
- /// getFETokenInfo/setFETokenInfo - The language front-end is allowed to
- /// associate arbitrary metadata with this token.
- template<typename T>
- T *getFETokenInfo() const { return static_cast<T*>(FETokenInfo); }
- void setFETokenInfo(void *T) { FETokenInfo = T; }
-};
-
-/// IdentifierTable - This table implements an efficient mapping from strings to
-/// IdentifierInfo nodes. It has no other purpose, but this is an
-/// extremely performance-critical piece of the code, as each occurrance of
-/// every identifier goes through here when lexed.
-class IdentifierTable {
- // Shark shows that using MallocAllocator is *much* slower than using this
- // BumpPtrAllocator!
- typedef llvm::StringMap<IdentifierInfo, llvm::BumpPtrAllocator> HashTableTy;
- HashTableTy HashTable;
-public:
- /// IdentifierTable ctor - Create the identifier table, populating it with
- /// info about the language keywords for the language specified by LangOpts.
- IdentifierTable(const LangOptions &LangOpts);
-
- /// get - Return the identifier token info for the specified named identifier.
- ///
- IdentifierInfo &get(const char *NameStart, const char *NameEnd) {
- return HashTable.GetOrCreateValue(NameStart, NameEnd).getValue();
- }
-
- IdentifierInfo &get(const char *Name) {
- return get(Name, Name+strlen(Name));
- }
- IdentifierInfo &get(const std::string &Name) {
- // Don't use c_str() here: no need to be null terminated.
- const char *NameBytes = &Name[0];
- return get(NameBytes, NameBytes+Name.size());
- }
-
- typedef HashTableTy::const_iterator iterator;
- typedef HashTableTy::const_iterator const_iterator;
-
- iterator begin() const { return HashTable.begin(); }
- iterator end() const { return HashTable.end(); }
-
- /// PrintStats - Print some statistics to stderr that indicate how well the
- /// hashing is doing.
- void PrintStats() const;
-private:
- void AddKeywords(const LangOptions &LangOpts);
-};
-
-/// Selector - This smart pointer class efficiently represents Objective-C
-/// method names. This class will either point to an IdentifierInfo or a
-/// MultiKeywordSelector (which is private). This enables us to optimize
-/// selectors that no arguments and selectors that take 1 argument, which
-/// accounts for 78% of all selectors in Cocoa.h.
-class Selector {
- enum IdentifierInfoFlag {
- // MultiKeywordSelector = 0.
- ZeroArg = 0x1,
- OneArg = 0x2,
- ArgFlags = ZeroArg|OneArg
- };
- uintptr_t InfoPtr; // a pointer to the MultiKeywordSelector or IdentifierInfo.
-
- Selector(IdentifierInfo *II, unsigned nArgs) {
- InfoPtr = reinterpret_cast<uintptr_t>(II);
- assert((InfoPtr & ArgFlags) == 0 &&"Insufficiently aligned IdentifierInfo");
- assert(nArgs < 2 && "nArgs not equal to 0/1");
- InfoPtr |= nArgs+1;
- }
- Selector(MultiKeywordSelector *SI) {
- InfoPtr = reinterpret_cast<uintptr_t>(SI);
- assert((InfoPtr & ArgFlags) == 0 &&"Insufficiently aligned IdentifierInfo");
- }
- Selector(intptr_t V) : InfoPtr(V) {}
-public:
- friend class SelectorTable; // only the SelectorTable can create these.
-
- IdentifierInfo *getAsIdentifierInfo() const {
- if (getIdentifierInfoFlag())
- return reinterpret_cast<IdentifierInfo *>(InfoPtr & ~ArgFlags);
- return 0;
- }
- unsigned getIdentifierInfoFlag() const {
- return InfoPtr & ArgFlags;
- }
- /// operator==/!= - Indicate whether the specified selectors are identical.
- bool operator==(const Selector &RHS) const {
- return InfoPtr == RHS.InfoPtr;
- }
- bool operator!=(const Selector &RHS) const {
- return InfoPtr != RHS.InfoPtr;
- }
- void *getAsOpaquePtr() const {
- return reinterpret_cast<void*>(InfoPtr);
- }
- // Predicates to identify the selector type.
- bool isKeywordSelector() const {
- return getIdentifierInfoFlag() != ZeroArg;
- }
- bool isUnarySelector() const {
- return getIdentifierInfoFlag() == ZeroArg;
- }
- unsigned getNumArgs() const;
- IdentifierInfo *getIdentifierInfoForSlot(unsigned argIndex) const;
-
- /// getName - Derive the full selector name (e.g. "foo:bar:") and return it.
- ///
- std::string getName() const;
-
- static Selector getEmptyMarker() {
- return Selector(uintptr_t(-1));
- }
- static Selector getTombstoneMarker() {
- return Selector(uintptr_t(-2));
- }
-};
-
-/// SelectorTable - This table allows us to fully hide how we implement
-/// multi-keyword caching.
-class SelectorTable {
- void *Impl; // Actually a FoldingSet<MultiKeywordSelector>*
- SelectorTable(const SelectorTable&); // DISABLED: DO NOT IMPLEMENT
- void operator=(const SelectorTable&); // DISABLED: DO NOT IMPLEMENT
-public:
- SelectorTable();
- ~SelectorTable();
-
- /// getSelector - This can create any sort of selector. NumArgs indicates
- /// whether this is a no argument selector "foo", a single argument selector
- /// "foo:" or multi-argument "foo:bar:".
- Selector getSelector(unsigned NumArgs, IdentifierInfo **IIV);
-
- Selector getUnarySelector(IdentifierInfo *ID) {
- return Selector(ID, 1);
- }
- Selector getNullarySelector(IdentifierInfo *ID) {
- return Selector(ID, 0);
- }
-};
-
-} // end namespace clang
-
-
-/// Define DenseMapInfo so that Selectors can be used as keys in DenseMap and
-/// DenseSets.
-namespace llvm {
-template <>
-struct DenseMapInfo<clang::Selector> {
- static inline clang::Selector getEmptyKey() {
- return clang::Selector::getEmptyMarker();
- }
- static inline clang::Selector getTombstoneKey() {
- return clang::Selector::getTombstoneMarker();
- }
-
- static unsigned getHashValue(clang::Selector S);
-
- static bool isEqual(clang::Selector LHS, clang::Selector RHS) {
- return LHS == RHS;
- }
-
- static bool isPod() { return true; }
-};
-
-} // end namespace llvm
-
-#endif
Modified: cfe/trunk/include/clang/Lex/Preprocessor.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/Preprocessor.h?rev=42730&r1=42729&r2=42730&view=diff
==============================================================================
--- cfe/trunk/include/clang/Lex/Preprocessor.h (original)
+++ cfe/trunk/include/clang/Lex/Preprocessor.h Sun Oct 7 03:58:51 2007
@@ -14,9 +14,9 @@
#ifndef LLVM_CLANG_LEX_PREPROCESSOR_H
#define LLVM_CLANG_LEX_PREPROCESSOR_H
-#include "clang/Lex/IdentifierTable.h"
#include "clang/Lex/Lexer.h"
#include "clang/Lex/MacroExpander.h"
+#include "clang/Basic/IdentifierTable.h"
#include "clang/Basic/SourceLocation.h"
#include "llvm/ADT/DenseMap.h"
Modified: cfe/trunk/include/clang/Parse/Action.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Action.h?rev=42730&r1=42729&r2=42730&view=diff
==============================================================================
--- cfe/trunk/include/clang/Parse/Action.h (original)
+++ cfe/trunk/include/clang/Parse/Action.h Sun Oct 7 03:58:51 2007
@@ -14,9 +14,9 @@
#ifndef LLVM_CLANG_PARSE_ACTION_H
#define LLVM_CLANG_PARSE_ACTION_H
+#include "clang/Basic/IdentifierTable.h"
#include "clang/Basic/SourceLocation.h"
#include "clang/Basic/TokenKinds.h"
-#include "clang/Lex/IdentifierTable.h" // FIXME: should be in Basic, not Lex.
namespace clang {
// Semantic.
More information about the cfe-commits
mailing list