This get the resource dir string to match with the one from libclang (which is not adding '/../'),
and allows clang to accept a modules-enabled PCH that was created by libclang.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296262
91177308-0d34-0410-b5e6-
96231b3b80d8
llvm::sys::path::append(P, ClangResourceDir);
} else {
StringRef ClangLibdirSuffix(CLANG_LIBDIR_SUFFIX);
- llvm::sys::path::append(P, "..", Twine("lib") + ClangLibdirSuffix, "clang",
+ P = llvm::sys::path::parent_path(Dir);
+ llvm::sys::path::append(P, Twine("lib") + ClangLibdirSuffix, "clang",
CLANG_VERSION_STRING);
}
ResourceDir = P.str();
--- /dev/null
+// Check that clang can use a PCH created from libclang.
+// RUN: c-index-test -write-pch %t.h.pch %s -fmodules -fmodules-cache-path=%t.mcp
+// RUN: %clang -fsyntax-only -include %t.h %s -Xclang -verify -fmodules -fmodules-cache-path=%t.mcp -Xclang -detailed-preprocessing-record
+
+// expected-no-diagnostics
+
+#ifndef HEADER
+#define HEADER
+
+struct S { int x; };
+
+#else
+
+void test(struct S *s) {
+ s->x = 0;
+}
+
+#endif