This is an archive of the discontinued LLVM Phabricator instance.

Fix incorrect use of current directory to find moved paths in ASTReader.
ClosedPublic

Authored by klimek on Jul 25 2017, 3:04 AM.

Details

Summary

CurrentDir was set as the path of the current module, but that can change as
part of a chain of loaded modules.

When we try to locate a file mentioned in a module that does not exist, we use
a heuristic to look at the relative path between the original location of the
module and the file we look for, and use that relatively to the CurrentDir.

This only works if CurrentDir is the same as the (current) path of the module
file the file was mentioned in; if it is not, we look at the path relatively to
the wrong directory, and can end up reading random unrelated files that happen
to have the same name.

This patch fixes this by using the BaseDirectory of the module file the file
we look for was mentioned in instead of the CurrentDir heuristic.

Event Timeline

klimek created this revision.Jul 25 2017, 3:04 AM
This revision is now accepted and ready to land.Jul 25 2017, 3:12 AM
This revision was automatically updated to reflect the committed changes.