r296262 - [driver] Pass a resource dir without the '/../' part.

Argyrios Kyrtzidis via cfe-commits cfe-commits at lists.llvm.org
Sat Feb 25 10:14:35 PST 2017


Author: akirtzidis
Date: Sat Feb 25 12:14:35 2017
New Revision: 296262

URL: http://llvm.org/viewvc/llvm-project?rev=296262&view=rev
Log:
[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.

Added:
    cfe/trunk/test/Index/pch-from-libclang.c
Modified:
    cfe/trunk/lib/Driver/Driver.cpp

Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=296262&r1=296261&r2=296262&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Sat Feb 25 12:14:35 2017
@@ -79,7 +79,8 @@ Driver::Driver(StringRef ClangExecutable
     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();

Added: cfe/trunk/test/Index/pch-from-libclang.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/pch-from-libclang.c?rev=296262&view=auto
==============================================================================
--- cfe/trunk/test/Index/pch-from-libclang.c (added)
+++ cfe/trunk/test/Index/pch-from-libclang.c Sat Feb 25 12:14:35 2017
@@ -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




More information about the cfe-commits mailing list