Skip to content

[clang] Remove unused local variables (NFC) #138453

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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion clang/lib/CodeGen/CGBuiltin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1949,7 +1949,6 @@ RValue CodeGenFunction::emitBuiltinOSLogFormat(const CallExpr &E) {
analyze_os_log::OSLogBufferLayout Layout;
analyze_os_log::computeOSLogBufferLayout(Ctx, &E, Layout);
Address BufAddr = EmitPointerWithAlignment(E.getArg(0));
llvm::SmallVector<llvm::Value *, 4> RetainableOperands;

// Ignore argument 1, the format string. It is not currently used.
CallArgList Args;
Expand Down
1 change: 0 additions & 1 deletion clang/lib/CodeGen/CGCUDANV.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1194,7 +1194,6 @@ void CGNVCUDARuntime::transformManagedVars() {
// registered. The linker will provide a pointer to this section so we can
// register the symbols with the linked device image.
void CGNVCUDARuntime::createOffloadingEntries() {
SmallVector<char, 32> Out;
llvm::object::OffloadKind Kind = CGM.getLangOpts().HIP
? llvm::object::OffloadKind::OFK_HIP
: llvm::object::OffloadKind::OFK_Cuda;
Expand Down
1 change: 0 additions & 1 deletion clang/lib/CodeGen/CGDeclCXX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -748,7 +748,6 @@ void CodeGenModule::EmitCXXModuleInitFunc(Module *Primary) {
// Add any initializers with specified priority; this uses the same approach
// as EmitCXXGlobalInitFunc().
if (!PrioritizedCXXGlobalInits.empty()) {
SmallVector<llvm::Function *, 8> LocalCXXGlobalInits;
llvm::array_pod_sort(PrioritizedCXXGlobalInits.begin(),
PrioritizedCXXGlobalInits.end());
for (SmallVectorImpl<GlobalInitData>::iterator
Expand Down
2 changes: 0 additions & 2 deletions clang/lib/CodeGen/CGExpr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3955,8 +3955,6 @@ void CodeGenFunction::EmitCfiCheckFail() {
{CFITCK_UnrelatedCast, SanitizerKind::SO_CFIUnrelatedCast},
{CFITCK_ICall, SanitizerKind::SO_CFIICall}};

SmallVector<std::pair<llvm::Value *, SanitizerKind::SanitizerOrdinal>, 5>
Checks;
for (auto CheckKindOrdinalPair : CheckKinds) {
int Kind = CheckKindOrdinalPair.first;
SanitizerKind::SanitizerOrdinal Ordinal = CheckKindOrdinalPair.second;
Expand Down
1 change: 0 additions & 1 deletion clang/lib/CodeGen/CGExprAgg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1814,7 +1814,6 @@ void AggExprEmitter::VisitCXXParenListOrInitListExpr(

// We'll need to enter cleanup scopes in case any of the element
// initializers throws an exception.
SmallVector<EHScopeStack::stable_iterator, 16> cleanups;
CodeGenFunction::CleanupDeactivationScope DeactivateCleanups(CGF);

unsigned curInitIndex = 0;
Expand Down
1 change: 0 additions & 1 deletion clang/lib/CodeGen/CGHLSLRuntime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,6 @@ static void gatherFunctions(SmallVectorImpl<Function *> &Fns, llvm::Module &M,
// HLSL neither supports priorities or COMDat values, so we will check those
// in an assert but not handle them.

llvm::SmallVector<Function *> CtorFns;
for (const auto &Ctor : CA->operands()) {
if (isa<ConstantAggregateZero>(Ctor))
continue;
Expand Down
2 changes: 0 additions & 2 deletions clang/lib/CodeGen/CGObjCGNU.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3827,8 +3827,6 @@ void CGObjCGNU::GenerateClass(const ObjCImplementationDecl *OID) {
} else {
SuperClass = llvm::ConstantPointerNull::get(PtrToInt8Ty);
}
// Empty vector used to construct empty method lists
SmallVector<llvm::Constant*, 1> empty;
// Generate the method and instance variable lists
llvm::Constant *MethodList = GenerateMethodList(ClassName, "",
InstanceMethods, false);
Expand Down
1 change: 0 additions & 1 deletion clang/lib/CodeGen/CGStmtOpenMP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3495,7 +3495,6 @@ bool CodeGenFunction::EmitOMPWorksharingLoop(
Ordered = true;
}

llvm::DenseSet<const Expr *> EmittedFinals;
emitAlignedClause(*this, S);
bool HasLinears = EmitOMPLinearClauseInit(S);
// Emit helper vars inits.
Expand Down
1 change: 0 additions & 1 deletion clang/lib/Driver/ToolChains/CommonArgs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2533,7 +2533,6 @@ static void GetSDLFromOffloadArchive(

C.addTempFile(C.getArgs().MakeArgString(OutputLib));

ArgStringList CmdArgs;
SmallString<128> DeviceTriple;
DeviceTriple += Action::GetOffloadKindName(JA.getOffloadingDeviceKind());
DeviceTriple += '-';
Expand Down
1 change: 0 additions & 1 deletion clang/lib/Driver/ToolChains/HLSL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,6 @@ HLSLToolChain::TranslateArgs(const DerivedArgList &Args, StringRef BoundArch,
for (Arg *A : Args) {
if (A->getOption().getID() == options::OPT_dxil_validator_version) {
StringRef ValVerStr = A->getValue();
std::string ErrorMsg;
if (!isLegalValidatorVersion(ValVerStr, getDriver()))
continue;
}
Expand Down
1 change: 0 additions & 1 deletion clang/lib/Driver/ToolChains/OHOS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,6 @@ ToolChain::path_list OHOS::getRuntimePaths() const {

// Third try the effective triple.
P.assign(D.ResourceDir);
std::string SysRoot = computeSysRoot();
llvm::sys::path::append(P, "lib", getMultiarchTriple(Triple),
SelectedMultilib.gccSuffix());
Paths.push_back(P.c_str());
Expand Down
1 change: 0 additions & 1 deletion clang/lib/Frontend/InitPreprocessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -974,7 +974,6 @@ static void InitializePredefinedMacros(const TargetInfo &TI,

if (LangOpts.ObjCRuntime.getKind() == ObjCRuntime::GNUstep) {
auto version = LangOpts.ObjCRuntime.getVersion();
std::string versionString = "1";
// Don't rely on the tuple argument, because we can be asked to target
// later ABIs than we actually support, so clamp these values to those
// currently supported
Expand Down
1 change: 0 additions & 1 deletion clang/lib/Lex/PPDirectives.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3659,7 +3659,6 @@ void Preprocessor::HandleElifFamilyDirective(Token &ElifToken,
std::optional<LexEmbedParametersResult>
Preprocessor::LexEmbedParameters(Token &CurTok, bool ForHasEmbed) {
LexEmbedParametersResult Result{};
SmallVector<Token, 2> ParameterTokens;
tok::TokenKind EndTokenKind = ForHasEmbed ? tok::r_paren : tok::eod;

auto DiagMismatchedBracesAndSkipToEOD =
Expand Down
1 change: 0 additions & 1 deletion clang/lib/Parse/ParsePragma.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3455,7 +3455,6 @@ void PragmaSTDC_FENV_ROUNDHandler::HandlePragma(Preprocessor &PP,
PragmaIntroducer Introducer,
Token &Tok) {
Token PragmaName = Tok;
SmallVector<Token, 1> TokenList;
if (!PP.getTargetInfo().hasStrictFP() && !PP.getLangOpts().ExpStrictFP) {
PP.Diag(Tok.getLocation(), diag::warn_pragma_fp_ignored)
<< PragmaName.getIdentifierInfo()->getName();
Expand Down
1 change: 0 additions & 1 deletion clang/lib/Sema/SemaCodeComplete.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4837,7 +4837,6 @@ void SemaCodeCompletion::CodeCompleteAttribute(
// We skip this if the scope was already spelled and not guarded, or
// we must spell it and can't guard it.
if (!(InScope && !InScopeUnderscore) && SyntaxSupportsGuards) {
llvm::SmallString<32> Guarded;
if (Scope.empty()) {
Add(Scope, Name, /*Underscores=*/true);
} else {
Expand Down
1 change: 0 additions & 1 deletion clang/lib/Sema/SemaDeclAttr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -851,7 +851,6 @@ static void handleDiagnoseIfAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
}

StringRef WarningGroup;
SmallVector<StringRef, 2> Options;
if (AL.getNumArgs() > 3) {
if (!S.checkStringLiteralArgumentAttr(AL, 3, WarningGroup))
return;
Expand Down
1 change: 0 additions & 1 deletion clang/lib/Sema/SemaDeclObjC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3589,7 +3589,6 @@ ObjCMethodDecl *SemaObjC::LookupMethodInGlobalPool(Selector Sel, SourceRange R,

// Gather the non-hidden methods.
ObjCMethodList &MethList = instance ? Pos->second.first : Pos->second.second;
SmallVector<ObjCMethodDecl *, 4> Methods;
for (ObjCMethodList *M = &MethList; M; M = M->getNext()) {
if (M->getMethod() && M->getMethod()->isUnconditionallyVisible())
return M->getMethod();
Expand Down
1 change: 0 additions & 1 deletion clang/lib/Sema/SemaInit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5842,7 +5842,6 @@ static void TryOrBuildParenListInitialization(

if (const ArrayType *AT =
S.getASTContext().getAsArrayType(Entity.getType())) {
SmallVector<InitializedEntity, 4> ElementEntities;
uint64_t ArrayLength;
// C++ [dcl.init]p16.5
// if the destination type is an array, the object is initialized as
Expand Down
5 changes: 0 additions & 5 deletions clang/lib/Sema/SemaOpenMP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5777,7 +5777,6 @@ processImplicitMapsWithDefaultMappers(Sema &S, DSAStackTy *Stack,
// Check for the default mapper for data members.
if (S.getLangOpts().OpenMP < 50)
return;
SmallVector<OMPClause *, 4> ImplicitMaps;
for (int Cnt = 0, EndCnt = Clauses.size(); Cnt < EndCnt; ++Cnt) {
auto *C = dyn_cast<OMPMapClause>(Clauses[Cnt]);
if (!C)
Expand Down Expand Up @@ -14901,8 +14900,6 @@ StmtResult SemaOpenMP::ActOnOpenMPUnrollDirective(ArrayRef<OMPClause *> Clauses,
std::string OrigVarName = OrigVar->getNameInfo().getAsString();
std::string OuterIVName = (Twine(".unrolled.iv.") + OrigVarName).str();
std::string InnerIVName = (Twine(".unroll_inner.iv.") + OrigVarName).str();
std::string InnerTripCountName =
(Twine(".unroll_inner.tripcount.") + OrigVarName).str();

// Create the iteration variable for the unrolled loop.
VarDecl *OuterIVDecl =
Expand Down Expand Up @@ -15317,9 +15314,7 @@ StmtResult SemaOpenMP::ActOnOpenMPInterchangeDirective(

assert(LoopHelper.Counters.size() == 1 &&
"Single-dimensional loop iteration space expected");
auto *OrigCntVar = cast<DeclRefExpr>(LoopHelper.Counters.front());

std::string OrigVarName = OrigCntVar->getNameInfo().getAsString();
addLoopPreInits(Context, LoopHelper, LoopStmts[I], OriginalInits[I],
PreInits);
}
Expand Down
2 changes: 0 additions & 2 deletions clang/lib/Serialization/ASTReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10188,8 +10188,6 @@ void ASTReader::ReadComments() {
}
}
NextCursor:
llvm::DenseMap<FileID, std::map<unsigned, RawComment *>>
FileToOffsetToComment;
for (RawComment *C : Comments) {
SourceLocation CommentLoc = C->getBeginLoc();
if (CommentLoc.isValid()) {
Expand Down
1 change: 0 additions & 1 deletion clang/lib/Serialization/ASTWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5599,7 +5599,6 @@ void ASTWriter::PrepareWritingSpecialDecls(Sema &SemaRef) {
// Writing all of the tentative definitions in this file, in
// TentativeDefinitions order. Generally, this record will be empty for
// headers.
RecordData TentativeDefinitions;
AddLazyVectorDecls(*this, SemaRef.TentativeDefinitions);

// Writing all of the file scoped decls in this file.
Expand Down
1 change: 0 additions & 1 deletion clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,6 @@ const NoteTag *taintOriginTrackerTag(CheckerContext &C,
return C.getNoteTag([TaintedSymbols = std::move(TaintedSymbols),
TaintedArgs = std::move(TaintedArgs), CallLocation](
PathSensitiveBugReport &BR) -> std::string {
SmallString<256> Msg;
// We give diagnostics only for taint related reports
if (!BR.isInteresting(CallLocation) ||
BR.getBugType().getCategory() != categories::TaintedData) {
Expand Down
1 change: 0 additions & 1 deletion clang/lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -972,7 +972,6 @@ void NonLocalizedStringChecker::checkPostObjCMessage(const ObjCMethodCall &msg,
const IdentifierInfo *odInfo = OD->getIdentifier();

Selector S = msg.getSelector();
std::string SelectorName = S.getAsString();

std::pair<const IdentifierInfo *, Selector> MethodDescription = {odInfo, S};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,6 @@ static std::string getModuleContextHash(const ModuleDeps &MD,
llvm::vfs::FileSystem &VFS) {
llvm::HashBuilder<llvm::TruncatedBLAKE3<16>, llvm::endianness::native>
HashBuilder;
SmallString<32> Scratch;

// Hash the compiler version and serialization version to ensure the module
// will be readable.
Expand Down
1 change: 0 additions & 1 deletion clang/tools/libclang/CIndex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4689,7 +4689,6 @@ static const ExprEvalResult *evaluateExpr(Expr *expr, CXCursor C) {
if (ER.Val.isFloat()) {
llvm::SmallVector<char, 100> Buffer;
ER.Val.getFloat().toString(Buffer);
std::string floatStr(Buffer.data(), Buffer.size());
result->EvalType = CXEval_Float;
bool ignored;
llvm::APFloat apFloat = ER.Val.getFloat();
Expand Down
7 changes: 0 additions & 7 deletions clang/unittests/StaticAnalyzer/CallDescriptionTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -361,15 +361,8 @@ TEST(CallDescription, AliasNames) {
std::cont v;
v.data();
})code";
constexpr StringRef UseStructNameInSpelling = R"code(
void foo() {
std::container v;
v.data();
})code";
const std::string UseAliasInSpellingCode =
(Twine{AliasNamesCode} + UseAliasInSpelling).str();
const std::string UseStructNameInSpellingCode =
(Twine{AliasNamesCode} + UseStructNameInSpelling).str();

// Test if the code spells the alias, wile we match against the struct name,
// and again matching against the alias.
Expand Down
1 change: 0 additions & 1 deletion clang/utils/TableGen/ClangAttrEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4638,7 +4638,6 @@ static void GenerateSpellingIndexToSemanticSpelling(const Record &Attr,
// Generate the enumeration we will use for the mapping.
SemanticSpellingMap SemanticToSyntacticMap;
std::string Enum = CreateSemanticSpellings(Spellings, SemanticToSyntacticMap);
std::string Name = Attr.getName().str() + "AttrSpellingMap";

OS << "unsigned spellingIndexToSemanticSpelling(";
OS << "const ParsedAttr &Attr) const override {\n";
Expand Down
Loading