diff options
author | Hans Wennborg <hans@hanshq.net> | 2012-07-30 17:11:32 +0000 |
---|---|---|
committer | Hans Wennborg <hans@hanshq.net> | 2012-07-30 17:11:32 +0000 |
commit | cec9ce49dcf4b4b768043f96c8ef8c1d4cdbb6b9 (patch) | |
tree | 9d721b14c3dc15581ba2acee713216b5f103561c /lib/Analysis/ScanfFormatString.cpp | |
parent | 3ccc173d6f1f9e43566c258289b7581d8aa523ad (diff) |
Make -Wformat check the argument type for %n.
This makes Clang check that the corresponding argument for "%n" in a
format string is a pointer to int.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160966 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/ScanfFormatString.cpp')
-rw-r--r-- | lib/Analysis/ScanfFormatString.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/Analysis/ScanfFormatString.cpp b/lib/Analysis/ScanfFormatString.cpp index 5c7e6ef8f2..3c848f1f09 100644 --- a/lib/Analysis/ScanfFormatString.cpp +++ b/lib/Analysis/ScanfFormatString.cpp @@ -303,6 +303,9 @@ ScanfArgTypeResult ScanfSpecifier::getArgType(ASTContext &Ctx) const { case ConversionSpecifier::pArg: return ScanfArgTypeResult(ArgTypeResult(ArgTypeResult::CPointerTy)); + case ConversionSpecifier::nArg: + return ArgTypeResult(Ctx.IntTy); + default: break; } @@ -315,6 +318,10 @@ bool ScanfSpecifier::fixType(QualType QT, const LangOptions &LangOpt, if (!QT->isPointerType()) return false; + // %n is different from other conversion specifiers; don't try to fix it. + if (CS.getKind() == ConversionSpecifier::nArg) + return false; + QualType PT = QT->getPointeeType(); // If it's an enum, get its underlying type. |