[cfe-commits] r130335 - /cfe/trunk/lib/Analysis/PrintfFormatString.cpp
Douglas Gregor
dgregor at apple.com
Wed Apr 27 15:15:54 PDT 2011
On Apr 27, 2011, at 3:06 PM, Eli Friedman wrote:
> Author: efriedma
> Date: Wed Apr 27 17:06:20 2011
> New Revision: 130335
>
> URL: http://llvm.org/viewvc/llvm-project?rev=130335&view=rev
> Log:
> Don't print fixits for format specifiers in cases where the fixit does not actually fix the warning. PR8781.
>
> I'm not sure what the preferred way to write a test for whether a fixit is emitted.
Check out the tests in test/FixIt. Basically, we do a -verify check first. Then, we copy the source file to another file, run clang -cc1 in "-fixit" mode to apply the fix-its in place, and then check that the file syntax-checks without any more errors.
- Doug
>
> Modified:
> cfe/trunk/lib/Analysis/PrintfFormatString.cpp
>
> Modified: cfe/trunk/lib/Analysis/PrintfFormatString.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/PrintfFormatString.cpp?rev=130335&r1=130334&r2=130335&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Analysis/PrintfFormatString.cpp (original)
> +++ cfe/trunk/lib/Analysis/PrintfFormatString.cpp Wed Apr 27 17:06:20 2011
> @@ -381,8 +381,32 @@
>
> // Set length modifier
> switch (BT->getKind()) {
> - default:
> - // The rest of the conversions are either optional or for non-builtin types
> + case BuiltinType::Bool:
> + case BuiltinType::WChar_U:
> + case BuiltinType::WChar_S:
> + case BuiltinType::Char16:
> + case BuiltinType::Char32:
> + case BuiltinType::UInt128:
> + case BuiltinType::Int128:
> + // Integral types which are non-trivial to correct.
> + return false;
> +
> + case BuiltinType::Void:
> + case BuiltinType::NullPtr:
> + case BuiltinType::ObjCId:
> + case BuiltinType::ObjCClass:
> + case BuiltinType::ObjCSel:
> + case BuiltinType::Dependent:
> + case BuiltinType::Overload:
> + case BuiltinType::BoundMember:
> + case BuiltinType::UnknownAny:
> + // Misc other stuff which doesn't make sense here.
> + return false;
> +
> + case BuiltinType::UInt:
> + case BuiltinType::Int:
> + case BuiltinType::Float:
> + case BuiltinType::Double:
> LM.setKind(LengthModifier::None);
> break;
>
> @@ -398,8 +422,6 @@
> LM.setKind(LengthModifier::AsShort);
> break;
>
> - case BuiltinType::WChar_S:
> - case BuiltinType::WChar_U:
> case BuiltinType::Long:
> case BuiltinType::ULong:
> LM.setKind(LengthModifier::AsLong);
> @@ -429,13 +451,6 @@
> else if (QT->isRealFloatingType()) {
> CS.setKind(ConversionSpecifier::fArg);
> }
> - else if (QT->isPointerType()) {
> - CS.setKind(ConversionSpecifier::pArg);
> - Precision.setHowSpecified(OptionalAmount::NotSpecified);
> - HasAlternativeForm = 0;
> - HasLeadingZeroes = 0;
> - HasPlusPrefix = 0;
> - }
> else if (QT->isSignedIntegerType()) {
> CS.setKind(ConversionSpecifier::dArg);
> HasAlternativeForm = 0;
> @@ -448,7 +463,7 @@
> HasPlusPrefix = 0;
> }
> else {
> - return false;
> + assert(0 && "Unexpected type");
> }
>
> return true;
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
More information about the cfe-commits
mailing list