Skip to content

Commit

Permalink
[modules] allow use of ptrauth module from no_undeclared_includes sys…
Browse files Browse the repository at this point in the history
…tem modules (#88432)

Co-authored-by: Alex Lorenz <arphaman@gmail.com>
  • Loading branch information
ian-twilightcoder and hyp committed Apr 13, 2024
1 parent ed128c7 commit 4138367
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 0 deletions.
4 changes: 4 additions & 0 deletions clang/lib/Basic/Module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module libc [no_undeclared_includes] {
module stddef { header "stddef.h" export * }
}

module ptrauth {
header "ptrauth.h"
export *
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
void foo();
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@import ptrauth;
6 changes: 6 additions & 0 deletions clang/test/Modules/ptrauth-include-from-darwin.m
Original file line number Diff line number Diff line change
@@ -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(); }

0 comments on commit 4138367

Please sign in to comment.