[cfe-commits] r109470 - in /cfe/trunk: lib/Basic/FileManager.cpp test/Index/Inputs/preamble.h test/Index/Inputs/prefix.h test/Index/preamble.c
Douglas Gregor
dgregor at apple.com
Mon Jul 26 16:54:23 PDT 2010
Author: dgregor
Date: Mon Jul 26 18:54:23 2010
New Revision: 109470
URL: http://llvm.org/viewvc/llvm-project?rev=109470&view=rev
Log:
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...
Added:
cfe/trunk/test/Index/Inputs/preamble.h
cfe/trunk/test/Index/Inputs/prefix.h
cfe/trunk/test/Index/preamble.c
Modified:
cfe/trunk/lib/Basic/FileManager.cpp
Modified: cfe/trunk/lib/Basic/FileManager.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/FileManager.cpp?rev=109470&r1=109469&r2=109470&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/FileManager.cpp (original)
+++ cfe/trunk/lib/Basic/FileManager.cpp Mon Jul 26 18:54:23 2010
@@ -365,6 +365,18 @@
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;
}
Added: cfe/trunk/test/Index/Inputs/preamble.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/Inputs/preamble.h?rev=109470&view=auto
==============================================================================
--- cfe/trunk/test/Index/Inputs/preamble.h (added)
+++ cfe/trunk/test/Index/Inputs/preamble.h Mon Jul 26 18:54:23 2010
@@ -0,0 +1 @@
+int bar(int);
Added: cfe/trunk/test/Index/Inputs/prefix.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/Inputs/prefix.h?rev=109470&view=auto
==============================================================================
--- cfe/trunk/test/Index/Inputs/prefix.h (added)
+++ cfe/trunk/test/Index/Inputs/prefix.h Mon Jul 26 18:54:23 2010
@@ -0,0 +1,4 @@
+#ifndef PREFIX_H
+#define PREFIX_H
+int foo(int);
+#endif
Added: cfe/trunk/test/Index/preamble.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/preamble.c?rev=109470&view=auto
==============================================================================
--- cfe/trunk/test/Index/preamble.c (added)
+++ cfe/trunk/test/Index/preamble.c Mon Jul 26 18:54:23 2010
@@ -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]
More information about the cfe-commits
mailing list