Skip to content

Commit 0542d15

Browse files
Remove redundant string initialization (NFC)
Identified with readability-redundant-string-init.
1 parent 7006d34 commit 0542d15

File tree

20 files changed

+28
-28
lines changed

20 files changed

+28
-28
lines changed

clang-tools-extra/clang-tidy/cert/LimitedRandomnessCheck.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ void LimitedRandomnessCheck::registerMatchers(MatchFinder *Finder) {
2424
}
2525

2626
void LimitedRandomnessCheck::check(const MatchFinder::MatchResult &Result) {
27-
std::string Msg = "";
27+
std::string Msg;
2828
if (getLangOpts().CPlusPlus)
2929
Msg = "; use C++11 random library instead";
3030

clang/lib/Basic/Targets/M68k.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ M68kTargetInfo::M68kTargetInfo(const llvm::Triple &Triple,
2929
const TargetOptions &)
3030
: TargetInfo(Triple) {
3131

32-
std::string Layout = "";
32+
std::string Layout;
3333

3434
// M68k is Big Endian
3535
Layout += "E";

clang/lib/Basic/Targets/PPC.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ class LLVM_LIBRARY_VISIBILITY PPC64TargetInfo : public PPCTargetInfo {
414414
LongWidth = LongAlign = PointerWidth = PointerAlign = 64;
415415
IntMaxType = SignedLong;
416416
Int64Type = SignedLong;
417-
std::string DataLayout = "";
417+
std::string DataLayout;
418418

419419
if (Triple.isOSAIX()) {
420420
// TODO: Set appropriate ABI for AIX platform.

clang/lib/CodeGen/CGOpenMPRuntime.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1434,7 +1434,7 @@ llvm::Value *CGOpenMPRuntime::emitUpdateLocation(CodeGenFunction &CGF,
14341434
Loc.isInvalid()) {
14351435
SrcLocStr = OMPBuilder.getOrCreateDefaultSrcLocStr();
14361436
} else {
1437-
std::string FunctionName = "";
1437+
std::string FunctionName;
14381438
if (const auto *FD = dyn_cast_or_null<FunctionDecl>(CGF.CurFuncDecl))
14391439
FunctionName = FD->getQualifiedNameAsString();
14401440
PresumedLoc PLoc = CGF.getContext().getSourceManager().getPresumedLoc(Loc);
@@ -9540,7 +9540,7 @@ emitMappingInformation(CodeGenFunction &CGF, llvm::OpenMPIRBuilder &OMPBuilder,
95409540
Loc = MapExprs.getMapDecl()->getLocation();
95419541
}
95429542

9543-
std::string ExprName = "";
9543+
std::string ExprName;
95449544
if (MapExprs.getMapExpr()) {
95459545
PrintingPolicy P(CGF.getContext().getLangOpts());
95469546
llvm::raw_string_ostream OS(ExprName);

clang/lib/Format/NamespaceEndCommentsFixer.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ std::string computeName(const FormatToken *NamespaceTok) {
2828
assert(NamespaceTok &&
2929
NamespaceTok->isOneOf(tok::kw_namespace, TT_NamespaceMacro) &&
3030
"expecting a namespace token");
31-
std::string name = "";
31+
std::string name;
3232
const FormatToken *Tok = NamespaceTok->getNextNonComment();
3333
if (NamespaceTok->is(TT_NamespaceMacro)) {
3434
// Collects all the non-comment tokens between opening parenthesis
@@ -224,7 +224,7 @@ std::pair<tooling::Replacements, unsigned> NamespaceEndCommentsFixer::analyze(
224224
return {Fixes, 0};
225225
}
226226

227-
std::string AllNamespaceNames = "";
227+
std::string AllNamespaceNames;
228228
size_t StartLineIndex = SIZE_MAX;
229229
StringRef NamespaceTokenText;
230230
unsigned int CompactedNamespacesCount = 0;

clang/lib/Frontend/InitHeaderSearch.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ void InitHeaderSearch::AddDefaultCIncludePaths(const llvm::Triple &triple,
354354
break;
355355
case llvm::Triple::PS4: {
356356
// <isysroot> gets prepended later in AddPath().
357-
std::string BaseSDKPath = "";
357+
std::string BaseSDKPath;
358358
if (!HasSysroot) {
359359
const char *envValue = getenv("SCE_ORBIS_SDK_DIR");
360360
if (envValue)

clang/lib/StaticAnalyzer/Checkers/ReturnValueChecker.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class ReturnValueChecker : public Checker<check::PostCall, check::EndFunction> {
5959
} // namespace
6060

6161
static std::string getName(const CallEvent &Call) {
62-
std::string Name = "";
62+
std::string Name;
6363
if (const auto *MD = dyn_cast<CXXMethodDecl>(Call.getDecl()))
6464
if (const CXXRecordDecl *RD = MD->getParent())
6565
Name += RD->getNameAsString() + "::";

clang/tools/clang-scan-deps/ClangScanDeps.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ int main(int argc, const char **argv) {
470470
AdjustingCompilations->appendArgumentsAdjuster(
471471
[&ResourceDirCache](const tooling::CommandLineArguments &Args,
472472
StringRef FileName) {
473-
std::string LastO = "";
473+
std::string LastO;
474474
bool HasResourceDir = false;
475475
bool ClangCLMode = false;
476476
auto FlagsEnd = llvm::find(Args, "--");

clang/utils/TableGen/NeonEmitter.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1473,7 +1473,7 @@ Intrinsic::DagEmitter::emitDagCall(DagInit *DI, bool MatchMangledName) {
14731473
Intr.Dependencies.insert(&Callee);
14741474

14751475
// Now create the call itself.
1476-
std::string S = "";
1476+
std::string S;
14771477
if (!Callee.isBigEndianSafe())
14781478
S += CallPrefix.str();
14791479
S += Callee.getMangledName(true) + "(";

lldb/source/Commands/CommandCompletions.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,7 @@ void CommandCompletions::VariablePath(CommandInterpreter &interpreter,
600600
void CommandCompletions::Registers(CommandInterpreter &interpreter,
601601
CompletionRequest &request,
602602
SearchFilter *searcher) {
603-
std::string reg_prefix = "";
603+
std::string reg_prefix;
604604
if (request.GetCursorArgumentPrefix().startswith("$"))
605605
reg_prefix = "$";
606606

lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1111,7 +1111,7 @@ DisassemblerLLVMC::DisassemblerLLVMC(const ArchSpec &arch,
11111111
triple.getSubArch() == llvm::Triple::NoSubArch)
11121112
triple.setArchName("armv8.7a");
11131113

1114-
std::string features_str = "";
1114+
std::string features_str;
11151115
const char *triple_str = triple.getTriple().c_str();
11161116

11171117
// ARM Cortex M0-M7 devices only execute thumb instructions

lldb/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ EmulateInstructionMIPS::EmulateInstructionMIPS(
137137
break;
138138
}
139139

140-
std::string features = "";
140+
std::string features;
141141
uint32_t arch_flags = arch.GetFlags();
142142
if (arch_flags & ArchSpec::eMIPSAse_msa)
143143
features += "+msa,";

lldb/source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ EmulateInstructionMIPS64::EmulateInstructionMIPS64(
137137
break;
138138
}
139139

140-
std::string features = "";
140+
std::string features;
141141
uint32_t arch_flags = arch.GetFlags();
142142
if (arch_flags & ArchSpec::eMIPSAse_msa)
143143
features += "+msa,";

lldb/source/Plugins/InstrumentationRuntime/MainThreadChecker/InstrumentationRuntimeMainThreadChecker.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -100,14 +100,14 @@ InstrumentationRuntimeMainThreadChecker::RetrieveReportData(
100100
if (!apiname_ptr)
101101
return StructuredData::ObjectSP();
102102

103-
std::string apiName = "";
103+
std::string apiName;
104104
Status read_error;
105105
target.ReadCStringFromMemory(apiname_ptr, apiName, read_error);
106106
if (read_error.Fail())
107107
return StructuredData::ObjectSP();
108108

109-
std::string className = "";
110-
std::string selector = "";
109+
std::string className;
110+
std::string selector;
111111
if (apiName.substr(0, 2) == "-[") {
112112
size_t spacePos = apiName.find(' ');
113113
if (spacePos != std::string::npos) {

lldb/source/Plugins/InstrumentationRuntime/TSan/InstrumentationRuntimeTSan.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -711,7 +711,7 @@ addr_t InstrumentationRuntimeTSan::GetMainRacyAddress(
711711
std::string InstrumentationRuntimeTSan::GetLocationDescription(
712712
StructuredData::ObjectSP report, addr_t &global_addr,
713713
std::string &global_name, std::string &filename, uint32_t &line) {
714-
std::string result = "";
714+
std::string result;
715715

716716
ProcessSP process_sp = GetProcessSP();
717717

@@ -820,8 +820,8 @@ bool InstrumentationRuntimeTSan::NotifyBreakpointHit(
820820
report->GetAsDictionary()->AddIntegerItem("memory_address", main_address);
821821

822822
addr_t global_addr = 0;
823-
std::string global_name = "";
824-
std::string location_filename = "";
823+
std::string global_name;
824+
std::string location_filename;
825825
uint32_t location_line = 0;
826826
std::string location_description = instance->GetLocationDescription(
827827
report, global_addr, global_name, location_filename, location_line);

lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ Status MinidumpFileBuilder::AddSystemInfo(const llvm::Triple &target_triple) {
115115
sys_info.PlatformId = platform_id;
116116
m_data.AppendData(&sys_info, sizeof(llvm::minidump::SystemInfo));
117117

118-
std::string csd_string = "";
118+
std::string csd_string;
119119

120120
error = WriteString(csd_string, &m_data);
121121
if (error.Fail()) {

lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -693,7 +693,7 @@ const UnixSignalsSP &PlatformRemoteGDBServer::GetRemoteUnixSignals() {
693693
if (object_sp && object_sp->IsValid())
694694
notify = object_sp->GetBooleanValue();
695695

696-
std::string description{""};
696+
std::string description;
697697
object_sp = dict->GetValueForKey("description");
698698
if (object_sp && object_sp->IsValid())
699699
description = std::string(object_sp->GetStringValue());

lldb/source/Target/RegisterContextUnwind.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1509,7 +1509,7 @@ RegisterContextUnwind::SavedLocationForRegister(
15091509
regnum.GetName(), regnum.GetAsKind(eRegisterKindLLDB));
15101510
return UnwindLLDB::RegisterSearchResult::eRegisterFound;
15111511
} else {
1512-
std::string unwindplan_name("");
1512+
std::string unwindplan_name;
15131513
if (m_full_unwind_plan_sp) {
15141514
unwindplan_name += "via '";
15151515
unwindplan_name += m_full_unwind_plan_sp->GetSourceName().AsCString();

llvm/lib/DebugInfo/DWARF/DWARFDebugAbbrev.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ std::string DWARFAbbreviationDeclarationSet::getCodeRange() const {
7474
for (const auto &Decl : Decls)
7575
Codes.push_back(Decl.getCode());
7676

77-
std::string Buffer = "";
77+
std::string Buffer;
7878
raw_string_ostream Stream(Buffer);
7979
// Each iteration through this loop represents a single contiguous range in
8080
// the set of codes.

llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ void AMDGPUTargetID::setTargetIDFromTargetIDStream(StringRef TargetID) {
410410
}
411411

412412
std::string AMDGPUTargetID::toString() const {
413-
std::string StringRep = "";
413+
std::string StringRep;
414414
raw_string_ostream StreamRep(StringRep);
415415

416416
auto TargetTriple = STI.getTargetTriple();
@@ -421,7 +421,7 @@ std::string AMDGPUTargetID::toString() const {
421421
<< TargetTriple.getOSName() << '-'
422422
<< TargetTriple.getEnvironmentName() << '-';
423423

424-
std::string Processor = "";
424+
std::string Processor;
425425
// TODO: Following else statement is present here because we used various
426426
// alias names for GPUs up until GFX9 (e.g. 'fiji' is same as 'gfx803').
427427
// Remove once all aliases are removed from GCNProcessors.td.
@@ -432,7 +432,7 @@ std::string AMDGPUTargetID::toString() const {
432432
Twine(Version.Stepping))
433433
.str();
434434

435-
std::string Features = "";
435+
std::string Features;
436436
if (Optional<uint8_t> HsaAbiVersion = getHsaAbiVersion(&STI)) {
437437
switch (*HsaAbiVersion) {
438438
case ELF::ELFABIVERSION_AMDGPU_HSA_V2:

0 commit comments

Comments
 (0)