First step to fixing a long lived layering violation: this
moves the MacroInfo pointer to a side hash table (which currently 
lives in IdentifierTable.cpp).  This removes a pointer from 
Identifier info, but doesn't shrink it, as it requires a new bit 
be added.  This strange approach with the 'hasmacro' bit is needed
to not lose preprocessor performance.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@42722 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/Lex/IdentifierTable.cpp b/Lex/IdentifierTable.cpp
index fd64dec..b1c2c63 100644
--- a/Lex/IdentifierTable.cpp
+++ b/Lex/IdentifierTable.cpp
@@ -19,6 +19,24 @@
 #include "llvm/ADT/DenseMap.h"
 using namespace clang;
 
+static llvm::DenseMap<const IdentifierInfo*, MacroInfo*> Macros;
+
+MacroInfo *IdentifierInfo::getMacroInfoInternal() const {
+  return Macros[this];
+}
+void IdentifierInfo::setMacroInfo(MacroInfo *I) {
+  if (I == 0) {
+    if (HasMacro) {
+      Macros.erase(this);
+      HasMacro = false;
+    }
+  } else {
+    Macros[this] = I;
+    HasMacro = true;
+  }
+}
+
+
 //===----------------------------------------------------------------------===//
 // Token Implementation
 //===----------------------------------------------------------------------===//
@@ -40,11 +58,11 @@
 //===----------------------------------------------------------------------===//
 
 IdentifierInfo::IdentifierInfo() {
-  Macro = 0;
   TokenID = tok::identifier;
   PPID = tok::pp_not_keyword;
   ObjCID = tok::objc_not_keyword;
   BuiltinID = 0;
+  HasMacro = false;
   IsExtension = false;
   IsPoisoned = false;
   IsOtherTargetMacro = false;
@@ -54,7 +72,8 @@
 }
 
 IdentifierInfo::~IdentifierInfo() {
-  delete Macro;
+  if (MacroInfo *Macro = getMacroInfo())
+    delete Macro;
 }
 
 //===----------------------------------------------------------------------===//