From a792aff1c7de253b89c473fdb7eef4a5bba83aec Mon Sep 17 00:00:00 2001 From: Hans Wennborg Date: Wed, 7 Dec 2011 10:33:11 +0000 Subject: 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 --- lib/Analysis/FormatString.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'lib/Analysis/FormatString.cpp') 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; } - - -- cgit v1.2.3