[cfe-commits] r79496 - /cfe/trunk/lib/Sema/SemaDeclAttr.cpp

Ted Kremenek kremenek at apple.com
Wed Aug 19 16:56:49 PDT 2009


Author: kremenek
Date: Wed Aug 19 18:56:48 2009
New Revision: 79496

URL: http://llvm.org/viewvc/llvm-project?rev=79496&view=rev
Log:
Enhance diagnostics concerning attribute 'ns_returns_retained' and 'cf_returns_retained' to present the range of the attribute and have the diagnostic location be the declaration that the attribute was falsely attached to.  This solves the problem where these diagnostics were being suppressed when these attributes were wrapped in a macro that was defined in a system header.

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

Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=79496&r1=79495&r2=79496&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Wed Aug 19 18:56:48 2009
@@ -1730,15 +1730,17 @@
   else if (FunctionDecl *FD = dyn_cast<FunctionDecl>(d))
     RetTy = FD->getResultType();
   else {
-    S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type)
-        << Attr.getName() << 3 /* function or method */;
+    SourceLocation L = Attr.getLoc();
+    S.Diag(d->getLocStart(), diag::warn_attribute_wrong_decl_type)
+        << SourceRange(L, L) << Attr.getName() << 3 /* function or method */;
     return;
   }
 
   if (!(S.Context.isObjCNSObjectType(RetTy) || RetTy->getAs<PointerType>()
         || RetTy->getAsObjCObjectPointerType())) {
-    S.Diag(Attr.getLoc(), diag::warn_ns_attribute_wrong_return_type)
-      << Attr.getName();
+    SourceLocation L = Attr.getLoc();
+    S.Diag(d->getLocStart(), diag::warn_ns_attribute_wrong_return_type)
+      << SourceRange(L, L) << Attr.getName();
     return;
   }
 





More information about the cfe-commits mailing list