Skip to content

Conversation

@kazutakahirata
Copy link
Contributor

With DenseMap::keys, we don't need to use [[maybe_unused]].

With DenseMap::keys, we don't need to use [[maybe_unused]].
@llvmbot llvmbot added clang Clang issues not falling into any other category clang:dataflow Clang Dataflow Analysis framework - https://clang.llvm.org/docs/DataFlowAnalysisIntro.html clang:analysis labels Nov 13, 2025
@llvmbot
Copy link
Member

llvmbot commented Nov 13, 2025

@llvm/pr-subscribers-clang

@llvm/pr-subscribers-clang-analysis

Author: Kazu Hirata (kazutakahirata)

Changes

With DenseMap::keys, we don't need to use [[maybe_unused]].


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

2 Files Affected:

  • (modified) clang/include/clang/Analysis/FlowSensitive/StorageLocation.h (+1-1)
  • (modified) clang/lib/Analysis/FlowSensitive/ASTOps.cpp (+1-1)
diff --git a/clang/include/clang/Analysis/FlowSensitive/StorageLocation.h b/clang/include/clang/Analysis/FlowSensitive/StorageLocation.h
index 5d9a0f702a299..8948428accb97 100644
--- a/clang/include/clang/Analysis/FlowSensitive/StorageLocation.h
+++ b/clang/include/clang/Analysis/FlowSensitive/StorageLocation.h
@@ -131,7 +131,7 @@ class RecordStorageLocation final : public StorageLocation {
                      << " on StorageLocation " << this << " of type "
                      << getType() << "\n";
         llvm::dbgs() << "Existing children:\n";
-        for ([[maybe_unused]] auto [Field, Loc] : Children) {
+        for (const auto &Field : Children.keys()) {
           llvm::dbgs() << Field->getNameAsString() << "\n";
         }
       }
diff --git a/clang/lib/Analysis/FlowSensitive/ASTOps.cpp b/clang/lib/Analysis/FlowSensitive/ASTOps.cpp
index 431b1f2038357..7ce6b03fc0e71 100644
--- a/clang/lib/Analysis/FlowSensitive/ASTOps.cpp
+++ b/clang/lib/Analysis/FlowSensitive/ASTOps.cpp
@@ -81,7 +81,7 @@ bool containsSameFields(const FieldSet &Fields,
                         const RecordStorageLocation::FieldToLoc &FieldLocs) {
   if (Fields.size() != FieldLocs.size())
     return false;
-  for ([[maybe_unused]] auto [Field, Loc] : FieldLocs)
+  for (const auto &Field : FieldLocs.keys())
     if (!Fields.contains(cast_or_null<FieldDecl>(Field)))
       return false;
   return true;

@kazutakahirata kazutakahirata merged commit 3c85d04 into llvm:main Nov 13, 2025
14 checks passed
@kazutakahirata kazutakahirata deleted the cleanup_20251112_ADT_DenseMap_keys branch November 13, 2025 15:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clang:analysis clang:dataflow Clang Dataflow Analysis framework - https://clang.llvm.org/docs/DataFlowAnalysisIntro.html clang Clang issues not falling into any other category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants