xgupta created this revision. xgupta added reviewers: aaron.ballman, xbolva00. Herald added a project: All. xgupta requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits.
The issue with size_t comes when we are trying to addd -Wtype-limits to -Wextra for GCC compatibility in review https://reviews.llvm.org/D142826. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D155457 Files: clang/lib/Sema/SemaChecking.cpp Index: clang/lib/Sema/SemaChecking.cpp =================================================================== --- clang/lib/Sema/SemaChecking.cpp +++ clang/lib/Sema/SemaChecking.cpp @@ -13363,6 +13363,13 @@ if (InRange && IsEnumConstOrFromMacro(S, Constant)) return false; + // Don't warn if the comparison involves the 'size_t' type. + QualType SizeT = S.Context.getSizeType(); + if (S.Context.hasSameType(Constant->getType().getCanonicalType(), SizeT) && + S.Context.hasSameType(Other->getType().getCanonicalType(), SizeT)) { + return false; + } + // A comparison of an unsigned bit-field against 0 is really a type problem, // even though at the type level the bit-field might promote to 'signed int'. if (Other->refersToBitField() && InRange && Value == 0 &&
Index: clang/lib/Sema/SemaChecking.cpp =================================================================== --- clang/lib/Sema/SemaChecking.cpp +++ clang/lib/Sema/SemaChecking.cpp @@ -13363,6 +13363,13 @@ if (InRange && IsEnumConstOrFromMacro(S, Constant)) return false; + // Don't warn if the comparison involves the 'size_t' type. + QualType SizeT = S.Context.getSizeType(); + if (S.Context.hasSameType(Constant->getType().getCanonicalType(), SizeT) && + S.Context.hasSameType(Other->getType().getCanonicalType(), SizeT)) { + return false; + } + // A comparison of an unsigned bit-field against 0 is really a type problem, // even though at the type level the bit-field might promote to 'signed int'. if (Other->refersToBitField() && InRange && Value == 0 &&
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits