aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Serialization/ASTWriter.cpp
diff options
context:
space:
mode:
authorJan Svoboda <jan_svoboda@apple.com>2024-10-31 16:33:28 -0700
committerGitHub <noreply@github.com>2024-10-31 16:33:28 -0700
commite494e2694a90ac6fb18976b8cb6aab849b6279b4 (patch)
tree4e913a6a569b763e0928ece53de9f38c851728ec /clang/lib/Serialization/ASTWriter.cpp
parenta1987beac58765b7df9690eb898c14f629449210 (diff)
downloadllvm-e494e2694a90ac6fb18976b8cb6aab849b6279b4.zip
llvm-e494e2694a90ac6fb18976b8cb6aab849b6279b4.tar.gz
llvm-e494e2694a90ac6fb18976b8cb6aab849b6279b4.tar.bz2
[clang][lex] Remove `HeaderFileInfo::Framework` (#114460)
This PR removes the `HeaderFileInfo::Framework` member and reduces the size of this data type from 32B to 16B. This should improve Clang's memory usage in situations where it keeps track of lots of header files. NFCI. Depends on #114459.
Diffstat (limited to 'clang/lib/Serialization/ASTWriter.cpp')
-rw-r--r--clang/lib/Serialization/ASTWriter.cpp26
1 files changed, 1 insertions, 25 deletions
diff --git a/clang/lib/Serialization/ASTWriter.cpp b/clang/lib/Serialization/ASTWriter.cpp
index 010a9de..732c7ef 100644
--- a/clang/lib/Serialization/ASTWriter.cpp
+++ b/clang/lib/Serialization/ASTWriter.cpp
@@ -1958,10 +1958,6 @@ namespace {
class HeaderFileInfoTrait {
ASTWriter &Writer;
- // Keep track of the framework names we've used during serialization.
- SmallString<128> FrameworkStringData;
- llvm::StringMap<unsigned> FrameworkNameOffset;
-
public:
HeaderFileInfoTrait(ASTWriter &Writer) : Writer(Writer) {}
@@ -2005,7 +2001,7 @@ namespace {
std::pair<unsigned, unsigned>
EmitKeyDataLength(raw_ostream& Out, key_type_ref key, data_type_ref Data) {
unsigned KeyLen = key.Filename.size() + 1 + 8 + 8;
- unsigned DataLen = 1 + sizeof(IdentifierID) + 4;
+ unsigned DataLen = 1 + sizeof(IdentifierID);
for (auto ModInfo : Data.KnownHeaders)
if (Writer.getLocalOrImportedSubmoduleID(ModInfo.getModule()))
DataLen += 4;
@@ -2045,22 +2041,6 @@ namespace {
LE.write<IdentifierID>(
Writer.getIdentifierRef(Data.HFI.LazyControllingMacro.getPtr()));
- unsigned Offset = 0;
- if (!Data.HFI.Framework.empty()) {
- // If this header refers into a framework, save the framework name.
- llvm::StringMap<unsigned>::iterator Pos
- = FrameworkNameOffset.find(Data.HFI.Framework);
- if (Pos == FrameworkNameOffset.end()) {
- Offset = FrameworkStringData.size() + 1;
- FrameworkStringData.append(Data.HFI.Framework);
- FrameworkStringData.push_back(0);
-
- FrameworkNameOffset[Data.HFI.Framework] = Offset;
- } else
- Offset = Pos->second;
- }
- LE.write<uint32_t>(Offset);
-
auto EmitModule = [&](Module *M, ModuleMap::ModuleHeaderRole Role) {
if (uint32_t ModID = Writer.getLocalOrImportedSubmoduleID(M)) {
uint32_t Value = (ModID << 3) | (unsigned)Role;
@@ -2076,9 +2056,6 @@ namespace {
assert(Out.tell() - Start == DataLen && "Wrong data length");
}
-
- const char *strings_begin() const { return FrameworkStringData.begin(); }
- const char *strings_end() const { return FrameworkStringData.end(); }
};
} // namespace
@@ -2213,7 +2190,6 @@ void ASTWriter::WriteHeaderSearch(const HeaderSearch &HS) {
// Write the header search table
RecordData::value_type Record[] = {HEADER_SEARCH_TABLE, BucketOffset,
NumHeaderSearchEntries, TableData.size()};
- TableData.append(GeneratorTrait.strings_begin(),GeneratorTrait.strings_end());
Stream.EmitRecordWithBlob(TableAbbrev, Record, TableData);
// Free all of the strings we had to duplicate.