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
diff --git a/lib/Basic/IdentifierTable.cpp b/lib/Basic/IdentifierTable.cpp
index 8f0387e..e17f48a 100644
--- a/lib/Basic/IdentifierTable.cpp
+++ b/lib/Basic/IdentifierTable.cpp
@@ -28,6 +28,7 @@
 IdentifierInfo::IdentifierInfo() {
   TokenID = tok::identifier;
   ObjCOrBuiltinID = 0;
+  OperatorID = 0;
   HasMacro = false;
   IsExtension = false;
   IsPoisoned = false;
@@ -46,6 +47,7 @@
   // 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 @@
 #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