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

Make CodeStyleChecker to be used in a real compilation process. #34

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

Conversation

tylzh97
Copy link

@tylzh97 tylzh97 commented Jun 4, 2024

Adding the getActionType method to allow the clang plugin to automatically load plugins during the compilation process.

…cally load plugins during the compilation process.
@tylzh97 tylzh97 changed the title Main Make CodeStyleChecker to be used in a real compilation process. Jun 4, 2024
@banach-space
Copy link
Owner

Nice, I forgot about this! Could you add some more docs, in particular a reference to https://clang.llvm.org/docs/ClangPlugins.html#using-the-clang-command-line? Both in README and in the code?

Importantly, how can we test this?

@tylzh97
Copy link
Author

tylzh97 commented Jun 5, 2024

I have added some documents and passed all test cases of lit.

Copy link
Owner

@banach-space banach-space left a comment

Choose a reason for hiding this comment

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

Thank you so much for working on this and for sharing, this is brilliant!

Now, instead of modifying existing tests, could you add a new test? In particular, it would be good to add a test that does this:

$ rm file.o
$ ls file.o
ls: cannot access 'file.o': No such file or directory
$Clang_DIR/bin/clang -fplugin=libCodeStyleChecker.dylib -o file.o -c file.cpp
$ ls file.o
file.o

Here's an example how to use bash commands in a LIT test https://github.com/llvm/llvm-project/blob/e090bac638e56ff9db87e622cdf925f2b99dfc30/clang/test/Modules/check-for-sanitizer-feature.cpp#L1-L8

Thank you for working on this 🙏🏻

}
```

The **CodeStyleChecker** plugin could be automatically load and be used during the normal compilation
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
The **CodeStyleChecker** plugin could be automatically load and be used during the normal compilation
The **CodeStyleChecker** plugin could be automatically loaded and used during the normal compilation

Comment on lines +373 to +382
$Clang_DIR/bin/clang -fplugin=libCodeStyleChecker.dylib -o file.o -c file.cpp
file.cpp:2:7: warning: Type and variable names should start with upper-case letter
class clangTutor_BadName;
^~~~~~~~~~~~~~~~~~~
ClangTutor_BadName
file.cpp:2:17: warning: `_` in names is not allowed
class clangTutor_BadName;
~~~~~~~~~~^~~~~~~~~
clangTutorBadName
2 warnings generated.
Copy link
Owner

Choose a reason for hiding this comment

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

Add ls file.o (together without output) before and after invoking clang to demonstrate that the file was indeed created.

@@ -40,4 +40,9 @@ foreach( tool ${CLANG_TUTOR_TOOLS} )
${tool}
"clangTooling"
)

# ct action type should be CmdlineAfterMainAction
Copy link
Owner

Choose a reason for hiding this comment

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

What does ct stand for?

@banach-space
Copy link
Owner

Ping @tylzh97 :)

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.

2 participants