================ @@ -320,6 +321,69 @@ bool clang::analyze_format_string::ParseUTF8InvalidSpecifier( // Methods on ArgType. //===----------------------------------------------------------------------===// +static bool namedTypeToLengthModifierKind(QualType QT, + LengthModifier::Kind &K) { + for (/**/; const auto *TT = QT->getAs<TypedefType>(); + QT = TT->getDecl()->getUnderlyingType()) { + StringRef Name = TT->getDecl()->getIdentifier()->getName(); + if (Name == "size_t" || Name == "__size_t") { + K = LengthModifier::AsSizeT; + return true; + } else if (Name == "__signed_size_t" || + Name == "ssize_t" /*Not C99, but common in Unix.*/) { + K = LengthModifier::AsSizeT; + return true; + } else if (Name == "ptrdiff_t" || Name == "__ptrdiff_t") { + K = LengthModifier::AsPtrDiff; + return true; + } else if (Name == "intmax_t") { + K = LengthModifier::AsIntMax; + return true; + } else if (Name == "uintmax_t") { + K = LengthModifier::AsIntMax; + return true; + } + } + return false; ---------------- frederick-vs-ja wrote:
Ditto `<stdint.h>`/`<cstdint>`. Perhaps only `ssize_t` should be specifically handled. Note that POSIX surprisingly allows `ssize_t` not to be the signed version of `size_t`, per https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/sys_types.h.html. https://github.com/llvm/llvm-project/pull/143653 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits