summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/CodeGen')
-rw-r--r--clang/lib/CodeGen/CGBlocks.cpp39
-rw-r--r--clang/lib/CodeGen/CGExpr.cpp11
2 files changed, 11 insertions, 39 deletions
diff --git a/clang/lib/CodeGen/CGBlocks.cpp b/clang/lib/CodeGen/CGBlocks.cpp
index a26c0709e39..e50b320a0cd 100644
--- a/clang/lib/CodeGen/CGBlocks.cpp
+++ b/clang/lib/CodeGen/CGBlocks.cpp
@@ -132,42 +132,6 @@ static bool CanBlockBeGlobal(const CodeGenFunction::BlockInfo &Info)
return Info.ByRefDeclRefs.empty() && Info.ByCopyDeclRefs.empty();
}
-/// CanGenerateCodeForBlockExpr - Returns whether CodeGen for the block expr
-/// is supported. Will emit a diagnostic and return false if not.
-/// FIXME: Once we support everything this should of course be removed.
-static bool CanGenerateCodeForBlockExpr(CodeGenFunction &CGF,
- const BlockExpr* BE,
- const CodeGenFunction::BlockInfo &Info)
-{
- if (!Info.ByRefDeclRefs.empty()) {
- CGF.ErrorUnsupported(BE, "block expression with __block variables");
- return false;
- }
-
- for (size_t I = 0, E = Info.ByCopyDeclRefs.size(); I != E; ++I) {
- const BlockDeclRefExpr *E = Info.ByCopyDeclRefs[I];
-
- if (E->getType()->isBlockPointerType()) {
- CGF.ErrorUnsupported(BE, "block expression with imported block");
- return false;
- }
-
- if (E->getDecl()->getAttr<ObjCNSObjectAttr>() ||
- CGF.getContext().isObjCNSObjectType(E->getType())) {
- CGF.ErrorUnsupported(BE, "block expression with __attribute__((NSObject))"
- " variable");
- return false;
- }
-
- if (CGF.getContext().isObjCObjectPointerType(E->getType())) {
- CGF.ErrorUnsupported(BE, "block expression with Objective-C variable");
- return false;
- }
- }
-
- return true;
-}
-
// FIXME: Push most into CGM, passing down a few bits, like current
// function name.
llvm::Value *CodeGenFunction::BuildBlockLiteralTmp(const BlockExpr *BE) {
@@ -180,9 +144,6 @@ llvm::Value *CodeGenFunction::BuildBlockLiteralTmp(const BlockExpr *BE) {
if (CanBlockBeGlobal(Info))
return CGM.GetAddrOfGlobalBlock(BE, Name.c_str());
- if (!CanGenerateCodeForBlockExpr(*this, BE, Info))
- return llvm::UndefValue::get(ConvertType(BE->getType()));
-
std::vector<llvm::Constant*> Elts;
llvm::Constant *C;
llvm::Value *V;
diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
index 7e8eff3847d..5485e9eb1f6 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/lib/CodeGen/CGExpr.cpp
@@ -674,6 +674,17 @@ llvm::Value *CodeGenFunction::GetAddrOfBlockDecl(const BlockDeclRefExpr *E) {
const llvm::Type *Ty;
Ty = CGM.getTypes().ConvertType(E->getDecl()->getType());
+ if (E->isByRef())
+ ErrorUnsupported(E, "__block variable in block literal");
+ else if (E->getType()->isBlockPointerType())
+ ErrorUnsupported(E, "block pointer in block literal");
+ else if (E->getDecl()->getAttr<ObjCNSObjectAttr>() ||
+ getContext().isObjCNSObjectType(E->getType()))
+ ErrorUnsupported(E, "__attribute__((NSObject)) variable in block "
+ "literal");
+ else if (getContext().isObjCObjectPointerType(E->getType()))
+ ErrorUnsupported(E, "Objective-C variable in block literal");
+
// See if we have already allocated an offset for this variable.
if (offset == 0) {
// if not, allocate one now.
OpenPOWER on IntegriCloud