[clang] c2647ed - fix unused variables in condition warning

Mikhail Goncharov via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 30 08:40:02 PDT 2023


Author: Mikhail Goncharov
Date: 2023-08-30T17:39:54+02:00
New Revision: c2647ed9b9cd5a0baddb2edf242c9b1f8976d7b6

URL: https://github.com/llvm/llvm-project/commit/c2647ed9b9cd5a0baddb2edf242c9b1f8976d7b6
DIFF: https://github.com/llvm/llvm-project/commit/c2647ed9b9cd5a0baddb2edf242c9b1f8976d7b6.diff

LOG: fix unused variables in condition warning

for 92023b15099012a657da07ebf49dd7d94a260f84

Added: 
    

Modified: 
    clang/include/clang/AST/DeclTemplate.h
    clang/lib/AST/Interp/ByteCodeExprGen.cpp

Removed: 
    


################################################################################
diff  --git a/clang/include/clang/AST/DeclTemplate.h b/clang/include/clang/AST/DeclTemplate.h
index 7cd505218f2b90..f2e86da1c745a0 100644
--- a/clang/include/clang/AST/DeclTemplate.h
+++ b/clang/include/clang/AST/DeclTemplate.h
@@ -377,7 +377,8 @@ class DefaultArgStorage {
     InheritedFrom = getParmOwningDefaultArg(InheritedFrom);
     if (!isSet())
       ValueOrInherited = InheritedFrom;
-    else if (auto *D = ValueOrInherited.template dyn_cast<ParmDecl *>()) {
+    else if ([[maybe_unused]] auto *D =
+                 ValueOrInherited.template dyn_cast<ParmDecl *>()) {
       assert(C.isSameDefaultTemplateArgument(D, InheritedFrom));
       ValueOrInherited =
           new (allocateDefaultArgStorageChain(C)) Chain{InheritedFrom, get()};

diff  --git a/clang/lib/AST/Interp/ByteCodeExprGen.cpp b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
index d8a4ca0db12fc8..a865faeedae6f4 100644
--- a/clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -1670,7 +1670,7 @@ template <class Emitter>
 std::optional<unsigned>
 ByteCodeExprGen<Emitter>::allocateLocal(DeclTy &&Src, bool IsExtended) {
   // Make sure we don't accidentally register the same decl twice.
-  if (const auto *VD =
+  if ([[maybe_unused]]  const auto *VD =
           dyn_cast_if_present<ValueDecl>(Src.dyn_cast<const Decl *>())) {
     assert(!P.getGlobal(VD));
     assert(!Locals.contains(VD));


        


More information about the cfe-commits mailing list