summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2017-02-25 18:14:35 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2017-02-25 18:14:35 +0000
commitbcae047dc98d08b8ccc8b17ba2729c80d66ff5c0 (patch)
treec0028322ce083706f3eb44820714276c36a513a1
parentbdff27dbeac3f8152bb2195bc6e4d51e54c5360a (diff)
downloadbcm5719-llvm-bcae047dc98d08b8ccc8b17ba2729c80d66ff5c0.tar.gz
bcm5719-llvm-bcae047dc98d08b8ccc8b17ba2729c80d66ff5c0.zip
[driver] Pass a resource dir without the '/../' part.
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. llvm-svn: 296262
-rw-r--r--clang/lib/Driver/Driver.cpp3
-rw-r--r--clang/test/Index/pch-from-libclang.c18
2 files changed, 20 insertions, 1 deletions
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index b8ae7e4c312..6defb204134 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -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/clang/test/Index/pch-from-libclang.c b/clang/test/Index/pch-from-libclang.c
new file mode 100644
index 00000000000..e1bbe7cbd12
--- /dev/null
+++ b/clang/test/Index/pch-from-libclang.c
@@ -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
OpenPOWER on IntegriCloud