Skip to content

Commit

Permalink
Revert "Revert "[cxxmodules] Allow submodules to contain headers whic…
Browse files Browse the repository at this point in the history
…h may be missing.""

ROOT 6.24 only requires C++11 and we want to continue supporting the
likes of GCC 4.8.5 (on CentOS 7) and GCC 5.4.0 (on Ubuntu 16.04).

This reverts commit 44a0c8d.
  • Loading branch information
hahnjo committed Oct 17, 2022
1 parent 44a0c8d commit dadead0
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 18 deletions.
5 changes: 4 additions & 1 deletion interpreter/cling/include/cling/std.modulemap
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ module "std" [system] {
header "csignal"
}
module "cstdalign" {
requires !cplusplus17
requires !cplusplus17, !header_existence
export *
header "cstdalign"
}
Expand Down Expand Up @@ -309,6 +309,7 @@ module "std" [system] {
header "string"
}
module "string_view" {
requires !header_existence
export *
textual header "string_view"
}
Expand Down Expand Up @@ -365,10 +366,12 @@ module "std" [system] {
header "vector"
}
module "codecvt" {
requires !header_existence
export *
header "codecvt"
}
module "cuchar" {
requires !header_existence
export *
header "cuchar"
}
Expand Down
26 changes: 14 additions & 12 deletions interpreter/cling/include/cling/std_msvc.modulemap
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ module "std" [system] {
header "atomic"
}
module "bit" {
requires cplusplus20
requires cplusplus20, !header_existence
export *
header "bit"
}
Expand Down Expand Up @@ -53,7 +53,7 @@ module "std" [system] {
header "cfloat"
}
module "charconv" {
requires cplusplus17
requires cplusplus17, !header_existence
export *
header "charconv"
}
Expand Down Expand Up @@ -86,7 +86,7 @@ module "std" [system] {
header "codecvt"
}
module "compare" {
requires cplusplus20
requires cplusplus20, !header_existence
export *
header "compare"
}
Expand All @@ -95,7 +95,7 @@ module "std" [system] {
header "complex"
}
module "concepts" {
requires cplusplus20
requires cplusplus20, !header_existence
export *
header "concepts"
}
Expand Down Expand Up @@ -172,12 +172,12 @@ module "std" [system] {
header "exception"
}
module "execution" {
requires cplusplus17
requires cplusplus17, !header_existence
export *
header "execution"
}
module "filesystem" {
requires cplusplus17
requires cplusplus17, !header_existence
export *
header "filesystem"
}
Expand Down Expand Up @@ -250,7 +250,7 @@ module "std" [system] {
header "memory"
}
module "memory_resource" {
requires cplusplus17
requires cplusplus17, !header_existence
export *
header "memory_resource"
}
Expand All @@ -263,7 +263,7 @@ module "std" [system] {
header "new"
}
module "numbers" {
requires cplusplus20
requires cplusplus20, !header_existence
export *
header "numbers"
}
Expand All @@ -272,7 +272,7 @@ module "std" [system] {
header "numeric"
}
module "optional" {
requires cplusplus17
requires cplusplus17, !header_existence
export *
header "optional"
}
Expand All @@ -289,7 +289,7 @@ module "std" [system] {
header "random"
}
module "ranges" {
requires cplusplus20
requires cplusplus20, !header_existence
export *
header "ranges"
}
Expand Down Expand Up @@ -338,7 +338,7 @@ module "std" [system] {
header "string"
}
module "string_view" {
requires cplusplus17
requires cplusplus17, !header_existence
export *
textual header "string_view"
}
Expand Down Expand Up @@ -391,7 +391,7 @@ module "std" [system] {
header "valarray"
}
module "variant" {
requires cplusplus17
requires cplusplus17, !header_existence
export *
header "variant"
}
Expand Down Expand Up @@ -484,10 +484,12 @@ module "std" [system] {
header "xstring"
}
module "xthreads.h" {
requires !header_existence
export *
textual header "xthreads.h"
}
module "xtimec.h" {
requires !header_existence
export *
textual header "xtimec.h"
}
Expand Down
14 changes: 9 additions & 5 deletions interpreter/llvm/src/tools/clang/lib/Basic/Module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ static bool isPlatformEnvironment(const TargetInfo &Target, StringRef Feature) {
/// Determine whether a translation unit built using the current
/// language options has the given feature.
static bool hasFeature(StringRef Feature, const LangOptions &LangOpts,
const TargetInfo &Target) {
const TargetInfo &Target, bool HasMissingHeaders) {
bool HasFeature = llvm::StringSwitch<bool>(Feature)
.Case("altivec", LangOpts.AltiVec)
.Case("blocks", LangOpts.Blocks)
Expand All @@ -121,6 +121,7 @@ static bool hasFeature(StringRef Feature, const LangOptions &LangOpts,
.Case("objc", LangOpts.ObjC)
.Case("objc_arc", LangOpts.ObjCAutoRefCount)
.Case("opencl", LangOpts.OpenCL)
.Case("header_existence", !HasMissingHeaders)
.Case("tls", Target.isTLSSupported())
.Case("zvector", LangOpts.ZVector)
.Default(Target.hasFeature(Feature) ||
Expand All @@ -144,14 +145,16 @@ bool Module::isAvailable(const LangOptions &LangOpts, const TargetInfo &Target,
ShadowingModule = Current->ShadowingModule;
return false;
}
bool HasMissingHeaders = !Current->MissingHeaders.empty();
for (unsigned I = 0, N = Current->Requirements.size(); I != N; ++I) {
if (hasFeature(Current->Requirements[I].first, LangOpts, Target) !=
Current->Requirements[I].second) {
if (hasFeature(Current->Requirements[I].first, LangOpts, Target,
HasMissingHeaders) !=
Current->Requirements[I].second) {
Req = Current->Requirements[I];
return false;
}
}
if (!Current->MissingHeaders.empty()) {
if (HasMissingHeaders) {
MissingHeader = Current->MissingHeaders.front();
return false;
}
Expand Down Expand Up @@ -279,7 +282,8 @@ void Module::addRequirement(StringRef Feature, bool RequiredState,
Requirements.push_back(Requirement(Feature, RequiredState));

// If this feature is currently available, we're done.
if (hasFeature(Feature, LangOpts, Target) == RequiredState)
if (hasFeature(Feature, LangOpts, Target, !MissingHeaders.empty()) ==
RequiredState)
return;

markUnavailable(/*MissingRequirement*/true);
Expand Down

0 comments on commit dadead0

Please sign in to comment.