r201578 - libclang: fix a bug in processing invalid arguments, introduced in r201249

Dmitri Gribenko gribozavr at gmail.com
Tue Feb 18 07:20:02 PST 2014


Author: gribozavr
Date: Tue Feb 18 09:20:02 2014
New Revision: 201578

URL: http://llvm.org/viewvc/llvm-project?rev=201578&view=rev
Log:
libclang: fix a bug in processing invalid arguments, introduced in r201249

Recommit r201346, reverted in r201373.

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

Modified: cfe/trunk/test/Unit/lit.cfg
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Unit/lit.cfg?rev=201578&r1=201577&r2=201578&view=diff
==============================================================================
--- cfe/trunk/test/Unit/lit.cfg (original)
+++ cfe/trunk/test/Unit/lit.cfg Tue Feb 18 09:20:02 2014
@@ -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
+

Modified: cfe/trunk/test/Unit/lit.site.cfg.in
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Unit/lit.site.cfg.in?rev=201578&r1=201577&r2=201578&view=diff
==============================================================================
--- cfe/trunk/test/Unit/lit.site.cfg.in (original)
+++ cfe/trunk/test/Unit/lit.site.cfg.in Tue Feb 18 09:20:02 2014
@@ -10,7 +10,6 @@ config.llvm_build_mode = "@LLVM_BUILD_MO
 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

Modified: cfe/trunk/tools/libclang/CIndex.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=201578&r1=201577&r2=201578&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/CIndex.cpp (original)
+++ cfe/trunk/tools/libclang/CIndex.cpp Tue Feb 18 09:20:02 2014
@@ -2686,6 +2686,11 @@ static void clang_parseTranslationUnit_I
   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_I
     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;
 }
 

Modified: cfe/trunk/unittests/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/CMakeLists.txt?rev=201578&r1=201577&r2=201578&view=diff
==============================================================================
--- cfe/trunk/unittests/CMakeLists.txt (original)
+++ cfe/trunk/unittests/CMakeLists.txt Tue Feb 18 09:20:02 2014
@@ -22,3 +22,6 @@ if(CLANG_ENABLE_REWRITER)
   add_subdirectory(Format)
   add_subdirectory(Sema)
 endif()
+if(NOT WIN32) # FIXME:Investigating.
+  add_subdirectory(libclang)
+endif()

Modified: cfe/trunk/unittests/Makefile
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Makefile?rev=201578&r1=201577&r2=201578&view=diff
==============================================================================
--- cfe/trunk/unittests/Makefile (original)
+++ cfe/trunk/unittests/Makefile Tue Feb 18 09:20:02 2014
@@ -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
 





More information about the cfe-commits mailing list