aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2010-07-26 23:54:23 +0000
committerDouglas Gregor <dgregor@apple.com>2010-07-26 23:54:23 +0000
commit3e15e0a7b4da6d906357b00b1bd2bba5ec3195ed (patch)
tree696f5bd7b8705631692abb79d5aa73c2fdbbfdd1
parente42b8a596886fc98e367c73e54d761446700029e (diff)
When remapping a virtual file, also make an entry for the file with
its absolute path on disk. Also, introduce a fun test for the precompiled preamble, which almost works... git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@109470 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Basic/FileManager.cpp12
-rw-r--r--test/Index/Inputs/preamble.h1
-rw-r--r--test/Index/Inputs/prefix.h4
-rw-r--r--test/Index/preamble.c13
4 files changed, 30 insertions, 0 deletions
diff --git a/lib/Basic/FileManager.cpp b/lib/Basic/FileManager.cpp
index 3c91a0f875..aa175cb1a6 100644
--- a/lib/Basic/FileManager.cpp
+++ b/lib/Basic/FileManager.cpp
@@ -365,6 +365,18 @@ FileManager::getVirtualFile(llvm::StringRef Filename, off_t Size,
UFE->ModTime = ModificationTime;
UFE->Dir = DirInfo;
UFE->UID = NextFileUID++;
+
+ // If this virtual file resolves to a file, also map that file to the
+ // newly-created file entry.
+ const char *InterndFileName = NamedFileEnt.getKeyData();
+ struct stat StatBuf;
+ if (!stat_cached(InterndFileName, &StatBuf) &&
+ !S_ISDIR(StatBuf.st_mode)) {
+ llvm::sys::Path FilePath(InterndFileName);
+ FilePath.makeAbsolute();
+ FileEntries[FilePath.str()] = UFE;
+ }
+
return UFE;
}
diff --git a/test/Index/Inputs/preamble.h b/test/Index/Inputs/preamble.h
new file mode 100644
index 0000000000..e588c12ddc
--- /dev/null
+++ b/test/Index/Inputs/preamble.h
@@ -0,0 +1 @@
+int bar(int);
diff --git a/test/Index/Inputs/prefix.h b/test/Index/Inputs/prefix.h
new file mode 100644
index 0000000000..82ba2da360
--- /dev/null
+++ b/test/Index/Inputs/prefix.h
@@ -0,0 +1,4 @@
+#ifndef PREFIX_H
+#define PREFIX_H
+int foo(int);
+#endif
diff --git a/test/Index/preamble.c b/test/Index/preamble.c
new file mode 100644
index 0000000000..ad64a43554
--- /dev/null
+++ b/test/Index/preamble.c
@@ -0,0 +1,13 @@
+#include "prefix.h"
+#include "preamble.h"
+int wibble(int);
+
+// FIXME: Turn on use of preamble files
+
+// RUN: %clang -x c-header -o %t.pch %S/Inputs/prefix.h
+// RUN: c-index-test -test-load-source-reparse 5 local -I %S/Inputs -include %t %s | FileCheck %s
+
+// CHECK: preamble.h:1:5: FunctionDecl=bar:1:5 Extent=[1:5 - 1:13]
+// CHECK: preamble.h:1:12: ParmDecl=:1:12 (Definition) Extent=[1:9 - 1:13]
+// CHECK: preamble.c:3:5: FunctionDecl=wibble:3:5 Extent=[3:5 - 3:16]
+// CHECK: preamble.c:3:15: ParmDecl=:3:15 (Definition) Extent=[3:12 - 3:16]