diff options
author | Hans Wennborg <hans@hanshq.net> | 2012-07-31 16:37:47 +0000 |
---|---|---|
committer | Hans Wennborg <hans@hanshq.net> | 2012-07-31 16:37:47 +0000 |
commit | 5deddafd3ef51e94b4ac4d80e38271d3768b1af6 (patch) | |
tree | 7f4e06763ba091274905164494f32c5484b32363 /lib/Analysis/FormatString.cpp | |
parent | 6b4be2ef4ce49717ff972434975ce3c34c9a1c4c (diff) |
-Wformat: better handling of qualifiers on pointer arguments
Warn about using pointers to const-qualified types as arguments to
scanf. Ignore the volatile qualifier when checking if types match.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@161052 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/FormatString.cpp')
-rw-r--r-- | lib/Analysis/FormatString.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/Analysis/FormatString.cpp b/lib/Analysis/FormatString.cpp index a68b9bb324..f03a84fb52 100644 --- a/lib/Analysis/FormatString.cpp +++ b/lib/Analysis/FormatString.cpp @@ -262,6 +262,13 @@ bool ArgTypeResult::matchesType(ASTContext &C, QualType argTy) const { argTy = ETy->getDecl()->getIntegerType(); argTy = C.getCanonicalType(argTy).getUnqualifiedType(); + if (const PointerType *PTy = argTy->getAs<PointerType>()) { + // Strip volatile qualifier from pointee type. + QualType Pointee = PTy->getPointeeType(); + Pointee.removeLocalVolatile(); + argTy = C.getPointerType(Pointee); + } + if (T == argTy) return true; // Check for "compatible types". |