[cfe-commits] [Patch] correct scope token location when parsing GNU attributes

Richard Smith richard at metafoo.co.uk
Wed Oct 3 22:50:36 PDT 2012


> --- lib/Sema/SemaDecl.cpp (revision 165089)
> +++ lib/Sema/SemaDecl.cpp (working copy)
> @@ -2774,7 +2774,8 @@
>          TypeSpecType == DeclSpec::TST_enum) {
>        AttributeList* attrs = DS.getAttributes().getList();
>        while (attrs) {
> -        Diag(attrs->getScopeLoc(),
> +        Diag(attrs->getScopeLoc().isValid() ?
> +             attrs->getScopeLoc() : attrs->getLoc(),

You can just use attrs->getLoc() here; it points to the first token of the
attribute. LGTM with that change.

Incidentally, Parser::ParseGNUAttributeArgs's call to addNew isn't passing
in the right SourceRange any more: the start should be ScopeLoc if it is
valid.

On Tue, Oct 2, 2012 at 10:03 PM, Michael Han <Michael.Han at autodesk.com>wrote:

> Hi,
>
> Attached patch correct the source location of scopes when parsing and
> creating an attribute in GNU syntax: since the GNU syntax attribute does
> not have scope tokens, we shall use a newly created SourceLocation()
> instead of reuse the attribute token source location. As a result, when
> emitting diagnostics the valid of the locations needs to be checked first
> before used.
>
> Michael
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20121003/965ffc6b/attachment.html>


More information about the cfe-commits mailing list