This is an archive of the discontinued LLVM Phabricator instance.

[clang][lex] NFCI: Use FileEntryRef in PPCallbacks::InclusionDirective()
ClosedPublic

Authored by jansvoboda11 on Apr 12 2022, 12:22 AM.

Details

Summary

This patch changes type of the File parameter in PPCallbacks::InclusionDirective() from const FileEntry * to Optional<FileEntryRef>.

With the API change in place, this patch then removes some uses of the deprecated FileEntry::getName() (e.g. in DependencyGraph.cpp and ModuleDependencyCollector.cpp).

Diff Detail

Event Timeline

jansvoboda11 created this revision.Apr 12 2022, 12:22 AM
jansvoboda11 requested review of this revision.Apr 12 2022, 12:22 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptApr 12 2022, 12:22 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
jansvoboda11 edited the summary of this revision. (Show Details)Apr 12 2022, 10:23 AM
jansvoboda11 edited the summary of this revision. (Show Details)
dexonsmith accepted this revision.Apr 12 2022, 11:51 AM

LGTM, with a couple of nitpicks. If you'd rather not improve the tests that's probably fine, since the patch doesn't make them any worse.

clang-tools-extra/clangd/unittests/HeadersTests.cpp
71–72

Test might be cleaner with EXPECT_THAT_ERROR; see comment in ParsedASTTests.cpp.

clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
564–566

It might be nice to see the errors here on failures. You could do that with:

Optional<FileEntryRef> MainFE;
ASSERT_THAT_ERROR(FM.getFileRef(testPath("foo.cpp")).moveInto(MainFE), Succeeded());

The {EXPECT,ASSERT}_THAT_ERROR live in llvm/Testing/Support/Error.h.

clang/lib/Serialization/ASTReader.cpp
6047–6048

I think you can remove the inner if here.

This revision is now accepted and ready to land.Apr 12 2022, 11:51 AM
bnbarham accepted this revision.Apr 12 2022, 11:54 AM

Thanks Jan :)!

Rebase, apply review suggestions

jansvoboda11 marked 3 inline comments as done.Apr 14 2022, 1:28 AM
jansvoboda11 added inline comments.
clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
564–566

That's pretty sweet, thanks for the suggestion!

jansvoboda11 retitled this revision from [clang] NFCI: Use FileEntryRef in PPCallbacks::InclusionDirective to [clang][lex] NFCI: Use FileEntryRef in PPCallbacks::InclusionDirective().Apr 14 2022, 1:28 AM
jansvoboda11 edited the summary of this revision. (Show Details)
This revision was landed with ongoing or failed builds.Apr 14 2022, 1:46 AM
This revision was automatically updated to reflect the committed changes.
jansvoboda11 marked an inline comment as done.