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 | 16250c7c1847184f543d8a837512765cd6eb4bda (patch) | |
tree | 4a296ac236ec9a95e1252490ad4cfd47f91d7ba9 /clang/lib/Analysis/FormatString.cpp | |
parent | e8a21b73ac5b4d84981fc813db9d8254a45ae477 (diff) | |
download | bcm5719-llvm-16250c7c1847184f543d8a837512765cd6eb4bda.tar.gz bcm5719-llvm-16250c7c1847184f543d8a837512765cd6eb4bda.zip |
-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.
llvm-svn: 161052
Diffstat (limited to 'clang/lib/Analysis/FormatString.cpp')
-rw-r--r-- | clang/lib/Analysis/FormatString.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/clang/lib/Analysis/FormatString.cpp b/clang/lib/Analysis/FormatString.cpp index a68b9bb3240..f03a84fb523 100644 --- a/clang/lib/Analysis/FormatString.cpp +++ b/clang/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". |