Page MenuHomePhabricator

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

Authored by ymandel on Tue, Jun 25, 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.Tue, Jun 25, 12:48 PM
Herald added a project: Restricted Project. · View Herald TranscriptTue, Jun 25, 12:48 PM
Herald added a subscriber: xazax.hun. · View Herald Transcript
hokein accepted this revision.Wed, Jun 26, 2:52 AM

looks good.

This revision is now accepted and ready to land.Wed, Jun 26, 2:52 AM
gribozavr accepted this revision.Wed, Jun 26, 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.Wed, Jun 26, 7:39 AM
ymandel marked 3 inline comments as done.

responded to comments.

ymandel added inline comments.Wed, Jun 26, 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 TranscriptWed, Jun 26, 8:04 AM