Working on (de-)serialization right now.<br><br><div class="gmail_quote">On Wed, Aug 29, 2012 at 2:20 AM, Alexander Kornienko <span dir="ltr"><<a href="mailto:alexfh@google.com" target="_blank">alexfh@google.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: alexfh<br>
Date: Tue Aug 28 19:20:03 2012<br>
New Revision: 162810<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=162810&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=162810&view=rev</a><br>
Log:<br>
Keep history of macro definitions and #undefs<br>
<br>
Summary:<br>
Summary: Keep history of macro definitions and #undefs with corresponding source locations, so that we can later find out all macros active in a specified source location. We don't save the history in PCH (no need currently). Memory overhead is about sizeof(void*)*3*<number of macro definitions and #undefs>+<in-memory size of all #undef'd macros><br>

<br>
I've run a test on a file composed of 109 .h files from boost 1.49 on x86-64 linux.<br>
Stats before this patch:<br>
*** Preprocessor Stats:<br>
73222 directives found:<br>
  19171 #define.<br>
  4345 #undef.<br>
  #include/#include_next/#import:<br>
    5233 source files entered.<br>
    27 max include stack depth<br>
  19210 #if/#ifndef/#ifdef.<br>
  2384 #else/#elif.<br>
  6891 #endif.<br>
  408 #pragma.<br>
14466 #if/#ifndef#ifdef regions skipped<br>
80023/451669/1270 obj/fn/builtin macros expanded, 85724 on the fast path.<br>
127145 token paste (##) operations performed, 11008 on the fast path.<br>
<br>
Preprocessor Memory: 5874615B total<br>
  BumpPtr: 4399104<br>
  Macro Expanded Tokens: 417768<br>
  Predefines Buffer: 8135<br>
  Macros: 1048576<br>
  #pragma push_macro Info: 0<br>
  Poison Reasons: 1024<br>
  Comment Handlers: 8<br>
<br>
Stats with this patch:<br>
...<br>
Preprocessor Memory: 7541687B total<br>
  BumpPtr: 6066176<br>
  Macro Expanded Tokens: 417768<br>
  Predefines Buffer: 8135<br>
  Macros: 1048576<br>
  #pragma push_macro Info: 0<br>
  Poison Reasons: 1024<br>
  Comment Handlers: 8<br>
<br>
In my test increase in memory usage is about 1.7Mb, which is ~28% of initial preprocessor's memory usage and about 0.8% of clang's total VMM allocation.<br>
<br>
As for CPU overhead, it should only be noticeable when iterating over all macros, and should mostly consist of couple extra dereferences and one comparison per macro + skipping of #undef'd macros. It's less trivial to measure, though, as the preprocessor consumes a very small fraction of compilation time.<br>

<br>
<br>
Reviewers: doug.gregor, klimek, rsmith, djasper<br>
<br>
Reviewed By: doug.gregor<br>
<br>
CC: cfe-commits, chandlerc<br>
<br>
Differential Revision: <a href="http://llvm-reviews.chandlerc.com/D28" target="_blank">http://llvm-reviews.chandlerc.com/D28</a><br>
<br>
Modified:<br>
    cfe/trunk/include/clang/Lex/MacroInfo.h<br>
    cfe/trunk/include/clang/Lex/Preprocessor.h<br>
    cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp<br>
    cfe/trunk/lib/Lex/MacroInfo.cpp<br>
    cfe/trunk/lib/Lex/PPDirectives.cpp<br>
    cfe/trunk/lib/Lex/PPMacroExpansion.cpp<br>
    cfe/trunk/lib/Lex/Pragma.cpp<br>
    cfe/trunk/lib/Sema/SemaCodeComplete.cpp<br>
    cfe/trunk/lib/Serialization/ASTWriter.cpp<br>
<br>
Modified: cfe/trunk/include/clang/Lex/MacroInfo.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/MacroInfo.h?rev=162810&r1=162809&r2=162810&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/MacroInfo.h?rev=162810&r1=162809&r2=162810&view=diff</a><br>

==============================================================================<br>
--- cfe/trunk/include/clang/Lex/MacroInfo.h (original)<br>
+++ cfe/trunk/include/clang/Lex/MacroInfo.h Tue Aug 28 19:20:03 2012<br>
@@ -32,6 +32,12 @@<br>
   SourceLocation Location;<br>
   /// EndLocation - The location of the last token in the macro.<br>
   SourceLocation EndLocation;<br>
+  /// \brief The location where the macro was #undef'd, or an invalid location<br>
+  /// for macros that haven't been undefined.<br>
+  SourceLocation UndefLocation;<br>
+  /// \brief Previous definition, the identifier of this macro was defined to,<br>
+  /// or NULL.<br>
+  MacroInfo *PreviousDefinition;<br>
<br>
   /// Arguments - The list of arguments for a function-like macro.  This can be<br>
   /// empty, for, e.g. "#define X()".  In a C99-style variadic macro, this<br>
@@ -128,10 +134,31 @@<br>
   /// setDefinitionEndLoc - Set the location of the last token in the macro.<br>
   ///<br>
   void setDefinitionEndLoc(SourceLocation EndLoc) { EndLocation = EndLoc; }<br>
+<br>
   /// getDefinitionEndLoc - Return the location of the last token in the macro.<br>
   ///<br>
   SourceLocation getDefinitionEndLoc() const { return EndLocation; }<br>
-<br>
+<br>
+  /// \brief Set the location where macro was undefined. Can only be set once.<br>
+  void setUndefLoc(SourceLocation UndefLoc) {<br>
+    assert(UndefLocation.isInvalid() && "UndefLocation is already set!");<br>
+    assert(UndefLoc.isValid() && "Invalid UndefLoc!");<br>
+    UndefLocation = UndefLoc;<br>
+  }<br>
+<br>
+  /// \brief Get the location where macro was undefined.<br>
+  SourceLocation getUndefLoc() const { return UndefLocation; }<br>
+<br>
+  /// \brief Set previous definition of the macro with the same name. Can only<br>
+  /// be set once.<br>
+  void setPreviousDefinition(MacroInfo *PreviousDef) {<br>
+    assert(!PreviousDefinition && "PreviousDefiniton is already set!");<br>
+    PreviousDefinition = PreviousDef;<br>
+  }<br>
+<br>
+  /// \brief Get previous definition of the macro with the same name.<br>
+  MacroInfo *getPreviousDefinition() { return PreviousDefinition; }<br>
+<br>
   /// \brief Get length in characters of the macro definition.<br>
   unsigned getDefinitionLength(SourceManager &SM) const {<br>
     if (IsDefinitionLengthCached)<br>
<br>
Modified: cfe/trunk/include/clang/Lex/Preprocessor.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/Preprocessor.h?rev=162810&r1=162809&r2=162810&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/Preprocessor.h?rev=162810&r1=162809&r2=162810&view=diff</a><br>

==============================================================================<br>
--- cfe/trunk/include/clang/Lex/Preprocessor.h (original)<br>
+++ cfe/trunk/include/clang/Lex/Preprocessor.h Tue Aug 28 19:20:03 2012<br>
@@ -274,8 +274,9 @@<br>
   };<br>
   SmallVector<MacroExpandsInfo, 2> DelayedMacroExpandsCallbacks;<br>
<br>
-  /// Macros - For each IdentifierInfo with 'HasMacro' set, we keep a mapping<br>
-  /// to the actual definition of the macro.<br>
+  /// Macros - For each IdentifierInfo that was associated with a macro, we<br>
+  /// keep a mapping to the history of all macro definitions and #undefs in<br>
+  /// the reverse order (the latest one is in the head of the list).<br>
   llvm::DenseMap<IdentifierInfo*, MacroInfo*> Macros;<br>
<br>
   /// \brief Macros that we want to warn because they are not used at the end<br>
@@ -470,8 +471,10 @@<br>
   void setMacroInfo(IdentifierInfo *II, MacroInfo *MI,<br>
                     bool LoadedFromAST = false);<br>
<br>
-  /// macro_iterator/macro_begin/macro_end - This allows you to walk the current<br>
-  /// state of the macro table.  This visits every currently-defined macro.<br>
+  /// macro_iterator/macro_begin/macro_end - This allows you to walk the macro<br>
+  /// history table. Currently defined macros have<br>
+  /// IdentifierInfo::hasMacroDefinition() set and an empty<br>
+  /// MacroInfo::getUndefLoc() at the head of the list.<br>
   typedef llvm::DenseMap<IdentifierInfo*,<br>
                          MacroInfo*>::const_iterator macro_iterator;<br>
   macro_iterator macro_begin(bool IncludeExternalMacros = true) const;<br>
<br>
Modified: cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp?rev=162810&r1=162809&r2=162810&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp?rev=162810&r1=162809&r2=162810&view=diff</a><br>

==============================================================================<br>
--- cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp (original)<br>
+++ cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp Tue Aug 28 19:20:03 2012<br>
@@ -570,8 +570,12 @@<br>
   do PP.Lex(Tok);<br>
   while (Tok.isNot(tok::eof));<br>
<br>
-  SmallVector<id_macro_pair, 128><br>
-    MacrosByID(PP.macro_begin(), PP.macro_end());<br>
+  SmallVector<id_macro_pair, 128> MacrosByID;<br>
+  for (Preprocessor::macro_iterator I = PP.macro_begin(), E = PP.macro_end();<br>
+       I != E; ++I) {<br>
+    if (I->first->hasMacroDefinition())<br>
+      MacrosByID.push_back(id_macro_pair(I->first, I->second));<br>
+  }<br>
   llvm::array_pod_sort(MacrosByID.begin(), MacrosByID.end(), MacroIDCompare);<br>
<br>
   for (unsigned i = 0, e = MacrosByID.size(); i != e; ++i) {<br>
<br>
Modified: cfe/trunk/lib/Lex/MacroInfo.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/MacroInfo.cpp?rev=162810&r1=162809&r2=162810&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/MacroInfo.cpp?rev=162810&r1=162809&r2=162810&view=diff</a><br>

==============================================================================<br>
--- cfe/trunk/lib/Lex/MacroInfo.cpp (original)<br>
+++ cfe/trunk/lib/Lex/MacroInfo.cpp Tue Aug 28 19:20:03 2012<br>
@@ -15,44 +15,46 @@<br>
 #include "clang/Lex/Preprocessor.h"<br>
 using namespace clang;<br>
<br>
-MacroInfo::MacroInfo(SourceLocation DefLoc) : Location(DefLoc) {<br>
-  IsFunctionLike = false;<br>
-  IsC99Varargs = false;<br>
-  IsGNUVarargs = false;<br>
-  IsBuiltinMacro = false;<br>
-  IsFromAST = false;<br>
-  ChangedAfterLoad = false;<br>
-  IsDisabled = false;<br>
-  IsUsed = false;<br>
-  IsAllowRedefinitionsWithoutWarning = false;<br>
-  IsWarnIfUnused = false;<br>
-  IsDefinitionLengthCached = false;<br>
-  IsPublic = true;<br>
-<br>
-  ArgumentList = 0;<br>
-  NumArguments = 0;<br>
+MacroInfo::MacroInfo(SourceLocation DefLoc)<br>
+  : Location(DefLoc),<br>
+    PreviousDefinition(0),<br>
+    ArgumentList(0),<br>
+    NumArguments(0),<br>
+    IsDefinitionLengthCached(false),<br>
+    IsFunctionLike(false),<br>
+    IsC99Varargs(false),<br>
+    IsGNUVarargs(false),<br>
+    IsBuiltinMacro(false),<br>
+    IsFromAST(false),<br>
+    ChangedAfterLoad(false),<br>
+    IsDisabled(false),<br>
+    IsUsed(false),<br>
+    IsAllowRedefinitionsWithoutWarning(false),<br>
+    IsWarnIfUnused(false),<br>
+    IsPublic(true) {<br>
 }<br>
<br>
-MacroInfo::MacroInfo(const MacroInfo &MI, llvm::BumpPtrAllocator &PPAllocator) {<br>
-  Location = MI.Location;<br>
-  EndLocation = MI.EndLocation;<br>
-  ReplacementTokens = MI.ReplacementTokens;<br>
-  IsFunctionLike = MI.IsFunctionLike;<br>
-  IsC99Varargs = MI.IsC99Varargs;<br>
-  IsGNUVarargs = MI.IsGNUVarargs;<br>
-  IsBuiltinMacro = MI.IsBuiltinMacro;<br>
-  IsFromAST = MI.IsFromAST;<br>
-  ChangedAfterLoad = MI.ChangedAfterLoad;<br>
-  IsDisabled = MI.IsDisabled;<br>
-  IsUsed = MI.IsUsed;<br>
-  IsAllowRedefinitionsWithoutWarning = MI.IsAllowRedefinitionsWithoutWarning;<br>
-  IsWarnIfUnused = MI.IsWarnIfUnused;<br>
-  IsDefinitionLengthCached = MI.IsDefinitionLengthCached;<br>
-  DefinitionLength = MI.DefinitionLength;<br>
-  IsPublic = MI.IsPublic;<br>
-<br>
-  ArgumentList = 0;<br>
-  NumArguments = 0;<br>
+MacroInfo::MacroInfo(const MacroInfo &MI, llvm::BumpPtrAllocator &PPAllocator)<br>
+  : Location(MI.Location),<br>
+    EndLocation(MI.EndLocation),<br>
+    UndefLocation(MI.UndefLocation),<br>
+    PreviousDefinition(0),<br>
+    ArgumentList(0),<br>
+    NumArguments(0),<br>
+    ReplacementTokens(MI.ReplacementTokens),<br>
+    DefinitionLength(MI.DefinitionLength),<br>
+    IsDefinitionLengthCached(MI.IsDefinitionLengthCached),<br>
+    IsFunctionLike(MI.IsFunctionLike),<br>
+    IsC99Varargs(MI.IsC99Varargs),<br>
+    IsGNUVarargs(MI.IsGNUVarargs),<br>
+    IsBuiltinMacro(MI.IsBuiltinMacro),<br>
+    IsFromAST(MI.IsFromAST),<br>
+    ChangedAfterLoad(MI.ChangedAfterLoad),<br>
+    IsDisabled(MI.IsDisabled),<br>
+    IsUsed(MI.IsUsed),<br>
+    IsAllowRedefinitionsWithoutWarning(MI.IsAllowRedefinitionsWithoutWarning),<br>
+    IsWarnIfUnused(MI.IsWarnIfUnused),<br>
+    IsPublic(MI.IsPublic) {<br>
   setArgumentList(MI.ArgumentList, MI.NumArguments, PPAllocator);<br>
 }<br>
<br>
<br>
Modified: cfe/trunk/lib/Lex/PPDirectives.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPDirectives.cpp?rev=162810&r1=162809&r2=162810&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPDirectives.cpp?rev=162810&r1=162809&r2=162810&view=diff</a><br>

==============================================================================<br>
--- cfe/trunk/lib/Lex/PPDirectives.cpp (original)<br>
+++ cfe/trunk/lib/Lex/PPDirectives.cpp Tue Aug 28 19:20:03 2012<br>
@@ -1849,7 +1849,7 @@<br>
   MI->setDefinitionEndLoc(LastTok.getLocation());<br>
<br>
   // Finally, if this identifier already had a macro defined for it, verify that<br>
-  // the macro bodies are identical and free the old definition.<br>
+  // the macro bodies are identical, and issue diagnostics if they are not.<br>
   if (MacroInfo *OtherMI = getMacroInfo(MacroNameTok.getIdentifierInfo())) {<br>
     // It is very common for system headers to have tons of macro redefinitions<br>
     // and for warnings to be disabled in system headers.  If this is the case,<br>
@@ -1870,7 +1870,6 @@<br>
     }<br>
     if (OtherMI->isWarnIfUnused())<br>
       WarnUnusedMacroLocs.erase(OtherMI->getDefinitionLoc());<br>
-    ReleaseMacroInfo(OtherMI);<br>
   }<br>
<br>
   setMacroInfo(MacroNameTok.getIdentifierInfo(), MI);<br>
@@ -1921,9 +1920,11 @@<br>
   if (MI->isWarnIfUnused())<br>
     WarnUnusedMacroLocs.erase(MI->getDefinitionLoc());<br>
<br>
-  // Free macro definition.<br>
-  ReleaseMacroInfo(MI);<br>
-  setMacroInfo(MacroNameTok.getIdentifierInfo(), 0);<br>
+  MI->setUndefLoc(MacroNameTok.getLocation());<br>
+  IdentifierInfo *II = MacroNameTok.getIdentifierInfo();<br>
+  II->setHasMacroDefinition(false);<br>
+  if (II->isFromAST())<br>
+    II->setChangedSinceDeserialization();<br>
 }<br>
<br>
<br>
<br>
Modified: cfe/trunk/lib/Lex/PPMacroExpansion.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPMacroExpansion.cpp?rev=162810&r1=162809&r2=162810&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPMacroExpansion.cpp?rev=162810&r1=162809&r2=162810&view=diff</a><br>

==============================================================================<br>
--- cfe/trunk/lib/Lex/PPMacroExpansion.cpp (original)<br>
+++ cfe/trunk/lib/Lex/PPMacroExpansion.cpp Tue Aug 28 19:20:03 2012<br>
@@ -33,15 +33,15 @@<br>
<br>
 MacroInfo *Preprocessor::getInfoForMacro(IdentifierInfo *II) const {<br>
   assert(II->hasMacroDefinition() && "Identifier is not a macro!");<br>
-<br>
-  llvm::DenseMap<IdentifierInfo*, MacroInfo*>::const_iterator Pos<br>
-    = Macros.find(II);<br>
+<br>
+  macro_iterator Pos = Macros.find(II);<br>
   if (Pos == Macros.end()) {<br>
     // Load this macro from the external source.<br>
     getExternalSource()->LoadMacroDefinition(II);<br>
     Pos = Macros.find(II);<br>
   }<br>
   assert(Pos != Macros.end() && "Identifier macro info is missing!");<br>
+  assert(Pos->second->getUndefLoc().isInvalid() && "Macro is undefined!");<br>
   return Pos->second;<br>
 }<br>
<br>
@@ -49,17 +49,12 @@<br>
 ///<br>
 void Preprocessor::setMacroInfo(IdentifierInfo *II, MacroInfo *MI,<br>
                                 bool LoadedFromAST) {<br>
-  if (MI) {<br>
-    Macros[II] = MI;<br>
-    II->setHasMacroDefinition(true);<br>
-    if (II->isFromAST() && !LoadedFromAST)<br>
-      II->setChangedSinceDeserialization();<br>
-  } else if (II->hasMacroDefinition()) {<br>
-    Macros.erase(II);<br>
-    II->setHasMacroDefinition(false);<br>
-    if (II->isFromAST() && !LoadedFromAST)<br>
-      II->setChangedSinceDeserialization();<br>
-  }<br>
+  assert(MI && "MacroInfo should be non-zero!");<br>
+  MI->setPreviousDefinition(Macros[II]);<br>
+  Macros[II] = MI;<br>
+  II->setHasMacroDefinition(true);<br>
+  if (II->isFromAST() && !LoadedFromAST)<br>
+    II->setChangedSinceDeserialization();<br>
 }<br>
<br>
 /// RegisterBuiltinMacro - Register the specified identifier in the identifier<br>
<br>
Modified: cfe/trunk/lib/Lex/Pragma.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Pragma.cpp?rev=162810&r1=162809&r2=162810&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Pragma.cpp?rev=162810&r1=162809&r2=162810&view=diff</a><br>

==============================================================================<br>
--- cfe/trunk/lib/Lex/Pragma.cpp (original)<br>
+++ cfe/trunk/lib/Lex/Pragma.cpp Tue Aug 28 19:20:03 2012<br>
@@ -733,12 +733,10 @@<br>
   llvm::DenseMap<IdentifierInfo*, std::vector<MacroInfo*> >::iterator iter =<br>
     PragmaPushMacroInfo.find(IdentInfo);<br>
   if (iter != PragmaPushMacroInfo.end()) {<br>
-    // Release the MacroInfo currently associated with IdentInfo.<br>
-    MacroInfo *CurrentMI = getMacroInfo(IdentInfo);<br>
-    if (CurrentMI) {<br>
+    // Forget the MacroInfo currently associated with IdentInfo.<br>
+    if (MacroInfo *CurrentMI = getMacroInfo(IdentInfo)) {<br>
       if (CurrentMI->isWarnIfUnused())<br>
         WarnUnusedMacroLocs.erase(CurrentMI->getDefinitionLoc());<br>
-      ReleaseMacroInfo(CurrentMI);<br>
     }<br>
<br>
     // Get the MacroInfo we want to reinstall.<br>
<br>
Modified: cfe/trunk/lib/Sema/SemaCodeComplete.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCodeComplete.cpp?rev=162810&r1=162809&r2=162810&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCodeComplete.cpp?rev=162810&r1=162809&r2=162810&view=diff</a><br>

==============================================================================<br>
--- cfe/trunk/lib/Sema/SemaCodeComplete.cpp (original)<br>
+++ cfe/trunk/lib/Sema/SemaCodeComplete.cpp Tue Aug 28 19:20:03 2012<br>
@@ -2904,7 +2904,11 @@<br>
   for (Preprocessor::macro_iterator M = PP.macro_begin(),<br>
                                  MEnd = PP.macro_end();<br>
        M != MEnd; ++M) {<br>
-    Results.AddResult(Result(M->first,<br>
+    // FIXME: Eventually, we'd want to be able to look back to the macro<br>
+    // definition that was actually active at the point of code completion (even<br>
+    // if that macro has since been #undef'd).<br>
+    if (M->first->hasMacroDefinition())<br>
+      Results.AddResult(Result(M->first,<br>
                              getMacroUsagePriority(M->first->getName(),<br>
                                                    PP.getLangOpts(),<br>
                                                    TargetTypeIsPointer)));<br>
<br>
Modified: cfe/trunk/lib/Serialization/ASTWriter.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriter.cpp?rev=162810&r1=162809&r2=162810&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriter.cpp?rev=162810&r1=162809&r2=162810&view=diff</a><br>

==============================================================================<br>
--- cfe/trunk/lib/Serialization/ASTWriter.cpp (original)<br>
+++ cfe/trunk/lib/Serialization/ASTWriter.cpp Tue Aug 28 19:20:03 2012<br>
@@ -1677,10 +1677,12 @@<br>
   for (Preprocessor::macro_iterator I = PP.macro_begin(Chain == 0),<br>
                                     E = PP.macro_end(Chain == 0);<br>
        I != E; ++I) {<br>
-    const IdentifierInfo *Name = I->first;<br>
-    if (!IsModule || I->second->isPublic()) {<br>
-      MacroDefinitionsSeen.insert(Name);<br>
-      MacrosToEmit.push_back(std::make_pair(I->first, I->second));<br>
+    // FIXME: We'll need to store macro history in PCH.<br>
+    if (I->first->hasMacroDefinition()) {<br>
+      if (!IsModule || I->second->isPublic()) {<br>
+        MacroDefinitionsSeen.insert(I->first);<br>
+        MacrosToEmit.push_back(std::make_pair(I->first, I->second));<br>
+      }<br>
     }<br>
   }<br>
<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
</blockquote></div><br><br clear="all"><div>-- </div><div>Regards,</div><div>Alex</div>