This is an archive of the discontinued LLVM Phabricator instance.

[clangd] No longer getting template instantiations from header files in Main AST.
ClosedPublic

Authored by jvikstrom on Jun 26 2019, 5:47 AM.

Details

Summary

[clangd] No longer getting template instantiations from header files in Main AST. Added another check to DeclTrackingASTConsumer to check that a Decl is actually in the main file.

Diff Detail

Repository
rL LLVM

Event Timeline

jvikstrom created this revision.Jun 26 2019, 5:47 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 26 2019, 5:47 AM
jvikstrom retitled this revision from [clangd] No longer getting template instantiations from header files in Main AST. Added another check to DeclTrackingASTConsumer to check that a Decl is actually in the main file. to [clangd] No longer getting template instantiations from header files in Main AST..Jun 26 2019, 6:10 AM
jvikstrom edited the summary of this revision. (Show Details)
hokein added inline comments.Jun 26 2019, 6:16 AM
clang-tools-extra/clangd/ClangdUnit.cpp
74 ↗(On Diff #206643)

you could get SourceManager from D->getASTContext().getSourceManager().

75 ↗(On Diff #206643)

nit: This comment just repeats the code, I think the comment describe why we need to do this check (because of the template instantiation?)

jvikstrom updated this revision to Diff 206664.Jun 26 2019, 7:26 AM

Removed comment, getting SM from Decl and removed old check for checking the file.

jvikstrom marked 3 inline comments as done.Jun 26 2019, 7:29 AM
jvikstrom added inline comments.
clang-tools-extra/clangd/ClangdUnit.cpp
75 ↗(On Diff #206643)

Removed the D->isFromASTFile because this if actually covers that as well. Don't know what to do about comments though as it is not only specific to that case.

jvikstrom marked an inline comment as done.Jun 26 2019, 7:32 AM
ilya-biryukov added inline comments.Jun 26 2019, 7:48 AM
clang-tools-extra/clangd/ClangdUnit.cpp
47 ↗(On Diff #206664)

NIT: This include is redundant, maybe remove?
Probably added by accident.

71 ↗(On Diff #206664)

Please use isWrittenInMainFile instead.
isInMainFile takes #line markers into account, we don't want that in clangd.

jvikstrom updated this revision to Diff 206684.Jun 26 2019, 8:37 AM
jvikstrom marked 2 inline comments as done.

Using isInMainFile instead

jvikstrom updated this revision to Diff 206685.Jun 26 2019, 8:38 AM

Fixed formatting

hokein accepted this revision.Jul 1 2019, 1:00 AM

Looks good, please update the patch description (in git, and phabricator), mentioning why the previous solution won't work.

clang-tools-extra/clangd/ClangdUnit.cpp
71 ↗(On Diff #206685)

nit: remove the {}

This revision is now accepted and ready to land.Jul 1 2019, 1:00 AM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptJul 1 2019, 4:49 AM