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

clang-tidy: readability-redundant-smartptr-get does not remove -> (#97964) #98757

Closed
wants to merge 7 commits into from

Conversation

akshaykumars614
Copy link
Contributor

@akshaykumars614 akshaykumars614 commented Jul 13, 2024

added a check to remove '->' if exists

Fixes #97964

@llvmbot
Copy link
Collaborator

llvmbot commented Jul 13, 2024

@llvm/pr-subscribers-libc
@llvm/pr-subscribers-clang-tools-extra

@llvm/pr-subscribers-clang-tidy

Author: None (akshaykumars614)

Changes

added a check to remove '->' if exists


Full diff: https://github.com/llvm/llvm-project/pull/98757.diff

1 Files Affected:

  • (modified) clang-tools-extra/clang-tidy/readability/RedundantSmartptrGetCheck.cpp (+4)
diff --git a/clang-tools-extra/clang-tidy/readability/RedundantSmartptrGetCheck.cpp b/clang-tools-extra/clang-tidy/readability/RedundantSmartptrGetCheck.cpp
index 8837ac16e8828..be52af77ae0a5 100644
--- a/clang-tools-extra/clang-tidy/readability/RedundantSmartptrGetCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/RedundantSmartptrGetCheck.cpp
@@ -164,6 +164,10 @@ void RedundantSmartptrGetCheck::check(const MatchFinder::MatchResult &Result) {
   StringRef SmartptrText = Lexer::getSourceText(
       CharSourceRange::getTokenRange(Smartptr->getSourceRange()),
       *Result.SourceManager, getLangOpts());
+  // Check if the last two characters are "->" and remove them
+  if (SmartptrText.ends_with("->")) {
+    SmartptrText = SmartptrText.drop_back(2);
+  }
   // Replace foo->get() with *foo, and foo.get() with foo.
   std::string Replacement = Twine(IsPtrToPtr ? "*" : "", SmartptrText).str();
   diag(GetCall->getBeginLoc(), "redundant get() call on smart pointer")

@akshaykumars614
Copy link
Contributor Author

I am not sure if I need to write a test case for clang-tidy

@PiotrZSL
Copy link
Member

I am not sure if I need to write a test case for clang-tidy

Yes, and release notes entry,

@akshaykumars614
Copy link
Contributor Author

can you tell me where to add test case and release notes entry

@akshaykumars614
Copy link
Contributor Author

I am new here

@PiotrZSL
Copy link
Member

can you tell me where to add test case and release notes entry

Tests:
clang-tools-extra/test/clang-tidy/checkers/readability/redundant-smartptr-get.cpp

Release notes:
clang-tools-extra/docs/ReleaseNotes.rst

petrhosek and others added 4 commits July 15, 2024 13:00
This addresses the build error introduced in llvm#98287 where
src/errno/errno.h is included instead of the system errno.h.

We instead move the declaration to libc_errno.h.
The declaration must match the previous declaration in errno.h.
The definitions must match the previous declaration in errno.h.
Copy link
Member

@PiotrZSL PiotrZSL left a comment

Choose a reason for hiding this comment

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

Fix release notes, and remove not related changed to errno (i assume due to merge).
fell free to rebase branch if needed

clang-tools-extra/docs/ReleaseNotes.rst Show resolved Hide resolved
libc/src/errno/CMakeLists.txt Outdated Show resolved Hide resolved
@llvmbot llvmbot added the libc label Jul 17, 2024
@akshaykumars614 akshaykumars614 deleted the 97964 branch July 23, 2024 19:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

clang-tidy: readability-redundant-smartptr-get does not remove ->
6 participants