[PATCH] D34984: Store token literal data in PCH. Avoids disk read on PreProc expansion.
Vassil Vassilev via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Jul 4 07:42:17 PDT 2017
v.g.vassilev created this revision.
Patch by Axel Naumann!
Repository:
rL LLVM
https://reviews.llvm.org/D34984
Files:
include/clang/Serialization/ASTReader.h
lib/Serialization/ASTReader.cpp
lib/Serialization/ASTWriter.cpp
Index: lib/Serialization/ASTWriter.cpp
===================================================================
--- lib/Serialization/ASTWriter.cpp
+++ lib/Serialization/ASTWriter.cpp
@@ -4287,6 +4287,8 @@
Record.push_back(Tok.getKind());
// FIXME: Should translate token flags to a stable encoding.
Record.push_back(Tok.getFlags());
+ if (Tok.isLiteral())
+ AddString(Tok.getLiteralData(), Record);
}
void ASTWriter::AddString(StringRef Str, RecordDataImpl &Record) {
Index: lib/Serialization/ASTReader.cpp
===================================================================
--- lib/Serialization/ASTReader.cpp
+++ lib/Serialization/ASTReader.cpp
@@ -1517,6 +1517,12 @@
Tok.setIdentifierInfo(II);
Tok.setKind((tok::TokenKind)Record[Idx++]);
Tok.setFlag((Token::TokenFlags)Record[Idx++]);
+ if (Tok.isLiteral()) {
+ const RecordData& RD = reinterpret_cast<const RecordData&>(Record);
+ std::string* Lit = new std::string(ReadString(RD, Idx));
+ TokenLiteralDataLoaded.push_back(Lit);
+ Tok.setLiteralData(Lit->c_str());
+ }
return Tok;
}
@@ -9909,6 +9915,9 @@
ASTReader::~ASTReader() {
if (OwnsDeserializationListener)
delete DeserializationListener;
+ for (auto PStr: TokenLiteralDataLoaded) {
+ delete PStr;
+ }
}
IdentifierResolver &ASTReader::getIdResolver() {
Index: include/clang/Serialization/ASTReader.h
===================================================================
--- include/clang/Serialization/ASTReader.h
+++ include/clang/Serialization/ASTReader.h
@@ -604,6 +604,9 @@
/// files.
llvm::DenseSet<LoadedMacroInfo> LoadedUndefs;
+ /// \brief Token literal data loaded and owned by us.
+ std::vector<std::string *> TokenLiteralDataLoaded;
+
typedef ContinuousRangeMap<serialization::MacroID, ModuleFile *, 4>
GlobalMacroMapType;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D34984.105176.patch
Type: text/x-patch
Size: 1831 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170704/152ad8bc/attachment-0001.bin>
More information about the cfe-commits
mailing list