Skip to content
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

Add support for GetIncludePaths #178

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

Conversation

Krishna-13-cyber
Copy link
Contributor

This PR adds GetIncludePaths() to fetch the include paths

@Krishna-13-cyber Krishna-13-cyber changed the title Add GetIncludePaths() to fetch the include paths Add support for GetIncludePaths Jan 4, 2024
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 11. Check the log or trigger a new build to see more.

lib/Interpreter/CppInterOpInterpreter.h Outdated Show resolved Hide resolved
lib/Interpreter/CppInterOpInterpreter.h Outdated Show resolved Hide resolved
lib/Interpreter/Paths.cpp Outdated Show resolved Hide resolved
lib/Interpreter/Paths.cpp Outdated Show resolved Hide resolved
lib/Interpreter/Paths.cpp Outdated Show resolved Hide resolved
lib/Interpreter/Paths.cpp Outdated Show resolved Hide resolved
lib/Interpreter/Paths.cpp Outdated Show resolved Hide resolved
lib/Interpreter/Paths.cpp Show resolved Hide resolved
lib/Interpreter/Paths.cpp Show resolved Hide resolved
lib/Interpreter/Paths.cpp Outdated Show resolved Hide resolved
Copy link

codecov bot commented Jan 4, 2024

Codecov Report

Attention: Patch coverage is 43.47826% with 13 lines in your changes are missing coverage. Please review.

Project coverage is 77.18%. Comparing base (0e75241) to head (72adf22).
Report is 108 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #178      +/-   ##
==========================================
- Coverage   77.55%   77.18%   -0.37%     
==========================================
  Files           8        8              
  Lines        2887     3042     +155     
==========================================
+ Hits         2239     2348     +109     
- Misses        648      694      +46     
Files Coverage Δ
include/clang/Interpreter/CppInterOp.h 100.00% <ø> (ø)
lib/Interpreter/CppInterOp.cpp 85.31% <100.00%> (-0.14%) ⬇️
lib/Interpreter/CppInterOpInterpreter.h 91.16% <100.00%> (-1.62%) ⬇️
lib/Interpreter/Paths.cpp 31.61% <13.33%> (-2.65%) ⬇️

... and 4 files with indirect coverage changes

Files Coverage Δ
include/clang/Interpreter/CppInterOp.h 100.00% <ø> (ø)
lib/Interpreter/CppInterOp.cpp 85.31% <100.00%> (-0.14%) ⬇️
lib/Interpreter/CppInterOpInterpreter.h 91.16% <100.00%> (-1.62%) ⬇️
lib/Interpreter/Paths.cpp 31.61% <13.33%> (-2.65%) ⬇️

... and 4 files with indirect coverage changes

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

lib/Interpreter/CppInterOpInterpreter.h Outdated Show resolved Hide resolved
lib/Interpreter/Paths.cpp Outdated Show resolved Hide resolved
unittests/CppInterOp/InterpreterTest.cpp Outdated Show resolved Hide resolved
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

Paths.push_back(PathStr);

// Avoid duplicates
llvm::SmallVector<llvm::StringRef, val> PathsChecked;

Choose a reason for hiding this comment

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

warning: unused variable 'Path' [clang-diagnostic-unused-variable]

    for (llvm::StringRef Path : PathsChecked)
                         ^

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

lib/Interpreter/Paths.cpp Show resolved Hide resolved
@@ -444,6 +444,9 @@ namespace Cpp {
/// Returns the resource-dir path (for headers).
const char* GetResourceDir();

/// Get Include Paths
void GetIncludePath(const char* dir, std::vector<std::string>& includePaths);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
void GetIncludePath(const char* dir, std::vector<std::string>& includePaths);
void GetIncludePath(std::vector<std::string>& includePaths);

This function should only have a single output parameter.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh okay, I will make the required changes.

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

@@ -347,6 +347,10 @@ class Interpreter {
const_cast<const Interpreter*>(this)->getDynamicLibraryManager());
}

/// @brief As a interface to store paths added in AddIncludePaths
std::vector<std::string> include;
Copy link

Choose a reason for hiding this comment

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

warning: member variable 'include' has public visibility [cppcoreguidelines-non-private-member-variables-in-classes]

  std::vector<std::string> include;
                           ^

@@ -449,5 +448,32 @@
#undef DEBUG_TYPE
}

void GetIncludePaths(
Copy link

Choose a reason for hiding this comment

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

warning: an assignment within an 'if' condition is bug-prone [bugprone-assignment-in-if-condition]

      if ((Exists = E.Path == Path))
           ^
Additional context

lib/Interpreter/Paths.cpp:450: if it should be an assignment, move it out of the 'if' condition

      if ((Exists = E.Path == Path))
           ^

lib/Interpreter/Paths.cpp:450: if it is meant to be an equality check, change '=' to '=='

      if ((Exists = E.Path == Path))
           ^

else
Paths.push_back(PathStr);

// Avoid duplicates
Copy link

Choose a reason for hiding this comment

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

warning: unused variable 'Path' [clang-diagnostic-unused-variable]

    for (llvm::StringRef Path : PathsChecked)
                         ^

@Krishna-13-cyber
Copy link
Contributor Author

Hi @vgvassilev,
Pinging you for a review on this updated version, so that we can complete this.

@@ -347,6 +347,10 @@ class Interpreter {
const_cast<const Interpreter*>(this)->getDynamicLibraryManager());
}

/// @brief As a interface to store paths added in AddIncludePaths
std::vector<std::string> include;
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need this. The include paths are stored in the HeaderSearch already.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So we know that AddincludePaths() is fetching the paths and giving it to HeaderSearch, now GetIncludePaths() had the aim of exposing all the paths which were added(not present in HeaderSearch) to the user, for this we had to get/store all those paths which were being added to HeaderSearch with a vector ( as an interface) as AddIncludePaths() does'nt store any paths (makes it available for HeaderSearch).

Initially, I tried other methods to store all the paths from AddIncludePaths() itself but for that we require a change in function definition and would not require another function GetIncludePaths(). I also tried creating wrappers around AddIncludePaths() but to maintain the function signature I could'nt find a way to store the paths.

@aaronj0 aaronj0 added the API The CppInterOp API label May 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API The CppInterOp API
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants