Printf format strings: Added some more tests and fixed some minor bugs.

- Precision toStrings shouldn't print a dot when they have no value.
- Length of char length modifier is now returned correctly.
- Added several fixit tests.

Note: fixit tests are currently broken due to a bug in HighlightRange. Marking as XFAIL for now.

M    test/Sema/format-strings-fixit.c
M    include/clang/Analysis/Analyses/PrintfFormatString.h
M    lib/Analysis/PrintfFormatString.cpp

llvm-svn: 106275
This commit is contained in:
Tom Care
2010-06-18 03:02:16 +00:00
parent e96a9132b8
commit 6e4ea2db7f
3 changed files with 23 additions and 5 deletions

View File

@@ -611,20 +611,21 @@ const char *LengthModifier::toString() const {
//===----------------------------------------------------------------------===//
void OptionalAmount::toString(llvm::raw_ostream &os) const {
if (UsesDotPrefix)
os << ".";
switch (hs) {
case Invalid:
case NotSpecified:
return;
case Arg:
if (UsesDotPrefix)
os << ".";
if (usesPositionalArg())
os << "*" << getPositionalArgIndex() << "$";
else
os << "*";
break;
case Constant:
if (UsesDotPrefix)
os << ".";
os << amt;
break;
}