This is an archive of the discontinued LLVM Phabricator instance.

[clangd] Fix opening declarations located in non-preamble inclusion
ClosedPublic

Authored by malaperle on Nov 6 2017, 3:21 PM.

Details

Summary

When an inclusion is not processed as part of the preamble, its path is
not made into an absolute path as part of the precompiled header code
(adjustFilenameForRelocatableAST in ASTWriter.cpp). Because of this,
when we convert a Decl location to retrieve the file name with
FileEntry->getName(), it is possible for this path to be relative.
Instead, we should try to use tryGetRealPathName first which returns
an absolute path.

Fixes bug 35217.

Diff Detail

Repository
rL LLVM

Event Timeline

malaperle created this revision.Nov 6 2017, 3:21 PM
malaperle set the repository for this revision to rL LLVM.
malaperle added a project: Restricted Project.
malaperle added a subscriber: cfe-commits.
sammccall accepted this revision.Nov 7 2017, 1:19 AM

LGTM

clangd/ClangdUnit.cpp
970 ↗(On Diff #121803)

Can you add a comment about when this is needed?
like // Non-preamble included files may have relative paths.

This revision is now accepted and ready to land.Nov 7 2017, 1:19 AM
This revision was automatically updated to reflect the committed changes.