diff options
| author | Ted Kremenek <kremenek@apple.com> | 2013-10-15 05:25:17 +0000 |
|---|---|---|
| committer | Ted Kremenek <kremenek@apple.com> | 2013-10-15 05:25:17 +0000 |
| commit | da2f405b0903ae21577b877ec49892e28eff0d0d (patch) | |
| tree | fcb14f40d46c272a22cb442e5c3fae9496fbee7f /clang/lib/Sema | |
| parent | ef9e993eaa9dd8cb5afe6e1efd2ed4cf5973a4c7 (diff) | |
| download | bcm5719-llvm-da2f405b0903ae21577b877ec49892e28eff0d0d.tar.gz bcm5719-llvm-da2f405b0903ae21577b877ec49892e28eff0d0d.zip | |
Special case '%C' handling in ObjC format strings to handle integer literals that can represent unicode characters
Fixes <rdar://problem/13991617>.
llvm-svn: 192673
Diffstat (limited to 'clang/lib/Sema')
| -rw-r--r-- | clang/lib/Sema/SemaChecking.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp index 94a58cc625a..b0950ab7e65 100644 --- a/clang/lib/Sema/SemaChecking.cpp +++ b/clang/lib/Sema/SemaChecking.cpp @@ -3115,7 +3115,15 @@ CheckPrintfHandler::checkFormatExpr(const analyze_printf::PrintfSpecifier &FS, // 'unichar' is defined as a typedef of unsigned short, but we should // prefer using the typedef if it is visible. IntendedTy = S.Context.UnsignedShortTy; - + + // While we are here, check if the value is an IntegerLiteral that happens + // to be within the valid range. + if (const IntegerLiteral *IL = dyn_cast<IntegerLiteral>(E)) { + const llvm::APInt &V = IL->getValue(); + if (V.getActiveBits() <= S.Context.getTypeSize(IntendedTy)) + return true; + } + LookupResult Result(S, &S.Context.Idents.get("unichar"), E->getLocStart(), Sema::LookupOrdinaryName); if (S.LookupName(Result, S.getCurScope())) { |

