justinstitt created this revision. Herald added a subscriber: pengfei. Herald added a project: All. justinstitt requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits.
-Wnull-conversion is not supported in C and therefore DiagnoseNullConversions should only be called for C++. When testing this change on Linux Kernel builds (x86_64 defconfig) we see an approximate 2.1% reduction in build times! This is mainly caused by two methods no longer needing to be invoked as often: 1. ExprConstant::CheckICE and 2) IntExprEvaluator::VisitBinaryOperator. The former has had its total cpu cycles reduced by ~90% and the latter by about ~50% for Kernel builds. The C++ Standard (https://isocpp.org/files/papers/N4860.pdf) states that "NULL is an implementation-defined null pointer constant" and "possible definitions include 0, 0L, but not (void*)0". Which may explain the difference in C and C++ as seen here: https://godbolt.org/z/c5j8fY39 Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D131532 Files: clang/lib/Sema/SemaChecking.cpp Index: clang/lib/Sema/SemaChecking.cpp =================================================================== --- clang/lib/Sema/SemaChecking.cpp +++ clang/lib/Sema/SemaChecking.cpp @@ -13865,7 +13865,8 @@ } } - DiagnoseNullConversion(S, E, T, CC); + if (S.getLangOpts().CPlusPlus) + DiagnoseNullConversion(S, E, T, CC); S.DiscardMisalignedMemberAddress(Target, E);
Index: clang/lib/Sema/SemaChecking.cpp =================================================================== --- clang/lib/Sema/SemaChecking.cpp +++ clang/lib/Sema/SemaChecking.cpp @@ -13865,7 +13865,8 @@ } } - DiagnoseNullConversion(S, E, T, CC); + if (S.getLangOpts().CPlusPlus) + DiagnoseNullConversion(S, E, T, CC); S.DiscardMisalignedMemberAddress(Target, E);
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits