Skip to content

Commit

Permalink
[cherry-pick stable/20230725] [Modules] textual headers in submodules…
Browse files Browse the repository at this point in the history
… never resolve their `use`s

llvm#69651
rdar://117227965
  • Loading branch information
git apple-llvm automerger authored and ian-twilightcoder committed Oct 22, 2023
1 parent 8a19e13 commit 492c174
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 6 deletions.
13 changes: 7 additions & 6 deletions clang/lib/Lex/ModuleMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1408,16 +1408,17 @@ bool ModuleMap::resolveExports(Module *Mod, bool Complain) {
}

bool ModuleMap::resolveUses(Module *Mod, bool Complain) {
auto Unresolved = std::move(Mod->UnresolvedDirectUses);
Mod->UnresolvedDirectUses.clear();
auto *Top = Mod->getTopLevelModule();
auto Unresolved = std::move(Top->UnresolvedDirectUses);
Top->UnresolvedDirectUses.clear();
for (auto &UDU : Unresolved) {
Module *DirectUse = resolveModuleId(UDU, Mod, Complain);
Module *DirectUse = resolveModuleId(UDU, Top, Complain);
if (DirectUse)
Mod->DirectUses.push_back(DirectUse);
Top->DirectUses.push_back(DirectUse);
else
Mod->UnresolvedDirectUses.push_back(UDU);
Top->UnresolvedDirectUses.push_back(UDU);
}
return !Mod->UnresolvedDirectUses.empty();
return !Top->UnresolvedDirectUses.empty();
}

bool ModuleMap::resolveConflicts(Module *Mod, bool Complain) {
Expand Down
31 changes: 31 additions & 0 deletions clang/test/Modules/no-undeclared-includes.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// RUN: rm -rf %t
// RUN: split-file %s %t
// RUN: %clang_cc1 -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -I %t %t/no-undeclared-includes.c -verify

//--- no-undeclared-includes.c
// expected-no-diagnostics
#include <assert.h>

//--- assert.h
#include <base.h>

//--- base.h
#ifndef base_h
#define base_h



#endif /* base_h */

//--- module.modulemap
module cstd [system] [no_undeclared_includes] {
use base
module assert {
textual header "assert.h"
}
}

module base [system] {
header "base.h"
export *
}

0 comments on commit 492c174

Please sign in to comment.