llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang-tools-extra Author: Haojian Wu (hokein) <details> <summary>Changes</summary> `nullptr` doesn't exist in objective-c. Right now, if an objective-c file compiled with `-std=c23` flag, it will trigger this check. This patch suppresses the check warning. --- Full diff: https://github.com/llvm/llvm-project/pull/141229.diff 3 Files Affected: - (modified) clang-tools-extra/clang-tidy/modernize/UseNullptrCheck.h (+1-1) - (modified) clang-tools-extra/docs/ReleaseNotes.rst (+4) - (added) clang-tools-extra/test/clang-tidy/checkers/modernize/use-nullptr-c23.m (+7) ``````````diff diff --git a/clang-tools-extra/clang-tidy/modernize/UseNullptrCheck.h b/clang-tools-extra/clang-tidy/modernize/UseNullptrCheck.h index f1591bae44657..ee380d03064f9 100644 --- a/clang-tools-extra/clang-tidy/modernize/UseNullptrCheck.h +++ b/clang-tools-extra/clang-tidy/modernize/UseNullptrCheck.h @@ -19,7 +19,7 @@ class UseNullptrCheck : public ClangTidyCheck { bool isLanguageVersionSupported(const LangOptions &LangOpts) const override { // FIXME this should be CPlusPlus11 but that causes test cases to // erroneously fail. - return LangOpts.CPlusPlus || LangOpts.C23; + return LangOpts.CPlusPlus || (LangOpts.C23 && !LangOpts.ObjC); } void storeOptions(ClangTidyOptions::OptionMap &Opts) override; void registerMatchers(ast_matchers::MatchFinder *Finder) override; diff --git a/clang-tools-extra/docs/ReleaseNotes.rst b/clang-tools-extra/docs/ReleaseNotes.rst index 579fca54924d5..900f65ccc56a7 100644 --- a/clang-tools-extra/docs/ReleaseNotes.rst +++ b/clang-tools-extra/docs/ReleaseNotes.rst @@ -219,6 +219,10 @@ Changes in existing checks tolerating fix-it breaking compilation when functions is used as pointers to avoid matching usage of functions within the current compilation unit. +- Improved :doc:`modernize-use-nullptr + <clang-tidy/checks/modernize/modernize-use-nullptr>` check to not run on + objective-c code. + Removed checks ^^^^^^^^^^^^^^ diff --git a/clang-tools-extra/test/clang-tidy/checkers/modernize/use-nullptr-c23.m b/clang-tools-extra/test/clang-tidy/checkers/modernize/use-nullptr-c23.m new file mode 100644 index 0000000000000..1d6446c486317 --- /dev/null +++ b/clang-tools-extra/test/clang-tidy/checkers/modernize/use-nullptr-c23.m @@ -0,0 +1,7 @@ +// RUN: %check_clang_tidy %s modernize-use-nullptr %t -- -- -std=c23 + +#define NULL 0 + +void test_assignment() { + int *p1 = NULL; +} `````````` </details> https://github.com/llvm/llvm-project/pull/141229 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits