Revert "[clang][modules] Add support for merging lifetime-extended temporaries"

This reverts commit 3c7f6b4396.
This commit is contained in:
Tyker 2019-11-30 17:52:26 +01:00
parent 3c7f6b4396
commit 3f4b70c79e
10 changed files with 1 additions and 88 deletions

View File

@ -3041,9 +3041,7 @@ public:
/// Implicit declaration of a temporary that was materialized by
/// a MaterializeTemporaryExpr and lifetime-extended by a declaration
class LifetimeExtendedTemporaryDecl final
: public Decl,
public Mergeable<LifetimeExtendedTemporaryDecl> {
class LifetimeExtendedTemporaryDecl final : public Decl {
friend class MaterializeTemporaryExpr;
friend class ASTDeclReader;

View File

@ -346,8 +346,6 @@ public:
void VisitObjCPropertyImplDecl(const ObjCPropertyImplDecl *D);
void VisitBlockDecl(const BlockDecl *D);
void VisitConceptDecl(const ConceptDecl *D);
void
VisitLifetimeExtendedTemporaryDecl(const LifetimeExtendedTemporaryDecl *D);
};
} // namespace clang

View File

@ -551,14 +551,6 @@ private:
llvm::DenseMap<Decl*, llvm::SmallVector<NamedDecl*, 2>>
AnonymousDeclarationsForMerging;
/// Key used to identify LifetimeExtendedTemporaryDecl for merging,
/// containing the lifetime-extending declaration and the mangling number.
using LETemporaryKey = std::pair<Decl *, unsigned>;
/// Map of already deserialiazed temporaries.
llvm::DenseMap<LETemporaryKey, LifetimeExtendedTemporaryDecl *>
LETemporaryForMerging;
struct FileDeclsInfo {
ModuleFile *Mod = nullptr;
ArrayRef<serialization::LocalDeclID> Decls;

View File

@ -1338,17 +1338,6 @@ void TextNodeDumper::VisitFunctionDecl(const FunctionDecl *D) {
OS << " <<<NULL params x " << D->getNumParams() << ">>>";
}
void TextNodeDumper::VisitLifetimeExtendedTemporaryDecl(
const LifetimeExtendedTemporaryDecl *D) {
OS << " extended by ";
dumpBareDeclRef(D->getExtendingDecl());
OS << " mangling ";
{
ColorScope Color(OS, ShowColors, ValueColor);
OS << D->getManglingNumber();
}
}
void TextNodeDumper::VisitFieldDecl(const FieldDecl *D) {
dumpName(D);
dumpType(D->getType());

View File

@ -424,9 +424,6 @@ namespace clang {
template<typename T>
void mergeMergeable(Mergeable<T> *D);
template <>
void mergeMergeable(Mergeable<LifetimeExtendedTemporaryDecl> *D);
void mergeTemplatePattern(RedeclarableTemplateDecl *D,
RedeclarableTemplateDecl *Existing,
DeclID DsID, bool IsKeyDecl);
@ -2361,7 +2358,6 @@ 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>
@ -2559,28 +2555,6 @@ static bool allowODRLikeMergeInC(NamedDecl *ND) {
return false;
}
/// Attempts to merge LifetimeExtendedTemporaryDecl with
/// identical class definitions from two different modules.
template<>
void ASTDeclReader::mergeMergeable(
Mergeable<LifetimeExtendedTemporaryDecl> *D) {
// If modules are not available, there is no reason to perform this merge.
if (!Reader.getContext().getLangOpts().Modules)
return;
LifetimeExtendedTemporaryDecl *LETDecl =
static_cast<LifetimeExtendedTemporaryDecl *>(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

View File

@ -1,2 +0,0 @@
constexpr const int& LETemp = 0;

View File

@ -1,4 +0,0 @@
#include "a.h"
constexpr const int* PtrTemp1 = &LETemp;

View File

@ -1,4 +0,0 @@
#include "a.h"
constexpr const int* PtrTemp2 = &LETemp;

View File

@ -1,14 +0,0 @@
module "a" {
export *
header "a.h"
}
module "b" {
export *
header "b.h"
}
module "c" {
export *
header "c.h"
}

View File

@ -1,14 +0,0 @@
// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -x c++ -I%S/Inputs/merge-lifetime-extended-temporary -verify -std=c++11 %s -DORDER=1
// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -x c++ -I%S/Inputs/merge-lifetime-extended-temporary -verify -std=c++11 %s -DORDER=2
// expected-no-diagnostics
#if ORDER == 1
#include "c.h"
#include "b.h"
#else
#include "b.h"
#include "c.h"
#endif
static_assert(PtrTemp1 == &LETemp, "");
static_assert(PtrTemp1 == PtrTemp2, "");