diff options
author | Hans Wennborg <hans@hanshq.net> | 2012-01-12 17:11:12 +0000 |
---|---|---|
committer | Hans Wennborg <hans@hanshq.net> | 2012-01-12 17:11:12 +0000 |
commit | 37969b7e14d6a4dfd934ef6d3738cc90b832ec1d (patch) | |
tree | a00be7b6ba9cfa6a1466d270dbe0c590c90cd564 /lib/Analysis/ScanfFormatString.cpp | |
parent | 1d7049a6eddcc1a4bd33c6a595d4ad2ae8c1cece (diff) |
scanf: parse the 'm' length modifier, and check that the right arguments
are used with that and the 'a' length modifier.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148029 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/ScanfFormatString.cpp')
-rw-r--r-- | lib/Analysis/ScanfFormatString.cpp | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/lib/Analysis/ScanfFormatString.cpp b/lib/Analysis/ScanfFormatString.cpp index d248476e47..d5a44cb8e0 100644 --- a/lib/Analysis/ScanfFormatString.cpp +++ b/lib/Analysis/ScanfFormatString.cpp @@ -220,6 +220,7 @@ ScanfArgTypeResult ScanfSpecifier::getArgType(ASTContext &Ctx) const { return ScanfArgTypeResult(Ctx.getPointerDiffType(), "ptrdiff_t *"); case LengthModifier::AsLongDouble: return ScanfArgTypeResult::Invalid(); case LengthModifier::AsAllocate: return ScanfArgTypeResult::Invalid(); + case LengthModifier::AsMAllocate: return ScanfArgTypeResult::Invalid(); } // Unsigned int. @@ -243,6 +244,7 @@ ScanfArgTypeResult ScanfSpecifier::getArgType(ASTContext &Ctx) const { return ScanfArgTypeResult(); case LengthModifier::AsLongDouble: return ScanfArgTypeResult::Invalid(); case LengthModifier::AsAllocate: return ScanfArgTypeResult::Invalid(); + case LengthModifier::AsMAllocate: return ScanfArgTypeResult::Invalid(); } // Float. @@ -271,15 +273,24 @@ ScanfArgTypeResult ScanfSpecifier::getArgType(ASTContext &Ctx) const { case LengthModifier::None: return ScanfArgTypeResult::CStrTy; case LengthModifier::AsLong: return ScanfArgTypeResult(ScanfArgTypeResult::WCStrTy, "wchar_t *"); + case LengthModifier::AsAllocate: + case LengthModifier::AsMAllocate: + return ScanfArgTypeResult(ArgTypeResult::CStrTy); default: return ScanfArgTypeResult::Invalid(); } case ConversionSpecifier::CArg: case ConversionSpecifier::SArg: // FIXME: Mac OS X specific? - if (LM.getKind() == LengthModifier::None) - return ScanfArgTypeResult(ScanfArgTypeResult::WCStrTy, "wchar_t *"); - return ScanfArgTypeResult::Invalid(); + switch (LM.getKind()) { + case LengthModifier::None: + return ScanfArgTypeResult(ScanfArgTypeResult::WCStrTy, "wchar_t *"); + case LengthModifier::AsAllocate: + case LengthModifier::AsMAllocate: + return ScanfArgTypeResult(ArgTypeResult::WCStrTy, "wchar_t **"); + default: + return ScanfArgTypeResult::Invalid(); + } // Pointer. case ConversionSpecifier::pArg: |