[cfe-commits] r140711 - /cfe/trunk/lib/Sema/SemaType.cpp

Argyrios Kyrtzidis akyrtzi at gmail.com
Wed Sep 28 11:35:07 PDT 2011


Author: akirtzidis
Date: Wed Sep 28 13:35:06 2011
New Revision: 140711

URL: http://llvm.org/viewvc/llvm-project?rev=140711&view=rev
Log:
For __weak/__strong/etc. ownership attributes, don't macro expand them in diagnostics.

Modified:
    cfe/trunk/lib/Sema/SemaType.cpp

Modified: cfe/trunk/lib/Sema/SemaType.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=140711&r1=140710&r2=140711&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaType.cpp (original)
+++ cfe/trunk/lib/Sema/SemaType.cpp Wed Sep 28 13:35:06 2011
@@ -3142,15 +3142,18 @@
     return false;
 
   Sema &S = state.getSema();
+  SourceLocation AttrLoc = attr.getLoc();
+  if (AttrLoc.isMacroID())
+    AttrLoc = S.getSourceManager().getImmediateExpansionRange(AttrLoc).first;
 
   if (type.getQualifiers().getObjCLifetime()) {
-    S.Diag(attr.getLoc(), diag::err_attr_objc_ownership_redundant)
+    S.Diag(AttrLoc, diag::err_attr_objc_ownership_redundant)
       << type;
     return true;
   }
 
   if (!attr.getParameterName()) {
-    S.Diag(attr.getLoc(), diag::err_attribute_argument_n_not_string)
+    S.Diag(AttrLoc, diag::err_attribute_argument_n_not_string)
       << "objc_ownership" << 1;
     attr.setInvalid();
     return true;
@@ -3166,7 +3169,7 @@
   else if (attr.getParameterName()->isStr("autoreleasing"))
     lifetime = Qualifiers::OCL_Autoreleasing;
   else {
-    S.Diag(attr.getLoc(), diag::warn_attribute_type_not_supported)
+    S.Diag(AttrLoc, diag::warn_attribute_type_not_supported)
       << "objc_ownership" << attr.getParameterName();
     attr.setInvalid();
     return true;
@@ -3184,7 +3187,7 @@
 
   // If we have a valid source location for the attribute, use an
   // AttributedType instead.
-  if (attr.getLoc().isValid())
+  if (AttrLoc.isValid())
     type = S.Context.getAttributedType(AttributedType::attr_objc_ownership,
                                        origType, type);
 
@@ -3195,10 +3198,11 @@
     // Actually, delay this until we know what we're parsing.
     if (S.DelayedDiagnostics.shouldDelayDiagnostics()) {
       S.DelayedDiagnostics.add(
-          sema::DelayedDiagnostic::makeForbiddenType(attr.getLoc(),
+          sema::DelayedDiagnostic::makeForbiddenType(
+              S.getSourceManager().getExpansionLoc(AttrLoc),
               diag::err_arc_weak_no_runtime, type, /*ignored*/ 0));
     } else {
-      S.Diag(attr.getLoc(), diag::err_arc_weak_no_runtime);
+      S.Diag(AttrLoc, diag::err_arc_weak_no_runtime);
     }
 
     attr.setInvalid();
@@ -3214,7 +3218,7 @@
     if (const ObjCObjectPointerType *ObjT = T->getAs<ObjCObjectPointerType>()) {
       ObjCInterfaceDecl *Class = ObjT->getInterfaceDecl();
       if (Class->isArcWeakrefUnavailable()) {
-          S.Diag(attr.getLoc(), diag::err_arc_unsupported_weak_class);
+          S.Diag(AttrLoc, diag::err_arc_unsupported_weak_class);
           S.Diag(ObjT->getInterfaceDecl()->getLocation(), 
                  diag::note_class_declared);
       }





More information about the cfe-commits mailing list