r215272 - [modules] Weaken an out-of-date assertion: an #undef can have no location if we

Richard Smith richard-llvm at metafoo.co.uk
Fri Aug 8 18:24:07 PDT 2014


Author: rsmith
Date: Fri Aug  8 20:24:07 2014
New Revision: 215272

URL: http://llvm.org/viewvc/llvm-project?rev=215272&view=rev
Log:
[modules] Weaken an out-of-date assertion: an #undef can have no location if we
imported it from a module when performing finalization before writing out
an AST file.

Added:
    cfe/trunk/test/Modules/Inputs/macros_bottom.h
Modified:
    cfe/trunk/include/clang/Lex/MacroInfo.h
    cfe/trunk/test/Modules/Inputs/macros_right_undef.h
    cfe/trunk/test/Modules/Inputs/macros_top.h
    cfe/trunk/test/Modules/Inputs/module.map
    cfe/trunk/test/Modules/macros.c

Modified: cfe/trunk/include/clang/Lex/MacroInfo.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/MacroInfo.h?rev=215272&r1=215271&r2=215272&view=diff
==============================================================================
--- cfe/trunk/include/clang/Lex/MacroInfo.h (original)
+++ cfe/trunk/include/clang/Lex/MacroInfo.h Fri Aug  8 20:24:07 2014
@@ -524,7 +524,7 @@ public:
                                unsigned ImportedFromModuleID = 0,
                                ArrayRef<unsigned> Overrides = None)
       : MacroDirective(MD_Undefine, UndefLoc, ImportedFromModuleID, Overrides) {
-    assert(UndefLoc.isValid() && "Invalid UndefLoc!");
+    assert((UndefLoc.isValid() || ImportedFromModuleID) && "Invalid UndefLoc!");
   }
 
   static bool classof(const MacroDirective *MD) {

Added: cfe/trunk/test/Modules/Inputs/macros_bottom.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/macros_bottom.h?rev=215272&view=auto
==============================================================================
--- cfe/trunk/test/Modules/Inputs/macros_bottom.h (added)
+++ cfe/trunk/test/Modules/Inputs/macros_bottom.h Fri Aug  8 20:24:07 2014
@@ -0,0 +1,3 @@
+ at import macros_right;
+
+extern TOP_DEF_RIGHT_UNDEF *TDRUp;

Modified: cfe/trunk/test/Modules/Inputs/macros_right_undef.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/macros_right_undef.h?rev=215272&r1=215271&r2=215272&view=diff
==============================================================================
--- cfe/trunk/test/Modules/Inputs/macros_right_undef.h (original)
+++ cfe/trunk/test/Modules/Inputs/macros_right_undef.h Fri Aug  8 20:24:07 2014
@@ -2,3 +2,4 @@
 
 @import macros_top;
 #undef TOP_OTHER_DEF_RIGHT_UNDEF
+#undef TOP_DEF_RIGHT_UNDEF

Modified: cfe/trunk/test/Modules/Inputs/macros_top.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/macros_top.h?rev=215272&r1=215271&r2=215272&view=diff
==============================================================================
--- cfe/trunk/test/Modules/Inputs/macros_top.h (original)
+++ cfe/trunk/test/Modules/Inputs/macros_top.h Fri Aug  8 20:24:07 2014
@@ -22,3 +22,4 @@
 #define TOP_OTHER_DEF_RIGHT_UNDEF void
 
 #define TOP_REDEF_IN_SUBMODULES 0
+#define TOP_DEF_RIGHT_UNDEF void

Modified: cfe/trunk/test/Modules/Inputs/module.map
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/module.map?rev=215272&r1=215271&r2=215272&view=diff
==============================================================================
--- cfe/trunk/test/Modules/Inputs/module.map (original)
+++ cfe/trunk/test/Modules/Inputs/module.map Fri Aug  8 20:24:07 2014
@@ -40,6 +40,10 @@ module macros_right {
     header "macros_right_undef.h"
   }
 }
+module macros_bottom { 
+  header "macros_bottom.h" 
+  export *
+}
 module macros { header "macros.h" }
 module macros_other { header "macros_other.h" }
 module category_top { header "category_top.h" }

Modified: cfe/trunk/test/Modules/macros.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/macros.c?rev=215272&r1=215271&r2=215272&view=diff
==============================================================================
--- cfe/trunk/test/Modules/macros.c (original)
+++ cfe/trunk/test/Modules/macros.c Fri Aug  8 20:24:07 2014
@@ -130,8 +130,14 @@ void test3() {
 #  error TOP_RIGHT_UNDEF should still be defined
 #endif
 
+ at import macros_bottom;
+
+TOP_DEF_RIGHT_UNDEF *TDRUf() { return TDRUp; }
+
 @import macros_right.undef;
 
+int TOP_DEF_RIGHT_UNDEF; // ok, no longer defined
+
 // FIXME: When macros_right.undef is built, macros_top is visible because
 // the state from building macros_right leaks through, so macros_right.undef
 // undefines macros_top's macro.





More information about the cfe-commits mailing list