diff options
author | Hans Wennborg <hans@hanshq.net> | 2011-12-07 10:33:11 +0000 |
---|---|---|
committer | Hans Wennborg <hans@hanshq.net> | 2011-12-07 10:33:11 +0000 |
commit | a792aff1c7de253b89c473fdb7eef4a5bba83aec (patch) | |
tree | 861496c88b07bf5ca7eca8921971bf02e6b7fdb8 /lib/Analysis/FormatString.cpp | |
parent | 29f2787b6da552018a7716f18f5bd8f67bd6edb5 (diff) |
Make printf warnings refer to intmax_t et al. by name
in addition to underlying type.
For example, the warning for printf("%zu", 42.0);
changes from "conversion specifies type 'unsigned long'" to "conversion
specifies type 'size_t' (aka 'unsigned long')"
(This is a second attempt after r145697, which got reverted.)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@146032 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/FormatString.cpp')
-rw-r--r-- | lib/Analysis/FormatString.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/Analysis/FormatString.cpp b/lib/Analysis/FormatString.cpp index 6498ded4e3..0853164df7 100644 --- a/lib/Analysis/FormatString.cpp +++ b/lib/Analysis/FormatString.cpp @@ -228,6 +228,7 @@ bool ArgTypeResult::matchesType(ASTContext &C, QualType argTy) const { return false; } + case TypedefTy: case SpecificTy: { argTy = C.getCanonicalType(argTy).getUnqualifiedType(); if (T == argTy) @@ -331,6 +332,7 @@ QualType ArgTypeResult::getRepresentativeType(ASTContext &C) const { case AnyCharTy: return C.CharTy; case SpecificTy: + case TypedefTy: return T; case CStrTy: return C.getPointerType(C.CharTy); @@ -351,6 +353,13 @@ QualType ArgTypeResult::getRepresentativeType(ASTContext &C) const { return QualType(); } +std::string ArgTypeResult::getRepresentativeTypeName(ASTContext &C) const { + if (K != TypedefTy) + return std::string("'") + getRepresentativeType(C).getAsString() + "'"; + return std::string("'") + Name + "' (aka '" + T.getAsString() + "')"; +} + + //===----------------------------------------------------------------------===// // Methods on OptionalAmount. //===----------------------------------------------------------------------===// @@ -485,5 +494,3 @@ bool FormatSpecifier::hasValidLengthModifier() const { } return false; } - - |