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)) {
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))
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;
}
add_subdirectory(Format)
add_subdirectory(Sema)
endif()
+add_subdirectory(libclang)
IS_UNITTEST_LEVEL := 1
CLANG_LEVEL := ..
-PARALLEL_DIRS = Basic Lex Driver
+PARALLEL_DIRS = Basic Lex Driver libclang
include $(CLANG_LEVEL)/../..//Makefile.config
--- /dev/null
+add_clang_unittest(libclangTests
+ LibclangTest.cpp
+ )
+
+target_link_libraries(libclangTests
+ libclang
+ )
--- /dev/null
+//===- unittests/libclang/LibclangTest.cpp --- libclang tests -------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "clang-c/Index.h"
+#include "gtest/gtest.h"
+
+TEST(libclang, TestInvalidArgs) {
+ EXPECT_EQ(CXError_InvalidArguments,
+ clang_parseTranslationUnit2(0, 0, 0, 0, 0, 0, 0, 0));
+}
+
--- /dev/null
+##===- unittests/libclang/Makefile -------------------------*- Makefile -*-===##
+#
+# The LLVM Compiler Infrastructure
+#
+# This file is distributed under the University of Illinois Open Source
+# License. See LICENSE.TXT for details.
+#
+##===----------------------------------------------------------------------===##
+
+CLANG_LEVEL = ../..
+TESTNAME = libclang
+include $(CLANG_LEVEL)/../../Makefile.config
+LINK_COMPONENTS := $(TARGETS_TO_BUILD) asmparser bitreader support mc option
+
+# Note that 'USEDLIBS' must include all of the core clang libraries
+# when -static is given to linker on cygming.
+USEDLIBS = clang.a \
+ clangIndex.a clangFormat.a clangRewriteCore.a \
+ clangFrontend.a clangDriver.a \
+ clangTooling.a \
+ clangSerialization.a clangParse.a clangSema.a \
+ clangAnalysis.a clangEdit.a clangAST.a clangLex.a \
+ clangBasic.a
+
+include $(CLANG_LEVEL)/unittests/Makefile