Skip to content

[clang][NFC] Spell out DynTypedNode instead of auto #114427

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

Merged
merged 1 commit into from
Nov 6, 2024

Conversation

ccotter
Copy link
Contributor

@ccotter ccotter commented Oct 31, 2024

No description provided.

@llvmbot llvmbot added clang Clang issues not falling into any other category clang:static analyzer labels Oct 31, 2024
@llvmbot
Copy link
Member

llvmbot commented Oct 31, 2024

@llvm/pr-subscribers-clang

@llvm/pr-subscribers-clang-static-analyzer-1

Author: Chris Cotter (ccotter)

Changes

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

2 Files Affected:

  • (modified) clang/include/clang/ASTMatchers/ASTMatchers.h (+1-1)
  • (modified) clang/lib/StaticAnalyzer/Checkers/OSObjectCStyleCast.cpp (+1-1)
diff --git a/clang/include/clang/ASTMatchers/ASTMatchers.h b/clang/include/clang/ASTMatchers/ASTMatchers.h
index 54e484d41fb1c3..b086cb1e86212a 100644
--- a/clang/include/clang/ASTMatchers/ASTMatchers.h
+++ b/clang/include/clang/ASTMatchers/ASTMatchers.h
@@ -3226,7 +3226,7 @@ AST_MATCHER_P(CXXDependentScopeMemberExpr, memberHasSameNameAsBoundNode,
 
   return Builder->removeBindings(
       [this, MemberName](const BoundNodesMap &Nodes) {
-        const auto &BN = Nodes.getNode(this->BindingID);
+        const DynTypedNode &BN = Nodes.getNode(this->BindingID);
         if (const auto *ND = BN.get<NamedDecl>()) {
           if (!isa<FieldDecl, CXXMethodDecl, VarDecl>(ND))
             return true;
diff --git a/clang/lib/StaticAnalyzer/Checkers/OSObjectCStyleCast.cpp b/clang/lib/StaticAnalyzer/Checkers/OSObjectCStyleCast.cpp
index 6bc2ce6686ed64..46690dd886b2be 100644
--- a/clang/lib/StaticAnalyzer/Checkers/OSObjectCStyleCast.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/OSObjectCStyleCast.cpp
@@ -38,7 +38,7 @@ namespace clang {
 namespace ast_matchers {
 AST_MATCHER_P(StringLiteral, mentionsBoundType, std::string, BindingID) {
   return Builder->removeBindings([this, &Node](const BoundNodesMap &Nodes) {
-    const auto &BN = Nodes.getNode(this->BindingID);
+    const DynTypedNode &BN = Nodes.getNode(this->BindingID);
     if (const auto *ND = BN.get<NamedDecl>()) {
       return ND->getName() != Node.getString();
     }

@steakhal
Copy link
Contributor

steakhal commented Nov 2, 2024

Have you other similar cases in the Static Analyzer code base?

@ccotter
Copy link
Contributor Author

ccotter commented Nov 2, 2024

While working on #114244, I noticed the use of auto in memberHasSameNameAsBoundNode. The only other place I could find using auto with Nodes.getNode was in the second file I changed.

Copy link
Contributor

@steakhal steakhal left a comment

Choose a reason for hiding this comment

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

I don't really feel that this is relevant enough to be merged, but let's do it anyways.
If you find more things to refactor, or have plans for doing so, let me know.

@steakhal steakhal merged commit 2bbb6c0 into llvm:main Nov 6, 2024
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:static analyzer clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants