summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaExpr.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2015-07-07 03:58:01 +0000
committerDouglas Gregor <dgregor@apple.com>2015-07-07 03:58:01 +0000
commitc5e07f5c115ed486f57db957447086c1b0023385 (patch)
tree9709fc3db84e459cb5da1bbc17c224f50c369c5c /clang/lib/Sema/SemaExpr.cpp
parente83b95641f911e44c8c092bc0eef7743df0cd73d (diff)
downloadbcm5719-llvm-c5e07f5c115ed486f57db957447086c1b0023385.tar.gz
bcm5719-llvm-c5e07f5c115ed486f57db957447086c1b0023385.zip
Improve the Objective-C common-type computation used by the ternary operator.
The Objective-C common-type computation had a few problems that required a significant rework, including: - Quadradic behavior when finding the common base type; now it's linear. - Keeping around type arguments when computing the common type between a specialized and an unspecialized type - Introducing redundant protocol qualifiers. Part of rdar://problem/6294649. Also fixes rdar://problem/19572837 by addressing a longstanding bug in ASTContext::CollectInheritedProtocols(). llvm-svn: 241544
Diffstat (limited to 'clang/lib/Sema/SemaExpr.cpp')
-rw-r--r--clang/lib/Sema/SemaExpr.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index afc9279cba1..a4911c20c68 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -6273,7 +6273,10 @@ QualType Sema::FindCompositeObjCPointerType(ExprResult &LHS, ExprResult &RHS,
// FIXME: Consider unifying with 'areComparableObjCPointerTypes'.
// It could return the composite type.
- if (Context.canAssignObjCInterfaces(LHSOPT, RHSOPT)) {
+ if (!(compositeType =
+ Context.areCommonBaseCompatible(LHSOPT, RHSOPT)).isNull()) {
+ // Nothing more to do.
+ } else if (Context.canAssignObjCInterfaces(LHSOPT, RHSOPT)) {
compositeType = RHSOPT->isObjCBuiltinType() ? RHSTy : LHSTy;
} else if (Context.canAssignObjCInterfaces(RHSOPT, LHSOPT)) {
compositeType = LHSOPT->isObjCBuiltinType() ? LHSTy : RHSTy;
@@ -6287,10 +6290,7 @@ QualType Sema::FindCompositeObjCPointerType(ExprResult &LHS, ExprResult &RHS,
compositeType = Context.getObjCIdType();
} else if (LHSTy->isObjCIdType() || RHSTy->isObjCIdType()) {
compositeType = Context.getObjCIdType();
- } else if (!(compositeType =
- Context.areCommonBaseCompatible(LHSOPT, RHSOPT)).isNull())
- ;
- else {
+ } else {
Diag(QuestionLoc, diag::ext_typecheck_cond_incompatible_operands)
<< LHSTy << RHSTy
<< LHS.get()->getSourceRange() << RHS.get()->getSourceRange();
OpenPOWER on IntegriCloud