forked from OSchip/llvm-project
parent
45e6c2406d
commit
f9e9bb8858
|
@ -1275,17 +1275,19 @@ ASTUnit::ComputePreamble(CompilerInvocation &Invocation,
|
||||||
// command line (to another file) or directly through the compiler invocation
|
// command line (to another file) or directly through the compiler invocation
|
||||||
// (to a memory buffer).
|
// (to a memory buffer).
|
||||||
llvm::MemoryBuffer *Buffer = 0;
|
llvm::MemoryBuffer *Buffer = 0;
|
||||||
llvm::sys::PathWithStatus MainFilePath(FrontendOpts.Inputs[0].getFile());
|
std::string MainFilePath(FrontendOpts.Inputs[0].getFile());
|
||||||
if (const llvm::sys::FileStatus *MainFileStatus = MainFilePath.getFileStatus()) {
|
uint64_t MainFileID;
|
||||||
|
if (!llvm::sys::fs::GetUniqueID(MainFilePath, MainFileID)) {
|
||||||
// Check whether there is a file-file remapping of the main file
|
// Check whether there is a file-file remapping of the main file
|
||||||
for (PreprocessorOptions::remapped_file_iterator
|
for (PreprocessorOptions::remapped_file_iterator
|
||||||
M = PreprocessorOpts.remapped_file_begin(),
|
M = PreprocessorOpts.remapped_file_begin(),
|
||||||
E = PreprocessorOpts.remapped_file_end();
|
E = PreprocessorOpts.remapped_file_end();
|
||||||
M != E;
|
M != E;
|
||||||
++M) {
|
++M) {
|
||||||
llvm::sys::PathWithStatus MPath(M->first);
|
std::string MPath(M->first);
|
||||||
if (const llvm::sys::FileStatus *MStatus = MPath.getFileStatus()) {
|
uint64_t MID;
|
||||||
if (MainFileStatus->uniqueID == MStatus->uniqueID) {
|
if (!llvm::sys::fs::GetUniqueID(MPath, MID)) {
|
||||||
|
if (MainFileID == MID) {
|
||||||
// We found a remapping. Try to load the resulting, remapped source.
|
// We found a remapping. Try to load the resulting, remapped source.
|
||||||
if (CreatedBuffer) {
|
if (CreatedBuffer) {
|
||||||
delete Buffer;
|
delete Buffer;
|
||||||
|
@ -1308,9 +1310,10 @@ ASTUnit::ComputePreamble(CompilerInvocation &Invocation,
|
||||||
E = PreprocessorOpts.remapped_file_buffer_end();
|
E = PreprocessorOpts.remapped_file_buffer_end();
|
||||||
M != E;
|
M != E;
|
||||||
++M) {
|
++M) {
|
||||||
llvm::sys::PathWithStatus MPath(M->first);
|
std::string MPath(M->first);
|
||||||
if (const llvm::sys::FileStatus *MStatus = MPath.getFileStatus()) {
|
uint64_t MID;
|
||||||
if (MainFileStatus->uniqueID == MStatus->uniqueID) {
|
if (!llvm::sys::fs::GetUniqueID(MPath, MID)) {
|
||||||
|
if (MainFileID == MID) {
|
||||||
// We found a remapping.
|
// We found a remapping.
|
||||||
if (CreatedBuffer) {
|
if (CreatedBuffer) {
|
||||||
delete Buffer;
|
delete Buffer;
|
||||||
|
@ -2478,15 +2481,19 @@ void ASTUnit::CodeComplete(StringRef File, unsigned Line, unsigned Column,
|
||||||
llvm::MemoryBuffer *OverrideMainBuffer = 0;
|
llvm::MemoryBuffer *OverrideMainBuffer = 0;
|
||||||
if (!getPreambleFile(this).empty()) {
|
if (!getPreambleFile(this).empty()) {
|
||||||
using llvm::sys::FileStatus;
|
using llvm::sys::FileStatus;
|
||||||
llvm::sys::PathWithStatus CompleteFilePath(File);
|
std::string CompleteFilePath(File);
|
||||||
llvm::sys::PathWithStatus MainPath(OriginalSourceFile);
|
uint64_t CompleteFileID;
|
||||||
if (const FileStatus *CompleteFileStatus = CompleteFilePath.getFileStatus())
|
|
||||||
if (const FileStatus *MainStatus = MainPath.getFileStatus())
|
if (!llvm::sys::fs::GetUniqueID(CompleteFilePath, CompleteFileID)) {
|
||||||
if (CompleteFileStatus->getUniqueID() == MainStatus->getUniqueID() &&
|
std::string MainPath(OriginalSourceFile);
|
||||||
Line > 1)
|
uint64_t MainID;
|
||||||
|
if (!llvm::sys::fs::GetUniqueID(MainPath, MainID)) {
|
||||||
|
if (CompleteFileID == MainID && Line > 1)
|
||||||
OverrideMainBuffer
|
OverrideMainBuffer
|
||||||
= getMainBufferWithPrecompiledPreamble(*CCInvocation, false,
|
= getMainBufferWithPrecompiledPreamble(*CCInvocation, false,
|
||||||
Line - 1);
|
Line - 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the main file has been overridden due to the use of a preamble,
|
// If the main file has been overridden due to the use of a preamble,
|
||||||
|
|
Loading…
Reference in New Issue