-
Notifications
You must be signed in to change notification settings - Fork 0
added tests for c-api #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -136,11 +136,15 @@ class Interpreter { | |
private: | ||
std::unique_ptr<clang::Interpreter> inner; | ||
|
||
Interpreter(std::unique_ptr<clang::Interpreter> CI) : inner(std::move(CI)) {} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warning: no header providing "std::move" is directly included [misc-include-cleaner] lib/Interpreter/CppInterOpInterpreter.h:24: - #if CLANG_VERSION_MAJOR >= 19
+ #include <utility>
+ #if CLANG_VERSION_MAJOR >= 19 |
||
|
||
public: | ||
Interpreter(int argc, const char* const* argv, const char* llvmdir = 0, | ||
const std::vector<std::shared_ptr<clang::ModuleFileExtension>>& | ||
moduleExtensions = {}, | ||
void* extraLibHandle = 0, bool noRuntime = true) { | ||
|
||
static std::unique_ptr<Interpreter> | ||
create(int argc, const char* const* argv, const char* llvmdir = nullptr, | ||
const std::vector<std::shared_ptr<clang::ModuleFileExtension>>& | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warning: no header providing "clang::ModuleFileExtension" is directly included [misc-include-cleaner] lib/Interpreter/CppInterOpInterpreter.h:24: - #if CLANG_VERSION_MAJOR >= 19
+ #include <clang/Serialization/ModuleFileExtension.h>
+ #if CLANG_VERSION_MAJOR >= 19 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warning: no header providing "std::shared_ptr" is directly included [misc-include-cleaner] const std::vector<std::shared_ptr<clang::ModuleFileExtension>>&
^ There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warning: no header providing "std::vector" is directly included [misc-include-cleaner] lib/Interpreter/CppInterOpInterpreter.h:24: - #if CLANG_VERSION_MAJOR >= 19
+ #include <vector>
+ #if CLANG_VERSION_MAJOR >= 19 |
||
moduleExtensions = {}, | ||
void* extraLibHandle = nullptr, bool noRuntime = true) { | ||
// Initialize all targets (required for device offloading) | ||
llvm::InitializeAllTargetInfos(); | ||
llvm::InitializeAllTargets(); | ||
|
@@ -150,7 +154,13 @@ class Interpreter { | |
std::vector<const char*> vargs(argv + 1, argv + argc); | ||
vargs.push_back("-include"); | ||
vargs.push_back("new"); | ||
inner = compat::createClangInterpreter(vargs); | ||
auto CI = compat::createClangInterpreter(vargs); | ||
if (!CI) { | ||
llvm::errs() << "Interpreter creation failed\n"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warning: no header providing "llvm::errs" is directly included [misc-include-cleaner] lib/Interpreter/CppInterOpInterpreter.h:24: - #if CLANG_VERSION_MAJOR >= 19
+ #include <llvm/Support/raw_ostream.h>
+ #if CLANG_VERSION_MAJOR >= 19 |
||
return nullptr; | ||
} | ||
|
||
return std::unique_ptr<Interpreter>(new Interpreter(std::move(CI))); | ||
} | ||
|
||
~Interpreter() {} | ||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -166,6 +166,29 @@ TEST(InterpreterTest, CreateInterpreter) { | |||||
#endif | ||||||
} | ||||||
|
||||||
TEST(InterpreterTest, CreateInterpreterCAPI) { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warning: function 'TEST' can be made static or moved into an anonymous namespace to enforce internal linkage [misc-use-internal-linkage]
Suggested change
|
||||||
#ifdef CPPINTEROP_USE_CLING | ||||||
GTEST_SKIP() << "C API is not available in this build"; | ||||||
#endif | ||||||
// C API | ||||||
const char* argv[] = {"-std=c++17"}; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warning: do not declare C-style arrays, use std::array<> instead [cppcoreguidelines-avoid-c-arrays] const char* argv[] = {"-std=c++17"};
^ |
||||||
auto *CXI = clang_createInterpreter(argv, 1); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warning: do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay] auto *CXI = clang_createInterpreter(argv, 1);
^ |
||||||
auto CLI = clang_Interpreter_getClangInterpreter(CXI); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warning: 'auto CLI' can be declared as 'auto *CLI' [llvm-qualified-auto]
Suggested change
|
||||||
EXPECT_TRUE(CLI); | ||||||
clang_Interpreter_dispose(CXI); | ||||||
} | ||||||
|
||||||
TEST(InterpreterTest, CreateInterpreterCAPIFailure) { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warning: function 'TEST' can be made static or moved into an anonymous namespace to enforce internal linkage [misc-use-internal-linkage]
Suggested change
|
||||||
#ifdef CPPINTEROP_USE_CLING | ||||||
GTEST_SKIP() << "C API is not available in this build"; | ||||||
#endif | ||||||
const char* argv[] = {"-fsyntax-only", "-Xclang", "-invalid-plugin"}; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warning: do not declare C-style arrays, use std::array<> instead [cppcoreguidelines-avoid-c-arrays] const char* argv[] = {"-fsyntax-only", "-Xclang", "-invalid-plugin"};
^ |
||||||
testing::internal::CaptureStderr(); // Suppress error messages | ||||||
auto *CXI = clang_createInterpreter(argv, 3); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warning: do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay] auto *CXI = clang_createInterpreter(argv, 3);
^ |
||||||
std::string capturedStderr = testing::internal::GetCapturedStderr(); | ||||||
EXPECT_EQ(CXI, nullptr); | ||||||
} | ||||||
|
||||||
#ifdef LLVM_BINARY_DIR | ||||||
TEST(InterpreterTest, DetectResourceDir) { | ||||||
#ifdef EMSCRIPTEN | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: no header providing "std::make_unique" is directly included [misc-include-cleaner]