summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorReid Kleckner <rnk@google.com>2019-10-10 01:10:01 +0000
committerReid Kleckner <rnk@google.com>2019-10-10 01:10:01 +0000
commitc34385d07c7d59447bf836b740f032235391d121 (patch)
tree78e30b3299264ab557a9b6f86602e358f899ba6c
parent9d8f0b3519c4e9e4e2a3d3b19ea0caf9ef3f85ce (diff)
downloadbcm5719-llvm-c34385d07c7d59447bf836b740f032235391d121.tar.gz
bcm5719-llvm-c34385d07c7d59447bf836b740f032235391d121.zip
Revert [mangle] Fix mangling where an extra mangle context is required.
This reverts r374200 (git commit fd18e94697c987d5f24e25aa4e27adaffff3cce4) Causes crashes just compiling `int main() {}` on my machine. llvm-svn: 374268
-rw-r--r--clang/include/clang/AST/ASTContext.h5
-rw-r--r--clang/include/clang/Sema/Sema.h14
-rw-r--r--clang/lib/AST/ASTContext.cpp10
-rw-r--r--clang/lib/Sema/SemaLambda.cpp12
-rw-r--r--clang/test/CodeGenCXX/mangle-lambdas.cpp10
5 files changed, 25 insertions, 26 deletions
diff --git a/clang/include/clang/AST/ASTContext.h b/clang/include/clang/AST/ASTContext.h
index 7547960b092..5105b9c35cd 100644
--- a/clang/include/clang/AST/ASTContext.h
+++ b/clang/include/clang/AST/ASTContext.h
@@ -514,8 +514,6 @@ private:
/// need to be consistently numbered for the mangler).
llvm::DenseMap<const DeclContext *, std::unique_ptr<MangleNumberingContext>>
MangleNumberingContexts;
- llvm::DenseMap<const Decl *, std::unique_ptr<MangleNumberingContext>>
- ExtraMangleNumberingContexts;
/// Side-table of mangling numbers for declarations which rarely
/// need them (like static local vars).
@@ -2814,9 +2812,6 @@ public:
/// Retrieve the context for computing mangling numbers in the given
/// DeclContext.
MangleNumberingContext &getManglingNumberContext(const DeclContext *DC);
- enum NeedExtraManglingDecl_t { NeedExtraManglingDecl };
- MangleNumberingContext &getManglingNumberContext(NeedExtraManglingDecl_t,
- const Decl *D);
std::unique_ptr<MangleNumberingContext> createMangleNumberingContext() const;
diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 1cc6fc67bc9..b68da4b7f5c 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -1045,6 +1045,13 @@ public:
/// suffice, e.g., in a default function argument.
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
/// for which we have deferred checking the completeness of the return type.
SmallVector<CallExpr *, 8> DelayedDecltypeCalls;
@@ -1073,7 +1080,12 @@ public:
ExpressionKind ExprContext)
: Context(Context), ParentCleanup(ParentCleanup),
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 {
return Context == ExpressionEvaluationContext::Unevaluated ||
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 8dd57f2bd28..a41b64ffcc8 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -10261,16 +10261,6 @@ ASTContext::getManglingNumberContext(const DeclContext *DC) {
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>
ASTContext::createMangleNumberingContext() const {
return ABI->createMangleNumberingContext();
diff --git a/clang/lib/Sema/SemaLambda.cpp b/clang/lib/Sema/SemaLambda.cpp
index b05ed75e879..a76a840f26e 100644
--- a/clang/lib/Sema/SemaLambda.cpp
+++ b/clang/lib/Sema/SemaLambda.cpp
@@ -352,13 +352,21 @@ Sema::getCurrentMangleNumberContext(const DeclContext *DC,
// -- the initializers of inline variables
case VariableTemplate:
// -- the initializers of templated variables
- return &Context.getManglingNumberContext(ASTContext::NeedExtraManglingDecl,
- ManglingContextDecl);
+ return &ExprEvalContexts.back().getMangleNumberingContext(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(
CXXRecordDecl *Class, SourceRange IntroducerRange,
TypeSourceInfo *MethodTypeInfo, SourceLocation EndLoc,
diff --git a/clang/test/CodeGenCXX/mangle-lambdas.cpp b/clang/test/CodeGenCXX/mangle-lambdas.cpp
index fcca878e387..d49ed4b2a5e 100644
--- a/clang/test/CodeGenCXX/mangle-lambdas.cpp
+++ b/clang/test/CodeGenCXX/mangle-lambdas.cpp
@@ -178,24 +178,18 @@ void use_func_template() {
}
namespace std {
- struct type_info {
- bool before(const type_info &) const noexcept;
- };
+ struct type_info;
}
namespace PR12123 {
struct A { virtual ~A(); } g;
- struct C { virtual ~C(); } k;
struct B {
void f(const std::type_info& x = typeid([]()->A& { return g; }()));
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"* @_ZZN7PR121231B1jEbEd_NKUlvE_clEv
-// CHECK-LABEL: define linkonce_odr dereferenceable({{[0-9]+}}) %"struct.PR12123::C"* @_ZZN7PR121231B1jEbEd_NKUlvE0_clEv
// CHECK-LABEL: define {{.*}} @_Z{{[0-9]*}}testVarargsLambdaNumberingv(
inline int testVarargsLambdaNumbering() {
OpenPOWER on IntegriCloud