Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions clang/include/clang/Basic/Module.h
Original file line number Diff line number Diff line change
Expand Up @@ -284,9 +284,10 @@ class alignas(8) Module {
/// found on the file system.
SmallVector<UnresolvedHeaderDirective, 1> MissingHeaders;

/// An individual requirement: a feature name and a flag indicating
/// the required state of that feature.
using Requirement = std::pair<std::string, bool>;
struct Requirement {
std::string FeatureName;
bool RequiredState;
};

/// The set of language features required to use this module.
///
Expand Down
10 changes: 5 additions & 5 deletions clang/lib/Basic/Module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,8 @@ bool Module::isUnimportable(const LangOptions &LangOpts,
return true;
}
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].FeatureName, LangOpts, Target) !=
Current->Requirements[I].RequiredState) {
Req = Current->Requirements[I];
return true;
}
Expand Down Expand Up @@ -319,7 +319,7 @@ bool Module::directlyUses(const Module *Requested) {
void Module::addRequirement(StringRef Feature, bool RequiredState,
const LangOptions &LangOpts,
const TargetInfo &Target) {
Requirements.push_back(Requirement(std::string(Feature), RequiredState));
Requirements.push_back(Requirement{std::string(Feature), RequiredState});

// If this feature is currently available, we're done.
if (hasFeature(Feature, LangOpts, Target) == RequiredState)
Expand Down Expand Up @@ -504,9 +504,9 @@ void Module::print(raw_ostream &OS, unsigned Indent, bool Dump) const {
for (unsigned I = 0, N = Requirements.size(); I != N; ++I) {
if (I)
OS << ", ";
if (!Requirements[I].second)
if (!Requirements[I].RequiredState)
OS << "!";
OS << Requirements[I].first;
OS << Requirements[I].FeatureName;
}
OS << "\n";
}
Expand Down
3 changes: 2 additions & 1 deletion clang/lib/Lex/PPDirectives.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1918,7 +1918,8 @@ bool Preprocessor::checkModuleIsAvailable(const LangOptions &LangOpts,
// FIXME: Track the location at which the requirement was specified, and
// use it here.
Diags.Report(M.DefinitionLoc, diag::err_module_unavailable)
<< M.getFullModuleName() << Requirement.second << Requirement.first;
<< M.getFullModuleName() << Requirement.RequiredState
<< Requirement.FeatureName;
}
return true;
}
Expand Down
4 changes: 2 additions & 2 deletions clang/lib/Serialization/ASTWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2988,8 +2988,8 @@ void ASTWriter::WriteSubmodules(Module *WritingModule) {

// Emit the requirements.
for (const auto &R : Mod->Requirements) {
RecordData::value_type Record[] = {SUBMODULE_REQUIRES, R.second};
Stream.EmitRecordWithBlob(RequiresAbbrev, Record, R.first);
RecordData::value_type Record[] = {SUBMODULE_REQUIRES, R.RequiredState};
Stream.EmitRecordWithBlob(RequiresAbbrev, Record, R.FeatureName);
}

// Emit the umbrella header, if there is one.
Expand Down