Skip to content

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

added tests for c-api #3

wants to merge 4 commits into from

Conversation

kr-2003
Copy link
Owner

@kr-2003 kr-2003 commented Apr 15, 2025

No description provided.

Copy link

@github-actions github-actions bot left a 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)

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)) {}

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>>&

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>>&

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>>&

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";

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) {

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]

Suggested change
TEST(InterpreterTest, CreateInterpreterCAPI) {
TESTstatic (InterpreterTest, CreateInterpreterCAPI) {

@@ -166,6 +166,20 @@
#endif
}

TEST(InterpreterTest, CreateInterpreterCAPI) {
const char* argv[] = {"-std=c++17"};

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);

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);

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]

Suggested change
auto CLI = clang_Interpreter_getClangInterpreter(CXI);
auto *CLI = clang_Interpreter_getClangInterpreter(CXI);

Copy link

@github-actions github-actions bot left a 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) {

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]

Suggested change
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"};

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);

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);
                                      ^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant