aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema
diff options
context:
space:
mode:
authorEd Schouten <ed@FreeBSD.org>2009-06-08 15:36:55 +0000
committerEd Schouten <ed@FreeBSD.org>2009-06-08 15:36:55 +0000
commit8ba99c00327a4394e7568244d6cffd6e62625a7a (patch)
tree7ab9fa5634c95f5df8575db81b24ea5586e65b28 /lib/Sema
parent70b4596d9d0d559e94f9bad8f43463e5d98a577e (diff)
downloadsrc-8ba99c00327a4394e7568244d6cffd6e62625a7a.tar.gz
src-8ba99c00327a4394e7568244d6cffd6e62625a7a.zip
Import Clang r73070.vendor/clang/clang-r73070
Notes
Notes: svn path=/vendor/clang/dist/; revision=193725 svn path=/vendor/clang/clang-r73070./; revision=193727; tag=vendor/clang/clang-r73070
Diffstat (limited to 'lib/Sema')
-rw-r--r--lib/Sema/Sema.h4
-rw-r--r--lib/Sema/SemaExpr.cpp10
-rw-r--r--lib/Sema/SemaExprObjC.cpp37
-rw-r--r--lib/Sema/SemaTemplateDeduction.cpp31
-rw-r--r--lib/Sema/SemaTemplateInstantiateExpr.cpp25
5 files changed, 79 insertions, 28 deletions
diff --git a/lib/Sema/Sema.h b/lib/Sema/Sema.h
index d3bfef67cbc8..c5582935db7f 100644
--- a/lib/Sema/Sema.h
+++ b/lib/Sema/Sema.h
@@ -1696,6 +1696,10 @@ public:
virtual ExprResult ParseObjCStringLiteral(SourceLocation *AtLocs,
ExprTy **Strings,
unsigned NumStrings);
+
+ Expr *BuildObjCEncodeExpression(SourceLocation AtLoc,
+ QualType EncodedType,
+ SourceLocation RParenLoc);
virtual ExprResult ParseObjCEncodeExpression(SourceLocation AtLoc,
SourceLocation EncodeLoc,
SourceLocation LParenLoc,
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index ee5132a7d8e0..da32d4ec1061 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -3003,8 +3003,8 @@ QualType Sema::CheckConditionalOperands(Expr *&Cond, Expr *&LHS, Expr *&RHS,
compositeType = Context.getObjCIdType();
} else if (LHSBPT || RHSBPT) {
if (!sameKind
- || !Context.typesAreBlockCompatible(lhptee.getUnqualifiedType(),
- rhptee.getUnqualifiedType()))
+ || !Context.typesAreCompatible(lhptee.getUnqualifiedType(),
+ rhptee.getUnqualifiedType()))
Diag(QuestionLoc, diag::err_typecheck_cond_incompatible_operands)
<< LHSTy << RHSTy << LHS->getSourceRange() << RHS->getSourceRange();
return QualType();
@@ -3218,7 +3218,7 @@ Sema::CheckBlockPointerTypesForAssignment(QualType lhsType,
if (lhptee.getCVRQualifiers() != rhptee.getCVRQualifiers())
ConvTy = CompatiblePointerDiscardsQualifiers;
- if (!Context.typesAreBlockCompatible(lhptee, rhptee))
+ if (!Context.typesAreCompatible(lhptee, rhptee))
return IncompatibleBlockPointer;
return ConvTy;
}
@@ -3978,7 +3978,7 @@ QualType Sema::CheckCompareOperands(Expr *&lex, Expr *&rex, SourceLocation Loc,
QualType rpointee = rType->getAsBlockPointerType()->getPointeeType();
if (!LHSIsNull && !RHSIsNull &&
- !Context.typesAreBlockCompatible(lpointee, rpointee)) {
+ !Context.typesAreCompatible(lpointee, rpointee)) {
Diag(Loc, diag::err_typecheck_comparison_of_distinct_blocks)
<< lType << rType << lex->getSourceRange() << rex->getSourceRange();
}
@@ -5220,7 +5220,7 @@ Sema::OwningExprResult Sema::ActOnBlockStmtExpr(SourceLocation CaretLoc,
QualType BlockTy;
if (!BSI->hasPrototype)
- BlockTy = Context.getFunctionNoProtoType(RetTy);
+ BlockTy = Context.getFunctionType(RetTy, 0, 0, false, 0);
else
BlockTy = Context.getFunctionType(RetTy, ArgTypes.data(), ArgTypes.size(),
BSI->isVariadic, 0);
diff --git a/lib/Sema/SemaExprObjC.cpp b/lib/Sema/SemaExprObjC.cpp
index eabc87d7f3b8..b6cf9d8e738c 100644
--- a/lib/Sema/SemaExprObjC.cpp
+++ b/lib/Sema/SemaExprObjC.cpp
@@ -92,6 +92,29 @@ Sema::ExprResult Sema::ParseObjCStringLiteral(SourceLocation *AtLocs,
return new (Context) ObjCStringLiteral(S, Ty, AtLocs[0]);
}
+Expr *Sema::BuildObjCEncodeExpression(SourceLocation AtLoc,
+ QualType EncodedType,
+ SourceLocation RParenLoc) {
+ QualType StrTy;
+ if (EncodedType->isDependentType())
+ StrTy = Context.DependentTy;
+ else {
+ std::string Str;
+ Context.getObjCEncodingForType(EncodedType, Str);
+
+ // The type of @encode is the same as the type of the corresponding string,
+ // which is an array type.
+ StrTy = Context.CharTy;
+ // A C++ string literal has a const-qualified element type (C++ 2.13.4p1).
+ if (getLangOptions().CPlusPlus)
+ StrTy.addConst();
+ StrTy = Context.getConstantArrayType(StrTy, llvm::APInt(32, Str.size()+1),
+ ArrayType::Normal, 0);
+ }
+
+ return new (Context) ObjCEncodeExpr(StrTy, EncodedType, AtLoc, RParenLoc);
+}
+
Sema::ExprResult Sema::ParseObjCEncodeExpression(SourceLocation AtLoc,
SourceLocation EncodeLoc,
SourceLocation LParenLoc,
@@ -99,19 +122,7 @@ Sema::ExprResult Sema::ParseObjCEncodeExpression(SourceLocation AtLoc,
SourceLocation RParenLoc) {
QualType EncodedType = QualType::getFromOpaquePtr(ty);
- std::string Str;
- Context.getObjCEncodingForType(EncodedType, Str);
-
- // The type of @encode is the same as the type of the corresponding string,
- // which is an array type.
- QualType StrTy = Context.CharTy;
- // A C++ string literal has a const-qualified element type (C++ 2.13.4p1).
- if (getLangOptions().CPlusPlus)
- StrTy.addConst();
- StrTy = Context.getConstantArrayType(StrTy, llvm::APInt(32, Str.size()+1),
- ArrayType::Normal, 0);
-
- return new (Context) ObjCEncodeExpr(StrTy, EncodedType, AtLoc, RParenLoc);
+ return BuildObjCEncodeExpression(AtLoc, EncodedType, RParenLoc);
}
Sema::ExprResult Sema::ParseObjCSelectorExpression(Selector Sel,
diff --git a/lib/Sema/SemaTemplateDeduction.cpp b/lib/Sema/SemaTemplateDeduction.cpp
index 812b319804d7..db7e622f7f68 100644
--- a/lib/Sema/SemaTemplateDeduction.cpp
+++ b/lib/Sema/SemaTemplateDeduction.cpp
@@ -265,6 +265,37 @@ static bool DeduceTemplateArguments(ASTContext &Context, QualType Param,
return false;
}
+ case Type::FunctionProto: {
+ const FunctionProtoType *FunctionProtoArg =
+ dyn_cast<FunctionProtoType>(Arg);
+ if (!FunctionProtoArg)
+ return false;
+
+ const FunctionProtoType *FunctionProtoParam =
+ cast<FunctionProtoType>(Param);
+
+ // Check return types.
+ if (!DeduceTemplateArguments(Context,
+ FunctionProtoParam->getResultType(),
+ FunctionProtoArg->getResultType(),
+ Deduced))
+ return false;
+
+ if (FunctionProtoParam->getNumArgs() != FunctionProtoArg->getNumArgs())
+ return false;
+
+ for (unsigned I = 0, N = FunctionProtoParam->getNumArgs(); I != N; ++I) {
+ // Check argument types.
+ if (!DeduceTemplateArguments(Context,
+ FunctionProtoParam->getArgType(I),
+ FunctionProtoArg->getArgType(I),
+ Deduced))
+ return false;
+ }
+
+ return true;
+ }
+
default:
break;
}
diff --git a/lib/Sema/SemaTemplateInstantiateExpr.cpp b/lib/Sema/SemaTemplateInstantiateExpr.cpp
index 5ba42f2e5af9..fa5fdee2c13c 100644
--- a/lib/Sema/SemaTemplateInstantiateExpr.cpp
+++ b/lib/Sema/SemaTemplateInstantiateExpr.cpp
@@ -1216,15 +1216,22 @@ TemplateExprInstantiator::VisitCXXUnresolvedMemberExpr(
// Objective-C Expressions
//----------------------------------------------------------------------------
Sema::OwningExprResult
-TemplateExprInstantiator::VisitObjCStringLiteral(ObjCStringLiteral *E) {
- assert(false && "FIXME: Template instantiations for ObjC expressions");
- return SemaRef.ExprError();
+TemplateExprInstantiator::VisitObjCStringLiteral(ObjCStringLiteral *E) {
+ return SemaRef.Owned(E->Clone(SemaRef.Context));
}
Sema::OwningExprResult
-TemplateExprInstantiator::VisitObjCEncodeExpr(ObjCEncodeExpr *E) {
- assert(false && "FIXME: Template instantiations for ObjC expressions");
- return SemaRef.ExprError();
+TemplateExprInstantiator::VisitObjCEncodeExpr(ObjCEncodeExpr *E) {
+ QualType EncodedType = SemaRef.InstantiateType(E->getEncodedType(),
+ TemplateArgs,
+ /*FIXME:*/E->getAtLoc(),
+ DeclarationName());
+ if (EncodedType.isNull())
+ return SemaRef.ExprError();
+
+ return SemaRef.Owned(SemaRef.BuildObjCEncodeExpression(E->getAtLoc(),
+ EncodedType,
+ E->getRParenLoc()));
}
Sema::OwningExprResult
@@ -1235,14 +1242,12 @@ TemplateExprInstantiator::VisitObjCMessageExpr(ObjCMessageExpr *E) {
Sema::OwningExprResult
TemplateExprInstantiator::VisitObjCSelectorExpr(ObjCSelectorExpr *E) {
- assert(false && "FIXME: Template instantiations for ObjC expressions");
- return SemaRef.ExprError();
+ return SemaRef.Owned(E->Clone(SemaRef.Context));
}
Sema::OwningExprResult
TemplateExprInstantiator::VisitObjCProtocolExpr(ObjCProtocolExpr *E) {
- assert(false && "FIXME: Template instantiations for ObjC expressions");
- return SemaRef.ExprError();
+ return SemaRef.Owned(E->Clone(SemaRef.Context));
}
Sema::OwningExprResult