Skip to content

Commit 581c473

Browse files
committed
[NFC] Fix formatv() usage in preparation of validation
Fix several uses of formatv() that would be flagged as invalid by an upcoming change that will add additional validation to formatv().
1 parent eb9c49c commit 581c473

File tree

10 files changed

+19
-24
lines changed

10 files changed

+19
-24
lines changed

clang/lib/StaticAnalyzer/Checkers/CheckPlacementNew.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ bool PlacementNewChecker::checkPlaceCapacityIsSufficient(
131131
"Storage provided to placement new is only {0} bytes, "
132132
"whereas the allocated array type requires more space for "
133133
"internal needs",
134-
SizeOfPlaceCI->getValue(), SizeOfTargetCI->getValue()));
134+
SizeOfPlaceCI->getValue()));
135135
else
136136
Msg = std::string(llvm::formatv(
137137
"Storage provided to placement new is only {0} bytes, "

lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -655,7 +655,7 @@ DWARFUnit::GetDIE(dw_offset_t die_offset) {
655655

656656
if (!ContainsDIEOffset(die_offset)) {
657657
GetSymbolFileDWARF().GetObjectFile()->GetModule()->ReportError(
658-
"GetDIE for DIE {0:x16} is outside of its CU {0:x16}", die_offset,
658+
"GetDIE for DIE {0:x16} is outside of its CU {1:x16}", die_offset,
659659
GetOffset());
660660
return DWARFDIE(); // Not found
661661
}

llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1518,8 +1518,7 @@ DWARFVerifier::verifyNameIndexAbbrevs(const DWARFDebugNames::NameIndex &NI) {
15181518
error() << formatv("NameIndex @ {0:x}: Indexing multiple compile units "
15191519
"and abbreviation {1:x} has no DW_IDX_compile_unit "
15201520
"or DW_IDX_type_unit attribute.\n",
1521-
NI.getUnitOffset(), Abbrev.Code,
1522-
dwarf::DW_IDX_compile_unit);
1521+
NI.getUnitOffset(), Abbrev.Code);
15231522
});
15241523
++NumErrors;
15251524
}

llvm/tools/llvm-pdbutil/ExplainOutputStyle.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,8 @@ bool ExplainOutputStyle::explainPdbBlockStatus() {
139139
FileOffset, File.pdb().getFileSize());
140140
return false;
141141
}
142-
P.formatLine("Block:Offset = {2:X-}:{1:X-4}.", FileOffset, pdbBlockOffset(),
143-
pdbBlockIndex());
142+
P.formatLine("Block:Offset = {0:X-}:{1:X-4}.", pdbBlockIndex(),
143+
pdbBlockOffset());
144144

145145
bool IsFree = File.pdb().getMsfLayout().FreePageMap[pdbBlockIndex()];
146146
P.formatLine("Address is in block {0} ({1}allocated).", pdbBlockIndex(),

llvm/utils/TableGen/IntrinsicEmitter.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -735,8 +735,8 @@ Intrinsic::getIntrinsicFor{1}Builtin(StringRef TargetPrefix,
735735
const auto &[Map, CommonPrefix] = Entry;
736736
if (TargetPrefix.empty())
737737
continue;
738-
OS << formatv(R"( {{"{0}", {0}Names, "{2}"},)", TargetPrefix,
739-
TargetPrefix, CommonPrefix)
738+
OS << formatv(R"( {{"{0}", {0}Names, "{1}"},)", TargetPrefix,
739+
CommonPrefix)
740740
<< "\n";
741741
}
742742
OS << " };\n";

mlir/tools/mlir-linalg-ods-gen/mlir-linalg-ods-yaml-gen.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -634,7 +634,7 @@ ArrayAttr {0}::getIndexingMaps() {{
634634
MLIRContext *context = getContext();
635635
auto symbolBindings = getSymbolBindings(*this);
636636
SmallVector<AffineMap> maps;
637-
{2}
637+
{1}
638638
cached = Builder(context).getAffineMapArrayAttr(maps);
639639
getOperation()->setAttr(memoizeAttr, cached);
640640
return cached;
@@ -929,7 +929,7 @@ exprs.push_back(getAffineConstantExpr(cst{1}, context));
929929
// TODO: This needs to be memoized and/or converted to non-parser based
930930
// C++ codegen prior to real use.
931931
os << llvm::formatv(structuredOpIndexingMapsFormat, className,
932-
dimIdentsStr, interleaveToString(stmts, "\n "));
932+
interleaveToString(stmts, "\n "));
933933
}
934934
} else {
935935
os << llvm::formatv(rankPolyStructuredOpIndexingMapsFormat, className);

mlir/tools/mlir-tblgen/LLVMIRConversionGen.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,7 @@ static void emitOneCEnumFromConversion(const llvm::Record *record,
519519
os << formatv(
520520
"inline LLVM_ATTRIBUTE_UNUSED {0}::{1} convert{1}FromLLVM(int64_t "
521521
"value) {{\n",
522-
cppNamespace, cppClassName, llvmClass);
522+
cppNamespace, cppClassName);
523523
os << " switch (value) {\n";
524524

525525
for (const auto &enumerant : enumAttr.getAllCases()) {

mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1378,7 +1378,7 @@ void OpEmitter::genPropertiesSupport() {
13781378
::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) -> ::mlir::LogicalResult {{
13791379
{0}
13801380
};
1381-
{2};
1381+
{1};
13821382
)decl";
13831383
const char *attrGetNoDefaultFmt = R"decl(;
13841384
if (attr && ::mlir::failed(setFromAttr(prop.{0}, attr, emitError)))
@@ -1419,7 +1419,7 @@ void OpEmitter::genPropertiesSupport() {
14191419
&fctx.addSubst("_attr", propertyAttr)
14201420
.addSubst("_storage", propertyStorage)
14211421
.addSubst("_diag", propertyDiag)),
1422-
name, getAttr);
1422+
getAttr);
14231423
if (prop.hasStorageTypeValueOverride()) {
14241424
setPropMethod << formatv(attrGetDefaultFmt, name,
14251425
prop.getStorageTypeValueOverride());
@@ -2768,11 +2768,10 @@ void OpEmitter::genInferredTypeCollectiveParamBuilder() {
27682768
<< "u && \"mismatched number of return types\");";
27692769
body << "\n " << builderOpState << ".addTypes(inferredReturnTypes);";
27702770

2771-
body << formatv(R"(
2772-
} else {{
2771+
body << R"(
2772+
} else {
27732773
::llvm::report_fatal_error("Failed to infer result type(s).");
2774-
})",
2775-
opClass.getClassName(), builderOpState);
2774+
})";
27762775
}
27772776

27782777
void OpEmitter::genUseOperandAsResultTypeSeparateParamBuilder() {
@@ -3882,7 +3881,7 @@ void OpEmitter::genSuccessorVerifier(MethodBody &body) {
38823881

38833882
auto getSuccessor =
38843883
formatv(successor.isVariadic() ? "{0}()" : getSingleSuccessor,
3885-
successor.name, it.index())
3884+
successor.name)
38863885
.str();
38873886
auto constraintFn =
38883887
staticVerifierEmitter.getSuccessorConstraintFn(successor.constraint);

mlir/tools/mlir-tblgen/OpFormatGen.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1122,7 +1122,7 @@ static void genCustomDirectiveParser(CustomDirective *dir, MethodBody &body,
11221122
" {0}Operands.append(subRange.begin(), subRange.end());\n"
11231123
" {0}OperandGroupSizes.push_back(subRange.size());\n"
11241124
" }\n",
1125-
var->name, var->constraint.getVariadicOfVariadicSegmentSizeAttr());
1125+
var->name);
11261126
}
11271127
} else if (auto *dir = dyn_cast<TypeDirective>(param)) {
11281128
ArgumentLengthKind lengthKind;
@@ -1575,9 +1575,7 @@ void OperationFormat::genElementParser(FormatElement *element, MethodBody &body,
15751575
ArgumentLengthKind lengthKind = getArgumentLengthKind(operand->getVar());
15761576
StringRef name = operand->getVar()->name;
15771577
if (lengthKind == ArgumentLengthKind::VariadicOfVariadic)
1578-
body << llvm::formatv(
1579-
variadicOfVariadicOperandParserCode, name,
1580-
operand->getVar()->constraint.getVariadicOfVariadicSegmentSizeAttr());
1578+
body << llvm::formatv(variadicOfVariadicOperandParserCode, name);
15811579
else if (lengthKind == ArgumentLengthKind::Variadic)
15821580
body << llvm::formatv(variadicOperandParserCode, name);
15831581
else if (lengthKind == ArgumentLengthKind::Optional)

mlir/tools/mlir-tblgen/SPIRVUtilsGen.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -780,8 +780,7 @@ static void emitSerializationFunction(const Record *attrClass,
780780
os << formatv(" (void)emitDebugLine(functionBody, {0}.getLoc());\n",
781781
opVar);
782782
os << formatv(" (void)encodeInstructionInto("
783-
"functionBody, spirv::Opcode::{1}, {2});\n",
784-
op.getQualCppClassName(),
783+
"functionBody, spirv::Opcode::{0}, {1});\n",
785784
record->getValueAsString("spirvOpName"), operands);
786785
}
787786

0 commit comments

Comments
 (0)