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 | ebcd1c7ca2e21192dee17985221c7c0efb017506 (patch) | |
tree | d668bcf284ccf52aea6f3652021602f0dd1e16fd /clang/lib/Analysis/PrintfFormatString.cpp | |
parent | dfe14f7848d2389c9c02d74b2f8e732832e00ffa (diff) | |
download | bcm5719-llvm-ebcd1c7ca2e21192dee17985221c7c0efb017506.tar.gz bcm5719-llvm-ebcd1c7ca2e21192dee17985221c7c0efb017506.zip |
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.
llvm-svn: 160966
Diffstat (limited to 'clang/lib/Analysis/PrintfFormatString.cpp')
-rw-r--r-- | clang/lib/Analysis/PrintfFormatString.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/clang/lib/Analysis/PrintfFormatString.cpp b/clang/lib/Analysis/PrintfFormatString.cpp index 2a9644a3530..ed87c921013 100644 --- a/clang/lib/Analysis/PrintfFormatString.cpp +++ b/clang/lib/Analysis/PrintfFormatString.cpp @@ -330,6 +330,8 @@ ArgTypeResult PrintfSpecifier::getArgType(ASTContext &Ctx, return ArgTypeResult(Ctx.WCharTy, "wchar_t"); case ConversionSpecifier::pArg: return ArgTypeResult::CPointerTy; + case ConversionSpecifier::nArg: + return Ctx.getPointerType(Ctx.IntTy); case ConversionSpecifier::ObjCObjArg: return ArgTypeResult::ObjCPointerTy; default: @@ -342,6 +344,10 @@ ArgTypeResult PrintfSpecifier::getArgType(ASTContext &Ctx, bool PrintfSpecifier::fixType(QualType QT, const LangOptions &LangOpt, ASTContext &Ctx, bool IsObjCLiteral) { + // %n is different from other conversion specifiers; don't try to fix it. + if (CS.getKind() == ConversionSpecifier::nArg) + return false; + // Handle Objective-C objects first. Note that while the '%@' specifier will // not warn for structure pointer or void pointer arguments (because that's // how CoreFoundation objects are implemented), we only show a fixit for '%@' |