]> granicus.if.org Git - clang/commit
Bug 7377: Fixed several bad printf format string bugs.
authorTom Care <tcare@apple.com>
Thu, 17 Jun 2010 19:00:27 +0000 (19:00 +0000)
committerTom Care <tcare@apple.com>
Thu, 17 Jun 2010 19:00:27 +0000 (19:00 +0000)
commite4ee9663168dfb2b4122c768091e30217328c9fa
tree337a0a3fc27b9f74809fe6ccfc131eb04be417a1
parente2872d0bda1d209d4409de2ed13648e6811628b7
Bug 7377: Fixed several bad printf format string bugs.
- Added warning for undefined behavior when using field specifier
- Added warning for undefined behavior when using length modifier
- Fixed warnings for invalid flags
- Added warning for ignored flags
- Added fixits for the above warnings
- Fixed accuracy of detecting several undefined behavior conditions
- Receive normal warnings in addition to security warnings when using %n
- Fix bug where '+' flag would remain on unsigned conversion suggestions

Summary of changes:
- Added expanded tests
- Added/expanded warnings
- Added position info to OptionalAmounts for fixits
- Extracted optional flags to a wrapper class with position info for fixits
- Added several methods to validate a FormatSpecifier by component, each checking for undefined behavior
- Fixed conversion specifier checking to conform to C99 standard
- Added hooks to detect the invalid states in CheckPrintfHandler::HandleFormatSpecifier

Note: warnings involving the ' ' (space) flag are temporarily disabled until whitespace highlighting no longer triggers assertions. I will make a post about this on cfe-dev shortly.

M    test/Sema/format-strings.c
M    include/clang/Basic/DiagnosticSemaKinds.td
M    include/clang/Analysis/Analyses/PrintfFormatString.h
M    lib/Analysis/PrintfFormatString.cpp
M    lib/Sema/SemaChecking.cpp

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106233 91177308-0d34-0410-b5e6-96231b3b80d8
include/clang/Analysis/Analyses/PrintfFormatString.h
include/clang/Basic/DiagnosticSemaKinds.td
lib/Analysis/PrintfFormatString.cpp
lib/Sema/SemaChecking.cpp
test/Sema/format-strings.c