Index: clang/include/clang/AST/FormatString.h =================================================================== --- clang/include/clang/AST/FormatString.h +++ clang/include/clang/AST/FormatString.h @@ -65,22 +65,24 @@ public: enum Kind { None, - AsChar, // 'hh' - AsShort, // 'h' - AsShortLong, // 'hl' (OpenCL float/int vector element) - AsLong, // 'l' - AsLongLong, // 'll' - AsQuad, // 'q' (BSD, deprecated, for 64-bit integer types) - AsIntMax, // 'j' - AsSizeT, // 'z' - AsPtrDiff, // 't' - AsInt32, // 'I32' (MSVCRT, like __int32) - AsInt3264, // 'I' (MSVCRT, like __int3264 from MIDL) - AsInt64, // 'I64' (MSVCRT, like __int64) - AsLongDouble, // 'L' - AsAllocate, // for '%as', GNU extension to C90 scanf - AsMAllocate, // for '%ms', GNU extension to scanf - AsWide, // 'w' (MSVCRT, like l but only for c, C, s, S, or Z + AsChar, // 'hh' + AsShort, // 'h' + AsShortLong, // 'hl' (OpenCL float/int vector element) + AsLong, // 'l' + AsLongLong, // 'll' + AsQuad, // 'q' (BSD, deprecated, for 64-bit integer types) + AsIntMax, // 'j' + AsSizeT, // 'z' + AsPtrDiff, // 't' + AsInt32, // 'I32' (MSVCRT, like __int32) + AsInt3264, // 'I' (MSVCRT, like __int3264 from MIDL) + AsInt64, // 'I64' (MSVCRT, like __int64) + AsLongDouble, // 'L' + AsAllocate, // for '%as', GNU extension to C90 scanf + AsMAllocate, // for '%ms', GNU extension to scanf + AsUTF16, // for '%l16(c|s)', Clang extension + AsUTF32, // for '%l32(c|s)', Clang extension + AsWide, // 'w' (MSVCRT, like l but only for c, C, s, S, or Z AsWideChar = AsLong // for '%ls', only makes sense for printf }; Index: clang/lib/AST/FormatString.cpp =================================================================== --- clang/lib/AST/FormatString.cpp +++ clang/lib/AST/FormatString.cpp @@ -520,6 +520,12 @@ case WCStrTy: Res = C.getPointerType(C.getWideCharType()); break; + case Char16Ty: + Res = C.getPointerType(C.getChar16Type()); + break; + case Char32Ty: + Res = C.getPointerType(C.getChar32Type()); + break; case ObjCPointerTy: Res = C.ObjCBuiltinIdTy; break; @@ -607,6 +613,10 @@ return "m"; case AsWide: return "w"; + case AsUTF16: + return "l16"; + case AsUTF32: + return "l32"; case None: return ""; } @@ -860,6 +870,17 @@ default: return false; } + case LengthModifier::AsUTF16: + case LengthModifier::AsUTF32: + switch (CS.getKind()) { + case ConversionSpecifier::cArg: + case ConversionSpecifier::CArg: + case ConversionSpecifier::sArg: + case ConversionSpecifier::SArg: + return true; + default: + return false; + } case LengthModifier::AsWide: switch (CS.getKind()) { case ConversionSpecifier::cArg: @@ -886,6 +907,8 @@ case LengthModifier::AsSizeT: case LengthModifier::AsPtrDiff: case LengthModifier::AsLongDouble: + case LengthModifier::AsUTF16: + case LengthModifier::AsUTF32: return true; case LengthModifier::AsAllocate: case LengthModifier::AsMAllocate: @@ -997,6 +1020,12 @@ } else if (Identifier->getName() == "ptrdiff_t") { LM.setKind(LengthModifier::AsPtrDiff); return true; + } else if (Identifier->getName() == "char16_t") { + LM.setKind(LengthModifier::AsUTF16); + return true; + } else if (Identifier->getName() == "char32_t") { + LM.setKind(LengthModifier::AsUTF32); + return true; } QualType T = Typedef->getUnderlyingType();