From d1518c7b1c38a6b8c1cc45b885fd8cd29f4bd603 Mon Sep 17 00:00:00 2001 From: "Maksimova, Viktoria" Date: Wed, 28 Jun 2023 03:40:37 -0700 Subject: [PATCH] [PATCH 65/79] Fix clang-tidy warnings Gbp-Pq: Name 0065-Fix-clang-tidy-warnings.patch --- lib/SPIRV/LLVMToSPIRVDbgTran.cpp | 6 ++--- lib/SPIRV/SPIRVToLLVMDbgTran.cpp | 39 ++++++++++++++++---------------- 2 files changed, 23 insertions(+), 22 deletions(-) diff --git a/lib/SPIRV/LLVMToSPIRVDbgTran.cpp b/lib/SPIRV/LLVMToSPIRVDbgTran.cpp index 3937e18..d44b6b0 100644 --- a/lib/SPIRV/LLVMToSPIRVDbgTran.cpp +++ b/lib/SPIRV/LLVMToSPIRVDbgTran.cpp @@ -1440,7 +1440,7 @@ SPIRVExtInst *LLVMToSPIRVDbgTran::getSource(const T *DIEntry) { ->getId()); else if (BM->getDebugInfoEIS() == SPIRVEIS_NonSemantic_Shader_DebugInfo_200) { - SPIRVDebug::FileChecksumKind ChecksumKind = + const SPIRVDebug::FileChecksumKind ChecksumKind = SPIRV::DbgChecksumKindMap::map(CheckSum.Kind); Ops.push_back( @@ -1473,10 +1473,10 @@ SPIRVExtInst *LLVMToSPIRVDbgTran::getSource(const T *DIEntry) { if (NumWords < MaxNumWords) return Source; - uint64_t NumOfContinuedInstructions = + const uint64_t NumOfContinuedInstructions = NumWords / MaxNumWords - 1 + (NumWords % MaxNumWords ? 1 : 0); for (uint64_t J = 0; J < NumOfContinuedInstructions; J++) { - SPIRVWord Op = BM->getString(Str.substr(0, MaxStrSize))->getId(); + const SPIRVWord Op = BM->getString(Str.substr(0, MaxStrSize))->getId(); BM->addDebugInfo(SPIRVDebug::SourceContinued, getVoidTy(), {Op}); Str.erase(0, MaxStrSize); } diff --git a/lib/SPIRV/SPIRVToLLVMDbgTran.cpp b/lib/SPIRV/SPIRVToLLVMDbgTran.cpp index 6cba6b3..a1102cf 100644 --- a/lib/SPIRV/SPIRVToLLVMDbgTran.cpp +++ b/lib/SPIRV/SPIRVToLLVMDbgTran.cpp @@ -85,7 +85,7 @@ SPIRVToLLVMDbgTran::getDIFile(const std::string &FileName, // relations with other debug metadata is not going through DICompileUnit if (!Split.BaseName.empty()) { if (Source.hasValue()) { - StringRef SourceRef = StringRef(Source.getValue()); + const StringRef SourceRef = StringRef(Source.getValue()); return BuilderMap.begin()->second->createFile( Split.BaseName, Split.Path, CS, SourceRef); } @@ -149,7 +149,7 @@ SPIRVToLLVMDbgTran::getStringSourceContinued(const SPIRVId Id, std::string Str = BM->get(Id)->getStr(); using namespace SPIRVDebug::Operand::SourceContinued; for (auto *I : DebugInst->getContinuedInstructions()) { - std::string TmpStr = + const std::string TmpStr = BM->get(I->getArguments()[TextIdx])->getStr(); Str.append(TmpStr); } @@ -696,14 +696,14 @@ SPIRVToLLVMDbgTran::transTypeMemberNonSemantic(const SPIRVExtInst *DebugInst, assert(Ops.size() >= MinOperandCount && "Invalid number of operands"); DIFile *File = getFile(Ops[SourceIdx]); - SPIRVWord LineNo = + const SPIRVWord LineNo = getConstantValueOrLiteral(Ops, LineIdx, DebugInst->getExtSetKind()); - StringRef Name = getString(Ops[NameIdx]); + const StringRef Name = getString(Ops[NameIdx]); DIType *BaseType = transDebugInst(BM->get(Ops[TypeIdx])); - uint64_t OffsetInBits = + const uint64_t OffsetInBits = BM->get(Ops[OffsetIdx])->getZExtIntValue(); - SPIRVWord SPIRVFlags = + const SPIRVWord SPIRVFlags = getConstantValueOrLiteral(Ops, FlagsIdx, DebugInst->getExtSetKind()); DINode::DIFlags Flags = DINode::FlagZero; if ((SPIRVDebug::FlagAccess & SPIRVFlags) == SPIRVDebug::FlagIsPublic) { @@ -726,8 +726,8 @@ SPIRVToLLVMDbgTran::transTypeMemberNonSemantic(const SPIRVExtInst *DebugInst, return getDIBuilder(DebugInst).createStaticMemberType( Scope, Name, File, LineNo, BaseType, Flags, cast(Val)); } - uint64_t Size = BM->get(Ops[SizeIdx])->getZExtIntValue(); - uint64_t Alignment = 0; + const uint64_t Size = BM->get(Ops[SizeIdx])->getZExtIntValue(); + const uint64_t Alignment = 0; return getDIBuilder(ParentInst) .createMemberType(Scope, Name, File, LineNo, Size, Alignment, @@ -1164,7 +1164,8 @@ DINode *SPIRVToLLVMDbgTran::transTypeInheritance(const SPIRVExtInst *DebugInst, const SPIRVWordVec &Ops = DebugInst->getArguments(); assert(Ops.size() >= MinOperandCount && "Invalid number of operands"); // No Child operand for NonSemantic debug spec - SPIRVWord Offset = isNonSemanticDebugInfo(DebugInst->getExtSetKind()) ? 1 : 0; + const SPIRVWord Offset = + isNonSemanticDebugInfo(DebugInst->getExtSetKind()) ? 1 : 0; DIType *Parent = transDebugInst(BM->get(Ops[ParentIdx - Offset])); DIType *Child = @@ -1172,15 +1173,15 @@ DINode *SPIRVToLLVMDbgTran::transTypeInheritance(const SPIRVExtInst *DebugInst, ? ChildClass : transDebugInst(BM->get(Ops[ChildIdx])); DINode::DIFlags Flags = DINode::FlagZero; - SPIRVWord SPIRVFlags = getConstantValueOrLiteral(Ops, FlagsIdx - Offset, - DebugInst->getExtSetKind()); + const SPIRVWord SPIRVFlags = getConstantValueOrLiteral( + Ops, FlagsIdx - Offset, DebugInst->getExtSetKind()); if ((SPIRVFlags & SPIRVDebug::FlagAccess) == SPIRVDebug::FlagIsPublic) Flags |= llvm::DINode::FlagPublic; if ((SPIRVFlags & SPIRVDebug::FlagAccess) == SPIRVDebug::FlagIsProtected) Flags |= llvm::DINode::FlagProtected; if ((SPIRVFlags & SPIRVDebug::FlagAccess) == SPIRVDebug::FlagIsPrivate) Flags |= llvm::DINode::FlagPrivate; - uint64_t OffsetVal = + const uint64_t OffsetVal = BM->get(Ops[OffsetIdx - Offset])->getZExtIntValue(); return getDIBuilder(DebugInst).createInheritance(Child, Parent, OffsetVal, 0, Flags); @@ -1533,7 +1534,7 @@ DebugLoc SPIRVToLLVMDbgTran::transDebugScope(const SPIRVInstruction *Inst) { // If DebugLine and OpLine are both active give DebugLine priority if (auto DL = Inst->getDebugLine()) { using namespace SPIRVDebug::Operand::DebugLine; - SPIRVWordVec DebugLineArgs = DL->getArguments(); + const SPIRVWordVec DebugLineArgs = DL->getArguments(); Line = getConstantValueOrLiteral(DebugLineArgs, StartIdx, DL->getExtSetKind()); Col = getConstantValueOrLiteral(DebugLineArgs, ColumnStartIdx, @@ -1581,9 +1582,9 @@ MDNode *SPIRVToLLVMDbgTran::transDebugInlinedNonSemanticShader200( using namespace SPIRVDebug::Operand::InlinedAt::NonSemantic; SPIRVWordVec Ops = DebugInst->getArguments(); assert(Ops.size() >= MinOperandCount && "Invalid number of operands"); - SPIRVWord Line = + const SPIRVWord Line = getConstantValueOrLiteral(Ops, LineIdx, DebugInst->getExtSetKind()); - unsigned Col = + const unsigned Col = getConstantValueOrLiteral(Ops, ColumnIdx, DebugInst->getExtSetKind()); DILocalScope *Scope = cast(getScope(BM->getEntry(Ops[ScopeIdx]))); @@ -1613,7 +1614,7 @@ DIFile *SPIRVToLLVMDbgTran::getFile(const SPIRVId SourceId) { return getDIFile(getString(SourceArgs[FileIdx])); if (!isNonSemanticDebugInfo(Source->getExtSetKind())) { - std::string ChecksumStr = + const std::string ChecksumStr = getDbgInst(SourceArgs[TextIdx]) ? "" : getString(SourceArgs[TextIdx]); @@ -1629,12 +1630,12 @@ DIFile *SPIRVToLLVMDbgTran::getFile(const SPIRVId SourceId) { // go together if (!getDbgInst(SourceArgs[ChecksumKind]) && !getDbgInst(SourceArgs[ChecksumValue])) { - llvm::DIFile::ChecksumKind Kind = SPIRV::DbgChecksumKindMap::rmap( + const llvm::DIFile::ChecksumKind Kind = SPIRV::DbgChecksumKindMap::rmap( static_cast( BM->get(SourceArgs[ChecksumKind]) ->getZExtIntValue())); - StringRef Checksum = getString(SourceArgs[ChecksumValue]); - size_t ChecksumEndPos = Checksum.find_if_not(llvm::isHexDigit); + const StringRef Checksum = getString(SourceArgs[ChecksumValue]); + const size_t ChecksumEndPos = Checksum.find_if_not(llvm::isHexDigit); CS.emplace(Kind, Checksum.substr(0, ChecksumEndPos)); } } -- 2.30.2