Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[clang-tools-extra] Remove redundant calls to std::unique_ptr<T>::get (NFC) #138774

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

Conversation

kazutakahirata
Copy link
Contributor

No description provided.

@llvmbot
Copy link
Member

llvmbot commented May 6, 2025

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

@llvm/pr-subscribers-clangd

Author: Kazu Hirata (kazutakahirata)

Changes

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

2 Files Affected:

  • (modified) clang-tools-extra/clang-change-namespace/ChangeNamespace.cpp (+3-4)
  • (modified) clang-tools-extra/clangd/unittests/PrerequisiteModulesTest.cpp (+2-2)
diff --git a/clang-tools-extra/clang-change-namespace/ChangeNamespace.cpp b/clang-tools-extra/clang-change-namespace/ChangeNamespace.cpp
index 850df7daf5c03..3e367ab1a5558 100644
--- a/clang-tools-extra/clang-change-namespace/ChangeNamespace.cpp
+++ b/clang-tools-extra/clang-change-namespace/ChangeNamespace.cpp
@@ -113,7 +113,7 @@ static SourceLocation getStartOfNextLine(SourceLocation Loc,
                                          const SourceManager &SM,
                                          const LangOptions &LangOpts) {
   std::unique_ptr<Lexer> Lex = getLexerStartingFromLoc(Loc, SM, LangOpts);
-  if (!Lex.get())
+  if (!Lex)
     return SourceLocation();
   llvm::SmallVector<char, 16> Line;
   // FIXME: this is a bit hacky to get ReadToEndOfLine work.
@@ -647,9 +647,8 @@ static SourceLocation getLocAfterNamespaceLBrace(const NamespaceDecl *NsDecl,
                                                  const LangOptions &LangOpts) {
   std::unique_ptr<Lexer> Lex =
       getLexerStartingFromLoc(NsDecl->getBeginLoc(), SM, LangOpts);
-  assert(Lex.get() &&
-         "Failed to create lexer from the beginning of namespace.");
-  if (!Lex.get())
+  assert(Lex && "Failed to create lexer from the beginning of namespace.");
+  if (!Lex)
     return SourceLocation();
   Token Tok;
   while (!Lex->LexFromRawLexer(Tok) && Tok.isNot(tok::TokenKind::l_brace)) {
diff --git a/clang-tools-extra/clangd/unittests/PrerequisiteModulesTest.cpp b/clang-tools-extra/clangd/unittests/PrerequisiteModulesTest.cpp
index 27f4c817a8ff3..03e65768c26a6 100644
--- a/clang-tools-extra/clangd/unittests/PrerequisiteModulesTest.cpp
+++ b/clang-tools-extra/clangd/unittests/PrerequisiteModulesTest.cpp
@@ -545,8 +545,8 @@ void func() {
   EXPECT_TRUE(Preamble);
   EXPECT_TRUE(Preamble->RequiredModules);
 
-  auto Result = signatureHelp(getFullPath("Use.cpp"), Test.point(),
-                              *Preamble.get(), Use, MarkupKind::PlainText);
+  auto Result = signatureHelp(getFullPath("Use.cpp"), Test.point(), *Preamble,
+                              Use, MarkupKind::PlainText);
   EXPECT_FALSE(Result.signatures.empty());
   EXPECT_EQ(Result.signatures[0].label, "printA(int a) -> void");
   EXPECT_EQ(Result.signatures[0].parameters[0].labelString, "int a");

@kazutakahirata kazutakahirata merged commit 5d305b6 into llvm:main May 7, 2025
12 of 13 checks passed
@kazutakahirata kazutakahirata deleted the cleanup_clang_tidy_readability_redundant_smartptr_get_clang_tools branch May 7, 2025 03:16
GeorgeARM pushed a commit to GeorgeARM/llvm-project that referenced this pull request May 7, 2025
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.

3 participants