Skip to content

Commit 7d6ba7c

Browse files
committed
[clang-tidy] Don't run use-nullptr check on objective-c code.
If we compile an objective-c file with the `-std=c23` flag, this check will warn the NULL usage, this patch fix it. nullptr doesn't exist in objective-c.
1 parent d39ca81 commit 7d6ba7c

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

clang-tools-extra/clang-tidy/modernize/UseNullptrCheck.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class UseNullptrCheck : public ClangTidyCheck {
1919
bool isLanguageVersionSupported(const LangOptions &LangOpts) const override {
2020
// FIXME this should be CPlusPlus11 but that causes test cases to
2121
// erroneously fail.
22-
return LangOpts.CPlusPlus || LangOpts.C23;
22+
return LangOpts.CPlusPlus || (LangOpts.C23 && !LangOpts.ObjC);
2323
}
2424
void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
2525
void registerMatchers(ast_matchers::MatchFinder *Finder) override;

clang-tools-extra/docs/ReleaseNotes.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,10 @@ Changes in existing checks
219219
tolerating fix-it breaking compilation when functions is used as pointers
220220
to avoid matching usage of functions within the current compilation unit.
221221

222+
- Improved :doc:`modernize-use-nullptr
223+
<clang-tidy/checks/modernize/use-nullptr>` check to not run on
224+
objective-c code.
225+
222226
Removed checks
223227
^^^^^^^^^^^^^^
224228

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// RUN: %check_clang_tidy %s modernize-use-nullptr %t -- -- -std=c23
2+
3+
#define NULL 0
4+
5+
void test_assignment() {
6+
int *p1 = NULL;
7+
}

0 commit comments

Comments
 (0)