Revert [mangle] Fix mangling where an extra mangle context is required.

This reverts r374200 (git commit fd18e94697)

Causes crashes just compiling `int main() {}` on my machine.

llvm-svn: 374268
This commit is contained in:
Reid Kleckner 2019-10-10 01:10:01 +00:00
parent 9d8f0b3519
commit c34385d07c
5 changed files with 25 additions and 26 deletions

View File

@ -514,8 +514,6 @@ private:
/// need to be consistently numbered for the mangler). /// need to be consistently numbered for the mangler).
llvm::DenseMap<const DeclContext *, std::unique_ptr<MangleNumberingContext>> llvm::DenseMap<const DeclContext *, std::unique_ptr<MangleNumberingContext>>
MangleNumberingContexts; MangleNumberingContexts;
llvm::DenseMap<const Decl *, std::unique_ptr<MangleNumberingContext>>
ExtraMangleNumberingContexts;
/// Side-table of mangling numbers for declarations which rarely /// Side-table of mangling numbers for declarations which rarely
/// need them (like static local vars). /// need them (like static local vars).
@ -2814,9 +2812,6 @@ public:
/// Retrieve the context for computing mangling numbers in the given /// Retrieve the context for computing mangling numbers in the given
/// DeclContext. /// DeclContext.
MangleNumberingContext &getManglingNumberContext(const DeclContext *DC); MangleNumberingContext &getManglingNumberContext(const DeclContext *DC);
enum NeedExtraManglingDecl_t { NeedExtraManglingDecl };
MangleNumberingContext &getManglingNumberContext(NeedExtraManglingDecl_t,
const Decl *D);
std::unique_ptr<MangleNumberingContext> createMangleNumberingContext() const; std::unique_ptr<MangleNumberingContext> createMangleNumberingContext() const;

View File

@ -1045,6 +1045,13 @@ public:
/// suffice, e.g., in a default function argument. /// suffice, e.g., in a default function argument.
Decl *ManglingContextDecl; Decl *ManglingContextDecl;
/// The context information used to mangle lambda expressions
/// and block literals within this context.
///
/// This mangling information is allocated lazily, since most contexts
/// do not have lambda expressions or block literals.
std::unique_ptr<MangleNumberingContext> MangleNumbering;
/// If we are processing a decltype type, a set of call expressions /// If we are processing a decltype type, a set of call expressions
/// for which we have deferred checking the completeness of the return type. /// for which we have deferred checking the completeness of the return type.
SmallVector<CallExpr *, 8> DelayedDecltypeCalls; SmallVector<CallExpr *, 8> DelayedDecltypeCalls;
@ -1073,7 +1080,12 @@ public:
ExpressionKind ExprContext) ExpressionKind ExprContext)
: Context(Context), ParentCleanup(ParentCleanup), : Context(Context), ParentCleanup(ParentCleanup),
NumCleanupObjects(NumCleanupObjects), NumTypos(0), NumCleanupObjects(NumCleanupObjects), NumTypos(0),
ManglingContextDecl(ManglingContextDecl), ExprContext(ExprContext) {} ManglingContextDecl(ManglingContextDecl), MangleNumbering(),
ExprContext(ExprContext) {}
/// Retrieve the mangling numbering context, used to consistently
/// number constructs like lambdas for mangling.
MangleNumberingContext &getMangleNumberingContext(ASTContext &Ctx);
bool isUnevaluated() const { bool isUnevaluated() const {
return Context == ExpressionEvaluationContext::Unevaluated || return Context == ExpressionEvaluationContext::Unevaluated ||

View File

@ -10261,16 +10261,6 @@ ASTContext::getManglingNumberContext(const DeclContext *DC) {
return *MCtx; return *MCtx;
} }
MangleNumberingContext &
ASTContext::getManglingNumberContext(NeedExtraManglingDecl_t, const Decl *D) {
assert(LangOpts.CPlusPlus); // We don't need mangling numbers for plain C.
std::unique_ptr<MangleNumberingContext> &MCtx =
ExtraMangleNumberingContexts[D];
if (!MCtx)
MCtx = createMangleNumberingContext();
return *MCtx;
}
std::unique_ptr<MangleNumberingContext> std::unique_ptr<MangleNumberingContext>
ASTContext::createMangleNumberingContext() const { ASTContext::createMangleNumberingContext() const {
return ABI->createMangleNumberingContext(); return ABI->createMangleNumberingContext();

View File

@ -352,13 +352,21 @@ Sema::getCurrentMangleNumberContext(const DeclContext *DC,
// -- the initializers of inline variables // -- the initializers of inline variables
case VariableTemplate: case VariableTemplate:
// -- the initializers of templated variables // -- the initializers of templated variables
return &Context.getManglingNumberContext(ASTContext::NeedExtraManglingDecl, return &ExprEvalContexts.back().getMangleNumberingContext(Context);
ManglingContextDecl);
} }
llvm_unreachable("unexpected context"); llvm_unreachable("unexpected context");
} }
MangleNumberingContext &
Sema::ExpressionEvaluationContextRecord::getMangleNumberingContext(
ASTContext &Ctx) {
assert(ManglingContextDecl && "Need to have a context declaration");
if (!MangleNumbering)
MangleNumbering = Ctx.createMangleNumberingContext();
return *MangleNumbering;
}
CXXMethodDecl *Sema::startLambdaDefinition( CXXMethodDecl *Sema::startLambdaDefinition(
CXXRecordDecl *Class, SourceRange IntroducerRange, CXXRecordDecl *Class, SourceRange IntroducerRange,
TypeSourceInfo *MethodTypeInfo, SourceLocation EndLoc, TypeSourceInfo *MethodTypeInfo, SourceLocation EndLoc,

View File

@ -178,24 +178,18 @@ void use_func_template() {
} }
namespace std { namespace std {
struct type_info { struct type_info;
bool before(const type_info &) const noexcept;
};
} }
namespace PR12123 { namespace PR12123 {
struct A { virtual ~A(); } g; struct A { virtual ~A(); } g;
struct C { virtual ~C(); } k;
struct B { struct B {
void f(const std::type_info& x = typeid([]()->A& { return g; }())); void f(const std::type_info& x = typeid([]()->A& { return g; }()));
void h(); void h();
void j(bool cond = typeid([]() -> A & { return g; }()).before(typeid([]() -> C & { return k; }())));
}; };
void B::h() { f(); j(); } void B::h() { f(); }
} }
// CHECK-LABEL: define linkonce_odr dereferenceable({{[0-9]+}}) %"struct.PR12123::A"* @_ZZN7PR121231B1fERKSt9type_infoEd_NKUlvE_clEv // CHECK-LABEL: define linkonce_odr dereferenceable({{[0-9]+}}) %"struct.PR12123::A"* @_ZZN7PR121231B1fERKSt9type_infoEd_NKUlvE_clEv
// CHECK-LABEL: define linkonce_odr dereferenceable({{[0-9]+}}) %"struct.PR12123::A"* @_ZZN7PR121231B1jEbEd_NKUlvE_clEv
// CHECK-LABEL: define linkonce_odr dereferenceable({{[0-9]+}}) %"struct.PR12123::C"* @_ZZN7PR121231B1jEbEd_NKUlvE0_clEv
// CHECK-LABEL: define {{.*}} @_Z{{[0-9]*}}testVarargsLambdaNumberingv( // CHECK-LABEL: define {{.*}} @_Z{{[0-9]*}}testVarargsLambdaNumberingv(
inline int testVarargsLambdaNumbering() { inline int testVarargsLambdaNumbering() {