From: Argyrios Kyrtzidis Date: Sat, 25 Feb 2017 18:14:35 +0000 (+0000) Subject: [driver] Pass a resource dir without the '/../' part. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f94b622d130121f250e5a1690569c1d2819e3f38;p=clang [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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296262 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Driver/Driver.cpp b/lib/Driver/Driver.cpp index b8ae7e4c31..6defb20413 100644 --- a/lib/Driver/Driver.cpp +++ b/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/test/Index/pch-from-libclang.c b/test/Index/pch-from-libclang.c new file mode 100644 index 0000000000..e1bbe7cbd1 --- /dev/null +++ b/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