[modules] Track how 'header' directives were written in module map files,

rather than trying to extract this information from the FileEntry after the
fact.

This has a number of beneficial effects. For instance, diagnostic messages for
failed module builds give a path relative to the "module root" rather than an
absolute file path, and the contents of the module includes file is no longer
dependent on what files the including TU happened to inspect prior to
triggering the module build.

llvm-svn: 223095
This commit is contained in:
Richard Smith
2014-12-02 00:08:08 +00:00
parent 4cdf4eba74
commit 3c1a41ad99
13 changed files with 241 additions and 147 deletions

View File

@@ -26,7 +26,7 @@ using namespace clang;
Module::Module(StringRef Name, SourceLocation DefinitionLoc, Module *Parent,
bool IsFramework, bool IsExplicit)
: Name(Name), DefinitionLoc(DefinitionLoc), Parent(Parent),
: Name(Name), DefinitionLoc(DefinitionLoc), Parent(Parent), Directory(),
Umbrella(), ASTFile(nullptr), IsMissingRequirement(false),
IsAvailable(true), IsFromModuleFile(false), IsFramework(IsFramework),
IsExplicit(IsExplicit), IsSystem(false), IsExternC(false),
@@ -70,9 +70,9 @@ static bool hasFeature(StringRef Feature, const LangOptions &LangOpts,
.Default(Target.hasFeature(Feature));
}
bool
Module::isAvailable(const LangOptions &LangOpts, const TargetInfo &Target,
Requirement &Req, HeaderDirective &MissingHeader) const {
bool Module::isAvailable(const LangOptions &LangOpts, const TargetInfo &Target,
Requirement &Req,
UnresolvedHeaderDirective &MissingHeader) const {
if (IsAvailable)
return true;
@@ -338,19 +338,20 @@ void Module::print(raw_ostream &OS, unsigned Indent) const {
OS << "\n";
}
struct HeaderKind {
struct {
StringRef Prefix;
const SmallVectorImpl<const FileEntry *> &Headers;
} Kinds[] = {{"", NormalHeaders},
{"exclude ", ExcludedHeaders},
{"textual ", TextualHeaders},
{"private ", PrivateHeaders}};
HeaderKind Kind;
} Kinds[] = {{"", HK_Normal},
{"textual ", HK_Textual},
{"private ", HK_Private},
{"private textual ", HK_PrivateTextual},
{"exclude ", HK_Excluded}};
for (auto &K : Kinds) {
for (auto *H : K.Headers) {
for (auto &H : Headers[K.Kind]) {
OS.indent(Indent + 2);
OS << K.Prefix << "header \"";
OS.write_escaped(H->getName());
OS.write_escaped(H.NameAsWritten);
OS << "\"\n";
}
}