[cfe-commits] [PATCH] Improve the warning for cv-qualifiers on free functions.

Ahmed Charles ahmedcharles at gmail.com
Mon Oct 17 16:11:12 PDT 2011


Test and using isBeforeInTranslationUnit().

On Mon, Oct 17, 2011 at 9:23 AM, Douglas Gregor <dgregor at apple.com> wrote:
>
> On Oct 17, 2011, at 9:17 AM, Ahmed Charles wrote:
>
>> Thanks. Another thing, I'm trying to convince myself that nothing can
>> come between const and volatile if both are there, is that true or is
>> it possible to have a token between them? I.e. Should I have two
>> fixits rather than one?
>
> The grammar says
>
>        parameters-and-qualifiers:
>                ( parameter-declaration-clause ) attribute-specifier-seq[opt] cv-qualifier-seq[opt]
>                ref-qualifier[opt] exception-specification[opt]
>
> so nothing can come between the 'const' and 'volatile' except perhaps some whitespace and macro expansions that expand to nothing (neither of which we care about).
>
> One other comment:
>
> +                case Qualifiers::Const | Qualifiers::Volatile: {
> +                    SourceLocation CLoc = Chunk.Fun.getConstQualifierLoc();
> +                    SourceLocation VLoc = Chunk.Fun.getVolatileQualifierLoc();
> +                    Range =
> +                        SourceRange(std::min(CLoc, VLoc), std::max(CLoc, VLoc));
> +                  }
> +                  break;
>
> The "min()" here doesn't actually do the right thing. You'll need to use SourceManager::isBeforeInTranslationUnit().
>
> Otherwise, your patch is looking good, once it has a test case.
>
>        - Doug
>



-- 
Ahmed Charles
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0006-Improve-the-warning-for-cv-qualifiers-on-free-functi.patch
Type: application/octet-stream
Size: 11101 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20111017/2249856a/attachment.obj>


More information about the cfe-commits mailing list