]> granicus.if.org Git - clang/commitdiff
libclang: fix a bug in processing invalid arguments, introduced in r201249
authorDmitri Gribenko <gribozavr@gmail.com>
Tue, 18 Feb 2014 15:20:02 +0000 (15:20 +0000)
committerDmitri Gribenko <gribozavr@gmail.com>
Tue, 18 Feb 2014 15:20:02 +0000 (15:20 +0000)
Recommit r201346, reverted in r201373.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@201578 91177308-0d34-0410-b5e6-96231b3b80d8

test/Unit/lit.cfg
test/Unit/lit.site.cfg.in
tools/libclang/CIndex.cpp
unittests/CMakeLists.txt
unittests/Makefile

index f39fded3acc78ac92c38294659448d02e1a31615..01b54c799dac1f3270881174636482a6f675dd0b 100644 (file)
@@ -3,6 +3,7 @@
 # Configuration file for the 'lit' test runner.
 
 import os
+import platform
 
 import lit.formats
 import lit.util
@@ -85,10 +86,19 @@ if config.test_exec_root is None:
     lit_config.load_config(config, site_cfg)
     raise SystemExit
 
-# If necessary, point the dynamic loader at libLLVM.so.
-if config.enable_shared:
-    shlibpath = config.environment.get(config.shlibpath_var,'')
-    if shlibpath:
-        shlibpath = os.pathsep + shlibpath
-    shlibpath = config.shlibdir + shlibpath
-    config.environment[config.shlibpath_var] = shlibpath
+shlibpath_var = ''
+if platform.system() == 'Linux':
+    shlibpath_var = 'LD_LIBRARY_PATH'
+elif platform.system() == 'Darwin':
+    shlibpath_var = 'DYLD_LIBRARY_PATH'
+elif platform.system() == 'Windows':
+    shlibpath_var = 'PATH'
+
+# Point the dynamic loader at dynamic libraries in 'lib'.
+llvm_libs_dir = getattr(config, 'llvm_libs_dir', None)
+if not llvm_libs_dir:
+    lit_config.fatal('No LLVM libs dir set!')
+shlibpath = os.path.pathsep.join((llvm_libs_dir,
+                                 config.environment.get(shlibpath_var,'')))
+config.environment[shlibpath_var] = shlibpath
+
index a255cdce0de8c557334c66ddc1dad6622914da59..37e8cb011ebb88e933635f1594141ffc1bc977fc 100644 (file)
@@ -10,7 +10,6 @@ config.llvm_build_mode = "@LLVM_BUILD_MODE@"
 config.clang_obj_root = "@CLANG_BINARY_DIR@"
 config.enable_shared = @ENABLE_SHARED@
 config.shlibdir = "@SHLIBDIR@"
-config.shlibpath_var = "@SHLIBPATH_VAR@"
 config.target_triple = "@TARGET_TRIPLE@"
 
 # Support substitution of the tools_dir, libs_dirs, and build_mode with user
index a74feabf06f3c42d32c382890e7613c326fbf7d2..e862889f26367c2f565704660e9fc7f517f4540e 100644 (file)
@@ -2686,6 +2686,11 @@ static void clang_parseTranslationUnit_Impl(void *UserData) {
   unsigned options = PTUI->options;
   CXTranslationUnit *out_TU = PTUI->out_TU;
 
+  // Set up the initial return values.
+  if (out_TU)
+    *out_TU = NULL;
+  PTUI->result = CXError_Failure;
+
   // Check arguments.
   if (!CIdx || !out_TU ||
       (unsaved_files == NULL && num_unsaved_files != 0)) {
@@ -2693,10 +2698,6 @@ static void clang_parseTranslationUnit_Impl(void *UserData) {
     return;
   }
 
-  // Set up the initial return values.
-  *out_TU = NULL;
-  PTUI->result = CXError_Failure;
-
   CIndexer *CXXIdx = static_cast<CIndexer *>(CIdx);
 
   if (CXXIdx->isOptEnabled(CXGlobalOpt_ThreadBackgroundPriorityForIndexing))
@@ -2826,12 +2827,8 @@ clang_parseTranslationUnit(CXIndex CIdx,
       CIdx, source_filename, command_line_args, num_command_line_args,
       unsaved_files, num_unsaved_files, options, &TU);
   (void)Result;
-
-  // FIXME: This probably papers over a problem. If the result is not success,
-  // no TU should be set.
-  if (Result != CXError_Success)
-    return 0;
-
+  assert((TU && Result == CXError_Success) ||
+         (!TU && Result != CXError_Success));
   return TU;
 }
 
index f00008e04071f80d6586815a6fa4ab1e4af23dc8..cc1322699e50fa8b682131670dafccbdad194798 100644 (file)
@@ -22,3 +22,6 @@ if(CLANG_ENABLE_REWRITER)
   add_subdirectory(Format)
   add_subdirectory(Sema)
 endif()
+if(NOT WIN32) # FIXME:Investigating.
+  add_subdirectory(libclang)
+endif()
index e4fbe584da1f0dcb682abe7a34db2262b2a822e1..9b95a6eda20e51b918bd49419ff3602aa22ff8f0 100644 (file)
@@ -14,7 +14,7 @@ ifndef CLANG_LEVEL
 
 IS_UNITTEST_LEVEL := 1
 CLANG_LEVEL := ..
-PARALLEL_DIRS = Basic Lex Driver
+PARALLEL_DIRS = Basic Lex Driver libclang
 
 include $(CLANG_LEVEL)/../..//Makefile.config