-
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?
Conversation
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.
clang-tidy made some suggestions
There were too many comments to post at once. Showing the first 10 out of 13. Check the log or trigger a new build to see more.
@@ -271,8 +271,17 @@ static inline compat::Interpreter* getInterpreter(const CXInterpreterImpl* I) { | |||
} | |||
|
|||
CXInterpreter clang_createInterpreter(const char* const* argv, int argc) { | |||
auto* I = new CXInterpreterImpl(); // NOLINT(*-owning-memory) | |||
auto I = std::make_unique<CXInterpreterImpl>(); // NOLINT(*-owning-memory) |
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]
auto I = std::make_unique<CXInterpreterImpl>(); // NOLINT(*-owning-memory)
^
@@ -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 comment
The 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
|
||
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 comment
The 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
|
||
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 comment
The 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>>&
^
|
||
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 comment
The 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
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 comment
The 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
@@ -166,6 +166,20 @@ TEST(InterpreterTest, CreateInterpreter) { | |||
#endif | |||
} | |||
|
|||
TEST(InterpreterTest, CreateInterpreterCAPI) { |
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: function 'TEST' can be made static or moved into an anonymous namespace to enforce internal linkage [misc-use-internal-linkage]
TEST(InterpreterTest, CreateInterpreterCAPI) { | |
TESTstatic (InterpreterTest, CreateInterpreterCAPI) { |
@@ -166,6 +166,20 @@ | |||
#endif | |||
} | |||
|
|||
TEST(InterpreterTest, CreateInterpreterCAPI) { | |||
const char* argv[] = {"-std=c++17"}; |
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: do not declare C-style arrays, use std::array<> instead [cppcoreguidelines-avoid-c-arrays]
const char* argv[] = {"-std=c++17"};
^
@@ -166,6 +166,20 @@ | |||
#endif | |||
} | |||
|
|||
TEST(InterpreterTest, CreateInterpreterCAPI) { | |||
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 comment
The 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);
^
TEST(InterpreterTest, CreateInterpreterCAPI) { | ||
const char* argv[] = {"-std=c++17"}; | ||
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 comment
The reason will be displayed to describe this comment to others. Learn more.
warning: 'auto CLI' can be declared as 'auto *CLI' [llvm-qualified-auto]
auto CLI = clang_Interpreter_getClangInterpreter(CXI); | |
auto *CLI = clang_Interpreter_getClangInterpreter(CXI); |
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.
clang-tidy made some suggestions
clang_Interpreter_dispose(CXI); | ||
} | ||
|
||
TEST(InterpreterTest, CreateInterpreterCAPIFailure) { |
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: function 'TEST' can be made static or moved into an anonymous namespace to enforce internal linkage [misc-use-internal-linkage]
TEST(InterpreterTest, CreateInterpreterCAPIFailure) { | |
TESTstatic (InterpreterTest, CreateInterpreterCAPIFailure) { |
#ifdef CPPINTEROP_USE_CLANG | ||
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 comment
The 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"};
^
GTEST_SKIP() << "C API is not available in this build"; | ||
#endif | ||
const char* argv[] = {"-fsyntax-only", "-Xclang", "-invalid-plugin"}; | ||
auto *CXI = clang_createInterpreter(argv, 3); |
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: 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);
^
No description provided.