When writing file references in a pch, make sure to ask the file manager for the absolute path.
llvm-svn: 127248
This commit is contained in:
parent
679cfb54ec
commit
a426705cc6
|
@ -1460,6 +1460,13 @@ void ASTWriter::WriteSourceManagerBlock(SourceManager &SourceMgr,
|
|||
// Turn the file name into an absolute path, if it isn't already.
|
||||
const char *Filename = Content->OrigEntry->getName();
|
||||
llvm::SmallString<128> FilePath(Filename);
|
||||
|
||||
// Ask the file manager to fixup the relative path for us. This will
|
||||
// honor the working directory.
|
||||
SourceMgr.getFileManager().FixupRelativePath(FilePath);
|
||||
|
||||
// FIXME: This call to make_absolute shouldn't be necessary, the
|
||||
// call to FixupRelativePath should always return an absolute path.
|
||||
llvm::sys::fs::make_absolute(FilePath);
|
||||
Filename = FilePath.c_str();
|
||||
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
template<typename T> struct A {
|
||||
A() {
|
||||
int a;
|
||||
}
|
||||
};
|
|
@ -0,0 +1,12 @@
|
|||
// Test this without pch.
|
||||
// RUN: %clang_cc1 -working-directory %S -I. -include working-directory.h %s -Wunused
|
||||
|
||||
// Test with pch.
|
||||
// RUN: %clang_cc1 -working-directory %S -x c++-header -emit-pch -o %t.pch -I. working-directory.h
|
||||
// RUN: %clang_cc1 -include-pch %t.pch -fsyntax-only %s -Wunused
|
||||
|
||||
void f() {
|
||||
// Instantiating A<char> will trigger a warning, which will end up trying to get the path to
|
||||
// the header that contains A.
|
||||
A<char> b;
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
#include <Inputs/working-directory-1.h>
|
Loading…
Reference in New Issue