aboutsummaryrefslogtreecommitdiff
path: root/lib/Analysis/FormatString.cpp
diff options
context:
space:
mode:
authorJordan Rose <jordan_rose@apple.com>2012-06-04 22:48:57 +0000
committerJordan Rose <jordan_rose@apple.com>2012-06-04 22:48:57 +0000
commitee0259d308e72141982a85b40863e760a8447edf (patch)
tree8662e003cd916965cd4ec50c0a68b27bff987192 /lib/Analysis/FormatString.cpp
parentbd1d18ecc420838b7ba620c0a2c5d2a86cac371d (diff)
Teach printf/scanf about enums with fixed underlying types.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@157961 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/FormatString.cpp')
-rw-r--r--lib/Analysis/FormatString.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/Analysis/FormatString.cpp b/lib/Analysis/FormatString.cpp
index f776c89cc5..caceeac113 100644
--- a/lib/Analysis/FormatString.cpp
+++ b/lib/Analysis/FormatString.cpp
@@ -241,6 +241,9 @@ bool ArgTypeResult::matchesType(ASTContext &C, QualType argTy) const {
return true;
case AnyCharTy: {
+ if (const EnumType *ETy = argTy->getAs<EnumType>())
+ argTy = ETy->getDecl()->getIntegerType();
+
if (const BuiltinType *BT = argTy->getAs<BuiltinType>())
switch (BT->getKind()) {
default:
@@ -255,7 +258,10 @@ bool ArgTypeResult::matchesType(ASTContext &C, QualType argTy) const {
}
case SpecificTy: {
+ if (const EnumType *ETy = argTy->getAs<EnumType>())
+ argTy = ETy->getDecl()->getIntegerType();
argTy = C.getCanonicalType(argTy).getUnqualifiedType();
+
if (T == argTy)
return true;
// Check for "compatible types".