From 3c1a41ad9969ae4e3353f5984d66af85ce56cf9a Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Tue, 2 Dec 2014 00:08:08 +0000 Subject: [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 --- clang/lib/Basic/Module.cpp | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'clang/lib/Basic/Module.cpp') diff --git a/clang/lib/Basic/Module.cpp b/clang/lib/Basic/Module.cpp index c0f5a6afa10..ba3526c334f 100644 --- a/clang/lib/Basic/Module.cpp +++ b/clang/lib/Basic/Module.cpp @@ -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 &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"; } } -- cgit v1.2.3