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

Address issue of suppressing diagnostic #162

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Smit1603
Copy link
Contributor

@Smit1603 Smit1603 commented Nov 5, 2023

Issue : #96
coauthor : @Krishna-13-cyber
cc: @sudo-panda @vgvassilev

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

clangSilent(clang::DiagnosticsEngine& diag) : fDiagEngine(diag) {
auto& I = getInterp();
DiagnosticsEngine& parentDiagnostics = I.getSema().getDiagnostics();
clang::IgnoringDiagConsumer* ignoringDiagConsumer =
Copy link

Choose a reason for hiding this comment

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

warning: initializing non-owner 'clang::IgnoringDiagConsumer *' with a newly created 'gsl::owner<>' [cppcoreguidelines-owning-memory]

      clang::IgnoringDiagConsumer* ignoringDiagConsumer =
      ^

clangSilent(clang::DiagnosticsEngine& diag) : fDiagEngine(diag) {
auto& I = getInterp();
DiagnosticsEngine& parentDiagnostics = I.getSema().getDiagnostics();
clang::IgnoringDiagConsumer* ignoringDiagConsumer =
Copy link

Choose a reason for hiding this comment

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

warning: use auto when initializing with new to avoid duplicating the type name [modernize-use-auto]

Suggested change
clang::IgnoringDiagConsumer* ignoringDiagConsumer =
auto* ignoringDiagConsumer =

~clangSilent() {
auto& I = getInterp();
DiagnosticsEngine& parentDiagnostics = I.getSema().getDiagnostics();
clang::IgnoringDiagConsumer* ignoringDiagConsumer =
Copy link

Choose a reason for hiding this comment

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

warning: initializing non-owner 'clang::IgnoringDiagConsumer *' with a newly created 'gsl::owner<>' [cppcoreguidelines-owning-memory]

      clang::IgnoringDiagConsumer* ignoringDiagConsumer =
      ^

~clangSilent() {
auto& I = getInterp();
DiagnosticsEngine& parentDiagnostics = I.getSema().getDiagnostics();
clang::IgnoringDiagConsumer* ignoringDiagConsumer =
Copy link

Choose a reason for hiding this comment

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

warning: use auto when initializing with new to avoid duplicating the type name [modernize-use-auto]

Suggested change
clang::IgnoringDiagConsumer* ignoringDiagConsumer =
auto* ignoringDiagConsumer =

Copy link

codecov bot commented Nov 5, 2023

Codecov Report

Merging #162 (e07aa45) into main (654359e) will increase coverage by 0.35%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #162      +/-   ##
==========================================
+ Coverage   72.75%   73.10%   +0.35%     
==========================================
  Files           8        8              
  Lines        2885     2893       +8     
==========================================
+ Hits         2099     2115      +16     
+ Misses        786      778       -8     
Files Coverage Δ
lib/Interpreter/CppInterOp.cpp 80.58% <100.00%> (+0.53%) ⬆️

... and 1 file with indirect coverage changes

Files Coverage Δ
lib/Interpreter/CppInterOp.cpp 80.58% <100.00%> (+0.53%) ⬆️

... and 1 file with indirect coverage changes

Copy link
Contributor

@vgvassilev vgvassilev left a comment

Choose a reason for hiding this comment

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

Please address the clang-tidy reports.


TEST(InterpreterTest, Declare) {
EXPECT_EQ(Cpp::Declare("int i;", true), 0);
EXPECT_EQ(Cpp::Declare("int i;", true), 1);
Copy link
Contributor

Choose a reason for hiding this comment

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

Here we should check the output streams if a diagnostic was provided or not.

Copy link
Contributor

Choose a reason for hiding this comment

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

There is no diagnostic provided when we try to use the above case, However there is a slight observation for the below scenario:

[cling]$ InterOp::Declare("integer i;", true)
(unsigned long) 1

For the current upstream,
When we take this test case with the backend as cling, we get 1 as the output.
But on a similar basis when we use clang-repl as our backend for this test case, the expected output comes as 0 which is contrary to the former case.

When I use this patch where IgnoreDiagConsumer() is being used to swap the current diagnostics of CI with ignoring diagnostics from the diagnostic engine. But this deviates from the current output.

@Smit1603 can you please implement the latest changes we discussed.

Comment on lines +85 to +88
EXPECT_EQ(Cpp::Declare("int i;", true), 0);
EXPECT_EQ(Cpp::Declare("int i;", true), 1);
EXPECT_EQ(Cpp::Declare("integer i;", true), 1);
EXPECT_EQ(Cpp::Declare("int i1;", true), 0);
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
EXPECT_EQ(Cpp::Declare("int i;", true), 0);
EXPECT_EQ(Cpp::Declare("int i;", true), 1);
EXPECT_EQ(Cpp::Declare("integer i;", true), 1);
EXPECT_EQ(Cpp::Declare("int i1;", true), 0);
EXPECT_EQ(Cpp::Declare("int i;", /*silent=*/true), 0);
EXPECT_EQ(Cpp::Declare("int i;", /*silent=*/true), 1);
EXPECT_EQ(Cpp::Declare("integer i;", /*silent=*/true), 1);
EXPECT_EQ(Cpp::Declare("int i1;", /*silent=*/true), 0);

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.

None yet

3 participants