]> granicus.if.org Git - clang/commitdiff
[driver] Pass a resource dir without the '/../' part.
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Sat, 25 Feb 2017 18:14:35 +0000 (18:14 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Sat, 25 Feb 2017 18:14:35 +0000 (18:14 +0000)
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

lib/Driver/Driver.cpp
test/Index/pch-from-libclang.c [new file with mode: 0644]

index b8ae7e4c3129cc6f91733ec55cfe9ffeccdf7262..6defb2041347c7f8998fd8a2a495ff56bd97a5f2 100644 (file)
@@ -79,7 +79,8 @@ Driver::Driver(StringRef ClangExecutable, StringRef DefaultTargetTriple,
     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();
diff --git a/test/Index/pch-from-libclang.c b/test/Index/pch-from-libclang.c
new file mode 100644 (file)
index 0000000..e1bbe7c
--- /dev/null
@@ -0,0 +1,18 @@
+// 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