llvmorg-github-actions[bot] wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clangir

Author: Kazu Hirata (kazutakahirata)

<details>
<summary>Changes</summary>

This patch removes unused local variables of container, string, and
value types across clang/.

Note that these variables did not trigger -Wunused-variable because
their types have non-trivial constructors or destructors, and their
initializers have no side effects.

Assisted-by: Antigravity


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


17 Files Affected:

- (modified) clang/lib/AST/DeclarationName.cpp (-2) 
- (modified) clang/lib/AST/ExprConstant.cpp (-2) 
- (modified) clang/lib/AST/TypeLoc.cpp (-1) 
- (modified) clang/lib/Analysis/BodyFarm.cpp (-6) 
- (modified) clang/lib/CIR/Dialect/Transforms/HoistAllocas.cpp (-1) 
- (modified) clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp (-1) 
- (modified) clang/lib/CodeGen/CGCall.cpp (-1) 
- (modified) clang/lib/CodeGen/CodeGenFunction.cpp (-1) 
- (modified) clang/lib/DependencyScanning/ModuleDepCollector.cpp (-1) 
- (modified) clang/lib/Sema/SemaDeclCXX.cpp (-3) 
- (modified) clang/lib/Sema/SemaInit.cpp (-1) 
- (modified) clang/lib/Sema/SemaOpenMP.cpp (-1) 
- (modified) clang/lib/Sema/TreeTransform.h (-1) 
- (modified) clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp (-4) 
- (modified) clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp (-2) 
- (modified) clang/tools/cir-translate/cir-translate.cpp (-1) 
- (modified) clang/utils/TableGen/ClangOptionDocEmitter.cpp (-2) 


``````````diff
diff --git a/clang/lib/AST/DeclarationName.cpp 
b/clang/lib/AST/DeclarationName.cpp
index 105d2935d0c639..13aa0affb3e962 100644
--- a/clang/lib/AST/DeclarationName.cpp
+++ b/clang/lib/AST/DeclarationName.cpp
@@ -456,7 +456,6 @@ std::string DeclarationNameInfo::getAsString() const {
 }
 
 raw_ostream &clang::operator<<(raw_ostream &OS, DeclarationNameInfo DNInfo) {
-  LangOptions LO;
   DNInfo.printName(OS, PrintingPolicy(LangOptions()));
   return OS;
 }
@@ -482,7 +481,6 @@ void DeclarationNameInfo::printName(raw_ostream &OS, 
PrintingPolicy Policy) cons
         OS << '~';
       else if (Name.getNameKind() == 
DeclarationName::CXXConversionFunctionName)
         OS << "operator ";
-      LangOptions LO;
       Policy.adjustForCPlusPlus();
       Policy.SuppressScope = true;
       OS << TInfo->getType().getAsString(Policy);
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index f1da1dca7b87b1..57d5bb475d0f9b 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -2829,7 +2829,6 @@ static bool HandleFloatToFloatCast(EvalInfo &Info, const 
Expr *E,
          "the new expression or address the root cause of this usage.");
   llvm::RoundingMode RM = getActiveRoundingMode(Info, E);
   APFloat::opStatus St;
-  APFloat Value = Result;
   bool ignored;
   St = Result.convert(Info.Ctx.getFloatTypeSemantics(DestType), RM, &ignored);
   return checkFloatingPointResultForConstantFolding(Info, E, St);
@@ -7321,7 +7320,6 @@ static bool HandleFunctionCall(SourceLocation CallLoc,
                            MD->getParent()->isUnion()))
       return false;
 
-    LValue Obj;
     if (!handleAssignment(Info, Args[ExplicitOffset], *ObjectArg,
                           MD->getFunctionObjectParameterReferenceType(),
                           RHSValue))
diff --git a/clang/lib/AST/TypeLoc.cpp b/clang/lib/AST/TypeLoc.cpp
index ae09489e283248..4e6a680e93b4f4 100644
--- a/clang/lib/AST/TypeLoc.cpp
+++ b/clang/lib/AST/TypeLoc.cpp
@@ -712,7 +712,6 @@ void 
TemplateSpecializationTypeLoc::initializeLocal(ASTContext &Context,
     QualifierLoc = Builder.getWithLocInContext(Context);
   }
 
-  TemplateArgumentListInfo TAL(Loc, Loc);
   set(ElaboratedKeywordLoc, QualifierLoc,
       /*TemplateKeywordLoc=*/HasTemplateKeyword ? Loc : SourceLocation(),
       /*NameLoc=*/Loc, /*LAngleLoc=*/Loc, /*RAngleLoc=*/Loc);
diff --git a/clang/lib/Analysis/BodyFarm.cpp b/clang/lib/Analysis/BodyFarm.cpp
index 17217b83c7c36d..a5a9dbbf6d5b05 100644
--- a/clang/lib/Analysis/BodyFarm.cpp
+++ b/clang/lib/Analysis/BodyFarm.cpp
@@ -13,7 +13,6 @@
 
 #include "clang/Analysis/BodyFarm.h"
 #include "clang/AST/ASTContext.h"
-#include "clang/AST/CXXInheritance.h"
 #include "clang/AST/Decl.h"
 #include "clang/AST/Expr.h"
 #include "clang/AST/ExprCXX.h"
@@ -236,11 +235,6 @@ MemberExpr *ASTMaker::makeMemberExpression(Expr *base, 
ValueDecl *MemberDecl,
 }
 
 ValueDecl *ASTMaker::findMemberField(const RecordDecl *RD, StringRef Name) {
-
-  CXXBasePaths Paths(
-      /* FindAmbiguities=*/false,
-      /* RecordPaths=*/false,
-      /* DetectVirtual=*/ false);
   const IdentifierInfo &II = C.Idents.get(Name);
   DeclarationName DeclName = C.DeclarationNames.getIdentifier(&II);
 
diff --git a/clang/lib/CIR/Dialect/Transforms/HoistAllocas.cpp 
b/clang/lib/CIR/Dialect/Transforms/HoistAllocas.cpp
index 741ee78c7fdad1..9f991422ba5ccb 100644
--- a/clang/lib/CIR/Dialect/Transforms/HoistAllocas.cpp
+++ b/clang/lib/CIR/Dialect/Transforms/HoistAllocas.cpp
@@ -108,7 +108,6 @@ static void process(mlir::ModuleOp mod, cir::FuncOp func) {
 
 void HoistAllocasPass::runOnOperation() {
   llvm::TimeTraceScope scope("Hoist Allocas");
-  llvm::SmallVector<Operation *, 16> ops;
 
   Operation *op = getOperation();
   auto mod = mlir::dyn_cast<mlir::ModuleOp>(op);
diff --git a/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp 
b/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp
index 39ecb6fa7c746c..9d74696bde0d39 100644
--- a/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp
+++ b/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp
@@ -1306,7 +1306,6 @@ class GlobalInitAttrRewriter {
     if (auto intTy = mlir::dyn_cast<cir::IntType>(attr.getType());
         intTy && intTy.isBitInt())
       return getBitIntStorageAttr(rewriter, attr, dataLayout);
-    llvm::APInt val = attr.getValue();
 
     return rewriter.getIntegerAttr(llvmType, attr.getValue());
   }
diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index 0b63ea4a97b365..5f0a7d45cc0666 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -1097,7 +1097,6 @@ const CGFunctionInfo 
&CodeGenTypes::arrangeLLVMFunctionInfo(
                       [](CanQualType T) { return T.isCanonicalAsParam(); }));
 
   // Lookup or create unique function info.
-  llvm::FoldingSetNodeID ID;
   bool isInstanceMethod =
       (opts & FnInfoOpts::IsInstanceMethod) == FnInfoOpts::IsInstanceMethod;
   bool isChainCall =
diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp 
b/clang/lib/CodeGen/CodeGenFunction.cpp
index b6081479fd7bce..8fa84788f054b2 100644
--- a/clang/lib/CodeGen/CodeGenFunction.cpp
+++ b/clang/lib/CodeGen/CodeGenFunction.cpp
@@ -3046,7 +3046,6 @@ void CodeGenFunction::EmitPPCAIXMultiVersionResolver(
   // entry:
   llvm::BasicBlock *CurBlock = createBasicBlock("entry", Resolver);
 
-  SmallVector<std::pair<llvm::Value *, llvm::BasicBlock *>, 3> PhiArgs;
   for (const FMVResolverOption &RO : Options) {
     Builder.SetInsertPoint(CurBlock);
     // The 'default' or 'generic' case.
diff --git a/clang/lib/DependencyScanning/ModuleDepCollector.cpp 
b/clang/lib/DependencyScanning/ModuleDepCollector.cpp
index ed660fc0707acf..f95e83a95b7b30 100644
--- a/clang/lib/DependencyScanning/ModuleDepCollector.cpp
+++ b/clang/lib/DependencyScanning/ModuleDepCollector.cpp
@@ -881,7 +881,6 @@ void 
ModuleDepCollector::addAllModuleDeps(serialization::ModuleFile &MF,
                                           ModuleDeps &MD) {
   auto &MDC = *this;
 
-  llvm::DenseSet<const Module *> Seen;
   for (serialization::ModuleFile *Import : MF.Imports) {
     if (MDC.isPrebuiltModule(Import)) {
       MD.PrebuiltModuleDeps.push_back(createPrebuiltModuleDep(Import));
diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index f2a8bd452a6ea9..9cf100221704f0 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -15575,7 +15575,6 @@ void Sema::DefineImplicitCopyAssignment(SourceLocation 
CurrentLocation,
     }
 
     // Build references to the field in the object we're copying from and to.
-    CXXScopeSpec SS; // Intentionally empty
     LookupResult MemberLookup(*this, Field->getDeclName(), Loc,
                               LookupMemberName);
     MemberLookup.addDecl(Field);
@@ -17973,8 +17972,6 @@ static bool EvaluateAsStringImpl(Sema &SemaRef, Expr 
*Message,
     DeclarationName DN = SemaRef.PP.getIdentifierInfo(Member);
     LookupResult MemberLookup(SemaRef, DN, Loc, Sema::LookupMemberName);
     SemaRef.LookupQualifiedName(MemberLookup, RD);
-    OverloadCandidateSet Candidates(MemberLookup.getNameLoc(),
-                                    OverloadCandidateSet::CSK_Normal);
     if (MemberLookup.empty())
       return std::nullopt;
     return std::move(MemberLookup);
diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp
index fa4ef1ce57f172..d9134c052fa9df 100644
--- a/clang/lib/Sema/SemaInit.cpp
+++ b/clang/lib/Sema/SemaInit.cpp
@@ -3140,7 +3140,6 @@ InitListChecker::CheckDesignatedInitializer(const 
InitializedEntity &Entity,
                          return A.Pos < B.Pos;
                        });
 
-            llvm::SmallString<128> FixedInitList{};
             SourceManager &SM = SemaRef.getSourceManager();
             const LangOptions &LangOpts = SemaRef.getLangOpts();
 
diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index 5fba2895938703..8381082f29cc7f 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -2613,7 +2613,6 @@ VarDecl *SemaOpenMP::isOpenMPCapturedDecl(ValueDecl *D, 
bool CheckScopeInfo,
       Expr *ThisExpr = SemaRef.BuildCXXThisExpr(SourceLocation(),
                                                 SemaRef.getCurrentThisType(),
                                                 /*IsImplicit=*/true);
-      const CXXScopeSpec CS = CXXScopeSpec();
       Expr *ME = SemaRef.BuildMemberExpr(
           ThisExpr, /*IsArrow=*/true, SourceLocation(),
           NestedNameSpecifierLoc(), SourceLocation(), FD,
diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h
index f22951b8ed0fa8..b56d00a65187f3 100644
--- a/clang/lib/Sema/TreeTransform.h
+++ b/clang/lib/Sema/TreeTransform.h
@@ -5328,7 +5328,6 @@ bool TreeTransform<Derived>::TransformTemplateArguments(
         PackLocIterator;
 
       TemplateArgumentListInfo *PackOutput = &Outputs;
-      TemplateArgumentListInfo New;
 
       if (TransformTemplateArguments(
               PackLocIterator(*this, In.getArgument().pack_begin()),
diff --git a/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp 
b/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
index 5c6c2a4612b69b..38d1cab8ff71e9 100644
--- a/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
+++ b/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
@@ -1709,10 +1709,6 @@ PathDiagnosticPieceRef StoreSiteFinder::VisitNode(const 
ExplodedNode *Succ,
       !OriginSF->isParentOf(StoreSite->getStackFrame()))
     return nullptr;
 
-  // Okay, we've found the binding. Emit an appropriate message.
-  SmallString<256> sbuf;
-  llvm::raw_svector_ostream os(sbuf);
-
   StoreInfo SI = {StoreInfo::Assignment, // default kind
                   StoreSite,
                   InitE,
diff --git a/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp 
b/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
index e15fdad49331f6..d96135e4006ca4 100644
--- a/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
+++ b/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
@@ -2304,7 +2304,6 @@ bool ConstraintAssignor::assignSymExprToConst(const 
SymExpr *Sym,
   for (std::pair<EquivalenceClass, ClassSet> DisequalityEntry :
        DisequalityInfo) {
     EquivalenceClass Class = DisequalityEntry.first;
-    ClassSet DisequalClasses = DisequalityEntry.second;
     State = EquivalenceClass::simplify(Builder, RangeFactory, State, Class);
     if (!State)
       return false;
@@ -2985,7 +2984,6 @@ 
RangeConstraintManager::removeDeadBindings(ProgramStateRef State,
   SymbolSet::Factory &SetFactory = State->get_context<SymbolSet>();
 
   ConstraintRangeTy Constraints = State->get<ConstraintRange>();
-  ConstraintRangeTy NewConstraints = Constraints;
   ConstraintRangeTy::Factory &ConstraintFactory =
       State->get_context<ConstraintRange>();
 
diff --git a/clang/tools/cir-translate/cir-translate.cpp 
b/clang/tools/cir-translate/cir-translate.cpp
index cefa7d2996f300..c581076fc16dbd 100644
--- a/clang/tools/cir-translate/cir-translate.cpp
+++ b/clang/tools/cir-translate/cir-translate.cpp
@@ -97,7 +97,6 @@ llvm::LogicalResult prepareCIRModuleDataLayout(mlir::ModuleOp 
mod,
   llvm::IntrusiveRefCntPtr<clang::DiagnosticsEngine> diagnostics =
       new clang::DiagnosticsEngine(diagID, diagOpts,
                                    new clang::IgnoringDiagConsumer());
-  llvm::Triple triple(rawTriple);
   // TODO: Need to set various target options later to populate
   // 'TargetInfo' properly.
   clang::TargetOptions targetOptions;
diff --git a/clang/utils/TableGen/ClangOptionDocEmitter.cpp 
b/clang/utils/TableGen/ClangOptionDocEmitter.cpp
index 7924d5e5ca1c82..ba4f56dd653db0 100644
--- a/clang/utils/TableGen/ClangOptionDocEmitter.cpp
+++ b/clang/utils/TableGen/ClangOptionDocEmitter.cpp
@@ -64,8 +64,6 @@ static bool isOptionVisible(const Record *Option, const 
Record *DocInfo) {
 // Reorganize the records into a suitable form for emitting documentation.
 Documentation extractDocumentation(const RecordKeeper &Records,
                                    const Record *DocInfo) {
-  Documentation Result;
-
   // Build the tree of groups. The root in the tree is the fake option group
   // (Record*)nullptr, which contains all top-level groups and options.
   std::map<const Record *, std::vector<const Record *>> OptionsInGroup;

``````````

</details>


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

Reply via email to