[clang] allow use of ptrauth module from no_undeclared_includes system modules (PR #88432)
ian-twilightcoder wrote: Upstream from Apple, followup for https://github.com/llvm/llvm-project/pull/65996. Allows Apple's Darwin module to include ptrauth.h without declaring a `use`. https://github.com/llvm/llvm-project/pull/88432 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] allow use of ptrauth module from no_undeclared_includes system modules (PR #88432)
https://github.com/ian-twilightcoder updated https://github.com/llvm/llvm-project/pull/88432 >From 88da8be7ed10f1ee8e7e992fdd59dce52456b2ce Mon Sep 17 00:00:00 2001 From: Alex Lorenz Date: Thu, 9 Jul 2020 15:10:49 -0700 Subject: [PATCH] [modules] allow use of ptrauth module from no_undeclared_includes system modules --- clang/lib/Basic/Module.cpp| 4 .../Inputs/ptrauth-include-from-darwin/module.modulemap | 8 .../Modules/Inputs/ptrauth-include-from-darwin/ptrauth.h | 1 + .../Modules/Inputs/ptrauth-include-from-darwin/stddef.h | 1 + clang/test/Modules/ptrauth-include-from-darwin.m | 6 ++ 5 files changed, 20 insertions(+) create mode 100644 clang/test/Modules/Inputs/ptrauth-include-from-darwin/module.modulemap create mode 100644 clang/test/Modules/Inputs/ptrauth-include-from-darwin/ptrauth.h create mode 100644 clang/test/Modules/Inputs/ptrauth-include-from-darwin/stddef.h create mode 100644 clang/test/Modules/ptrauth-include-from-darwin.m diff --git a/clang/lib/Basic/Module.cpp b/clang/lib/Basic/Module.cpp index 256365d66bb907..bb212cde878826 100644 --- a/clang/lib/Basic/Module.cpp +++ b/clang/lib/Basic/Module.cpp @@ -305,6 +305,10 @@ bool Module::directlyUses(const Module *Requested) { if (Requested->fullModuleNameIs({"_Builtin_stddef", "max_align_t"}) || Requested->fullModuleNameIs({"_Builtin_stddef_wint_t"})) return true; + // Darwin is allowed is to use our builtin 'ptrauth.h' and its accompanying + // module. + if (!Requested->Parent && Requested->Name == "ptrauth") +return true; if (NoUndeclaredIncludes) UndeclaredUses.insert(Requested); diff --git a/clang/test/Modules/Inputs/ptrauth-include-from-darwin/module.modulemap b/clang/test/Modules/Inputs/ptrauth-include-from-darwin/module.modulemap new file mode 100644 index 00..741b9bb1efc54d --- /dev/null +++ b/clang/test/Modules/Inputs/ptrauth-include-from-darwin/module.modulemap @@ -0,0 +1,8 @@ +module libc [no_undeclared_includes] { + module stddef { header "stddef.h" export * } +} + +module ptrauth { + header "ptrauth.h" + export * +} diff --git a/clang/test/Modules/Inputs/ptrauth-include-from-darwin/ptrauth.h b/clang/test/Modules/Inputs/ptrauth-include-from-darwin/ptrauth.h new file mode 100644 index 00..c8620b64b2ceef --- /dev/null +++ b/clang/test/Modules/Inputs/ptrauth-include-from-darwin/ptrauth.h @@ -0,0 +1 @@ +void foo(); diff --git a/clang/test/Modules/Inputs/ptrauth-include-from-darwin/stddef.h b/clang/test/Modules/Inputs/ptrauth-include-from-darwin/stddef.h new file mode 100644 index 00..777a524fc67110 --- /dev/null +++ b/clang/test/Modules/Inputs/ptrauth-include-from-darwin/stddef.h @@ -0,0 +1 @@ +@import ptrauth; diff --git a/clang/test/Modules/ptrauth-include-from-darwin.m b/clang/test/Modules/ptrauth-include-from-darwin.m new file mode 100644 index 00..72b0c36e7cb7d3 --- /dev/null +++ b/clang/test/Modules/ptrauth-include-from-darwin.m @@ -0,0 +1,6 @@ +// RUN: rm -rf %t +// RUN: %clang_cc1 -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -I %S/Inputs/ptrauth-include-from-darwin %s -verify +// expected-no-diagnostics + +@import libc; +void bar() { foo(); } ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] allow use of ptrauth module from no_undeclared_includes system modules (PR #88432)
llvmbot wrote: @llvm/pr-subscribers-clang Author: Ian Anderson (ian-twilightcoder) Changes --- Full diff: https://github.com/llvm/llvm-project/pull/88432.diff 5 Files Affected: - (modified) clang/lib/Basic/Module.cpp (+4) - (added) clang/test/Modules/Inputs/ptrauth-include-from-darwin/module.modulemap (+8) - (added) clang/test/Modules/Inputs/ptrauth-include-from-darwin/ptrauth.h (+1) - (added) clang/test/Modules/Inputs/ptrauth-include-from-darwin/stddef.h (+1) - (added) clang/test/Modules/ptrauth-include-from-darwin.m (+6) ``diff diff --git a/clang/lib/Basic/Module.cpp b/clang/lib/Basic/Module.cpp index 256365d66bb907..bb212cde878826 100644 --- a/clang/lib/Basic/Module.cpp +++ b/clang/lib/Basic/Module.cpp @@ -305,6 +305,10 @@ bool Module::directlyUses(const Module *Requested) { if (Requested->fullModuleNameIs({"_Builtin_stddef", "max_align_t"}) || Requested->fullModuleNameIs({"_Builtin_stddef_wint_t"})) return true; + // Darwin is allowed is to use our builtin 'ptrauth.h' and its accompanying + // module. + if (!Requested->Parent && Requested->Name == "ptrauth") +return true; if (NoUndeclaredIncludes) UndeclaredUses.insert(Requested); diff --git a/clang/test/Modules/Inputs/ptrauth-include-from-darwin/module.modulemap b/clang/test/Modules/Inputs/ptrauth-include-from-darwin/module.modulemap new file mode 100644 index 00..741b9bb1efc54d --- /dev/null +++ b/clang/test/Modules/Inputs/ptrauth-include-from-darwin/module.modulemap @@ -0,0 +1,8 @@ +module libc [no_undeclared_includes] { + module stddef { header "stddef.h" export * } +} + +module ptrauth { + header "ptrauth.h" + export * +} diff --git a/clang/test/Modules/Inputs/ptrauth-include-from-darwin/ptrauth.h b/clang/test/Modules/Inputs/ptrauth-include-from-darwin/ptrauth.h new file mode 100644 index 00..c8620b64b2ceef --- /dev/null +++ b/clang/test/Modules/Inputs/ptrauth-include-from-darwin/ptrauth.h @@ -0,0 +1 @@ +void foo(); diff --git a/clang/test/Modules/Inputs/ptrauth-include-from-darwin/stddef.h b/clang/test/Modules/Inputs/ptrauth-include-from-darwin/stddef.h new file mode 100644 index 00..777a524fc67110 --- /dev/null +++ b/clang/test/Modules/Inputs/ptrauth-include-from-darwin/stddef.h @@ -0,0 +1 @@ +@import ptrauth; diff --git a/clang/test/Modules/ptrauth-include-from-darwin.m b/clang/test/Modules/ptrauth-include-from-darwin.m new file mode 100644 index 00..72b0c36e7cb7d3 --- /dev/null +++ b/clang/test/Modules/ptrauth-include-from-darwin.m @@ -0,0 +1,6 @@ +// RUN: rm -rf %t +// RUN: %clang_cc1 -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -I %S/Inputs/ptrauth-include-from-darwin %s -verify +// expected-no-diagnostics + +@import libc; +void bar() { foo(); } `` https://github.com/llvm/llvm-project/pull/88432 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] allow use of ptrauth module from no_undeclared_includes system modules (PR #88432)
https://github.com/ian-twilightcoder created https://github.com/llvm/llvm-project/pull/88432 None >From 43b007bfb184c6fdb5d802afca16af14e555b628 Mon Sep 17 00:00:00 2001 From: Alex Lorenz Date: Thu, 9 Jul 2020 15:10:49 -0700 Subject: [PATCH] allow use of ptrauth module from no_undeclared_includes system modules --- clang/lib/Basic/Module.cpp| 4 .../Inputs/ptrauth-include-from-darwin/module.modulemap | 8 .../Modules/Inputs/ptrauth-include-from-darwin/ptrauth.h | 1 + .../Modules/Inputs/ptrauth-include-from-darwin/stddef.h | 1 + clang/test/Modules/ptrauth-include-from-darwin.m | 6 ++ 5 files changed, 20 insertions(+) create mode 100644 clang/test/Modules/Inputs/ptrauth-include-from-darwin/module.modulemap create mode 100644 clang/test/Modules/Inputs/ptrauth-include-from-darwin/ptrauth.h create mode 100644 clang/test/Modules/Inputs/ptrauth-include-from-darwin/stddef.h create mode 100644 clang/test/Modules/ptrauth-include-from-darwin.m diff --git a/clang/lib/Basic/Module.cpp b/clang/lib/Basic/Module.cpp index 256365d66bb907..bb212cde878826 100644 --- a/clang/lib/Basic/Module.cpp +++ b/clang/lib/Basic/Module.cpp @@ -305,6 +305,10 @@ bool Module::directlyUses(const Module *Requested) { if (Requested->fullModuleNameIs({"_Builtin_stddef", "max_align_t"}) || Requested->fullModuleNameIs({"_Builtin_stddef_wint_t"})) return true; + // Darwin is allowed is to use our builtin 'ptrauth.h' and its accompanying + // module. + if (!Requested->Parent && Requested->Name == "ptrauth") +return true; if (NoUndeclaredIncludes) UndeclaredUses.insert(Requested); diff --git a/clang/test/Modules/Inputs/ptrauth-include-from-darwin/module.modulemap b/clang/test/Modules/Inputs/ptrauth-include-from-darwin/module.modulemap new file mode 100644 index 00..741b9bb1efc54d --- /dev/null +++ b/clang/test/Modules/Inputs/ptrauth-include-from-darwin/module.modulemap @@ -0,0 +1,8 @@ +module libc [no_undeclared_includes] { + module stddef { header "stddef.h" export * } +} + +module ptrauth { + header "ptrauth.h" + export * +} diff --git a/clang/test/Modules/Inputs/ptrauth-include-from-darwin/ptrauth.h b/clang/test/Modules/Inputs/ptrauth-include-from-darwin/ptrauth.h new file mode 100644 index 00..c8620b64b2ceef --- /dev/null +++ b/clang/test/Modules/Inputs/ptrauth-include-from-darwin/ptrauth.h @@ -0,0 +1 @@ +void foo(); diff --git a/clang/test/Modules/Inputs/ptrauth-include-from-darwin/stddef.h b/clang/test/Modules/Inputs/ptrauth-include-from-darwin/stddef.h new file mode 100644 index 00..777a524fc67110 --- /dev/null +++ b/clang/test/Modules/Inputs/ptrauth-include-from-darwin/stddef.h @@ -0,0 +1 @@ +@import ptrauth; diff --git a/clang/test/Modules/ptrauth-include-from-darwin.m b/clang/test/Modules/ptrauth-include-from-darwin.m new file mode 100644 index 00..72b0c36e7cb7d3 --- /dev/null +++ b/clang/test/Modules/ptrauth-include-from-darwin.m @@ -0,0 +1,6 @@ +// RUN: rm -rf %t +// RUN: %clang_cc1 -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -I %S/Inputs/ptrauth-include-from-darwin %s -verify +// expected-no-diagnostics + +@import libc; +void bar() { foo(); } ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits