summaryrefslogtreecommitdiffstats
path: root/clang/lib/Serialization
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2014-12-02 00:08:08 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2014-12-02 00:08:08 +0000
commit3c1a41ad9969ae4e3353f5984d66af85ce56cf9a (patch)
treef19e3452dbc34c152accbcee5057286a353da704 /clang/lib/Serialization
parent4cdf4eba74df1c2a679931716fc630fd484bdb3c (diff)
downloadbcm5719-llvm-3c1a41ad9969ae4e3353f5984d66af85ce56cf9a.tar.gz
bcm5719-llvm-3c1a41ad9969ae4e3353f5984d66af85ce56cf9a.zip
[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
Diffstat (limited to 'clang/lib/Serialization')
-rw-r--r--clang/lib/Serialization/ASTReader.cpp8
-rw-r--r--clang/lib/Serialization/ASTWriter.cpp31
2 files changed, 26 insertions, 13 deletions
diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp
index c0f22846787..e1daa04647f 100644
--- a/clang/lib/Serialization/ASTReader.cpp
+++ b/clang/lib/Serialization/ASTReader.cpp
@@ -1559,7 +1559,13 @@ HeaderFileInfoTrait::ReadData(internal_key_ref key, const unsigned char *d,
FileManager &FileMgr = Reader.getFileManager();
ModuleMap &ModMap =
Reader.getPreprocessor().getHeaderSearchInfo().getModuleMap();
- ModMap.addHeader(Mod, FileMgr.getFile(key.Filename), HFI.getHeaderRole());
+ // FIXME: This is wrong. We should track the filename as written; this
+ // information should be propagated through the SUBMODULE_HEADER etc
+ // records rather than from here.
+ // FIXME: We don't ever mark excluded headers.
+ ModMap.addHeader(
+ Mod, Module::Header{key.Filename, FileMgr.getFile(key.Filename)},
+ HFI.getHeaderRole());
}
}
diff --git a/clang/lib/Serialization/ASTWriter.cpp b/clang/lib/Serialization/ASTWriter.cpp
index b9be775408b..5ffb259b0a1 100644
--- a/clang/lib/Serialization/ASTWriter.cpp
+++ b/clang/lib/Serialization/ASTWriter.cpp
@@ -2511,24 +2511,31 @@ void ASTWriter::WriteSubmodules(Module *WritingModule) {
// Emit the headers.
struct {
- unsigned Kind;
+ unsigned RecordKind;
unsigned Abbrev;
- ArrayRef<const FileEntry*> Headers;
+ Module::HeaderKind HeaderKind;
} HeaderLists[] = {
- {SUBMODULE_HEADER, HeaderAbbrev, Mod->NormalHeaders},
- {SUBMODULE_TEXTUAL_HEADER, TextualHeaderAbbrev, Mod->TextualHeaders},
- {SUBMODULE_PRIVATE_HEADER, PrivateHeaderAbbrev, Mod->PrivateHeaders},
+ {SUBMODULE_HEADER, HeaderAbbrev, Module::HK_Normal},
+ {SUBMODULE_TEXTUAL_HEADER, TextualHeaderAbbrev, Module::HK_Textual},
+ {SUBMODULE_PRIVATE_HEADER, PrivateHeaderAbbrev, Module::HK_Private},
{SUBMODULE_PRIVATE_TEXTUAL_HEADER, PrivateTextualHeaderAbbrev,
- Mod->PrivateTextualHeaders},
- {SUBMODULE_EXCLUDED_HEADER, ExcludedHeaderAbbrev, Mod->ExcludedHeaders},
- {SUBMODULE_TOPHEADER, TopHeaderAbbrev,
- Mod->getTopHeaders(PP->getFileManager())}
+ Module::HK_PrivateTextual},
+ {SUBMODULE_EXCLUDED_HEADER, ExcludedHeaderAbbrev, Module::HK_Excluded}
};
for (auto &HL : HeaderLists) {
Record.clear();
- Record.push_back(HL.Kind);
- for (auto *H : HL.Headers)
- Stream.EmitRecordWithBlob(HL.Abbrev, Record, H->getName());
+ Record.push_back(HL.RecordKind);
+ for (auto &H : Mod->Headers[HL.HeaderKind])
+ Stream.EmitRecordWithBlob(HL.Abbrev, Record, H.NameAsWritten);
+ }
+
+ // Emit the top headers.
+ {
+ auto TopHeaders = Mod->getTopHeaders(PP->getFileManager());
+ Record.clear();
+ Record.push_back(SUBMODULE_TOPHEADER);
+ for (auto *H : TopHeaders)
+ Stream.EmitRecordWithBlob(TopHeaderAbbrev, Record, H->getName());
}
// Emit the imports.
OpenPOWER on IntegriCloud