summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang/lib/Basic/FileManager.cpp7
-rw-r--r--clang/test/Modules/Inputs/filename/a.h1
-rw-r--r--clang/test/Modules/Inputs/filename/module.map3
-rw-r--r--clang/test/Modules/filename.cpp9
4 files changed, 20 insertions, 0 deletions
diff --git a/clang/lib/Basic/FileManager.cpp b/clang/lib/Basic/FileManager.cpp
index e4a7f1e2575..07297baf6d5 100644
--- a/clang/lib/Basic/FileManager.cpp
+++ b/clang/lib/Basic/FileManager.cpp
@@ -281,6 +281,13 @@ const FileEntry *FileManager::getFile(StringRef Filename, bool openFile,
if (DirInfo != UFE.Dir && Data.IsVFSMapped)
UFE.Dir = DirInfo;
+ // Always update the name to use the last name by which a file was accessed.
+ // FIXME: Neither this nor always using the first name is correct; we want
+ // to switch towards a design where we return a FileName object that
+ // encapsulates both the name by which the file was accessed and the
+ // corresponding FileEntry.
+ UFE.Name = Data.Name;
+
return &UFE;
}
diff --git a/clang/test/Modules/Inputs/filename/a.h b/clang/test/Modules/Inputs/filename/a.h
new file mode 100644
index 00000000000..8f896a9ba8f
--- /dev/null
+++ b/clang/test/Modules/Inputs/filename/a.h
@@ -0,0 +1 @@
+const char *p = __FILE__;
diff --git a/clang/test/Modules/Inputs/filename/module.map b/clang/test/Modules/Inputs/filename/module.map
new file mode 100644
index 00000000000..ff164ad7bac
--- /dev/null
+++ b/clang/test/Modules/Inputs/filename/module.map
@@ -0,0 +1,3 @@
+module "A" {
+ header "a.h"
+}
diff --git a/clang/test/Modules/filename.cpp b/clang/test/Modules/filename.cpp
new file mode 100644
index 00000000000..66891a04b74
--- /dev/null
+++ b/clang/test/Modules/filename.cpp
@@ -0,0 +1,9 @@
+// RUN: cd %S
+// RUN: %clang_cc1 -I. -fmodule-maps -fmodule-name=A -fmodule-map-file=%S/Inputs/filename/module.map %s -E | FileCheck %s
+// REQUIRES: shell
+
+#include "Inputs/filename/a.h"
+
+// Make sure that headers that are referenced by module maps have __FILE__
+// reflect the include path they were found with.
+// CHECK: const char *p = "./Inputs/filename/a.h"
OpenPOWER on IntegriCloud