This is an archive of the discontinued LLVM Phabricator instance.

Support Objective-C/C++ source files in check_clang_tidy.py
ClosedPublic

Authored by benhamilton on Oct 16 2017, 10:55 AM.

Details

Reviewers
hokein
alexfh
Summary

check_clang_tidy.py currently only handles C and C++ source files.

This extends the logic to also handle Objective-C (.m) and
Objective-C++ (.mm) files.

However, by default, clang compiles .m/.mm files using Objective-C 1.0
syntax. Objective-C 2.0 has been the default in Xcode for about 10
years, and Objective-C Automatic Reference Counting (ARC) for about 6
years, so this enables both by default.

(Clients which actually want to test clang-tidy checks for Objective-C
1.0 or non-ARC files can pass custom flags to check_clang_tidy.py
after --, which will disable the Objective-C 2.0 and ARC flags).

I did not add logic to handle running clang-tidy on Objective-C header
files alone; they also use the .h file extension, so we'd need to
look inside their contents.

I included a new test to confirm the new behavior.

Depends On D38963

Event Timeline

benhamilton created this revision.Oct 16 2017, 10:55 AM
hokein added inline comments.
test/clang-tidy/objc-arc-and-properties.m
2

I'd suggest adding one more test for default clang behavior (Objective-C 1.0 and non-ARC).

  • Add new test to confirm disabling ARC and ObjC 2.0 works
benhamilton marked an inline comment as done.Oct 17 2017, 8:37 AM
benhamilton added inline comments.
test/clang-tidy/objc-arc-and-properties.m
2

I added a new test, but I realized we shouldn't rely on default clang parameters, since they can change based on the Objective-C runtime for the platform (which is different between Linux and Mac).

benhamilton retitled this revision from check_clang_tidy.py currently only handles C and C++ source files. to Support Objective-C/C++ source files in check_clang_tidy.py currently only handles C and C++ source files..Oct 17 2017, 8:42 AM
benhamilton edited the summary of this revision. (Show Details)
benhamilton retitled this revision from Support Objective-C/C++ source files in check_clang_tidy.py currently only handles C and C++ source files. to Support Objective-C/C++ source files in check_clang_tidy.py.
hokein accepted this revision.Oct 17 2017, 9:21 AM

LGTM.

test/clang-tidy/objc-arc-and-properties.m
2

Sounds good. Thanks for the explanation.

This revision is now accepted and ready to land.Oct 17 2017, 9:21 AM

@benhamilton, can you rebase this patch? It failed to apply this patch after I committed D38963.

benhamilton marked an inline comment as done.

Rebase

hokein closed this revision.Oct 18 2017, 8:58 AM

Committed in rL316090.