[cfe-commits] [Patch] -Wformat: properly handle length modifiers used with %n (Was: -Wformat: warn about using length modifiers with %n)

Hans Wennborg hans at chromium.org
Tue Aug 7 02:19:11 PDT 2012


On Mon, Aug 6, 2012 at 6:39 PM, Ted Kremenek <kremenek at apple.com> wrote:
> This looks great.  One comment:
>
>>  std::string ArgType::getRepresentativeTypeName(ASTContext &C) const {
>>    std::string S = getRepresentativeType(C).getAsString();
>> -  if (Name && S != Name)
>> -    return std::string("'") + Name + "' (aka '" + S + "')";
>> +  std::string Alias;
>> +  if (Name) {
>> +    Alias = Name;
>> +    if (Ptr)
>> +      Alias += (Alias[Alias.size()-1] == '*') ? "*" : " *";
>> +    if (S == Alias)
>> +      Alias.clear();
>> +  }
>> +
>> +  if (!Alias.empty())
>> +    return std::string("'") + Alias + "' (aka '" + S + "')";
>>    return std::string("'") + S + "'";
>>  }
>
> Can you add some comments here, specifically around the string construction, that says what it is trying to accomplish?
>
> Overall, the rest of it looks pretty obvious.  Nice clean refactoring, with a bunch of the expected checking logic.

Thanks! Landed r161403, r161407 (with extra comments) and r161408.

 - Hans



More information about the cfe-commits mailing list