aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEli Friedman <eli.friedman@gmail.com>2011-04-27 22:06:20 +0000
committerEli Friedman <eli.friedman@gmail.com>2011-04-27 22:06:20 +0000
commit06d88ec4204be7af2cf935f39a3e3391d281ad52 (patch)
treef0169a48c90aa42323d6144bd18d2a2ef476817f
parent251c27b6299a841d97901a014d02e4a62f1b6e8e (diff)
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@130335 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Analysis/PrintfFormatString.cpp39
1 files changed, 27 insertions, 12 deletions
diff --git a/lib/Analysis/PrintfFormatString.cpp b/lib/Analysis/PrintfFormatString.cpp
index 19a9134c04..00b0b279e4 100644
--- a/lib/Analysis/PrintfFormatString.cpp
+++ b/lib/Analysis/PrintfFormatString.cpp
@@ -381,8 +381,32 @@ bool PrintfSpecifier::fixType(QualType QT) {
// 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 @@ bool PrintfSpecifier::fixType(QualType QT) {
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 @@ bool PrintfSpecifier::fixType(QualType QT) {
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 @@ bool PrintfSpecifier::fixType(QualType QT) {
HasPlusPrefix = 0;
}
else {
- return false;
+ assert(0 && "Unexpected type");
}
return true;