diff options
author | Tom Care <tcare@apple.com> | 2010-06-11 04:22:02 +0000 |
---|---|---|
committer | Tom Care <tcare@apple.com> | 2010-06-11 04:22:02 +0000 |
commit | 00554634db29d7fb7aab508a2e0c84ff6a1ecfcc (patch) | |
tree | 81eaeb30260d11d065a260e0e60412a80abc4683 /clang/lib/Analysis/PrintfFormatString.cpp | |
parent | 41f923275eb15ac0b2fc9442f272fd6e4ed8f12a (diff) | |
download | bcm5719-llvm-00554634db29d7fb7aab508a2e0c84ff6a1ecfcc.tar.gz bcm5719-llvm-00554634db29d7fb7aab508a2e0c84ff6a1ecfcc.zip |
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
llvm-svn: 105807
Diffstat (limited to 'clang/lib/Analysis/PrintfFormatString.cpp')
-rw-r--r-- | clang/lib/Analysis/PrintfFormatString.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/clang/lib/Analysis/PrintfFormatString.cpp b/clang/lib/Analysis/PrintfFormatString.cpp index 03aff386c26..99dc22901c7 100644 --- a/clang/lib/Analysis/PrintfFormatString.cpp +++ b/clang/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: |