[cfe-commits] r156517 - in /cfe/trunk: include/clang/AST/TypeLoc.h lib/Parse/ParseObjc.cpp lib/Sema/SemaDecl.cpp lib/Sema/SemaType.cpp test/FixIt/fixit-interface-as-param.m
Fariborz Jahanian
fjahanian at apple.com
Wed May 9 14:49:29 PDT 2012
Author: fjahanian
Date: Wed May 9 16:49:29 2012
New Revision: 156517
URL: http://llvm.org/viewvc/llvm-project?rev=156517&view=rev
Log:
objective-c. Fixes a 'fixit' where location of
'*' on objective-c class name was misplaced.
// rdar://11311333
Added:
cfe/trunk/test/FixIt/fixit-interface-as-param.m
Modified:
cfe/trunk/include/clang/AST/TypeLoc.h
cfe/trunk/lib/Parse/ParseObjc.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaType.cpp
Modified: cfe/trunk/include/clang/AST/TypeLoc.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/TypeLoc.h?rev=156517&r1=156516&r2=156517&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/TypeLoc.h (original)
+++ cfe/trunk/include/clang/AST/TypeLoc.h Wed May 9 16:49:29 2012
@@ -831,6 +831,7 @@
struct ObjCInterfaceLocInfo {
SourceLocation NameLoc;
+ SourceLocation NameEndLoc;
};
/// \brief Wrapper for source info for ObjC interfaces.
@@ -850,9 +851,17 @@
void setNameLoc(SourceLocation Loc) {
getLocalData()->NameLoc = Loc;
}
-
+
SourceRange getLocalSourceRange() const {
- return SourceRange(getNameLoc());
+ return SourceRange(getNameLoc(), getNameEndLoc());
+ }
+
+ SourceLocation getNameEndLoc() const {
+ return getLocalData()->NameEndLoc;
+ }
+
+ void setNameEndLoc(SourceLocation Loc) {
+ getLocalData()->NameEndLoc = Loc;
}
void initializeLocal(ASTContext &Context, SourceLocation Loc) {
Modified: cfe/trunk/lib/Parse/ParseObjc.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseObjc.cpp?rev=156517&r1=156516&r2=156517&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseObjc.cpp (original)
+++ cfe/trunk/lib/Parse/ParseObjc.cpp Wed May 9 16:49:29 2012
@@ -894,6 +894,7 @@
DeclSpec declSpec(AttrFactory);
declSpec.setObjCQualifiers(&DS);
ParseSpecifierQualifierList(declSpec);
+ declSpec.SetRangeEnd(Tok.getLocation().getLocWithOffset(-1));
Declarator declarator(declSpec, context);
ParseDeclarator(declarator);
Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=156517&r1=156516&r2=156517&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Wed May 9 16:49:29 2012
@@ -7193,9 +7193,10 @@
// Parameter declarators cannot be interface types. All ObjC objects are
// passed by reference.
if (T->isObjCObjectType()) {
+ SourceLocation TypeEndLoc = TSInfo->getTypeLoc().getLocEnd();
Diag(NameLoc,
diag::err_object_cannot_be_passed_returned_by_value) << 1 << T
- << FixItHint::CreateInsertion(NameLoc, "*");
+ << FixItHint::CreateInsertion(TypeEndLoc, "*");
T = Context.getObjCObjectPointerType(T);
New->setType(T);
}
Modified: cfe/trunk/lib/Sema/SemaType.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=156517&r1=156516&r2=156517&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaType.cpp (original)
+++ cfe/trunk/lib/Sema/SemaType.cpp Wed May 9 16:49:29 2012
@@ -2882,6 +2882,10 @@
}
void VisitObjCInterfaceTypeLoc(ObjCInterfaceTypeLoc TL) {
TL.setNameLoc(DS.getTypeSpecTypeLoc());
+ // FIXME. We should have DS.getTypeSpecTypeEndLoc(). But, it requires
+ // addition field. What we have is good enough for dispay of location
+ // of 'fixit' on interface name.
+ TL.setNameEndLoc(DS.getLocEnd());
}
void VisitObjCObjectTypeLoc(ObjCObjectTypeLoc TL) {
// Handle the base type, which might not have been written explicitly.
Added: cfe/trunk/test/FixIt/fixit-interface-as-param.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/FixIt/fixit-interface-as-param.m?rev=156517&view=auto
==============================================================================
--- cfe/trunk/test/FixIt/fixit-interface-as-param.m (added)
+++ cfe/trunk/test/FixIt/fixit-interface-as-param.m Wed May 9 16:49:29 2012
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fdiagnostics-parseable-fixits -x objective-c %s 2>&1 | FileCheck %s
+// rdar://11311333
+
+ at interface NSView @end
+
+ at interface INTF
+- (void) drawRect : inView:(NSView)view;
+ at end
+
+// CHECK: {7:34-7:34}:"*"
+
More information about the cfe-commits
mailing list