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
diff --git a/lib/Analysis/ScanfFormatString.cpp b/lib/Analysis/ScanfFormatString.cpp
index 5c7e6ef..3c848f1 100644
--- a/lib/Analysis/ScanfFormatString.cpp
+++ b/lib/Analysis/ScanfFormatString.cpp
@@ -303,6 +303,9 @@
case ConversionSpecifier::pArg:
return ScanfArgTypeResult(ArgTypeResult(ArgTypeResult::CPointerTy));
+ case ConversionSpecifier::nArg:
+ return ArgTypeResult(Ctx.IntTy);
+
default:
break;
}
@@ -315,6 +318,10 @@
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.