EricWF created this revision.

This patch attempts to fix llvm.org/PR31905. However I have no clue if this fix 
is correct; I simply stumbled upon it.

The fix is to remove the `_Builtin_stddef_max_align_t` module, making 
`__stddef_max_align_t.h` non-modular. This fixes the issue because including 
`<stddef.h>` no longer includes an modularized header, and therefore no longer 
performs the problematic `module.modulemap` search.

All of the modules tests pass after applying these changes, but it's possible 
the need for `_Builtin_stddef_max_align_t` is untested.


https://reviews.llvm.org/D32111

Files:
  lib/Basic/Module.cpp
  lib/Headers/module.modulemap
  test/Modules/Inputs/PR31905/my-project/module.modulemap
  test/Modules/Inputs/PR31905/my-project/my-header.h
  test/Modules/pr31905.cpp


Index: test/Modules/pr31905.cpp
===================================================================
--- /dev/null
+++ test/Modules/pr31905.cpp
@@ -0,0 +1,9 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: cp -R %S/Inputs/PR31905 %t/other-include
+// RUN: %clang_cc1 -std=c++11 -I%S/Inputs/PR31905/ -I%t/other-include 
-fmodules -fmodules-local-submodule-visibility \
+// RUN:    -fimplicit-module-maps -fmodules-cache-path=%t  -verify %s
+
+#include "my-project/my-header.h"
+
+int main() {} // expected-no-diagnostics
Index: test/Modules/Inputs/PR31905/my-project/my-header.h
===================================================================
--- /dev/null
+++ test/Modules/Inputs/PR31905/my-project/my-header.h
@@ -0,0 +1,4 @@
+#ifndef MY_HEADER_H
+#define MY_HEADER_H
+#include <stddef.h>
+#endif
Index: test/Modules/Inputs/PR31905/my-project/module.modulemap
===================================================================
--- /dev/null
+++ test/Modules/Inputs/PR31905/my-project/module.modulemap
@@ -0,0 +1,3 @@
+module my_project {
+  header "my-header.h"
+}
Index: lib/Headers/module.modulemap
===================================================================
--- lib/Headers/module.modulemap
+++ lib/Headers/module.modulemap
@@ -157,10 +157,6 @@
   }
 }
 
-module _Builtin_stddef_max_align_t [system] [extern_c] {
-  header "__stddef_max_align_t.h"
-}
-
 module opencl_c {
   requires opencl
   header "opencl-c.h"
Index: lib/Basic/Module.cpp
===================================================================
--- lib/Basic/Module.cpp
+++ lib/Basic/Module.cpp
@@ -184,10 +184,6 @@
     if (Requested->isSubModuleOf(Use))
       return true;
 
-  // Anyone is allowed to use our builtin stddef.h and its accompanying module.
-  if (!Requested->Parent && Requested->Name == "_Builtin_stddef_max_align_t")
-    return true;
-
   return false;
 }
 


Index: test/Modules/pr31905.cpp
===================================================================
--- /dev/null
+++ test/Modules/pr31905.cpp
@@ -0,0 +1,9 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: cp -R %S/Inputs/PR31905 %t/other-include
+// RUN: %clang_cc1 -std=c++11 -I%S/Inputs/PR31905/ -I%t/other-include -fmodules -fmodules-local-submodule-visibility \
+// RUN:    -fimplicit-module-maps -fmodules-cache-path=%t  -verify %s
+
+#include "my-project/my-header.h"
+
+int main() {} // expected-no-diagnostics
Index: test/Modules/Inputs/PR31905/my-project/my-header.h
===================================================================
--- /dev/null
+++ test/Modules/Inputs/PR31905/my-project/my-header.h
@@ -0,0 +1,4 @@
+#ifndef MY_HEADER_H
+#define MY_HEADER_H
+#include <stddef.h>
+#endif
Index: test/Modules/Inputs/PR31905/my-project/module.modulemap
===================================================================
--- /dev/null
+++ test/Modules/Inputs/PR31905/my-project/module.modulemap
@@ -0,0 +1,3 @@
+module my_project {
+  header "my-header.h"
+}
Index: lib/Headers/module.modulemap
===================================================================
--- lib/Headers/module.modulemap
+++ lib/Headers/module.modulemap
@@ -157,10 +157,6 @@
   }
 }
 
-module _Builtin_stddef_max_align_t [system] [extern_c] {
-  header "__stddef_max_align_t.h"
-}
-
 module opencl_c {
   requires opencl
   header "opencl-c.h"
Index: lib/Basic/Module.cpp
===================================================================
--- lib/Basic/Module.cpp
+++ lib/Basic/Module.cpp
@@ -184,10 +184,6 @@
     if (Requested->isSubModuleOf(Use))
       return true;
 
-  // Anyone is allowed to use our builtin stddef.h and its accompanying module.
-  if (!Requested->Parent && Requested->Name == "_Builtin_stddef_max_align_t")
-    return true;
-
   return false;
 }
 
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
  • [PATCH] D32111: [modules] At... Eric Fiselier via Phabricator via cfe-commits

Reply via email to