[cfe-commits] r139734 - in /cfe/trunk: lib/Serialization/ASTWriter.cpp test/Modules/macros.c

Douglas Gregor dgregor at apple.com
Wed Sep 14 13:57:14 PDT 2011


Author: dgregor
Date: Wed Sep 14 15:57:14 2011
New Revision: 139734

URL: http://llvm.org/viewvc/llvm-project?rev=139734&view=rev
Log:
Revert my exported-macro hackery. Something is amiss

Modified:
    cfe/trunk/lib/Serialization/ASTWriter.cpp
    cfe/trunk/test/Modules/macros.c

Modified: cfe/trunk/lib/Serialization/ASTWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriter.cpp?rev=139734&r1=139733&r2=139734&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTWriter.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTWriter.cpp Wed Sep 14 15:57:14 2011
@@ -2223,26 +2223,24 @@
   /// that needs a full IdentifierInfo structure written into the hash
   /// table.
   bool isInterestingIdentifier(IdentifierInfo *II, MacroInfo *&Macro) {
+    Macro = 0;
+    
     if (II->isPoisoned() ||
         II->isExtensionToken() ||
         II->getObjCOrBuiltinID() ||
         II->getFETokenInfo<void>())
       return true;
 
-    return hasMacroDefinition(II, Macro);
-  }
-  
-  bool hasMacroDefinition(IdentifierInfo *II, MacroInfo *&Macro) {
     if (!II->hasMacroDefinition())
       return false;
     
     if (!IsModule)
       return true;
     
-    if (Macro || (Macro = PP.getMacroInfo(II)))
+    if ((Macro = PP.getMacroInfo(II)))
       return Macro->isExported();
     
-    return false;    
+    return false;
   }
 
 public:
@@ -2263,10 +2261,11 @@
     EmitKeyDataLength(raw_ostream& Out, IdentifierInfo* II, IdentID ID) {
     unsigned KeyLen = II->getLength() + 1;
     unsigned DataLen = 4; // 4 bytes for the persistent ID << 1
-    MacroInfo *Macro = 0;
+    MacroInfo *Macro;
     if (isInterestingIdentifier(II, Macro)) {
       DataLen += 2; // 2 bytes for builtin ID, flags
-      if (hasMacroDefinition(const_cast<IdentifierInfo *>(II), Macro))
+      if (II->hasMacroDefinition() &&
+          !PP.getMacroInfo(const_cast<IdentifierInfo *>(II))->isBuiltinMacro())
         DataLen += 4;
       for (IdentifierResolver::iterator D = IdentifierResolver::begin(II),
                                      DEnd = IdentifierResolver::end();
@@ -2291,7 +2290,7 @@
 
   void EmitData(raw_ostream& Out, IdentifierInfo* II,
                 IdentID ID, unsigned) {
-    MacroInfo *Macro = 0;
+    MacroInfo *Macro;
     if (!isInterestingIdentifier(II, Macro)) {
       clang::io::Emit32(Out, ID << 1);
       return;
@@ -2299,16 +2298,18 @@
 
     clang::io::Emit32(Out, (ID << 1) | 0x01);
     uint32_t Bits = 0;
-    bool HasMacroDefinition = hasMacroDefinition(II, Macro);
+    bool hasMacroDefinition 
+      = II->hasMacroDefinition() && 
+        (Macro || (Macro = PP.getMacroInfo(II))) && !Macro->isBuiltinMacro();
     Bits = (uint32_t)II->getObjCOrBuiltinID();
-    Bits = (Bits << 1) | unsigned(HasMacroDefinition);
+    Bits = (Bits << 1) | unsigned(hasMacroDefinition);
     Bits = (Bits << 1) | unsigned(II->isExtensionToken());
     Bits = (Bits << 1) | unsigned(II->isPoisoned());
     Bits = (Bits << 1) | unsigned(II->hasRevertedTokenIDToIdentifier());
     Bits = (Bits << 1) | unsigned(II->isCPlusPlusOperatorKeyword());
     clang::io::Emit16(Out, Bits);
 
-    if (HasMacroDefinition)
+    if (hasMacroDefinition)
       clang::io::Emit32(Out, Writer.getMacroOffset(II));
 
     // Emit the declaration IDs in reverse order, because the

Modified: cfe/trunk/test/Modules/macros.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/macros.c?rev=139734&r1=139733&r2=139734&view=diff
==============================================================================
--- cfe/trunk/test/Modules/macros.c (original)
+++ cfe/trunk/test/Modules/macros.c Wed Sep 14 15:57:14 2011
@@ -9,8 +9,6 @@
 #__export_macro__ INTEGER
 #__export_macro__ DOUBLE
 
-int (INTEGER);
-
 #else
 
 __import_module__ macros;
@@ -32,7 +30,4 @@
 
 #__export_macro__ WIBBLE // expected-error{{no macro named 'WIBBLE' to export}}
 
-void f() {
-  int i = INTEGER; // the value was exported, the macro was not.
-}
 #endif





More information about the cfe-commits mailing list