aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaChecking.cpp
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2013-03-25 22:28:37 +0000
committerTed Kremenek <kremenek@apple.com>2013-03-25 22:28:37 +0000
commit6edb029026d290f12393ed8389a3e1de596c77ec (patch)
tree1032a8f8fe36ed413f7c94e150613e703b325be5 /lib/Sema/SemaChecking.cpp
parentabde2c7f2c0699c7db395166f4e89b80bb87bf67 (diff)
For printf checking, handle nested typedefs for darwin-specific checking.
Fixes <rdar://problem/13491605>. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@177931 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaChecking.cpp')
-rw-r--r--lib/Sema/SemaChecking.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/Sema/SemaChecking.cpp b/lib/Sema/SemaChecking.cpp
index cfce85eef0..4e11b3aa79 100644
--- a/lib/Sema/SemaChecking.cpp
+++ b/lib/Sema/SemaChecking.cpp
@@ -2803,7 +2803,9 @@ CheckPrintfHandler::checkFormatExpr(const analyze_printf::PrintfSpecifier &FS,
// casts to primitive types that are known to be large enough.
bool ShouldNotPrintDirectly = false;
if (S.Context.getTargetInfo().getTriple().isOSDarwin()) {
- if (const TypedefType *UserTy = IntendedTy->getAs<TypedefType>()) {
+ // Use a 'while' to peel off layers of typedefs.
+ QualType TyTy = IntendedTy;
+ while (const TypedefType *UserTy = TyTy->getAs<TypedefType>()) {
StringRef Name = UserTy->getDecl()->getName();
QualType CastTy = llvm::StringSwitch<QualType>(Name)
.Case("NSInteger", S.Context.LongTy)
@@ -2815,7 +2817,9 @@ CheckPrintfHandler::checkFormatExpr(const analyze_printf::PrintfSpecifier &FS,
if (!CastTy.isNull()) {
ShouldNotPrintDirectly = true;
IntendedTy = CastTy;
+ break;
}
+ TyTy = UserTy->desugar();
}
}