From d7e52b8141c8fbff1b9f9e7960c925a00953cc12 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Sun, 5 Sep 2010 00:43:21 +0000 Subject: [PATCH] "const id *" instead of "id const *". I think this wraps up all the legal cases. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@113096 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/AST/TypePrinter.cpp | 16 +++++++++------- test/SemaObjC/method-arg-qualifier-warning.m | 4 ++-- test/SemaObjCXX/objc-pointer-conv.mm | 4 ++-- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/lib/AST/TypePrinter.cpp b/lib/AST/TypePrinter.cpp index 21f855b8e8..b8ce77b7f8 100644 --- a/lib/AST/TypePrinter.cpp +++ b/lib/AST/TypePrinter.cpp @@ -680,14 +680,19 @@ void TypePrinter::PrintObjCObjectPointer(const ObjCObjectPointerType *T, std::string &S) { std::string ObjCQIString; + T->getPointeeType().getLocalQualifiers().getAsStringInternal(ObjCQIString, + Policy); + if (!ObjCQIString.empty()) + ObjCQIString += ' '; + if (T->isObjCIdType() || T->isObjCQualifiedIdType()) - ObjCQIString = "id"; + ObjCQIString += "id"; else if (T->isObjCClassType() || T->isObjCQualifiedClassType()) - ObjCQIString = "Class"; + ObjCQIString += "Class"; else if (T->isObjCSelType()) - ObjCQIString = "SEL"; + ObjCQIString += "SEL"; else - ObjCQIString = T->getInterfaceDecl()->getNameAsString(); + ObjCQIString += T->getInterfaceDecl()->getNameAsString(); if (!T->qual_empty()) { ObjCQIString += '<'; @@ -701,9 +706,6 @@ void TypePrinter::PrintObjCObjectPointer(const ObjCObjectPointerType *T, ObjCQIString += '>'; } - T->getPointeeType().getLocalQualifiers().getAsStringInternal(ObjCQIString, - Policy); - if (!T->isObjCIdType() && !T->isObjCQualifiedIdType()) ObjCQIString += " *"; // Don't forget the implicit pointer. else if (!S.empty()) // Prefix the basic type, e.g. 'typedefname X'. diff --git a/test/SemaObjC/method-arg-qualifier-warning.m b/test/SemaObjC/method-arg-qualifier-warning.m index 463fb7fd77..690509e795 100644 --- a/test/SemaObjC/method-arg-qualifier-warning.m +++ b/test/SemaObjC/method-arg-qualifier-warning.m @@ -12,8 +12,8 @@ static NSString * const Identifier3 = @"Identifier3"; int main () { - [@"Identifier1" isEqualToString:Identifier1]; // expected-warning {{sending 'NSString const *' to parameter of type 'NSString *' discards qualifiers}} - [@"Identifier2" isEqualToString:Identifier2]; // expected-warning {{sending 'NSString const *' to parameter of type 'NSString *' discards qualifiers}} + [@"Identifier1" isEqualToString:Identifier1]; // expected-warning {{sending 'const NSString *' to parameter of type 'NSString *' discards qualifiers}} + [@"Identifier2" isEqualToString:Identifier2]; // expected-warning {{sending 'const NSString *' to parameter of type 'NSString *' discards qualifiers}} [@"Identifier3" isEqualToString:Identifier3]; return 0; } diff --git a/test/SemaObjCXX/objc-pointer-conv.mm b/test/SemaObjCXX/objc-pointer-conv.mm index af239a8c5b..335c240c17 100644 --- a/test/SemaObjCXX/objc-pointer-conv.mm +++ b/test/SemaObjCXX/objc-pointer-conv.mm @@ -29,10 +29,10 @@ void RandomFunc(CFMDRef theDict, const void *key, const void *value); - (void) Meth : (I*) Arg; // expected-note{{passing argument to parameter 'Arg' here}} @end -void Func (I* arg); // expected-note {{candidate function not viable: no known conversion from 'I const *' to 'I *' for 1st argument}} +void Func (I* arg); // expected-note {{candidate function not viable: no known conversion from 'const I *' to 'I *' for 1st argument}} void foo(const I *p, I* sel) { - [sel Meth : p]; // expected-error {{cannot initialize a parameter of type 'I *' with an lvalue of type 'I const *'}} + [sel Meth : p]; // expected-error {{cannot initialize a parameter of type 'I *' with an lvalue of type 'const I *'}} Func(p); // expected-error {{no matching function for call to 'Func'}} } -- 2.40.0