diff options
author | Douglas Gregor <dgregor@apple.com> | 2008-11-06 22:13:31 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2008-11-06 22:13:31 +0000 |
commit | 1cd1b1e987f5e2f060d7972b13d83239b36d77d6 (patch) | |
tree | 2776b50f5ad1ceafd1aae9a31001b6b1a3f9dd5d /lib/Basic/IdentifierTable.cpp | |
parent | 5142af38ed0dd2f592cbfa00fa6e2e14dd6cc516 (diff) |
Parsing, ASTs, and semantic analysis for the declaration of overloaded
operators in C++. Overloaded operators can be called directly via
their operator-function-ids, e.g., "operator+(foo, bar)", but we don't
yet implement the semantics of operator overloading to handle, e.g.,
"foo + bar".
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58817 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Basic/IdentifierTable.cpp')
-rw-r--r-- | lib/Basic/IdentifierTable.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/Basic/IdentifierTable.cpp b/lib/Basic/IdentifierTable.cpp index 8f0387e99e..e17f48ad3b 100644 --- a/lib/Basic/IdentifierTable.cpp +++ b/lib/Basic/IdentifierTable.cpp @@ -28,6 +28,7 @@ using namespace clang; IdentifierInfo::IdentifierInfo() { TokenID = tok::identifier; ObjCOrBuiltinID = 0; + OperatorID = 0; HasMacro = false; IsExtension = false; IsPoisoned = false; @@ -46,6 +47,7 @@ IdentifierTable::IdentifierTable(const LangOptions &LangOpts) // Populate the identifier table with info about keywords for the current // language. AddKeywords(LangOpts); + AddOverloadedOperators(); } // This cstor is intended to be used only for serialization. @@ -160,6 +162,15 @@ void IdentifierTable::AddKeywords(const LangOptions &LangOpts) { #include "clang/Basic/TokenKinds.def" } +/// AddOverloadedOperators - Register the name of all C++ overloadable +/// operators ("operator+", "operator[]", etc.) +void IdentifierTable::AddOverloadedOperators() { +#define OVERLOADED_OPERATOR(Name,Spelling,Token) \ + OverloadedOperators[OO_##Name] = &get(Spelling); \ + OverloadedOperators[OO_##Name]->setOverloadedOperatorID(OO_##Name); +#include "clang/Basic/OperatorKinds.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 |