summaryrefslogtreecommitdiffstats
path: root/clang/lib/Serialization/ASTReaderDecl.cpp
diff options
context:
space:
mode:
authorTyker <tyker1@outlook.com>2019-11-30 16:42:33 +0100
committerTyker <tyker1@outlook.com>2019-12-01 21:28:48 +0100
commita3cbe1a202df6ec8e23bd55e14db254e4bc33021 (patch)
tree93c47cab8d92a21f939373da9ca4740067f7a0e5 /clang/lib/Serialization/ASTReaderDecl.cpp
parent67298d683ca18fa8855349b5b0c289f92c93b6b1 (diff)
downloadbcm5719-llvm-a3cbe1a202df6ec8e23bd55e14db254e4bc33021.tar.gz
bcm5719-llvm-a3cbe1a202df6ec8e23bd55e14db254e4bc33021.zip
[clang][modules] Add support for merging lifetime-extended temporaries
Summary: Add support for merging lifetime-extended temporaries Reviewers: rsmith Reviewed By: rsmith Subscribers: xbolva00, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D70190
Diffstat (limited to 'clang/lib/Serialization/ASTReaderDecl.cpp')
-rw-r--r--clang/lib/Serialization/ASTReaderDecl.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/clang/lib/Serialization/ASTReaderDecl.cpp b/clang/lib/Serialization/ASTReaderDecl.cpp
index 8991a39a706..3f7a1ed7fd5 100644
--- a/clang/lib/Serialization/ASTReaderDecl.cpp
+++ b/clang/lib/Serialization/ASTReaderDecl.cpp
@@ -424,6 +424,8 @@ namespace clang {
template<typename T>
void mergeMergeable(Mergeable<T> *D);
+ void mergeMergeable(LifetimeExtendedTemporaryDecl *D);
+
void mergeTemplatePattern(RedeclarableTemplateDecl *D,
RedeclarableTemplateDecl *Existing,
DeclID DsID, bool IsKeyDecl);
@@ -2358,6 +2360,7 @@ void ASTDeclReader::VisitLifetimeExtendedTemporaryDecl(
if (Record.readInt())
D->Value = new (D->getASTContext()) APValue(Record.readAPValue());
D->ManglingNumber = Record.readInt();
+ mergeMergeable(D);
}
std::pair<uint64_t, uint64_t>
@@ -2555,6 +2558,25 @@ static bool allowODRLikeMergeInC(NamedDecl *ND) {
return false;
}
+/// Attempts to merge LifetimeExtendedTemporaryDecl with
+/// identical class definitions from two different modules.
+void ASTDeclReader::mergeMergeable(LifetimeExtendedTemporaryDecl *D) {
+ // If modules are not available, there is no reason to perform this merge.
+ if (!Reader.getContext().getLangOpts().Modules)
+ return;
+
+ LifetimeExtendedTemporaryDecl *LETDecl = D;
+
+ LifetimeExtendedTemporaryDecl *&LookupResult =
+ Reader.LETemporaryForMerging[std::make_pair(
+ LETDecl->getExtendingDecl(), LETDecl->getManglingNumber())];
+ if (LookupResult)
+ Reader.getContext().setPrimaryMergedDecl(LETDecl,
+ LookupResult->getCanonicalDecl());
+ else
+ LookupResult = LETDecl;
+}
+
/// Attempts to merge the given declaration (D) with another declaration
/// of the same entity, for the case where the entity is not actually
/// redeclarable. This happens, for instance, when merging the fields of
OpenPOWER on IntegriCloud