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

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
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 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 missing coverage. Please review.

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

Files with missing lines Patch % Lines
lib/Interpreter/Paths.cpp 13.33% 13 Missing ⚠️
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 with missing lines 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 with missing lines 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
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

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

Paths.push_back(PathStr);

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

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

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

@@ -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.

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
Contributor

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
Contributor

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
Copy link
Contributor

github-actions bot commented Dec 6, 2024

This PR is stale because it has been open for 90 days with no activity.

@github-actions github-actions bot added the stale label Dec 6, 2024
@Vipul-Cariappa
Copy link
Collaborator

Closed through #311.
Feel free to reopen if I have missed something.

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

Successfully merging this pull request may close these issues.

4 participants