aboutsummaryrefslogtreecommitdiff
path: root/lib/Analysis/PrintfFormatString.cpp
diff options
context:
space:
mode:
authorTom Care <tcare@apple.com>2010-06-11 04:22:02 +0000
committerTom Care <tcare@apple.com>2010-06-11 04:22:02 +0000
commit876e994957472eda4b40136d4e1d6e08e2be338f (patch)
treee11b0094f73ab59b6f69a7df8ab80cbcf588830c /lib/Analysis/PrintfFormatString.cpp
parente60cea829b3bc45fcfedbfdb08cffb61f5bde79f (diff)
Small fixes regarding printf fix suggestions.
- Added some handling of flags that become invalid when changing the conversion specifier. - Changed fixit behavior to remove unnecessary length modifiers. - Separated some tests out and added some comments. modified: lib/Analysis/PrintfFormatString.cpp test/Sema/format-strings-fixit.c git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@105807 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/PrintfFormatString.cpp')
-rw-r--r--lib/Analysis/PrintfFormatString.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/Analysis/PrintfFormatString.cpp b/lib/Analysis/PrintfFormatString.cpp
index 03aff386c2..99dc22901c 100644
--- a/lib/Analysis/PrintfFormatString.cpp
+++ b/lib/Analysis/PrintfFormatString.cpp
@@ -686,6 +686,10 @@ bool FormatSpecifier::fixType(QualType QT) {
if (QT->isPointerType() && (QT->getPointeeType()->isAnyCharacterType())) {
CS.setKind(ConversionSpecifier::CStrArg);
+ // Disable irrelevant flags
+ HasAlternativeForm = 0;
+ HasLeadingZeroes = 0;
+
// Set the long length modifier for wide characters
if (QT->getPointeeType()->isWideCharType())
LM.setKind(LengthModifier::AsWideChar);
@@ -699,10 +703,14 @@ bool FormatSpecifier::fixType(QualType QT) {
// Everything else should be a base type
const BuiltinType *BT = QT->getAs<BuiltinType>();
+
// Set length modifier
switch (BT->getKind()) {
default:
+ // The rest of the conversions are either optional or for non-builtin types
+ LM.setKind(LengthModifier::None);
break;
+
case BuiltinType::WChar:
case BuiltinType::Long:
case BuiltinType::ULong: