diff options
author | Douglas Gregor <dgregor@apple.com> | 2008-11-18 14:39:36 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2008-11-18 14:39:36 +0000 |
commit | e94ca9e4371c022329270436b3dd77adc4ddfa8f (patch) | |
tree | 88577be07029db31b21b7b0c8e3dbcf593dff4a4 /include/clang/Basic/IdentifierTable.h | |
parent | db0e15ae3e2b5e180541eec35e2bce54359ca7d8 (diff) |
Extend DeclarationName to support C++ overloaded operators, e.g.,
operator+, directly, using the same mechanism as all other special
names.
Removed the "special" identifiers for the overloaded operators from
the identifier table and IdentifierInfo data structure. IdentifierInfo
is back to representing only real identifiers.
Added a new Action, ActOnOperatorFunctionIdExpr, that builds an
expression from an parsed operator-function-id (e.g., "operator
+"). ActOnIdentifierExpr used to do this job, but
operator-function-ids are no longer represented by IdentifierInfo's.
Extended Declarator to store overloaded operator names.
Sema::GetNameForDeclarator now knows how to turn the operator
name into a DeclarationName for the overloaded operator.
Except for (perhaps) consolidating the functionality of
ActOnIdentifier, ActOnOperatorFunctionIdExpr, and
ActOnConversionFunctionExpr into a common routine that builds an
appropriate DeclRefExpr by looking up a DeclarationName, all of the
work on normalizing declaration names should be complete with this
commit.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59526 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Basic/IdentifierTable.h')
-rw-r--r-- | include/clang/Basic/IdentifierTable.h | 40 |
1 files changed, 12 insertions, 28 deletions
diff --git a/include/clang/Basic/IdentifierTable.h b/include/clang/Basic/IdentifierTable.h index 58ad133e3b..cbd27547ac 100644 --- a/include/clang/Basic/IdentifierTable.h +++ b/include/clang/Basic/IdentifierTable.h @@ -51,12 +51,11 @@ class IdentifierInfo { // First NUM_OBJC_KEYWORDS values are for Objective-C, the remaining values // are for builtins. unsigned ObjCOrBuiltinID :10; - unsigned OperatorID : 6; // C++ overloaded operator. 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 IsCPPOperatorKeyword : 1; // True if ident is a C++ operator keyword. - // 4 bits left in 32-bit word. + // 10 bits left in 32-bit word. void *FETokenInfo; // Managed by the language front-end. IdentifierInfo(const IdentifierInfo&); // NONCOPYABLE. void operator=(const IdentifierInfo&); // NONASSIGNABLE. @@ -123,16 +122,6 @@ public: && "ID too large for field!"); } - /// getOverloadedOperatorID - Get the C++ overloaded operator that - /// corresponds to this identifier. - OverloadedOperatorKind getOverloadedOperatorID() const { - return OverloadedOperatorKind(OperatorID); - } - void setOverloadedOperatorID(OverloadedOperatorKind ID) { - OperatorID = ID; - assert(OperatorID == (unsigned)ID && "ID too large for field!"); - } - /// 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. @@ -175,10 +164,6 @@ class IdentifierTable { typedef llvm::StringMap<IdentifierInfo, llvm::BumpPtrAllocator> HashTableTy; HashTableTy HashTable; - /// OverloadedOperators - Identifiers corresponding to each of the - /// overloadable operators in C++. - IdentifierInfo *OverloadedOperators[NUM_OVERLOADED_OPERATORS]; - public: /// IdentifierTable ctor - Create the identifier table, populating it with /// info about the language keywords for the language specified by LangOpts. @@ -199,11 +184,6 @@ public: return get(NameBytes, NameBytes+Name.size()); } - /// getOverloadedOperator - Retrieve the identifier - IdentifierInfo &getOverloadedOperator(OverloadedOperatorKind Op) { - return *OverloadedOperators[Op]; - } - typedef HashTableTy::const_iterator iterator; typedef HashTableTy::const_iterator const_iterator; @@ -217,7 +197,6 @@ public: void PrintStats() const; void AddKeywords(const LangOptions &LangOpts); - void AddOverloadedOperators(); /// Emit - Serialize this IdentifierTable to a bitstream. This should /// be called AFTER objects that externally reference the identifiers in the @@ -342,9 +321,9 @@ public: static SelectorTable* CreateAndRegister(llvm::Deserializer& D); }; -/// DeclarationNameExtra - Common base of the MultiKeywordSelector and -/// CXXSpecialName classes, both of which are private classes that can -/// be stored by the AST's DeclarationName class. +/// DeclarationNameExtra - Common base of the MultiKeywordSelector, +/// CXXSpecialName, and CXXOperatorIdName classes, all of which are +/// private classes that describe different kinds of names. class DeclarationNameExtra { public: /// ExtraKind - The kind of "extra" information stored in the @@ -354,12 +333,17 @@ public: CXXConstructor = 0, CXXDestructor, CXXConversionFunction, +#define OVERLOADED_OPERATOR(Name,Spelling,Token,Unary,Binary,MemberOnly) \ + CXXOperator##Name, +#include "clang/Basic/OperatorKinds.def" NUM_EXTRA_KINDS }; - /// ExtraKindOrNumArgs - Either the kind of C++ special name (if the - /// value is one of the CXX* enumerators of ExtraKind), in which - /// case the DeclarationNameExtra is also a CXXSpecialName, or + /// ExtraKindOrNumArgs - Either the kind of C++ special name or + /// operator-id (if the value is one of the CXX* enumerators of + /// ExtraKind), in which case the DeclarationNameExtra is also a + /// CXXSpecialName (for CXXConstructor, CXXDestructor, or + /// CXXConversionFunction) or CXXOperatorIdName, otherwise it is /// NUM_EXTRA_KINDS+NumArgs, where NumArgs is the number of /// arguments in the Objective-C selector, in which case the /// DeclarationNameExtra is also a MultiKeywordSelector. |