Skip to content

Conversation

kr-2003
Copy link
Contributor

@kr-2003 kr-2003 commented Sep 20, 2025

No description provided.

Copy link
Contributor

@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 16. Check the log or trigger a new build to see more.


inline std::unique_ptr<clang::Interpreter>
createClangInterpreter(std::vector<const char*>& args) {
createClangInterpreter(std::vector<const char*>& args, int stdin_fd = 0,
Copy link
Contributor

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/CppInterOp/Compatibility.h:14:

+ #include <vector>

m_FD = fileno(m_TempFile);
m_OwnsFile = false;
} else {
m_TempFile = tmpfile();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: assigning newly created 'gsl::owner<>' to non-owner 'FILE *' (aka '_IO_FILE *') [cppcoreguidelines-owning-memory]

      m_TempFile = tmpfile();
      ^

~StreamCaptureInfo() {
assert(m_DupFD == -1 && "Captured output not used?");
if (m_TempFile && m_OwnsFile) {
fclose(m_TempFile);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: calling legacy resource function without passing a 'gsl::owner<>' [cppcoreguidelines-owning-memory]

      fclose(m_TempFile);
      ^

size_t newLen =
fread(content.get(), sizeof(char), bufsize, m_TempFile.get());
if (ferror(m_TempFile.get()) != 0)
size_t newLen = fread(content.get(), sizeof(char), bufsize, m_TempFile);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: The 1st argument to 'fread' is a buffer with size 0 but should be a buffer with size equal to or greater than the value of the 2nd argument (which is 1) times the 3rd argument (which is 18446744073709551615) [clang-analyzer-unix.StdCLibraryFunctions]

    size_t newLen = fread(content.get(), sizeof(char), bufsize, m_TempFile);
                    ^
Additional context

lib/CppInterOp/CppInterOp.cpp:4409: Calling 'StreamCaptureInfo::GetCapturedString'

  std::string result = SCI.GetCapturedString();
                       ^

lib/CppInterOp/CppInterOp.cpp:4356: Taking false branch

    if (dup2(m_DupFD, m_FD) < 0)
    ^

lib/CppInterOp/CppInterOp.cpp:4359: Taking false branch

    if (fseek(m_TempFile, 0L, SEEK_END) != 0)
    ^

lib/CppInterOp/CppInterOp.cpp:4363: Assuming that 'ftell' fails

    long bufsize = ftell(m_TempFile);
                   ^

lib/CppInterOp/CppInterOp.cpp:4363: 'bufsize' initialized here

    long bufsize = ftell(m_TempFile);
    ^

lib/CppInterOp/CppInterOp.cpp:4364: Taking true branch

    if (bufsize == -1)
    ^

lib/CppInterOp/CppInterOp.cpp:4368: Storing uninitialized value

    std::unique_ptr<char[]> content(new char[bufsize + 1]);
                                    ^

lib/CppInterOp/CppInterOp.cpp:4368: Passing value via 1st parameter '__p'

    std::unique_ptr<char[]> content(new char[bufsize + 1]);
                                    ^

lib/CppInterOp/CppInterOp.cpp:4368: Calling constructor for 'unique_ptr<char[], std::default_delete<char[]>>'

    std::unique_ptr<char[]> content(new char[bufsize + 1]);
                            ^

/usr/include/c++/13/bits/unique_ptr.h:603: Calling constructor for '__uniq_ptr_data<char, std::default_delete<char[]>, true, true>'

	: _M_t(__p)
   ^

/usr/include/c++/13/bits/unique_ptr.h:603: Passing '' via 1st parameter '__p'

	: _M_t(__p)
        ^

/usr/include/c++/13/bits/unique_ptr.h:603: Calling constructor for '__uniq_ptr_impl<char, std::default_delete<char[]>>'

	: _M_t(__p)
   ^

/usr/include/c++/13/bits/unique_ptr.h:175: Calling '__uniq_ptr_impl::_M_ptr'

      __uniq_ptr_impl(pointer __p) : _M_t() { _M_ptr() = __p; }
                                              ^

/usr/include/c++/13/bits/unique_ptr.h:196: Calling 'get<0UL, char *, std::default_delete<char[]>>'

      pointer&   _M_ptr() noexcept { return std::get<0>(_M_t); }
                                            ^

/usr/include/c++/13/tuple:1803: Calling '__get_helper<0UL, char *, std::default_delete<char[]>>'

    { return std::__get_helper<__i>(__t); }
             ^

/usr/include/c++/13/tuple:1787: Calling '_Tuple_impl::_M_head'

    { return _Tuple_impl<__i, _Head, _Tail...>::_M_head(__t); }
             ^

/usr/include/c++/13/tuple:268: Calling '_Head_base::_M_head'

      _M_head(_Tuple_impl& __t) noexcept { return _Base::_M_head(__t); }
                                                  ^

/usr/include/c++/13/tuple:268: Returning from '_Head_base::_M_head'

      _M_head(_Tuple_impl& __t) noexcept { return _Base::_M_head(__t); }
                                                  ^

/usr/include/c++/13/tuple:1787: Returning from '_Tuple_impl::_M_head'

    { return _Tuple_impl<__i, _Head, _Tail...>::_M_head(__t); }
             ^

/usr/include/c++/13/tuple:1803: Returning from '__get_helper<0UL, char *, std::default_delete<char[]>>'

    { return std::__get_helper<__i>(__t); }
             ^

/usr/include/c++/13/bits/unique_ptr.h:196: Returning from 'get<0UL, char *, std::default_delete<char[]>>'

      pointer&   _M_ptr() noexcept { return std::get<0>(_M_t); }
                                            ^

/usr/include/c++/13/bits/unique_ptr.h:175: Returning from '__uniq_ptr_impl::_M_ptr'

      __uniq_ptr_impl(pointer __p) : _M_t() { _M_ptr() = __p; }
                                              ^

/usr/include/c++/13/bits/unique_ptr.h:175: The value of '__p' is assigned to 'content._M_t._M_t._M_head_impl'

      __uniq_ptr_impl(pointer __p) : _M_t() { _M_ptr() = __p; }
                                              ^

/usr/include/c++/13/bits/unique_ptr.h:603: Returning from constructor for '__uniq_ptr_impl<char, std::default_delete<char[]>>'

	: _M_t(__p)
   ^

/usr/include/c++/13/bits/unique_ptr.h:603: Returning from constructor for '__uniq_ptr_data<char, std::default_delete<char[]>, true, true>'

	: _M_t(__p)
   ^

lib/CppInterOp/CppInterOp.cpp:4368: Returning from constructor for 'unique_ptr<char[], std::default_delete<char[]>>'

    std::unique_ptr<char[]> content(new char[bufsize + 1]);
                            ^

lib/CppInterOp/CppInterOp.cpp:4371: Taking false branch

    if (fseek(m_TempFile, 0L, SEEK_SET) != 0)
    ^

lib/CppInterOp/CppInterOp.cpp:4375: The 1st argument to 'fread' is a buffer with size 0 but should be a buffer with size equal to or greater than the value of the 2nd argument (which is 1) times the 3rd argument (which is 18446744073709551615)

    size_t newLen = fread(content.get(), sizeof(char), bufsize, m_TempFile);
                    ^

struct FileDeleter {
void operator()(FILE* f /* owns */) {
if (f)
fclose(f);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: calling legacy resource function without passing a 'gsl::owner<>' [cppcoreguidelines-owning-memory]

        fclose(f);
        ^

"with in-process JIT execution.\n";
io_ctx->outOfProcess = false;
} else {
stdin_fd = fileno(io_ctx->stdin_file.get());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: no header providing "fileno" is directly included [misc-include-cleaner]

lib/CppInterOp/CppInterOpInterpreter.h:25:

- #if CLANG_VERSION_MAJOR >= 19
+ #include <stdio.h>
+ #if CLANG_VERSION_MAJOR >= 19


return std::unique_ptr<Interpreter>(new Interpreter(std::move(CI)));
return std::unique_ptr<Interpreter>(
new Interpreter(std::move(CI), std::move(io_ctx)));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: use std::make_unique instead [modernize-make-unique]

Suggested change
new Interpreter(std::move(CI), std::move(io_ctx)));
return std::make_unique<Interpreter>(
std::move(CI), std::move(io_ctx));

operator const clang::Interpreter&() const { return *inner; }
operator clang::Interpreter&() { return *inner; }

bool isOutOfProcess() const {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: function 'isOutOfProcess' should be marked [[nodiscard]] [modernize-use-nodiscard]

Suggested change
bool isOutOfProcess() const {
[[nodiscard]] bool isOutOfProcess() const {

return llvm::orc::ExecutorAddr(*AddrOrErr);
}

pid_t getOutOfProcessExecutorPID() const {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: function 'getOutOfProcessExecutorPID' should be marked [[nodiscard]] [modernize-use-nodiscard]

Suggested change
pid_t getOutOfProcessExecutorPID() const {
[[nodiscard]] pid_t getOutOfProcessExecutorPID() const {

return llvm::orc::ExecutorAddr(*AddrOrErr);
}

pid_t getOutOfProcessExecutorPID() const {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: method 'getOutOfProcessExecutorPID' can be made static [readability-convert-member-functions-to-static]

Suggested change
pid_t getOutOfProcessExecutorPID() const {
static pid_t getOutOfProcessExecutorPID() {

Copy link
Contributor

@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

return llvm::orc::ExecutorAddr(*AddrOrErr);
}

pid_t getOutOfProcessExecutorPID() const {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: no header providing "pid_t" is directly included [misc-include-cleaner]

lib/CppInterOp/CppInterOpInterpreter.h:25:

- #if CLANG_VERSION_MAJOR >= 19
+ #include <sched.h>
+ #if CLANG_VERSION_MAJOR >= 19

if (llvm::sys::RunningOnValgrind())
GTEST_SKIP() << "XFAIL due to Valgrind report";
TestUtils::CreateInterpreter();
pid_t pid = Cpp::GetExecutorPID();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: no header providing "pid_t" is directly included [misc-include-cleaner]

unittests/CppInterOp/FunctionReflectionTest.cpp:15:

- #include <string>
+ #include <sched.h>
+ #include <string>

testing::internal::CaptureStderr();
Cpp::Process("int c = 12;");
cerrs = testing::internal::GetCapturedStderr();
std::cout << cerrs << std::endl;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: do not use 'std::endl' with streams; use '\n' instead [performance-avoid-endl]

Suggested change
std::cout << cerrs << std::endl;
std::cout << cerrs << '\n';

testing::internal::CaptureStderr();
Cpp::Process("int c = 12;");
cerrs = testing::internal::GetCapturedStderr();
std::cout << cerrs << std::endl;
Copy link
Contributor

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::cout" is directly included [misc-include-cleaner]

unittests/CppInterOp/InterpreterTest.cpp:2:

+ #include <iostream>

testing::internal::CaptureStderr();
Cpp::Process("int c = 12;");
cerrs = testing::internal::GetCapturedStderr();
std::cout << cerrs << std::endl;
Copy link
Contributor

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::endl" is directly included [misc-include-cleaner]

unittests/CppInterOp/InterpreterTest.cpp:2:

+ #include <ostream>

}
}

TInterp_t
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: no header providing "TInterp_t" is directly included [misc-include-cleaner]

unittests/CppInterOp/Utils.cpp:13:

- #include <string>
+ #include <clang-c/CXCppInterOp.h>
+ #include <string>

Copy link
Contributor

@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

GTEST_SKIP() << "XFAIL due to Valgrind report";
std::vector<const char*> interpreter_args = { "-include", "new" };
auto* I = Cpp::CreateInterpreter(interpreter_args);
std::vector<const char*> interpreter_args = {"-include", "new"};
Copy link
Contributor

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]

unittests/CppInterOp/InterpreterTest.cpp:2:

+ #include <vector>

TEST(InterpreterTest, CreateInterpreterCAPI) {
const char* argv[] = {"-std=c++17"};
auto *CXI = clang_createInterpreter(argv, 1);
auto* CXI = clang_createInterpreter(argv, 1);
Copy link
Contributor

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

#endif
const char* argv[] = {"-fsyntax-only", "-Xclang", "-invalid-plugin"};
auto *CXI = clang_createInterpreter(argv, 3);
auto* CXI = clang_createInterpreter(argv, 3);
Copy link
Contributor

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

Cpp::GetIncludePaths(includes);
EXPECT_NE(std::find(includes.begin(), includes.end(), "/non/existent/"),
std::end(includes));
std::end(includes));
Copy link
Contributor

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::end" is directly included [misc-include-cleaner]

unittests/CppInterOp/InterpreterTest.cpp:2:

+ #include <iterator>

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