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

Douglas Gregor dgregor at apple.com
Tue Oct 18 23:07:22 PDT 2011


On Oct 17, 2011, at 4:11 PM, Ahmed Charles wrote:

> Test and using isBeforeInTranslationUnit().

I've committed this as r142478, thanks!

	- Doug

> 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
> <0006-Improve-the-warning-for-cv-qualifiers-on-free-functi.patch>




More information about the cfe-commits mailing list