summaryrefslogtreecommitdiffstats
path: root/clang/lib/Analysis/FormatString.cpp
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2011-07-13 20:20:58 +0000
committerTed Kremenek <kremenek@apple.com>2011-07-13 20:20:58 +0000
commit60654d697ae8f613ba4ea6565df199c913b1cf08 (patch)
tree835066d8d98d61d766f09c8fc30c108dd1db3c90 /clang/lib/Analysis/FormatString.cpp
parent7bb72e2824f3b462dc1c435c619c4710bce69c2c (diff)
downloadbcm5719-llvm-60654d697ae8f613ba4ea6565df199c913b1cf08.tar.gz
bcm5719-llvm-60654d697ae8f613ba4ea6565df199c913b1cf08.zip
format string checking: long and int have the same widths on 32-bit, so we shouldn't warn about using
an "int" format specifier with a "long" type in 32-bit. llvm-svn: 135075
Diffstat (limited to 'clang/lib/Analysis/FormatString.cpp')
-rw-r--r--clang/lib/Analysis/FormatString.cpp19
1 files changed, 9 insertions, 10 deletions
diff --git a/clang/lib/Analysis/FormatString.cpp b/clang/lib/Analysis/FormatString.cpp
index 5f3cd4c6154..74f1e927944 100644
--- a/clang/lib/Analysis/FormatString.cpp
+++ b/clang/lib/Analysis/FormatString.cpp
@@ -206,6 +206,10 @@ clang::analyze_format_string::ParseLengthModifier(FormatSpecifier &FS,
// Methods on ArgTypeResult.
//===----------------------------------------------------------------------===//
+static bool hasSameSize(ASTContext &astContext, QualType typeA, QualType typeB) {
+ return astContext.getTypeSize(typeA) == astContext.getTypeSize(typeB);
+}
+
bool ArgTypeResult::matchesType(ASTContext &C, QualType argTy) const {
switch (K) {
case InvalidTy:
@@ -226,26 +230,21 @@ bool ArgTypeResult::matchesType(ASTContext &C, QualType argTy) const {
break;
case BuiltinType::Char_S:
case BuiltinType::SChar:
- return T == C.UnsignedCharTy;
case BuiltinType::Char_U:
case BuiltinType::UChar:
- return T == C.SignedCharTy;
+ return hasSameSize(C, T, C.UnsignedCharTy);
case BuiltinType::Short:
- return T == C.UnsignedShortTy;
case BuiltinType::UShort:
- return T == C.ShortTy;
+ return hasSameSize(C, T, C.ShortTy);
case BuiltinType::Int:
- return T == C.UnsignedIntTy;
case BuiltinType::UInt:
- return T == C.IntTy;
+ return hasSameSize(C, T, C.IntTy);
case BuiltinType::Long:
- return T == C.UnsignedLongTy;
case BuiltinType::ULong:
- return T == C.LongTy;
+ return hasSameSize(C, T, C.LongTy);
case BuiltinType::LongLong:
- return T == C.UnsignedLongLongTy;
case BuiltinType::ULongLong:
- return T == C.LongLongTy;
+ return hasSameSize(C, T, C.LongLongTy);
}
return false;
}
OpenPOWER on IntegriCloud