r223136 - This patch fixes a crash involving use of predefined
Fariborz Jahanian
fjahanian at apple.com
Tue Dec 2 10:42:52 PST 2014
Author: fjahanian
Date: Tue Dec 2 12:42:51 2014
New Revision: 223136
URL: http://llvm.org/viewvc/llvm-project?rev=223136&view=rev
Log:
This patch fixes a crash involving use of predefined
expressions. It fixes crash when mangling name for block's helper
function used inside a constructor/destructor.
rdar://19065361.
Modified:
cfe/trunk/lib/AST/Mangle.cpp
cfe/trunk/test/CodeGenCXX/predefined-expr.cpp
Modified: cfe/trunk/lib/AST/Mangle.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Mangle.cpp?rev=223136&r1=223135&r2=223136&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Mangle.cpp (original)
+++ cfe/trunk/lib/AST/Mangle.cpp Tue Dec 2 12:42:51 2014
@@ -236,7 +236,11 @@ void MangleContext::mangleBlock(const De
(void) getBlockId(cast<BlockDecl>(DC), true);
assert((isa<TranslationUnitDecl>(DC) || isa<NamedDecl>(DC)) &&
"expected a TranslationUnitDecl or a NamedDecl");
- if (auto ND = dyn_cast<NamedDecl>(DC)) {
+ if (const auto *CD = dyn_cast<CXXConstructorDecl>(DC))
+ mangleCtorBlock(CD, /*CT*/ Ctor_Complete, BD, Out);
+ else if (const auto *DD = dyn_cast<CXXDestructorDecl>(DC))
+ mangleDtorBlock(DD, /*DT*/ Dtor_Complete, BD, Out);
+ else if (auto ND = dyn_cast<NamedDecl>(DC)) {
if (!shouldMangleDeclName(ND) && ND->getIdentifier())
Stream << ND->getIdentifier()->getName();
else {
Modified: cfe/trunk/test/CodeGenCXX/predefined-expr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/predefined-expr.cpp?rev=223136&r1=223135&r2=223136&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/predefined-expr.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/predefined-expr.cpp Tue Dec 2 12:42:51 2014
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -std=c++11 %s -triple %itanium_abi_triple -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -std=c++11 -fblocks %s -triple %itanium_abi_triple -emit-llvm -o - | FileCheck %s
// CHECK: private unnamed_addr constant [15 x i8] c"externFunction\00"
// CHECK: private unnamed_addr constant [26 x i8] c"void NS::externFunction()\00"
@@ -537,3 +537,33 @@ int main() {
return 0;
}
+
+// rdar://19065361
+class XXX {
+ XXX();
+ ~XXX();
+};
+
+void XXLog(const char *functionName) { }
+
+typedef void (^notify_handler_t)(int token);
+
+typedef void (^dispatch_block_t)(void);
+
+void notify_register_dispatch(notify_handler_t handler);
+
+void _dispatch_once(dispatch_block_t block);
+
+XXX::XXX()
+{
+ _dispatch_once(^{ notify_register_dispatch( ^(int token) { XXLog(__FUNCTION__); });
+ });
+}
+// CHECK: define internal void @___ZN3XXXC2Ev_block_invoke_
+
+XXX::~XXX()
+{
+ _dispatch_once(^{ notify_register_dispatch( ^(int token) { XXLog(__FUNCTION__); });
+ });
+}
+// CHECK: define internal void @___ZN3XXXD2Ev_block_invoke_
More information about the cfe-commits
mailing list