summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2013-08-13 23:44:55 +0000
committerFariborz Jahanian <fjahanian@apple.com>2013-08-13 23:44:55 +0000
commita802c3526bc896234e252460a086890a6a7749a0 (patch)
treee2d4946713c2f11382c2f7b2aaa4850671a342a5 /clang/lib
parent2e27459d6c016cd0e49151fb3cd0c5c64b858412 (diff)
downloadbcm5719-llvm-a802c3526bc896234e252460a086890a6a7749a0.tar.gz
bcm5719-llvm-a802c3526bc896234e252460a086890a6a7749a0.zip
ObjectiveC [QoI] issue warning if an element of an nsarray
expresison is a concatenated nsstring element. // rdar://14303083 llvm-svn: 188332
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Sema/SemaExprObjC.cpp15
1 files changed, 11 insertions, 4 deletions
diff --git a/clang/lib/Sema/SemaExprObjC.cpp b/clang/lib/Sema/SemaExprObjC.cpp
index de0daca4b8b..e3e91d140a0 100644
--- a/clang/lib/Sema/SemaExprObjC.cpp
+++ b/clang/lib/Sema/SemaExprObjC.cpp
@@ -324,7 +324,8 @@ ExprResult Sema::ActOnObjCBoolLiteral(SourceLocation AtLoc,
/// \brief Check that the given expression is a valid element of an Objective-C
/// collection literal.
static ExprResult CheckObjCCollectionLiteralElement(Sema &S, Expr *Element,
- QualType T) {
+ QualType T,
+ bool ArrayLiteral = false) {
// If the expression is type-dependent, there's nothing for us to do.
if (Element->isTypeDependent())
return Element;
@@ -401,14 +402,20 @@ static ExprResult CheckObjCCollectionLiteralElement(Sema &S, Expr *Element,
Recovered = true;
}
}
-
+
if (!Recovered) {
S.Diag(Element->getLocStart(), diag::err_invalid_collection_element)
<< Element->getType();
return ExprError();
}
}
-
+ if (ArrayLiteral)
+ if (ObjCStringLiteral *getString = dyn_cast<ObjCStringLiteral>(OrigElement)) {
+ if (getString->getString() && getString->getString()->getNumConcatenated() > 1)
+ S.Diag(Element->getLocStart(), diag::warn_concatenated_nsarray_literal)
+ << Element->getType();
+ }
+
// Make sure that the element has the type that the container factory
// function expects.
return S.PerformCopyInitialization(
@@ -710,7 +717,7 @@ ExprResult Sema::BuildObjCArrayLiteral(SourceRange SR, MultiExprArg Elements) {
for (unsigned I = 0, N = Elements.size(); I != N; ++I) {
ExprResult Converted = CheckObjCCollectionLiteralElement(*this,
ElementsBuffer[I],
- RequiredType);
+ RequiredType, true);
if (Converted.isInvalid())
return ExprError();
OpenPOWER on IntegriCloud