]> granicus.if.org Git - clang/commit
Fix incorrect use of current directory to find moved paths in ASTReader.
authorManuel Klimek <klimek@google.com>
Tue, 25 Jul 2017 10:22:06 +0000 (10:22 +0000)
committerManuel Klimek <klimek@google.com>
Tue, 25 Jul 2017 10:22:06 +0000 (10:22 +0000)
commit7bc4653919144b817f63cb1cccc73c87f11e2683
treeed856add0c9934c6092e625677b2438b1fbc53dd
parent7c823a91d83e273cc09979528b2dd0e1233dfbef
Fix incorrect use of current directory to find moved paths in ASTReader.

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.

Differential Revision: https://reviews.llvm.org/D35828

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@308962 91177308-0d34-0410-b5e6-96231b3b80d8
include/clang/Serialization/ASTReader.h
lib/Serialization/ASTReader.cpp
test/Modules/path-resolution.modulemap [new file with mode: 0644]