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 | 11d0c4c0985fc37a844c0c3033db9f49291e2e1f (patch) | |
tree | 4437dd5182125f02765bdb5e19309bd3cacf0e1f /clang/lib/Basic | |
parent | 193e4c025efda046c3db4be1efb098a491767ff9 (diff) | |
download | bcm5719-llvm-11d0c4c0985fc37a844c0c3033db9f49291e2e1f.tar.gz bcm5719-llvm-11d0c4c0985fc37a844c0c3033db9f49291e2e1f.zip |
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".
llvm-svn: 58817
Diffstat (limited to 'clang/lib/Basic')
-rw-r--r-- | clang/lib/Basic/IdentifierTable.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/clang/lib/Basic/IdentifierTable.cpp b/clang/lib/Basic/IdentifierTable.cpp index 8f0387e99e6..e17f48ad3bd 100644 --- a/clang/lib/Basic/IdentifierTable.cpp +++ b/clang/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 |