Skip to content

Commit 4138367

Browse files
[modules] allow use of ptrauth module from no_undeclared_includes system modules (#88432)
Co-authored-by: Alex Lorenz <[email protected]>
1 parent ed128c7 commit 4138367

File tree

5 files changed

+20
-0
lines changed

5 files changed

+20
-0
lines changed

clang/lib/Basic/Module.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,10 @@ bool Module::directlyUses(const Module *Requested) {
305305
if (Requested->fullModuleNameIs({"_Builtin_stddef", "max_align_t"}) ||
306306
Requested->fullModuleNameIs({"_Builtin_stddef_wint_t"}))
307307
return true;
308+
// Darwin is allowed is to use our builtin 'ptrauth.h' and its accompanying
309+
// module.
310+
if (!Requested->Parent && Requested->Name == "ptrauth")
311+
return true;
308312

309313
if (NoUndeclaredIncludes)
310314
UndeclaredUses.insert(Requested);
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
module libc [no_undeclared_includes] {
2+
module stddef { header "stddef.h" export * }
3+
}
4+
5+
module ptrauth {
6+
header "ptrauth.h"
7+
export *
8+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
void foo();
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
@import ptrauth;
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// RUN: rm -rf %t
2+
// RUN: %clang_cc1 -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -I %S/Inputs/ptrauth-include-from-darwin %s -verify
3+
// expected-no-diagnostics
4+
5+
@import libc;
6+
void bar() { foo(); }

0 commit comments

Comments
 (0)