[clang] [Clang][Modules] Fix -Wunused-variable (PR #196577)

2026-05-09 Thread Aiden Grossman via cfe-commits

https://github.com/boomanaiden154 closed 
https://github.com/llvm/llvm-project/pull/196577
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][Modules] Fix -Wunused-variable (PR #196577)

2026-05-09 Thread Aiden Grossman via cfe-commits

https://github.com/boomanaiden154 created 
https://github.com/llvm/llvm-project/pull/196577

Mark some variables [[maybe_unused]] and inline others that do not have
side effects to avoid -Wunused-variable in non-assert builds.

>From bcc884511c67b540a631f9c0e5a2d7b05e54cf31 Mon Sep 17 00:00:00 2001
From: Aiden Grossman 
Date: Fri, 8 May 2026 16:52:24 +
Subject: [PATCH] [Clang][Modules] Fix -Wunused-variable

Mark some variables [[maybe_unused]] and inline others that do not have
side effects to avoid -Wunused-variable in non-assert builds.
---
 clang/lib/Serialization/ASTReader.cpp | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/clang/lib/Serialization/ASTReader.cpp 
b/clang/lib/Serialization/ASTReader.cpp
index 6b242f553c59d..dfd714dd53814 100644
--- a/clang/lib/Serialization/ASTReader.cpp
+++ b/clang/lib/Serialization/ASTReader.cpp
@@ -6327,7 +6327,8 @@ Module *ASTReader::getSubmodule(uint32_t GlobalID) {
   assert(It != GlobalSubmoduleMap.end());
   ModuleFile &F = *It->second;
   unsigned Index = GlobalID - F.BaseSubmoduleID - NUM_PREDEF_SUBMODULE_IDS;
-  unsigned LocalID = Index + F.LocalBaseSubmoduleID + NUM_PREDEF_SUBMODULE_IDS;
+  [[maybe_unused]] unsigned LocalID =
+  Index + F.LocalBaseSubmoduleID + NUM_PREDEF_SUBMODULE_IDS;
 
   BitstreamCursor &Cursor = F.SubmodulesCursor;
   SavedStreamPosition SavedPosition(Cursor);
@@ -6397,10 +6398,9 @@ Module *ASTReader::getSubmodule(uint32_t GlobalID) {
 
   StringRef Name = Blob;
   unsigned Idx = 0;
-  unsigned ReadLocalID = Record[Idx++];
+  [[maybe_unused]] unsigned ReadLocalID = Record[Idx++];
   assert(LocalID == ReadLocalID);
-  SubmoduleID ReadGlobalID = getGlobalSubmoduleID(F, ReadLocalID);
-  assert(GlobalID == ReadGlobalID);
+  assert(GlobalID == getGlobalSubmoduleID(F, ReadLocalID));
   SubmoduleID Parent = getGlobalSubmoduleID(F, Record[Idx++]);
   Module::ModuleKind Kind = (Module::ModuleKind)Record[Idx++];
   SourceLocation DefinitionLoc = ReadSourceLocation(F, Record[Idx++]);

___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits