This is an archive of the discontinued LLVM Phabricator instance.

[clang-tidy] Fix ClangTidyTest to initialize context before checks.
ClosedPublic

Authored by ymandel on Jun 25 2019, 12:48 PM.

Details

Summary

Currently, clang::tidy::test::runCheckOnCode() constructs the check
instances *before* initializing the ClangTidyContext. This ordering causes
problems when the check's constructor accesses the context, for example, through
getLangOpts().

This revision moves the construction to after the context initialization, which
follows the pattern used in the clang tidy tool itself.

Diff Detail

Repository
rL LLVM

Event Timeline

ymandel created this revision.Jun 25 2019, 12:48 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 25 2019, 12:48 PM
Herald added a subscriber: xazax.hun. · View Herald Transcript
hokein accepted this revision.Jun 26 2019, 2:52 AM

looks good.

This revision is now accepted and ready to land.Jun 26 2019, 2:52 AM
gribozavr accepted this revision.Jun 26 2019, 2:53 AM

Good catch!

clang-tools-extra/unittests/clang-tidy/ClangTidyTest.h
48 ↗(On Diff #206509)

"CheckTypes"? 'cause "Checks" below is also technically a "check list".

65 ↗(On Diff #206509)

Please explain why ("so that check constructors can access the context")

ymandel updated this revision to Diff 206667.Jun 26 2019, 7:39 AM
ymandel marked 3 inline comments as done.

responded to comments.

ymandel added inline comments.Jun 26 2019, 7:43 AM
clang-tools-extra/unittests/clang-tidy/ClangTidyTest.h
48 ↗(On Diff #206509)

Agreed. I was just blindly following what was already there. Changed here and below.

This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptJun 26 2019, 8:04 AM