r174214 - objc: Provide correct fixit instruction when two mismatched
Fariborz Jahanian
fjahanian at apple.com
Fri Feb 1 12:04:50 PST 2013
Author: fjahanian
Date: Fri Feb 1 14:04:49 2013
New Revision: 174214
URL: http://llvm.org/viewvc/llvm-project?rev=174214&view=rev
Log:
objc: Provide correct fixit instruction when two mismatched
nsstringis are compared without. // rdar://12716301
Added:
cfe/trunk/test/FixIt/fixit-nsstring-compare.m
Modified:
cfe/trunk/lib/Sema/SemaExpr.cpp
Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=174214&r1=174213&r2=174214&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Fri Feb 1 14:04:49 2013
@@ -6964,11 +6964,12 @@ static void diagnoseObjCLiteralCompariso
hasIsEqualMethod(S, LHS.get(), RHS.get())) {
SourceLocation Start = LHS.get()->getLocStart();
SourceLocation End = S.PP.getLocForEndOfToken(RHS.get()->getLocEnd());
- SourceRange OpRange(Loc, S.PP.getLocForEndOfToken(Loc));
+ CharSourceRange OpRange =
+ CharSourceRange::getCharRange(Loc, S.PP.getLocForEndOfToken(Loc));
S.Diag(Loc, diag::note_objc_literal_comparison_isequal)
<< FixItHint::CreateInsertion(Start, Opc == BO_EQ ? "[" : "![")
- << FixItHint::CreateReplacement(OpRange, "isEqual:")
+ << FixItHint::CreateReplacement(OpRange, " isEqual:")
<< FixItHint::CreateInsertion(End, "]");
}
}
Added: cfe/trunk/test/FixIt/fixit-nsstring-compare.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/FixIt/fixit-nsstring-compare.m?rev=174214&view=auto
==============================================================================
--- cfe/trunk/test/FixIt/fixit-nsstring-compare.m (added)
+++ cfe/trunk/test/FixIt/fixit-nsstring-compare.m Fri Feb 1 14:04:49 2013
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fdiagnostics-parseable-fixits -x objective-c %s 2>&1 | FileCheck %s
+// rdar://12716301
+
+typedef unsigned char BOOL;
+
+ at protocol NSObject
+- (BOOL)isEqual:(id)object;
+ at end
+
+ at interface NSString<NSObject>
+ at end
+
+int main() {
+ NSString *stringA = @"stringA";
+
+ BOOL comparison = stringA==@"stringB";
+
+}
+
+// CHECK: {16:21-16:21}:"["
+// CHECK: {16:28-16:30}:" isEqual:"
+// CHECK: {16:40-16:40}:"]"
More information about the cfe-commits
mailing list